/* Guess the Move. Design tokens first; light is the default, dark follows the system or the toggle (data-theme on <html>).
 * No inline styles anywhere: the Content-Security-Policy forbids them (tests/test_containers.py). */
:root {
--page-max: 1180px; --board-max: 680px; --panel-max: 1fr; /* page, board and panel limits; they grow on large screens (below) */
--t-brilliant: #0e8f8f; --t-great: #5b4bd6; --t-best: #1f8a3d; --t-excellent: #4f8f2a; --t-good: #7b8a17; --t-inaccuracy: #b07d00; --t-mistake: #c9561a; --t-blunder: #c62828;
  --bg: #f6f5f1; --surface: #ffffff; --surface-2: #efeee8; --fg: #1d1d1b; --muted: #5f5f59; --line: #d8d6cc;
  --accent: #1d5fd1; --accent-fg: #ffffff; --focus: #1d5fd1; --warn-bg: #fff4d6; --warn-fg: #5a4300; --warn-line: #ecd48a;
  --sq-light: #f0d9b5; --sq-dark: #b58863; --coord-light: #7a5a3b; --coord-dark: #fff3df;
  --sel: rgba(29, 95, 209, .42); --hint: rgba(20, 20, 20, .3); --pending: rgba(0, 158, 115, .45);
  --c-you: #cc79a7; --c-best: #009e73; --c-real: #0072b2; --c-maia: #e69f00; --halo: rgba(20, 20, 20, .55);
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px;
  --radius: 10px; --radius-sm: 6px; --shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 4px 14px rgba(0, 0, 0, .06);
  --fs-sm: .875rem; --fs-md: 1rem; --fs-lg: 1.2rem; --fs-xl: 1.6rem; --tap: 44px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #151513; --surface: #1f1f1c; --surface-2: #292925; --fg: #ecebe6; --muted: #a8a79e; --line: #3a3a35;
  --accent: #7fb0ff; --accent-fg: #0b1b36; --focus: #9ec3ff; --warn-bg: #3a3012; --warn-fg: #f1deaa; --warn-line: #5c4d1d;
  --sq-light: #d4bf96; --sq-dark: #8f6c4b; --coord-light: #5f4429; --coord-dark: #fff3df;
  --sel: rgba(127, 176, 255, .45); --shadow: 0 1px 2px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: var(--fs-md)/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2 { line-height: 1.2; }
.muted { color: var(--muted); } .small { font-size: var(--fs-sm); }
.sr-only, .skip-link:not(:focus) {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link:focus { position: fixed; top: var(--s-2); left: var(--s-2); z-index: 10; background: var(--surface); padding: var(--s-2) var(--s-3); border-radius: var(--radius-sm); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

button, select { font: inherit; color: inherit; }
button {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 var(--s-4);
  min-height: var(--tap); min-width: var(--tap); cursor: pointer; font-weight: 500;
}
button:hover { background: var(--surface-2); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; }
button.primary:hover { filter: brightness(1.06); }
/* Things you can do with the answer: real buttons, wrapping on a narrow screen. */
.result-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); margin: var(--s-3) 0; }
button.link { border: 0; background: none; color: var(--accent); min-height: var(--tap); padding: 0; }
button[hidden] { display: none; }
select { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0 var(--s-2); min-height: var(--tap); }
.icon-btn { display: inline-grid; place-items: center; padding: 0; }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:root[data-theme="dark"] .icon-moon, :root:not([data-theme="dark"]) .icon-sun { display: none; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); max-width: var(--page-max); margin: 0 auto; padding: var(--s-3) var(--s-4); }
.brand h1 { margin: 0; font-size: var(--fs-xl); white-space: nowrap; }
.sub { margin: 0; color: var(--muted); font-size: var(--fs-sm); }
.brand { min-width: 0; }
.topbar-actions { display: flex; gap: var(--s-2); flex-shrink: 0; }

