/* Layout: street scene on top; grid on the left, the neighbours' clues on the right (a bottom drawer on phones). */
:root {
  --ground: #E4E9EF; --paper: #F8FAFC; --ink: #1A2233; --muted: #5B6677; --line: #CBD3DD;
  --lantern: #A86A05; --glow: #F3B33D; --good: #2D7A4E; --bad: #B23A30; --chip: #EDF1F5;
  --roof: #3A4558; --wall: #F2EEE6; --sky-top: #9DB4CF; --sky-bottom: #E9D8C4; --star: transparent; --cobble: #C9D0D9;
  --roof-1: #8C4B3E; --roof-2: #3F5A73; --roof-3: #5E6B4A; --roof-4: #6E5378; --roof-5: #7A6A4F; --roof-6: #4C5D63;
  --f-display: 'Young Serif', Georgia, 'Times New Roman', serif;
  --f-body: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --f-mono: 'DM Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --ground: #0E131C; --paper: #161D2A; --ink: #E6EBF2; --muted: #93A0B3; --line: #2A3446;
  --lantern: #F0A830; --glow: #F7C35C; --good: #5BBF86; --bad: #F07468; --chip: #1E2737;
  --roof: #6C7A92; --wall: #232C3C; --sky-top: #070B14; --sky-bottom: #1B2640; --star: #DCE4F5; --cobble: #222B3B;
  --roof-1: #6B3A31; --roof-2: #2F465C; --roof-3: #46523A; --roof-4: #533F5C; --roof-5: #5C503C; --roof-6: #3A484D;
  color-scheme: dark } }
