/* Layout: one centered column for search/list pages, board + side panel for review.
   Palette: neutral greys tinted toward the felt-green accent; class colours are semantic. */
:root {
  --bg: #f4f5f2;
  --surface: #ffffff;
  --surface-2: #eceeea;
  --line: #dde0da;
  --text: #1c211e;
  --muted: #5f6862;
  --accent: #2f6b4f;
  --accent-soft: #e1ece5;
  --on-accent: #ffffff;
  --graph-bg: #3a3f3c;
  --graph-fill: #f1f2ef;
  --shadow: 0 1px 2px rgba(20, 30, 25, 0.06), 0 4px 16px rgba(20, 30, 25, 0.06);
  --sq-l: #ebe6db;
  --sq-d: #8fa08c;
  --win: #4f9a45;
  --loss: #c9413b;
  --draw: #8c958f;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  /* corner system: panels 12, controls 8, small parts 6 */
  --radius: 12px;
  --r-ctl: 8px;
  --r-sm: 6px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: var(--font-body); font-size: 15px; line-height: 1.5;
  min-height: 100vh; display: flex; flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { letter-spacing: -0.01em; text-wrap: balance; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.row { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.row.center { justify-content: center; }
.err { color: var(--loss); font-size: 13px; }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px max(24px, env(safe-area-inset-right, 0px)) 12px max(24px, env(safe-area-inset-left, 0px));
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 18px; }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: var(--r-ctl); font-size: 18px; background: var(--accent); color: var(--on-accent); }
.topbar-tag { color: var(--muted); font-size: 13px; }
.page { flex: 1; width: 100%; max-width: 1240px; margin: 0 auto; padding: 18px max(24px, env(safe-area-inset-right, 0px)) 24px max(24px, env(safe-area-inset-left, 0px)); }
.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 12px 16px 14px; border-top: 1px solid var(--line); }

/* buttons & inputs */
.btn {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  border: none; background: var(--surface-2); color: var(--text);
  padding: 8px 14px; border-radius: var(--r-ctl); cursor: pointer; font-weight: 600; font-size: 14px;
  transition: background .12s ease;
}
@media (hover: hover) { .btn:hover { background: var(--line); text-decoration: none; } .btn.icon:hover { background: var(--line); } }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; padding-left: 4px; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--surface-2); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.icon { flex: 1; height: 46px; justify-content: center; padding: 0; font-size: 15px; border-radius: 0; background: transparent; color: var(--text); -webkit-tap-highlight-color: transparent; }
.btn.icon svg { width: 22px; height: 22px; display: block; }
.btn.icon:active { background: var(--line); }
.btn.icon.wide { flex: 1.6; font-size: 13px; color: var(--muted); }
.btn.icon.active { color: var(--accent); }
.link-btn { background: none; border: none; color: var(--muted); cursor: pointer; margin-top: 14px; padding: 0; text-decoration: underline; text-underline-offset: 3px; }
.link-btn:hover { color: var(--text); }
.chip { border: none; border-bottom: 2px solid transparent; background: none; padding: 6px 2px; margin: 0 6px; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--muted); }
.chip:hover { color: var(--text); }
.chip.active { color: var(--text); border-bottom-color: var(--accent); }
.select { background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: var(--r-ctl); padding: 8px 10px; font: inherit; font-weight: 600; cursor: pointer; }
.select.sm { padding: 5px 8px; font-size: 13px; }

