/* Enterprise Chess Club Hub — navy and gold from the club patch, used as signage. */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --hover: #e7ebf2;
  --line: #d7dde7;
  --line-strong: #aeb7c7;
  --text: #172036;
  --muted: #586179;
  --navy: #141c33;
  --navy-2: #222d4d;
  --on-navy: #f3efe6;
  --on-navy-muted: #aab2c8;
  --gold: #c9a66b;
  --gold-hover: #b8935a;
  --gold-soft: #f3ead8;
  --gold-ink: #7a5a22;
  --on-gold: #141c33;
  --good: #2e7a4d;
  --good-soft: #e3f1e8;
  --bad: #b33636;
  --bad-soft: #f8e4e4;
  --warn: #9a6410;
  --warn-soft: #f8eedb;
  --q-best: #2e7a4d;
  --q-good: #6d8a77;
  --q-inaccuracy: #b98612;
  --q-mistake: #d2691e;
  --q-blunder: #c0392b;
  --sq-light: #ece0c4;
  --sq-dark: #6b81a3;
  --hl-dest: rgba(20, 28, 51, 0.35);
  --hl-pre: rgba(150, 60, 60, 0.45);
  --veil: rgba(20, 28, 51, 0.55);
  --shadow: 0 1px 2px rgba(20, 28, 51, 0.06), 0 4px 14px rgba(20, 28, 51, 0.07);
  --radius: 8px;
  --header: 0px;
  --side: 228px;
  --font: 'Barlow', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mark: 'Graduate', 'Barlow', serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1424; --surface: #151d33; --surface-2: #1b2540; --hover: #222d4c; --line: #2a3556; --line-strong: #44517a;
    --text: #e8ebf2; --muted: #a2abc1; --navy: #0a1020; --navy-2: #1a2440; --gold-soft: #2b2a28; --gold-ink: #e2c48f;
    --good: #5fbf86; --good-soft: #17301f; --bad: #e07070; --bad-soft: #3a1c1f; --warn: #e0a84a; --warn-soft: #33281a;
    --q-good: #93ad9b; --hl-dest: rgba(20, 28, 51, 0.45); --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 18px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1424; --surface: #151d33; --surface-2: #1b2540; --hover: #222d4c; --line: #2a3556; --line-strong: #44517a;
  --text: #e8ebf2; --muted: #a2abc1; --navy: #0a1020; --navy-2: #1a2440; --gold-soft: #2b2a28; --gold-ink: #e2c48f;
  --good: #5fbf86; --good-soft: #17301f; --bad: #e07070; --bad-soft: #3a1c1f; --warn: #e0a84a; --warn-soft: #33281a;
  --q-good: #93ad9b; --hl-dest: rgba(20, 28, 51, 0.45); --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 18px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}