/* Neither of these may sit in the page flow above <main>: inserting them after load would shift the whole layout (CLS). */
.onboarding {
  position: fixed; z-index: 20; left: var(--s-4); right: var(--s-4); bottom: calc(88px + env(safe-area-inset-bottom));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 28px rgba(0, 0, 0, .28); padding: var(--s-3) var(--s-4);
}
@media (min-width: 900px) { .onboarding { left: auto; right: var(--s-5); bottom: var(--s-5); width: 380px; } }
.onboarding h2 { margin: 0 0 var(--s-2); font-size: var(--fs-lg); }
.onboarding ol { margin: 0 0 var(--s-3); padding-left: var(--s-5); }
.banner { background: var(--warn-bg); color: var(--warn-fg); border: 1px solid var(--warn-line); border-radius: var(--radius); padding: var(--s-3) var(--s-4); margin-bottom: var(--s-3); }
.demo-chip { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 var(--s-3); background: var(--warn-bg); color: var(--warn-fg); border: 1px solid var(--warn-line); border-radius: 999px; font-size: var(--fs-sm); font-weight: 600; text-decoration: none; }
[hidden] { display: none !important; }

/* Layout. Phone first: one column, board edge to edge, sticky action bar. */
#gameMain {
  display: grid; gap: var(--s-4); max-width: var(--page-max); margin: 0 auto; grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "stage" "panel" "bar";
}
.stage { grid-area: stage; } .panel { grid-area: panel; padding: 0 var(--s-4); } .actionbar { grid-area: bar; }
.posinfo { font-weight: 600; padding: 0 var(--s-4) var(--s-2); min-height: 2em; }
.boardwrap { position: relative; width: 100%; aspect-ratio: 1; }
#boardSvg { display: block; width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#boardSvg:focus:not(:focus-visible) { outline: none; } /* no ring after a mouse press; the cursor square shows keyboard focus */
#boardSvg:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.skeleton { position: absolute; inset: 0; background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.slot { min-height: 5.5rem; padding: var(--s-3) var(--s-4) 0; }
.prompt { color: var(--muted); }
.verdict { margin: 0 0 var(--s-2); font-size: var(--fs-lg); font-weight: 650; }
.legend { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-4); font-size: var(--fs-sm); color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-line { width: 44px; height: 14px; }
.promo { display: flex; gap: var(--s-2); align-items: center; padding: var(--s-3) var(--s-4) 0; }
.actionbar {
  position: sticky; bottom: 0; display: flex; gap: var(--s-3); padding: var(--s-3) var(--s-4) calc(var(--s-3) + env(safe-area-inset-bottom));
  background: var(--bg); border-top: 1px solid var(--line);
}
.actionbar button { flex: 1; }

