/* ───────────────────────────── tokens ───────────────────────────── */
:root {
  --bg:        #302e2b;
  --panel:     #262522;
  --panel-2:   #21201d;
  --panel-3:   #1b1a18;
  --line:      #3d3a36;
  --line-soft: #34312d;
  --text:      #ece9e3;
  --muted:     #a6a19a;
  --accent:    #81b64c;
  --accent-hi: #9dd45f;
  --accent-ink:#14240a;
  --danger:    #d36c5d;
  --warn:      #e8b64c;
  --light-sq:  #ebecd0;
  --dark-sq:   #739552;
  --sel:       rgba(255, 241, 105, .58);
  --last:      rgba(255, 241, 105, .42);
  --pre:       rgba(226, 124, 84, .62);
  --radius:    10px;
  --boardmax:  calc(100dvh - 292px);
  --board:     min(var(--boardmax), 100%);
  --shadow:    0 10px 30px rgba(0,0,0,.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
h1, h2, h3 { margin: 0 0 .5rem; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: .82rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-top: 1.25rem; }
p  { margin: 0 0 .6rem; }
b  { font-weight: 700; }
code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .9em; background: var(--panel-3); padding: .1em .35em; border-radius: 4px; }
.muted { color: var(--muted); }
.small, .muted.small { font-size: .82rem; }
.hidden { display: none !important; }
.spacer { flex: 1; }

/* ───────────────────────────── controls ───────────────────────────── */
.btn {
  appearance: none; border: 0; cursor: pointer; font: inherit; font-weight: 600;
  border-radius: 8px; padding: .5rem .9rem; color: var(--text);
  background: #3b3835; transition: background .12s, transform .06s, opacity .12s;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
}
.btn:hover { background: #474340; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .42; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 3px 0 #5f8c36; }
.btn.primary:hover { background: var(--accent-hi); }
.btn.primary:active { box-shadow: 0 1px 0 #5f8c36; }
.btn.danger { background: #4a2d29; color: #f0b3a9; }
.btn.danger:hover { background: #5d372f; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.btn.ghost:hover { background: #33302c; color: var(--text); }
.btn.big { width: 100%; padding: .75rem; font-size: 1.02rem; margin-top: .9rem; }
.btn.small { padding: .36rem .65rem; font-size: .85rem; }
.btn.tiny { padding: .2rem .5rem; font-size: .74rem; border-radius: 6px; }
.btn.icon { width: 36px; height: 36px; padding: 0; font-size: 1.05rem; }
.btn.file { position: relative; overflow: hidden; }
.btn.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.field { display: block; margin-bottom: .7rem; }
.field > span { display: block; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: .25rem; }
.field > span i { text-transform: none; letter-spacing: 0; font-style: normal; opacity: .7; }
input[type=text], input[type=number], input:not([type]), select {
  width: 100%; padding: .55rem .65rem; border-radius: 8px; font: inherit;
  background: var(--panel-3); color: var(--text); border: 1px solid var(--line);
}
input:focus, select:focus, .btn:focus-visible, .board:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.check { display: flex; gap: .55rem; align-items: flex-start; margin: .5rem 0; font-size: .9rem; color: var(--muted); cursor: pointer; }
.check input { margin-top: .2rem; accent-color: var(--accent); }
.row.two { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
/* the always-visible top row of the create card */
.toprow { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; margin-bottom: .4rem; }
.switch { display: inline-flex; align-items: center; gap: .45rem; cursor: pointer; font-size: .9rem; color: var(--muted); }
.switch input { appearance: none; width: 34px; height: 19px; border-radius: 999px; background: #3b3835;
  position: relative; cursor: pointer; transition: background .15s; flex: none; }
.switch input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px;
  border-radius: 50%; background: #9a948c; transition: transform .15s, background .15s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(15px); background: #14240a; }
.switch input:checked + span { color: var(--text); }

/* time-control presets */
.presets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; margin: .8rem 0 .9rem; }
.preset {
  display: flex; flex-direction: column; align-items: center; gap: .1rem; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  border-radius: 10px; padding: .65rem .5rem; font: inherit; transition: all .13s;
}
.preset:hover { border-color: var(--accent); background: #2d3324; transform: translateY(-1px); }
.preset:active { transform: none; }
.preset b { font-size: 1.15rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.preset.wide b { font-size: .95rem; }
.preset span { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

/* line-up picker */
.lineup { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.lineup select { width: auto; min-width: 5.2rem; }
.lineup .vs { color: var(--muted); font-weight: 700; }
.lineup-note { font-size: .8rem; color: var(--muted); flex: 1 1 100%; }

/* collapsible options */
.opts { border: 1px solid var(--line-soft); border-radius: 10px; background: var(--panel-2); margin-bottom: .2rem; }
.opts > summary {
  cursor: pointer; padding: .6rem .8rem; font-weight: 600; font-size: .9rem;
  list-style: none; display: flex; align-items: center; gap: .45rem; color: var(--text);
}
.opts > summary::-webkit-details-marker { display: none; }
.opts > summary::before { content: '▸'; color: var(--muted); transition: transform .15s; }
.opts[open] > summary::before { transform: rotate(90deg); }
.opts > summary:hover { background: #2c2a27; border-radius: 10px; }
.opts-body { padding: .2rem .8rem .8rem; border-top: 1px solid var(--line-soft); }
.opts-body h4 {
  margin: 1.1rem 0 .5rem; font-size: .72rem; text-transform: uppercase;
  letter-spacing: .08em; color: var(--accent-hi); font-weight: 700;
}
.opts-body h4:first-child { margin-top: .8rem; }
.opt-note { margin: -.35rem 0 .7rem; }

.warn-note { border-left: 3px solid var(--warn); padding: .4rem .6rem; background: var(--panel-2); border-radius: 0 6px 6px 0; margin: .2rem 0 .6rem; }

/* ───────────────────────────── home ───────────────────────────── */
.screen { min-height: 100%; }
.home-inner { max-width: 1040px; margin: 0 auto; padding: 2.2rem 1.1rem 3rem; }
.home-head { display: flex; flex-wrap: wrap; gap: 1.2rem; align-items: flex-end; justify-content: space-between; margin-bottom: 1.6rem; }
.brand { display: flex; gap: .9rem; align-items: center; }
.brand-mark { width: 60px; height: 60px; flex: none; display: block; }

/* the tetrahedron doubles as the quick-play button */
.quickplay {
  position: relative; width: 88px; height: 88px; flex: none; padding: 0;
  border: 0; background: none; cursor: pointer; border-radius: 14px;
  transition: transform .16s;
}
.quickplay canvas {
  display: block; width: 100%; height: 100%;
  transition: filter .18s ease, opacity .18s ease, transform .18s ease;
}
.quickplay .qp-label {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: .72rem; font-weight: 800; line-height: 1.1; letter-spacing: .08em;
  text-transform: uppercase; text-align: center; color: var(--accent-hi);
  text-shadow: 0 1px 4px rgba(0,0,0,.85);
  opacity: 0; transition: opacity .18s ease;
  pointer-events: none;
}
.quickplay:hover canvas,
.quickplay:focus-visible canvas { filter: blur(3.5px) saturate(.55); opacity: .55; transform: scale(.93); }
.quickplay:hover .qp-label,
.quickplay:focus-visible .qp-label { opacity: 1; }
.quickplay:active { transform: scale(.96); }
.quickplay:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.tag { color: var(--muted); margin: 0; font-size: .93rem; }
.name-field { margin: 0; min-width: 210px; }

.home-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; align-items: start; }
.card { background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 1.1rem; }
.joinrow { display: flex; gap: .55rem; }
.joinrow input { text-transform: uppercase; letter-spacing: .12em; font-weight: 700; }
.roomlist { display: flex; flex-direction: column; gap: .4rem; max-height: 250px; overflow: auto; }
.roomrow {
  display: flex; align-items: center; gap: .7rem; padding: .5rem .6rem;
  background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: 8px; font-size: .9rem;
}
.roomrow .code { font-weight: 700; letter-spacing: .08em; }
.roomrow .who { color: var(--muted); font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-foot { margin-top: 1.6rem; color: var(--muted); font-size: .9rem; }
.home-foot summary { cursor: pointer; font-weight: 600; color: var(--text); }
.home-foot p { margin-top: .6rem; max-width: 72ch; }
.home-foot .legal { margin-top: 1.4rem; font-size: .76rem; color: #6f6a64; }
.home-foot .legal a { color: #8a857e; }
.home-foot .legal a:hover { color: var(--accent-hi); }

/* ───────────────────────────── game chrome ───────────────────────────── */
#game { display: flex; flex-direction: column; height: 100dvh; }
.topbar {
  display: flex; align-items: center; gap: .6rem; padding: .5rem .8rem;
  background: var(--panel); border-bottom: 1px solid var(--line-soft); flex: none;
}
.room-id { display: flex; align-items: center; gap: .5rem; }
.room-id .label { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.room-id b { letter-spacing: .14em; font-size: 1.05rem; }
.conn { display: flex; align-items: center; gap: .4rem; font-size: .78rem; color: var(--muted); }
.conn i { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.conn.on i { background: var(--accent); }
.conn.off i { background: var(--danger); }

.layout {
  flex: 1; min-height: 0; display: grid; gap: 1rem;
  grid-template-columns: minmax(0, 1fr) 340px;
  padding: 1rem; align-items: start;
  /* keep the sidebar beside the board instead of stranded at the far right */
  width: 100%; max-width: calc(var(--boardmax) + 340px + 3rem); margin-inline: auto;
}
.boardcol { display: flex; flex-direction: column; gap: .55rem; min-width: 0; align-items: center; }

/* ── consensus banner: draw offers and resign votes ── */
.consensus { width: var(--board); display: flex; flex-direction: column; gap: .4rem; }
.consensus:empty { display: none; }
.cbar {
  display: flex; align-items: center; gap: .7rem; flex-wrap: wrap;
  padding: .6rem .8rem; border-radius: 10px; font-size: .92rem;
  border: 1px solid var(--line); background: var(--panel);
}
.cbar .ctext { flex: 1; min-width: 12ch; }
.cbar .ctext b { display: block; font-size: 1.02rem; }
.cbar .ctext span { color: var(--muted); font-size: .84rem; }
.cbar .cbtns { display: flex; gap: .4rem; }
/* the loud one: the other team has agreed a draw between themselves */
.cbar.offer {
  border-color: var(--warn); background: linear-gradient(90deg, #40361d, #2f2a20);
  box-shadow: 0 0 0 1px #e8b64c33, 0 6px 18px #0004;
  animation: cpulse 2.2s ease-in-out infinite;
}
.cbar.offer .ctext b { color: var(--warn); }
.cbar.pending { border-style: dashed; }
.cbar.danger { border-color: var(--danger); background: #3a2622; }
.cbar.danger .ctext b { color: #f0b3a9; }
@keyframes cpulse {
  0%, 100% { box-shadow: 0 0 0 1px #e8b64c33, 0 6px 18px #0004; }
  50%      { box-shadow: 0 0 0 3px #e8b64c40, 0 6px 22px #0006; }
}
@media (prefers-reduced-motion: reduce) { .cbar.offer { animation: none; } }

/* ── turn-order rail ── */
.rail { display: flex; gap: .4rem; align-items: center; width: var(--board); flex-wrap: wrap; }
.rail .rail-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); margin-right: .2rem; }
.rail-pill {
  display: flex; align-items: center; gap: .4rem; padding: .28rem .6rem; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line-soft); font-size: .82rem; color: var(--muted);
  transition: all .18s;
}
.rail-pill .dot { width: 9px; height: 9px; border-radius: 3px; border: 1px solid #0006; }
.rail-pill.w .dot { background: #f2f0ea; }
.rail-pill.b .dot { background: #2f2d2b; }
.rail-pill.now { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 700; }
.rail-pill.next { color: var(--text); }
.rail-pill.you { box-shadow: 0 0 0 2px #81b64c66; }
.rail-arrow { color: var(--line); font-size: .8rem; }

/* ── seat cards ── */
.seatstrip { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; width: var(--board); }
.seatstrip.many { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.seatstrip.many .seatcard { padding: .3rem .45rem; }
.seatstrip.many .seatcard .badge { width: 26px; height: 26px; font-size: .66rem; }
.seatstrip.many .seatcard .sub { display: none; }
.seatstrip.many .clock { font-size: .92rem; }
.seatcard {
  display: flex; align-items: center; gap: .6rem; padding: .45rem .6rem; min-width: 0;
  background: var(--panel); border: 1px solid var(--line-soft); border-radius: 8px;
  transition: border-color .15s, background .15s;
}
.seatcard.onmove { border-color: var(--accent); background: #2d3324; }
/* Discord-style: whoever is talking gets a ring */
.seatcard.speaking { box-shadow: 0 0 0 2px #3ba55d, 0 0 10px #3ba55d55; }
.seatcard.speaking .badge { box-shadow: 0 0 0 2px #3ba55d; }
.seatcard .sub .mic { transition: color .12s; }
.seatcard.speaking .sub .mic { color: #57d98a; }
@media (prefers-reduced-motion: no-preference) {
  .seatcard.speaking { transition: box-shadow .09s ease-out; }
}
.seatcard.empty { border-style: dashed; }
.seatcard .badge {
  flex: none; width: 34px; height: 34px; border-radius: 7px; display: grid; place-items: center;
  font-weight: 800; font-size: .78rem; letter-spacing: .02em;
}
.seatcard.white .badge { background: #efece4; color: #22201d; }
.seatcard.black .badge { background: #2b2926; color: #efece4; border: 1px solid #4a4642; }
.seatcard .who { min-width: 0; flex: 1; }
.seatcard .nm { font-weight: 600; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seatcard .sub { font-size: .72rem; color: var(--muted); display: flex; align-items: center; gap: .3rem; }
.seatcard .sub .off { color: var(--danger); }
.seatcard .sub .mic { color: var(--accent-hi); }
.seatcard .taken { display: flex; gap: 1px; align-items: center; height: 15px; }
.seatcard .taken img { width: 15px; height: 15px; opacity: .9; margin-left: -4px; }
.seatcard .edge { font-size: .72rem; color: var(--accent-hi); font-weight: 700; }
.clock {
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.12rem; padding: .18rem .5rem;
  background: var(--panel-3); border-radius: 6px; color: var(--muted); flex: none;
}
.seatcard.onmove .clock { background: #e9e6e0; color: #1b1a18; }
.clock.low { color: var(--danger) !important; }
.seatcard.onmove .clock.low { background: #d36c5d; color: #1b1a18 !important; }

/* ── board ── */
.board-row { display: flex; gap: .4rem; width: var(--board); align-items: stretch; }
.board-outer { position: relative; flex: 1; min-width: 0; aspect-ratio: 1; }

/* Stockfish evaluation bar */
.evalbar {
  position: relative; width: 18px; flex: none; border-radius: 4px; overflow: hidden;
  background: #2b2926; box-shadow: var(--shadow);
  display: flex; flex-direction: column; justify-content: flex-end;
}
.evalfill { width: 100%; background: #efece4; transition: height .35s ease; height: 50%; }
.evalbar .evalnum {
  position: absolute; left: 0; right: 0; text-align: center; font-size: 8.5px;
  font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; z-index: 2;
}
.evalbar .evalnum.top { top: 2px; color: #cfcbc4; }
.evalbar .evalnum.bottom { bottom: 2px; color: #26241f; }
.evalbar.flip { flex-direction: column-reverse; }
.evalbar.flip .evalnum.top { top: auto; bottom: 2px; color: #26241f; }
.evalbar.flip .evalnum.bottom { bottom: auto; top: 2px; color: #cfcbc4; }

/* post-game review */
.reviewbox { padding: .6rem; border-bottom: 1px solid var(--line-soft); flex: none; }
.reviewbox h4 { margin: 0 0 .5rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.acc { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: .35rem; }
.acccard { background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: 8px; padding: .35rem .45rem; }
.acccard b { display: block; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.acccard span { font-size: .7rem; color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acccard .sb { display: inline-block; font-size: .6rem; font-weight: 800; background: #4a4641;
  color: #d7d2ca; border-radius: 3px; padding: 0 .25rem; margin-right: .2rem; }
.tally { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .5rem; font-size: .72rem; }
.tally i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: .2rem; vertical-align: -1px; }
.mv .qual { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.revprog { height: 4px; background: var(--panel-3); border-radius: 2px; overflow: hidden; margin-top: .45rem; }
.revprog i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.board {
  position: absolute; inset: 0; border-radius: 6px; overflow: hidden;
  box-shadow: var(--shadow); touch-action: none; user-select: none; -webkit-user-select: none;
  /* the board itself is one supplied SVG; the .sq divs above it are only
     hit-targets and coordinate labels */
  background: url(../assets/board.svg) center / 100% 100% no-repeat, var(--dark-sq);
}
.sq { position: absolute; left: 0; top: 0; width: 12.5%; height: 12.5%; }

.sq .coord { position: absolute; font-size: clamp(8px, 1.5vh, 11px); font-weight: 700; opacity: .65; }
.sq .coord.file { right: 3px; bottom: 1px; }
.sq .coord.rank { left: 3px; top: 1px; }
.sq.light .coord { color: var(--dark-sq); }
.sq.dark .coord { color: var(--light-sq); }

.mark { position: absolute; left: 0; top: 0; width: 12.5%; height: 12.5%; pointer-events: none; }
.mark.last { background: var(--last); }
.mark.sel  { background: var(--sel); }
.mark.pre  { background: var(--pre); }
.mark.check {
  background: radial-gradient(circle at 50% 50%, rgba(255,60,40,.95) 0%, rgba(230,40,20,.72) 42%, rgba(200,20,10,0) 72%);
}
.hint { position: absolute; left: 0; top: 0; width: 12.5%; height: 12.5%; pointer-events: none; display: grid; place-items: center; }
.hint i { display: block; width: 30%; height: 30%; border-radius: 50%; background: rgba(0,0,0,.22); }
.hint.cap i { width: 92%; height: 92%; border-radius: 50%; background: none; box-shadow: inset 0 0 0 7px rgba(0,0,0,.2); }
.hoversq { position: absolute; left: 0; top: 0; width: 12.5%; height: 12.5%; pointer-events: none; box-shadow: inset 0 0 0 4px rgba(255,255,255,.72); border-radius: 2px; }

.pc-el {
  position: absolute; left: 0; top: 0; width: 12.5%; height: 12.5%; will-change: transform;
  transition: transform .13s cubic-bezier(.2,.8,.3,1); z-index: 2;
}
.pc-el.dragging { transition: none; z-index: 30; cursor: grabbing; filter: drop-shadow(0 6px 8px rgba(0,0,0,.45)); }
.pc-el img { width: 100%; height: 100%; display: block; pointer-events: none; -webkit-user-drag: none; }
.board.grabbable .pc-el.mine { cursor: grab; }

.shapes { position: absolute; inset: 0; z-index: 6; pointer-events: none; overflow: visible; }

.board-over {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 40;
  background: rgba(20,19,17,.72); backdrop-filter: blur(2px); border-radius: 6px; text-align: center; padding: 1rem;
}
.over-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 1.2rem 1.6rem; box-shadow: var(--shadow); max-width: 320px; }
.over-card h2 { font-size: 1.25rem; }
.over-card .score { font-size: 2rem; font-weight: 800; letter-spacing: .04em; margin: .2rem 0 .1rem; }
.over-card .btns { display: flex; gap: .5rem; justify-content: center; margin-top: .9rem; flex-wrap: wrap; }

/* promotion picker */
.promo { position: absolute; z-index: 50; background: var(--panel); border-radius: 8px; box-shadow: var(--shadow); padding: 3px; display: flex; flex-direction: column; }
.promo button { width: 100%; aspect-ratio: 1; background: #3b3835; border: 0; border-radius: 6px; cursor: pointer; padding: 2px; margin: 1px 0; }
.promo button:hover { background: var(--accent); }
.promo img { width: 100%; height: 100%; display: block; }

.actionbar { display: flex; gap: .45rem; flex-wrap: wrap; width: var(--board); min-height: 32px; }

/* ───────────────────────────── sidebar ───────────────────────────── */
.sidebar {
  background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius);
  display: flex; flex-direction: column; height: 100%; max-height: calc(100dvh - 2rem - 49px); overflow: hidden;
}
.tabs { display: flex; border-bottom: 1px solid var(--line-soft); flex: none; }
.tab {
  flex: 1; background: none; border: 0; padding: .7rem .4rem; color: var(--muted); cursor: pointer;
  font: inherit; font-weight: 600; font-size: .88rem; border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); background: var(--panel-2); }
.tab .pip { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-left: .25rem; vertical-align: 1px; }
.pane { display: none; flex-direction: column; min-height: 0; flex: 1; }
.pane.active { display: flex; }

.movelist { flex: 1; overflow: auto; padding: .35rem; min-height: 120px; }
.mv-row { display: grid; grid-template-columns: 2.1rem 1fr 1fr; align-items: stretch; font-size: .92rem; }
.mv-row:nth-child(odd) { background: #2b2926; }
.mv-no { color: var(--muted); font-variant-numeric: tabular-nums; padding: .3rem .25rem; text-align: right; font-size: .82rem; }
.mv {
  display: flex; align-items: center; gap: .35rem; padding: .3rem .4rem; border-radius: 5px;
  cursor: pointer; font-weight: 600; min-width: 0;
}
.mv:hover { background: #3a3733; }
.mv.cur { background: var(--accent); color: var(--accent-ink); }
.mv .seatbadge {
  font-size: .62rem; font-weight: 800; padding: .05rem .25rem; border-radius: 3px; flex: none;
  background: #4a4641; color: #d7d2ca; letter-spacing: .02em;
}
.mv.cur .seatbadge { background: #ffffffa8; color: #1d2a10; }
.mv .san { overflow: hidden; text-overflow: ellipsis; }
.mv.empty { cursor: default; }
.savebar { display: flex; gap: .4rem; padding: .5rem; border-top: 1px solid var(--line-soft); flex: none; }
.savebar .btn { flex: 1; }

.seatpicker { padding: .6rem; display: flex; flex-direction: column; gap: .45rem; overflow: auto; }
.pickrow { display: flex; align-items: center; gap: .6rem; padding: .5rem .6rem; background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: 8px; }
.pickrow .badge { width: 30px; height: 30px; border-radius: 6px; display: grid; place-items: center; font-weight: 800; font-size: .74rem; flex: none; }
.pickrow.white .badge { background: #efece4; color: #22201d; }
.pickrow.black .badge { background: #2b2926; color: #efece4; border: 1px solid #4a4642; }
.pickrow .nm { flex: 1; min-width: 0; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.roominfo { padding: .6rem .8rem; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: .84rem; }
.roominfo dl { display: grid; grid-template-columns: auto 1fr; gap: .2rem .6rem; margin: 0; }
.roominfo dt { color: var(--muted); }
.roominfo dd { margin: 0; color: var(--text); }

.chatlog { flex: 1; overflow: auto; padding: .6rem; display: flex; flex-direction: column; gap: .35rem; font-size: .89rem; }
.chatmsg .nm { font-weight: 700; }
.chatmsg .sb { font-size: .64rem; font-weight: 800; padding: .05rem .25rem; border-radius: 3px; background: #4a4641; color: #d7d2ca; margin-right: .25rem; }
.chatmsg.sys { color: var(--muted); font-style: italic; }
.chatform { display: flex; gap: .4rem; padding: .5rem; border-top: 1px solid var(--line-soft); flex: none; }

/* ───────────────────────────── name gate ───────────────────────────── */
.gate {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center;
  background: rgba(20, 19, 17, .82); backdrop-filter: blur(3px); padding: 1rem;
}
.gate-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 1.6rem; max-width: 380px; width: 100%; text-align: center; box-shadow: var(--shadow);
}
.gate-mark { width: 72px; height: 72px; display: block; margin: 0 auto .6rem; }
.gate-card h2 { font-size: 1.2rem; }
.gate-card input { margin: .9rem 0 .2rem; text-align: center; font-size: 1.05rem; }
.gate-card b { letter-spacing: .12em; }
.gate-btns { display: flex; flex-direction: column; gap: .45rem; margin-top: .9rem; }

/* ───────────────────────────── toasts ───────────────────────────── */
#toasts { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: .4rem; pointer-events: none; }
.toast {
  background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  padding: .55rem .85rem; border-radius: 8px; box-shadow: var(--shadow); font-size: .9rem;
  animation: pop .18s ease-out;
}
.toast.bad { border-left-color: var(--danger); }
@keyframes pop { from { opacity: 0; transform: translateY(-6px); } }

/* ───────────────────────────── responsive ───────────────────────────── */
@media (max-width: 960px) {
  .home-grid { grid-template-columns: 1fr; }
  .layout { grid-template-columns: 1fr; overflow: auto; }
  #game { height: auto; min-height: 100dvh; }
  .sidebar { max-height: none; height: 420px; }
  .board-outer, .seatstrip, .rail, .actionbar, .board-row { width: min(100%, 560px); }
  .board-outer { width: auto; }
  :root { --board: min(100%, 560px); }
  .layout { max-width: none; }
  .boardcol { align-items: stretch; }
}
@media (max-width: 620px) {
  .home-inner { padding: 1.2rem .8rem 2rem; }
  .layout { padding: .5rem; gap: .6rem; }
  :root { --board: min(100%, 560px); }
  .layout { max-width: none; }
  .rail .rail-label { display: none; }
  .rail-pill { padding: .22rem .45rem; font-size: .74rem; gap: .3rem; }
  .rail-pill .nm { display: none; }
  .rail-pill.now .nm { display: inline; }
  .seatcard { padding: .35rem .45rem; gap: .45rem; }
  .seatcard .badge { width: 28px; height: 28px; font-size: .7rem; border-radius: 6px; }
  .seatcard .taken { display: none; }
  .seatcard .nm { font-size: .85rem; }
  .seatcard .sub { font-size: .68rem; white-space: nowrap; overflow: hidden; }
  .clock { font-size: .98rem; padding: .14rem .38rem; }
  .actionbar .btn { flex: 1 1 auto; }
  .topbar { padding: .4rem .5rem; gap: .35rem; }
  .topbar .btn { white-space: nowrap; }
  .room-id .label { display: none; }
  .conn span { display: none; }
  .btn.icon { width: 32px; height: 32px; }
}
.actionbar:empty { display: none; }
.topbar .btn.tiny { white-space: nowrap; }
@media (prefers-reduced-motion: reduce) {
  .pc-el { transition: none; }
}
