[hidden] { display: none !important; } /* the display rules below must not override the hidden attribute */
/* Layout: board as the hero on the left, a narrow control rail on the right; stacks on phones. Palette drawn from Horezu pottery: slip, cobalt, ochre, glaze green. */
:root {
  --bg: #eceef0;
  --surface: #f8f8f6;
  --fg: #1c2230;
  --muted: #5b6373;
  --line: #d3d7de;
  --accent: #2b4f9e;        /* cobalt */
  --ochre: #c18a25;         /* decoration only (band): 2.85:1 on --surface, never text or a focus ring */
  --ochre-text: #8a5f0f;    /* 5.30:1 on --surface (#f8f8f6) */
  --danger-text: #a3271f;
  --frame: #2f3a2c;
  /* The board looks the same in light and dark mode, like a real one. Every pairing of these is checked in test/contrast.test.ts. */
  --sq-light: #e6dbc1;
  --sq-dark: #4d6448;       /* glaze green */
  --sq-light-last: #f0d896; /* the squares of the last move */
  --sq-dark-last: #6f6a3a;
  --sq-check: #8a2f2a;      /* the king in check */
  --piece-white-fill: #fbf6e8;
  --piece-white-line: #1b1f26;
  --piece-black-fill: #050608;
  --piece-black-line: #d8cca8;
  --font-display: "Alegreya SC", "Palatino Linotype", Palatino, Georgia, serif;
  --font-body: "Alegreya Sans", "Gill Sans", "Segoe UI", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171d; --surface: #1c2028; --fg: #e6e8ec; --muted: #9aa2b1; --line: #2e3440;
    --accent: #7f9ee6; --ochre: #e0a940; --ochre-text: #e0a940; --danger-text: #ec6a5f; --frame: #0d100c;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14171d; --surface: #1c2028; --fg: #e6e8ec; --muted: #9aa2b1; --line: #2e3440;
  --accent: #7f9ee6; --ochre: #e0a940; --ochre-text: #e0a940; --danger-text: #ec6a5f; --frame: #0d100c;
  color-scheme: dark;
}
html, body { background: var(--bg); color: var(--fg); }
body {
  margin: 0;
  font-family: var(--font-body); font-size: 16px; line-height: 1.45;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 20px 32px;
}
.wrap { max-width: 1060px; margin: 0 auto; display: grid; gap: 20px; }
header h1 { font-family: var(--font-display); font-weight: 700; font-size: clamp(28px, 5vw, 40px); margin: 0; letter-spacing: 0.02em; line-height: 1.1; text-wrap: balance; }
header p { margin: 4px 0 0; color: var(--muted); }
.band { height: 10px; border-radius: 2px; opacity: .9;
  background:
    repeating-linear-gradient(90deg, var(--accent) 0 6px, transparent 6px 12px) top/100% 5px no-repeat,
    repeating-linear-gradient(90deg, transparent 0 6px, var(--ochre) 6px 12px) bottom/100% 5px no-repeat; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
@media (max-width: 860px) { .layout { grid-template-columns: minmax(0, 1fr); } }

/* The pieces: six shapes drawn once in the page (the hidden #piece-* symbols) and copied into each square, coloured by .piece.white or .piece.black. */
.piece .fill { fill: var(--piece-fill); stroke: var(--piece-line); stroke-width: 1.4; stroke-linejoin: round; }
.piece .line-only { fill: none; stroke: var(--piece-line); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.piece .detail { fill: var(--piece-line); stroke: none; }
.piece.white { --piece-fill: var(--piece-white-fill); --piece-line: var(--piece-white-line); }
.piece.black { --piece-fill: var(--piece-black-fill); --piece-line: var(--piece-black-line); }

/* Board */
.board-column { display: grid; gap: 8px; max-width: 640px; width: 100%; margin: 0 auto; min-width: 0; }
.board-frame { background: var(--frame); padding: 10px; border-radius: 6px; box-sizing: border-box; }
.board { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); grid-template-rows: repeat(8, minmax(0, 1fr)); aspect-ratio: 1; max-width: 100%; }
.sq { border: 0; padding: 0; margin: 0; min-width: 0; min-height: 0; position: relative; display: grid; place-items: center; border-radius: 0; cursor: pointer; font: inherit; }
.sq.light { background: var(--sq-light); color: var(--sq-dark); }
.sq.dark { background: var(--sq-dark); color: var(--sq-light); }
.sq.light.last { background: var(--sq-light-last); }
.sq.dark.last { background: var(--sq-dark-last); color: var(--piece-white-fill); }
.sq.check, .sq.check.last { background: var(--sq-check); color: var(--piece-white-fill); box-shadow: inset 0 0 0 3px var(--piece-white-fill); } /* the ring is a second cue, for anyone who cannot tell the red */
.sq[data-rank-label]::before, .sq[data-file-label]::after { position: absolute; font-size: clamp(10px, 1.7vw, 12px); font-weight: 700; line-height: 1; pointer-events: none; }
.sq[data-rank-label]::before { content: attr(data-rank-label); top: 3px; left: 4px; }
.sq[data-file-label]::after { content: attr(data-file-label); bottom: 3px; right: 4px; }
.sq .piece { width: 88%; height: 88%; pointer-events: none; }
.sq.selected { box-shadow: inset 0 0 0 3px var(--piece-white-line), inset 0 0 0 6px var(--piece-white-fill); }
.sq:focus-visible { outline: 4px solid var(--piece-white-line); outline-offset: -4px; box-shadow: inset 0 0 0 7px var(--piece-white-fill); z-index: 2; }
.sq.selected:focus-visible { box-shadow: inset 0 0 0 7px var(--piece-white-fill); }
/* A legal move: a dot on an empty square, a ring round a piece that can be taken. Dark centre and light edge so it shows on both colours of square. */
.sq.target::after { content: ""; position: absolute; width: 26%; height: 26%; border-radius: 50%; background: var(--piece-white-line); box-shadow: 0 0 0 2px var(--piece-white-fill); }
.sq.capture-target::after { content: ""; position: absolute; inset: 5%; border-radius: 50%; border: 4px solid var(--piece-white-line); box-shadow: 0 0 0 2px var(--piece-white-fill), inset 0 0 0 2px var(--piece-white-fill); pointer-events: none; }
.board[data-reviewing] .sq { cursor: default; }
.player-strip { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 28px; font-size: 15px; }
.player-name { font-weight: 700; }
.player-strip[data-turn="true"] .player-name::after { content: " 2  to move"; font-weight: 500; color: var(--muted); }
.board-status { display: none; margin: 0; font-family: var(--font-display); font-size: 20px; line-height: 1.2; }
@media (max-width: 860px) { .board-status { display: block; } header p { display: none; } .btn, .seg button, .ply { min-height: 44px; } }
@media (min-width: 861px) { .board-column { position: sticky; top: 16px; } }
.row.controls { display: grid; grid-template-columns: 1fr 1fr; }
.captured { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 0; min-height: 20px; }
.piece.mini { width: 20px; height: 20px; margin-right: -6px; }
.piece.mini.white { background: var(--sq-dark); border-radius: 3px; }
.piece.mini.black { background: var(--sq-light); border-radius: 3px; }
.captured .lead { margin-left: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Rail */
.rail { display: grid; gap: 16px; min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; display: grid; gap: 10px; }
.label { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 700; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { font: inherit; font-size: 14px; border: 0; padding: 8px 6px; background: transparent; color: var(--fg); cursor: pointer; min-height: 36px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--surface); font-weight: 700; }
.seg.strengths { grid-auto-flow: row; grid-template-columns: repeat(5, 1fr); }
.seg.strengths button:nth-child(5n + 1) { border-left: 0; }
.seg.strengths button:nth-child(n + 6) { border-top: 1px solid var(--line); }
.seg button:focus-visible, .btn:focus-visible, .field:focus-visible, .ply:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row.nowrap { flex-wrap: nowrap; }
.row.navigation .btn { flex: 1; padding-inline: 4px; }
.btn { font: inherit; font-size: 14px; font-weight: 500; padding: 8px 14px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--fg); cursor: pointer; min-height: 36px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--surface); font-weight: 700; }
.btn:disabled { opacity: .45; cursor: default; }
.field { font: inherit; font-size: 16px; padding: 7px 10px; border-radius: 6px; border: 1px solid var(--muted); background: var(--bg); color: var(--fg); min-width: 0; flex: 1; box-sizing: border-box; }
.field:disabled { opacity: .55; }
.field[aria-invalid="true"] { border-color: var(--danger-text); }
textarea.pgn { width: 100%; font-family: ui-monospace, Consolas, monospace; font-size: 13px; resize: vertical; }
.error { color: var(--danger-text); overflow-wrap: anywhere; }

