/* ============================================================================
   BOARDS -- the drawing layer for `ui/kit.js` and the per-game renderers.
   ==========================================================================

   Loaded on TOP of whichever page stylesheet is in play, so it uses that
   page's variables (--bg, --panel, --line, --ink, --dim, --accent) and never
   redefines them. The arena and the study build look different on purpose and
   the boards should inherit that difference rather than override it.

   ON COLOUR. Four seat hues exist and NONE of them carries meaning on its
   own: every coloured mark in the kit is drawn with the seat's name beside
   it, and `KIT.actions` gives every option in a row the same class. A reader
   who cannot separate the blue from the violet loses nothing but decoration.
   The one place colour is load-bearing is a fill's LENGTH, which is a
   position, not a hue.
   ============================================================================ */

:root {
  --s0: #7aa2f7;   /* seat 0 -- also the page accent */
  --s1: #e0af68;   /* seat 1 */
  --s2: #9ece6a;   /* seat 2 */
  --s3: #bb9af7;   /* seat 3 */
  --felt:  #1a2b22;
  --edge:  #39404c;
  --good:  #9ece6a;
  --bad:   #f7768e;
}

.bd { display: flex; flex-direction: column; gap: 1rem; }

/* ── header strip ─────────────────────────────────────────────────────── */
.bd-head {
  display: flex; align-items: center; gap: .8rem; flex-wrap: wrap;
  padding-bottom: .7rem; border-bottom: 1px solid var(--line);
}
.bd-where { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; }
.bd-pill {
  font-size: .74rem; letter-spacing: .06em; text-transform: uppercase;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 999px; padding: .18rem .6rem; color: var(--dim);
  white-space: nowrap;
}
.bd-title { font-weight: 600; }
.bd-sub { color: var(--dim); font-size: .86rem; }

.bd-scores { display: flex; gap: .45rem; margin-left: auto; flex-wrap: wrap; }
.bd-score {
  display: flex; align-items: baseline; gap: .35rem;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: .2rem .55rem; font-size: .82rem;
}
.bd-score .nm { color: var(--dim); }
.bd-score b { font-variant-numeric: tabular-nums; }
.bd-score.mine { border-color: var(--accent); }
.bd-score.mine .nm { color: var(--ink); }

/* ── panels ───────────────────────────────────────────────────────────── */
.bd-panels {
  display: grid; gap: .9rem;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  align-items: start;
}
.bd-panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .8rem .9rem;
}
.bd-panel.wide { grid-column: 1 / -1; }
.bd-panel-h {
  font-size: .72rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--dimmer); margin-bottom: .6rem;
}
.bd-note { color: var(--dim); font-size: .86rem; margin: .35rem 0; }
.bd-note.warn { color: var(--warm); }
.bd-note b, .bd-note strong { color: var(--ink); }

/* ── the action area, always last and always distinct ─────────────────── */
.bd-act {
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: var(--radius); background: var(--panel-2);
  padding: .9rem 1rem; display: flex; flex-direction: column; gap: .75rem;
}
.bd-act .bd-panel-h { margin-bottom: 0; }

.bd-buttons { display: flex; gap: .5rem; flex-wrap: wrap; }
/* Every legal option is this class. There is no variant. */
.bd-opt {
  min-width: 6.5rem; padding: .55rem 1rem; text-transform: lowercase;
  background: var(--panel); border: 1px solid var(--edge);
}
.bd-opt:hover { border-color: var(--accent); }
.bd-opt.on { border-color: var(--accent); background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--accent); }
.bd-submit { border-color: var(--accent); font-weight: 600; align-self: flex-start; }
.bd-send { white-space: nowrap; }

/* ── dial ─────────────────────────────────────────────────────────────── */
.bd-dial .lab, .bd-textbox .lab, .bd-meter .lab {
  font-size: .78rem; color: var(--dim); margin-bottom: .3rem;
}
.bd-dial .row { display: flex; align-items: stretch; gap: .3rem; }
.bd-dial input[type=number] {
  width: 6rem; text-align: center; font: inherit;
  font-variant-numeric: tabular-nums;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; padding: .4rem;
}
.bd-dial .step { padding: .4rem .7rem; min-width: 2.2rem; }
.bd-dial input[type=range] { width: 100%; margin-top: .5rem; accent-color: var(--accent); }
.bd-dial .hint { color: var(--dimmer); font-size: .76rem; margin-top: .3rem; }

