:root {
  --bg: #f4f1ea;
  --fg: #22201c;
  --muted: #6b665c;
  --panel: #fffdf8;
  --border: #d9d3c5;
  --accent: #8a5a2b;
  --wood: #dcb36b;
  --wood-edge: #c89b4f;
  --line: #3a2c17;
  --stone-black: #1b1b1b;
  --stone-white: #f7f7f2;
  --stone-white-edge: #8e8e88;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1916;
    --fg: #ece8df;
    --muted: #a59f92;
    --panel: #24221e;
    --border: #3b3831;
    --accent: #d9a466;
    --wood: #c9a160;
    --wood-edge: #a8823f;
  }
}
:root[data-theme="dark"] {
  --bg: #1a1916;
  --fg: #ece8df;
  --muted: #a59f92;
  --panel: #24221e;
  --border: #3b3831;
  --accent: #d9a466;
  --wood: #c9a160;
  --wood-edge: #a8823f;
}

* { box-sizing: border-box; }

/* Links: the accent colour, underlined on hover or keyboard focus. */
a { color: var(--accent); text-decoration: none; text-underline-offset: .18em; text-decoration-thickness: .08em; }
a:hover, a:focus-visible { text-decoration: underline; }
a:active { opacity: .75; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px;
  align-items: start;
}

/* slides: one screen each */
.slide { min-height: 100vh; }

.toc-slide, .proverb-slide {
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 1000px;
  margin: 0 auto;
  padding: 48px 16px;
}

.kicker { color: var(--accent); text-transform: uppercase; letter-spacing: .12em; font-size: .9rem; margin: 0 0 12px; }
.byline { color: var(--muted); margin: 0; }

/* slide index: the first slide, one link per slide */
.index-slide {
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 1000px;
  margin: 0 auto;
  padding: 48px 16px;
}
.index-title { font-size: clamp(2rem, 6vw, 3.5rem); line-height: 1.05; margin: 0 0 12px; font-weight: 700; }
.index-slide .byline { margin-bottom: 32px; font-size: 1.15rem; }
.slide-index { margin: 0; padding: 0 0 0 2.5em; columns: 2 280px; column-gap: 48px; }
.slide-index li { break-inside: avoid; padding: 8px 0; font-size: 1.2rem; }
.slide-index li::marker { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }

.toc-slide h2 { font-size: clamp(2rem, 5vw, 3rem); margin: 0 0 24px; }

