/* PuzzleShikaku — design system */
:root {
  --bg: #f5f0e6;
  --bg-2: #efe8da;
  --surface: #fffdf8;
  --surface-2: #faf6ee;
  --ink: #1b2232;
  --ink-2: #364055;
  --muted: #646d7e;
  --line: #e3dac8;
  --line-2: #d4c9b3;
  --accent: #f0603f;
  --accent-ink: #ffffff;
  --accent-soft: #fde3da;
  --blue: #2f5fe0;
  --ok: #148a5c;
  --ok-soft: #d6f2e5;
  --bad: #d93a3f;
  --bad-soft: #fbe0e0;
  --warn: #c98a12;
  --rect-l: 85%;
  --rect-s: 78%;
  --rect-border-l: 52%;
  --cell-line: #e8e0cf;
  --board-bg: #fffdf8;
  --shadow-sm: 0 1px 2px rgba(27, 34, 50, .06), 0 1px 1px rgba(27, 34, 50, .04);
  --shadow: 0 10px 30px -12px rgba(27, 34, 50, .25), 0 2px 6px rgba(27, 34, 50, .06);
  --shadow-lg: 0 30px 60px -20px rgba(27, 34, 50, .35);
  --radius: 16px;
  --radius-sm: 10px;
  --font-display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --font-body: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --maxw: 1180px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e131d; --bg-2: #131a27; --surface: #161d2b; --surface-2: #1b2334;
    --ink: #eef1f7; --ink-2: #cdd3df; --muted: #98a1b3; --line: #263049; --line-2: #33405e;
    --accent: #ff7b5c; --accent-ink: #1a0f0b; --accent-soft: #3a2018; --blue: #7b9cff;
    --ok: #3ccf91; --ok-soft: #133528; --bad: #ff6b6f; --bad-soft: #3a1a1d; --warn: #f2b84b;
    --rect-l: 30%; --rect-s: 45%; --rect-border-l: 62%; --cell-line: #222b3f; --board-bg: #121927;
    --shadow: 0 10px 30px -12px rgba(0, 0, 0, .6), 0 2px 6px rgba(0, 0, 0, .3);
    --shadow-lg: 0 30px 60px -20px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e131d; --bg-2: #131a27; --surface: #161d2b; --surface-2: #1b2334;
  --ink: #eef1f7; --ink-2: #cdd3df; --muted: #98a1b3; --line: #263049; --line-2: #33405e;
  --accent: #ff7b5c; --accent-ink: #1a0f0b; --accent-soft: #3a2018; --blue: #7b9cff;
  --ok: #3ccf91; --ok-soft: #133528; --bad: #ff6b6f; --bad-soft: #3a1a1d; --warn: #f2b84b;
  --rect-l: 30%; --rect-s: 45%; --rect-border-l: 62%; --cell-line: #222b3f; --board-bg: #121927;
  --shadow: 0 10px 30px -12px rgba(0, 0, 0, .6), 0 2px 6px rgba(0, 0, 0, .3);
  --shadow-lg: 0 30px 60px -20px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.65 var(--font-body); font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--blue); text-underline-offset: 3px; }