.status { font-family: var(--font-display); font-size: 22px; line-height: 1.2; display: flex; align-items: center; gap: 10px; text-wrap: balance; }
.status.over { color: var(--ochre-text); }
.hint { color: var(--muted); font-size: 14px; margin: 0; }

.tally { display: grid; gap: 6px; }
.tally div { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.tally b { margin-left: auto; font-variant-numeric: tabular-nums; }

.log { position: relative; max-height: 220px; overflow-y: auto; font-variant-numeric: tabular-nums; font-size: 14px; margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; }
.log li { display: grid; grid-template-columns: 2.4em 1fr 1fr; align-items: center; gap: 4px; }
.log .n { color: var(--muted); }
.ply { font: inherit; font-size: 14px; text-align: left; border: 0; border-radius: 4px; background: transparent; color: var(--fg); padding: 3px 6px; cursor: pointer; min-height: 28px; }
.ply:hover { background: var(--bg); }
.ply[aria-current="true"] { background: var(--accent); color: var(--surface); font-weight: 700; }
.empty { color: var(--muted); font-size: 14px; display: block !important; }

details.rules summary { cursor: pointer; font-weight: 700; padding-block: 6px; }
details.rules textarea { margin-block: 8px; }
/* Site chrome shared by every page: skip link, footer, document pages */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 10; background: var(--surface); color: var(--fg); padding: 8px 12px; border-radius: 6px; border: 1px solid var(--line); }
.skip-link:focus { top: 8px; }
a { color: var(--accent); }
header .brand { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: clamp(22px, 4vw, 28px); letter-spacing: 0.02em; color: var(--fg); }
header .brand a { color: inherit; text-decoration: none; }
header .brand a:hover, header .brand a:focus-visible { text-decoration: underline; }
footer.site { border-top: 1px solid var(--line); padding-top: 16px; display: grid; gap: 8px; font-size: 14px; color: var(--muted); }
footer.site nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 6px 18px; flex-wrap: wrap; }
footer.site p { margin: 0; }
main.doc { display: grid; gap: 14px; max-width: 720px; }
main.doc h1 { font-family: var(--font-display); font-size: clamp(28px, 5vw, 40px); margin: 0; line-height: 1.1; }
main.doc h2 { font-family: var(--font-display); font-size: 24px; margin: 18px 0 0; }
main.doc h3 { font-size: 18px; margin: 10px 0 0; }
main.doc p, main.doc ul, main.doc ol { margin: 0; }
main.doc ul, main.doc ol { padding-left: 22px; display: grid; gap: 6px; }
main.doc code { font-size: .92em; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
main.doc table { border-collapse: collapse; width: 100%; font-size: 15px; }
main.doc th, main.doc td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.lede { color: var(--muted); font-size: 18px; }
.build-number { font-weight: 700; }
.changelog { list-style: none; padding: 0 !important; display: grid; gap: 16px !important; }
.changelog li { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; display: grid; gap: 6px; }
.changelog-meta { display: flex; gap: 6px 14px; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.changelog-build { font-weight: 700; color: var(--fg); font-variant-numeric: tabular-nums; }
