/* Baduk — locked palette: warm paper + ink + real wood board + single vermilion accent.
   One accent everywhere. Light + dark, both shipped. No external fonts (zero network deps). */
:root {
  /* near-neutral off-white page so the warm WOOD board reads as the one
     deliberate warm element (not a warm-monochrome page) */
  --paper: #f3f2ef;
  --panel: #fbfaf8;
  --ink: #221e18;
  --ink-soft: #5f5a51;
  --line: #e3dfd8;
  --wood-a: #e3bd80;
  --wood-b: #cf9f56;
  --grid: #5b3d1c;
  --accent: #bf3f29;       /* vermilion 朱 — the one accent */
  --accent-soft: #e9c6bd;
  --shadow: rgba(60, 40, 15, .22);
  --radius: 14px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans Thai", sans-serif;
}
:root[data-theme="dark"] {
  --paper: #14110c;
  --panel: #1d1810;
  --ink: #ece3d2;
  --ink-soft: #a99c84;
  --line: #2e2719;
  --wood-a: #c79a55;
  --wood-b: #a87d3e;
  --grid: #3a2710;
  --accent: #e0664a;
  --accent-soft: #4a2118;
  --shadow: rgba(0, 0, 0, .45);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #14110c; --panel: #1d1810; --ink: #ece3d2; --ink-soft: #a99c84;
    --line: #2e2719; --wood-a: #c79a55; --wood-b: #a87d3e; --grid: #3a2710;
    --accent: #e0664a; --accent-soft: #4a2118; --shadow: rgba(0, 0, 0, .45);
  }
}

* { box-sizing: border-box; }
/* the hidden attribute must win over author display rules (e.g. .lesson-nav/.size-row use flex) */
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1100px; margin: 0 auto; padding: clamp(16px, 3vw, 32px); }

header { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.brand { display: flex; align-items: baseline; gap: 12px; }
.brand h1 { font-size: clamp(22px, 3.4vw, 30px); margin: 0; letter-spacing: -.02em; font-weight: 700; }
.brand .cjk { color: var(--accent); }
.brand .sub { color: var(--ink-soft); font-size: 13px; }
.top-controls { display: flex; gap: 8px; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: clamp(16px, 3vw, 28px); align-items: start; }
@media (max-width: 820px) { .layout { grid-template-columns: 1fr; } }

/* segmented mode control */
.modes { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 4px; margin-bottom: 14px; }
.modes button {
  border: 0; background: transparent; color: var(--ink-soft); font: inherit; font-size: 14px;
  padding: 10px 16px; min-height: 44px; border-radius: 999px; cursor: pointer; transition: color .18s, background .18s;
}
.modes button[aria-pressed="true"] { background: var(--accent); color: #fff; font-weight: 600; }
.modes button:hover[aria-pressed="false"] { color: var(--ink); }

/* board */
.board-wrap {
  position: relative; border-radius: var(--radius); padding: clamp(10px, 2.5vw, 22px);
  background: linear-gradient(135deg, var(--wood-a), var(--wood-b));
  box-shadow: 0 10px 30px var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .25);
}
/* faint grain so the wood doesn't read as flat AI gradient */
.board-wrap::before {
  content: ""; position: absolute; inset: 0; border-radius: var(--radius); pointer-events: none;
  background-image: radial-gradient(rgba(90, 61, 28, .10) 1px, transparent 1.4px);
  background-size: 7px 7px; opacity: .5; mix-blend-mode: multiply;
}
svg#board { display: block; width: 100%; height: auto; touch-action: manipulation; outline: none; cursor: pointer; }
svg#board:focus-visible { box-shadow: 0 0 0 3px var(--accent); border-radius: 6px; }

.grid-line { stroke: var(--grid); stroke-width: .035; }
.star { fill: var(--grid); }

#layerStone { filter: drop-shadow(0 .05px .12px rgba(40, 26, 8, .5)); }
.stone { stroke-width: .02; }
.stone.black { fill: url(#gradBlack); stroke: #000; }
.stone.white { fill: url(#gradWhite); stroke: #b9b0a0; stroke-width: .03; }
.stone.just-placed { transform-box: fill-box; transform-origin: center; animation: pop .22s cubic-bezier(.16, 1, .3, 1); }
@keyframes pop { from { transform: scale(.55); opacity: .2; } to { transform: scale(1); opacity: 1; } }

.ghost { opacity: .42; pointer-events: none; }
.ghost.black { fill: #1a1714; } .ghost.white { fill: #efe9dc; }
.last-move { pointer-events: none; }
.last-move.on-black { fill: #efe9dc; } .last-move.on-white { fill: #1a1714; }
.ko-mark { fill: none; stroke: var(--accent); stroke-width: .05; }
.cursor { fill: none; stroke: var(--accent); stroke-width: .04; opacity: .8; pointer-events: none; }
.invalid { fill: var(--accent); opacity: .5; animation: flash .26s ease-out; pointer-events: none; }
@keyframes flash { from { opacity: .55; } to { opacity: 0; } }
.mark-target { fill: var(--accent); opacity: .22; }
.mark-good { fill: #2e7d57; opacity: .25; }
.mark-eye { fill: none; stroke: var(--accent); stroke-width: .05; stroke-dasharray: .12 .1; }

/* actions */
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
button.btn, .top-controls button, .lesson-nav button, .panel button {
  font: inherit; font-size: 14px; cursor: pointer; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 10px 14px; min-height: 44px; transition: transform .08s, border-color .18s, background .18s;
}
button:hover { border-color: var(--accent); }
button:active { transform: translateY(1px) scale(.985); }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon-btn { width: 44px; padding: 9px 0; text-align: center; }

/* panel */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.panel h2 { font-size: 17px; margin: 0 0 8px; letter-spacing: -.01em; }
.panel p { margin: 0 0 14px; color: var(--ink-soft); font-size: 14.5px; }
.goal-box { border: 1px solid var(--accent); padding: 9px 13px; background: var(--accent-soft); border-radius: 8px; font-size: 14px; margin-bottom: 14px; color: var(--ink); }
.lesson-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.lesson-nav .progress { color: var(--ink-soft); font-size: 13px; }
.pulse { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 var(--accent); } 50% { box-shadow: 0 0 0 4px transparent; } }

.meta { display: flex; align-items: center; gap: 16px; margin: 14px 0 6px; flex-wrap: wrap; }
.turn { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }
.swatch { width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--line); display: inline-block; }
.swatch.black { background: #1a1714; } .swatch.white { background: #efe9dc; }
.caps { font-size: 13px; color: var(--ink-soft); display: flex; gap: 14px; }
.size-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 14px; color: var(--ink-soft); }

/* difficulty (vs bot) — reuses .modes segmented styling */
.diff-row { margin-top: 14px; }
.diff-label { display: block; font-size: 14px; color: var(--ink-soft); margin-bottom: 7px; }
.diff-seg { margin-bottom: 0; display: flex; width: 100%; }
.diff-seg button { flex: 1; padding: 10px 8px; }
.diff-note { font-size: 12.5px; color: var(--ink-soft); margin: 7px 0 0; }
select { font: inherit; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); }

.score-box { margin-top: 14px; border: 1px solid var(--accent); border-radius: 10px; padding: 12px 14px; background: var(--panel); }
.score-box h3 { margin: 0 0 4px; font-size: 14px; color: var(--accent); letter-spacing: .02em; }
.score-box .line { font-size: 15px; } .score-box .winner { font-weight: 700; margin-top: 4px; }

.status { min-height: 20px; margin-top: 10px; font-size: 14px; color: var(--ink); }
footer { margin-top: 26px; color: var(--ink-soft); font-size: 12.5px; text-align: center; }
footer a { color: var(--accent); text-decoration: none; }

/* dead-stone marking (scoring mode) */
.stone.dead { opacity: .26; }
.score-hint { font-size: 13.5px; color: var(--ink-soft); margin: 0 0 8px; }
#scoreControls { margin-top: 14px; }

/* mascot guide — art slot stays empty until the licensed 碁石さん art is added */
.mascot-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.mascot { width: 54px; height: 54px; flex: none; }
.mascot-row:has(.mascot[hidden]) { margin-bottom: 10px; }
.mascot-msg { font-size: 13.5px; color: var(--ink); margin: 0; min-height: 18px; font-weight: 500; }

@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
