/* Puzzlune — "Moonlit" design system (approved 2026-09-25, preview in _design/design-system-2026-09-25.html).
 * Page chrome follows [data-theme]. Game boards use the same tokens; each game adds its own board CSS in css/<slug>.css.
 * Rules: moon gold only where something happens (primary button, solved state, placed piece); lavender for links/emphasis.
 */
:root {
  --bg: #f4f2fb; --surface: #ffffff; --surface-2: #ebe8f6; --line: #d9d4ec; --line-strong: #c2bce0;
  --ink: #1b1a3f; --ink-soft: #5a577f; --ink-faint: #6b6890;
  --accent: #e9b54a; --accent-ink: #2a2000; --accent-2: #6d66e0; --good: #2fa37a; --bad: #d95c4a;
  --ico-bg: #efeafb; --ico-ink: #3f3a8a;
  --board-bg: #ffffff; --cell: #ece9f6; --reg1: #fdf0d1; --reg2: #e6e2fb; --reg3: #d9f3ea; --reg4: #fde2df; --reg5: #e2eefb; --reg6: #f3e4f7;
  --tile: #1b1a3f; --tile-ink: #f6f2ff; --solved-bg: #fdf3da; --solved-ink: #4a3600;
  --shadow: 0 1px 2px rgba(27, 26, 63, .05); --shadow-hover: 0 10px 26px rgba(27, 26, 63, .12); --btn-shadow: 0 6px 16px rgba(233, 181, 74, .35);
  --display: 'Bricolage Grotesque', system-ui, sans-serif; --body: 'Figtree', system-ui, -apple-system, sans-serif;
  --r: 16px; --r-btn: 12px; --r-cell: 10px;
}
[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0f0e24; --surface: #181736; --surface-2: #22214a; --line: #2e2d5b; --line-strong: #43427a;
  --ink: #efedff; --ink-soft: #b4b1d6; --ink-faint: #918eba;
  --accent: #f2c25a; --accent-ink: #1a1300; --accent-2: #9a94ff; --good: #4fd0a0; --bad: #ff7d6a;
  --ico-bg: #262457; --ico-ink: #c9c4ff;
  --board-bg: #141331; --cell: #22214a; --reg1: #3a3120; --reg2: #2c2a63; --reg3: #1e3a35; --reg4: #3d2635; --reg5: #22315a; --reg6: #3a2a4d;
  --tile: #f2c25a; --tile-ink: #1a1300; --solved-bg: #2b2650; --solved-ink: #f6e7b8;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-hover: 0 10px 26px rgba(0, 0, 0, .45); --btn-shadow: 0 6px 16px rgba(242, 194, 90, .25);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 17px; line-height: 1.55; }
a { color: var(--accent-2); text-underline-offset: 3px; }
a:hover { color: var(--ink); }
:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); line-height: 1.12; margin: .2em 0 .4em; letter-spacing: -.02em; text-wrap: balance; }
h1 { font-weight: 800; font-size: clamp(28px, 4.2vw, 38px); }
h2 { font-weight: 700; font-size: clamp(21px, 3vw, 26px); margin-top: 1.4em; }
h3 { font-weight: 700; font-size: 18px; margin-top: 1.2em; }
p { margin: .5em 0 .9em; }
.num { font-variant-numeric: tabular-nums; }
.muted, .note { color: var(--ink-soft); font-size: 14px; }
.wrap { max-width: 1020px; margin: 0 auto; padding: 0 16px; }
.wrap-narrow { max-width: 720px; margin: 0 auto; padding: 0 16px; }
.wrap-game { max-width: 640px; margin: 0 auto; padding: 0 16px; }
.eyebrow { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-faint); font-weight: 700; margin: 0 0 8px; }
.lede { color: var(--ink-soft); font-size: 18px; max-width: 58ch; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- Header ---------- */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 40; }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 58px; }
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); }
.brand-mark { width: 28px; height: 28px; flex: none; }
.brand-mark .moon { fill: var(--accent); } .brand-mark .piece { fill: var(--accent-2); }
.brand-name { font-family: var(--display); font-weight: 800; font-size: 21px; letter-spacing: -.02em; white-space: nowrap; }
.site-nav { display: flex; align-items: center; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.site-nav::-webkit-scrollbar { display: none; }
.site-nav a { text-decoration: none; color: var(--ink-soft); font-size: 14px; font-weight: 600; padding: 7px 9px; white-space: nowrap; border-radius: 8px; }
.site-nav a:hover { color: var(--ink); }
.site-nav a[aria-current='page'] { color: var(--ink); background: var(--surface-2); }
.theme-toggle { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); display: grid; place-items: center; font-size: 14px; flex: none; cursor: pointer; padding: 0; }
.site-header .right { display: flex; align-items: center; gap: 4px; min-width: 0; }
@media (max-width: 560px) {
  .site-header .wrap { flex-wrap: wrap; min-height: 0; padding-top: 8px; padding-bottom: 6px; row-gap: 2px; }
  .brand { order: 1; } .site-header .theme-toggle { order: 2; margin-left: auto; }
  .site-header .right { order: 3; flex-basis: 100%; }
  .site-nav { width: 100%; margin: 0 -16px; padding: 0 12px; }
  .site-nav a { padding: 6px 8px; font-size: 13px; }
}