.bd-textbox .row { display: flex; gap: .4rem; }
.bd-textbox input[type=text] {
  flex: 1; padding: .5rem .65rem; background: var(--bg); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; font: inherit;
}
.bd-textbox input:focus, .bd-dial input:focus { outline: none; border-color: var(--accent); }

/* ── meters and bars ──────────────────────────────────────────────────── */
.bd-meter .track {
  position: relative; height: 14px; border-radius: 7px;
  background: var(--bg); border: 1px solid var(--line); overflow: visible;
}
.bd-meter .fill {
  height: 100%; border-radius: 6px 4px 4px 6px; background: var(--s0);
  transition: width .25s;
}
.bd-meter .fill.warn { background: var(--s1); }
.bd-meter .fill.bad  { background: var(--bad); }
.bd-meter .fill.good { background: var(--good); }
.bd-meter .mark {
  position: absolute; top: -4px; bottom: -4px; width: 2px;
  background: var(--ink); opacity: .65;
}
.bd-meter .mark::after {
  content: attr(data-lab); position: absolute; top: -1.15rem; left: 50%;
  transform: translateX(-50%); font-size: .68rem; color: var(--dim);
  white-space: nowrap;
}
.bd-meter .val {
  margin-top: .3rem; font-size: .82rem; color: var(--dim);
  font-variant-numeric: tabular-nums;
}

.bd-bars { display: flex; flex-direction: column; gap: .35rem; }
.bd-bar { display: grid; grid-template-columns: 5.2rem 1fr 2.6rem; gap: .5rem; align-items: center; }
.bd-bar .nm { color: var(--dim); font-size: .82rem; }
.bd-bar .track { height: 10px; border-radius: 5px; background: var(--bg); border: 1px solid var(--line); display: block; }
.bd-bar .fill { display: block; height: 100%; border-radius: 4px; background: var(--dim); }
.bd-bar b { text-align: right; font-size: .84rem; font-variant-numeric: tabular-nums; }
.bd-bar .fill.s0 { background: var(--s0); }
.bd-bar .fill.s1 { background: var(--s1); }
.bd-bar .fill.s2 { background: var(--s2); }
.bd-bar .fill.s3 { background: var(--s3); }
.bd-bar .fill.neutral { background: var(--dim); }

