/* MasyuPuzzles.com — design system */
:root {
  --bg: #f6f3ec;
  --bg-glow: #ece6ff;
  --surface: #ffffff;
  --surface-2: #f1ece3;
  --surface-3: #e9e2d5;
  --ink: #1c1a2e;
  --ink-2: #3b3852;
  --muted: #6d6a83;
  --line: #e2dbcd;
  --grid: #d9d1c2;
  --board: #fffdf8;
  --accent: #5a48d8;
  --accent-ink: #ffffff;
  --accent-soft: #ebe7ff;
  --accent-2: #d9468a;
  --loop: #5a48d8;
  --loop-glow: rgba(90, 72, 216, .35);
  --cross: #b8afa0;
  --ok: #148a63;
  --ok-soft: #dcf5ea;
  --err: #e0393e;
  --err-soft: #fde4e4;
  --warn: #c98a12;
  --pearl-w1: #ffffff;
  --pearl-w2: #e7e2f3;
  --pearl-stroke: #2a2740;
  --pearl-b1: #4a4766;
  --pearl-b2: #0d0c18;
  --shadow-sm: 0 1px 2px rgba(28, 26, 46, .06), 0 1px 1px rgba(28, 26, 46, .04);
  --shadow: 0 10px 30px -12px rgba(28, 26, 46, .22), 0 2px 6px rgba(28, 26, 46, .06);
  --shadow-lg: 0 30px 60px -20px rgba(28, 26, 46, .35);
  --radius: 14px;
  --radius-lg: 22px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --max: 1160px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0e19; --bg-glow: #1d1840; --surface: #161829; --surface-2: #1d2036; --surface-3: #262a45;
    --ink: #eceaf6; --ink-2: #cbc8de; --muted: #9b98b6; --line: #2a2e4b; --grid: #31365a; --board: #12142a;
    --accent: #8f81ff; --accent-ink: #0d0e19; --accent-soft: #262150; --accent-2: #ff6fae;
    --loop: #a395ff; --loop-glow: rgba(163, 149, 255, .45); --cross: #5d6185;
    --ok: #3ed29c; --ok-soft: #133a2e; --err: #ff6267; --err-soft: #3d1a20; --warn: #f0b443;
    --pearl-w1: #ffffff; --pearl-w2: #cfc9e6; --pearl-stroke: #d9d5ee; --pearl-b1: #55527a; --pearl-b2: #050510;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow: 0 12px 34px -12px rgba(0,0,0,.6); --shadow-lg: 0 30px 70px -20px rgba(0,0,0,.75);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d0e19; --bg-glow: #1d1840; --surface: #161829; --surface-2: #1d2036; --surface-3: #262a45;
  --ink: #eceaf6; --ink-2: #cbc8de; --muted: #9b98b6; --line: #2a2e4b; --grid: #31365a; --board: #12142a;
  --accent: #8f81ff; --accent-ink: #0d0e19; --accent-soft: #262150; --accent-2: #ff6fae;
  --loop: #a395ff; --loop-glow: rgba(163, 149, 255, .45); --cross: #5d6185;
  --ok: #3ed29c; --ok-soft: #133a2e; --err: #ff6267; --err-soft: #3d1a20; --warn: #f0b443;
  --pearl-w1: #ffffff; --pearl-w2: #cfc9e6; --pearl-stroke: #d9d5ee; --pearl-b1: #55527a; --pearl-b2: #050510;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow: 0 12px 34px -12px rgba(0,0,0,.6); --shadow-lg: 0 30px 70px -20px rgba(0,0,0,.75);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; font-family: var(--font); font-size: 17px; line-height: 1.65; color: var(--ink);
  background: var(--bg);
  background-image: radial-gradient(1200px 500px at 85% -10%, var(--bg-glow), transparent 60%),
                    radial-gradient(900px 400px at -10% 10%, var(--bg-glow), transparent 55%);
  background-repeat: no-repeat;
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s, color .3s;
}
img, svg { max-width: 100%; }
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1.5px; }
a:hover { color: var(--accent-2); }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 650; line-height: 1.15; letter-spacing: -.015em; margin: 1.6em 0 .55em; color: var(--ink); }
h1 { font-size: clamp(2.1rem, 4.6vw, 3.6rem); margin-top: .2em; font-variation-settings: "SOFT" 50, "opsz" 120; }
h2 { font-size: clamp(1.55rem, 2.8vw, 2.2rem); }
h3 { font-size: 1.3rem; }
p { margin: 0 0 1.05em; }
ul, ol { padding-left: 1.3em; }
li { margin: .3em 0; }
code, kbd { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88em; }
kbd { background: var(--surface-2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: .05em .4em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2.5em 0; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--accent-ink); padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 20px; }
.prose { max-width: 760px; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* ---------- header ---------- */
.site-header { position: sticky; top: 0; z-index: 40; backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px);
  background: color-mix(in srgb, var(--bg) 78%, transparent); 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: 700; font-size: 1.28rem; letter-spacing: -.02em; }