:root[data-board="brown"] { --sq-light: #f0d9b5; --sq-dark: #b58863; }
:root[data-board="green"] { --sq-light: #eeeed2; --sq-dark: #769656; }
:root[data-board="grey"] { --sq-light: #dfe3e8; --sq-dark: #8d99a8; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 var(--font); font-variant-numeric: tabular-nums; min-height: 100vh; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: var(--gold); color: var(--on-gold); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
input, textarea, select { caret-color: var(--gold-hover); accent-color: var(--navy-2); }
* { scrollbar-color: var(--line-strong) transparent; scrollbar-width: thin; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- shell ---------- */
/* Desktop: a navy sidebar (signage), content to its right. Phone: navy top bar + bottom tabs. */
.sidenav { position: fixed; inset: 0 auto 0 0; width: var(--side); z-index: 30; background: var(--navy); color: var(--on-navy); display: flex; flex-direction: column; padding: 18px 12px 14px; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; flex: none; color: var(--on-navy); }
.sidenav .brand { padding: 0 6px; }
.brand img { width: 40px; height: 40px; }
.brand-name { font: 400 14px/1.15 var(--font-mark); letter-spacing: 0.03em; }
.side-links { display: grid; gap: 2px; }
.side-links a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 8px; color: var(--on-navy-muted); font-weight: 600; font-size: 16px; text-decoration: none; }
.side-links a .ico { width: 22px; height: 22px; }
.side-links a:hover { background: var(--navy-2); color: var(--on-navy); }
.side-links a[aria-current="page"] { background: var(--navy-2); color: var(--on-navy); }
.side-links a[aria-current="page"] .ico { color: var(--gold); }
.side-foot { margin-top: auto; display: grid; gap: 8px; }
.side-tools { display: flex; align-items: center; justify-content: space-between; padding: 4px 2px 0; }
.side-tools a { color: var(--on-navy-muted); text-decoration: none; }
.side-tools a:hover { color: var(--on-navy); }
.btn.ghost { background: transparent; color: inherit; border-color: currentColor; }
.sidenav .btn.ghost, .top .btn.ghost { color: var(--on-navy); border-color: var(--on-navy-muted); }
.sidenav .btn.ghost:hover, .top .btn.ghost:hover { background: var(--navy-2); }
.me-btn { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 8px; border: 0; border-radius: 8px; background: transparent; color: var(--on-navy); font-weight: 600; text-align: left; width: 100%; }
.me-btn:hover { background: var(--navy-2); }
.me-btn .who { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--gold); color: var(--on-gold); display: grid; place-items: center; font: 700 14px var(--font); flex: none; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 8px; border: 0; background: transparent; color: inherit; }
.sidenav .icon-btn, .top .icon-btn { color: var(--on-navy-muted); }
.sidenav .icon-btn:hover, .top .icon-btn:hover { background: var(--navy-2); color: var(--on-navy); }
.top { display: none; }
.menu { position: fixed; z-index: 40; min-width: 240px; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; display: grid; }
.menu .menu-head { padding: 10px 12px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu .menu-head b { display: block; }
.menu .menu-head span { color: var(--muted); font-size: 14px; }
.menu a, .menu button { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 6px; border: 0; background: none; text-align: left; text-decoration: none; font-weight: 500; }
.menu a:hover, .menu button:hover { background: var(--hover); }

main { margin-left: var(--side); max-width: 1240px; padding: 28px 32px 48px; }
.tabbar { display: none; }

/* ---------- type ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
h1.title { font: 700 clamp(1.5rem, 2.6vw, 2rem)/1.15 var(--font); letter-spacing: -0.01em; color: var(--text); }
.lede { color: var(--muted); max-width: 62ch; margin-top: 6px; }
h2.section { font: 700 1.125rem/1.3 var(--font); margin: 28px 0 10px; }
h2.section:first-child { margin-top: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- controls ---------- */
.ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: var(--radius); border: 1px solid var(--line-strong); background: var(--surface); font-weight: 600; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: var(--on-gold); }
.btn.primary:hover { background: var(--gold-hover); border-color: var(--gold-hover); }
.btn.navy { background: var(--navy-2); border-color: var(--navy-2); color: var(--on-navy); }
.btn.quiet { border-color: transparent; background: transparent; padding: 0 10px; }
.btn.quiet:hover { background: var(--hover); }
.btn.danger { color: var(--bad); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 15px; }
.btn.wide { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.seg { display: inline-flex; flex-wrap: wrap; align-self: flex-start; justify-self: start; max-width: 100%; gap: 0; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.seg button { min-height: 40px; padding: 0 14px; border: 0; border-right: 1px solid var(--line); background: transparent; font-weight: 600; color: var(--muted); }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--navy-2); color: var(--on-navy); }
.seg button:hover:not([aria-pressed="true"]) { background: var(--hover); color: var(--text); }
/* Many choices: an even grid instead of a ragged wrap. */
.seg.seg-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--line); align-self: stretch; justify-self: stretch; }
.seg.seg-grid button { border-right: 0; background: var(--surface); padding: 0 8px; }
.seg.seg-grid button[aria-pressed="true"] { background: var(--navy-2); }
.field { display: grid; gap: 6px; }
.field label, .label { font-weight: 600; font-size: 15px; }
.field .hint { color: var(--muted); font-size: 14px; }
input[type=text], input[type=email], input[type=password], input[type=search], select, textarea { width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); }
textarea { min-height: 140px; resize: vertical; font-size: 15px; line-height: 1.4; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input[aria-invalid="true"] { border-color: var(--bad); }
.form { display: grid; gap: 16px; max-width: 440px; }
.check-row { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.check-row input { width: 18px; height: 18px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; }
:not(.two-col):not(.three-col) > .panel + .panel { margin-top: 14px; }
.panel h2 { font: 700 1.0625rem/1.3 var(--font); margin-bottom: 10px; }
.note { padding: 12px 14px; border-radius: var(--radius); background: var(--surface-2); color: var(--text); font-size: 15px; }
.note.warn { background: var(--warn-soft); }
.note.bad { background: var(--bad-soft); }
.note.good { background: var(--good-soft); }
.error-text { color: var(--bad); font-weight: 600; font-size: 15px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); font-size: 13px; font-weight: 600; color: var(--muted); }

.rows { display: grid; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); overflow: hidden; }
.row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; text-decoration: none; border: 0; background: none; text-align: left; width: 100%; }
.row + .row { border-top: 1px solid var(--line); }
a.row:hover, button.row:hover { background: var(--hover); }
.row .ico { color: var(--navy-2); width: 22px; height: 22px; }
:root[data-theme="dark"] .row .ico { color: var(--gold); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .row .ico { color: var(--gold); } }
.row .grow { flex: 1; min-width: 0; }
.row b { display: block; font-weight: 600; }
.row span.sub { color: var(--muted); font-size: 14px; }
.row .chev { color: var(--muted); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--navy); color: var(--on-navy); padding: 12px 18px; border-radius: 8px; box-shadow: var(--shadow); z-index: 60; max-width: min(90vw, 520px); font-weight: 500; }