:root[data-theme="dark"] {
  --ground: #0E131C; --paper: #161D2A; --ink: #E6EBF2; --muted: #93A0B3; --line: #2A3446;
  --lantern: #F0A830; --glow: #F7C35C; --good: #5BBF86; --bad: #F07468; --chip: #1E2737;
  --roof: #6C7A92; --wall: #232C3C; --sky-top: #070B14; --sky-bottom: #1B2640; --star: #DCE4F5; --cobble: #222B3B;
  --roof-1: #6B3A31; --roof-2: #2F465C; --roof-3: #46523A; --roof-4: #533F5C; --roof-5: #5C503C; --roof-6: #3A484D;
  color-scheme: dark }

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--ground); color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.45;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 18px 40px; }
.wrap { max-width: 1080px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, .chip:focus-visible { outline: 2px solid var(--lantern); outline-offset: 2px; }

/* ---------- header ---------- */
header.top { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.brand { font-family: var(--f-display); font-size: 30px; line-height: 1; letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px; }
.brand .lamp { width: 14px; height: 20px; border-radius: 4px 4px 7px 7px; background: var(--glow); box-shadow: 0 0 14px 3px color-mix(in srgb, var(--glow) 55%, transparent); animation: flicker 5s infinite; }
@keyframes flicker { 0%, 100% { opacity: 1; } 47% { opacity: 1; } 48% { opacity: .75; } 50% { opacity: 1; } 72% { opacity: .9; } }
.header-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
nav.tabs { display: flex; gap: 2px; background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
nav.tabs button { border: 0; background: none; padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--muted); }
nav.tabs button[aria-current="page"] { background: var(--ink); color: var(--paper); }
.theme-btn { border: 1px solid var(--line); background: var(--paper); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; display: inline-flex; gap: 6px; align-items: center; }

/* ---------- layout ---------- */
.game { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.main-col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
@media (min-width: 900px) {
  .game { grid-template-columns: minmax(0, 1fr) minmax(300px, 360px); }
  .clues { position: sticky; top: 16px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
  .clues .clue-scroll { overflow-y: auto; min-height: 0; }
  .clues .drawer-toggle { pointer-events: none; margin-bottom: 4px; }
  .clues .drawer-toggle .chev, .clues .drawer-toggle .grip { display: none; }
}

.intro { display: flex; flex-direction: column; gap: 4px; }
.meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.meta strong { color: var(--ink); font-weight: 600; }
.flavour { font-family: var(--f-display); font-size: 18px; line-height: 1.3; margin: 0; text-wrap: balance; max-width: 60ch; }
.pill { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--lantern); color: var(--lantern); }
.timer { font-family: var(--f-mono); font-variant-numeric: tabular-nums; margin-left: auto; color: var(--ink); }

/* ---------- street scene ---------- */
.board { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; display: flex; flex-direction: column; }
.scene { position: relative; padding: 30px 12px 0; background: linear-gradient(var(--sky-top), var(--sky-bottom)); }
.scene::before { content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(1.2px 1.2px at 12% 22%, var(--star) 99%, transparent), radial-gradient(1px 1px at 28% 10%, var(--star) 99%, transparent),
    radial-gradient(1.4px 1.4px at 47% 30%, var(--star) 99%, transparent), radial-gradient(1px 1px at 63% 14%, var(--star) 99%, transparent),
    radial-gradient(1.2px 1.2px at 81% 26%, var(--star) 99%, transparent), radial-gradient(1px 1px at 92% 8%, var(--star) 99%, transparent); }
.scene .moon { position: absolute; top: 10px; right: 16px; width: 22px; height: 22px; border-radius: 50%; background: var(--glow); opacity: .85;
  box-shadow: 0 0 18px 4px color-mix(in srgb, var(--glow) 35%, transparent); }
.scene .moon::after { content: ""; position: absolute; inset: -3px -3px 4px 6px; border-radius: 50%; background: var(--sky-top); }
.street, .row { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 6px; }
.street { position: relative; align-items: end; }
.house { display: flex; flex-direction: column; align-items: center; position: relative; }
.house .chimney { position: absolute; top: 4px; right: 26%; width: 7px; height: 12px; background: var(--h-roof); }
.house .roof { width: 92%; height: 22px; background: var(--h-roof); clip-path: polygon(50% 0, 100% 100%, 0 100%); position: relative; }
.house.flat .roof { clip-path: polygon(8% 30%, 92% 30%, 100% 100%, 0 100%); }
.house.tall .roof { height: 28px; }
.house .body { width: 78%; height: 42px; background: var(--wall); border: 1.5px solid color-mix(in srgb, var(--ink) 25%, transparent); border-bottom: 0; position: relative; display: flex; align-items: end; justify-content: space-between; padding: 0 5px; }
.house .windows { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; width: 24px; margin-bottom: 8px; }
.house .window { width: 6px; height: 6px; border-radius: 1px; background: color-mix(in srgb, var(--ink) 18%, var(--wall)); transition: background .5s, box-shadow .5s; }
.house .door { width: 13px; height: 22px; border: 1.5px solid color-mix(in srgb, var(--ink) 35%, transparent); border-bottom: 0; border-radius: 7px 7px 0 0; background: color-mix(in srgb, var(--ink) 6%, var(--wall)); transition: background .4s; }
.house .num { position: absolute; top: 3px; left: 0; right: 0; text-align: center; font-family: var(--f-mono); font-size: 11px; color: var(--muted); }
.house .lamp { position: absolute; bottom: 20px; left: -5px; width: 6px; height: 9px; border-radius: 2px 2px 3px 3px; background: color-mix(in srgb, var(--ink) 25%, transparent); transition: background .5s, box-shadow .5s; }
.house .window.on { background: color-mix(in srgb, var(--glow) 80%, var(--wall)); box-shadow: 0 0 5px 1px color-mix(in srgb, var(--glow) 45%, transparent); }
.house.lit .window, .house.lit .lamp { background: var(--glow); box-shadow: 0 0 8px 2px color-mix(in srgb, var(--glow) 55%, transparent); }
.house.glow .body { animation: housepulse 1.4s ease-out; }
@keyframes housepulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--glow) 0%, transparent); } 30% { box-shadow: 0 0 22px 8px color-mix(in srgb, var(--glow) 60%, transparent); } 100% { box-shadow: 0 0 0 0 transparent; } }
.house:nth-child(1) { transition-delay: 0s; } .house:nth-child(2) .lamp, .house:nth-child(2) .window { transition-delay: .12s; }
.house:nth-child(3) .lamp, .house:nth-child(3) .window { transition-delay: .24s; } .house:nth-child(4) .lamp, .house:nth-child(4) .window { transition-delay: .36s; }
.house:nth-child(5) .lamp, .house:nth-child(5) .window { transition-delay: .48s; } .house:nth-child(6) .lamp, .house:nth-child(6) .window { transition-delay: .6s; }
.pavement { height: 8px; background: repeating-linear-gradient(90deg, var(--cobble) 0 14px, color-mix(in srgb, var(--cobble) 70%, var(--paper)) 14px 16px); }
.progress { font-size: 12px; color: var(--muted); padding: 8px 12px 0; display: flex; justify-content: space-between; gap: 8px; font-variant-numeric: tabular-nums; }

