:root {
  --bg: #0b1020; --panel: #131a2e; --board: #0f1528; --line: #26304d;
  --text: #e8ecf6; --muted: #9aa6c4; --accent: #ffb020; --accent-ink: #1b1300;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
.wrap { max-width: 860px; margin: 0 auto; padding: 0 16px; }

.site-head { border-bottom: 1px solid var(--line); }
.site-head .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 56px; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 700; font-size: 18px; text-decoration: none; }
.brand svg { width: 26px; height: 26px; }
.nav { display: flex; gap: 18px; }
.nav a { color: var(--muted); text-decoration: none; font-size: 15px; }
.nav a:hover, .nav a[aria-current] { color: var(--text); }

h1 { font-size: clamp(26px, 5vw, 36px); line-height: 1.2; margin: 24px 0 8px; }
h2 { font-size: 23px; line-height: 1.3; margin: 40px 0 10px; }
h3 { font-size: 18px; margin: 24px 0 6px; }
.lede { color: var(--muted); margin: 0 0 18px; max-width: 62ch; }
p, li { max-width: 70ch; }

.game { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.hud { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; font-size: 15px; }
.hud .stat { color: var(--muted); }
.hud .stat b { color: var(--text); font-variant-numeric: tabular-nums; }
.hearts { color: #ff5d73; font-size: 20px; letter-spacing: 2px; }
.stage { position: relative; display: flex; justify-content: center; background: var(--board); border-radius: 10px; overflow: hidden; }
.stage canvas { display: block; touch-action: manipulation; cursor: pointer; }
.overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 20px; text-align: center; background: rgba(11, 16, 32, 0.88); }
.overlay[hidden] { display: none; }
.overlay h2 { margin: 0; }
.overlay p { margin: 0 0 6px; color: var(--muted); }
.controls { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.controls .spacer { flex: 1; }
button { font: inherit; color: var(--text); background: #1d2742; border: 1px solid var(--line); border-radius: 9px; padding: 8px 14px; min-height: 40px; cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: 0.4; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }

.steps { padding-left: 20px; }
table { border-collapse: collapse; width: 100%; max-width: 560px; font-size: 15px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; }
details { border-bottom: 1px solid var(--line); padding: 12px 0; max-width: 70ch; }
summary { cursor: pointer; font-weight: 600; }
details p { margin: 8px 0 0; color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.card { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; color: var(--text); text-decoration: none; }
.card:hover { border-color: var(--accent); }
.card span { display: block; color: var(--muted); font-size: 14px; }

.spinner { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 22px 12px; }
.dial { width: min(300px, 78vw); aspect-ratio: 1; border-radius: 50%; background: var(--board); border: 2px solid var(--line); position: relative; }
.dial svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.dial .needle { transform-origin: 50% 50%; transition: transform 2.6s cubic-bezier(0.12, 0.7, 0.1, 1); }
.result { font-size: 24px; font-weight: 700; min-height: 1.6em; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.opts button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.history { color: var(--muted); font-size: 14px; text-align: center; min-height: 1.6em; }

.site-foot { border-top: 1px solid var(--line); margin-top: 56px; padding: 22px 0 34px; color: var(--muted); font-size: 14px; }
.site-foot .wrap { display: flex; flex-wrap: wrap; gap: 8px 18px; justify-content: space-between; }
.site-foot a { color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .dial .needle { transition-duration: 0.01s; } }

.crumbs { margin: 18px 0 -14px; font-size: 14px; color: var(--muted); }
.jump a { display: inline-block; min-width: 34px; padding: 4px 8px; margin: 0 4px 6px 0; text-align: center; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; }
.sol-board { display: block; width: 100%; height: auto; margin: 12px 0; }
.moves { columns: 2; column-gap: 32px; color: var(--muted); font-size: 15px; }
.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 36px; }
@media (max-width: 520px) {
  .site-head .wrap { flex-wrap: wrap; height: auto; padding-top: 10px; padding-bottom: 10px; row-gap: 6px; }
  .moves { columns: 1; }
}

th[scope="row"] { white-space: nowrap; width: 1%; padding-right: 18px; }