/* ---------- board layouts ---------- */
.board-page { display: grid; grid-template-columns: var(--board-size) minmax(300px, 1fr); gap: 28px; align-items: start;
  --board-size: min(calc(100dvh - 56px), 720px, calc(100vw - var(--side) - 440px)); }
.board-page.with-bar { grid-template-columns: 18px var(--board-size) minmax(300px, 1fr); gap: 12px 20px; }
.board-shell { position: relative; width: var(--board-size); aspect-ratio: 1; }
.side { display: flex; flex-direction: column; gap: 14px; min-width: 0; max-height: var(--board-size); overflow-y: auto; padding-right: 4px; }
.side > .moves, .side > .tree { flex: 1 1 auto; }
.side .grow-scroll { overflow: auto; min-height: 0; }
.side > * { min-width: 0; }
.side .nav-row { position: sticky; top: 0; z-index: 2; background: var(--bg); padding: 2px 0; border-bottom: 1px solid var(--line); }
.side > .review-head { position: sticky; top: 0; z-index: 3; background: var(--bg); display: grid; gap: 6px; }
.review-head .nav-row { position: static; }
.side .nav-row.icons { flex-wrap: nowrap; justify-content: space-between; }
.side .nav-row.icons .btn { flex: 1 1 0; min-width: 0; padding: 0 6px; }
.btn-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.btn-grid .btn { padding: 0 10px; }
.btn-grid .btn.quiet:last-child { grid-column: 1 / -1; }

/* board (layer 1) */
.cg-wrap { position: relative; width: 100%; height: 100%; user-select: none; -webkit-user-select: none; }
.cg-board { position: absolute; inset: 0; border-radius: 4px; overflow: hidden; touch-action: none; cursor: pointer;
  background: repeating-conic-gradient(var(--sq-dark) 0 25%, var(--sq-light) 0 50%) 0 0 / 25% 25%; box-shadow: var(--shadow); }