a:hover { color: var(--accent); }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.15; letter-spacing: -.02em; margin: 0 0 .5em; color: var(--ink); }
h1 { font-size: clamp(2rem, 4.6vw, 3.4rem); font-weight: 800; }
h2 { font-size: clamp(1.55rem, 3vw, 2.2rem); font-weight: 750; }
h3 { font-size: 1.22rem; font-weight: 700; }
p { margin: 0 0 1em; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
.nav { display: flex; align-items: center; gap: 18px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-family: var(--font-display); font-weight: 800; font-size: 1.2rem; letter-spacing: -.02em; }
.brand:hover { color: var(--ink); }
.brand-mark { width: 32px; height: 32px; transition: transform .5s cubic-bezier(.2, .9, .3, 1.4); }
.brand:hover .brand-mark { transform: rotate(-8deg) scale(1.06); }
.brand b { color: var(--accent); font-weight: 800; }
.nav-links { display: flex; gap: 2px; margin-left: auto; list-style: none; padding: 0; margin-block: 0; }
.nav-links a { display: block; padding: 8px 12px; border-radius: 999px; text-decoration: none; color: var(--ink-2); font-weight: 550; font-size: .94rem; transition: background .2s, color .2s; }
.nav-links a:hover, .nav-links a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer;
  transition: transform .15s, background .2s, border-color .2s;
}
.icon-btn:hover { border-color: var(--line-2); transform: translateY(-1px); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 20px; height: 20px; }
.menu-btn { display: none; }
.theme-btn .moon { display: none; }
:root[data-theme="dark"] .theme-btn .sun { display: none; }
:root[data-theme="dark"] .theme-btn .moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-btn .sun { display: none; }
  :root:not([data-theme="light"]) .theme-btn .moon { display: block; }
}
@media (max-width: 920px) {
  .menu-btn { display: inline-grid; margin-left: auto; }
  .nav-links {
    position: fixed; inset: 64px 0 auto 0; flex-direction: column; gap: 4px; padding: 14px 16px 22px;
    background: var(--bg); border-bottom: 1px solid var(--line); box-shadow: var(--shadow);
    transform: translateY(-12px); opacity: 0; pointer-events: none; transition: .25s ease;
  }
  .nav-links a { padding: 12px 14px; font-size: 1.02rem; }
  body.menu-open .nav-links { transform: none; opacity: 1; pointer-events: auto; }
}

/* ---------- Buttons ---------- */
.btn {
  --b: var(--surface); --c: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--b); color: var(--c);
  font: 600 .93rem/1.1 var(--font-body); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform .15s ease, box-shadow .2s, background .2s, border-color .2s;
  box-shadow: var(--shadow-sm);
}
.btn:hover { transform: translateY(-1px); border-color: var(--line-2); color: var(--c); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0) scale(.97); }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary { --b: var(--accent); --c: var(--accent-ink); border-color: transparent; }
.btn-primary:hover { border-color: transparent; filter: brightness(1.05); }
.btn-ghost { background: transparent; box-shadow: none; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn-sm { padding: 7px 11px; font-size: .85rem; border-radius: 10px; }

/* ---------- Hero ---------- */
.hero { padding-top: 34px; padding-bottom: 10px; position: relative; }
.hero h1 { margin-bottom: .25em; }
.hero h1 .hl { color: var(--accent); }
.lede { font-size: clamp(1.02rem, 1.6vw, 1.16rem); color: var(--ink-2); max-width: 760px; }
.badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; padding: 0; list-style: none; }
.badges li { font-size: .82rem; font-weight: 600; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line); padding: 5px 11px; border-radius: 999px; display: inline-flex; gap: 6px; align-items: center; }
.badges li::before { content: ""; width: 7px; height: 7px; border-radius: 2px; background: var(--accent); transform: rotate(45deg); }

