/* Go. Light and dark themes from the same tokens; every text colour meets WCAG 2.2 AA on its background, and the
   board's stones and marks keep 3:1 against the wood they sit on (white stones have a dark rim). The board itself is
   wood-toned in both themes. Built from Chess's stylesheet (chess/assets/app.css). */
:root {
  --bg: #f6f1ea; --card: #ffffff; --ink: #1f1a14; --muted: #5b5146; --line: #e2d7c8;
  --brand: #7a4a1c; --brand-ink: #ffffff; --link: #6b3f14; --head: #3b2410; --head-ink: #ffffff; --head-soft: #f0dcc4;
  --danger: #b42318; --danger-ink: #ffffff; --focus: #1d4ed8;
  --ok-bg: #e6f4ea; --ok-ink: #14532d; --warn-bg: #fff3d4; --warn-ink: #5e4100; --err-bg: #fde8e6; --err-ink: #8a1c12;
  --tag-bg: #f3e9dc;
  --wood: #dcb26a; --wood-edge: #b98a3e; --gl: #2b1d0e; --lab: #3b2a14;
  --hint: #15803d; --cross: #c81e1e;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15110d; --card: #221b14; --ink: #f2ebe2; --muted: #c7b9a7; --line: #3a2f24;
    --brand: #e0b07a; --brand-ink: #2a1708; --link: #f0c592; --head: #0f0b07; --head-ink: #ffffff; --head-soft: #f0dcc4;
    --danger: #ff8f80; --danger-ink: #2a0905; --focus: #93c5fd;
    --ok-bg: #163a24; --ok-ink: #c8efd2; --warn-bg: #3a2e0c; --warn-ink: #ffe3a3; --err-bg: #3d1611; --err-ink: #ffd2cb;
    --tag-bg: #2d241b;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }
a { color: var(--link); text-underline-offset: 2px; }
h1 { font-size: 1.7rem; line-height: 1.2; margin: 0 0 .6rem; }
h2 { font-size: 1.25rem; line-height: 1.25; margin: 1.2rem 0 .6rem; }
h3 { font-size: 1.05rem; margin: 16px 0 6px; }
.h-small { font-size: 1rem; margin: 16px 0 6px; }
.card > h2:first-child, .card > h1:first-child { margin-top: 0; }
p { margin: 0 0 .8rem; }
:is(a, button, input, select, textarea, summary, [tabindex]):focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -9999px; top: 0; background: var(--card); color: var(--ink); padding: 8px 12px; z-index: 2000; }
.skip:focus { left: 8px; top: 8px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 16px; padding-bottom: 24px; }
main:focus { outline: none; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.lede { font-size: 1.08rem; color: var(--muted); }
.row { display: flex; align-items: center; }
.gap { gap: 8px; }
.wrap-row { flex-wrap: wrap; margin: 0 0 10px; }
ul.plain { list-style: none; padding: 0; margin: 0 0 12px; }

/* Header and footer */
.site-header { background: var(--head); color: var(--head-ink); }
.site-header .bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 4px 16px; min-height: 56px; }
.brand { color: var(--head-ink); text-decoration: none; font-weight: 800; font-size: 1.2rem; padding: 8px 0; }
.brand span { margin-right: .3em; }
.top-nav { display: flex; flex-wrap: wrap; gap: 2px 18px; }
.top-nav a { color: var(--head-soft); text-decoration: none; padding: 8px 0; border-bottom: 3px solid transparent; }
.top-nav a:hover, .top-nav a[aria-current] { color: var(--head-ink); border-bottom-color: var(--head-soft); }
.site-footer { border-top: 1px solid var(--line); margin-top: 24px; padding: 16px 0 28px; color: var(--muted); font-size: .92rem; }
.site-footer a { color: var(--link); }

