/* HumanChess — cozy theme: warm paper, wood board, soft cards. */

:root {
  --bg: #f4ece1;
  --bg-2: #efe3d3;
  --card: #fffaf3;
  --line: #e7d9c6;
  --text: #3a2e26;
  --muted: #8a7768;
  --accent: #c2603f;
  --accent-soft: #f3dccf;
  --honey: #d9a441;
  --sage: #6f8f63;
  --best: #4f8a4a;
  --simple: #3f7cac;
  --tricky: #d98a2b;
  --played: #b9473f;
  --mistake: #c4553f;
  --choice: #8b5e9b;
  --mistake-bg: #f7e1da;
  --choice-bg: #efe4f2;
  --best-bg: #e6f0e1;
  --simple-bg: #e2ecf4;
  --tricky-bg: #f8ead6;
  --j-excellent: #5f9e8a; --j-good: #86a36d; --j-inaccuracy: #d6a12c; --j-mistake: #e0663f; --j-blunder: #c2392d;
  --sq-light: #f1dfc4;
  --sq-dark: #b98b62;
  --coord-on-light: #9a7351;
  --coord-on-dark: #f3e3cb;
  --eval-black: #4a3b31;
  --eval-white: #fbf5ec;
  --shadow: 0 1px 2px rgba(80, 50, 20, .06), 0 8px 28px rgba(80, 50, 20, .08);
  --radius: 18px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1d1814; --bg-2: #241e19; --card: #2a231e; --line: #3b3029; --text: #f0e6da; --muted: #b3a291;
    --accent: #e08a68; --accent-soft: #4a3226; --honey: #e2b55b; --sage: #93b086;
    --best: #79b56f; --simple: #6fa6d1; --tricky: #e9a552; --played: #e06a5f;
    --mistake: #e57a62; --choice: #bb93cc; --mistake-bg: #3e2620; --choice-bg: #33283a;
    --best-bg: #2c3a29; --simple-bg: #26323d; --tricky-bg: #3d3122;
    --j-excellent: #77b29f; --j-good: #9dba86; --j-inaccuracy: #e2b44e; --j-mistake: #ec7f5c; --j-blunder: #e05a4c;
    --sq-light: #d9c3a3; --sq-dark: #8f6a4b; --coord-on-light: #7a5a3f; --coord-on-dark: #ecdcc4;
    --eval-black: #15110e; --eval-white: #efe4d4;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1d1814; --bg-2: #241e19; --card: #2a231e; --line: #3b3029; --text: #f0e6da; --muted: #b3a291;
  --accent: #e08a68; --accent-soft: #4a3226; --honey: #e2b55b; --sage: #93b086;
  --best: #79b56f; --simple: #6fa6d1; --tricky: #e9a552; --played: #e06a5f;
  --mistake: #e57a62; --choice: #bb93cc; --mistake-bg: #3e2620; --choice-bg: #33283a;
  --best-bg: #2c3a29; --simple-bg: #26323d; --tricky-bg: #3d3122;
  --j-excellent: #77b29f; --j-good: #9dba86; --j-inaccuracy: #e2b44e; --j-mistake: #ec7f5c; --j-blunder: #e05a4c;
  --sq-light: #d9c3a3; --sq-dark: #8f6a4b; --coord-on-light: #7a5a3f; --coord-on-dark: #ecdcc4;
  --eval-black: #15110e; --eval-white: #efe4d4;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 600px at 10% -10%, var(--bg-2), transparent 60%), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.55 Nunito, system-ui, "Segoe UI", sans-serif;
  min-height: 100vh;
}
h1, h2, h3 { font-family: Fraunces, Georgia, serif; font-weight: 700; margin: 0; letter-spacing: -.01em; }
h3 { font-size: 17px; }
a { color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; margin: 10px 0 0; }
.error { color: var(--played); }

/* ---------- top bar */
.topbar {
  display: flex; align-items: center; gap: 14px;
  max-width: 1240px; margin: 0 auto; padding: 18px 16px 6px;
}
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none;
  font: 700 22px Fraunces, Georgia, serif; }
.logo-mark {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px;
  background: var(--accent); color: #fff8ef; font-size: 24px; box-shadow: var(--shadow);
  font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", "DejaVu Sans", serif; font-weight: 400;
}
.tagline { color: var(--muted); font-size: 14px; flex: 1; }
@media (max-width: 640px) { .tagline { display: none; } .topbar { justify-content: space-between; } }

main { max-width: 1240px; margin: 0 auto; padding: 12px 16px 64px; }