/* ---------- grid ---------- */
.rows { padding: 8px 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.cat-label { font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.cat-label .legend { font-weight: 500; letter-spacing: 0; text-transform: none; font-size: 12px; overflow-wrap: anywhere; }
.cell { background: var(--chip); border-radius: 8px; min-height: 58px; padding: 4px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px; align-content: center; justify-items: center; transition: background .2s; }
.cell.n2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.chip { border: 0; background: none; border-radius: 6px; aspect-ratio: 1; width: 100%; max-width: 38px; min-height: 24px; display: grid; place-items: center; font-size: 16px; line-height: 1; padding: 0; font-weight: 700; font-family: var(--f-body); touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.chip:hover { background: color-mix(in srgb, var(--ink) 9%, transparent); }
.chip.selected { background: color-mix(in srgb, var(--lantern) 28%, transparent); box-shadow: inset 0 0 0 1.5px var(--lantern); }
.chip.out { opacity: 0.16; cursor: default; }
.chip.out:hover { background: none; }
.chip .dot { width: 14px; height: 14px; border-radius: 50%; border: 1px solid color-mix(in srgb, var(--ink) 30%, transparent); }
.cell.placed { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; background: color-mix(in srgb, var(--lantern) 13%, var(--chip)); }
.cell.placed .big { font-size: 22px; line-height: 1; font-weight: 700; }
.cell.placed .big .dot { width: 20px; height: 20px; border-radius: 50%; display: inline-block; border: 1px solid color-mix(in srgb, var(--ink) 30%, transparent); }
.cell.placed .word { font-size: 11px; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell.shake { animation: shake .35s; background: color-mix(in srgb, var(--bad) 22%, var(--chip)); }
@keyframes shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }

/* ---------- choice menu ---------- */
.menu { position: absolute; z-index: 30; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 10px; width: 230px; max-width: calc(100vw - 32px);
  box-shadow: 0 10px 30px color-mix(in srgb, #000 22%, transparent); display: flex; flex-direction: column; gap: 8px; }
.menu .q { font-size: 13px; color: var(--muted); }
.menu .q b { color: var(--ink); font-weight: 600; }
.menu .acts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.menu .acts button { border: 1px solid var(--line); background: var(--chip); border-radius: 9px; padding: 9px 6px; font-size: 13px; font-weight: 600; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.menu .acts button .k { font-size: 18px; line-height: 1; }
.menu .acts .yes { border-color: var(--good); color: var(--good); }
.menu .acts .no { border-color: var(--bad); color: var(--bad); }

.tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.btn { border: 1px solid var(--line); background: var(--paper); border-radius: 10px; padding: 8px 12px; font-size: 13px; font-weight: 600; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--lantern); border-color: var(--lantern); color: #1A1306; }
.tools .tally { margin-left: auto; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.toast { font-size: 13px; color: var(--muted); min-height: 1.4em; }
.tip { font-size: 12px; color: var(--muted); margin: 0; }

/* ---------- clues ---------- */
.clues { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; }
.clues h2, .panel h2, .dt-title { font-family: var(--f-display); font-weight: 400; font-size: 20px; margin: 0; text-wrap: balance; }
.clues .left { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.clues ol { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; }
.clues li { display: grid; grid-template-columns: 1.8em 1fr; gap: 4px; padding: 8px 6px; border-top: 1px dashed var(--line); cursor: pointer; border-radius: 6px; transition: opacity .2s, background .2s; }
.clues li:first-child { border-top: 0; }
.clues li .n { font-family: var(--f-mono); color: var(--lantern); font-size: 12px; padding-top: 2px; }
.clues li.done { opacity: 0.35; text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--ink) 40%, transparent); }
.clues li.hint { background: color-mix(in srgb, var(--glow) 28%, transparent); opacity: 1; text-decoration: none; }
.howto { font-size: 12.5px; color: var(--muted); margin: 0 0 6px; }
.drawer-toggle { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 8px; border: 0; background: none; padding: 0; text-align: left; }
.drawer-toggle .grip { width: 36px; height: 4px; border-radius: 2px; background: var(--line); position: absolute; top: -10px; left: 50%; transform: translateX(-50%); }
.drawer-toggle .chev { font-size: 13px; color: var(--muted); }

/* ---------- other views ---------- */
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 12px; max-width: 720px; }
.panel p { margin: 0; max-width: 62ch; }
.days { display: flex; flex-direction: column; }
.day { display: grid; grid-template-columns: 4.5em 1fr auto; gap: 10px; align-items: center; padding: 9px 2px; border: 0; border-top: 1px solid var(--line); background: none; text-align: left; }
.day:first-child { border-top: 0; }
.day .d { font-family: var(--f-mono); font-size: 12px; color: var(--muted); }
.day .t { min-width: 0; }
.day .t small { display: block; color: var(--muted); font-size: 12px; }
.day .s { font-size: 12px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.day .s.ok { color: var(--good); }
.day.locked { opacity: 0.55; }
.week-break { font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--lantern); padding: 14px 0 4px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.stat { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.stat b { display: block; font-family: var(--f-display); font-weight: 400; font-size: 26px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }
.tiers { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.tier { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.tier.feature { border-color: var(--lantern); }
.tier h3 { margin: 0; font-size: 15px; }
.tier .price { font-family: var(--f-display); font-size: 22px; }
.tier ul { margin: 0; padding-left: 18px; font-size: 13px; color: var(--muted); }
.note { font-size: 12px; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media (max-width: 420px) { .chip { font-size: 14px; min-height: 20px; } .cell { min-height: 52px; padding: 3px; } .rows, .scene { padding-inline: 8px; } .street, .row { gap: 4px; } .brand { font-size: 26px; } }

/* ---------- multi-page site ---------- */
a { color: var(--lantern); text-underline-offset: 2px; }
a:focus-visible { outline: 2px solid var(--lantern); outline-offset: 2px; border-radius: 3px; }
nav.tabs a { text-decoration: none; padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--muted); }
nav.tabs a[aria-current="page"] { background: var(--ink); color: var(--paper); }
.brand { text-decoration: none; color: inherit; }
.page-title { font-family: var(--f-body); font-size: 13px; font-weight: 600; margin: 0; color: var(--ink); letter-spacing: 0; }
.page-title span { color: var(--muted); font-weight: 500; }
.prose { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; max-width: 760px; display: flex; flex-direction: column; gap: 10px; }
.prose h1 { font-family: var(--f-display); font-weight: 400; font-size: 28px; line-height: 1.15; margin: 0; text-wrap: balance; }
.prose h2 { font-family: var(--f-display); font-weight: 400; font-size: 20px; margin: 10px 0 0; text-wrap: balance; }
.prose h3 { font-size: 15px; margin: 6px 0 0; }
.prose p, .prose li { max-width: 66ch; }
.prose p { margin: 0; }
.prose ol, .prose ul { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 4px; }
.prose .lede { font-size: 16.5px; }
.prose table { border-collapse: collapse; font-size: 14px; min-width: 520px; }
.prose th, .prose td { border-bottom: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.prose th { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.table-wrap { overflow-x: auto; }
.prose details { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--chip); }
.prose details summary { cursor: pointer; font-weight: 600; }
.prose details[open] summary { margin-bottom: 6px; }
.crumbs { font-size: 12px; color: var(--muted); }
.crumbs a { color: var(--muted); }
.cta { display: inline-block; background: var(--lantern); color: #1A1306; padding: 9px 14px; border-radius: 10px; font-weight: 700; text-decoration: none; align-self: start; }
.site-foot { font-size: 12px; color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap; padding-top: 8px; }
.site-foot a { color: var(--muted); }
.day { text-decoration: none; color: inherit; }
.ssr-note { font-size: 13px; color: var(--muted); }
.page-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.panel h2.week-break { font-family: var(--f-body); font-size: 11px; margin: 0; }

/* ---------- header: icon buttons, phone menu ---------- */
.icon-btn { border: 1px solid var(--line); background: var(--paper); color: var(--ink); border-radius: 999px; width: 36px; height: 36px; padding: 0; display: inline-grid; place-items: center; }
.icon-btn:focus-visible { outline: 2px solid var(--lantern); outline-offset: 2px; }
.nav-toggle { display: none; }
.day-links { margin: 0; font-size: 13px; color: var(--muted); }
a.btn { text-decoration: none; color: var(--ink); display: inline-flex; align-items: center; }

/* ---------- tools: mode switch ---------- */
.seg { display: inline-flex; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 2px; }
.seg button { border: 0; background: none; border-radius: 8px; padding: 6px 10px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.btn.icon-only { padding: 8px 0; width: 36px; text-align: center; }
.cell.picked { box-shadow: inset 0 0 0 2px var(--lantern); }
.cell[role="button"] { cursor: pointer; }

/* ---------- messages ---------- */
.toast { border-radius: 10px; }
.toast.bad { color: var(--bad); }
.toast.info { color: var(--ink); }
.toast[hidden] { display: none; }

/* ---------- clue panel: title, peek, tools ---------- */
.drawer-toggle { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 8px; row-gap: 2px; }
.drawer-toggle .dt-title { grid-column: 1; }
.drawer-toggle .chev { grid-column: 2; grid-row: 1; align-self: center; }
.drawer-toggle .peek { grid-column: 1 / -1; font-size: 13.5px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drawer-toggle .peek.hinted { background: color-mix(in srgb, var(--glow) 30%, transparent); border-radius: 6px; padding: 2px 6px; margin-inline: -6px; }
.drawer-toggle .peek b { color: var(--lantern); font-family: var(--f-mono); font-weight: 500; }
.clue-body { display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.clue-tools { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 6px; }
.switch { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); cursor: pointer; }
.switch input { accent-color: var(--lantern); margin: 0; }
@media (min-width: 900px) {
  .clues .drawer-toggle .peek { display: none; }
  .clues .clue-body { flex: 1; }
}

/* phones and narrow windows: the clues sit in a drawer that collapses to a one-line peek of the current clue */
@media (max-width: 899px) {
  :root { --peek: 74px; }
  body.playing { padding-bottom: calc(var(--peek) + 24px + env(safe-area-inset-bottom, 0px)); }
  .clues { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; border-radius: 16px 16px 0 0; border-bottom: 0;
    padding: 16px max(16px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
    min-height: var(--peek); display: flex; flex-direction: column; box-shadow: 0 -8px 24px color-mix(in srgb, #000 16%, transparent); }
  .clues .dt-title { font-size: 13px; font-family: var(--f-body); font-weight: 600; color: var(--muted); }
  .clues:not(.open):not(.review) .clue-body { display: none; }
  .clues.open { height: 65vh; }
  .clues.open .peek { display: none; }
  .clues.open .clue-body { flex: 1; }
  .clues .clue-scroll { overflow-y: auto; min-height: 0; flex: 1; }
  .clues .howto { display: none; }
  .clues.review { position: static; height: auto; min-height: 0; border-radius: 16px; border-bottom: 1px solid var(--line); box-shadow: none; padding: 14px 16px; }
  .clues.review .drawer-toggle { pointer-events: none; }
  .clues.review .chev, .clues.review .grip, .clues.review .peek { display: none; }
  .clues.review .dt-title { font-family: var(--f-display); font-size: 20px; font-weight: 400; color: var(--ink); }
  /* mistakes and hints show as a banner just above the drawer */
  body.playing .toast { position: fixed; z-index: 25; left: 12px; right: 12px; bottom: calc(var(--peek) + 10px + env(safe-area-inset-bottom, 0px));
    background: var(--paper); border: 1px solid var(--line); padding: 10px 12px; font-size: 14px; box-shadow: 0 6px 20px color-mix(in srgb, #000 20%, transparent); }
  body.playing .toast.bad { border-color: var(--bad); }
  body.playing.drawer-open .toast { bottom: calc(65vh + 10px); }
}

/* phones: compact header, shorter street */
@media (max-width: 640px) {
  .brand { font-size: 22px; }
  .brand .lamp { width: 11px; height: 16px; }
  .header-right { flex-wrap: nowrap; }
  .nav-toggle { display: inline-grid; }
  nav.tabs { display: none; position: absolute; z-index: 35; right: 0; top: calc(100% + 6px); flex-direction: column; border-radius: 12px; padding: 6px; min-width: 160px;
    box-shadow: 0 10px 30px color-mix(in srgb, #000 22%, transparent); }
  header.nav-open nav.tabs { display: flex; }
  nav.tabs a { border-radius: 8px; padding: 10px 12px; font-size: 14px; }
  .scene { padding-top: 18px; }
  .house .roof { height: 14px; } .house.tall .roof { height: 18px; }
  .house .chimney { height: 8px; top: 2px; }
  .house .body { height: 32px; padding: 0 3px; }
  .house .windows { margin-bottom: 4px; width: 20px; gap: 1.5px; }
  .house .window { width: 5px; height: 5px; }
  .house .door { width: 10px; height: 16px; }
  .house .num { font-size: 10px; top: 1px; }
  .house .lamp { bottom: 14px; }
  .flavour { font-size: 16px; }
  .tools { gap: 6px; }
  .tools .lbl { display: none; }
  .tools .tally { margin-left: 0; width: 100%; order: 5; }
  .seg button { padding: 7px 6px; font-size: 12.5px; }
  .tools .btn { padding: 8px 9px; }
  .tools .btn.icon-only { width: 34px; padding: 8px 0; }
}

/* ---------- cell picker (phones) ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: color-mix(in srgb, #000 40%, transparent); }
.sheet { position: fixed; z-index: 41; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 520px; max-height: 75vh; overflow-y: auto; background: var(--paper); color: var(--ink);
  border-radius: 18px 18px 0 0; padding: 14px 16px calc(16px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 10px; box-shadow: 0 -10px 30px color-mix(in srgb, #000 25%, transparent); }
.sheet-head { display: flex; align-items: center; gap: 6px; font-size: 15px; }
.sheet-head .btn { margin-left: auto; }
.sheet-msg { margin: 0; font-size: 14px; padding: 8px 10px; border-radius: 10px; background: var(--chip); }
.sheet-msg.bad { color: var(--bad); box-shadow: inset 0 0 0 1px var(--bad); }
.opts { display: flex; flex-direction: column; gap: 6px; }
.opt { display: flex; align-items: center; gap: 10px; background: var(--chip); border-radius: 12px; padding: 6px 6px 6px 12px; min-height: 56px; }
.opt-ic { font-size: 26px; line-height: 1; width: 32px; display: grid; place-items: center; }
.opt-ic .dot { width: 24px; height: 24px; border-radius: 50%; display: block; border: 1px solid color-mix(in srgb, var(--ink) 30%, transparent); }
.opt-name { flex: 1; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.opt button { min-width: 48px; min-height: 44px; border-radius: 10px; border: 1.5px solid; background: var(--paper); font-weight: 700; font-size: 16px; padding: 0 12px; }
.opt .yes { border-color: var(--good); color: var(--good); }
.opt .no { border-color: var(--bad); color: var(--bad); }

/* ---------- first-visit walkthrough ---------- */
#intro .sheet-backdrop { z-index: 50; }
.intro-card { position: fixed; z-index: 51; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(420px, calc(100vw - 32px)); background: var(--paper); color: var(--ink);
  border: 1px solid var(--line); border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 10px; box-shadow: 0 20px 50px color-mix(in srgb, #000 35%, transparent); }
.intro-card h2 { font-family: var(--f-display); font-weight: 400; font-size: 22px; margin: 0; }
.intro-card p { margin: 0; }
.intro-step { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--lantern); }
.intro-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* ---------- win card: follows the light/dark theme ---------- */
.win { background: var(--paper); color: var(--ink); border: 2px solid var(--lantern); border-radius: 16px; padding: 18px; display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--glow) 18%, transparent), 0 10px 30px color-mix(in srgb, var(--glow) 14%, transparent); }
.win h2 { font-family: var(--f-display); font-weight: 400; margin: 0; font-size: 24px; text-wrap: balance; }
.win p { margin: 0; color: var(--muted); }
.win p b { color: var(--ink); }
.win pre { font-family: var(--f-mono); font-size: 13px; margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--chip); color: var(--ink); padding: 10px 12px; border-radius: 8px; }
.win-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.win.enter { animation: rise .5s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.cd { font-family: var(--f-mono); font-weight: 500; font-variant-numeric: tabular-nums; }

/* ---------- pack waitlist ---------- */
.waitlist { display: flex; flex-direction: column; gap: 6px; border-top: 1px dashed var(--line); padding-top: 12px; }
.waitlist label { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.wl-row { display: flex; gap: 6px; flex-wrap: wrap; }
.wl-row input { flex: 1 1 180px; min-width: 0; font: inherit; color: var(--ink); background: var(--ground); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.wl-row input:focus-visible { outline: 2px solid var(--lantern); outline-offset: 1px; }
.wl-msg { margin: 0; font-size: 12.5px; color: var(--muted); }
.wl-msg:empty { display: none; }
.prose .waitlist { max-width: 480px; }

/* ---------- stats: calendar and per-difficulty table ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; max-width: 360px; }
.cal-h { font-size: 11px; font-weight: 700; color: var(--muted); text-align: center; }
.cal-day { aspect-ratio: 1; display: grid; place-items: center; border-radius: 8px; font-size: 13px; font-variant-numeric: tabular-nums; border: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.cal-day.solved { background: color-mix(in srgb, var(--good) 22%, var(--paper)); border-color: var(--good); font-weight: 700; }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--lantern); }
.cal-day.off { opacity: .35; border-style: dashed; }
.lvl-table { border-collapse: collapse; font-size: 14px; width: 100%; max-width: 520px; }
.lvl-table th, .lvl-table td { border-bottom: 1px solid var(--line); padding: 6px 10px; text-align: left; font-variant-numeric: tabular-nums; }
.lvl-table th { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* ---------- collections, pagers, printables ---------- */
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13.5px; flex-wrap: wrap; }
.pager a { font-weight: 600; }
.printable h1 .sub { display: block; font-family: var(--f-body); font-size: 14px; color: var(--muted); margin-top: 4px; }
.print-grid { border-collapse: collapse; width: 100%; min-width: 0; table-layout: fixed; }
.prose .print-grid th, .prose .print-grid td { border: 1px solid var(--line); padding: 6px; height: 44px; text-align: center; vertical-align: middle; }
.prose .print-grid tbody th { text-align: left; text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--ink); }
.print-note { display: none; }
@media print {
  body { background: #fff; color: #000; padding: 0; font-size: 12pt; }
  header.top, .site-foot, .no-print, .crumbs { display: none !important; }
  .prose { border: 0; padding: 0; max-width: none; background: #fff; }
  .prose a { color: #000; }
  .print-grid th, .print-grid td { border-color: #000 !important; height: 2.4em; }
  .print-note { display: block; font-size: 9pt; color: #444; margin-top: 12px; }
  .prose li, .print-grid { break-inside: avoid; }
}