/* Cards, forms, buttons, alerts */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin: 0 0 16px; }
.card.narrow { max-width: 600px; margin: 24px auto; }
.card.inset { padding: 14px; margin: 10px 0; background: var(--tag-bg); }
.hero { margin: 8px 0 18px; }
.hero h1 { font-size: 2rem; }
.hero h1 span { margin-right: .3em; }
.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 16px; margin-bottom: 16px; }
.modes .card { margin: 0; }
.prose ul { padding-left: 1.3rem; }
.prose li { margin: 0 0 .35rem; }
label { display: block; font-weight: 600; margin: 10px 0 4px; }
.stack > label:first-child, .stack > div > label:first-child { margin-top: 0; }
input[type=text], input[type=email] { width: 100%; max-width: 420px; padding: 9px 11px; font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--muted); border-radius: 8px; min-height: 44px; }
fieldset.choices { border: 0; padding: 0; margin: 12px 0; }
fieldset.choices legend { font-weight: 700; padding: 0; margin-bottom: 4px; }
label.choice { font-weight: 400; display: flex; gap: 8px; align-items: baseline; margin: 2px 0; padding: 6px 4px; min-height: 32px; cursor: pointer; border-radius: 6px; }
label.choice:hover { background: var(--tag-bg); }
label.choice.inline { display: inline-flex; margin-right: 12px; }
label.choice .muted { font-size: .88rem; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 400; margin: 8px 0; min-height: 32px; }
input[type=radio], input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--brand); flex: none; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--brand); color: var(--brand-ink); border: 2px solid var(--brand);
  border-radius: 8px; padding: 8px 16px; min-height: 44px; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { filter: brightness(1.07); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.small { min-height: 36px; padding: 4px 12px; font-size: .92rem; }
.btn.outline { background: transparent; color: var(--link); border-color: currentColor; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: var(--danger-ink); }
.stack .btn { margin-top: 14px; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--link); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; min-height: 24px; }
.alert { padding: 12px 14px; border-radius: 8px; margin: 0 0 14px; background: var(--tag-bg); }
.alert.ok { background: var(--ok-bg); color: var(--ok-ink); }
.alert.warn { background: var(--warn-bg); color: var(--warn-ink); }
.alert p:last-child { margin-bottom: 0; }
.alert .btn { margin-top: 4px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* The game: board and panel */
.game { display: grid; grid-template-columns: minmax(0, 620px) minmax(260px, 1fr); gap: 20px; align-items: start; }
@media (max-width: 860px) { .game { grid-template-columns: 1fr; } }
.board-wrap { max-width: 620px; width: 100%; position: relative; }
/* The board: a row of letters, the n rows of points (each with its number at both ends), and the letters again. Each
   point draws its two lines (cut short at the edges), and the star points a dot. */
.board { --n: 9; --lw: max(1px, .22cqw); container-type: inline-size; display: grid; grid-template-rows: .7fr repeat(var(--n), 1fr) .7fr; aspect-ratio: 1; width: 100%;
  background: var(--wood); border: 2px solid var(--wood-edge); border-radius: 6px; box-shadow: 0 2px 10px rgba(0,0,0,.25);
  user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.board .lrow, .board .brow { display: grid; grid-template-columns: .7fr repeat(var(--n), 1fr) .7fr; min-height: 0; }
.board .lrow span, .board .lab { display: flex; align-items: center; justify-content: center; color: var(--lab); font-weight: 700;
  font-size: calc(48cqw / (var(--n) + 1.4)); line-height: 1; }
.board.size-19 .lrow span, .board.size-19 .lab { font-size: calc(56cqw / (var(--n) + 1.4)); }
.pt { position: relative; cursor: pointer; min-width: 0; }
.pt::before, .pt::after { content: ''; position: absolute; background: var(--gl); pointer-events: none; }
.pt::before { left: 0; right: 0; top: 50%; height: var(--lw); transform: translateY(-50%); }
.pt::after { top: 0; bottom: 0; left: 50%; width: var(--lw); transform: translateX(-50%); }
.pt[data-edge*="l"]::before { left: 50%; }
.pt[data-edge*="r"]::before { right: 50%; }
.pt[data-edge*="t"]::after { top: 50%; }
.pt[data-edge*="b"]::after { bottom: 50%; }
.pt[data-edge*="t"]::before, .pt[data-edge*="b"]::before { height: calc(var(--lw) * 2); }
.pt[data-edge*="l"]::after, .pt[data-edge*="r"]::after { width: calc(var(--lw) * 2); }
.pt[data-star] { background: radial-gradient(circle closest-side, var(--gl) 0 20%, transparent 24%); }
.pt:focus { outline: none; }
/* Focus: a white ring with a blue one inside, so it shows on the wood and on either colour of stone. */
.pt:focus-visible { outline: 3px solid #ffffff; outline-offset: -3px; box-shadow: inset 0 0 0 6px #1d4ed8; z-index: 4; border-radius: 4px; }
/* Where your stone would go, under the pointer. */
@media (hover: hover) {
  .board.can-b .pt.empty:hover { background: radial-gradient(circle closest-side, rgba(0,0,0,.42) 0 88%, transparent 92%); }
  .board.can-w .pt.empty:hover { background: radial-gradient(circle closest-side, rgba(255,255,255,.7) 0 88%, transparent 92%); }
}
.stone { position: absolute; inset: 4%; border-radius: 50%; z-index: 1; pointer-events: none; }
.stone.b { background: radial-gradient(circle at 35% 30%, #5b5b5b 0, #1b1b1b 45%, #000 100%); box-shadow: 0 .25cqw .5cqw rgba(0,0,0,.45); }
.stone.w { background: radial-gradient(circle at 35% 30%, #ffffff 0, #f3f3f3 45%, #d2d2d2 100%); box-shadow: inset 0 0 0 max(1px, .25cqw) #3a3a3a, 0 .25cqw .5cqw rgba(0,0,0,.35); }
/* The last stone played: a ring of the other colour. */
.stone.last::after { content: ''; position: absolute; inset: 28%; border-radius: 50%; border: max(2px, .45cqw) solid #ffffff; }
.stone.w.last::after { border-color: #000000; }
/* A stone about to be played (tap twice), and a hint. */
.stone.ghost { opacity: .55; }
.pt.pending { box-shadow: inset 0 0 0 max(2px, .45cqw) #1d4ed8; border-radius: 50%; }
.pt.hinted { box-shadow: inset 0 0 0 max(2px, .55cqw) var(--hint), inset 0 0 0 max(3px, .8cqw) #ffffff; border-radius: 50%; }
/* Counting: dead stones are see-through, with a red cross; each point's owner gets a small square. */
.stone.dead.b { background: rgba(0,0,0,.38); box-shadow: none; }
.stone.dead.w { background: rgba(255,255,255,.5); box-shadow: inset 0 0 0 max(1px, .2cqw) rgba(58,58,58,.7); }
.stone.dead::before { content: ''; position: absolute; inset: 18%; z-index: 3;
  background: linear-gradient(45deg, transparent 42%, var(--cross) 42% 58%, transparent 58%), linear-gradient(-45deg, transparent 42%, var(--cross) 42% 58%, transparent 58%); }
.terr { position: absolute; left: 50%; top: 50%; width: 30%; height: 30%; transform: translate(-50%, -50%); z-index: 2; pointer-events: none; }
.terr.b { background: #111111; box-shadow: 0 0 0 max(1px, .15cqw) #f5e6c8; }
.terr.w { background: #ffffff; box-shadow: 0 0 0 max(1px, .2cqw) #111111; }
.board-help { margin-top: 8px; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.go-status { font-size: 1.12rem; font-weight: 700; margin-bottom: 10px; }
.go-caps li { display: flex; align-items: center; gap: 6px; margin: 3px 0; min-height: 26px; }
/* Little stones in the lists: shaded like the board's, so they don't read as radio buttons. */
.mv-stone { display: inline-block; width: 1em; height: 1em; border-radius: 50%; vertical-align: -.14em; flex: none; }
.mv-stone.b { background: radial-gradient(circle at 35% 30%, #6a6a6a, #151515 55%, #000000); box-shadow: 0 0 0 1px rgba(128,128,128,.55); }
.mv-stone.w { background: radial-gradient(circle at 35% 30%, #ffffff, #e8e8e8 55%, #b4b4b4); box-shadow: 0 0 0 1px rgba(80,80,80,.6); }
.go-type .row input { max-width: 160px; text-transform: uppercase; }
.go-type-msg:empty { display: none; }
.go-moves-box { max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.go-moves { margin: 0; padding-left: 2.6rem; font-variant-numeric: tabular-nums; }
.go-moves li.resume { list-style: none; margin-left: -2.2rem; color: var(--muted); font-style: italic; }
.go-moves:empty::before { content: 'No moves yet.'; color: var(--muted); margin-left: -2.4rem; }
.go-end { margin: 6px 0 10px; }
.go-count { margin: 10px 0 14px; }
.go-count h2 { margin-top: 0; }
.go-score { font-size: .92rem; margin-bottom: 8px; background: var(--card); }
.go-score th, .go-score td { padding: 5px 8px; }
.go-score td { text-align: right; }
.go-score thead th:not(:first-child) { text-align: right; }
.go-score tr.total th, .go-score tr.total td { font-weight: 800; color: var(--ink); }
.go-count-line { font-weight: 700; }
.go-count-line:empty, .go-count-help:empty, .go-oks:empty { display: none; }

/* The brand mark: half a black stone, half a white one. */
.brand-stone { display: inline-block; width: .9em; height: .9em; border-radius: 50%; vertical-align: -.1em; background: linear-gradient(90deg, #111 50%, #fff 50%); box-shadow: 0 0 0 2px #f0dcc4; }
.brand-stone.big { width: .85em; height: .85em; margin-right: .2em; box-shadow: 0 0 0 2px var(--ink); }

/* Learn Go: small diagrams. */
.learn .card { margin-bottom: 16px; }
.toc ol { margin: 0; columns: 2 240px; }
.dias { display: flex; flex-wrap: wrap; gap: 14px 18px; align-items: flex-start; margin: 6px 0 14px; }
.dia-arrow { font-size: 1.8rem; line-height: 1; color: var(--muted); margin-top: calc(var(--h, 4) * 17px - 8px); }
figure.dia { margin: 0; width: min-content; min-width: 210px; }
figure.dia figcaption { margin-top: 6px; font-size: .84rem; line-height: 1.35; color: var(--muted); }
.dia-board { --cell: 34px; --lw: 1.5px; display: grid; grid-template-columns: repeat(var(--w), var(--cell)); grid-auto-rows: var(--cell); padding: 6px;
  background: var(--wood); border: 2px solid var(--wood-edge); border-radius: 6px; }
.dp { position: relative; }
.dp::before, .dp::after { content: ''; position: absolute; background: var(--gl); }
.dp::before { left: 0; right: 0; top: 50%; height: var(--lw); transform: translateY(-50%); }
.dp::after { top: 0; bottom: 0; left: 50%; width: var(--lw); transform: translateX(-50%); }
.dp.c0::before { left: 50%; } .dp.cN::before { right: 50%; }
.dp.r0::after { top: 50%; } .dp.rN::after { bottom: 50%; }
.dp .stone.b { box-shadow: 0 1px 3px rgba(0,0,0,.45); }
.dp .stone.w { box-shadow: inset 0 0 0 1.5px #3a3a3a, 0 1px 3px rgba(0,0,0,.35); }
.dp .stone.next { opacity: .75; box-shadow: 0 0 0 3px var(--hint); }
.dp .stone.next.w { box-shadow: inset 0 0 0 1.5px #3a3a3a, 0 0 0 3px var(--hint); }
.dp .lib { position: absolute; left: 50%; top: 50%; width: 34%; height: 34%; transform: translate(-50%, -50%); border-radius: 50%; background: var(--hint); box-shadow: 0 0 0 2px #ffffff; z-index: 2; }
.dp .terr { width: 34%; height: 34%; }
.dp .lbl { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 2; font-weight: 800; font-size: 17px; line-height: 1;
  color: var(--lab); background: var(--wood); padding: 2px 4px; border-radius: 50%; }
.dp .lbl.on-b { color: #ffffff; background: transparent; }
.dp .lbl.on-w { color: #111111; background: transparent; }

/* Stats */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin: 0 0 16px; }
.tiles li { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; text-align: center; color: var(--muted); }
.tiles .big { display: block; font-size: 1.8rem; font-weight: 800; color: var(--ink); line-height: 1.1; }
.table-wrap { overflow-x: auto; margin: 0 0 8px; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
thead th { font-size: .88rem; color: var(--muted); }
td { font-variant-numeric: tabular-nums; }
dl.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px 20px; margin: 0 0 8px; }
dl.facts dt { font-weight: 700; }
dl.facts dd { margin: 0; }

@media (prefers-reduced-motion: no-preference) { .btn { transition: filter .12s; } }
@media print { .site-header, .site-footer, .panel .btn, .go-type, .board-help { display: none !important; } }