.brand:hover { color: var(--ink); }
.brand .logo { width: 34px; height: 34px; flex: none; }
.brand small { font-family: var(--font); font-weight: 500; font-size: .7rem; color: var(--muted); letter-spacing: .02em; display: block; margin-top: -4px; }
.nav > nav { margin-left: auto; }
.nav-links { display: flex; align-items: center; gap: 2px; list-style: none; padding: 0; margin: 0; }
.nav-links li { margin: 0; }
.nav-links a { display: block; padding: 8px 12px; border-radius: 10px; text-decoration: none; color: var(--ink-2); font-weight: 550; font-size: .95rem; white-space: nowrap; transition: background .2s, color .2s; }
.nav-links a:hover { background: var(--surface-2); color: var(--ink); }
.nav-links a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.icon-btn { width: 40px; height: 40px; display: inline-grid; place-items: center; flex: none; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; transition: transform .15s, background .2s; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 20px; height: 20px; }
.menu-btn { display: none; }
@media (max-width: 960px) {
  .nav > nav { margin-left: 0; }
  .nav > [data-action="theme"] { margin-left: auto; }
  .menu-btn { display: inline-grid; order: 3; }
  .nav-links { display: none; position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; align-items: stretch; gap: 2px;
    background: var(--surface); border-bottom: 1px solid var(--line); padding: 10px 16px 16px; box-shadow: var(--shadow); max-height: calc(100vh - 64px); overflow-y: auto; }
  .nav-links.open { display: flex; animation: menuIn .22s ease; }
  .nav-links a { padding: 12px 14px; font-size: 1.05rem; }
}
@keyframes menuIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ---------- buttons ---------- */
.btn { --b: var(--surface); display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; min-height: 42px; border-radius: 12px; border: 1px solid var(--line); background: var(--b); color: var(--ink); font: 600 .95rem/1 var(--font); cursor: pointer; text-decoration: none; transition: transform .15s ease, background .2s, box-shadow .2s, border-color .2s; user-select: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); color: var(--ink); }
.btn:active { transform: translateY(1px) scale(.98); }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn.primary { background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 70%, var(--accent-2))); color: var(--accent-ink); border-color: transparent; box-shadow: 0 8px 20px -8px var(--loop-glow); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 34px; padding: 6px 11px; font-size: .86rem; border-radius: 10px; }
.btn.lg { min-height: 52px; padding: 14px 24px; font-size: 1.05rem; border-radius: 14px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn.active, .btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ---------- hero ---------- */
.hero { padding: 34px 0 10px; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: .78rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); background: var(--accent-soft); padding: 6px 12px; border-radius: 999px; }
.lede { font-size: 1.15rem; color: var(--ink-2); max-width: 680px; }
.breadcrumbs { font-size: .85rem; color: var(--muted); margin: 18px 0 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.breadcrumbs li:not(:last-child)::after { content: "›"; margin-left: 6px; opacity: .6; }
.breadcrumbs a { color: var(--muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--accent); }

/* ---------- game layout ---------- */
.play-area { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 26px; align-items: start; margin: 18px 0 30px; }
@media (max-width: 960px) { .play-area { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.game-card { padding: 18px; position: relative; }
@media (max-width: 560px) { .game-card { padding: 12px; border-radius: 18px; } }
.picker { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin-bottom: 14px; }
.seg { display: inline-flex; background: var(--surface-2); padding: 4px; border-radius: 12px; gap: 2px; flex-wrap: wrap; }
.seg button, .seg a { border: 0; background: transparent; color: var(--ink-2); font: 600 .88rem/1 var(--font); padding: 9px 12px; border-radius: 9px; cursor: pointer; text-decoration: none; transition: background .2s, color .2s; }
.seg button:hover, .seg a:hover { color: var(--ink); }
.seg button[aria-pressed="true"], .seg a[aria-current="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.seg .d-easy[aria-pressed="true"] { color: var(--ok); }
.seg .d-medium[aria-pressed="true"] { color: var(--warn); }
.seg .d-hard[aria-pressed="true"] { color: var(--err); }

.game-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.game-title { font-family: var(--font-display); font-weight: 650; font-size: 1.2rem; margin: 0; display: flex; align-items: center; gap: 10px; }
.badge { display: inline-flex; align-items: center; gap: 6px; font: 700 .72rem/1 var(--font); letter-spacing: .06em; text-transform: uppercase; padding: 5px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.badge.easy { background: var(--ok-soft); color: var(--ok); }
.badge.medium { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.badge.hard { background: var(--err-soft); color: var(--err); }
.badge.solved { background: var(--ok); color: #fff; }
.timer { font: 650 1.05rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; font-variant-numeric: tabular-nums; display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); background: var(--surface-2); padding: 8px 12px; border-radius: 10px; }
.timer.hidden-time .t { filter: blur(5px); }
.nav-puzzle { display: inline-flex; gap: 6px; align-items: center; }
.nav-puzzle .num { font-weight: 650; min-width: 64px; text-align: center; font-variant-numeric: tabular-nums; }

.board-wrap { position: relative; display: grid; place-items: center; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.board { width: 100%; max-width: min(720px, 78vh); height: auto; display: block; border-radius: 16px; cursor: crosshair; overflow: visible; }
.board .bg { fill: var(--board); stroke: var(--line); stroke-width: 1.5; }
.board .gridline { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.board .dot { fill: var(--grid); }
.board .cell-hl { fill: var(--accent); opacity: 0; transition: opacity .15s; }
.board .cell-hl.on { opacity: .08; }
.board .cursor { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-dasharray: 5 4; opacity: 0; rx: 6; }
.board.kbd .cursor { opacity: 1; }
.board .edge { stroke: var(--loop); stroke-width: 7; stroke-linecap: round; opacity: 0; pointer-events: none; }
.board .edge.on { opacity: 1; animation: drawIn .22s cubic-bezier(.3, .9, .4, 1.3); }
.board .edge.hint { stroke: var(--ok); animation: hintPulse 1.2s ease-in-out 3; }
.board .edge.wrong { stroke: var(--err); animation: shake .4s ease-in-out 2; }
.board .x { stroke: var(--cross); stroke-width: 2.4; stroke-linecap: round; opacity: 0; transform-box: fill-box; transform-origin: center; pointer-events: none; }
.board .x.on { opacity: 1; animation: popIn .22s cubic-bezier(.3, 1.6, .5, 1); }
.board .x.wrong line { stroke: var(--err); }
.board .pearl { transform-box: fill-box; transform-origin: center; transition: transform .25s; }
.board .pearl .ring { fill: none; stroke: var(--ok); stroke-width: 3; opacity: 0; transition: opacity .3s, stroke .3s; }
.board .pearl.ok .ring { opacity: .85; }
.board .pearl.err .ring { opacity: 1; stroke: var(--err); animation: errPulse 1s ease-in-out infinite; }
.board .pearl.white .body { stroke: var(--pearl-stroke); stroke-width: 2.2; }
.board .pearl.black .body { stroke: var(--pearl-b2); stroke-width: 1.2; }
.board .pearl .shine { fill: #fff; opacity: .75; pointer-events: none; }
.board .pearl.black .shine { opacity: .35; }
.board .cellerr { fill: var(--err); opacity: 0; transition: opacity .2s; }
.board .cellerr.on { opacity: .16; }
.board.solved .edge.on { stroke: var(--loop); filter: drop-shadow(0 0 6px var(--loop-glow)); }
.board .win-path { fill: none; stroke: #fff; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; opacity: .9; pointer-events: none; mix-blend-mode: overlay; }
.board.solved .pearl { animation: pearlPop .6s cubic-bezier(.3, 1.7, .5, 1) both; }
.board.revealed .edge.on { stroke: var(--muted); }
.board.paused { filter: blur(12px) saturate(.4); pointer-events: none; }

@keyframes drawIn { from { stroke-width: 0; opacity: .3; } to { stroke-width: 7; opacity: 1; } }
@keyframes popIn { from { transform: scale(.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes hintPulse { 0%, 100% { stroke-width: 7; filter: none; } 50% { stroke-width: 11; filter: drop-shadow(0 0 8px var(--ok)); } }
@keyframes shake { 0%, 100% { transform: none; } 25% { transform: translateX(-2px); } 75% { transform: translateX(2px); } }
@keyframes errPulse { 0%, 100% { stroke-width: 3; } 50% { stroke-width: 5; } }
@keyframes pearlPop { 0% { transform: scale(1); } 40% { transform: scale(1.35); } 100% { transform: scale(1); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }

.pause-overlay { position: absolute; inset: 0; display: none; place-items: center; z-index: 5; }
.pause-overlay.show { display: grid; }
.pause-overlay .btn { box-shadow: var(--shadow-lg); }
.loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-weight: 600; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; }
.toolbar .sep { width: 1px; background: var(--line); margin: 4px 2px; }
.status { min-height: 26px; text-align: center; font-weight: 600; font-size: .95rem; margin-top: 10px; color: var(--muted); transition: color .2s; }
.status.good { color: var(--ok); }
.status.bad { color: var(--err); }
.progress { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 12px; }
.progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: inherit; transition: width .35s ease; }

.side { display: grid; gap: 16px; }
.side .card { padding: 18px 20px; }
.side h2, .side h3 { margin: 0 0 10px; font-size: 1.12rem; }
.rules-mini { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.rules-mini li { display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: start; margin: 0; font-size: .93rem; line-height: 1.5; color: var(--ink-2); }
.rules-mini svg { width: 30px; height: 30px; }
.controls-list { font-size: .88rem; color: var(--ink-2); margin: 0; padding-left: 1.1em; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.stat-grid div { background: var(--surface-2); border-radius: 12px; padding: 10px 4px; }
.stat-grid b { display: block; font-size: 1.3rem; font-family: var(--font-display); }
.stat-grid span { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 650; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 80; display: none; place-items: center; padding: 16px; background: rgba(10, 9, 20, .5); backdrop-filter: blur(6px); }
.modal.show { display: grid; animation: fadeIn .25s ease; }
.modal .dialog { width: min(460px, 100%); max-height: 90vh; overflow: auto; background: var(--surface); border-radius: 24px; padding: 28px; box-shadow: var(--shadow-lg); border: 1px solid var(--line); animation: fadeUp .35s cubic-bezier(.2, .9, .3, 1.2); position: relative; }
.modal h2 { margin: 0 0 6px; text-align: center; }
.modal .close { position: absolute; top: 14px; right: 14px; }
.win-icon { width: 84px; height: 84px; margin: 0 auto 8px; display: block; }
.win-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0; text-align: center; }
.win-stats div { background: var(--surface-2); border-radius: 14px; padding: 12px 6px; }
.win-stats b { display: block; font-size: 1.35rem; font-family: var(--font-display); }
.win-stats span { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; }
.modal .actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: .95rem; }
.setting:last-child { border-bottom: 0; }
.setting small { display: block; color: var(--muted); font-size: .8rem; }
.switch { position: relative; width: 46px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--surface-3); border-radius: 99px; transition: background .2s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .25s cubic-bezier(.3, 1.4, .5, 1); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
select.input, input.input { font: 500 .95rem var(--font); padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 600; font-size: .92rem; opacity: 0; pointer-events: none; transition: all .3s cubic-bezier(.2, .9, .3, 1.2); z-index: 90; box-shadow: var(--shadow-lg); max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 85; width: 100%; height: 100%; }

/* ---------- content ---------- */
.section { padding: 40px 0; }
.section-head { max-width: 720px; margin-bottom: 26px; }
.section-head h2 { margin-top: 0; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 18px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 22px; }
.feature { padding: 22px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); transition: transform .25s, box-shadow .25s; }
.feature:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.feature h3 { margin: 10px 0 6px; font-size: 1.15rem; }
.feature p { margin: 0; color: var(--ink-2); font-size: .95rem; }
.feature .ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.feature .ic svg { width: 24px; height: 24px; }
a.feature { text-decoration: none; color: inherit; display: block; }
.size-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.size-card { display: block; text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px; text-align: center; transition: transform .2s, border-color .2s, box-shadow .2s; }
.size-card:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: var(--shadow); color: var(--ink); }
.size-card svg { width: 72px; height: 72px; display: block; margin: 0 auto 8px; }
.size-card b { font-family: var(--font-display); font-size: 1.25rem; display: block; }
.size-card span { color: var(--muted); font-size: .82rem; }
.callout { border-radius: 18px; padding: 18px 20px; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); margin: 1.4em 0; }
.callout.tip { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.callout.warn { background: var(--err-soft); border-color: color-mix(in srgb, var(--err) 30%, transparent); }
.callout > :last-child { margin-bottom: 0; }
.callout strong:first-child { display: block; margin-bottom: 4px; }
.answer-box { border-left: 4px solid var(--accent); background: var(--surface); padding: 16px 20px; border-radius: 0 14px 14px 0; margin: 1em 0 1.6em; box-shadow: var(--shadow-sm); }
.answer-box p:last-child { margin: 0; }
figure.diagram { margin: 1.4em 0 1.8em; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 18px; text-align: center; }
figure.diagram .pair { display: flex; gap: 22px; justify-content: center; flex-wrap: wrap; align-items: center; }
figure.diagram svg.mini { width: 200px; max-width: 42vw; height: auto; }
figure.diagram .arrow { font-size: 1.6rem; color: var(--muted); }
figure.diagram figcaption { font-size: .9rem; color: var(--muted); margin-top: 10px; }
.technique { border: 1px solid var(--line); border-radius: 22px; padding: 6px 24px 18px; background: var(--surface); margin: 24px 0; box-shadow: var(--shadow-sm); }
.technique h3 { display: flex; align-items: center; gap: 10px; }
.technique h3 .n { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-family: var(--font); font-size: .9rem; flex: none; }
.technique figure.diagram { background: var(--surface-2); border: 0; }
.toc { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px 20px; margin: 1.4em 0; }
.toc ol { margin: .4em 0 0; columns: 2; column-gap: 28px; font-size: .95rem; }
@media (max-width: 600px) { .toc ol { columns: 1; } }
details.faq { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 0 20px; margin: 10px 0; transition: box-shadow .2s; }
details.faq[open] { box-shadow: var(--shadow); }
details.faq summary { cursor: pointer; list-style: none; padding: 16px 0; font-weight: 650; display: flex; justify-content: space-between; gap: 12px; }
details.faq summary::-webkit-details-marker { display: none; }
details.faq summary::after { content: "+"; font-size: 1.4rem; line-height: 1; color: var(--accent); transition: transform .25s; }
details.faq[open] summary::after { transform: rotate(45deg); }
details.faq > div { padding-bottom: 14px; color: var(--ink-2); }
table.data { width: 100%; border-collapse: collapse; font-size: .95rem; margin: 1em 0 1.6em; background: var(--surface); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow-sm); }
table.data th, table.data td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { background: var(--surface-2); font-weight: 650; }
.table-scroll { overflow-x: auto; }
dl.glossary dt { font-family: var(--font-display); font-weight: 650; font-size: 1.15rem; margin-top: 1.3em; }
dl.glossary dd { margin: .3em 0 0; color: var(--ink-2); }
.author-box { display: flex; gap: 14px; align-items: center; font-size: .88rem; color: var(--muted); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 12px 0; margin: 1.2em 0 2em; flex-wrap: wrap; }
.cta-band { margin: 50px 0; padding: 38px; border-radius: 28px; background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, var(--accent-2))); color: #fff; display: flex; justify-content: space-between; align-items: center; gap: 22px; flex-wrap: wrap; box-shadow: var(--shadow-lg); }
.cta-band h2 { color: #fff; margin: 0 0 6px; }
.cta-band p { margin: 0; opacity: .9; }
.cta-band .btn { background: #fff; color: #1c1a2e; border: 0; }
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .6s ease, transform .6s ease; }
.reveal.in { opacity: 1; transform: none; }

/* library */
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 12px; }
.lib-item { display: block; text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px; text-align: center; font-size: .85rem; font-weight: 650; transition: transform .2s, border-color .2s; position: relative; }
.lib-item:hover { transform: translateY(-2px); border-color: var(--accent); color: var(--ink); }
.lib-item svg { width: 100%; height: auto; display: block; margin-bottom: 6px; }
.lib-item.done { border-color: var(--ok); }
.lib-item.done::after { content: "✓"; position: absolute; top: 6px; right: 8px; width: 22px; height: 22px; border-radius: 50%; background: var(--ok); color: #fff; font-size: .75rem; display: grid; place-items: center; }
.lib-item.progress-saved::after { content: "…"; position: absolute; top: 6px; right: 8px; width: 22px; height: 22px; border-radius: 50%; background: var(--warn); color: #fff; font-size: .75rem; display: grid; place-items: center; }

/* solver page */
.solver-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center; margin: 12px 0; }

/* ---------- footer ---------- */
.site-footer { margin-top: 70px; border-top: 1px solid var(--line); background: var(--surface); padding: 46px 0 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; } }
.site-footer h3 { font-family: var(--font); font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 0 0 12px; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin: 7px 0; }
.site-footer a { color: var(--ink-2); text-decoration: none; }
.site-footer a:hover { color: var(--accent); }
.copyright { margin-top: 34px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; }

/* ---------- print ---------- */
.print-only { display: none; }
@media print {
  :root { --board: #fff; --grid: #999; --loop: #000; --pearl-stroke: #000; }
  body { background: #fff !important; color: #000; font-size: 12pt; }
  .site-header, .site-footer, .toolbar, .picker, .side, .no-print, .cta-band, .status, .progress, .timer, .nav-puzzle, .skip { display: none !important; }
  .card { box-shadow: none; border: 0; }
  .play-area { display: block; }
  .board { max-width: 16cm; max-height: 16cm; margin: 0 auto; }
  .print-only { display: block; }
  .print-sheet { page-break-after: always; }
}

@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; }
}

/* theme toggle icon */
.t-sun { display: none; } .t-moon { display: inline-flex; }
:root[data-theme="dark"] .t-sun { display: inline-flex; } :root[data-theme="dark"] .t-moon { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .t-sun { display: inline-flex; } :root:not([data-theme="light"]) .t-moon { display: none; } }

/* ---------- small screens ---------- */
.play-area > * { min-width: 0; }
@media (max-width: 960px) { .play-area { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 560px) {
  .wrap { padding: 0 16px; }
  .game-card { padding: 10px; }
  .picker { gap: 8px; margin-bottom: 10px; }
  .seg button, .seg a { padding: 8px 9px; font-size: .82rem; }
  .game-head { gap: 8px; }
  .game-title { font-size: 1.05rem; }
  .nav-puzzle { gap: 4px; flex-wrap: wrap; }
  .nav-puzzle .num { min-width: 0; font-size: .9rem; }
  .nav-puzzle [data-cmd="random"] span { display: none; }
  .timer { padding: 6px 9px; font-size: .95rem; }
  .toolbar { gap: 6px; }
  .toolbar .sep { display: none; }
  .toolbar .btn span { display: none; }
  .toolbar .btn { padding: 10px 13px; }
  .board-wrap { margin: 0 -4px; }
  .cta-band { padding: 26px; }
  figure.diagram .pair { gap: 12px; }
}