/* ---------- basics */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px;
}
.btn {
  font: inherit; font-weight: 700; border: 1px solid var(--line); background: var(--card); color: var(--text);
  padding: 9px 16px; border-radius: 12px; cursor: pointer; text-decoration: none; display: inline-block;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff8ef; }
.btn.soft { background: var(--accent-soft); border-color: transparent; }
.btn.small { padding: 4px 10px; font-size: 13px; border-radius: 10px; }
.link { font: inherit; font-weight: 700; color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; }
.link:hover { text-decoration: underline; }
.icon-btn {
  font: inherit; font-size: 17px; width: 42px; height: 38px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.input {
  font: inherit; flex: 1; min-width: 0; padding: 10px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
}
.input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 6px; }
.chip {
  font: inherit; font-size: 13px; font-weight: 700; padding: 5px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: transparent; color: var(--muted);
}
.chip.on, .chip:hover { background: var(--accent-soft); color: var(--text); border-color: transparent; }
.tag {
  font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: var(--bg-2); color: var(--muted); margin-left: 6px;
}
.tag.ok { background: var(--best-bg); color: var(--best); }
.mv { font-weight: 800; white-space: nowrap; }
.dots { display: inline-flex; gap: 3px; vertical-align: middle; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--honey); animation: bob 1s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes bob { 0%, 80%, 100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-4px); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .dots i { animation: none; } }
.loading { display: flex; align-items: center; gap: 8px; color: var(--muted); padding: 12px 0; }
.piece-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 8px; vertical-align: -1px;
  border: 1.5px solid var(--text); }