.cg-wrap.view-only .cg-board { cursor: default; }
.cg-squares, .cg-pieces { position: absolute; inset: 0; pointer-events: none; }
.sq, .pc { position: absolute; top: 0; left: 0; width: 12.5%; height: 12.5%; }
.pc { background-size: cover; z-index: 2; transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1); will-change: transform; }
.pc.dragging { z-index: 11; transition: none; filter: drop-shadow(0 6px 6px rgba(0, 0, 0, 0.25)); }
.pc.fresh, .pc.dropped, .no-anim .pc { transition: none; }
.sq.last-move.light { background: #f0d78e; }
.sq.last-move.dark { background: #c9a65c; }
.sq.selected { background: rgba(20, 28, 51, 0.2); box-shadow: inset 0 0 0 3px var(--gold); }
.sq.check { background: radial-gradient(ellipse at center, rgba(220, 40, 40, 1) 0%, rgba(210, 30, 30, 0.8) 30%, rgba(170, 0, 0, 0) 85%); }
.sq.move-dest { background: radial-gradient(var(--hl-dest) 18%, transparent 19%); }
.sq.move-dest.oc { background: radial-gradient(transparent 0 78%, var(--hl-dest) 79%); }
.sq.premove-dest { background: radial-gradient(var(--hl-pre) 18%, transparent 19%); }
.sq.premove-dest.oc { background: radial-gradient(transparent 0 78%, var(--hl-pre) 79%); }
.sq.current-premove { background: var(--hl-pre); }
.sq.drag-over { box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.6); }
.sq.hint { box-shadow: inset 0 0 0 4px var(--gold); }
.sq.good-sq { background: rgba(46, 122, 77, 0.5); }
.sq.bad-sq { background: rgba(179, 54, 54, 0.5); }
.cg-shapes { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; overflow: visible; }
.cg-shapes .arrow { stroke-width: 0.15; stroke-linecap: round; opacity: 0.85; }
.cg-shapes .ring { fill: none; stroke-width: 0.07; opacity: 0.9; }
.brush-green { stroke: #1f7a3a; fill: #1f7a3a; }
.brush-red { stroke: #b02525; fill: #b02525; }
.brush-gold { stroke: #c08a2c; fill: #c08a2c; }
.brush-blue { stroke: #2f5fb3; fill: #2f5fb3; }
.cg-shapes .ring { fill: none !important; }
.cg-coords { position: absolute; inset: 0; pointer-events: none; font: 700 clamp(9px, 1.4vw, 12px)/1 var(--font); z-index: 3; }
.cg-coords span { position: absolute; }
.cg-coords .file { bottom: 3px; width: 12.5%; text-align: right; padding-right: 4px; }
.cg-coords .rank { left: 4px; padding-top: 3px; }
.cg-coords .on-light { color: var(--sq-dark); }
.cg-coords .on-dark { color: var(--sq-light); }
.promotion { position: absolute; inset: 0; z-index: 20; background: var(--veil); }
.promo-sq { position: absolute; top: 0; left: 0; width: 12.5%; height: 12.5%; border: 0; border-radius: 50%; background: var(--surface-2); padding: 0; }
.promo-sq .pc { position: absolute; inset: 8%; width: 84%; height: 84%; transform: none; transition: none; }
.promo-sq:hover, .promo-sq:focus-visible { background: var(--gold); border-radius: 12%; }
.board-veil { position: absolute; inset: 0; z-index: 15; display: grid; place-items: center; background: var(--veil); border-radius: 4px; color: #fff; text-align: center; padding: 24px; }

/* eval bar */
.evalbar { position: relative; width: 18px; height: var(--board-size); border-radius: 4px; overflow: hidden; background: #2b2f3a; box-shadow: inset 0 0 0 1px var(--line); }
.evalbar .white { position: absolute; left: 0; right: 0; bottom: 0; background: #f5f2ea; transition: height 0.35s cubic-bezier(0.22, 1, 0.36, 1); }
.evalbar.flip .white { bottom: auto; top: 0; }
.evalbar .mid { position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: var(--gold); opacity: 0.8; }
.evalbar .lbl { position: absolute; left: 0; right: 0; font: 700 10px/1 var(--font); text-align: center; color: #172036; bottom: 3px; }
.evalbar .lbl.top { top: 3px; bottom: auto; color: #f5f2ea; }

/* status / players */
.status { display: grid; gap: 4px; }
.status .big { font: 700 1.375rem/1.2 var(--font); }
.status .sub { color: var(--muted); }
.status.good .big { color: var(--good); }
.status.bad .big { color: var(--bad); }
.player { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.player .grow { flex: 1; min-width: 0; }
.player .pname { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.player .ptag { color: var(--muted); font-size: 14px; }
.player.to-move { border-color: var(--gold); background: var(--gold-soft); }
.swatch { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--text); flex: none; }
.swatch.white { background: #fff; }
.swatch.black { background: #222; }
.clock { font: 700 1.5rem/1 var(--font); font-variant-numeric: tabular-nums; padding: 8px 12px; border-radius: 6px; background: var(--surface-2); min-width: 5.4ch; text-align: right; }
.clock.running { background: var(--navy-2); color: var(--on-navy); }
.clock.low.running { background: var(--bad); color: #fff; }
.material { display: inline-flex; align-items: center; font-size: 13px; color: var(--muted); }
.pc.mini { position: static; display: inline-block; width: 18px; height: 18px; margin-right: -5px; transition: none; transform: none; }
.material em { font-style: normal; margin-left: 8px; font-weight: 600; }

/* move list */
.moves { display: grid; grid-template-columns: 3ch 1fr 1fr; align-content: start; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: auto; min-height: 120px; font-size: 15px; }
.moves .no { padding: 6px 0 6px 10px; color: var(--muted); background: var(--surface-2); }
.moves button { text-align: left; padding: 6px 10px; border: 0; background: none; display: flex; align-items: center; gap: 6px; font-weight: 500; }
.moves button:hover { background: var(--hover); }
.moves button[aria-current="true"] { background: var(--gold-soft); font-weight: 700; }
.moves .empty { grid-column: 1 / -1; padding: 14px; color: var(--muted); }
.moves .result { grid-column: 1 / -1; padding: 10px; text-align: center; font-weight: 700; border-top: 1px solid var(--line); }
.q { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.q-best, .q-excellent { background: var(--q-best); }
.q-good { background: var(--q-good); }
.q-inaccuracy { background: var(--q-inaccuracy); }
.q-mistake { background: var(--q-mistake); }
.q-blunder { background: var(--q-blunder); }
.qtext-inaccuracy { color: var(--q-inaccuracy); }
.qtext-mistake { color: var(--q-mistake); }
.qtext-blunder { color: var(--q-blunder); }
.qtext-best, .qtext-excellent { color: var(--q-best); }

/* tree (analysis) */
.tree { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 10px 12px; overflow: auto; line-height: 1.9; min-height: 120px; font-size: 15px; }
.tree .mv { border: 0; background: none; padding: 1px 4px; border-radius: 4px; font-weight: 600; }
.tree .mv:hover { background: var(--hover); }
.tree .mv[aria-current="true"] { background: var(--gold); color: var(--on-gold); }
.tree .var { display: block; margin: 2px 0 2px 14px; padding-left: 10px; border-left: 1px solid var(--line-strong); color: var(--muted); }
.tree .var .mv { font-weight: 500; }
.tree .cmt { color: var(--muted); font-style: italic; margin: 0 4px; }
.tree .mno { color: var(--muted); margin-left: 4px; }

/* engine lines */
.lines { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
.line { display: flex; gap: 10px; align-items: baseline; padding: 6px 10px; border-radius: 6px; background: var(--surface-2); font-size: 14.5px; border: 0; text-align: left; width: 100%; }
.line:hover { background: var(--hover); }
.line .ev { font-weight: 700; min-width: 4.5ch; }
.line .pv { flex: 1; min-width: 0; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* review */
.coach { display: grid; gap: 8px; }
.coach .head { display: flex; align-items: center; gap: 10px; font: 700 1.125rem/1.3 var(--font); }
.coach p { line-height: 1.5; }
.acc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.acc { padding: 12px 14px; border-radius: var(--radius); background: var(--surface-2); }
.acc .who { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.acc .pct { font: 700 1.75rem/1.1 var(--font); margin-top: 4px; }
.acc ul { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 2px; font-size: 14px; color: var(--muted); }
.acc li { display: flex; align-items: center; gap: 6px; }
.graph { width: 100%; height: 90px; display: block; border-radius: 6px; background: var(--surface-2); cursor: pointer; }
.progress { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.progress > div { height: 100%; background: var(--gold); transition: width 0.2s; }

/* home */
.home-side .start ol { margin: 8px 0 0; padding-left: 20px; display: grid; gap: 6px; }

/* puzzles */
.dots { display: flex; flex-wrap: wrap; gap: 6px; }
.dot { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff; }
.dot.win { background: var(--good); }
.dot.fail { background: var(--bad); }
.dot.hint { background: var(--warn); }
.dot .ico { width: 14px; height: 14px; stroke-width: 2.6; }
.dot.now { background: var(--surface-2); box-shadow: inset 0 0 0 2px var(--gold); }
.stat-line { display: flex; gap: 4px 18px; flex-wrap: wrap; color: var(--muted); font-size: 15px; }
.stat-line b { color: var(--text); font-weight: 700; margin-left: 2px; }

/* profile */
.profile-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
/* Records hang like small championship banners: flat navy, gold numeral, notched foot. */
.records { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 28px; }
.record { width: 136px; padding: 16px 12px 28px; background: var(--navy-2); color: var(--on-navy); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 84%, 0 100%); display: grid; align-content: start; justify-items: center; gap: 6px; text-align: center; }
.record b { font: 700 1.625rem/1 var(--font); color: var(--gold); }
.record span { font-size: 13px; line-height: 1.25; color: var(--on-navy-muted); }
.record.empty { background: var(--surface-2); color: var(--muted); padding-top: 22px; box-shadow: inset 0 3px 0 var(--line-strong); }
.record.empty span { color: var(--muted); }
table.list { width: 100%; border-collapse: collapse; font-size: 15px; }
table.list th { text-align: left; font-size: 13px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.list td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }

.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.three-col { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.levels { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.levels button { min-height: 52px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); display: grid; place-items: center; padding: 4px; line-height: 1.15; }
.levels button b { font-size: 17px; }
.levels button span { font-size: 12px; color: var(--muted); }
.levels button[aria-pressed="true"] { background: var(--navy-2); border-color: var(--navy-2); color: var(--on-navy); }
.levels button[aria-pressed="true"] span { color: var(--on-navy-muted); }

.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--gold); animation: spin 0.8s linear infinite; display: inline-block; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }


/* ---------- task panel (board left, panel right) ---------- */
.panel-side { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 0 18px 18px; gap: 16px; height: var(--board-size); max-height: var(--board-size); }
.panel-head { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 6px; min-height: 60px; margin: 0 -18px; padding: 8px 18px 8px 10px; background: var(--surface); border-bottom: 1px solid var(--line); }
.panel-head h1 { font: 700 1.3rem/1.2 var(--font); margin-left: 8px; }
.panel-head .icon-btn { color: var(--muted); }
.panel-head .icon-btn:hover { background: var(--hover); color: var(--text); }
.narrow .panel-head { position: static; margin: 0 0 18px; padding: 0; border: 0; min-height: 0; background: none; }
.narrow .panel-head h1 { margin-left: 4px; font-size: clamp(1.5rem, 2.6vw, 2rem); }
.narrow { max-width: 640px; }
.panel-foot { position: sticky; bottom: -18px; margin: auto -18px -18px; padding: 14px 18px 18px; background: var(--surface); border-top: 1px solid var(--line); }
.side .panel-foot.btn-row:empty { display: none; }
.btn.big { min-height: 52px; font-size: 18px; }
.choices { display: grid; gap: 8px; }
.choice { display: flex; align-items: center; gap: 14px; padding: 14px 14px 14px 12px; border-radius: 10px; background: var(--surface-2); text-decoration: none; transition: background 0.15s; }
.choice:hover { background: var(--hover); }
.choice .grow { flex: 1; min-width: 0; display: grid; gap: 1px; }
.choice b { font-size: 17px; font-weight: 700; }
.choice .grow span { color: var(--muted); font-size: 14.5px; }
.choice .chev { color: var(--muted); }
.choice-ico { width: 44px; height: 44px; border-radius: 10px; background: var(--navy-2); color: var(--gold); display: grid; place-items: center; flex: none; }
.choice-ico .ico { width: 24px; height: 24px; }
.choice.current { background: var(--gold-soft); }
.choice.current .choice-ico { background: var(--gold); color: var(--on-gold); }

/* ---------- account pages ---------- */
.auth { max-width: 400px; margin: 4vh auto 0; display: grid; gap: 18px; }
.auth-mark { justify-self: center; }
.auth h1.title { text-align: center; }
.auth .form { max-width: none; }
.auth-foot { text-align: center; color: var(--muted); }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 48px; }
.pw-wrap .icon-btn { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.split { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.hint.warn-text { color: var(--warn); font-weight: 600; }
.nudge { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px; border-radius: 10px; background: var(--gold-soft); font-size: 15px; }
.nudge > span { flex: 1 1 180px; }
.nudge .ico { color: var(--gold-ink); }

/* ---------- home dashboard ---------- */
.join-band { display: flex; align-items: center; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; padding: 22px 24px; margin-bottom: 20px; border-radius: 12px; background: var(--navy); color: var(--on-navy); }
.join-band h2 { font: 700 1.375rem/1.2 var(--font); }
.join-band p { color: var(--on-navy-muted); margin-top: 4px; max-width: 52ch; }
.join-band .btn.ghost { color: var(--on-navy); border-color: var(--on-navy-muted); }
.join-band .btn.ghost:hover { background: var(--navy-2); }
h1.title + .dash { margin-top: 18px; }
.dash { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) minmax(0, 1fr); grid-auto-rows: minmax(170px, auto); gap: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; }
.tile h2 { font: 700 1.2rem/1.2 var(--font); }
p, .lede, .hint { text-wrap: pretty; }
.tile-link { text-decoration: none; transition: border-color 0.15s, box-shadow 0.15s; }
.tile-link:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.tile-head { display: flex; align-items: center; gap: 8px; }
.tile-head .ico { width: 20px; height: 20px; flex: none; color: var(--gold-ink); }
.tile-num { font: 700 2rem/1 var(--font); margin-top: 4px; }
.tile-num small { font-size: 14px; font-weight: 600; color: var(--muted); margin-left: 6px; }
.tile-go { margin-top: auto; padding-top: 10px; display: inline-flex; align-items: center; gap: 4px; font-weight: 700; color: var(--gold-ink); }
.tile-play { grid-row: span 2; padding: 0; overflow: hidden; gap: 0; }
.tile-board { padding: 18px 18px 0; }
.tile-board .board-shell { position: relative; width: 100%; aspect-ratio: 1; }
.tile-body { padding: 16px 18px 18px; display: grid; gap: 10px; }
.tile-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tile-actions .btn { padding: 0 8px; }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.theme { padding: 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); text-decoration: none; font-weight: 600; }
.theme:hover { border-color: var(--line-strong); background: var(--hover); }

/* ---------- review landing ---------- */
.add-game { display: grid; gap: 14px; }
.add-game h2 { margin: 0; }

/* ---------- responsible-use reminder ---------- */
dialog.usage { width: min(440px, calc(100vw - 32px)); border: 0; border-radius: 14px; padding: 28px 26px 24px; background: var(--surface); color: var(--text); box-shadow: 0 12px 40px rgba(10, 16, 32, 0.35); text-align: center; }
dialog.usage::backdrop { background: var(--veil); }
dialog.usage img { display: block; margin: 0 auto 10px; }
dialog.usage h2 { font: 700 1.3rem/1.25 var(--font); margin-bottom: 12px; }
dialog.usage p { color: var(--muted); font-size: 15.5px; line-height: 1.5; margin-bottom: 10px; text-align: left; }
dialog.usage .btn { margin-top: 10px; }

/* ---------- club ---------- */
.ratings { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.rating-chip { display: grid; gap: 2px; min-width: 150px; padding: 12px 16px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); text-decoration: none; }
a.rating-chip:hover { border-color: var(--line-strong); }
.rating-chip span { font-size: 13px; font-weight: 600; color: var(--muted); }
.rating-chip b { font: 700 1.6rem/1.1 var(--font); }
.rating-chip small { color: var(--muted); font-size: 13px; }
.leaderboard { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.leaderboard a { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); text-decoration: none; }
.leaderboard a:hover { background: var(--hover); }
.leaderboard .me a { background: var(--gold-soft); border-color: var(--gold); }
.leaderboard .rank { width: 2.2ch; text-align: right; font-weight: 700; color: var(--muted); }
.leaderboard li:nth-child(-n+3) .rank { color: var(--gold-ink); }
.leaderboard .grow { flex: 1; min-width: 0; display: grid; }
.leaderboard .grow span { color: var(--muted); font-size: 14px; }
.lb-rating { font: 700 1.2rem/1 var(--font); }

/* ---------- member games ---------- */
.rt { font-weight: 500; color: var(--muted); font-size: 0.92em; }
.rt-diff { font-weight: 700; font-size: 0.9em; margin-left: 4px; }
.rt-diff.up { color: var(--good); }
.rt-diff.down { color: var(--bad); }
.game-list { display: grid; gap: 6px; }
.game-list h2, .new-game h2 { font: 700 0.95rem/1.3 var(--font); color: var(--muted); }
.game-row { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); text-decoration: none; }
a.game-row:hover { background: var(--hover); }
.game-row .grow { flex: 1; min-width: 0; display: grid; }
.game-row .grow span { color: var(--muted); font-size: 14px; }
.new-game { display: grid; gap: 14px; padding-top: 4px; }
.new-game .seg button { padding: 0 11px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  :root { --side: 200px; }
  main { padding: 24px 24px 40px; }
  .board-page { --board-size: min(calc(100dvh - 56px), 640px, calc(100vw - var(--side) - 400px)); }
}
@media (max-width: 860px) {
  :root { --header: 56px; }
  .sidenav { display: none; }
  .top { position: sticky; top: 0; z-index: 30; height: var(--header); background: var(--navy); color: var(--on-navy); display: flex; align-items: center; gap: 10px; padding: 0 12px; padding-top: env(safe-area-inset-top); }
  .top .brand img { width: 32px; height: 32px; }
  .top .brand-name { font-size: 12.5px; }
  .top-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
  .top .me-btn { width: auto; padding: 0 4px; }
  .top .btn.small { min-height: 36px; padding: 0 12px; }
  main { margin-left: 0; padding: 16px 16px 96px; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a { display: grid; justify-items: center; gap: 2px; padding: 8px 0 10px; font-size: 12px; font-weight: 600; color: var(--muted); text-decoration: none; }
  .tabbar a[aria-current="page"] { color: var(--text); box-shadow: inset 0 3px 0 var(--gold); }
  .board-page, .board-page.with-bar { grid-template-columns: minmax(0, 1fr); --board-size: min(calc(100vw - 32px), 560px); gap: 14px; }
  .board-page.with-bar .evalbar { display: none; }
  .side { max-height: none; }
  .two-col, .profile-grid, .three-col { grid-template-columns: minmax(0, 1fr); }
  .dash { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-auto-rows: auto; gap: 12px; }
  .tile-play { grid-column: 1 / -1; grid-row: auto; display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1fr); align-items: center; }
  .tile-board { padding: 14px 0 14px 14px; }
  .tile-body { padding: 14px; }
  .tile-actions { grid-template-columns: minmax(0, 1fr); }
  .tile { padding: 16px; }
  .join-band { padding: 18px; }
  .panel-side { height: auto; max-height: none; border-radius: 0; border-width: 1px 0 0; background: var(--bg); padding: 0 16px 16px; }
  .panel-head { margin: 0 -16px; padding: 4px 16px 4px 6px; min-height: 48px; background: var(--bg); position: static; }
  .panel-head h1 { font-size: 1.15rem; }
  .panel-foot { position: sticky; bottom: calc(57px + env(safe-area-inset-bottom)); margin: 0 -16px; padding: 10px 16px; background: var(--bg); }
  .auth { margin-top: 8px; }
  .board-page.hub > .board-shell { display: none; }
  .board-page.hub { margin-top: -16px; }
  .levels { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .acc-grid { grid-template-columns: 1fr 1fr; }
  .games-table thead { display: none; }
  .games-table tr { display: grid; grid-template-columns: 1fr auto; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .games-table td { border: 0; padding: 2px 6px; }
  .games-table td:last-child { grid-column: 1 / -1; }
  .record { width: calc(50% - 6px); }
  .menu { right: 8px !important; left: auto !important; }
}
/* Phone: board edge to edge, the thing you came for first, browse controls in thumb reach. */
@media (max-width: 860px) {
  .board-page, .board-page.with-bar { --board-size: min(100vw, 600px); margin: -16px -16px 0; justify-items: center; }
  .board-page > .side { width: 100%; padding: 0 16px; overflow: visible; }
  .board-shell .cg-board { border-radius: 0; }
  .side > .review-head { display: contents; }
  .review-head > div:first-child { order: 0; }
  .side > * { order: 2; }
  .side > :first-child { order: 0; }
  .side > [data-coach], .side > [data-status], .side > [data-result], .side > .player { order: 1; }
  .side .nav-row { position: sticky; top: auto; bottom: calc(57px + env(safe-area-inset-bottom)); order: 3; margin: 0 -16px; padding: 4px 8px; background: var(--surface); border-top: 1px solid var(--line); justify-content: space-around; }
  .side .nav-row .btn { min-height: 44px; }
  .side .nav-row { flex-wrap: nowrap; }
  .hide-phone { display: none; }
  textarea, input, select { font-size: 16px; }
  h1.title { font-size: 1.5rem; }
  .page-head { margin-bottom: 14px; }
}
@media (max-width: 420px) {
  .top .brand-name { display: none; }
  .tile-play { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .tile-body { gap: 8px; }
  .tile-actions .btn { min-height: 40px; }
  .tile h2 { font-size: 1.05rem; }
  .tile-head { gap: 6px; }
  .tile-head .ico { width: 17px; height: 17px; }
}
/* Phone turned sideways: board on the left at screen height, controls beside it. */
@media (max-width: 860px) and (orientation: landscape) and (max-height: 520px) {
  .board-page, .board-page.with-bar { grid-template-columns: var(--board-size) minmax(0, 1fr); --board-size: calc(100dvh - var(--header) - 57px - env(safe-area-inset-bottom)); justify-items: stretch; gap: 0 16px; }
  .board-page > .side { padding: 12px 16px 0 0; max-height: var(--board-size); overflow-y: auto; }
  .side .nav-row { position: static; margin: 0; border: 1px solid var(--line); border-radius: var(--radius); }
  .board-page > .panel-side { display: block; height: var(--board-size); max-height: var(--board-size); overflow-y: auto; padding-top: 0; }
  .panel-side > * { margin-bottom: 12px; }
  .panel-foot { position: static; margin: 0; padding: 0; background: none; }
}
/* Touch screens: small buttons still get a thumb-sized target. */
@media (pointer: coarse) {
  .btn.small, .top .btn.small { min-height: 40px; }
  .top .me-btn { min-width: 44px; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
  .pc, .evalbar .white, .progress > div { transition: none; }
  .spinner { animation-duration: 2s; }
}