/* ---------- Game ---------- */
.game-shell { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 22px; align-items: start; margin: 18px 0 40px; }
@media (max-width: 960px) { .game-shell { grid-template-columns: 1fr; } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.game-main { padding: 16px; }
.game-top { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.seg { display: inline-flex; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; position: relative; flex-wrap: wrap; }
.seg button, .seg a {
  border: 0; background: transparent; color: var(--ink-2); font: 600 .85rem/1 var(--font-body);
  padding: 8px 11px; border-radius: 9px; cursor: pointer; transition: background .2s, color .2s, box-shadow .2s; text-decoration: none;
}
.seg button:hover, .seg a:hover { color: var(--ink); }
.seg [aria-pressed="true"], .seg [aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.game-meta { display: flex; gap: 14px; align-items: center; color: var(--muted); font-size: .85rem; flex-wrap: wrap; }
.game-meta strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.mode-label { font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .06em; font-size: .75rem; }

.board-wrap { position: relative; width: 100%; max-width: min(100%, 78vh); margin: 0 auto; aspect-ratio: var(--ar, 1); }
.board {
  position: absolute; inset: 0; border-radius: 14px; background: var(--board-bg);
  border: 2px solid var(--ink); overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none;
  cursor: crosshair; outline: none;
}
.board.is-solved { cursor: default; }
.btn, .icon-btn, .seg button { touch-action: manipulation; }
.board:focus-visible { box-shadow: 0 0 0 4px color-mix(in srgb, var(--blue) 40%, transparent); }
.cells { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(var(--cols), 1fr); grid-template-rows: repeat(var(--rows), 1fr); }
.cell { border-right: 1px solid var(--cell-line); border-bottom: 1px solid var(--cell-line); position: relative; }
.cell.dot::after { content: ""; position: absolute; left: 50%; top: 50%; width: 3px; height: 3px; margin: -1.5px; border-radius: 50%; background: var(--line-2); }
.layer { position: absolute; inset: 0; pointer-events: none; }
.clue {
  position: absolute; display: grid; place-items: center;
  font: 750 calc(var(--cell) * .5)/1 var(--font-display); color: var(--ink); font-variant-numeric: tabular-nums;
  transition: color .3s, transform .3s;
  animation: cluePop .5s cubic-bezier(.2, .9, .3, 1.5) both; animation-delay: var(--d, 0ms);
}
.clue span { display: grid; place-items: center; width: 74%; height: 74%; border-radius: 30%; transition: background .3s, color .3s, transform .35s cubic-bezier(.2, .9, .3, 1.5); }
.clue.done span { color: hsl(var(--h) 70% 22%); transform: scale(1.08); }
:root[data-theme="dark"] .clue.done span { color: hsl(var(--h) 90% 88%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .clue.done span { color: hsl(var(--h) 90% 88%); } }
.clue.err span { color: var(--bad); }
@keyframes cluePop { from { opacity: 0; transform: scale(.3) rotate(-12deg); } to { opacity: 1; transform: none; } }

.rect {
  position: absolute; border-radius: 9px;
  background: hsl(var(--h) var(--rect-s) var(--rect-l) / .92);
  border: 2px solid hsl(var(--h) 55% var(--rect-border-l));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5), 0 2px 6px -2px hsl(var(--h) 60% 40% / .35);
  animation: rectIn .38s cubic-bezier(.2, .9, .3, 1.35) both;
  transition: left .2s, top .2s, width .2s, height .2s, background .3s, border-color .3s;
}
.rect.settled { animation: none; }
.rect.pending { background: color-mix(in srgb, var(--muted) 14%, transparent); border: 2px dashed color-mix(in srgb, var(--muted) 60%, transparent); box-shadow: none; }
.rect.bad.show-bad { background: repeating-linear-gradient(135deg, var(--bad-soft) 0 8px, color-mix(in srgb, var(--bad-soft) 60%, transparent) 8px 16px); border: 2px solid var(--bad); animation: shake .45s ease both; }
.rect.out, .rect.bad.show-bad.out { animation: rectOut .25s ease forwards; pointer-events: none; }
.rect.hinted { animation: rectIn .38s cubic-bezier(.2, .9, .3, 1.35) both, glow 1.6s ease 2; }
.rect.wave { animation: wave .9s cubic-bezier(.2, .9, .3, 1.2) both; animation-delay: var(--wd, 0ms); }
@keyframes rectIn { from { opacity: 0; transform: scale(.82); } to { opacity: 1; transform: none; } }
@keyframes rectOut { to { opacity: 0; transform: scale(.85); } }
@keyframes shake { 0%, 100% { transform: none; } 20% { transform: translateX(-4px); } 40% { transform: translateX(4px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
@keyframes glow { 0%, 100% { box-shadow: 0 0 0 0 hsl(var(--h) 80% 55% / .0); } 50% { box-shadow: 0 0 0 6px hsl(var(--h) 80% 55% / .45); } }
@keyframes wave { 0% { transform: none; } 35% { transform: scale(1.06) translateY(-3px); filter: brightness(1.12) saturate(1.2); } 100% { transform: none; } }

.preview {
  position: absolute; border-radius: 9px; border: 2.5px dashed var(--blue);
  background: color-mix(in srgb, var(--blue) 12%, transparent); transition: left .06s, top .06s, width .06s, height .06s;
  display: none;
}
.preview.fit { border-color: var(--ok); border-style: solid; background: color-mix(in srgb, var(--ok) 16%, transparent); }
.preview.over { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, transparent); }
.preview.show { display: block; }
.preview-tag {
  position: absolute; left: 0; top: 0; z-index: 8; display: none; pointer-events: none;
  background: var(--ink); color: var(--bg); font: 700 .78rem/1 var(--font-body); padding: 6px 9px; border-radius: 8px; white-space: nowrap;
  box-shadow: var(--shadow);
}
.preview-tag.show { display: block; }
.preview-tag.fit { background: var(--ok); color: #fff; }
.cursor { position: absolute; border: 3px solid var(--blue); border-radius: 8px; display: none; transition: left .12s, top .12s; }
.board:focus-visible .cursor, .board.kbd .cursor { display: block; }
.anchor { position: absolute; border: 2px dashed var(--blue); border-radius: 8px; display: none; }

.board-loading { position: absolute; inset: 0; display: grid; place-items: center; background: color-mix(in srgb, var(--board-bg) 70%, transparent); z-index: 5; opacity: 0; pointer-events: none; transition: opacity .25s; border-radius: 14px; }
.board-loading.on { opacity: 1; pointer-events: auto; }
.spinner { display: grid; grid-template-columns: repeat(3, 14px); gap: 4px; }
.spinner i { width: 14px; height: 14px; border-radius: 4px; background: var(--accent); animation: blink 1s ease-in-out infinite; }
.spinner i:nth-child(2n) { background: var(--blue); }
.spinner i:nth-child(3n) { background: var(--ok); }
.spinner i:nth-child(1) { animation-delay: 0s } .spinner i:nth-child(2) { animation-delay: .1s } .spinner i:nth-child(3) { animation-delay: .2s }
.spinner i:nth-child(4) { animation-delay: .1s } .spinner i:nth-child(5) { animation-delay: .2s } .spinner i:nth-child(6) { animation-delay: .3s }
.spinner i:nth-child(7) { animation-delay: .2s } .spinner i:nth-child(8) { animation-delay: .3s } .spinner i:nth-child(9) { animation-delay: .4s }
@keyframes blink { 0%, 100% { transform: scale(.55); opacity: .5; } 50% { transform: scale(1); opacity: 1; } }

.paused-veil { position: absolute; inset: 0; z-index: 6; display: none; place-items: center; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); background: color-mix(in srgb, var(--board-bg) 55%, transparent); border-radius: 14px; }
.paused-veil.on { display: grid; }

.progress { height: 8px; border-radius: 99px; background: var(--bg-2); overflow: hidden; margin: 14px 0 4px; border: 1px solid var(--line); }
.progress > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #ffb347); border-radius: 99px; transition: width .4s cubic-bezier(.2, .8, .2, 1); }
.hint-line { color: var(--muted); font-size: .84rem; text-align: center; margin: 8px 0 0; }
.hint-line kbd, .kbd-list kbd { font: 600 .75rem var(--font-body); background: var(--bg-2); border: 1px solid var(--line); border-bottom-width: 2px; padding: 1px 6px; border-radius: 6px; }

.side { padding: 16px; display: flex; flex-direction: column; gap: 14px; position: sticky; top: 80px; }
@media (max-width: 960px) { .side { position: static; } }
.timer-card { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.timer { font: 800 2.2rem/1 var(--font-display); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.timer small { display: block; font: 600 .72rem/1.2 var(--font-body); color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 4px; }
.tools { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tools .btn { flex-direction: column; gap: 5px; padding: 11px 6px; font-size: .78rem; }
.tools .btn svg { width: 20px; height: 20px; }
.toggles { display: grid; gap: 8px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: .88rem; font-weight: 550; color: var(--ink-2); cursor: pointer; }
.switch input { appearance: none; -webkit-appearance: none; width: 40px; height: 23px; border-radius: 99px; background: var(--line-2); position: relative; cursor: pointer; transition: background .2s; flex: none; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .25s cubic-bezier(.2, .9, .3, 1.4); }
.switch input:checked { background: var(--ok); }
.switch input:checked::after { transform: translateX(17px); }
.side h3 { font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-family: var(--font-body); margin: 0 0 8px; }
.stat-mini { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.stat-mini div { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 8px 4px; }
.stat-mini b { display: block; font: 800 1.25rem/1.1 var(--font-display); font-variant-numeric: tabular-nums; }
.stat-mini span { font-size: .7rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.puzzle-id { font-size: .8rem; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.puzzle-id code { font: 600 .8rem ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink-2); }
.special-banner { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 12px; background: var(--accent-soft); color: var(--ink); font-size: .9rem; margin-bottom: 12px; }
.special-banner strong { font-family: var(--font-display); }

/* ---------- Toast & modal ---------- */
.toast-stack { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 80; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 12px; font-weight: 600; font-size: .9rem; box-shadow: var(--shadow-lg); animation: toastIn .35s cubic-bezier(.2, .9, .3, 1.3) both; max-width: min(92vw, 460px); text-align: center; }
.toast.ok { background: var(--ok); color: #fff; }
.toast.bad { background: var(--bad); color: #fff; }
.toast.leave { animation: toastOut .3s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px) scale(.95); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px); } }
dialog.modal { border: 0; padding: 0; border-radius: 22px; background: var(--surface); color: var(--ink); width: min(94vw, 460px); box-shadow: var(--shadow-lg); }
dialog.modal::backdrop { background: rgba(10, 14, 22, .5); backdrop-filter: blur(4px); }
dialog.modal[open] { animation: modalIn .45s cubic-bezier(.2, .9, .3, 1.25) both; }
@keyframes modalIn { from { opacity: 0; transform: translateY(24px) scale(.94); } }
.modal-body { padding: 26px 24px 22px; text-align: center; }
.modal-body .trophy { width: 74px; height: 74px; margin: 0 auto 8px; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(3deg); } }
.win-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 16px 0; }
.win-stats div { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 10px 6px; }
.win-stats b { display: block; font: 800 1.4rem/1.1 var(--font-display); }
.win-stats span { font-size: .72rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.modal-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.modal-close { position: absolute; top: 12px; right: 12px; }
.stats-table { width: 100%; border-collapse: collapse; font-size: .88rem; margin: 10px 0 16px; text-align: left; }
.stats-table th, .stats-table td { padding: 7px 6px; border-bottom: 1px solid var(--line); }
.stats-table th { color: var(--muted); font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 90; }

/* ---------- Content sections ---------- */
.section { padding: 56px 0; }
.section.alt { background: var(--bg-2); border-block: 1px solid var(--line); }
.eyebrow { font: 700 .76rem/1 var(--font-body); text-transform: uppercase; letter-spacing: .14em; color: var(--accent); margin-bottom: 10px; display: block; }
.section-head { max-width: 760px; margin-bottom: 28px; }
.section-head p { color: var(--ink-2); font-size: 1.05rem; }
.answer-box { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--accent); border-radius: 14px; padding: 20px 22px; box-shadow: var(--shadow-sm); font-size: 1.06rem; }
.answer-box p:last-child { margin: 0; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
@media (max-width: 860px) { .grid-3, .grid-2 { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-sm); transition: transform .25s cubic-bezier(.2, .9, .3, 1.3), box-shadow .25s, border-color .25s; position: relative; }
a.card { text-decoration: none; color: inherit; display: block; }
a.card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: var(--line-2); color: inherit; }
.card .num { font: 800 2.4rem/1 var(--font-display); color: var(--accent); letter-spacing: -.03em; }
.card p { color: var(--ink-2); margin-bottom: 0; font-size: .95rem; }
.card .meta { font-size: .8rem; color: var(--muted); font-weight: 600; margin-top: 10px; display: flex; gap: 10px; flex-wrap: wrap; }
.card .arrow { position: absolute; right: 18px; top: 20px; transition: transform .25s; color: var(--muted); }
a.card:hover .arrow { transform: translateX(4px); color: var(--accent); }
.size-thumb { width: 64px; height: 64px; margin-bottom: 12px; }
.steps { counter-reset: s; display: grid; gap: 14px; padding: 0; list-style: none; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 44px 1fr; gap: 14px; align-items: start; }
.steps li::before { content: counter(s); display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--ink); color: var(--bg); font: 800 1.1rem var(--font-display); }
.figure { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); margin: 0; }
.figure figcaption { font-size: .86rem; color: var(--muted); margin-top: 10px; text-align: center; }
.figure svg { margin: 0 auto; width: 100%; max-width: 340px; height: auto; }
.figure-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin: 22px 0; }
.check-list { list-style: none; padding: 0; display: grid; gap: 10px; }
.check-list li { padding-left: 32px; position: relative; }
.check-list li::before { content: ""; position: absolute; left: 0; top: 3px; width: 20px; height: 20px; border-radius: 6px; background: var(--ok-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5 10.5l3 3 7-7' fill='none' stroke='%23148a5c' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/16px no-repeat; }

/* FAQ */
.faq { display: grid; gap: 10px; }
.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 0 20px; transition: box-shadow .2s, border-color .2s; }
.faq details[open] { box-shadow: var(--shadow); border-color: var(--line-2); }
.faq summary { cursor: pointer; list-style: none; padding: 17px 30px 17px 0; font-weight: 650; font-size: 1.02rem; position: relative; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: ""; position: absolute; right: 0; top: 50%; width: 12px; height: 12px; margin-top: -8px; border-right: 2.5px solid var(--muted); border-bottom: 2.5px solid var(--muted); transform: rotate(45deg); transition: transform .3s; }
.faq details[open] summary::after { transform: rotate(225deg); margin-top: -2px; }
.faq .ans { padding: 0 0 18px; color: var(--ink-2); }
.faq .ans p:last-child { margin: 0; }

/* Article */
.article-hero { padding-top: 40px; padding-bottom: 10px; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: 14px; display: flex; gap: 6px; flex-wrap: wrap; list-style: none; padding: 0; }
.crumbs li + li::before { content: "/"; margin-right: 6px; color: var(--line-2); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }
.byline { font-size: .86rem; color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; }
.article { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 46px; padding-top: 26px; padding-bottom: 70px; }
@media (max-width: 900px) { .article { grid-template-columns: 1fr; gap: 10px; } .toc { position: static !important; } }
.toc { position: sticky; top: 84px; align-self: start; font-size: .88rem; }
.toc strong { display: block; font-size: .74rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin-bottom: 8px; }
.toc ol { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--line); }
.toc a { display: block; padding: 5px 0 5px 14px; color: var(--ink-2); text-decoration: none; margin-left: -2px; border-left: 2px solid transparent; transition: .2s; }
.toc a:hover, .toc a.active { color: var(--accent); border-left-color: var(--accent); }
.prose { max-width: 760px; font-size: 1.04rem; }
.prose h2 { margin-top: 1.8em; scroll-margin-top: 90px; }
.prose h3 { margin-top: 1.5em; scroll-margin-top: 90px; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin-bottom: .4em; }
.prose table { width: 100%; border-collapse: collapse; margin: 1em 0 1.6em; font-size: .94rem; background: var(--surface); border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.prose th, .prose td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.prose th { background: var(--surface-2); font-weight: 700; }
.prose tr:last-child td { border-bottom: 0; }
.table-scroll { overflow-x: auto; }
.callout { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; margin: 1.4em 0; display: grid; grid-template-columns: 30px 1fr; gap: 10px; }
.callout::before { content: "💡"; font-size: 1.2rem; }
.callout.warn::before { content: "⚠️"; }
.callout p:last-child { margin: 0; }
.key-takeaways { background: var(--ink); color: var(--bg); border-radius: 18px; padding: 22px 24px; margin: 1.6em 0; }
.key-takeaways h2, .key-takeaways h3 { color: var(--bg); margin-top: 0; }
.key-takeaways ul { margin: 0; }
.cta-band { background: linear-gradient(120deg, var(--accent), #ff9a5a); color: #fff; border-radius: 22px; padding: 30px; display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin: 30px 0; box-shadow: var(--shadow); }
.cta-band h2, .cta-band h3 { color: #fff; margin: 0 0 4px; }
.cta-band p { margin: 0; opacity: .92; }
.cta-band .btn { --b: #fff; --c: #1b2232; border: 0; }
.glossary dt { font-weight: 700; font-family: var(--font-display); font-size: 1.05rem; margin-top: 1em; }
.glossary dd { margin: 4px 0 0; color: var(--ink-2); }

/* Footer */
.site-footer { background: var(--surface); border-top: 1px solid var(--line); padding: 48px 0 26px; margin-top: 30px; font-size: .92rem; }
.footer-grid { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: 30px; }
@media (max-width: 760px) { .footer-grid { grid-template-columns: 1fr 1fr; } .footer-grid > :first-child { grid-column: 1 / -1; } }
.site-footer h4 { font-size: .78rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-family: var(--font-body); }
.site-footer ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 7px; }
.site-footer a { color: var(--ink-2); text-decoration: none; }
.site-footer a:hover { color: var(--accent); }
.footer-bottom { border-top: 1px solid var(--line); margin-top: 32px; padding-top: 18px; color: var(--muted); display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: .84rem; }

/* Reveal on scroll */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .7s ease, transform .7s cubic-bezier(.2, .8, .2, 1); }
.reveal.in { opacity: 1; transform: none; }

/* Hero decoration */
.deco { position: absolute; right: 0; top: 18px; width: 210px; opacity: .9; pointer-events: none; }
@media (max-width: 1100px) { .deco { display: none; } }
.deco rect { animation: floaty 6s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.deco rect:nth-child(2) { animation-delay: -1s } .deco rect:nth-child(3) { animation-delay: -2s } .deco rect:nth-child(4) { animation-delay: -3s } .deco rect:nth-child(5) { animation-delay: -4s }
@keyframes floaty { 50% { transform: translateY(-6px) rotate(2deg); } }

/* Solver / print tools */
.tool-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.tool-controls label { font-weight: 600; font-size: .9rem; display: inline-flex; gap: 8px; align-items: center; }
select, input[type="number"] { font: 600 .92rem var(--font-body); padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.editor-board .cell { cursor: pointer; display: grid; place-items: center; font: 750 calc(var(--cell) * .5)/1 var(--font-display); transition: background .15s; }
.editor-board .cell:hover { background: var(--accent-soft); }
.editor-board .cell.sel { background: color-mix(in srgb, var(--blue) 18%, transparent); box-shadow: inset 0 0 0 2px var(--blue); }
.print-sheet { display: grid; grid-template-columns: repeat(2, 1fr); gap: 26px; }
.print-item { break-inside: avoid; }
.print-item h3 { font-size: 1rem; margin: 0 0 6px; }
.print-item svg { width: 100%; height: auto; }

@media print {
  .site-header, .site-footer, .side, .game-top, .hint-line, .progress, .no-print, .toast-stack, .section:not(.print-keep), .hero .badges, .lede, .crumbs, .toc { display: none !important; }
  body { background: #fff; color: #000; }
  .game-shell { display: block; margin: 0; }
  .panel { box-shadow: none; border: 0; }
  .board { border-color: #000; }
  .rect { display: none; }
  .print-solution .rect { display: block; }
  .board-wrap { max-width: 16cm; }
  .print-sheet { gap: 1cm; }
  .article { display: block; padding: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .reveal { opacity: 1; transform: none; }
}

@media (max-width: 600px) {
  .wrap { padding: 0 16px; }
  .hero { padding-top: 20px; }
  .game-main { padding: 10px; }
  .game-shell { margin-top: 12px; gap: 14px; }
  .special-banner { flex-wrap: wrap; gap: 2px 10px; font-size: .84rem; padding: 9px 12px; }
  .special-banner span:last-child { margin-left: 0 !important; width: 100%; }
  .game-top .seg { width: 100%; justify-content: space-between; }
  .game-top .seg button { flex: 1; padding: 8px 4px; }
  .section { padding: 40px 0; }
  .cta-band { padding: 22px; }
}