.piece-dot.white { background: #fbf5ec; } .piece-dot.black { background: #3a2e26; }

/* ---------- home */
.hero { padding: 26px 4px 18px; max-width: 720px; }
.hero h1 { font-size: clamp(26px, 4vw, 36px); margin-bottom: 6px; }
.user-form { display: flex; gap: 10px; }
.game-list { display: grid; gap: 8px; margin-top: 10px; }
.game-row {
  display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 14px;
  padding: 12px 14px; border-radius: 14px; text-decoration: none; border: 1px solid transparent;
  background: var(--bg);
}
.game-row:hover { border-color: var(--line); transform: translateY(-1px); transition: transform .15s; }
.result-badge {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px;
  font-weight: 800; color: #fff8ef;
}
.r-win .result-badge { background: var(--sage); }
.r-loss .result-badge { background: var(--played); }
.r-draw .result-badge { background: var(--muted); }
.game-main { display: grid; min-width: 0; }
.game-title { font-size: 15px; }
.game-sub { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game-side { display: grid; justify-items: end; gap: 4px; }

/* ---------- review layout */
/* App-like review: the page never scrolls on desktop. The board is sized from the
   window height so it always stays in view; the side panel scrolls on its own. */
.review {
  --side: clamp(360px, 32vw, 460px);
  --board: max(300px, min(calc(100vh - 225px), calc(100vw - var(--side) - 120px), 820px));
  display: grid; grid-template-columns: auto var(--side); gap: 22px; justify-content: center; align-items: stretch;
  height: calc(100vh - 82px);
}
.board-col { display: grid; gap: 8px; align-content: start; justify-items: start; }
.player { display: flex; align-items: center; gap: 6px; min-height: 26px; font-size: 15px; padding: 0 4px 0 34px; }
.player .piece-dot { margin-right: 2px; }
.player .tag { margin-left: 2px; }
.board-wrap { display: grid; grid-template-columns: 22px var(--board); gap: 12px; }
.board-frame { position: relative; width: var(--board); }
.board-badges { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
/* The last move's class on its square: 0.44 of a square, at the top-right corner. */
.j-icon.on-board { position: absolute; width: 5.5%; height: 5.5%; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .4));
  animation: badge-in .22s ease-out .12s both; }
@keyframes badge-in { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .j-icon.on-board { animation: none; } }
.board {
  aspect-ratio: 1; width: var(--board); border-radius: 10px; overflow: hidden;
  box-shadow: 0 0 0 6px #7a5434, 0 0 0 7px rgba(0, 0, 0, .15), 0 18px 40px rgba(60, 35, 15, .25);
}
.cg-host { width: 100%; height: 100%; }
.controls { display: flex; justify-content: center; flex-wrap: wrap; gap: 14px; padding-left: 34px; }
.ctrl-group { display: flex; gap: 6px; }
.icon-btn.wide { width: auto; padding: 0 12px; font-size: 14px; font-weight: 800; color: var(--accent); }
.side-col { display: flex; flex-direction: column; gap: 10px; min-height: 0; padding: 14px; }
.side-head { display: grid; gap: 8px; flex: none; }
.back { font-size: 13px; font-weight: 700; color: var(--accent); text-decoration: none; }
.side-title { display: grid; }

/* ---------- board theme (chessground) */
cg-board {
  background-color: var(--sq-light);
  background-image: repeating-conic-gradient(var(--sq-dark) 0 25%, var(--sq-light) 0 50%);
  background-size: 25% 25%;
}
cg-board square.last-move { background-color: rgba(217, 164, 65, .45); }
cg-board square.selected { background-color: rgba(111, 143, 99, .55); }
cg-board square.move-dest { background: radial-gradient(rgba(79, 105, 70, .5) 22%, transparent 0); }
cg-board square.oc.move-dest { background: radial-gradient(transparent 0%, transparent 79%, rgba(79, 105, 70, .45) 80%); }
cg-board square.move-dest:hover { background: rgba(111, 143, 99, .35); }
cg-board square.check { background: radial-gradient(ellipse at center, rgba(200, 60, 40, .9) 0%, rgba(200, 60, 40, .35) 45%, transparent 75%); }
/* Coordinates inside the edge squares, Lichess style: ranks top-left, files
   bottom-right, each colored against its own square. Overrides chessground's
   base offsets, which are tuned for Lichess's layout. */
.cg-wrap coords { font-family: Nunito, sans-serif; font-weight: 800; opacity: 1;
  font-size: clamp(9px, calc(var(--board, 560px) / 50), 13px); line-height: 1; }
.cg-wrap coords.ranks { left: 3px; top: 3px; width: auto; height: 100%; }
.cg-wrap coords.ranks coord { flex: 1 1 0; transform: none; }
.cg-wrap coords.files { left: 0; bottom: 3px; width: 100%; height: auto; text-transform: lowercase; }
.cg-wrap coords.files coord { flex: 1 1 0; text-align: right; padding-right: 4px; }
.cg-wrap coords coord { color: var(--coord-on-light); }
.cg-wrap coords:not(.black) coord:nth-child(odd),
.cg-wrap coords.black coord:nth-child(even) { color: var(--coord-on-dark); }

/* ---------- eval bar */
.evalbar { position: relative; border-radius: 8px; overflow: hidden; background: var(--eval-black); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15); }
.evalbar-fill { position: absolute; left: 0; right: 0; bottom: 0; height: var(--win, 50%); background: var(--eval-white); transition: height .35s ease; }
.evalbar.flipped .evalbar-fill { bottom: auto; top: 0; }
.evalbar.stale { opacity: .45; }
.evalbar-label {
  position: absolute; left: 0; right: 0; top: 6px; text-align: center; font-size: 10px; font-weight: 800;
  color: var(--eval-white); writing-mode: vertical-rl; transform: rotate(180deg);
}
.evalbar-label.on-white { top: auto; bottom: 6px; color: var(--eval-black); }
.evalbar.flipped .evalbar-label { top: auto; bottom: 6px; }
.evalbar.flipped .evalbar-label.on-white { bottom: auto; top: 6px; }

/* ---------- summary + graph */
.accuracy { display: flex; gap: 8px; }
.acc { flex: 1; display: flex; align-items: baseline; gap: 8px; padding: 4px 10px; border-radius: 12px; background: var(--bg); min-width: 0; }
.acc .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-num { font: 700 20px Fraunces, Georgia, serif; color: var(--accent); }
.acc-num.soft { color: var(--muted); }
.graph svg { width: 100%; height: 52px; display: block; border-radius: 12px; cursor: pointer; }
.g-black { fill: var(--eval-black); }
.g-white { fill: var(--eval-white); }
.g-mid { stroke: var(--honey); stroke-width: 1; stroke-dasharray: 4 4; opacity: .7; }
.g-crit { fill: var(--honey); stroke: var(--card); stroke-width: 1.5; }
.g-cursor { stroke: var(--accent); stroke-width: 3; }

