:root {
  color-scheme: light dark;
  --bg: #f6f5f1;
  --fg: #1d1c1a;
  --muted: #6b675f;
  --line: #d9d5cc;
  --accent: #1f6f5c;
  --warn: #9a5b00;
  --bad: #a3312a;
  --light: #f0d9b5;
  --dark: #b58863;
  --lit: rgba(155, 199, 0, 0.45);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #161615; --fg: #ecebe6; --muted: #a29e95; --line: #34322e; --accent: #5cc2a6; --warn: #e2a64b; --bad: #ef7a72; }
}
* { box-sizing: border-box; }
/* A scrollbar appearing must not resize the player mid-game. */
html { scrollbar-gutter: stable; }
[hidden] { display: none !important; }
body { margin: 0; padding: 16px; background: var(--bg); color: var(--fg); font: 15px/1.5 system-ui, sans-serif; }
h1 { font-size: 1.3rem; margin: 0; }
h2 { font-size: 1rem; margin: 12px 0 6px; }
.note, .hint { color: var(--muted); }
.note { margin: 4px 0 16px; }
.hint { font-size: 0.9rem; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.row > label[for] { width: 100%; color: var(--muted); }
input, select { padding: 6px 8px; font: inherit; border: 1px solid var(--line); border-radius: 6px; background: transparent; color: inherit; min-width: 0; }
input#video { flex: 1 1 320px; }
input#fen { flex: 1 1 100%; }
button { padding: 6px 14px; font: inherit; border: 1px solid var(--accent); border-radius: 6px; background: var(--accent); color: #fff; cursor: pointer; }
button:disabled { opacity: 0.45; cursor: default; }
button.secondary { background: transparent; color: var(--accent); }
.inline { color: var(--muted); font-size: 0.9rem; display: inline-flex; gap: 6px; align-items: center; }
main { display: grid; grid-template-columns: minmax(320px, 2fr) minmax(0, 3fr); gap: 24px; }
@media (max-width: 900px) { main { grid-template-columns: 1fr; } }
.player-slot { aspect-ratio: 16 / 9; max-width: 100%; border: 1px solid var(--line); border-radius: 6px; display: grid; place-items: center; }
.player-slot iframe { width: 100%; height: 100%; border: 0; isolation: isolate; transform-style: flat; }
.empty { color: var(--muted); }
.steps { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 8px; }
.select canvas { width: 100%; max-width: 640px; height: auto; display: block; cursor: crosshair; touch-action: none; border-radius: 4px; background: #000; }
.board3d { width: 100%; border-radius: 8px; overflow: hidden; background: #1d2622; }
.board3d canvas { display: block; touch-action: none; }
.board { display: grid; grid-template-columns: repeat(8, 1fr); width: 100%; max-width: 420px; aspect-ratio: 1; border-radius: 4px; overflow: hidden; }
.sq { display: grid; place-items: center; font-size: clamp(18px, 4.2vw, 40px); line-height: 1; user-select: none; }
.sq.light { background: var(--light); }
.sq.dark { background: var(--dark); }
.sq.lit { box-shadow: inset 0 0 0 999px var(--lit); }
.sq[data-piece="w"] { color: #fff; text-shadow: 0 0 2px #000, 0 0 1px #000; }
.sq[data-piece="b"] { color: #111; }
.status { min-height: 1.5em; margin: 8px 0; }
.status.warn { color: var(--warn); }
.status.bad { color: var(--bad); }
.ask { border: 1px solid var(--warn); border-radius: 6px; padding: 10px; display: grid; gap: 8px; }
.ask .row { margin: 0; }
.moves { max-height: 240px; overflow-y: auto; columns: 2; padding-left: 1.6em; margin: 0; font-variant-numeric: tabular-nums; font-family: ui-monospace, monospace; }
.moves li.resync { color: var(--warn); }