/* home */
/* home: intro + search on the left, a sample review on the right */
.home-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 400px); gap: 56px; align-items: center; max-width: 1080px; margin: 0 auto; padding: 16px 0 24px; }
.hero { min-width: 0; }
.sample { display: flex; flex-direction: column; gap: 10px; min-width: 0; touch-action: pan-y; user-select: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
/* switching games: the new card slides in from the side you moved towards, parts staggered */
.sample-body { display: flex; flex-direction: column; gap: 8px; --from: 28px; }
.sample-body.from-left { --from: -28px; }
.sample-body > * { animation: sample-in .55s cubic-bezier(.22, .8, .24, 1) both; }
.sample-body > :nth-child(2) { animation-delay: .04s; }
.sample-body > :nth-child(3) { animation-delay: .08s; }
.sample-body > :nth-child(4) { animation-delay: .12s; }
.sample-body > :nth-child(n+5) { animation-delay: .16s; }
@keyframes sample-in { from { opacity: 0; transform: translateX(var(--from)); } to { opacity: 1; transform: none; } }
/* moves: the piece glides from its origin square */
.slide { animation: piece-slide .42s cubic-bezier(.3, .7, .3, 1) both; }
@keyframes piece-slide { from { transform: translate(var(--dx), var(--dy)); } to { transform: none; } }
.sample.instant .sample-body > *, .sample.instant .slide, .sample.instant .sample-note { animation: none; transition: none; }
@media (prefers-reduced-motion: reduce) { .sample-body > *, .slide { animation: none; } }
.sample-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 12.5px; margin-bottom: 2px; }
.sample-place { text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sample-tag { font-weight: 700; text-transform: uppercase; letter-spacing: .06em; font-size: 12px; color: var(--accent); flex: none; }
.sample-player { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; }
.sample .board { box-shadow: none; }
.sample-moves { margin-top: 2px; }
.sample-moves .mv { cursor: default; }
.sample-note { margin: 0; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0; transition: opacity .3s; }
.sample-note.shown { opacity: 1; }
.sample-dots { display: flex; justify-content: center; gap: 2px; flex-wrap: wrap; }
.dot-btn { width: 22px; height: 22px; border: none; background: none; padding: 0; cursor: pointer; display: grid; place-items: center; }
.dot-btn::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--line); transition: background .2s, transform .2s; }
.dot-btn:hover::before { background: var(--muted); }
.dot-btn.active::before { background: var(--accent); transform: scale(1.25); }
.hero h1 { font-size: clamp(30px, 4.6vw, 44px); line-height: 1.1; margin: 0 0 12px; font-weight: 700; }
.sub { color: var(--muted); font-size: 16.5px; margin: 0 0 26px; max-width: 58ch; }
.search { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 6px 6px 14px; }
.search:focus-within { border-color: var(--accent); }
.search-icon { color: var(--muted); font-weight: 600; }
.search input { flex: 1; min-width: 0; background: transparent; border: none; outline: none; color: var(--text); font: inherit; font-size: 16px; padding: 8px 2px; }
.search .btn { padding: 10px 18px; }
.hint { color: var(--loss); font-size: 13px; margin: 8px 2px 0; display: none; }
.hint.show { display: block; }
.pgn-box { margin-top: 12px; }
.pgn-box textarea { width: 100%; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; resize: vertical; margin-bottom: 8px; }
.pgn-box textarea:focus { outline: none; border-color: var(--accent); }
.legend { max-width: 1080px; margin: 0 auto 8px; padding-top: 18px; border-top: 1px solid var(--line); }
.legend h2 { font-size: 18px; margin: 0 0 4px; }
.legend > p { margin: 0 0 14px; font-size: 14px; }
.legend-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 28px; }
.legend-list li { display: grid; grid-template-columns: 22px auto 1fr; align-items: center; gap: 10px; font-size: 13.5px; }
.legend-list b { font-weight: 600; }
.lg-ico, .mico, .cico, .c-ico { display: block; flex: none; }
.lg-ico { width: 22px; height: 22px; }

