/* Hindsight: warm monochrome, editorial type, hairline structure. Color is reserved for move quality. */
:root {
  --bg: #191918;
  --surface: #1f1f1e;
  --surface-2: #262625;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #e6e5e2;
  --strong: #f5f4f1;
  --muted: #9b9a96;
  --primary: #edece8;
  --primary-hover: #d9d8d3;
  --on-primary: #111111;
  --chart-fill: #2b2b29;
  --light-sq: #e8e4dc;
  --dark-sq: #a39a8d;
  --last-move: #e7d48a;
  --c-brilliant: #7fb6db;
  --c-great: #78bdb5;
  --c-best: #8dbf8a;
  --c-excellent: #a3c29e;
  --c-good: #9b9a96;
  --c-book: #c2a27e;
  --c-inaccuracy: #d9b65e;
  --c-mistake: #db9361;
  --c-miss: #d88aa6;
  --c-blunder: #e0827d;
  --c-forced: #9b9a96;
  --serif: 'Instrument Serif', 'Newsreader', Georgia, serif;
  --sans: 'Geist', 'Helvetica Neue', system-ui, sans-serif;
  --mono: 'Geist Mono', 'SF Mono', ui-monospace, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --board: clamp(300px, calc(100dvh - 424px), 640px);
  color-scheme: dark;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

:root[data-theme="light"] {
  --bg: #f7f6f3;
  --surface: #ffffff;
  --surface-2: #f1f0ec;
  --border: #eaeaea;
  --border-strong: #d9d8d4;
  --text: #2f3437;
  --strong: #111111;
  --muted: #787774;
  --primary: #111111;
  --primary-hover: #333333;
  --on-primary: #ffffff;
  --chart-fill: #ebe9e4;
  --c-brilliant: #1f6c9f;
  --c-great: #2b6f6a;
  --c-best: #346538;
  --c-excellent: #4d7350;
  --c-good: #787774;
  --c-book: #7a5c3a;
  --c-inaccuracy: #956400;
  --c-mistake: #a0521c;
  --c-miss: #9a2f5a;
  --c-blunder: #9f2f2d;
  --c-forced: #787774;
  color-scheme: light;
  scrollbar-color: #d9d8d4 transparent;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 var(--sans);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

a { color: inherit; text-underline-offset: 3px; text-decoration-color: var(--border-strong); }
a:hover { text-decoration-color: currentColor; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }

.skip-link { position: absolute; left: -9999px; top: 8px; z-index: 50; background: var(--primary); color: var(--on-primary); padding: 8px 12px; border-radius: 6px; }
.skip-link:focus { left: 8px; }

/* --- Controls --------------------------------------------------------------- */

button, input, select, textarea { font: inherit; color: inherit; }
button {
  cursor: pointer;
  border: 1px solid var(--border-strong);
  background: transparent;
  border-radius: 6px;
  padding: 8px 14px;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease), color 0.2s var(--ease), transform 0.15s var(--ease);
}
button:hover { background: var(--surface-2); }
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.35; cursor: default; transform: none; }
button.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); font-weight: 500; }
button.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
button.secondary { background: var(--surface); }
button.wide { display: block; margin: 24px auto; }
.text-btn { border: 0; padding: 6px 8px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.text-btn:hover { background: transparent; color: var(--strong); }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; color: var(--muted); }
.icon-btn:hover { color: var(--strong); background: var(--surface-2); }
.icon-btn span, .text-btn span[data-icon] { display: inline-grid; place-items: center; }

input, textarea, select {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 8px 12px;
  transition: border-color 0.2s var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--strong); }
:focus-visible { outline: 2px solid var(--strong); outline-offset: 2px; }

/* --- Top bar ------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 32px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; font: 400 26px/1 var(--serif); letter-spacing: -0.02em; color: var(--strong); text-decoration: none; }
.logo-mark { width: 28px; height: 28px; flex: none; }
.logo-tile { fill: var(--strong); }
.logo-letter { fill: var(--bg); }
.logo-dot { fill: #e0827d; }
.nav { display: flex; gap: 22px; margin-left: 24px; margin-right: auto; }
.nav a { text-decoration: none; color: var(--muted); font-size: 14px; padding: 6px 0; border-bottom: 1px solid transparent; transition: color 0.2s var(--ease); }
.nav a:hover { color: var(--strong); }
.nav a.active { color: var(--strong); border-bottom-color: var(--strong); }
.search { display: flex; gap: 0; border: 1px solid var(--border-strong); border-radius: 6px; overflow: hidden; background: var(--surface); }
.search select { border: 0; border-right: 1px solid var(--border); border-radius: 0; padding: 6px 8px; font-size: 13px; color: var(--muted); background: transparent; }
.search input { width: 200px; border: 0; border-radius: 0; padding: 7px 10px; font-size: 14px; background: transparent; }
.search button { border-radius: 0; padding: 6px 14px; font-size: 14px; }
.top-tools { display: flex; align-items: center; gap: 0; }
.menu-btn { display: none; }
body[data-view="home"] .search { visibility: hidden; }

main { flex: 1; width: 100%; max-width: 1360px; margin: 0 auto; padding: 20px 32px 32px; }

/* --- Home ----------------------------------------------------------------- */

.hero { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); gap: 56px; align-items: center; padding: 64px 0 72px; }
.eyebrow { font: 500 12px var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0 0 20px; }
.hero h1 { font: 400 clamp(44px, 6vw, 80px)/1.02 var(--serif); letter-spacing: -0.03em; margin: 0 0 24px; color: var(--strong); max-width: 14ch; }
.hero h1 em { color: var(--muted); }
.lede { font-size: 18px; max-width: 58ch; margin: 0 0 32px; color: var(--text); }
.hero-search { max-width: 540px; }
.source-switch { display: flex; gap: 4px; margin-bottom: 10px; }
.source-switch label { cursor: pointer; }
.source-switch input { position: absolute; opacity: 0; pointer-events: none; }
.source-switch span { display: inline-block; font-size: 13px; padding: 4px 10px; border-radius: 4px; color: var(--muted); border: 1px solid transparent; transition: all 0.2s var(--ease); }
.source-switch input:checked + span { color: var(--strong); border-color: var(--border-strong); background: var(--surface); }
.source-switch input:focus-visible + span { outline: 2px solid var(--strong); outline-offset: 2px; }
.hero-search-row { display: flex; gap: 10px; }
.hero-search-row input { flex: 1; min-width: 0; padding: 12px 16px; font-size: 16px; }
.hero-search-row button { padding: 12px 20px; font-size: 15px; white-space: nowrap; }
.fine { font-size: 13px; color: var(--muted); margin: 14px 0 0; max-width: 54ch; }
.engine-choice { display: flex; flex-direction: column; gap: 10px; }
.choice { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--muted); cursor: pointer; }
.choice input { margin-top: 3px; accent-color: var(--strong); }
.choice b { display: block; color: var(--strong); font-weight: 500; font-size: 14px; margin-bottom: 1px; }
.fine a { color: var(--text); }