/* ── cards ────────────────────────────────────────────────────────────── */
.bd-cards { display: flex; gap: .4rem; flex-wrap: wrap; align-items: flex-end; }
.bd-card {
  position: relative; width: 54px; height: 76px; border-radius: 7px;
  background: #f2efe6; color: #1b1e24; border: 1px solid #cfc9bb;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; box-shadow: 0 1px 3px rgba(0,0,0,.35);
}
.bd-card.small { width: 40px; height: 56px; }
.bd-card .pip { font-size: 1.5rem; line-height: 1; }
.bd-card.small .pip { font-size: 1.1rem; }
.bd-card .corner {
  position: absolute; top: 3px; left: 5px; font-size: .68rem; font-weight: 700;
}
.bd-card .sub {
  position: absolute; bottom: 3px; right: 5px; font-size: .62rem;
  font-weight: 600; opacity: .75;
}
.bd-card.pick { cursor: pointer; }
.bd-card.pick:hover { outline: 2px solid var(--accent); outline-offset: 1px; }
.bd-card.back { background: var(--panel-2); border-color: var(--edge); }
.bd-card.back .weave {
  position: absolute; inset: 5px; border-radius: 4px;
  background: repeating-linear-gradient(135deg, var(--line) 0 4px, transparent 4px 8px);
}
/* Hanabi colours. The letter stays on the card, so the hue is a second cue. */
.bd-card.R { background: #f8dcdc; border-color: #d99a9a; }
.bd-card.Y { background: #f7f0cf; border-color: #cfc07a; }
.bd-card.G { background: #dcf0dc; border-color: #96c396; }
.bd-card.B { background: #d9e5f8; border-color: #93aad4; }
.bd-card.W { background: #f0f0f2; border-color: #b9b9c0; }
.bd-card.unknown { background: var(--panel-2); color: var(--dim); border-color: var(--edge); }
.bd-card.hint { box-shadow: 0 0 0 2px var(--accent), 0 1px 3px rgba(0,0,0,.35); }

/* ── dice ─────────────────────────────────────────────────────────────── */
.bd-dice { display: flex; gap: .4rem; flex-wrap: wrap; }
.bd-diewrap { display: inline-flex; }
.bd-die { width: 40px; height: 40px; }
.bd-die .body { fill: #f2efe6; stroke: #cfc9bb; }
.bd-die .pip  { fill: #1b1e24; }
.bd-die.lit .body { fill: #fff3d0; stroke: var(--s1); stroke-width: 2; }

/* ── tiles, crates, coins, chips ──────────────────────────────────────── */
.bd-tile {
  position: relative; width: 42px; height: 42px; border-radius: 6px;
  background: #e9e0c8; color: #241f16;
  border: 1px solid #c7b894; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.15rem; box-shadow: 0 1px 2px rgba(0,0,0,.35);
}
.bd-tile .v { position: absolute; bottom: 2px; right: 4px; font-size: .6rem; font-weight: 600; opacity: .7; }
.bd-tile.dim { opacity: .35; }
.bd-tile.lit { outline: 2px solid var(--accent); outline-offset: 1px; }

.bd-crates { display: flex; gap: .5rem; align-items: flex-end; }
.bd-crate {
  position: relative; width: 46px; border-radius: 4px;
  background: linear-gradient(#8a6f47, #6b5637);
  border: 1px solid #a68a5b; display: flex; align-items: center; justify-content: center;
}
.bd-crate::before {
  content: ''; position: absolute; inset: 5px; border: 1px solid rgba(0,0,0,.25);
  border-radius: 2px;
}
.bd-crate .v { position: relative; font-weight: 700; font-size: .9rem; color: #fdf6e6; }
.bd-crate .tag {
  position: absolute; bottom: -1.15rem; left: 0; right: 0; text-align: center;
  font-size: .64rem; color: var(--dim);
}
.bd-crate.small { background: linear-gradient(#6d5a3c, #55452c); }

.bd-coins { display: flex; align-items: center; gap: .45rem; }
.bd-coins .stack {
  width: 20px; height: 20px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f3d68a, #b8912f);
  border: 1px solid #8a6c20;
  box-shadow: 0 2px 0 -1px #8a6c20, 0 4px 0 -2px #8a6c20;
}
.bd-coins b { font-variant-numeric: tabular-nums; }
.bd-coins .lab { color: var(--dim); font-size: .8rem; }

.bd-chip {
  display: inline-flex; align-items: baseline; gap: .35rem;
  border: 1px solid var(--line); border-radius: 999px;
  padding: .15rem .6rem; font-size: .84rem; background: var(--panel);
}
.bd-chip.up b { color: var(--good); }
.bd-chip.down b { color: var(--bad); }
.bd-chip span { color: var(--dim); font-size: .78rem; }

/* ── track & ring ─────────────────────────────────────────────────────── */
.bd-track { display: flex; gap: .3rem; flex-wrap: wrap; }
.bd-track .step {
  min-width: 44px; padding: .35rem .35rem .3rem; border-radius: 8px;
  background: var(--bg); border: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; gap: .1rem;
}
.bd-track .step .n { font-weight: 600; font-size: .9rem; }
.bd-track .step .sub { font-size: .68rem; color: var(--dim); }
.bd-track .step .tag { font-size: .62rem; color: var(--dimmer); }
.bd-track .step.now { border-color: var(--accent); background: var(--panel-2); }
.bd-track .step.done { opacity: .72; }
.bd-track .step.mine { border-color: var(--s2); }
.bd-track .step.theirs { border-color: var(--s1); }
.bd-track .step.pick { cursor: pointer; }
.bd-track .step.pick:hover { border-color: var(--accent); }

.bd-ring { width: 184px; height: 184px; }
.bd-ring .node { fill: var(--panel-2); stroke: var(--edge); stroke-width: 1.5; }
.bd-ring .node.me { stroke: var(--accent); stroke-width: 2.5; }
.bd-ring .nm { fill: var(--ink); font-size: 10px; text-anchor: middle; font-weight: 600; }
.bd-ring .sub { fill: var(--dim); font-size: 9px; text-anchor: middle; }
.bd-ring .arrow { stroke: var(--dim); stroke-width: 1.5; opacity: .7; }
.bd-ring .arrowhead { fill: var(--dim); }

/* ── tables & logs ────────────────────────────────────────────────────── */
.bd-table { border-collapse: collapse; font-size: .82rem; width: 100%; }
.bd-table th, .bd-table td {
  padding: .28rem .5rem; text-align: right; border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.bd-table th:first-child, .bd-table td:first-child { text-align: left; }
.bd-table thead th { color: var(--dimmer); font-weight: 600; font-size: .72rem;
  text-transform: uppercase; letter-spacing: .05em; }
.bd-table tbody tr:last-child td { border-bottom: none; }
.bd-table tr.mine td { color: var(--ink); }
.bd-table tr.mine td:first-child { color: var(--accent); }

.bd-log { display: flex; flex-direction: column; gap: .15rem; font-size: .78rem; }
.bd-log .ln { color: var(--dim); font-family: ui-monospace, Menlo, Consolas, monospace; }
.bd-log .ln.dim { color: var(--dimmer); font-style: italic; font-family: inherit; }

.bd-matrix { border-collapse: collapse; font-size: .8rem; }
.bd-matrix th, .bd-matrix td {
  border: 1px solid var(--line); padding: .3rem .55rem; text-align: center;
}
.bd-matrix thead th { color: var(--dimmer); font-weight: 600; }
.bd-matrix tbody th { color: var(--dim); font-weight: 600; text-align: left; }
.bd-matrix .me { color: var(--ink); font-weight: 600; }
.bd-matrix .sep { color: var(--dimmer); margin: 0 .15rem; }
.bd-matrix .them { color: var(--dim); }

.bd-quote {
  border-left: 2px solid var(--edge); padding: .1rem 0 .1rem .7rem;
  margin: .3rem 0;
}
.bd-quote .who { font-size: .72rem; color: var(--dimmer); text-transform: uppercase; letter-spacing: .05em; }
.bd-quote .txt { color: var(--ink); font-size: .88rem; }

/* ── grids (battleship, sonar) ────────────────────────────────────────── */
.bd-grid { display: inline-grid; gap: 2px; }
.bd-sq {
  width: 30px; height: 30px; border-radius: 4px; background: var(--bg);
  border: 1px solid var(--line); display: flex; align-items: center;
  justify-content: center; font-size: .72rem; color: var(--dim);
}
.bd-sq.pick { cursor: pointer; }
.bd-sq.pick:hover { border-color: var(--accent); color: var(--ink); }
.bd-sq.mine { background: var(--panel-2); border-color: var(--s0); color: var(--ink); }
.bd-sq.hit  { background: #4a2530; border-color: var(--bad); color: var(--ink); }
.bd-sq.miss { background: var(--panel); border-color: var(--edge); color: var(--dimmer); }
.bd-sq.target { border-color: var(--s1); }
.bd-sq.head { border: none; background: none; color: var(--dimmer); font-size: .68rem; }

.bd-legend { display: flex; gap: .8rem; flex-wrap: wrap; font-size: .74rem; color: var(--dim); }
.bd-legend .key { display: inline-flex; align-items: center; gap: .3rem; }
.bd-legend .sw { width: 10px; height: 10px; border-radius: 3px; border: 1px solid var(--line); display: inline-block; }
.bd-legend .sw.s0 { background: var(--s0); }
.bd-legend .sw.s1 { background: var(--s1); }
.bd-legend .sw.s2 { background: var(--s2); }
.bd-legend .sw.s3 { background: var(--s3); }

.bd-rows { display: flex; flex-direction: column; gap: .4rem; }
.bd-row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.bd-kv { display: flex; gap: .35rem; align-items: baseline; font-size: .84rem; }
.bd-kv .k { color: var(--dim); }
.bd-kv .v { font-weight: 600; font-variant-numeric: tabular-nums; }
.bd-big { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.bd-hero { display: flex; align-items: baseline; gap: .5rem; }
.bd-hero .lab { color: var(--dim); font-size: .8rem; }