/* proverb slide */
.proverb { font-size: clamp(1.8rem, 5vw, 3.25rem); line-height: 1.15; font-weight: 700; margin: 0 0 16px; }
.proverb::before { content: "“"; color: var(--accent); }
.proverb::after { content: "”"; color: var(--accent); }
.proverb-origin { color: var(--muted); font-size: 1.1rem; max-width: 60ch; margin: 0 0 28px; }
.points { list-style: none; margin: 0 0 24px; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.points li { border-top: 3px solid var(--accent); padding-top: 10px; color: var(--muted); line-height: 1.45; }
.points strong { display: block; color: var(--fg); font-size: 1.1rem; margin-bottom: 4px; }
.toc { list-style: none; counter-reset: toc; margin: 0 0 24px; padding: 0; }
.toc li {
  counter-increment: toc;
  display: grid;
  grid-template-columns: 2.5em minmax(0, 14em) minmax(0, 1fr) auto;
  gap: 4px 16px;
  align-items: baseline;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.toc li::before { content: counter(toc); color: var(--accent); font-weight: 700; }
.toc-name { font-weight: 600; font-size: 1.15rem; }
.toc-idea { color: var(--muted); }
.toc-min { color: var(--muted); font-variant-numeric: tabular-nums; }

@media (max-width: 700px) {
  .toc li { grid-template-columns: 2em minmax(0, 1fr) auto; }
  .toc-idea { grid-column: 2 / -1; }
}

.board-wrap { display: flex; justify-content: center; }

/* Mirror go marks (19x19 mirror slide) */
.mirror-mark { fill: none; stroke: var(--accent); stroke-width: .09; pointer-events: none; }
.mirror-mark.broken { stroke-dasharray: .16 .1; }

.board {
  width: min(100%, calc(100vh - 48px));
  aspect-ratio: 1;
  display: block;
  touch-action: manipulation;
  user-select: none;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}



select, button, input[type="range"] { font: inherit; color: inherit; }

select {
  width: 100%;
  padding: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.info { margin: 0 0 12px; display: grid; gap: 4px; }
.info div { display: flex; justify-content: space-between; gap: 12px; }
.info dt { color: var(--muted); display: flex; align-items: center; gap: 6px; }
.info dd { margin: 0; text-align: right; overflow-wrap: anywhere; }

.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.dot.black { background: var(--stone-black); border: 1px solid var(--muted); }
.dot.white { background: var(--stone-white); border: 1px solid var(--stone-white-edge); }

.status { min-height: 3em; margin: 0 0 12px; font-weight: 600; }

.controls { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.controls button { flex: 1; }

button {
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .4; cursor: default; }
button[hidden] { display: none; }

input[type="range"] { width: 100%; margin: 0 0 16px; accent-color: var(--accent); }

.hint { font-size: .85rem; color: var(--muted); margin: 0; }

/* board svg */
.wood { fill: var(--wood); stroke: var(--wood-edge); stroke-width: .08; }
.grid line { stroke: var(--line); stroke-width: .035; }
.hoshi { fill: var(--line); }
.coord { fill: var(--line); font-size: .38px; text-anchor: middle; dominant-baseline: central; opacity: .75; }
.stone.b { fill: var(--stone-black); }
.stone.w { fill: var(--stone-white); stroke: var(--stone-white-edge); stroke-width: .03; }
.ghost { opacity: .45; pointer-events: none; }
.last { fill: none; stroke-width: .07; pointer-events: none; }
.last.on-b { stroke: var(--stone-white); }
.last.on-w { stroke: var(--stone-black); }

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .board { width: 100%; }
}

/* slide show */
.deck .slide:not(.active) { display: none !important; }
.deck .slide.active { min-height: 100vh; }
.deck .layout.active { align-content: center; }

.deck-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 10; pointer-events: none; }
.deck-progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s ease; }

.deck-nav {
  position: fixed; right: 16px; bottom: 16px; z-index: 10;
  display: flex; align-items: center; gap: 4px;
  padding: 4px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--border);
  opacity: .35; transition: opacity .2s;
}
.deck-nav:hover, .deck-nav:focus-within { opacity: 1; }
.deck-nav button { border: 0; background: transparent; border-radius: 999px; width: 36px; height: 36px; padding: 0; font-size: 1.2rem; line-height: 1; }
.deck-count { font-size: .85rem; color: var(--muted); min-width: 3.5em; text-align: center; font-variant-numeric: tabular-nums; }

/* scoring */
.stone.dead { opacity: .35; }
.terr { pointer-events: none; }
.terr.b { fill: var(--stone-black); stroke: var(--stone-white); stroke-width: .02; }
.terr.w { fill: var(--stone-white); stroke: var(--stone-black); stroke-width: .02; }

.scorecard { margin: 0 0 12px; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.scorecard h3 { font-size: 1rem; margin: 0 0 8px; }
.score { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.score th, .score td { padding: 3px 0; text-align: right; font-weight: normal; }
.score th:first-child { text-align: left; color: var(--muted); }
.score thead th { font-size: .85rem; color: var(--muted); }
.score tfoot th, .score tfoot td { font-weight: 700; border-top: 1px solid var(--border); padding-top: 6px; }
.score tfoot th:first-child { color: var(--fg); }
.score-note { font-size: .85rem; color: var(--muted); margin: 8px 0 0; }
.score-note strong { color: var(--fg); }

.check { display: flex; align-items: center; gap: 8px; font-size: .9rem; margin: 0 0 12px; }
.check input { accent-color: var(--accent); }

/* image slide */
.image-slide {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  max-width: 1000px;
  margin: 0 auto;
  padding: 32px 16px;
}
.image-slide figure { margin: 0; text-align: center; }
.image-slide img {
  display: block;
  max-width: 100%;
  max-height: 68vh;
  width: auto;
  height: auto;
  margin: 0 auto;
  border-radius: 8px;
}
.image-slide figcaption { font-size: .8rem; color: var(--muted); margin-top: 8px; }
.image-text { text-align: center; max-width: 60ch; }
.image-text h2 { font-size: clamp(1.5rem, 4vw, 2.25rem); margin: 0 0 8px; }
.image-text p { color: var(--muted); margin: 0; font-size: 1.1rem; }

/* autoplay */
.controls.autoplay select { flex: 1; width: auto; }
#autoplay[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }

.about { font-size: .9rem; margin: -8px 0 12px; color: var(--muted); }

.game-select { margin-bottom: 12px; }