@media (min-width: 481px) and (max-width: 899px) {
  .stage { width: min(100%, 600px); margin: 0 auto; }
  #gameMain { padding: 0 var(--s-4); } .panel { padding: 0; } .posinfo, .chips, .slot, .promo { padding-left: 0; padding-right: 0; }
  .boardwrap { border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
}
@media (min-width: 900px) {
  #gameMain {
    grid-template-columns: clamp(320px, calc(100vh - 190px), var(--board-max)) minmax(300px, var(--panel-max)); justify-content: center; align-items: start; padding: 0 var(--s-4); gap: var(--s-2) var(--s-5);
    grid-template-areas: "stage bar" "stage panel"; grid-template-rows: auto 1fr; /* the extra height of the tall board column goes to the panel row, not between the Skip bar and the panel */
  }
  .panel { padding: 0; } .posinfo, .chips, .slot, .promo { padding-left: 0; padding-right: 0; }
  .boardwrap { border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
  .actionbar { position: static; padding: 0; border: 0; background: none; }
}

/* Board layers */
.sq.light { fill: var(--sq-light); } .sq.dark { fill: var(--sq-dark); }
.coord { font: 700 20px system-ui, sans-serif; pointer-events: none; }
.coord.on-light { fill: var(--coord-light); } .coord.on-dark { fill: var(--coord-dark); }
.sel { fill: var(--sel); } .pending { fill: var(--pending); }
.cursor { fill: none; stroke: var(--focus); stroke-width: 8px; }
.dot { fill: var(--hint); } .ring { fill: none; stroke: var(--hint); stroke-width: 8px; }
.sel, .pending, .cursor, .dot, .ring, .piece, .ghost, .hover, .arrow, .coord { pointer-events: none; }
.piece.drag-origin { opacity: .3; }
.ghost { filter: drop-shadow(0 6px 8px rgba(0, 0, 0, .4)); }
.hover { fill: none; stroke-width: 7px; } .hover.ok { stroke: rgba(255, 255, 255, .85); } .hover.no { stroke: rgba(0, 0, 0, .35); } .hover.off { display: none; }

/* Arrows: colour from the colour-blind-safe Okabe-Ito set, plus a dash style and a letter, so colour is never the only cue. */
.arrow-you { --c: var(--c-you); } .arrow-best { --c: var(--c-best); } .arrow-real { --c: var(--c-real); } .arrow-maia { --c: var(--c-maia); }
.arrow .halo, .legend-line .halo { stroke: var(--halo); fill: none; }
.arrow .main, .legend-line .main { stroke: var(--c); fill: none; }
.arrow .head { fill: var(--c); stroke: var(--halo); stroke-width: 4px; stroke-linejoin: round; paint-order: stroke; }
.arrow-label rect { fill: #fff; stroke: var(--c); stroke-width: 5px; }
.arrow-label text { fill: #111; font: 700 22px system-ui, sans-serif; white-space: pre; text-anchor: middle; dominant-baseline: central; }
.arrow-real .halo, .arrow-real .main { stroke-dasharray: 22 14; }
.arrow-maia .halo, .arrow-maia .main { stroke-dasharray: 26 10 4 10; }
.arrow-you .halo, .arrow-you .main { stroke-dasharray: 1 16; }
.arrow-real .head, .arrow-maia .head, .arrow-you .head { stroke-dasharray: none; }
.arrow { animation: arrow-in .35s ease-out both; }
@keyframes arrow-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .arrow, .skeleton { animation: none; } }

/* Panel */
fieldset, details, .result, .settings { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 var(--s-3); }
fieldset { padding: var(--s-1) var(--s-3) var(--s-2); }
legend { color: var(--muted); font-size: var(--fs-sm); padding: 0 var(--s-1); }
.modes label, .check { display: flex; align-items: center; gap: var(--s-2); min-height: var(--tap); }
.modes label { width: 100%; }
input[type="radio"], input[type="checkbox"] { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
details > summary { min-height: var(--tap); display: flex; align-items: center; gap: var(--s-3); padding: 0 var(--s-3); cursor: pointer; font-weight: 600; }
details > :not(summary) { margin-left: var(--s-3); margin-right: var(--s-3); }
.filter-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); padding-bottom: var(--s-3); } /* minmax(0, ...): a column may be narrower than its select's longest option */
.filter-grid label { display: grid; gap: var(--s-1); font-size: var(--fs-sm); color: var(--muted); }
.filter-grid select { color: var(--fg); width: 100%; min-width: 0; max-width: 100%; text-overflow: ellipsis; }
@media (max-width: 480px) { .filter-grid { grid-template-columns: minmax(0, 1fr); } }
.filter-grid .check { grid-column: 1 / -1; display: flex; align-items: center; gap: var(--s-2); color: var(--fg); font-size: var(--fs-md); }
.settings { padding: var(--s-1) var(--s-3) var(--s-2); } .settings p { margin: 0; }
.result { padding: var(--s-3) var(--s-4); }
.headline { font-size: var(--fs-lg); font-weight: 700; margin: 0 0 var(--s-1); } .big { font-size: 1.5em; }
.detail { margin: var(--s-1) 0 var(--s-2); }
table { border-collapse: collapse; width: 100%; font-size: var(--fs-sm); }
th, td { text-align: left; padding: var(--s-2) var(--s-1); border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; } .num { text-align: right; font-variant-numeric: tabular-nums; }
.chip { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: var(--s-2); vertical-align: -1px; }
.chip-you { background: #cc79a7; } .chip-best { background: #009e73; } .chip-real { background: #0072b2; } .chip-maia { background: #e69f00; }
.cost-bar { display: block; width: 56px; height: 6px; margin: 3px 0 0 auto; }
.cost-bar .bg { fill: var(--line); } .cost-bar .fill { fill: var(--accent); }
.tags { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-2); }
.tag { background: var(--surface-2); border-radius: 999px; padding: 2px var(--s-3); font-size: var(--fs-sm); }
a { color: var(--accent); }
.field { display: block; margin: var(--s-2) 0 var(--s-1); font-size: var(--fs-sm); color: var(--muted); }
textarea, input[type="number"] { width: 100%; font: inherit; color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--s-2); min-height: var(--tap); }
#apiPanel button { margin: var(--s-3) 0 var(--s-1); }
footer { max-width: var(--page-max); margin: var(--s-5) auto var(--s-6); padding: 0 var(--s-4); color: var(--muted); font-size: var(--fs-sm); }

