/* Game of the Day. A club's demonstration board and scoresheet: the board is the biggest thing
   on the screen, the scoresheet sits beside it, everything else is reference and stays quiet.
   One type scale (12/14/16/20/28/40), three families with one job each:
   Bricolage Grotesque for the interface, Source Serif 4 for prose (move comments, lesson plan,
   trivia), JetBrains Mono for moves, FEN and numbers. */
:root {
  --bg: #f3f5f1;
  --surface: #ffffff;
  --sunk: #e9ede8;          /* wells: scoresheet header, eval graph, inputs */
  --ink: #17211c;
  --muted: #55645b;
  --line: #d6ddd7;
  --line-strong: #aab6ae;
  --accent: #2f7a4f;        /* bamboo green: the current move and the one primary action */
  --accent-ink: #ffffff;
  --on-strong: #ffffff;     /* text on a blunder / brilliant fill */
  --accent-soft: #e2efe6;
  --sq-light: #e9e4d4;
  --sq-dark: #7d9a86;
  --sq-last: rgba(240, 200, 60, .5);
  --sq-sel: rgba(47, 122, 79, .55);
  --arrow: rgba(31, 122, 140, .85);
  --good: #23784a;
  --warn: #8a6400;          /* inaccuracy */
  --mistake: #b2561a;
  --bad: #b23a2e;           /* blunder */
  --brilliant: #1f7a8c;
  --bad-soft: #fbe9e6;
  --eval-w: #f4f4f0;
  --eval-b: #2a302c;
  --shadow: 0 1px 2px rgba(20, 30, 24, .08), 0 8px 24px rgba(20, 30, 24, .08);
  --f-ui: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --f-prose: "Source Serif 4", Georgia, "Times New Roman", serif;
  --f-mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --t-xs: 12px; --t-sm: 14px; --t-md: 16px; --t-lg: 20px; --t-xl: 28px; --t-2xl: 40px;
  --r: 6px;
  --board: clamp(300px, calc(100vh - 252px), 640px);
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #111613; --surface: #181f1b; --sunk: #1f2823; --ink: #e6ece8; --muted: #9eada4; --line: #2c3731; --line-strong: #46544c;
  --accent: #6cc28f; --accent-ink: #0d1a12; --on-strong: #0d1a12; --accent-soft: #1f3529; --sq-light: #cdc7b2; --sq-dark: #5f7f69;
  --arrow: rgba(111, 195, 214, .85);
  --good: #6cc28f; --warn: #e0b84a; --mistake: #f0a060; --bad: #ef8a7d; --brilliant: #6fc3d6; --bad-soft: #3a2220;
  --eval-w: #e8e8e2; --eval-b: #0b0e0c; --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35); color-scheme: dark; } }
:root[data-theme="dark"] {
  --bg: #111613; --surface: #181f1b; --sunk: #1f2823; --ink: #e6ece8; --muted: #9eada4; --line: #2c3731; --line-strong: #46544c;
  --accent: #6cc28f; --accent-ink: #0d1a12; --on-strong: #0d1a12; --accent-soft: #1f3529; --sq-light: #cdc7b2; --sq-dark: #5f7f69;
  --arrow: rgba(111, 195, 214, .85);
  --good: #6cc28f; --warn: #e0b84a; --mistake: #f0a060; --bad: #ef8a7d; --brilliant: #6fc3d6; --bad-soft: #3a2220;
  --eval-w: #e8e8e2; --eval-b: #0b0e0c; --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35); color-scheme: dark; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 var(--t-md)/1.5 var(--f-ui); }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px 48px; }
a { color: var(--accent); }
h1, h2, h3, h4 { font-family: var(--f-ui); margin: 0; text-wrap: balance; }
h2 { font-size: var(--t-lg); font-weight: 700; line-height: 1.25; }
h3 { font-size: var(--t-md); font-weight: 700; }
h4 { font-size: var(--t-sm); font-weight: 700; }
.small { font-size: var(--t-sm); color: var(--muted); }
.label { font: 600 var(--t-xs)/1.3 var(--f-ui); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.prose { font-family: var(--f-prose); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---- top bar: brand, the day, help ---- */
.topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; min-height: 52px; border-bottom: 1px solid var(--line); }
.brand { font-size: var(--t-sm); font-weight: 700; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; min-width: 0; }
.brand-sub { font-weight: 500; color: var(--muted); }
.backlink { font-weight: 600; text-decoration: none; margin-right: 8px; }
.backlink:hover { text-decoration: underline; }
.daystrip { display: flex; align-items: center; gap: 4px; }
.day { font: 600 var(--t-sm) var(--f-ui); min-width: 9.5em; text-align: center; font-variant-numeric: tabular-nums; }
.top-links { display: flex; justify-content: flex-end; align-items: center; gap: 12px; font-size: var(--t-sm); }
.quiet { color: var(--muted); text-decoration: none; font-weight: 600; font-size: var(--t-sm); }
a.quiet:hover { color: var(--accent); }
.icon { width: 32px; height: 32px; border-radius: var(--r); border: 1px solid transparent; background: none; color: var(--ink); font: 600 var(--t-sm) var(--f-ui); cursor: pointer; display: inline-grid; place-items: center; }
.icon:hover:not(:disabled) { border-color: var(--line-strong); }
.icon:disabled { color: var(--line-strong); cursor: default; }
.icon.help { border-color: var(--line-strong); border-radius: 50%; }

/* ---- headline ---- */
.headline { padding: 14px 0 10px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 20px; }
h1 { font-size: var(--t-xl); line-height: 1.15; font-weight: 700; letter-spacing: -.01em; }
.dek { margin: 0; flex: 1 1 360px; font: var(--t-sm)/1.45 var(--f-prose); color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---- primary tabs: an underlined bar, not pills ---- */
.tabs { display: flex; gap: 0 20px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; font: 600 var(--t-sm) var(--f-ui); padding: 10px 0 9px; border: 0; border-bottom: 3px solid transparent; background: none; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.tab.day-tab { color: var(--ink); font-weight: 700; }
.tab-gap { flex: none; width: 1px; margin: 10px 0; background: var(--line); }

/* ---- layout ---- */
.app { display: grid; grid-template-columns: auto minmax(340px, 1fr); gap: 24px; align-items: start; }
.app.wide { grid-template-columns: minmax(0, 1fr); }
.stage { display: flex; flex-direction: column; gap: 10px; min-width: 0; }

/* ---- board ---- */
.board-row { display: flex; gap: 8px; align-items: stretch; }
.evalbar { position: relative; width: 14px; height: var(--board); border-radius: 3px; background: var(--eval-b); overflow: hidden; flex: none; border: 1px solid var(--line-strong); }
.evalbar .fill { position: absolute; left: 0; right: 0; bottom: 0; height: 50%; background: var(--eval-w); }
.evalbar.flipped .fill { bottom: auto; top: 0; }
.evalbar .ev { position: absolute; left: 0; right: 0; bottom: 2px; font: 600 9px var(--f-mono); text-align: center; color: var(--eval-b); writing-mode: vertical-rl; transform: rotate(180deg); }
.evalbar.black-ahead .ev { bottom: auto; top: 2px; color: var(--eval-w); }
.evalbar.flipped .ev { bottom: auto; top: 2px; }
.evalbar.flipped.black-ahead .ev { top: auto; bottom: 2px; }
.evalbar.off { visibility: hidden; }
@media (prefers-reduced-motion: no-preference) { .evalbar .fill { transition: height .25s ease; } }

.board-frame { display: grid; grid-template-columns: 18px var(--board); grid-template-rows: var(--board) 18px; }
.ranks { display: grid; grid-template-rows: repeat(8, 1fr); }
.files { display: grid; grid-template-columns: repeat(8, 1fr); }
.ranks span, .files span { display: flex; align-items: center; justify-content: center; font: 600 var(--t-xs) var(--f-mono); color: var(--muted); }
.board-box { position: relative; width: var(--board); height: var(--board); }
.board { display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); width: 100%; height: 100%; border-radius: 3px; overflow: hidden; user-select: none; box-shadow: 0 0 0 1px var(--line-strong); }
.overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.sq { position: relative; display: flex; align-items: center; justify-content: center; border: 0; padding: 0; margin: 0; cursor: default; border-radius: 0; }
.sq.l { background: var(--sq-light); } .sq.d { background: var(--sq-dark); }
.sq.hi::before, .sq.sel::before { content: ""; position: absolute; inset: 0; }
.sq.hi::before { background: var(--sq-last); }
.sq.sel::before { background: var(--sq-sel); }
.sq.tgt::after { content: ""; position: absolute; width: 28%; height: 28%; border-radius: 50%; background: rgba(20, 40, 30, .35); }
.sq.tgt.cap::after { width: 86%; height: 86%; background: transparent; border: 4px solid rgba(20, 40, 30, .35); }
.sq.check { background: radial-gradient(circle, #e8443a 0%, rgba(232, 68, 58, .4) 45%, transparent 75%), var(--sq-dark); }
.sq:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; z-index: 2; }
.sq .co { position: absolute; font: 600 9px var(--f-mono); line-height: 1; display: none; z-index: 1; }
.sq.l .co { color: var(--sq-dark); } .sq.d .co { color: var(--sq-light); }
.sq .co.r { top: 2px; left: 2px; } .sq .co.f { bottom: 2px; right: 3px; }
.pc { position: relative; z-index: 1; width: 90%; height: 90%; pointer-events: none; }
.playable .sq { cursor: pointer; }
.overlay .arrow { fill: var(--arrow); }
.overlay .badge circle { stroke: var(--surface); stroke-width: 4; }
.overlay .badge text { font: 700 34px var(--f-mono); fill: var(--on-strong); text-anchor: middle; dominant-baseline: central; }
.overlay .badge.blunder circle { fill: var(--bad); }
.overlay .badge.mistake circle { fill: var(--mistake); }
.overlay .badge.inaccuracy circle { fill: var(--warn); }
.overlay .badge.brilliant circle { fill: var(--brilliant); }

/* ---- Copy PGN / Open in PandaChess, under the moves ---- */
.pgn-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; flex: none; }
.pgn-msg { flex: 1 1 12em; min-width: 0; }
.pgn-msg:empty { display: none; }

/* ---- toolbar under the board ---- */
.toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding-left: 40px; width: calc(var(--board) + 40px); }
.toolbar .group { display: flex; gap: 4px; flex-wrap: wrap; }
.btn { font: 600 var(--t-sm) var(--f-ui); min-height: 36px; padding: 6px 12px; border-radius: var(--r); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; min-width: 40px; }
.btn:hover:not(:disabled) { border-color: var(--ink); }
.btn:disabled { opacity: .35; cursor: default; }
.btn.quiet { border-color: transparent; background: none; }
.btn.quiet:hover:not(:disabled) { border-color: var(--line-strong); }
.btn[aria-pressed="true"], .btn[aria-expanded="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.menu { position: relative; }
.tools { position: absolute; right: 0; bottom: calc(100% + 6px); z-index: 20; width: min(380px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: var(--shadow); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.tools input { width: 100%; font: var(--t-xs) var(--f-mono); padding: 8px; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--sunk); color: var(--ink); }
.tools .row { display: flex; gap: 6px; flex-wrap: wrap; }
.tools-h { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 2px; }
.pieceset { align-items: center; }
.pieceset .small { margin-right: auto; }
.pieceset .btn { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px 4px 6px; }
.pieceset .btn img { width: 26px; height: 26px; background: var(--sq-dark); border-radius: 3px; }

/* ---- side panel ---- */
.panel { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.app:not(.wide) .panel { height: calc(var(--board) + 18px + 46px); }
.panel-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.panel-head .who { min-width: 0; }
.panel-head .sub { font-size: var(--t-sm); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r); overflow: hidden; flex: none; }
.seg button { font: 600 var(--t-xs) var(--f-ui); letter-spacing: .04em; text-transform: uppercase; padding: 6px 10px; border: 0; background: none; color: var(--muted); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line-strong); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }

/* the move on the board, its comment, the engine's view */
.now { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.now.bad { border-color: var(--bad); background: var(--bad-soft); }
.now.brilliant { border-color: var(--brilliant); }
.now-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.now-move { font: 600 var(--t-lg) var(--f-mono); }
.now-move .cls { font: 600 var(--t-xs) var(--f-ui); letter-spacing: .06em; text-transform: uppercase; margin-left: 8px; vertical-align: 2px; }
.now-eval { font: 600 var(--t-sm) var(--f-mono); color: var(--muted); white-space: nowrap; }
.now-note { font: var(--t-md)/1.5 var(--f-prose); margin: 0; max-height: 9em; overflow-y: auto; }
.now-note:empty { display: none; }
.engine-line { font: var(--t-xs)/1.5 var(--f-mono); color: var(--muted); }
.now-count { display: none; }
.cls-blunder { color: var(--bad); } .cls-mistake { color: var(--mistake); } .cls-inaccuracy { color: var(--warn); } .cls-brilliant { color: var(--brilliant); }

/* scoresheet: numbered White / Black columns */
.sheet-wrap { flex: 1 1 auto; min-height: 120px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
table.sheet { width: 100%; border-collapse: collapse; font: var(--t-sm)/1 var(--f-mono); table-layout: fixed; }
table.sheet thead th { position: sticky; top: 0; z-index: 1; background: var(--sunk); font: 600 var(--t-xs) var(--f-ui); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.sheet th.no, table.sheet td.no { width: 3.2em; text-align: right; color: var(--muted); padding-right: 10px; }
table.sheet td { padding: 0; border-bottom: 1px solid var(--line); height: 30px; }
table.sheet tr:nth-child(5n) td { border-bottom-color: var(--line-strong); }
.mv { width: 100%; height: 100%; text-align: left; border: 0; background: none; color: var(--ink); font: inherit; padding: 0 8px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mv:hover { background: var(--accent-soft); }
.mv .g { font-weight: 600; margin-left: 2px; }
/* the mark and the "sac" badge are generated text: they show, but are never part of copied text */
.mv .g::before, .mv .sac::before { content: attr(data-t); }
.mv.blunder { color: var(--bad); font-weight: 600; } .mv.mistake { color: var(--mistake); font-weight: 600; }
.mv.inaccuracy { color: var(--warn); } .mv.brilliant { color: var(--brilliant); font-weight: 600; }
.mv.cur { background: var(--accent); color: var(--accent-ink); }
.mv.cur.blunder, .mv.cur.mistake { background: var(--bad); color: var(--on-strong); }
.mv.cur.brilliant { background: var(--brilliant); color: var(--on-strong); }
.mv .sac { font: 600 10px var(--f-ui); margin-left: 6px; letter-spacing: .04em; text-transform: uppercase; opacity: .8; }

.evalgraph { width: 100%; height: 48px; display: block; border-radius: 6px; background: var(--sunk); flex: none; }
.evalgraph .w { fill: var(--eval-w); }
.evalgraph .line { fill: none; stroke: var(--line-strong); stroke-width: 1; }
.evalgraph .mid { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 4; opacity: .5; }
.evalgraph .cur { stroke: var(--accent); stroke-width: 2; }
.evalgraph .hit { fill: transparent; cursor: pointer; }
.evalgraph .bl { fill: var(--bad); }
.evalgraph .br { fill: var(--brilliant); }
:root .evalgraph { --eval-w: #cfd6d1; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .evalgraph { --eval-w: #56635b; } }
:root[data-theme="dark"] .evalgraph { --eval-w: #56635b; }

/* about this game: reference, read between moves */
.about { overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding-right: 2px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; margin: 0; font-size: var(--t-sm); }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.scores { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.scores td { padding: 5px 0; border-bottom: 1px solid var(--line); vertical-align: baseline; }
.scores .v { font: 600 var(--t-md) var(--f-mono); width: 2.4em; text-align: right; padding-right: 12px; }
.scores .src { font-size: var(--t-xs); color: var(--muted); text-align: right; white-space: nowrap; }
.scores tr.curated .v { color: var(--accent); }
.scores .why { color: var(--muted); font-size: var(--t-xs); display: block; }
.taglist { font-size: var(--t-sm); color: var(--muted); margin: 0; }
details.sec { border-top: 1px solid var(--line); padding-top: 10px; }
details.sec summary { cursor: pointer; font: 700 var(--t-sm) var(--f-ui); list-style: none; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
details.sec summary::-webkit-details-marker { display: none; }
details.sec summary::after { content: "+"; font-family: var(--f-mono); color: var(--muted); }
details.sec[open] summary::after { content: "–"; }
details.sec > div { margin-top: 10px; display: flex; flex-direction: column; gap: 10px; font: var(--t-sm)/1.55 var(--f-prose); }
.terms { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; }
.terms dt { font: 700 var(--t-sm) var(--f-ui); }
.terms dd { margin: 0; }
.jump { font: 600 var(--t-xs) var(--f-mono); color: var(--accent); background: none; border: 0; cursor: pointer; padding: 0 2px; text-decoration: underline; text-underline-offset: 2px; }
.trivia { margin: 0; padding-left: 18px; }
.trivia li { margin-bottom: 6px; }
.trivia .kind { font: 600 var(--t-xs) var(--f-ui); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-right: 6px; }
.trivia .src { display: block; font-size: var(--t-xs); color: var(--muted); }
.lesson-card { border-top: 1px solid var(--line); padding-top: 8px; }
.lesson-card ol { margin: 6px 0 0; padding-left: 20px; }
.theory .row { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 12px; padding-block: 8px; border-bottom: 1px solid var(--line); }
.theory .t { font: 600 var(--t-xs) var(--f-mono); color: var(--muted); }
.theory p { margin: 2px 0 0; }

/* coach view: the day's 45-minute plan beside the board */
.lp { overflow-y: auto; display: flex; flex-direction: column; }
.lp .step { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.lp .t { font: 600 var(--t-xs) var(--f-mono); color: var(--accent); padding-top: 3px; font-variant-numeric: tabular-nums; }
.lp ul { margin: 4px 0 0; padding-left: 18px; font: var(--t-sm)/1.55 var(--f-prose); }
.lp li { margin-bottom: 4px; }
.lp .jump { font-size: inherit; font-family: var(--f-mono); padding: 0; }

/* ---- puzzles ---- */
.status { font: 700 var(--t-md) var(--f-ui); }
.status.ok { color: var(--good); } .status.no { color: var(--bad); }
.pz-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.plist { display: flex; flex-direction: column; overflow-y: auto; border-top: 1px solid var(--line); min-height: 0; }
.pitem { text-align: left; border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--ink); padding: 9px 10px; cursor: pointer; font: var(--t-sm) var(--f-ui); display: grid; grid-template-columns: 2em minmax(0, 1fr) auto; gap: 2px 8px; align-items: baseline; }
.pitem:hover { background: var(--accent-soft); }
.pitem[aria-current="true"] { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.pitem .n { font: 600 var(--t-xs) var(--f-mono); color: var(--muted); }
.pitem .tt { font-weight: 600; }
.pitem .meta { grid-column: 2; color: var(--muted); font-size: var(--t-xs); }
.pitem .stars { font-size: var(--t-xs); color: var(--warn); letter-spacing: 1px; white-space: nowrap; }
details.sol summary { cursor: pointer; font: 700 var(--t-sm) var(--f-ui); }
details.sol > div { margin-top: 8px; font: var(--t-sm)/1.55 var(--f-prose); }
.pack-head { display: flex; flex-direction: column; gap: 6px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.pack-head ol { margin: 0; padding-left: 20px; }
.pack-head .btn { align-self: flex-start; }

/* ---- wide views: rankings, packs, archive ---- */
.view-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 20px; }
.view-head p { margin: 0; max-width: 70ch; }
.filters { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: var(--t-sm); }
.fchip { font: 600 var(--t-sm) var(--f-ui); padding: 4px 0; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); cursor: pointer; }
.fchip span { font: var(--t-xs) var(--f-mono); margin-left: 3px; }
.fchip:hover { color: var(--ink); }
.fchip[aria-pressed="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.rank-tools { display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: center; }
.search { flex: 1 1 260px; font: var(--t-sm) var(--f-ui); padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface); color: var(--ink); }
.seen-toggle { display: flex; align-items: center; gap: 6px; }
details.weights-box summary { cursor: pointer; font: 600 var(--t-sm) var(--f-ui); color: var(--muted); }
.weights { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px 16px; margin-top: 8px; }
.weights label { display: flex; flex-direction: column; font: 600 var(--t-xs) var(--f-ui); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); gap: 2px; }
.weights input { width: 100%; accent-color: var(--accent); }
.weights output { color: var(--ink); font-family: var(--f-mono); }
.rank-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
table.rank { border-collapse: collapse; width: 100%; font-size: var(--t-sm); min-width: 680px; }
table.rank th, table.rank td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
table.rank th { font: 600 var(--t-xs) var(--f-ui); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--sunk); }
table.rank th button { all: unset; cursor: pointer; }
table.rank th button:focus-visible { outline: 3px solid var(--accent); }
table.rank th[aria-sort="descending"] button::after { content: " ▼"; }
table.rank th[aria-sort="ascending"] button::after { content: " ▲"; }
table.rank td.n { font-family: var(--f-mono); text-align: right; }
table.rank th.n { text-align: right; }
table.rank td.n.cur { color: var(--accent); font-weight: 600; }
table.rank tr.row { cursor: pointer; }
table.rank tr.row:hover td, table.rank tr.row:focus-visible td { background: var(--accent-soft); outline: none; }
table.rank .comp { font-weight: 700; }
table.rank .gt { font-weight: 600; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.seen { font: 600 var(--t-xs) var(--f-ui); color: var(--good); white-space: nowrap; margin-left: 6px; }
.packs { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.pack { text-align: left; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); padding: 14px; cursor: pointer; font: var(--t-sm) var(--f-ui); display: flex; flex-direction: column; gap: 4px; }
.pack:hover { border-color: var(--ink); }
.pack b { font-size: var(--t-md); }

/* archive: one card per day, newest first */
.days { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.day-card { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow: hidden; }
.day-card[aria-current="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.day-card a { display: flex; flex-direction: column; gap: 10px; padding: 12px; color: inherit; text-decoration: none; height: 100%; }
.day-card a:hover h3 { text-decoration: underline; }
.day-card .when { display: flex; justify-content: space-between; gap: 8px; font-size: var(--t-xs); }
.day-card .when b { font-family: var(--f-mono); font-weight: 600; }
.day-card .kind { color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.day-card .kind.coach { color: var(--accent); }
.day-card .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.day-card .pair figure { margin: 0; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.day-card figcaption { font-size: var(--t-xs); line-height: 1.3; color: var(--muted); }
.day-card figcaption b { display: block; color: var(--ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini { display: grid; grid-template-columns: repeat(8, 1fr); aspect-ratio: 1; border-radius: 2px; overflow: hidden; box-shadow: 0 0 0 1px var(--line-strong); }
.mini i { display: block; aspect-ratio: 1; background: var(--sq-light); }
.mini i.d { background: var(--sq-dark); }
.mini i.h { box-shadow: inset 0 0 0 100px var(--sq-last); }
.mini img { width: 100%; height: 100%; display: block; }
.month { grid-column: 1 / -1; margin: 10px 0 -4px; }

/* ---- free board / notices ---- */
.notice { padding: 14px; border: 1px solid var(--bad); border-radius: 8px; background: var(--bad-soft); }
.explore-moves { font: var(--t-sm)/1.8 var(--f-mono); }

/* ---- help ---- */
.help-box { max-width: 520px; width: calc(100vw - 32px); border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); padding: 18px 20px; position: fixed; inset: 64px 16px auto auto; margin: 0; z-index: 30; }
.help-box::backdrop { background: rgba(0, 0, 0, .25); }
.help-head { display: flex; justify-content: space-between; align-items: center; }
.help-box ol { margin: 10px 0 0; padding-left: 20px; font: var(--t-sm)/1.55 var(--f-prose); }
.help-box li { margin: 6px 0; }

footer { margin-top: 32px; padding-top: 12px; border-top: 1px solid var(--line); }
.mbar { display: none; }

/* ---- phone and narrow tablets ---- */
@media (max-width: 860px) {
  :root { --board: calc(100vw - 32px); }
  .topbar { grid-template-columns: 1fr auto; grid-template-areas: "brand links" "day day"; padding-block: 6px; gap: 0 12px; }
  .brand { grid-area: brand; } .top-links { grid-area: links; } .daystrip { grid-area: day; justify-content: center; border-top: 1px solid var(--line); padding-top: 4px; margin-top: 4px; }
  .brand-sub { display: none; }
  .top-links .quiet { display: none; }
  h1 { font-size: var(--t-lg); }
  .headline { padding: 10px 0 6px; }
  .app { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .app:not(.wide) .panel { height: auto; }
  .board-row { flex-direction: column; gap: 4px; }
  .evalbar { width: var(--board); height: 8px; order: 2; }
  .evalbar .fill { top: 0; bottom: 0; left: 0; right: auto; height: auto !important; width: var(--w, 50%); }
  .evalbar.flipped .fill { left: auto; right: 0; }
  .evalbar .ev { display: none; }
  .board-frame { grid-template-columns: var(--board); grid-template-rows: var(--board); }
  .ranks, .files, .board-frame > span { display: none; }
  .sq .co { display: block; }
  .toolbar { padding-left: 0; width: auto; }
  .toolbar .group:first-child { display: none; }
  .tools { bottom: auto; top: calc(100% + 6px); }
  .sheet-wrap { max-height: 300px; flex: none; }
  .about, .lp, .plist { overflow: visible; }
  .mbar { position: sticky; bottom: 0; z-index: 10; display: grid; grid-template-columns: 56px 1fr 56px; align-items: center; gap: 8px; margin: 12px -16px 0; padding: 8px 16px calc(8px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line-strong); }
  .mbar .btn { min-height: 44px; font-size: var(--t-lg); }
  .mbar-move { text-align: center; font: 600 var(--t-md) var(--f-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mbar-move .ev { color: var(--muted); font-size: var(--t-sm); margin-left: 6px; }
  body:not(.mode-game) .mbar { display: none; }
  .lp .step, .theory .row { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .days { grid-template-columns: minmax(0, 1fr); }
  .help-box { inset: 56px 16px auto 16px; width: auto; }
}

/* ---- Present: the board and the comment, big enough for the back row ---- */
body.present { overflow: hidden; }
body.present .topbar, body.present .headline, body.present .tabs, body.present footer, body.present .mbar,
body.present .panel > :not(.now), body.present .toolbar .group:last-child > :not(#b-present):not(#b-flip) { display: none !important; }
body.present .wrap { max-width: none; padding: 20px 28px; }
body.present { --board: min(calc(100vh - 100px), calc(100vw - 620px)); }
body.present .app { grid-template-columns: auto minmax(0, 1fr); gap: 36px; align-items: center; min-height: calc(100vh - 40px); }
body.present .app:not(.wide) .panel { height: auto; }
body.present .now { border: 0; background: none; padding: 0; gap: 18px; }
body.present .now.bad .now-move { color: var(--bad); }
body.present .now-move { font-size: var(--t-2xl); }
body.present .now-move .cls { font-size: var(--t-md); }
body.present .now-eval { font-size: var(--t-lg); }
body.present .now-note { font-size: 30px; line-height: 1.4; max-height: none; }
body.present .engine-line { font-size: var(--t-lg); }
body.present .now-count { display: block; font: 600 var(--t-md) var(--f-ui); color: var(--muted); }
body.present .toolbar { width: calc(var(--board) + 40px); }
@media (max-width: 860px) {
  body.present { --board: min(calc(100vw - 40px), calc(100vh - 260px)); overflow: auto; }
  body.present .app { grid-template-columns: minmax(0, 1fr); align-items: start; }
  body.present .now-note { font-size: var(--t-xl); }
}
body.present .engine-line { font-family: var(--f-prose); color: var(--muted); }

/* ---- mini-board previews, switched on and off (desktop only) ---- */
.view-head .boards-switch { order: 2; align-self: center; }
.view-head > p { order: 3; flex-basis: 100%; }
.seg .seg-label { font: 600 var(--t-xs) var(--f-ui); letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding: 6px 10px; border-right: 1px solid var(--line-strong); }
.rank-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.rank-preview { position: sticky; top: 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.rank-preview h3 { font-size: var(--t-lg); }
.rank-preview .mini { width: 100%; }
.rank-preview .seg { align-self: flex-start; }
.rank-preview .cap { margin: -4px 0 0; font-size: var(--t-xs); }
.rank-preview .btn { align-self: stretch; }
table.rank tr.row[aria-selected="true"] td { background: var(--accent-soft); }
table.rank tr.row[aria-selected="true"] td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.days.compact { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.day-card.compact a { gap: 6px; }
.day-card.compact .pair { grid-template-columns: 1fr; gap: 2px; }
.day-card.compact figcaption { display: flex; justify-content: space-between; gap: 8px; }
.day-card.compact figcaption b { order: 2; min-width: 0; }
.day-card.compact figcaption span { flex: none; }
@media (max-width: 860px) { .boards-switch { display: none; } }
/* with the preview beside it, the table gives up width by wrapping long game names */
.rank-layout table.rank { min-width: 0; }
.rank-layout table.rank th, .rank-layout table.rank td { padding: 8px 6px; }
.rank-layout table.rank td:nth-child(3) { white-space: normal; min-width: 220px; }