/* Hero composition: a real board, a move card overlapping it, and the game's evaluation line. */
.hero-art { position: relative; padding: 0 0 40px 0; }
.art-board { --board: min(420px, 100%); width: var(--board); aspect-ratio: 1; height: auto; }
.art-board.board { width: var(--board); height: auto; }
.art-board.small { --board: min(320px, 100%); }
.hero-art .art-board { margin-left: auto; }
.art-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; font-size: 14px; }
.art-card .ex-sub { font-size: 13.5px; }
.art-card-float { position: absolute; left: 0; bottom: 70px; width: min(330px, 80%); box-shadow: 0 12px 32px rgba(17, 17, 17, 0.12); }
.art-actions { display: flex; gap: 6px; margin-top: 12px; }
.art-btn { font-size: 12.5px; padding: 4px 11px; border: 1px solid var(--border-strong); border-radius: 6px; color: var(--text); }
.art-btn.dark { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.art-spark { display: block; width: min(420px, 100%); height: 46px; margin: 14px 0 0 auto; }

.sources-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 28px; padding: 22px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); font: 400 22px var(--serif); color: var(--text); }
.strip-label { font: 500 11px var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }

.showcase { padding: 40px 0 24px; }
.feature-row { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: 64px; align-items: center; padding: 64px 0; border-bottom: 1px solid var(--border); }
.feature-row.flip .feature-text { order: 2; }
.feature-text h2 { font: 400 clamp(32px, 4vw, 46px)/1.08 var(--serif); letter-spacing: -0.02em; margin: 0 0 16px; color: var(--strong); }
.feature-text > p { color: var(--text); max-width: 52ch; margin: 0 0 18px; }
.ticks { list-style: none; padding: 0; margin: 0; }
.ticks li { padding: 8px 0 8px 22px; border-top: 1px solid var(--border); position: relative; font-size: 14px; color: var(--muted); }
.ticks li::before { content: ""; position: absolute; left: 2px; top: 16px; width: 8px; height: 1px; background: var(--strong); }
.art-panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 24px; }
.art-summary { font: italic 400 22px/1.35 var(--serif); color: var(--strong); margin: 0 0 18px; }
.art-summary b { font-style: normal; font-weight: 400; }
.art-moves { margin-bottom: 14px; }
.art-moves .mv { cursor: default; }
.art-note { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; padding: 12px; background: var(--surface-2); border-radius: 6px; }
.art-note b { font: 500 13px var(--mono); margin-right: 6px; }
.art-retry { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr); gap: 20px; align-items: center; }
.art-retry .art-board { --board: min(300px, 100%); }
.art-timeline { display: block; width: 100%; height: 150px; }
.art-caption { font-size: 12px; color: var(--muted); margin: 12px 0 0; }
.art-engine-head { display: flex; justify-content: space-between; font: 12px var(--mono); color: var(--muted); padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.art-line { display: flex; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--border); font: 13px var(--mono); }
.art-line b { font-weight: 500; color: var(--strong); min-width: 46px; }
.art-line span { color: var(--text); }

.private { padding: 96px 0 72px; }
.private h2, .faq h2, .cta h2 { font: 400 clamp(32px, 4vw, 46px)/1.1 var(--serif); letter-spacing: -0.02em; margin: 0 0 28px; color: var(--strong); }
.private-grid { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 0; border-top: 1px solid var(--border); }
.private-grid > div { padding: 24px 28px 8px 0; }
.private-grid > div + div { padding-left: 28px; border-left: 1px solid var(--border); }
.private h3 { font-size: 16px; font-weight: 600; margin: 0 0 6px; color: var(--strong); }
.private p { margin: 0; color: var(--muted); font-size: 14px; }

.faq { display: grid; grid-template-columns: minmax(180px, 0.6fr) 2fr; gap: 48px; padding: 72px 0; border-top: 1px solid var(--border); }
.faq dl { margin: 0; }
.faq dl > div { display: grid; grid-template-columns: 1fr 1.4fr; gap: 24px; padding: 18px 0; border-bottom: 1px solid var(--border); }
.faq dl > div:first-child { padding-top: 6px; }
.faq dt { font-weight: 600; color: var(--strong); }
.faq dd { margin: 0; color: var(--muted); font-size: 14px; }