@media (max-width: 480px) {
  .topbar { padding: var(--s-2) var(--s-4); } .brand h1 { font-size: var(--fs-lg); white-space: normal; line-height: 1.15; } .sub { display: none; }
  .topbar-actions { gap: var(--s-1); } /* five buttons: the title wraps before the buttons are pushed off a narrow screen */
  #gameMain { gap: var(--s-3); } .boardwrap { border-radius: 0; box-shadow: none; }
}

/* A link that is its own line of text needs a finger-sized target. */
.tap-link { display: inline-flex; align-items: center; min-height: var(--tap); }

/* Focus mode: only the board and the timer, as large as the screen allows, until you move (a button, or `f`; Esc leaves). */
#focusBtn.off { visibility: hidden; } /* not offered, but it keeps its place: the board must not move when the answer appears */
.icon-focus-off, html.focus-mode .icon-focus-on { display: none; } html.focus-mode .icon-focus-off { display: block; }
html.focus-mode .topbar, html.focus-mode .panel, html.focus-mode .actionbar, html.focus-mode footer, html.focus-mode #chips, html.focus-mode #openingLine,
html.focus-mode #linkBtn, html.focus-mode #updateBar, html.focus-mode #banner, html.focus-mode #linkMsg { display: none; }
html.focus-mode #gameMain { grid-template-columns: minmax(0, 1fr); grid-template-areas: "stage"; grid-template-rows: auto; justify-content: stretch; padding: 0; gap: 0; max-width: none; }
html.focus-mode .stage { width: min(100vw, calc(100vh - 3.5rem)); width: min(100vw, calc(100dvh - 3.5rem)); margin: 0 auto; } /* the line above the board (a 44 px button and padding) takes 52 px */
html.focus-mode .posinfo { padding: var(--s-1) var(--s-3); min-height: 0; }
html.focus-mode .slot { min-height: 0; padding: 0; } html.focus-mode .slot > :not(#live) { display: none; } /* the prompt goes; the screen-reader announcements stay */
html.focus-mode .boardwrap { border-radius: 0; box-shadow: none; }

/* Pages (stats, settings, how it works, about): the same view with a row of links to the others. */
.pagenav { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-4); margin: 0 0 var(--s-3); border-bottom: 1px solid var(--line); }
.pagenav a { display: inline-flex; align-items: center; min-height: var(--tap); border-bottom: 3px solid transparent; }
.pagenav a[aria-current="page"] { font-weight: 650; border-bottom-color: var(--fg); text-decoration: none; }
.pagebody { max-width: 760px; }
.pagebody h3 { margin: var(--s-5) 0 var(--s-2); font-size: var(--fs-lg); }
.pagebody h4 { margin: var(--s-4) 0 var(--s-1); font-size: var(--fs-md); }
.pagebody p, .pagebody li, .pagebody dd { color: var(--fg); }
.pagebody dt { font-weight: 650; margin-top: var(--s-2); } .pagebody dd { margin: 0 0 var(--s-1); }
.pagebody ul { padding-left: var(--s-5); } .pagebody li { margin: var(--s-1) 0; }
.pagebody code { background: var(--surface-2); border-radius: 4px; padding: 0 4px; }

