/* Chess Game Review — Road of Knowledge (v20261010g) */
:root, [data-theme="dark"] {
  --bg: #161512; --panel: #262421; --panel-2: #302e2c; --text: #bababa; --bright: #f0f0f0;
  --muted: #8a877f; --accent: #629924; --border: #3c3935; --topbar-bg: #21201d; --topbar-border: #3c3935;
  --input-bg: #1b1a18; --btn-border: #4a4742; --btn-hover: #3a3834;
  --c-inaccuracy: #56b4e9; --c-mistake: #e69f00; --c-blunder: #df5353; --c-best: #629924; --c-alt: #3d8fd6;
  --sel: rgba(98,153,36,.35);
  --graph-bg: #3a3835; --graph-white: #dcdcdc;
  --sq-light: #f0d9b5; --sq-dark: #b58863;
  font-family: "Noto Sans", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #eceae3; --panel: #ffffff; --panel-2: #f3f1ea; --text: #3c3934; --bright: #1a1917;
  --muted: #74716a; --accent: #5a8a1a; --border: #d5d2c8; --topbar-bg: #f7f5ef; --topbar-border: #d5d2c8;
  --input-bg: #f7f5ef; --btn-border: #c8c4b8; --btn-hover: #e7e4da;
  --c-inaccuracy: #2f8fc4; --c-mistake: #d08a00; --c-blunder: #d23f3f; --c-best: #4f8a12; --c-alt: #2a78c0;
  --sel: rgba(90,138,26,.25);
  --graph-bg: #5a5853; --graph-white: #f4f4f4;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
code { font-size: .92em; }
.app { min-height: 100vh; display: flex; flex-direction: column; }

/* Top bar (same look as /chess/analysis/) */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 14px;
  background: var(--topbar-bg); border-bottom: 1px solid var(--topbar-border); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand h1 { margin: 0; font-size: 18px; color: var(--bright); font-weight: 700; letter-spacing: .02em; }
.tag { margin: 0; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.knight { font-size: 28px; line-height: 1; color: var(--accent); }
.top-actions { display: flex; align-items: center; gap: 8px; }

.btn { background: var(--panel-2); border: 1px solid var(--btn-border); color: var(--bright);
  border-radius: 4px; padding: 6px 10px; cursor: pointer; text-decoration: none; display: inline-flex;
  align-items: center; justify-content: center; gap: 4px; font-size: 14px; touch-action: manipulation; }
.btn:hover { background: var(--btn-hover); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: #3d5c16; border-color: #5a8a22; color: #fff; }
.btn.primary:hover:not(:disabled) { background: #4a701c; }
[data-theme="light"] .btn.primary { background: #5a8a1a; border-color: #4a7a12; }
.btn.big { padding: 10px 22px; font-size: 16px; font-weight: 600; }
.btn-icon { font-size: 17px; line-height: 1; min-width: 36px; padding: 5px 8px; }
.row { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.row.center { justify-content: center; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; }
.card h2 { margin: 0 0 6px; font-size: 16px; color: var(--bright); }

/* Load screen */
.load-view { width: 100%; max-width: 820px; margin: 0 auto; padding: 18px 16px 24px; display: flex; flex-direction: column; gap: 14px; }
textarea { width: 100%; background: var(--input-bg); border: 1px solid var(--border); border-radius: 6px;
  padding: 8px; resize: vertical; color: var(--bright); font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
select { background: var(--panel-2); border: 1px solid var(--btn-border); border-radius: 4px; padding: 5px 6px; color: var(--bright); max-width: 100%; }
.field { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; font-size: 13px; color: var(--muted); }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0 14px; margin-top: 4px; }
.error { margin-top: 10px; padding: 8px 10px; border-radius: 6px; background: rgba(223,83,83,.14); border: 1px solid rgba(223,83,83,.5); color: var(--bright); font-size: 13.5px; white-space: pre-wrap; }
.preview { margin-top: 10px; padding: 8px 10px; border-radius: 6px; background: var(--panel-2); font-size: 13.5px; color: var(--bright); }
.about p { margin: 0 0 8px; line-height: 1.55; font-size: 14px; }
.file-btn { position: relative; }

/* Progress */
.progress-view { width: 100%; max-width: 620px; margin: 0 auto; padding: 28px 16px; }
.progress-title { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; color: var(--bright); margin-bottom: 10px; flex-wrap: wrap; }
.progress-bar { height: 12px; border-radius: 6px; background: var(--panel-2); overflow: hidden; border: 1px solid var(--border); }
#progress-fill { height: 100%; width: 0; background: var(--accent); transition: width .25s ease; }

/* Review layout */
.layout { display: grid; grid-template-columns: minmax(0, auto) minmax(320px, 1fr); gap: 16px; padding: 16px 18px 24px;
  width: 100%; max-width: 1240px; margin: 0 auto; align-items: start; }
.col-board { width: var(--board-w); --board-w: min(calc(100vh - 210px), calc(100vw - 460px), 640px); }
.col-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.board-wrap { display: flex; gap: 6px; align-items: stretch; }
.board-box { position: relative; flex: 1; min-width: 0; }
#board { width: 100%; }
.arrows { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.eval-bar { width: 18px; flex: 0 0 18px; border-radius: 3px; background: #403d39; position: relative; overflow: hidden; }
.eval-fill { position: absolute; left: 0; right: 0; bottom: 0; height: 50%; background: #e8e8e8; transition: height .25s ease; }
.eval-bar.flipped .eval-fill { bottom: auto; top: 0; }
.eval-num { position: absolute; left: 0; right: 0; text-align: center; font-size: 9px; font-weight: 700; color: #777; bottom: 2px; }
.eval-num.top { bottom: auto; top: 2px; color: #ccc; }
.players-top, .players-bottom { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; color: var(--bright);
  padding: 4px 2px 4px 24px; min-height: 26px; }
.players-top .acc, .players-bottom .acc { color: var(--muted); font-size: 12.5px; }
.nav-row { display: flex; gap: 6px; margin-top: 8px; }
.nav-row .btn { flex: 1; }
.btn.nav { font-size: 16px; padding: 6px 4px; }
.arrow-opt { display: block; margin-top: 8px; line-height: 1.5; }
.c-best { color: var(--c-best); font-weight: 600; }
.c-alt { color: var(--c-alt); font-weight: 600; }
.c-inaccuracy { color: var(--c-inaccuracy); }
.c-mistake { color: var(--c-mistake); }
.c-blunder { color: var(--c-blunder); }

/* Board square colors + highlights */
#live-board .white-1e1d7,
#board .white-1e1d7 { background-color: var(--sq-light); color: var(--sq-dark); }
#live-board .black-3c85d,
#board .black-3c85d { background-color: var(--sq-dark); color: var(--sq-light); }
#live-board .hl-last,
#board .hl-last { box-shadow: inset 0 0 0 999px rgba(155,199,0,.41); }
#board .hl-inaccuracy { box-shadow: inset 0 0 0 999px rgba(86,180,233,.45); }
#board .hl-mistake { box-shadow: inset 0 0 0 999px rgba(230,159,0,.45); }
#board .hl-blunder { box-shadow: inset 0 0 0 999px rgba(223,83,83,.5); }
#board .board-b72b1, #live-board .board-b72b1 { border: 0; }
#live-board { width: 100%; }

/* Detail card */
.detail { min-height: 92px; }
.detail .d-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: 15px; color: var(--bright); }
.detail .d-move { font-weight: 700; font-size: 17px; }
.detail .badge { font-size: 12px; font-weight: 700; padding: 2px 7px; border-radius: 10px; color: #fff; }
.badge.inaccuracy { background: var(--c-inaccuracy); }
.badge.mistake { background: var(--c-mistake); }
.badge.blunder { background: var(--c-blunder); }
.badge.best { background: var(--c-best); }
.badge.good { background: #6f6d68; }
.detail .d-line { margin-top: 6px; font-size: 14px; line-height: 1.5; }
.detail .pv { font-family: ui-monospace, Consolas, monospace; font-size: 13px; color: var(--text); word-break: break-word; }
.detail b.ev { color: var(--bright); }
.detail .why { color: var(--muted); font-size: 13px; }

/* Graph */
.graph-card { padding: 8px; }
.graph { width: 100%; height: 150px; display: block; cursor: pointer; border-radius: 4px; background: var(--graph-bg); touch-action: manipulation; }
.graph-tip { margin-top: 4px; min-height: 17px; }

/* Summary */
.summary table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.summary th, .summary td { padding: 4px 6px; text-align: center; }
.summary th:first-child, .summary td:first-child { text-align: left; }
.summary thead th { color: var(--muted); font-weight: 600; font-size: 12px; border-bottom: 1px solid var(--border); }
.summary tbody td { color: var(--bright); }
.summary .pname { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.summary .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 1px solid #888; margin-right: 6px; vertical-align: -1px; }
.summary .dot.w { background: #fff; } .summary .dot.b { background: #222; }
.summary tr.dim td { opacity: .45; }
.summary .clickable { cursor: pointer; text-decoration: underline dotted; }
.summary .meta { margin-top: 6px; font-size: 12px; color: var(--muted); }

/* Move list */
.moves-card { padding: 4px 0; }
.moves { max-height: 360px; overflow-y: auto; font-size: 14px; }
.mrow { display: grid; grid-template-columns: 42px 1fr 1fr; align-items: stretch; }
.mrow:nth-child(odd) { background: rgba(128,128,128,.05); }
.mnum { color: var(--muted); padding: 4px 6px; text-align: right; font-size: 12.5px; align-self: center; }
.mv { padding: 4px 8px; cursor: pointer; display: flex; justify-content: space-between; gap: 6px; align-items: baseline; border-radius: 3px; color: var(--bright); }
.mv:hover { background: rgba(128,128,128,.15); }
.mv.cur { background: var(--sel); }
.mv .san { font-weight: 600; }
.mv .sym { font-weight: 900; margin-left: 1px; font-size: 1.08em; letter-spacing: .02em; }
.mv > span:first-child { white-space: nowrap; }
.mv .ev { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.mv.inaccuracy .san, .mv.inaccuracy .sym { color: var(--c-inaccuracy); }
.mv.mistake .san, .mv.mistake .sym { color: var(--c-mistake); }
.mv.blunder .san, .mv.blunder .sym { color: var(--c-blunder); }
.mv.best .sym { color: var(--c-best); }
.mv.dim .san { font-weight: 500; }
.mv.empty { cursor: default; }
.mres { text-align: center; padding: 6px; color: var(--muted); font-weight: 600; }

.seo-about { max-width: 1180px; width: 100%; margin: auto auto 0; padding: 14px 18px 22px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12.5px; line-height: 1.6; }
.seo-about h2 { margin: 0 0 4px; font-size: 13px; font-weight: 600; }
.seo-about p { margin: 0; max-width: 920px; }

/* Site hamburger menu (same as other chess pages) */
.site-menu-btn { appearance: none; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 32px; padding: 0;
  border-radius: 6px; cursor: pointer; flex-shrink: 0; border: 1px solid var(--topbar-border); background: rgba(128,128,128,.08); color: var(--bright); touch-action: manipulation; }
.site-menu-btn:hover { border-color: var(--accent); background: rgba(98,153,36,.14); }
.site-menu-btn[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
.site-menu { position: fixed; inset: 0; z-index: 200; pointer-events: none; }
.site-menu.is-open { pointer-events: auto; }
.site-menu[hidden] { display: none !important; }
.site-menu-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.5); opacity: 0; transition: opacity .18s ease; }
.site-menu.is-open .site-menu-backdrop { opacity: 1; }
.site-menu-panel { position: absolute; top: 0; right: 0; width: min(300px, 88vw); height: 100%; max-height: 100dvh; overflow-y: auto;
  display: flex; flex-direction: column; gap: .15rem; padding: .9rem .7rem 1.4rem; background: var(--topbar-bg); border-left: 1px solid var(--topbar-border);
  box-shadow: -12px 0 32px rgba(0,0,0,.45); transform: translateX(100%); transition: transform .2s ease; color: var(--bright); }
.site-menu.is-open .site-menu-panel { transform: none; }
.site-menu-section { margin: .75rem .5rem .3rem; padding-top: .5rem; border-top: 1px solid var(--topbar-border); color: var(--muted);
  font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.site-menu-link { display: block; padding: .65rem .8rem; border-radius: 8px; color: var(--bright); font-weight: 600; font-size: .95rem; text-decoration: none; line-height: 1.25; }
.site-menu-link:hover { background: rgba(128,128,128,.12); }
.site-menu-link.is-current, .site-menu-link[aria-current="page"] { background: rgba(98,153,36,.18); color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
html.site-menu-open { overflow: hidden; }

/* Mobile */
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 10px 8px 18px; gap: 10px; }
  .col-board { width: 100%; --board-w: 100%; max-width: 560px; margin: 0 auto; }
  .moves { max-height: 300px; }
  .col-side { order: 2; }
}
@media (max-width: 520px) {
  .topbar { padding: 6px 8px; gap: 6px; }
  .brand h1 { font-size: 16px; }
  .knight { font-size: 24px; }
  .site-menu-btn { width: 32px; height: 30px; }
  .btn { font-size: 13px; padding: 6px 8px; }
  .eval-bar { width: 12px; flex-basis: 12px; }
  .players-top, .players-bottom { padding-left: 18px; }
  .summary .pname { max-width: 90px; }
  .load-view { padding: 10px 8px 18px; }
}

/* Live board while analyzing (v20261010c) */
.progress-view { display: flex; flex-direction: column; gap: 12px; padding-top: 16px; }
.live-card { width: 100%; max-width: min(100%, calc(60vh + 40px), 520px); margin: 0 auto; padding: 10px; }
.live-label { font-size: 15px; font-weight: 700; color: var(--bright); margin: 0 0 8px 24px; min-height: 20px; }
.live-info { margin: 6px 0 0 24px; min-height: 17px; font-variant-numeric: tabular-nums; }
@media (max-width: 520px) {
  .progress-view { padding: 10px 8px; }
  .live-label, .live-info { margin-left: 18px; }
}

/* Best-move marks (v20261010d) */
.mv .star { color: var(--c-best); font-size: .72em; margin-left: 3px; opacity: .85; vertical-align: 1px; }
.summary td.c-best { font-weight: 600; }
.summary .pct { color: var(--muted); font-weight: 400; font-size: 12px; }

/* Loss columns (v20261010e) */
.summary thead th { line-height: 1.15; vertical-align: bottom; cursor: help; }
.summary thead th:first-child { cursor: default; }
.summary .sub { font-weight: 400; font-size: 11px; }

/* Navigation bar + batch review (v20261010f) */
.review-bar { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.review-title { color: var(--muted); font-size: 13.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.batch-pick { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 10px; }
.batch-head { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.batch-tools { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
.batch-tools input { flex: 1 1 180px; min-width: 0; background: var(--input-bg); border: 1px solid var(--border); border-radius: 4px; padding: 6px 8px; color: var(--bright); }
.batch-list { max-height: 300px; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; background: var(--input-bg); }
.bitem { display: flex; gap: 8px; align-items: flex-start; padding: 6px 8px; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 13.5px; color: var(--bright); }
.bitem:last-child { border-bottom: 0; }
.bitem:hover { background: rgba(128,128,128,.1); }
.bitem input { margin-top: 3px; flex: 0 0 auto; }
.bnum { color: var(--muted); min-width: 26px; text-align: right; }
.bmain { display: flex; flex-direction: column; min-width: 0; }
.bres { color: var(--muted); font-weight: 600; margin-left: 4px; }
.bsub { color: var(--muted); font-size: 12px; }
.batch-view { width: 100%; max-width: 1240px; margin: 0 auto; padding: 16px 18px 24px; display: flex; flex-direction: column; gap: 12px; }
.batch-player-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 10px 0; font-size: 14px; }
.batch-player-row label { color: var(--muted); }
.batch-score { color: var(--bright); }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.btable { width: 100%; border-collapse: collapse; font-size: 13.5px; white-space: nowrap; }
.btable th, .btable td { padding: 5px 7px; text-align: center; border-bottom: 1px solid var(--border); }
.btable th { color: var(--muted); font-weight: 600; font-size: 12px; line-height: 1.15; vertical-align: bottom; }
.btable .sub { font-weight: 400; font-size: 11px; }
.btable td { color: var(--bright); }
.btable .rowname { text-align: left; max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
.btable .pct { color: var(--muted); font-size: 11.5px; font-weight: 400; }
.btable tr.hl td { background: var(--sel); font-weight: 600; }
.btable tr.sub-row td { color: var(--text); font-size: 13px; }
.btable tr.total td { border-top: 2px solid var(--border); }
.btable.clickable tbody tr { cursor: pointer; }
.btable.clickable tbody tr:hover td { background: rgba(128,128,128,.12); }
.btable .res-W { color: var(--c-best); font-weight: 700; }
.btable .res-L { color: var(--c-blunder); font-weight: 700; }
.btable .res-D { color: var(--muted); font-weight: 700; }
.btable .ev-cell { max-width: 180px; overflow: hidden; text-overflow: ellipsis; text-align: left; }
@media (max-width: 520px) {
  .batch-view { padding: 10px 8px 18px; }
  .btable { font-size: 12.5px; }
  .btable th, .btable td { padding: 4px 5px; }
}
.bline { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