.cta { padding: 80px 0 96px; border-top: 1px solid var(--border); display: flex; align-items: baseline; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.cta h2 { margin: 0; }
.cta-btn { background: var(--primary); color: var(--on-primary); text-decoration: none; padding: 12px 22px; border-radius: 6px; font-weight: 500; transition: background 0.2s var(--ease); }
.cta-btn:hover { background: var(--primary-hover); }

/* --- Pages: features, changelog, analysis ----------------------------------- */
.page-head { padding: 32px 0 28px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.page-head h2 { font: 400 clamp(36px, 5vw, 56px)/1.05 var(--serif); letter-spacing: -0.025em; margin: 0; color: var(--strong); }
.page-head .lede { margin: 16px 0 0; color: var(--muted); }
.page-head .lede a { color: var(--text); }
.tag { display: inline-block; font: 500 10px var(--mono); text-transform: uppercase; letter-spacing: 0.08em; padding: 2px 6px; border-radius: 3px; background: color-mix(in srgb, var(--c-best) 14%, transparent); color: var(--c-best); vertical-align: 2px; }
.feature-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 56px; }
.feature-groups section { padding: 28px 0; border-bottom: 1px solid var(--border); }
.feature-groups h3 { font: 400 26px var(--serif); margin: 0 0 12px; color: var(--strong); }
.feature-groups ul { list-style: none; margin: 0; padding: 0; }
.feature-groups li { padding: 12px 0; border-top: 1px solid var(--border); }
.feature-groups li b { font-weight: 600; color: var(--strong); }
.feature-groups li > span:last-child { display: block; color: var(--muted); font-size: 14px; margin-top: 2px; }
.changelog { max-width: 880px; }
.release { display: grid; grid-template-columns: 180px 1fr; gap: 32px; padding: 32px 0; border-bottom: 1px solid var(--border); }
.release-meta { display: flex; flex-direction: column; gap: 4px; }
.release-version { font: 400 34px/1 var(--serif); color: var(--strong); }
.release-meta time { font: 12px var(--mono); color: var(--muted); }
.release h3 { font-size: 18px; font-weight: 600; margin: 0 0 10px; color: var(--strong); }
.release ul { margin: 0; padding: 0; list-style: none; }
.release li { padding: 7px 0 7px 20px; position: relative; color: var(--text); font-size: 14.5px; }
.release li::before { content: ""; position: absolute; left: 2px; top: 17px; width: 8px; height: 1px; background: var(--muted); }

#analysis .stage { margin-top: 20px; }
#analysis .page-head { padding-top: 12px; }
.ab-controls { display: flex; align-items: center; gap: 2px; padding-left: 16px; }
.ab-turn { margin-left: auto; font: 13px var(--mono); color: var(--muted); }
.ab-side { gap: 18px; contain: none; }
.ab-block { border-top: 1px solid var(--border); padding-top: 12px; }
.ab-block:first-child { border-top: 0; padding-top: 0; }
.ab-label { display: block; font: 500 11px var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 8px; }
.ab-label-row { display: flex; justify-content: space-between; align-items: baseline; }
.ab-block textarea { width: 100%; font: 12.5px var(--mono); resize: vertical; }
.ab-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.ab-row button { padding: 6px 12px; font-size: 13px; }
.ab-copy { display: flex; }
.ab-moves { display: flex; flex-wrap: wrap; gap: 2px; max-height: 180px; overflow-y: auto; padding: 4px 0; }
.ab-mv { border: 0; padding: 3px 6px; border-radius: 4px; font: 13px var(--mono); color: var(--text); }
.ab-mv:active { transform: none; }
.ab-mv.current { background: var(--surface-2); color: var(--strong); font-weight: 500; }
.ab-fen { width: 100%; margin-top: 8px; font: 11.5px var(--mono); color: var(--muted); }
.tb { margin-top: 12px; padding: 12px; background: var(--surface-2); border-radius: 6px; font-size: 13.5px; }
.tb-head b { font-weight: 600; color: var(--strong); margin-right: 6px; }
.tb-moves { list-style: none; margin: 8px 0 0; padding: 0; }
.tb-moves li { display: flex; gap: 12px; padding: 3px 0; color: var(--muted); }
.tb-moves .san { font: 500 13px var(--mono); color: var(--strong); min-width: 56px; }

.shortcuts { border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); color: var(--text); padding: 20px 24px 12px; width: min(440px, calc(100vw - 32px)); }
.shortcuts::backdrop { background: rgba(17, 17, 17, 0.35); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.dialog-head h2 { font: 400 26px var(--serif); margin: 0; color: var(--strong); }
.shortcuts dl { margin: 0; }
.shortcuts dl > div { display: grid; grid-template-columns: 140px 1fr; gap: 12px; padding: 9px 0; border-top: 1px solid var(--border); font-size: 14px; }
.shortcuts dd { margin: 0; color: var(--muted); }
kbd { font: 12px var(--mono); border: 1px solid var(--border-strong); border-radius: 4px; padding: 1px 6px; background: var(--surface-2); color: var(--strong); }

.skeleton-row { display: grid; grid-template-columns: 64px 1fr; gap: 20px; padding: 22px 8px; border-bottom: 1px solid var(--border); }
.skeleton-row span { height: 12px; border-radius: 3px; background: var(--surface-2); }
.skeleton-row span:last-child { width: 46%; }
@media (prefers-reduced-motion: no-preference) {
  .skeleton-row span { animation: pulse 1.4s ease-in-out infinite; }
  @keyframes pulse { 50% { opacity: 0.45; } }
}

.pgn-box { max-width: 640px; display: flex; flex-direction: column; gap: 10px; margin: 8px 0 40px; }
.pgn-box textarea { font: 13px var(--mono); resize: vertical; }
.pgn-box button { align-self: flex-start; }

.unused-how { display: grid; grid-template-columns: minmax(200px, 1fr) 2fr; gap: 48px; padding: 72px 0 96px; border-top: 1px solid var(--border); }
.how h2 { font: 400 34px/1.1 var(--serif); letter-spacing: -0.02em; margin: 0; color: var(--strong); }
.how-list { list-style: none; margin: 0; padding: 0; }
.how-list li { display: grid; grid-template-columns: 56px 1fr; padding: 22px 0; border-bottom: 1px solid var(--border); }
.how-list li:first-child { padding-top: 4px; }
.how-num { font: 12px var(--mono); color: var(--muted); padding-top: 4px; }
.how h3 { font-size: 17px; font-weight: 600; margin: 0 0 4px; color: var(--strong); letter-spacing: -0.01em; }
.how p { margin: 0; color: var(--muted); max-width: 56ch; }

@media (prefers-reduced-motion: no-preference) {
  .reveal { opacity: 0; transform: translateY(12px); transition: opacity 0.6s var(--ease), transform 0.6s var(--ease); }
  .reveal.in { opacity: 1; transform: none; }
}

/* --- Game list ------------------------------------------------------------ */

.games-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 24px 0 16px; border-bottom: 1px solid var(--border); }
.games-head h2 { margin: 0; font: 400 40px/1.1 var(--serif); letter-spacing: -0.02em; color: var(--strong); }
.game-list { list-style: none; padding: 0; margin: 0; }
.game-card {
  width: 100%;
  display: grid;
  grid-template-columns: 64px 1fr auto auto;
  align-items: center;
  gap: 20px;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 16px 8px;
}
.game-card:hover { background: var(--surface); }
.game-card:active { transform: none; }
.game-card:hover .review-cta { color: var(--strong); }
.result { display: none; }
.result-label { font: 500 11px var(--mono); text-transform: uppercase; letter-spacing: 0.08em; padding: 3px 0; }
.result-label.win { color: var(--c-best); }
.result-label.loss { color: var(--c-blunder); }
.result-label.draw { color: var(--muted); }
.game-main { display: flex; flex-direction: column; min-width: 0; }
.game-players { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; color: var(--strong); }
.game-players .muted { font: 13px var(--mono); }
.game-meta { color: var(--muted); font-size: 13px; }
.game-meta::first-letter { text-transform: uppercase; }
.vs { color: var(--muted); margin: 0 8px; font-weight: 400; }
.spark { width: 120px; height: 28px; }
.spark path { fill: none; stroke: var(--text); stroke-width: 1.2; }
.spark line { stroke: var(--border-strong); stroke-dasharray: 2 3; }
.review-cta { color: var(--muted); font-size: 14px; white-space: nowrap; }
.status { text-align: center; margin-top: 24px; }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 7px; border: 1px solid var(--border-strong); vertical-align: 0; }
.dot.white { background: #f4f2ed; }
.dot.black { background: #1a1a19; }

/* --- Review: header ------------------------------------------------------------ */

.report {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 24px;
  padding: 0 0 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.pcard { min-width: 0; }
.pcard.right { text-align: right; }
.pname-big { font: 400 30px/1.1 var(--serif); letter-spacing: -0.02em; color: var(--strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prating { font: 13px var(--mono); color: var(--muted); margin-left: 8px; letter-spacing: 0; }
.acc-line { display: flex; align-items: baseline; gap: 10px; margin-top: 6px; }
.pcard.right .acc-line { justify-content: flex-end; }
.acc-num { font: 500 26px/1 var(--sans); letter-spacing: -0.02em; color: var(--strong); }
.acc-cap { font-size: 13px; color: var(--muted); }
.form-up { color: var(--c-best); }
.form-even { color: var(--muted); }
.form-down { color: var(--c-mistake); }
.phases { margin-top: 6px; font: 12px var(--mono); color: var(--muted); }
.phases b { font-weight: 500; color: var(--text); }
.meta { text-align: center; padding-bottom: 2px; }
.meta-result { font: 400 40px/1 var(--serif); color: var(--strong); letter-spacing: 0.02em; }
.meta-sub { font-size: 12px; color: var(--muted); max-width: 320px; margin-top: 6px; }

/* --- Review: stage ---------------------------------------------------------- */

.stage { display: grid; grid-template-columns: auto minmax(320px, 440px); gap: 32px; justify-content: center; }
.stage > * { min-width: 0; }
.board-col { display: flex; flex-direction: column; gap: 8px; }
.board-row { display: flex; gap: 10px; }

.player { display: flex; align-items: center; gap: 6px; min-height: 30px; padding-left: 16px; font-size: 14px; }
.pname { font-weight: 500; color: var(--strong); }
.player .muted { font: 12px var(--mono); }
.captures { display: flex; align-items: center; margin-left: 8px; min-width: 0; overflow: hidden; }
.captures img { width: 17px; height: 17px; margin-right: -6px; opacity: 0.85; }
:root:not([data-theme="light"]) .captures img { filter: drop-shadow(0 0 0.6px rgba(255, 255, 255, 0.7)); }
.captures .adv { margin-left: 10px; font: 12px var(--mono); color: var(--muted); }
.clock { margin-left: auto; font: 500 15px var(--mono); border: 1px solid var(--border-strong); color: var(--muted); border-radius: 6px; padding: 2px 12px; min-width: 84px; text-align: right; transition: background 0.2s var(--ease), color 0.2s var(--ease); }
.clock.active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }

.board {
  position: relative;
  width: var(--board);
  height: var(--board);
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border-radius: 4px;
  overflow: hidden;
  user-select: none;
}
.sq { position: relative; }
.sq.light { background: var(--light-sq); }
.sq.dark { background: var(--dark-sq); }
.sq.hl::before { content: ""; position: absolute; inset: 0; background: var(--tint, var(--last-move)); opacity: 0.38; }
.sq.sel::before { content: ""; position: absolute; inset: 0; background: var(--last-move); opacity: 0.6; }
.sq.check::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle, rgba(159, 47, 45, 0.75) 0%, rgba(159, 47, 45, 0.3) 45%, transparent 72%); }
.board.interactive .sq { cursor: pointer; }
.piece { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; }
.coord { position: absolute; font: 500 calc(var(--board) / 52) var(--mono); z-index: 1; pointer-events: none; opacity: 0.85; }
.coord.rank { top: 3%; left: 4%; }
.coord.file { bottom: 2%; right: 5%; }
.sq.light .coord { color: var(--dark-sq); }
.sq.dark .coord { color: var(--light-sq); }
.badge { position: absolute; top: -2%; right: -2%; z-index: 3; font-size: calc(var(--board) / 36); }
.badge .cls-icon { background: #fbfaf7; color: var(--c); box-shadow: 0 1px 3px rgba(17, 17, 17, 0.18); }
/* Badges sit on the board's light squares, so they always use the light-theme marks. */
.badge { --c-brilliant: #1f6c9f; --c-great: #2b6f6a; --c-best: #346538; --c-excellent: #4d7350; --c-good: #787774; --c-book: #7a5c3a; --c-inaccuracy: #956400; --c-mistake: #a0521c; --c-miss: #9a2f5a; --c-blunder: #9f2f2d; --c-forced: #787774; }
.arrows { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; }
.hint, .hint-capture { position: absolute; z-index: 2; pointer-events: none; }
.hint { inset: 39%; border-radius: 50%; background: rgba(17, 17, 17, 0.2); }
.hint-capture { inset: 6%; border-radius: 50%; border: 4px solid rgba(17, 17, 17, 0.2); }
.drag-ghost { position: fixed; z-index: 100; pointer-events: none; filter: drop-shadow(0 6px 10px rgba(17, 17, 17, 0.25)); }
.promo { position: absolute; inset: 0; z-index: 10; display: grid; place-items: center; background: rgba(17, 17, 17, 0.4); }
.promo-box { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px; }
.promo-piece { width: calc(var(--board) / 8); height: calc(var(--board) / 8); padding: 4px; border: 0; }
.promo-piece img { width: 100%; height: 100%; }

.gauge { position: relative; width: 6px; flex: none; background: #2f3033; border-radius: 3px; overflow: hidden; }
.evalbar-fill { position: absolute; left: 0; right: 0; bottom: 0; height: 50%; background: #f4f2ed; transition: height 0.4s var(--ease); }
:root[data-theme="light"] .gauge { box-shadow: 0 0 0 1px var(--border-strong); }
.gauge.flipped .evalbar-fill { bottom: auto; top: 0; }
.evalbar-label { display: none; }

/* --- Review: side panel ------------------------------------------------------- */

.side { display: flex; flex-direction: column; gap: 14px; contain: size; min-height: 100%; }
.side-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex: none; border-bottom: 1px solid var(--border); }
@media (max-width: 640px) {
  .side-head { flex-wrap: wrap; row-gap: 0; }
  .head-btns { gap: 0; margin-left: auto; }
  .head-btns .icon-btn { width: 28px; }
  .head-btns .text-btn { padding-left: 4px; padding-right: 4px; }
}
.head-btns { display: flex; gap: 2px; }
.menu-wrap { position: relative; display: inline-flex; }
.pop-menu { position: absolute; top: calc(100% + 6px); right: 0; z-index: 30; min-width: 250px; padding: 6px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22); display: flex; flex-direction: column; }
.pop-menu[hidden] { display: none; }
.pop-menu button { border: 0; background: none; text-align: left; padding: 8px 10px; border-radius: 5px; font-size: 13px; color: var(--text); }
.pop-menu button:hover, .pop-menu button:focus-visible { background: var(--surface-2); color: var(--strong); }
.tabs { display: flex; gap: 20px; }
.tabs button { border: 0; border-radius: 0; background: transparent; padding: 8px 0 10px; margin-bottom: -1px; border-bottom: 1px solid transparent; color: var(--muted); font-size: 14px; font-weight: 500; }
.tabs button:hover { color: var(--strong); }
.tabs button:active { transform: none; }
.tabs button[aria-selected="true"] { color: var(--strong); border-bottom-color: var(--strong); }

.progress { position: relative; flex: none; padding-top: 6px; }
.progress-fill { position: absolute; top: 0; left: 0; height: 2px; background: var(--strong); transition: width 0.3s var(--ease); }
.progress::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: var(--border); }
.progress-label { font: 12px var(--mono); color: var(--muted); }

.pane { flex: 1; min-height: 0; overflow-y: auto; }
.depth { flex: none; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.depth select { padding: 3px 8px; font-size: 12px; }

/* Current move */
.explain { flex: none; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 16px 18px; max-height: 52%; overflow-y: auto; }
.ex-head { display: flex; align-items: center; gap: 10px; color: var(--strong); }
.ex-head b { font: 500 15px var(--mono); }
.ex-eval { margin-left: auto; font: 500 12px var(--mono); color: var(--muted); white-space: nowrap; }
.ex-sub { margin-top: 8px; font-size: 14px; color: var(--text); }
.ex-line { margin-top: 8px; color: var(--muted); font: 12.5px/1.6 var(--mono); }
.var-line { color: var(--text); }
.ex-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; align-items: center; }
.ex-actions button { padding: 5px 12px; font-size: 13px; }
.ex-actions button[data-act="retry"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.key-nav { display: flex; gap: 0; margin-left: auto; }
.key-nav button { border: 0; color: var(--muted); padding: 5px 6px; }
.key-nav button:hover { color: var(--strong); background: transparent; }
.live-lines { display: flex; flex-direction: column; margin-top: 10px; border-top: 1px solid var(--border); }
.live-line { display: flex; align-items: center; gap: 12px; text-align: left; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; padding: 7px 2px; font: 12.5px var(--mono); }
.live-line:active { transform: none; }
.live-line span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.live-line .ex-eval { min-width: 48px; margin: 0; color: var(--strong); }
.live-depth { font: 11px var(--mono); color: var(--muted); margin-top: 6px; text-align: right; }

/* Story */
.story-summary { font: italic 400 21px/1.35 var(--serif); color: var(--strong); padding: 2px 0 16px; letter-spacing: -0.005em; }
.story-summary b { font-weight: 400; font-style: normal; }
.story-label { font: 500 11px var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.moment { display: grid; grid-template-columns: 96px 1fr; column-gap: 12px; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; padding: 12px 4px; }
.moment:active { transform: none; }
.moment:hover { background: var(--surface); }
.moment.current { background: var(--surface-2); }
.moment-head { display: contents; }
.moment-head > span:nth-child(2) { font: 500 13px var(--mono); color: var(--strong); grid-column: 1; grid-row: 1; white-space: nowrap; }
.moment-head .cls-icon { grid-column: 1; grid-row: 2; justify-self: start; margin-top: 4px; }
.moment-head .who { grid-column: 2; grid-row: 1; font-size: 12px; color: var(--muted); }
.moment-note { grid-column: 2; grid-row: 2; font-size: 13.5px; color: var(--text); margin-top: 2px; }
.drill-cta { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0 16px; margin-bottom: 4px; border-bottom: 1px solid var(--border); font-size: 14px; color: var(--text); }
.drill-cta .small-btn { margin-top: 0; flex: none; }
.drill-count { margin-left: auto; font: 12px var(--mono); color: var(--muted); }
.breakdown { margin-top: 18px; }
.breakdown summary { cursor: pointer; font: 500 11px var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); list-style: none; }
.breakdown summary::before { content: "+ "; }
.breakdown[open] summary::before { content: "– "; }
.breakdown table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 13px; }
.breakdown td { padding: 5px 4px; border-bottom: 1px solid var(--border); }
.breakdown td.n { width: 40px; text-align: center; font: 13px var(--mono); color: var(--strong); }
.breakdown td.lbl { text-align: left; color: var(--text) !important; }
.breakdown td.lbl .cls-icon { margin-right: 10px; }

/* Move list */
.moves { padding: 0; }
.mrow { display: grid; grid-template-columns: 40px 1fr 1fr; align-items: center; border-bottom: 1px solid var(--border); }
.num { color: var(--muted); text-align: right; padding-right: 10px; font: 12px var(--mono); }
.mv { display: flex; align-items: center; gap: 6px; border: 0; border-radius: 4px; padding: 5px 8px; margin: 2px; text-align: left; font: 14px var(--mono); color: var(--text); }
.mv:active { transform: none; }
.mv:hover { background: var(--surface); }
.mv.current { background: var(--surface-2); color: var(--strong); font-weight: 500; }
.mv .cls-icon { background: none; padding: 0; min-width: 0; font-size: 12px; }

/* Move-quality marks: quiet tinted squares carrying the annotation symbol. */
.cls-icon {
  display: inline-grid;
  place-items: center;
  flex: none;
  min-width: 1.9em;
  height: 1.6em;
  padding: 0 0.35em;
  border-radius: 4px;
  background: color-mix(in srgb, var(--c) 14%, transparent);
  color: var(--c);
  font: 600 11px/1 var(--mono);
  letter-spacing: -0.03em;
}
.cls-icon.placeholder { background: transparent; }

/* --- Timeline ----------------------------------------------------------------- */

.timeline { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 16px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.tl-nav, .tl-side { display: flex; gap: 2px; align-items: center; }
.tl-counter { font: 13px var(--mono); color: var(--muted); min-width: 140px; text-align: right; margin-right: 8px; white-space: nowrap; }
.tl-counter b { color: var(--strong); font-weight: 500; }
.tl-track { position: relative; min-width: 0; }
.graph { cursor: pointer; line-height: 0; touch-action: none; user-select: none; }
.g-bg { fill: transparent; }
.g-area { fill: var(--chart-fill); }
.g-line { fill: none; stroke: var(--strong); stroke-width: 1.25; stroke-linejoin: round; }
.g-mid { stroke: var(--border-strong); stroke-width: 1; stroke-dasharray: 2 4; }
.g-cur { stroke: var(--strong); stroke-width: 1; }
.g-knob { fill: var(--strong); stroke: var(--bg); stroke-width: 2; }
.g-time-w, .g-time-b { fill: var(--border-strong); }
.g-time-b { opacity: 0.7; }
.graph-tip { position: absolute; bottom: calc(100% + 8px); width: 168px; display: flex; align-items: center; gap: 8px; justify-content: center; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 6px; padding: 5px 8px; font: 12px var(--mono); pointer-events: none; z-index: 5; }
.graph-tip .cls-icon { font-size: 10px; }

.notice { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; max-width: min(520px, calc(100vw - 32px)); background: var(--surface); color: var(--strong); border: 1px solid var(--border-strong); border-radius: 8px; padding: 12px 16px; font-size: 14px; box-shadow: 0 8px 24px rgba(17, 17, 17, 0.08); }

.footer { padding: 28px 32px 32px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); }
.footer-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.small-brand { font-size: 22px; }
.small-brand .logo-mark { width: 22px; height: 22px; }
.footer-nav { display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: 13px; }
.footer-nav a { text-decoration: none; color: var(--muted); }
.footer-nav a:hover { color: var(--strong); }
.footer p { margin: 0 0 4px; max-width: 120ch; }

/* --- Narrow screens ------------------------------------------------------- */

@media (max-width: 1100px) {
  .nav { gap: 16px; margin-left: 12px; }
  .search input { width: 150px; }
}
@media (max-width: 960px) {
  :root { --board: calc(100vw - 32px - 16px); }
  main { padding: 16px 16px 24px; }
  .topbar { padding: 12px 16px; gap: 10px; }
  .brand { margin-right: auto; }
  .menu-btn { display: inline-flex; }
  .nav { display: none; order: 4; flex-basis: 100%; flex-direction: column; gap: 0; margin: 0; }
  body.menu-open .nav { display: flex; }
  .nav a { padding: 12px 0; border-bottom: 1px solid var(--border); }
  .nav a.active { border-bottom-color: var(--border); color: var(--strong); font-weight: 500; }
  .search { order: 3; flex-basis: 100%; }
  .search input { flex: 1; min-width: 0; width: auto; }
  body[data-view="home"] .search { display: none; }
  .hero { grid-template-columns: 1fr; gap: 40px; padding: 32px 0 48px; }
  .lede { font-size: 16px; }
  .hero-search-row { flex-direction: column; }
  .art-card-float { position: relative; left: auto; bottom: auto; width: 100%; margin-top: -28px; }
  .hero-art .art-board { margin: 0 auto; }
  .art-spark { margin: 14px auto 0; }
  .sources-strip { font-size: 18px; gap: 6px 18px; }
  .feature-row { grid-template-columns: 1fr; gap: 28px; padding: 48px 0; }
  .feature-row.flip .feature-text { order: 0; }
  .art-retry { grid-template-columns: 1fr; }
  .private-grid { grid-template-columns: 1fr; }
  .private-grid > div + div { padding-left: 0; border-left: 0; border-top: 1px solid var(--border); }
  .faq { grid-template-columns: 1fr; gap: 16px; }
  .faq dl > div { grid-template-columns: 1fr; gap: 4px; }
  .feature-groups { grid-template-columns: 1fr; }
  .release { grid-template-columns: 1fr; gap: 8px; }
  #analysis .stage { display: grid; grid-template-columns: minmax(0, 1fr); }
  .game-card { grid-template-columns: 52px 1fr auto; gap: 12px; }
  .spark { display: none; }
  #review { display: flex; flex-direction: column; }
  .stage { display: contents; }
  .report { order: 0; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
  .meta { grid-column: 1 / -1; order: -1; }
  .pname-big { font-size: 22px; }
  .acc-num { font-size: 22px; }
  .acc-line { flex-wrap: wrap; gap: 2px 8px; }
  .board-col { order: 1; }
  .timeline { order: 2; grid-template-columns: minmax(0, 1fr) auto; }
  .tl-track { grid-column: 1 / -1; order: -1; }
  .tl-counter { min-width: 0; }
  .side { order: 3; contain: none; min-height: 0; margin-top: 18px; }
  .pane { overflow: visible; }
  .explain { max-height: none; }
}
@media (max-width: 960px) and (min-width: 620px) {
  :root { --board: min(calc(100vw - 64px), 580px); }
  .board-col { align-items: center; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
  html { scroll-behavior: auto; }
}

/* Each board is its own stacking layer, so cards can overlap it cleanly. */
.board { isolation: isolate; }
.art-card-float { z-index: 2; }
#analysis .side { contain: none; min-height: 0; }

/* --- Board frame: rounded outer corners only; squares stay square. --- */
.board { border-radius: 12px; box-shadow: 0 0 0 1px rgba(17, 17, 17, 0.08), 0 1px 2px rgba(17, 17, 17, 0.06); }
:root:not([data-theme="light"]) .board { box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06); }
.art-board.board { border-radius: 12px; }
.gauge { border-radius: 4px; }
:root[data-coords="off"] .coord { display: none; }

/* --- Settings sheet --- */
.sheet { border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface); color: var(--text); padding: 20px 24px 24px; width: min(520px, calc(100vw - 32px)); }
.sheet::backdrop { background: rgba(17, 17, 17, 0.35); }
.set-group { padding: 16px 0 4px; border-top: 1px solid var(--border); }
.set-group h3 { font: 500 11px var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 0 0 12px; }
.swatches { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.swatch, .piece-set { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; font-size: 13px; color: var(--muted); background: transparent; }
.swatch[aria-checked="true"], .piece-set[aria-checked="true"] { border-color: var(--strong); color: var(--strong); }
.swatch-board { display: grid; grid-template-columns: repeat(4, 1fr); width: 100%; aspect-ratio: 2 / 1; border-radius: 8px; overflow: hidden; }
.swatch-board i:nth-child(odd) { background: var(--sw-light); }
.swatch-board i:nth-child(even) { background: var(--sw-dark); }
.swatch-board i:nth-child(n + 5):nth-child(odd) { background: var(--sw-dark); }
.swatch-board i:nth-child(n + 5):nth-child(even) { background: var(--sw-light); }
.piece-sets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.piece-set span.pp { display: flex; gap: 2px; padding: 6px 8px; border-radius: 8px; background: var(--light-sq); }
.piece-set img { width: 34px; height: 34px; }
.toggle { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-size: 14px; cursor: pointer; }
.toggle input { width: 16px; height: 16px; accent-color: var(--strong); }

/* --- Explorer, account --- */
.mini-tabs { display: flex; gap: 2px; }
.mini-tabs button { border: 0; padding: 2px 8px; font-size: 12px; color: var(--muted); border-radius: 4px; }
.mini-tabs button[aria-selected="true"] { background: var(--surface-2); color: var(--strong); }
.explorer { display: flex; flex-direction: column; max-height: 240px; overflow-y: auto; }
.px-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 4px 0 8px; border-bottom: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.px-head b { color: var(--strong); font-weight: 500; }
.px-head .text-btn { margin-left: auto; font-size: 12px; }
.px-form { display: flex; gap: 6px; margin-bottom: 8px; }
.px-form input { flex: 1; min-width: 0; }
.ex-opening { font: 12px var(--mono); color: var(--muted); padding: 2px 0 8px; }
.ex-row { display: grid; grid-template-columns: 64px auto 1fr; gap: 10px; align-items: center; text-align: left; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; padding: 6px 2px; font-size: 13px; }
.ex-row:active { transform: none; }
.ex-row .san { font: 500 13px var(--mono); color: var(--strong); }
.ex-name { grid-column: 2 / -1; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ex-count { font: 12px var(--mono); color: var(--muted); min-width: 44px; text-align: right; }
.wdl { display: flex; height: 8px; border-radius: 2px; overflow: hidden; background: var(--surface-2); }
.wdl .w { background: #f2efe8; }
.wdl .d { background: #9b9a96; }
.wdl .b { background: #2a2a28; }
:root[data-theme="light"] .wdl { box-shadow: 0 0 0 1px var(--border-strong); }
.small-btn { padding: 5px 12px; font-size: 13px; margin-top: 6px; }
.account-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 14px; }
.account-row b { color: var(--strong); font-weight: 600; }
.account-actions { display: flex; gap: 8px; align-items: center; }
.account-actions a { font-size: 14px; }
.account-hint a { color: var(--text); }

/* --- Guide, tips --- */
.help-sheet { width: min(620px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); }
.grade-list, .term-list { margin: 0; }
.grade-list > div, .term-list > div { display: grid; grid-template-columns: 170px 1fr; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.grade-list dt { display: flex; align-items: center; gap: 10px; color: var(--strong); }
.term-list dt { color: var(--strong); font-weight: 500; }
.grade-list dd, .term-list dd { margin: 0; color: var(--muted); }
.first-tip { display: flex; gap: 8px; align-items: flex-start; padding: 12px 14px; margin-bottom: 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-size: 13.5px; }
.first-tip p { margin: 0; flex: 1; }
.first-tip b { color: var(--strong); font-weight: 600; }
.link-btn { border: 0; padding: 0; font: inherit; color: var(--strong); text-decoration: underline; text-underline-offset: 3px; background: none; }
.link-btn:hover { background: none; }
.tl-legend { display: flex; flex-wrap: wrap; gap: 2px 18px; font: 10px var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 4px; }
.tl-of { color: var(--muted); margin-left: 6px; }
@media (max-width: 960px) { .grade-list > div, .term-list > div { grid-template-columns: 1fr; gap: 2px; } }

.tl-legend i { font-style: normal; text-transform: none; letter-spacing: 0; opacity: 0.7; }
.head-btns .icon-btn { width: 32px; height: 32px; }
.mv-time { margin-left: auto; font: 11px var(--mono); color: var(--muted); padding-left: 6px; }

/* --- Analysis board: tools, tree, editor --- */
.ab-tools { display: flex; gap: 10px; align-items: center; }
.mini-select { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.mini-select select { padding: 2px 6px; font-size: 12px; }
.mini-toggle { padding: 2px 10px; font-size: 12px; border-radius: 4px; color: var(--muted); }
.mini-toggle[aria-pressed="true"] { background: color-mix(in srgb, var(--c-blunder) 16%, transparent); border-color: color-mix(in srgb, var(--c-blunder) 50%, transparent); color: var(--c-blunder); }
.mini-check { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.threat-note { font-size: 13px; color: var(--text); padding: 6px 0 2px; }
.threat-note b { font: 500 13px var(--mono); color: var(--c-blunder); }
.ab-moves { display: block; line-height: 1.9; }
.ab-moves .ab-mv { display: inline; }
.ab-var { color: var(--muted); font: 12.5px var(--mono); }
.ab-var .ab-mv { font-size: 12.5px; color: var(--muted); }
.ab-var .ab-mv.current { color: var(--strong); }
.ab-tree-tools { margin-top: 4px; }
.ab-tree-tools .text-btn { font-size: 12.5px; padding: 2px 4px; }
.ab-editor { margin-top: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); display: flex; flex-direction: column; gap: 10px; max-width: calc(var(--board) + 16px); }
.palette { display: grid; grid-template-columns: repeat(13, minmax(0, 1fr)); gap: 4px; }
.pal { aspect-ratio: 1; padding: 2px; border: 1px solid var(--border); border-radius: 6px; display: grid; place-items: center; background: var(--light-sq); color: var(--on-primary); }
.pal img { width: 100%; height: 100%; }
.pal.on { outline: 2px solid var(--strong); outline-offset: 1px; }
.pal[data-piece="x"] { background: var(--surface-2); color: var(--muted); }
.spacer { flex: 1; }
@media (max-width: 960px) { .palette { grid-template-columns: repeat(7, minmax(0, 1fr)); } }

/* --- Stats --- */
.games-tools { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.secondary-link { font-size: 14px; color: var(--text); }
.stat-cards { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--border); }
.stat-cards > div { padding: 24px 20px 24px 0; display: flex; flex-direction: column; gap: 4px; }
.stat-cards > div + div { padding-left: 20px; border-left: 1px solid var(--border); }
.stat-num { font: 400 40px/1 var(--serif); color: var(--strong); }
.stat-cap { font-size: 13px; color: var(--muted); }
.stat-section { padding: 28px 0; border-bottom: 1px solid var(--border); }
.stat-section h3 { font: 400 26px var(--serif); color: var(--strong); margin: 0 0 12px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 48px; }
.stat-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.stat-table th { text-align: left; font: 500 11px var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 6px 8px 8px 0; border-bottom: 1px solid var(--border); }
.stat-table td { padding: 8px 8px 8px 0; border-bottom: 1px solid var(--border); text-transform: capitalize; }
.stat-table td:nth-child(2), .stat-table td:nth-child(4) { font: 13px var(--mono); }
.stat-table td:nth-child(3) { width: 40%; }
.wdl .win { background: var(--c-best); }
.wdl .drawn { background: var(--muted); }
.wdl .lost { background: var(--c-blunder); }
.leaks { margin: 8px 0; padding: 0; list-style: none; }
.leaks li { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 15px; }
.leaks b { color: var(--strong); font-weight: 600; }
.rating-chart { display: block; width: 100%; height: 140px; }
.chart-axis { display: flex; justify-content: space-between; font: 11px var(--mono); color: var(--muted); margin-top: 6px; }

/* --- Practice --- */
.empty-state { padding: 48px 0; max-width: 560px; }
.empty-state h3 { font: 400 30px var(--serif); color: var(--strong); margin: 0 0 8px; }
.empty-state p { color: var(--muted); margin: 0 0 20px; }
.practice-stage { margin-top: 24px; }
#practice.in-session .page-head .lede, #practice.in-session .page-head h2 { display: none; }
#practice.in-session .page-head { padding-bottom: 0; border-bottom: 0; }
.train-who-form { padding: 32px 0; max-width: 640px; }
.train-who-form .ab-row { flex-wrap: wrap; }
.train-who-form input { flex: 1; min-width: 180px; }
.train-q { font: 400 26px var(--serif); color: var(--strong); margin: 0 0 14px; }
.train-session { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; padding: 28px 0; border-bottom: 1px solid var(--border); }
.train-session .eyebrow { margin-bottom: 10px; }
.train-session h3 { font: 400 34px/1.1 var(--serif); color: var(--strong); margin: 0 0 8px; }
.train-session p { margin: 0; max-width: 60ch; }
.train-session .primary { flex: none; padding: 12px 28px; }
.train-summary { padding: 16px 0; border-bottom: 1px solid var(--border); font-size: 14px; color: var(--muted); }
.train-summary b { color: var(--strong); font-weight: 500; }
.patterns { list-style: none; margin: 8px 0 0; padding: 0; }
.pattern { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 20px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.pattern:last-child { border-bottom: 0; }
.pattern-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.pattern-text b { color: var(--strong); font-weight: 500; font-size: 15px; }
.pattern-text span { font-size: 13px; color: var(--muted); }
.pattern-bar { display: block; height: 2px; margin-top: 6px; background: var(--border); position: relative; max-width: 320px; }
.pattern-bar::after { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--w); background: var(--c-mistake); }
.pattern-num { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font: 13px var(--mono); color: var(--text); white-space: nowrap; }
.pattern-num .muted { font-size: 12px; }
.pattern .small-btn { margin-top: 0; }
.scan { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.scan-text { font-size: 14px; }
.scan-bar { width: 100%; max-width: 420px; height: 3px; background: var(--border); }
.scan-bar i { display: block; height: 100%; background: var(--strong); transition: width 0.3s var(--ease); }
@media (max-width: 640px) {
  .train-session { flex-direction: column; align-items: stretch; }
  .pattern { grid-template-columns: 1fr auto; }
  .pattern-num { display: none; }
}
.practice-side { max-width: 440px; }
.practice-side h3 { font: 400 28px/1.15 var(--serif); color: var(--strong); margin: 4px 0 10px; }
.practice-side .cls-icon { vertical-align: 1px; }
.practice-msg { margin: 18px 0 4px; padding: 12px 14px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); font-size: 14px; }
.practice-msg.solved { border-color: color-mix(in srgb, var(--c-best) 50%, transparent); }
.text-link { font-size: 13px; color: var(--muted); margin-left: 6px; }
@media (max-width: 960px) {
  .stat-cards { grid-template-columns: 1fr 1fr; }
  .stat-cards > div:nth-child(3) { padding-left: 0; border-left: 0; }
  .stat-grid { grid-template-columns: 1fr; }
  #practice .stage { display: grid; grid-template-columns: minmax(0, 1fr); }
}
.art-leaks .eyebrow { margin-bottom: 12px; }
.art-leak { display: flex; flex-direction: column; gap: 2px; padding: 12px 0; border-top: 1px solid var(--border); font-size: 14px; }
.art-leak b { color: var(--strong); font-weight: 600; }
.art-leak span { color: var(--muted); }
.text-link-strong { color: var(--strong); font-weight: 500; }

/* --- Ads and support: quiet, text-first, never on the board --- */
.ad-slot { flex: none; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding: 10px 14px; border: 1px dashed var(--border-strong); border-radius: 8px; font-size: 13px; color: var(--text); }
.ad-slot a { color: var(--strong); }
.ad-label { font: 500 10px var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.ad-sponsor { color: var(--muted); font-size: 12px; }
.ad-home { margin: 32px 0 0; }
.support-line { font-size: 13px; color: var(--muted); }
.support-line a { color: var(--text); }