/* ---------- move classes: chess.com-style badges (simplest: shield, trickiest: bolt) */
.j-icon { display: inline-flex; flex: none; width: 20px; height: 20px; --j: var(--muted); }
.j-icon svg { width: 100%; height: 100%; display: block; }
.j-icon circle { fill: var(--j); }
.j-icon path, .j-icon text { fill: #fff; }
.j-icon path.stroke { fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.j-icon text { font-family: Nunito, system-ui, sans-serif; font-weight: 900; text-anchor: middle; letter-spacing: -.04em; }
.j-icon.sm { width: 16px; height: 16px; }
.j-icon.lg { width: 32px; height: 32px; }
.j-best { --j: var(--best); }
.j-simple { --j: var(--simple); }
.j-tricky { --j: var(--tricky); }
.j-excellent { --j: var(--j-excellent); }
.j-good { --j: var(--j-good); }
.j-inaccuracy { --j: var(--j-inaccuracy); }
.j-mistake { --j: var(--j-mistake); }
.j-blunder { --j: var(--j-blunder); }

/* ---------- moves */
.moves { margin-top: 8px; position: relative; }
.move-row { display: grid; grid-template-columns: 38px 1fr 1fr; gap: 4px; padding: 1px 0; }
.move-row:nth-child(odd) { background: var(--bg); border-radius: 8px; }
.move-no { color: var(--muted); font-size: 13px; padding: 4px 0 0 8px; }
.move {
  font: inherit; font-weight: 700; text-align: left; background: none; border: 0; color: var(--text);
  padding: 3px 8px; border-radius: 8px; cursor: pointer; display: flex; align-items: center; gap: 6px;
}
.move:hover { background: var(--accent-soft); }
.move.active { background: var(--accent); color: #fff8ef; }
.move .crit { color: var(--honey); margin-left: 4px; font-size: 13px; }
.move.active .crit { color: #fff8ef; }

/* ---------- coach */
.coach { display: grid; gap: 12px; }
.coach-head { display: flex; gap: 12px; align-items: center; }
.coach-avatar {
  display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-size: 24px;
  font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", "DejaVu Sans", serif;
}
.coach-head h3 { line-height: 1.2; }
.coach p { margin: 0; }
.summary-text { font-size: 15px; }
.pill { font-size: 12px; font-weight: 800; padding: 2px 9px; border-radius: 999px; color: #fff8ef; }
.pill.best { background: var(--best); } .pill.simple { background: var(--simple); } .pill.tricky { background: var(--tricky); }
.progress { display: grid; gap: 8px; }
.progress-track { height: 10px; border-radius: 999px; background: var(--bg-2); overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--honey), var(--accent)); border-radius: 999px; transition: width .6s ease; }
.analyse { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.variation { border-radius: 14px; padding: 10px 12px; background: var(--bg); border: 1px dashed var(--line); display: grid; gap: 6px; }
.var-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.var-moves { display: flex; flex-wrap: wrap; gap: 4px 8px; font-size: 14px; }
.var-move { font-weight: 700; color: var(--muted); }
.var-move.active { color: var(--accent); }
.key-list { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- home: how it works */
.how-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 0 0 18px; }
@media (max-width: 760px) { .how-grid { grid-template-columns: 1fr; } }
.how { border-radius: 16px; padding: 12px 14px; display: grid; gap: 6px; justify-items: start; align-content: start; }
.how p { margin: 0; font-size: 14px; }
.how.best { background: var(--best-bg); } .how.simple { background: var(--simple-bg); } .how.tricky { background: var(--tricky-bg); }
.skeleton { height: 62px; background: linear-gradient(90deg, var(--bg) 0%, var(--bg-2) 50%, var(--bg) 100%); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* ---------- review: header, legend */
.side-top { display: flex; justify-content: space-between; }
.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; min-height: 20px; font-size: 13px; color: var(--muted); padding-left: 34px; }
.legend .sw { display: inline-block; width: 18px; height: 6px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.sw.best { background: var(--best); } .sw.simple { background: var(--simple); } .sw.tricky { background: var(--tricky); } .sw.played { background: var(--played); opacity: .7; }
.keys { margin: 12px 0 0; }

/* ---------- coach: progress, verdict, options */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.steps li { display: flex; align-items: center; gap: 10px; color: var(--muted); font-weight: 600; }
.steps li.now { color: var(--text); }
.steps li.done { color: var(--sage); }
.step-dot { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; font-size: 12px; font-weight: 800;
  background: var(--bg-2); color: var(--muted); }
.steps li.now .step-dot { background: var(--honey); color: #fff8ef; }
.steps li.done .step-dot { background: var(--sage); color: #fff8ef; }

/* The headline of a move: badge, "8.h4 is the trickiest move", eval. */
.verdict { display: flex; align-items: center; gap: 12px; }
.verdict-text { display: grid; flex: 1; min-width: 0; }
.verdict h3 { font-size: 18px; line-height: 1.25; }
.verdict.j-best h3, .verdict.j-simple h3, .verdict.j-tricky h3 { color: var(--j); }
.verdict-eval { flex: none; font-weight: 800; font-size: 14px; padding: 3px 10px; border-radius: 10px; background: var(--bg); cursor: help; }

/* Which key moment this is, with its own previous / next. */
.moment-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.moment-bar.k-mistake .moment-kind { color: var(--mistake); }
.moment-bar.k-choice .moment-kind { color: var(--choice); }
.moment-nav { display: flex; align-items: center; gap: 6px; text-transform: none; letter-spacing: 0; }
.icon-btn.tiny { display: inline-grid; place-items: center; width: 28px; height: 26px; font-size: 10px; line-height: 1;
  border-radius: 8px; padding: 0; }
.icon-btn:disabled { opacity: .35; cursor: default; border-color: var(--line); color: var(--text); }

/* Candidate moves: rows that open one at a time. */
.options-label { display: flex; justify-content: space-between; font-size: 12px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .05em; margin-top: 2px; }
.options-label .muted { text-transform: none; letter-spacing: 0; font-weight: 700; }
.options { display: grid; gap: 6px; }
.opt { border-radius: 12px; background: var(--bg); transition: background .15s; }
.opt.open { box-shadow: inset 3px 0 0 var(--role); }
.opt.best { --role: var(--best); } .opt.simple { --role: var(--simple); } .opt.tricky { --role: var(--tricky); }
.opt.open.best { background: var(--best-bg); } .opt.open.simple { background: var(--simple-bg); } .opt.open.tricky { background: var(--tricky-bg); }
.opt-head { font: inherit; color: var(--text); width: 100%; display: grid; grid-template-columns: auto 1fr auto auto; align-items: center;
  gap: 8px; padding: 8px 12px; border: 0; background: none; border-radius: 12px; cursor: pointer; text-align: left; }
.opt:not(.open) .opt-head:hover { background: var(--accent-soft); }
.opt-icons { display: flex; gap: 2px; }
.opt-roles { font-size: 13px; font-weight: 800; color: var(--role); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opt-move { display: flex; align-items: center; gap: 6px; }
.opt-move .mv { font-size: 15px; }
.tag.mine { margin: 0; background: var(--card); color: var(--text); }
.opt-eval { font-weight: 800; color: var(--muted); min-width: 44px; text-align: right; }
.opt-body { display: grid; gap: 8px; padding: 0 12px 12px 15px; }
.opt-body p { font-size: 14px; }
.opt-body p.secondary { color: var(--muted); }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; font-size: 13px; }
.fact { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; border-bottom: 1px dashed var(--line); cursor: help; }
.opt-actions { display: flex; flex-wrap: wrap; gap: 16px; }
.link.warn { color: var(--played); justify-self: start; }
.link.tiny { font-size: 12px; }
.footnote { margin: 0; }

/* Start of the review: moments and move quality. */
.moment-list { display: grid; gap: 6px; }
.moment-row { font: inherit; display: grid; grid-template-columns: 22px auto 1fr; align-items: center; gap: 10px; text-align: left;
  padding: 8px 10px; border-radius: 12px; border: 1px solid transparent; background: var(--bg); color: var(--text); cursor: pointer; }
.moment-row:hover { border-color: var(--line); }
.moment-icon { font-weight: 800; }
.moment-move { display: inline-flex; align-items: center; gap: 6px; }
.quality { display: grid; gap: 3px; margin-top: 4px; }
.q-row { display: grid; grid-template-columns: 1fr 44px 44px; align-items: center; font-size: 14px; padding: 2px 4px; }
.q-row.head { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.q-label { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.q-row .n { font-weight: 800; text-align: center; }
.q-row .n.soft { color: var(--muted); }
.moment-row.k-mistake .moment-icon { color: var(--mistake); }
.moment-row.k-choice .moment-icon { color: var(--choice); }
.btn.soft.k-mistake { background: var(--mistake-bg); color: var(--mistake); }
.btn.soft.k-choice { background: var(--choice-bg); color: var(--choice); }
.var-move { font: inherit; font-weight: 700; color: var(--muted); background: none; border: 0; padding: 0 2px; cursor: pointer; }
.var-move:hover { color: var(--text); }

/* ---------- moves and graph: kinds */
.move.k-mistake .crit { color: var(--mistake); }
.move.k-choice .crit { color: var(--choice); }
.move.j-blunder .san, .move.j-mistake .san { color: var(--mistake); }
.move.active .san { color: inherit; }
.g-crit.k-mistake { fill: var(--mistake); }
.g-crit.k-choice { fill: var(--choice); }

@media (max-width: 1020px) {
  .review { --board: calc(100vw - 70px); grid-template-columns: 1fr; height: auto; }
  .side-col { max-height: none; }
  .panes { overflow: visible; }
  .player, .controls, .legend { padding-left: 0; }
}

/* ---------- side panel: tabs and candidate selector */
.side-head .side-title b { font-size: 15px; }
.chips.scroll { margin: 0; gap: 6px; }
.chips.scroll .chip { padding: 3px 10px; }
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--bg); flex: none; }
.tab { flex: 1; font: inherit; font-weight: 800; font-size: 14px; padding: 6px 10px; border: 0; border-radius: 9px;
  background: transparent; color: var(--muted); cursor: pointer; }
.tab.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(60, 40, 20, .12); }
.panes { flex: 1; min-height: 0; overflow-y: auto; margin: 0 -6px; padding: 2px 6px 6px; scrollbar-width: thin; }
.pane[hidden] { display: none; }
.coach { gap: 12px; }
.summary-text { font-size: 14px; }

/* The review fills the window: no bottom padding that would make the page scroll. */
main:has(.review) { padding-bottom: 0; max-width: none; }

body:has(.review) .topbar { max-width: none; padding-left: 28px; padding-right: 28px; }
.list-title { font-size: 20px; margin-bottom: 4px; }
.showcase-note { text-align: center; margin-top: 14px; }

/* ---------- sign in (only when the app has a password, as on AWS) */
.login { max-width: 380px; margin: 48px auto 0; display: grid; gap: 14px; }
.login h1 { font-size: 28px; }
.login p { margin: 0; }
.login-field { display: grid; gap: 6px; font-weight: 700; }
.login .btn { justify-self: start; }

/* ---------- demo games */
.tag.demo { background: var(--choice-bg); color: var(--choice); margin: 0 8px 0 0; text-transform: uppercase; letter-spacing: .04em; }
.demo-title { font-weight: 800; font-size: 15px; display: flex; align-items: center; margin-bottom: 2px; }
.game-row.demo { border-color: var(--choice-bg); }

/* ---------- public site: sources, pasted PGN, about, footer */
.chips.sources { margin: 0 0 12px; }
.privacy-note { margin: 10px 0 0; }
.pgn-card { margin-top: 16px; }
.pgn-card summary { cursor: pointer; font-weight: 700; color: var(--muted); }
.pgn-card form { display: grid; gap: 10px; margin-top: 12px; }
textarea.input.pgn { font: 13px/1.4 ui-monospace, "Cascadia Mono", Consolas, monospace; resize: vertical; width: 100%; }
.pgn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.about { margin-top: 16px; max-width: 760px; }
.about h2 { font-size: 20px; margin-bottom: 8px; }
.about p { margin: 8px 0; }
.site-footer { max-width: 1240px; margin: 0 auto; padding: 0 16px 36px; color: var(--muted); font-size: 13px; }
.site-footer a { text-decoration: underline; text-underline-offset: 2px; }
body.in-review .site-footer { display: none; }

/* ---------- phones: the board edge to edge, readable text, the controls under the thumb
   Portrait: the opponent's row, the board as wide as the screen over a thin eval strip,
   the coach panel, and the controls at the bottom, as in the chess apps. The panel
   scrolls when a text is longer than the room left; the text never shrinks to fit.
   A short landscape window puts the board on the left at full height. fitBoard() adds
   .compact (and .land) and sizes --board. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
button, a, summary { touch-action: manipulation; }
.compact-only { display: none; }
.review.compact .compact-only { display: inline-grid; }
.review.compact .hide-compact { display: none; }
body.compact-review { overflow: hidden; overscroll-behavior: none; }
body.compact-review .topbar, body.compact-review .site-footer { display: none; }
body.compact-review main { padding: 0; }
.review.compact {
  --role-bg: var(--bg);
  display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr) auto;
  grid-template-areas: "top" "board" "panel" "controls";
  gap: 0; height: 100vh; height: 100dvh; overflow: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
  -webkit-tap-highlight-color: transparent;
}
.review.compact .board-col { display: contents; }
.review.compact .player.top { grid-area: top; min-height: 36px; padding: 0 100px 0 12px; font-size: 15px; gap: 6px;
  white-space: nowrap; overflow: hidden; }
.review.compact .player.bottom, .review.compact .legend { display: none; }
.review.compact .back-compact { grid-area: top; justify-self: end; align-self: stretch; place-items: center; padding: 0 14px;
  font-size: 15px; }
.review.compact .board { border-radius: 0; box-shadow: none; }
.review.compact .cg-wrap coords { font-size: 10px; }
.review.compact:not(.land) .board-wrap { grid-area: board; grid-template-columns: var(--board); grid-template-rows: 5px auto; gap: 0;
  justify-content: center; }
.review.compact:not(.land) .evalbar { border-radius: 0; box-shadow: none; }
.review.compact:not(.land) .evalbar-label { display: none; }
/* The strip fills from the side of the player at the bottom of the board. */
.review.compact:not(.land) .evalbar-fill { top: 0; bottom: 0; left: 0; right: auto; height: auto; width: var(--win, 50%);
  transition: width .35s ease; }
.review.compact:not(.land) .evalbar.flipped .evalbar-fill { left: auto; right: 0; }

.review.compact .side-col { grid-area: panel; min-height: 0; overflow: hidden; gap: 0; padding: 10px 14px 0;
  border: 0; border-radius: 0; box-shadow: none; font-size: 16px; line-height: 1.5; }
.review.compact .side-head, .review.compact .tabs { display: none; }
.review.compact .panes { margin: 0 -14px; padding: 0 14px 14px; mask-image: linear-gradient(to bottom, #000 calc(100% - 12px), transparent); }
.review.compact .panes:not(:hover) { scrollbar-width: none; }

.review.compact .controls { grid-area: controls; flex-wrap: nowrap; gap: 6px; padding: 6px 8px max(6px, env(safe-area-inset-bottom));
  background: var(--card); border-top: 1px solid var(--line); }
/* Flip and moves on the left, key moments in the middle, back / forward on the right. */
.review.compact .ctrl-group { gap: 6px; flex: 2 1 0; min-width: 0; }
.review.compact .ctrl-group:nth-child(1) { order: 3; }
.review.compact .ctrl-group:nth-child(2) { order: 2; flex-grow: 3.2; }
.review.compact .ctrl-group:nth-child(3) { order: 1; }
.review.compact .controls .icon-btn { flex: 1 1 0; min-width: 0; width: auto; height: 48px; padding: 0; font-size: 20px; }
.review.compact .controls .icon-btn.wide { font-size: 14px; white-space: nowrap; }
.review.compact .icon-btn:active { background: var(--accent-soft); }

/* The coach panel */
.review.compact .coach { gap: 10px; }
.review.compact .coach p { line-height: 1.5; }
.review.compact .coach-avatar { display: none; }
.review.compact .coach-head h3 { font-size: 19px; }
.review.compact .small, .review.compact .muted.small { font-size: 14px; }
.review.compact .btn { padding: 12px 18px; }
.review.compact .moment-bar { font-size: 13px; }
.review.compact .moment-nav .icon-btn { display: none; }
.review.compact .verdict { gap: 10px; }
.review.compact .verdict h3 { font-size: 18px; line-height: 1.25; }
.review.compact .verdict .j-icon { width: 30px; height: 30px; }
.review.compact .verdict .verdict-text .muted { display: none; }
.review.compact .moment-row { padding: 10px 12px; min-height: 50px; }
.review.compact .q-row { font-size: 15px; }
.review.compact .var-moves { font-size: 16px; gap: 6px 10px; }
.review.compact .footnote { display: flex; align-items: baseline; gap: 6px; min-width: 0; margin: 0; font-size: 12px; white-space: nowrap; }
.review.compact .footnote .src { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.review.compact .footnote button { flex: none; font-size: 13px; padding: 6px 0; }

/* Options: your move and the candidates side by side as cards; only the chosen one explains itself below. */
.review.compact .options-label, .review.compact .opt-icons, .review.compact .opt-move .tag { display: none; }
.review.compact .options { grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr)); gap: 6px; }
.review.compact .opt { display: contents; }
.review.compact .opt.best { --role-bg: var(--best-bg); } .review.compact .opt.simple { --role-bg: var(--simple-bg); } .review.compact .opt.tricky { --role-bg: var(--tricky-bg); }
.opt.you { --role: var(--played); --role-bg: var(--mistake-bg); }
.opt.you .opt-roles { color: var(--played); }
/* A card: the role, the move (with your move's class), the eval, one line each. */
.review.compact .opt-head { grid-row: 1; display: grid; grid-template-columns: minmax(0, 1fr); align-content: center; justify-items: center;
  gap: 0; padding: 6px 4px; border-radius: 12px; background: var(--bg); border: 2px solid transparent; text-align: center; line-height: 1.25; }
.review.compact .opt.open .opt-head { background: var(--role-bg); border-color: var(--role); }
.review.compact .opt-roles { font-size: 13px; white-space: normal; }
.review.compact .opt-move { gap: 4px; }
.review.compact .opt-move .mv { font-size: 16px; }
.review.compact .opt-eval { min-width: 0; font-size: 13px; text-align: center; }
.review.compact .opt-body { grid-row: 2; grid-column: 1 / -1; gap: 10px; padding: 10px 14px 12px 16px; border-radius: 12px;
  background: var(--role-bg); box-shadow: inset 3px 0 0 var(--role); }
.review.compact .opt-body p { font-size: 16px; margin: 0; }
.review.compact .facts { font-size: 14px; gap: 2px 16px; }
.review.compact .opt-actions { gap: 0 20px; }
.review.compact .opt-body .link { justify-self: start; font-size: 15px; padding: 4px 0; }
.role-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill-btn { font: inherit; font-size: 14px; font-weight: 800; padding: 4px 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--muted); }
.pill-btn.on { background: var(--role); border-color: transparent; color: #fff8ef; }

/* The move list: rows tall enough to tap. */
.review.compact .move-row { grid-template-columns: 44px 1fr 1fr; }
.review.compact .move { padding: 8px 10px; font-size: 16px; }
.review.compact .move-no { font-size: 14px; padding-top: 9px; }
.review.compact .keys { display: none; }

/* A short landscape window: the board on the left at full height with the vertical eval bar. */
.review.compact.land {
  grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "board top" "board panel" "board controls";
  padding-top: max(4px, env(safe-area-inset-top)); padding-left: max(4px, env(safe-area-inset-left));
}
.review.compact.land .board-wrap { grid-area: board; grid-template-columns: 8px var(--board); gap: 4px; align-self: start; margin-right: 8px; }
.review.compact.land .evalbar-label { display: none; }
.review.compact.land .side-col, .review.compact.land .player.top, .review.compact.land .controls { border-left: 1px solid var(--line); }
.review.compact.land .controls .icon-btn { height: 44px; }

/* ---------- phones: the home scrolls as one page (a list scrolling inside a card was a
   few rows high once the browser's own bars took their share of the screen) */
@media (max-width: 760px) {
  body:has(#app.home) .topbar { padding: max(12px, env(safe-area-inset-top)) 16px 4px; }
  #app.home { display: flex; flex-direction: column; gap: 12px; padding: 4px 12px 16px; }
  #app.home .hero { padding: 0; }
  #app.home .hero h1 { font-size: 25px; }
  #app.home .hero p { margin: 4px 0 0; font-size: 15px; }
  #app.home .how-details { padding: 10px 14px; border-radius: 14px; }
  #app.home .how-details summary { cursor: pointer; font-weight: 700; color: var(--muted); font-size: 15px; }
  #app.home .how-details .how-grid { margin-top: 10px; }
  #app.home .how p { font-size: 15px; }
  #app.home .games-card { padding: 12px; }
  #app.home .games-card .chips { margin: 10px 0 8px; }
  #app.home .games-card .chips.sources { margin: 0 0 10px; }
  /* The time controls stay on one line and scroll sideways if they must. */
  #app.home .games-card .chips:not(.sources) { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-right: -12px; padding-right: 12px; }
  #app.home .chip { flex: none; font-size: 14px; padding: 7px 14px; }
  /* A game: the result, its title on the whole width, the accuracy on a line of its own. */
  #app.home .game-row { grid-template-columns: 34px minmax(0, 1fr); gap: 4px 12px; padding: 12px; }
  #app.home .result-badge { width: 34px; height: 34px; }
  #app.home .game-side { grid-column: 2; display: flex; align-items: center; gap: 10px; }
  #app.home .game-side .tag { margin: 0; }
  #app.home .demo-title { display: block; font-size: 15px; }
  #app.home .demo-title .tag { margin-right: 6px; }
  #app.home .game-title { font-size: 15px; }
  #app.home .game-sub { font-size: 13px; }
  #app.home .pgn-card { margin: 0; padding: 12px 14px; border-radius: 14px; }
  body:has(#app.home) .site-footer { padding: 0 16px max(16px, env(safe-area-inset-bottom)); font-size: 13px; }
  /* Under 16px, iOS zooms into a field when it gets the focus. */
  .input, textarea.input.pgn { font-size: 16px; }
}