/* games */
.games-page { max-width: 860px; margin: 0 auto; }
.profile-row { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.profile { display: flex; align-items: center; gap: 12px; }
.avatar { width: 48px; height: 48px; border-radius: var(--radius); object-fit: cover; background: var(--surface-2); }
.avatar.ph { display: grid; place-items: center; font-weight: 700; font-size: 20px; background: var(--accent-soft); color: var(--accent); }
.p-name { font-size: 22px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.title-tag { background: var(--loss); color: #fff; font-size: 12px; padding: 1px 6px; border-radius: var(--r-sm); }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.count { margin: 4px 2px 8px; }
.list { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.game-head, .game {
  display: grid; grid-template-columns: 86px minmax(0, 1fr) 22px 34px 56px 104px; gap: 12px; align-items: center;
}
.game-head { padding: 8px 16px; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); }
.game-head .c { text-align: center; } .game-head .r { text-align: right; }
.game {
  text-align: left; background: transparent; border: none; border-top: 1px solid var(--line);
  padding: 10px 16px; cursor: pointer; width: 100%; color: var(--text);
}
.game:not(:disabled):hover { background: var(--surface-2); }
.game:disabled { opacity: .5; cursor: default; }
.game.skeleton { height: 62px; cursor: default; background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.3s infinite linear; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.g-tc { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.g-tc-ico { width: 20px; height: 20px; flex: none; }
.g-tc-ico svg { width: 100%; height: 100%; display: block; }
.g-players, .g-scores { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.g-pl { display: flex; align-items: center; gap: 7px; white-space: nowrap; min-width: 0; font-size: 14px; }
.g-name { overflow: hidden; text-overflow: ellipsis; }
.g-pl.me .g-name { font-weight: 700; }
/* colour swatch for a side: .sq in the game list, .dot on accuracy cards */
.sq, .dot { width: 11px; height: 11px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px var(--muted); }
.sq.white, .dot.white { background: #f5f5f2; }
.sq.black, .dot.black { background: #2b2b2b; }
.rt { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.g-scores { align-items: center; font-weight: 700; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.g-res { width: 22px; height: 22px; border-radius: var(--r-sm); display: grid; place-items: center; font-weight: 800; font-size: 15px; line-height: 1; color: #fff; justify-self: center; }
.g-res.win { background: var(--win); }
.g-res.loss { background: var(--loss); }
.g-res.draw { background: var(--draw); }
.g-moves { text-align: center; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13.5px; }
.g-date { text-align: right; font-size: 13px; color: var(--muted); white-space: nowrap; }
.g-note { font-size: 12px; color: var(--muted); }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty p { margin: 8px 0 18px; font-size: 16px; }
.empty-ico { font-size: 48px; color: var(--muted); }

/* loading */
.loading-page { display: flex; flex-direction: column; align-items: center; padding: 80px 0; gap: 12px; }
.spinner { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; display: inline-block; }
.spinner.sm { width: 15px; height: 15px; border-width: 2px; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner, .game.skeleton { animation: none; } }

/* review */
.review-head { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.rh-title { flex: 1; min-width: 220px; }
.rh-title h2 { margin: 0; font-size: 21px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.result-tag { font-size: 12.5px; background: var(--surface-2); padding: 1px 7px; border-radius: var(--r-sm); color: var(--muted); }
.opening { font-size: 13px; color: var(--text); margin-top: 2px; }
.opening-now { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13.5px; font-weight: 600; color: var(--muted); padding: 0 2px; }
.opening-now img { flex: none; }
.opening-now span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rh-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.progress { position: relative; height: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-ctl); overflow: hidden; margin-bottom: 14px; }
.progress .bar { position: absolute; inset: 0 auto 0 0; background: var(--accent-soft); transition: width .25s ease; }
.ptext { position: relative; font-size: 12.5px; line-height: 22px; padding: 0 10px; font-variant-numeric: tabular-nums; }
.engine-err { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 12px; margin: -6px 0 14px; border: 1px solid var(--loss); border-radius: var(--r-ctl); color: var(--loss); font-size: 14px; }

.review { max-width: 1120px; margin: 0 auto; }
.review-grid { display: grid; grid-template-columns: minmax(0, 1fr) 370px; gap: 28px; align-items: start; }
.board-col { display: flex; flex-direction: column; gap: 6px; max-width: min(720px, max(340px, calc(100vh - 290px))); width: 100%; min-width: 0; }
.pname { font-weight: 600; font-size: 14px; padding-left: 34px; }
.board-wrap { display: flex; gap: 10px; }
.board { flex: 1; aspect-ratio: 1; max-width: 100%; border-radius: var(--r-sm); overflow: hidden; min-width: 0; }
.board-svg { display: block; width: 100%; height: 100%; }
.sq-l { fill: var(--sq-l); }
.sq-d { fill: var(--sq-d); }
.sq-last { fill: rgba(240, 200, 80, 0.45); }
.sq-check { fill: rgba(220, 60, 50, 0.55); }
.coord { font-size: 9.5px; font-weight: 700; font-family: var(--font-body); }
.c-l { fill: var(--sq-l); }
.c-d { fill: var(--sq-d); }
.arrow { stroke: #4f9a45; stroke-width: 5; stroke-linecap: round; opacity: .75; }

/* White's share fills from White's side (bottom, or top when flipped).
   The score label sits at the end of whichever side is ahead. */
.evalbar { --eb-dark: #333836; --eb-light: #f3f3f0; position: relative; width: 24px; flex: none; border-radius: var(--r-sm); overflow: hidden; background: var(--eb-dark); display: flex; flex-direction: column-reverse; border: 1px solid var(--line); }
.evalbar.white-top { flex-direction: column; }
.eb-white { background: var(--eb-light); transition: height .35s ease; width: 100%; }
.eb-label { position: absolute; left: 0; right: 0; text-align: center; font-size: 10px; font-weight: 700; overflow: hidden; letter-spacing: -0.04em; color: var(--eb-light); top: 5px; }
.evalbar.white-ahead .eb-label { color: var(--eb-dark); top: auto; bottom: 5px; }
.evalbar.white-top .eb-label { top: auto; bottom: 5px; }
.evalbar.white-top.white-ahead .eb-label { bottom: auto; top: 5px; }
.controls { display: flex; margin: 4px 0 0 34px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-ctl); overflow: hidden; }

.panel { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.comment {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; min-height: 56px;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line);
}
.c-ico { flex: none; width: 30px; height: 30px; }
.c-text { flex: 1; font-weight: 600; }
.c-text b { color: color-mix(in srgb, var(--c) 82%, #000); }
.c-eval { font-weight: 700; font-size: 13px; background: var(--surface-2); padding: 2px 8px; border-radius: var(--r-sm); }
.graph { padding: 0; overflow: hidden; cursor: pointer; }
.graph-inner { position: relative; height: 92px; }
.graph-body, .graph-svg { display: block; width: 100%; height: 100%; }
.g-bg { fill: var(--graph-bg); }
.g-white { fill: var(--graph-fill); }
.g-mid { stroke: #8c958f; stroke-width: 1; stroke-dasharray: 4 4; opacity: .7; vector-effect: non-scaling-stroke; }
.g-cur { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--accent); pointer-events: none; }
.g-dot { position: absolute; width: 8px; height: 8px; border-radius: 50%; transform: translate(-50%, -50%); border: 1.5px solid #fff; pointer-events: none; }

.movelist { position: relative; max-height: 280px; overflow-y: auto; padding: 4px; }
.mrow { display: grid; grid-template-columns: 36px 1fr 1fr; gap: 2px; align-items: center; }
.mrow:nth-child(odd) { background: var(--surface-2); border-radius: var(--r-sm); }
.mno { color: var(--muted); font-size: 12px; text-align: right; padding-right: 6px; font-variant-numeric: tabular-nums; }
.mv { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: var(--r-sm); border: none; background: transparent; cursor: pointer; font-weight: 500; font-size: 13.5px; text-align: left; min-width: 0; }
.mv:hover { background: var(--line); }

.mv.empty { cursor: default; color: var(--muted); }
.mico { flex: none; width: 18px; height: 18px; }
/* (current move overrides the class colour; see below) */
/* notable moves take their class colour (set as --c on the cell), darkened for contrast on white */
.mv:is([data-class="blunder"], [data-class="mistake"], [data-class="miss"], [data-class="brilliant"]) .san { color: color-mix(in srgb, var(--c) 78%, #000); font-weight: 700; }

.acc-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.acc { border-radius: var(--r-ctl); padding: 10px; text-align: center; }
.acc.white-side { box-shadow: inset 0 0 0 1px var(--line); background: #f7f7f4; color: #1c211e; }
.acc.white-side .rt, .acc.white-side .muted { color: #5f6862; }
.acc.black-side { background: #1d211f; color: #e5e8e5; }
.acc.black-side .rt, .acc.black-side .muted { color: #98a19b; }
.acc-name { display: flex; align-items: center; justify-content: center; gap: 6px; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc-num { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.counts { display: flex; flex-direction: column; max-width: 420px; margin: 0 auto; }
.crow { display: grid; grid-template-columns: 40px 1fr 40px; align-items: center; padding: 2px 0; }
.crow.zero { opacity: .55; }
.cnum { text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
/* fixed-width icon + name block, centred: icons line up in one column */
.cname { display: grid; grid-template-columns: 20px 92px; align-items: center; justify-content: center; column-gap: 10px; font-size: 13.5px; font-weight: 500; text-align: left; }
.cico { width: 20px; height: 20px; }

@media (max-width: 900px) {
  .home-top { grid-template-columns: 1fr; gap: 28px; padding-top: 28px; }
  .sample { max-width: 420px; width: 100%; margin: 0 auto; }
  .legend-list { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 980px) {
  .review-grid { grid-template-columns: 1fr; }
  .board-col { max-width: 640px; }
  .movelist { max-height: 240px; }
}
@media (max-width: 600px) {
  .page { padding: 14px max(16px, env(safe-area-inset-right, 0px)) 20px max(16px, env(safe-area-inset-left, 0px)); }
  .topbar { padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px)); }
  .topbar-tag { display: none; }
  .sub { font-size: 15px; }
  .search .btn { padding: 9px 12px; }
  .legend-list { grid-template-columns: 1fr; }
  .game-head, .game { grid-template-columns: 22px minmax(0, 1fr) 14px 24px 84px; gap: 8px; padding-left: 12px; padding-right: 12px; }
  .g-date { font-size: 12px; }
  .g-tc-txt, .g-moves, .game-head span:nth-child(5) { display: none; }
  .game-head span:first-child { visibility: hidden; }

  .pname { padding-left: 0; }
  .controls { margin-left: 0; }
  .btn.icon { height: 54px; }
  .btn.icon svg { width: 26px; height: 26px; }
  .board-wrap { gap: 6px; }
  .eb-label { font-size: 11px; letter-spacing: -0.06em; }
}
.lg-ico img, .mico img, .cico img, .c-ico img, .g-tc-ico img { display: block; width: 100%; height: 100%; }
.btn.more { display: block; margin: 12px auto 0; }

/* touch screens: comfortable tap targets */
@media (pointer: coarse) {
  .mv { min-height: 44px; }
  .btn.ghost, .select, .rh-tools .btn, .chip { min-height: 44px; }
}

/* Tablets upright and up: board and panel side by side. */
@media (min-width: 760px) and (max-width: 980px) {
  .review-grid { grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; }
  .board-col { max-width: none; }
}

/* Phones (and narrow windows): the move comment sits right above the board so both are visible together. */
@media (max-width: 759px) {
  .review-grid { display: flex; flex-direction: column; gap: 10px; }
  .panel { display: contents; }
  .opening-now { order: -2; }
  .comment { order: -1; min-height: 52px; padding: 10px 12px; }
  .board-col { order: 0; }
  .graph, .movelist, .summary { order: 1; }
  .rh-title h2 { font-size: 18px; }
}

/* Phones held sideways: fit the board to the screen height, panel beside it. */
@media (orientation: landscape) and (max-height: 520px) {
  .topbar { padding-top: 6px; padding-bottom: 6px; }
  .review-grid { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 16px; }
  .panel { display: flex; }
  .board-col { width: min(100%, calc(100svh - 90px)); max-width: none; }
  .pname { display: none; }
}

/* Very small phones: drop the date column so names fit. */
@media (max-width: 380px) {
  .game-head, .game { grid-template-columns: 22px minmax(0, 1fr) 14px 24px; }
  .g-date, .game-head span:last-child { display: none; }
}

/* current move: solid accent, text always readable (after the class-colour rule) */
.mv.current { background: var(--accent); color: var(--on-accent); }
.mv.current .san { color: var(--on-accent); }
.pgn-box textarea.invalid { border-color: var(--loss); }