/* ---------- Home ---------- */
main { padding: 8px 0 64px; }
.hero { padding: 26px 0 8px; }
.hero h1 { max-width: 22ch; margin-bottom: 10px; }
.hero h1 em { font-style: normal; color: var(--accent-2); }
.hero p { color: var(--ink-soft); margin: 0; max-width: 56ch; }
.game-grid { list-style: none; margin: 0; padding: 20px 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
@media (max-width: 480px) { .game-grid { grid-template-columns: 1fr 1fr; gap: 10px; } }
.game-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); transition: transform .15s ease, box-shadow .15s ease; }
.game-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.game-card a, .game-card > span.game-card-body { text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: 10px; padding: 14px; height: 100%; }
.game-card-soon { opacity: .75; }
.game-card .ico { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: var(--ico-ink); background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--ico-bg) 70%, #fff) 0, var(--ico-bg) 60%); }
[data-theme='dark'] .game-card .ico { background: radial-gradient(circle at 35% 30%, #33307a 0, var(--ico-bg) 60%); }
.game-card .ico svg { width: 26px; height: 26px; }
.game-card-name { font-family: var(--display); font-weight: 700; font-size: 19px; line-height: 1.15; color: var(--ink); letter-spacing: -.01em; }
.game-card-tag { font-size: 13px; color: var(--ink-soft); line-height: 1.35; }
.game-card-status { margin-top: auto; font-size: 12px; color: var(--ink-faint); display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.game-card-status i { width: 7px; height: 7px; border-radius: 50%; background: var(--good); display: inline-block; }
.game-card-status.done i { background: var(--accent); }

/* ---------- Buttons ---------- */
.btn { font-family: var(--body); font-weight: 700; font-size: 15px; padding: 11px 18px; border-radius: var(--r-btn); border: 1.5px solid transparent; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; line-height: 1; background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn:hover { border-color: var(--ink-faint); color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; box-shadow: var(--btn-shadow); }
.btn-primary:hover { color: var(--accent-ink); border-color: transparent; filter: brightness(1.04); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn-icon { width: 40px; height: 40px; padding: 0; border-color: var(--line); }
.btn-big { font-size: 17px; padding: 14px 24px; }
.btn-small { font-size: 13px; padding: 7px 12px; }

/* ---------- Game page shell (shared by every game) ---------- */
.gp-head { padding: 20px 0 8px; display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: flex-end; justify-content: space-between; }
.gp-head h1 { font-size: clamp(24px, 3vw, 30px); margin: 0; }
.gp-head .meta { color: var(--ink-soft); font-size: 14px; margin: 4px 0 0; }
.gp-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 0 12px; }
.gp-tabs::-webkit-scrollbar { display: none; }
.gp-tabs a { font-size: 13px; font-weight: 700; padding: 7px 12px; border-radius: 999px; text-decoration: none; color: var(--ink-soft); border: 1px solid var(--line); white-space: nowrap; }
.gp-tabs a:hover { color: var(--ink); }
.gp-tabs a[aria-current='page'] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.gp-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 0 0 12px; font-variant-numeric: tabular-nums; }
.gp-bar .t { font-family: var(--display); font-weight: 700; font-size: 22px; letter-spacing: .02em; margin-right: auto; }
.gp-bar .t small { font-family: var(--body); font-size: 12px; color: var(--ink-faint); font-weight: 600; margin-left: 6px; letter-spacing: .08em; }
.board-wrap #game { min-height: min(72vw, 420px); width: 100%; }
.board-wrap { background: var(--board-bg); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; display: flex; flex-direction: column; align-items: center; gap: 16px; box-shadow: var(--shadow); max-width: 100%; }
.gp-actions { display: flex; gap: 10px; padding: 14px 0 8px; flex-wrap: wrap; }
.solved { margin: 6px 0 20px; padding: 14px 16px; border-radius: var(--r); background: var(--solved-bg); color: var(--solved-ink); display: flex; gap: 12px; align-items: center; font-size: 14px; }
.solved b { font-family: var(--display); font-weight: 700; font-size: 18px; display: block; }
.solved .moon { width: 38px; height: 38px; flex: none; }
.countdown { color: var(--ink-soft); font-size: 14px; font-variant-numeric: tabular-nums; text-align: center; }
.solved .btn { margin-left: auto; } .solved .btn + .btn { margin-left: 0; }
.reveal-row { text-align: center; margin: 8px 0 0; font-size: 13px; min-height: 1.4em; }
.reveal-row button { background: none; border: 0; color: var(--ink-faint); text-decoration: underline; cursor: pointer; font: inherit; font-size: 13px; }
.share-ok { font-size: 12px; color: var(--good); }
.month-grid li a.part { border-color: var(--accent); }
.snd-off .ic-on { display: none; } .btn-icon:not(.snd-off) .ic-off { display: none; }
.gp-tabs { margin-top: 4px; }

/* ---------- Prose, tables, details, archive ---------- */
.prose { max-width: 720px; margin: 40px auto 0; }
.prose ul, .prose ol { padding-left: 1.2em; }
.prose li { margin: .35em 0; }
.prose.reveal { margin-top: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 18px; }
.prose.reveal summary { cursor: pointer; font-weight: 700; }
.steps { list-style: none; padding: 0; counter-reset: s; }
.steps li { position: relative; padding-left: 44px; margin: 14px 0; }
.steps li::before { counter-increment: s; content: counter(s); position: absolute; left: 0; top: 2px; width: 30px; height: 30px; border-radius: 50%; background: var(--ico-bg); color: var(--ico-ink); font-family: var(--display); font-weight: 800; display: grid; place-items: center; font-size: 14px; }
.steps h2 { font-size: 19px; margin: 0 0 .2em; }
.table { width: 100%; border-collapse: collapse; margin: 12px 0 20px; font-size: 15px; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--ink-faint); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.month-grid { list-style: none; padding: 0; margin: 6px 0 18px; display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.month-grid li a, .month-grid li span { display: grid; place-items: center; aspect-ratio: 1; border-radius: 10px; font-weight: 700; font-size: 14px; text-decoration: none; }
.month-grid li a { background: var(--surface); border: 1px solid var(--line); color: var(--ink); }
.month-grid li a:hover { border-color: var(--accent-2); color: var(--accent-2); }
.month-grid li a.done { background: var(--solved-bg); color: var(--solved-ink); border-color: transparent; }
.month-grid li span { color: var(--ink-faint); }
.archive-strip .row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin: 18px 0; }
.archive-chip { text-decoration: none; font-size: 14px; font-weight: 700; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-soft); background: var(--surface); }
.stats { max-width: 720px; margin: 18px auto 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 18px; }
.stats summary { cursor: pointer; font-weight: 700; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; margin: 12px 0; text-align: center; }
.stats-grid .v { font-family: var(--display); font-weight: 800; font-size: 26px; font-variant-numeric: tabular-nums; }
.stats-grid .k { font-size: 12px; color: var(--ink-faint); letter-spacing: .08em; text-transform: uppercase; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding: 22px 0 28px; color: var(--ink-faint); font-size: 13px; line-height: 1.55; margin-top: 40px; }
.site-footer .wrap > div { margin: 4px 0; }
.site-footer b, .site-footer strong { color: var(--ink-soft); }
.site-footer a { color: var(--ink-soft); text-decoration: none; }
.site-footer a:hover { color: var(--ink); text-decoration: underline; }
.disclaimer { font-size: 12px; }