/* Timer, sound button */
.posinfo { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); min-height: 3.25rem; } /* as tall as the 44 px buttons it can hold, so showing or hiding one never moves the board */
.level-card, .srs-card { grid-column: 1 / -1; }
.level-card h4 { margin: var(--s-4) 0 var(--s-1); font-size: var(--fs-md); }
.level-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: var(--s-4); }
.level-card .level-charts h4 { margin: 0 0 var(--s-1); }
.reliability { border: 0; background: none; margin: 0 0 var(--s-3); padding: 0; }
.reliability summary { padding: 0; cursor: pointer; color: var(--accent); min-height: var(--tap); display: flex; align-items: center; }
.reliability p { margin: 0; }
.level-card .level-big, .srs-card .level-big { margin: 0; font-size: 2.4rem; font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1.1; }
.level-card .level-range { margin: 0 0 var(--s-3); color: var(--muted); }
.ch-area { fill: var(--c-real); fill-opacity: .35; stroke: var(--c-real); stroke-width: 2; }
.ch-band { fill: var(--c-real); fill-opacity: .16; }
.ch-mean { stroke: var(--fg); stroke-width: 2; }
.link-btn { border: 0; background: none; }
.link-btn svg { width: 18px; height: 18px; }
.review-chip { align-self: center; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 0 var(--s-3); font-size: var(--fs-sm); font-weight: 600; }
.timer { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
#soundToggle[data-state="on"] .icon-sound-off, #soundToggle[data-state="off"] .icon-sound-on { display: none; }
#gameMain[hidden], footer[hidden], .statsview[hidden] { display: none; }

/* The stats view: a page of its own, KPI tiles and SVG charts. Colours are the arrow colours, so a colour means the same thing everywhere. */
.statsview { max-width: var(--page-max); margin: 0 auto; padding: 0 var(--s-4) var(--s-6); }
.statsview-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); margin: var(--s-3) 0; }
.statsview-head h2 { margin: 0; font-size: var(--fs-xl); }
.statsview-head h2:focus { outline: none; }
.empty { color: var(--muted); padding: var(--s-5) 0; }
.backup { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); margin: 0 0 var(--s-4); }
.backup p { margin: 0; flex-basis: 100%; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s-3); margin: 0 0 var(--s-5); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s-3) var(--s-4); }
.kpi dt { color: var(--muted); font-size: var(--fs-sm); }
.kpi dd { margin: 0; font-size: var(--fs-xl); font-weight: 700; font-variant-numeric: tabular-nums; }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: var(--s-4); }
.chart-card { align-self: start; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s-3) var(--s-4) var(--s-4); }
.chart-card h3 { margin: 0 0 var(--s-1); font-size: var(--fs-lg); }
.chart-card figcaption p, .chart-card > p { margin: 0 0 var(--s-3); color: var(--muted); font-size: var(--fs-sm); }
.chart { display: block; width: 100%; height: auto; }
.ch-grid { stroke: var(--line); stroke-width: 1; }
.ch-tick, .ch-label, .ch-value { fill: var(--muted); font: 12px system-ui, sans-serif; }
.ch-label, .ch-value { fill: var(--fg); font-size: 14px; }
.ch-track { fill: var(--surface-2); }
.ch-bar.c-best, .ch-dot.c-best { fill: var(--c-best); } .ch-bar.c-real, .ch-dot.c-real { fill: var(--c-real); }
.ch-bar.c-maia, .ch-dot.c-maia { fill: var(--c-maia); } .ch-bar.c-you, .ch-dot.c-you { fill: var(--c-you); }
.ch-dot { opacity: .7; }
.ch-line { fill: none; stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.ch-line.c-best { stroke: var(--c-best); } .ch-line.c-real { stroke: var(--c-real); }

/* Move tiers: a coloured disc with a glyph, always next to or carrying the tier's name. */
.tier { display: inline-flex; align-items: center; gap: 6px; vertical-align: middle; }
.tier-icon { width: 20px; height: 20px; flex: none; }
.tier-disc { fill: var(--t); stroke: var(--surface); stroke-width: 1; }
.tier-sym { fill: #fff; font: 800 11px system-ui, sans-serif; }
.tier-glyph path { fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.tier-name { font-weight: 650; }
.tier-brilliant { --t: var(--t-brilliant); } .tier-great { --t: var(--t-great); } .tier-best { --t: var(--t-best); } .tier-excellent { --t: var(--t-excellent); }
.tier-good { --t: var(--t-good); } .tier-inaccuracy { --t: var(--t-inaccuracy); } .tier-mistake { --t: var(--t-mistake); } .tier-blunder { --t: var(--t-blunder); }
.tier-line { margin: 0 0 var(--s-2); }
.tier-card { margin: var(--s-3) 0; }
.tier-bar { display: block; width: 100%; height: 40px; } /* stretched on purpose: rectangles stay sharp, and a phone gets a bar it can read */
.tier-seg, .tier-you { vector-effect: non-scaling-stroke; }
.tier-seg { fill: var(--t); stroke: var(--surface); stroke-width: 1; }
.tier-you { fill: none; stroke: var(--fg); stroke-width: 3; }
.tier-pin { fill: var(--fg); }
.tier-key { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-4); list-style: none; margin: var(--s-2) 0 0; padding: 0; font-size: var(--fs-sm); }
.all-moves { border: 0; background: none; padding: 0; margin: var(--s-3) 0; }
.all-moves summary { cursor: pointer; min-height: var(--tap); display: flex; align-items: center; font-weight: 650; padding: 0; }
.move-list { list-style: none; margin: 0; padding: 0; max-height: 22rem; overflow-y: auto; }
.ml-marks { display: inline-flex; gap: 4px; min-width: 3.4em; justify-content: flex-end; }
.ml-row { display: grid; grid-template-columns: 2.2em auto 4.5em 1fr auto auto; align-items: center; gap: var(--s-2); width: 100%; text-align: left;
  min-height: var(--tap); border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: none; padding: 0 var(--s-1); font-size: var(--fs-sm); }
.ml-row[aria-pressed="true"] { background: var(--surface-2); outline: 2px solid var(--accent); outline-offset: -2px; }
.ml-rank { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.ml-san { font-weight: 650; } .ml-tier { color: var(--muted); } .ml-cost { font-variant-numeric: tabular-nums; text-align: right; }
.mark { display: inline-grid; place-items: center; width: 1.5em; height: 1.5em; border-radius: 50%; color: #111; font-size: .8em; }
.mark-you { background: var(--c-you); } .mark-best { background: var(--c-best); } .mark-real { background: var(--c-real); color: #fff; } .mark-maia { background: var(--c-maia); }
.arrow-preview { --c: var(--fg); }
.ch-bar.t-brilliant { fill: var(--t-brilliant); } .ch-bar.t-great { fill: var(--t-great); } .ch-bar.t-best { fill: var(--t-best); } .ch-bar.t-excellent { fill: var(--t-excellent); }
.ch-bar.t-good { fill: var(--t-good); } .ch-bar.t-inaccuracy { fill: var(--t-inaccuracy); } .ch-bar.t-mistake { fill: var(--t-mistake); } .ch-bar.t-blunder { fill: var(--t-blunder); }

/* "A new version is ready": a fixed bar, so showing it never moves the page */
.update-bar { position: fixed; z-index: 25; left: var(--s-4); right: var(--s-4); bottom: calc(var(--s-4) + env(safe-area-inset-bottom)); display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: var(--s-2) var(--s-3); max-width: 480px; margin: 0 auto; }

/* Keyboard list in the help page */
.keys { width: 100%; border-collapse: collapse; }
.keys th, .keys td { text-align: left; padding: var(--s-1) var(--s-2) var(--s-1) 0; vertical-align: top; font-weight: 400; }
.keys th { white-space: nowrap; }
kbd { border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; background: var(--surface-2); font: inherit; font-size: .85em; }

/* Settings page */
.no-coords .coord { display: none; }
.pagebody .settings { background: none; border: 0; padding: 0; }
.pagebody .settings .field { display: block; margin-top: var(--s-3); }

/* Training session */
.session-btn { width: 100%; margin: 0 0 var(--s-3); }
.challenge-row { display: flex; gap: var(--s-2); margin: 0 0 var(--s-3); }
.challenge-row button { flex: 1; }
.challenge-row[hidden] { display: none; }
.session-moves { list-style: none; margin: 0 0 var(--s-3); padding: 0; }
#reportView h3 { margin: var(--s-4) 0 var(--s-2); }

.progress { margin: 0 0 var(--s-2); font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); padding: 0 var(--s-4) var(--s-2); }
.chips .link { min-height: 32px; }
.review-chip { white-space: nowrap; }

/* Large screens: the board follows the window height (100vh minus what sits above and below it: header, position line, opening
 * line, chips, prompt) and the page container is exactly as wide as board + gap + panel + padding, so the header, the content and
 * the footer line up with no empty bands. The panel keeps a readable width. */
@media (min-width: 1500px) {
  :root {
    --board-max: 960px; --panel-max: 720px;
    --board-size: clamp(420px, calc(100vh - 262px), var(--board-max));
    --page-max: calc(var(--board-size) + 24px + var(--panel-max) + 32px); /* 24 = the column gap, 32 = the side padding */
  }
  #gameMain { grid-template-columns: var(--board-size) minmax(300px, var(--panel-max)); }
}
@media (min-width: 2000px) { :root { --board-max: 1260px; --panel-max: 800px; } }

/* The opening line and the chips fill in when the first position arrives. On the stacked layout (phone and tablet) their rows are kept,
 * and the position line is two lines tall on a phone, so the board does not jump down by about 100 px at that moment: the layout shift
 * Lighthouse measured on the real build. Not on the two-column desktop layout, where the board is sized to the window height and every
 * row above it takes board size. */
@media (max-width: 899px) {
  .openingline { min-height: 21px; } .chips { min-height: 31px; }
  html:not(.focus-mode) .stage .openingline[hidden], html:not(.focus-mode) .stage .chips[hidden] { display: block !important; visibility: hidden; }
}
@media (max-width: 480px) { .posinfo { min-height: 5rem; } }
