/* Fall Back — shared styles */
:root {
  --bg: #fbf3e6;
  --bg2: #f4e7d2;
  --ink: #1d1a2f;
  --muted: #5b566f;
  --card: #fffdf8;
  --line: #e5d8c2;
  --accent: #d9481f;
  --accent-ink: #ffffff;
  --night: #27307a;
  --gold: #e8951c;
  --good: #1f7a4d;
  --bad: #b3261e;
  --shadow: 0 1px 2px rgba(40, 30, 10, .08), 0 8px 24px rgba(40, 30, 10, .08);
  --radius: 18px;
  --font-display: "Bricolage Grotesque", "Trebuchet MS", system-ui, sans-serif;
  --font-body: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0f1229;
  --bg2: #161a3a;
  --ink: #f4ecdf;
  --muted: #aaa7c6;
  --card: #1a1e40;
  --line: #2d3260;
  --accent: #ff7a4d;
  --accent-ink: #1a0d06;
  --night: #9fb0ff;
  --gold: #ffbd5a;
  --good: #5fd39a;
  --bad: #ff8a80;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  overflow-x: hidden;
}
img, svg { max-width: 100%; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.1; letter-spacing: -.01em; margin: 0 0 .5em; }
h1 { font-size: clamp(2.2rem, 8vw, 4.2rem); font-weight: 800; }
h2 { font-size: clamp(1.5rem, 4.5vw, 2.2rem); font-weight: 800; }
h3 { font-size: 1.2rem; font-weight: 700; }
p { margin: 0 0 1em; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.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; }

/* ---------- header / nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header .inner { max-width: 1120px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); font-family: var(--font-display); font-weight: 800; font-size: 1.2rem; margin-right: auto; }
.brand img { width: 30px; height: 30px; display: block; }
.hero-min, .hero-hour { transform-box: view-box; transform-origin: 150px 150px; }
.hero-min { animation: heroMin 6s ease-in-out infinite; }
.hero-hour { animation: heroHour 6s ease-in-out infinite; }
@keyframes heroMin { 0%, 15% { transform: rotate(0); } 55%, 100% { transform: rotate(-360deg); } }
@keyframes heroHour { 0%, 15% { transform: rotate(0); } 55%, 100% { transform: rotate(-30deg); } }
.nav { display: flex; gap: 2px; flex-wrap: wrap; order: 3; width: 100%; overflow-x: auto; }
.nav a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 999px; font-weight: 600; font-size: .92rem; white-space: nowrap; }
.nav a:hover { color: var(--ink); background: var(--bg2); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--bg2); box-shadow: inset 0 0 0 1px var(--line); }
.icon-btn { border: 1px solid var(--line); background: var(--card); color: var(--ink); width: 40px; height: 40px; border-radius: 12px; display: inline-grid; place-items: center; cursor: pointer; font-size: 1.1rem; }
.icon-btn:hover { border-color: var(--accent); }
@media (min-width: 760px) {
  .nav { order: 0; width: auto; }
  .brand { margin-right: 12px; }
  .nav { margin-right: auto; }
}

main { max-width: 1120px; margin: 0 auto; padding: 16px 16px 60px; }
.site-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; }
.site-footer .inner { max-width: 1120px; margin: 0 auto; padding: 24px 16px 40px; display: flex; flex-wrap: wrap; gap: 8px 20px; justify-content: space-between; }

/* ---------- buttons ---------- */
.btn {
  appearance: none; border: 0; cursor: pointer;
  font: 700 1rem/1 var(--font-body);
  padding: 13px 20px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none; transition: transform .12s ease, box-shadow .12s ease, background .2s;
  box-shadow: 0 3px 0 color-mix(in srgb, var(--accent) 60%, #000);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 color-mix(in srgb, var(--accent) 60%, #000); }
.btn.ghost { background: var(--card); color: var(--ink); box-shadow: inset 0 0 0 2px var(--line); }
.btn.ghost:hover { box-shadow: inset 0 0 0 2px var(--accent); }
.btn.small { padding: 9px 14px; font-size: .9rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.eyebrow { font: 700 .78rem/1 var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--accent); margin-bottom: 10px; }
.muted { color: var(--muted); }
.lead { font-size: 1.15rem; color: var(--muted); max-width: 60ch; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--bg2); border: 1px solid var(--line); font-size: .82rem; font-weight: 600; }

/* ---------- hero ---------- */
.hero { display: grid; gap: 22px; padding: 18px 0 8px; align-items: center; }
.hero h1 .flip { display: inline-block; color: var(--accent); }
.hero-clock { justify-self: center; width: min(300px, 80vw); }
.hero-clock svg { width: 100%; height: auto; display: block; }
.countdown { font-family: var(--font-mono); font-size: .95rem; background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; display: inline-block; }
.countdown strong { color: var(--accent); }
@media (min-width: 860px) {
  .hero { grid-template-columns: 1.4fr 1fr; }
}

/* ---------- mode picker ---------- */
.modes { display: grid; gap: 12px; grid-template-columns: 1fr; margin: 18px 0; }
@media (min-width: 620px) { .modes { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 980px) { .modes { grid-template-columns: repeat(4, 1fr); } }
.mode {
  text-align: left; cursor: pointer; border: 2px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: var(--radius); padding: 16px; font: inherit; display: flex; flex-direction: column; gap: 6px;
  transition: border-color .15s, transform .15s;
}
.mode:hover { border-color: var(--accent); transform: translateY(-2px); }
.mode .mode-title { font-family: var(--font-display); font-weight: 800; font-size: 1.25rem; }
.mode .mode-best { font-family: var(--font-mono); font-size: .8rem; color: var(--muted); }
.mode .mode-emoji { font-size: 1.6rem; }

/* ---------- HUD ---------- */
.hud {
  position: sticky; top: 58px; z-index: 30;
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: space-between;
  background: var(--ink); color: var(--bg); border-radius: 16px; padding: 8px 10px; margin-bottom: 14px;
  box-shadow: var(--shadow);
}
@media (max-width: 759px) {
  .site-header { position: relative; }
  .hud { top: 0; border-radius: 0 0 16px 16px; margin-left: -16px; margin-right: -16px; }
}
@media (min-width: 760px) { .hud { top: 62px; } }
.hud .stat { font-family: var(--font-mono); font-size: .85rem; display: flex; flex-direction: column; line-height: 1.15; padding: 0 6px; }
.hud .stat b { font-size: 1.15rem; }
.hud .phone { display: flex; align-items: center; gap: 8px; background: #000; color: #fff; padding: 6px 12px; border-radius: 12px; font-family: var(--font-mono); }
.hud .phone .t { font-size: 1.25rem; font-weight: 700; letter-spacing: .02em; }
.hud .phone small { opacity: .7; font-size: .65rem; display: block; line-height: 1.1; }
.hud .quit { background: transparent; color: inherit; border: 1px solid color-mix(in srgb, var(--bg) 40%, transparent); border-radius: 10px; padding: 6px 10px; cursor: pointer; font: 600 .85rem var(--font-body); }

/* ---------- house map ---------- */
.house { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 760px) { .house { grid-template-columns: repeat(4, 1fr); } }
.room-tile {
  position: relative; cursor: pointer; text-align: left; font: inherit; color: var(--ink);
  border: 2px solid var(--line); background: var(--card); border-radius: var(--radius); padding: 12px;
  display: flex; flex-direction: column; gap: 6px; min-height: 140px; transition: transform .15s, border-color .15s;
}
.room-tile:hover { transform: translateY(-2px); border-color: var(--accent); }
.room-tile .room { font: 700 .7rem/1 var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.room-tile .dname { font-family: var(--font-display); font-weight: 800; font-size: 1.05rem; line-height: 1.15; }
.room-tile .ico { font-size: 1.8rem; line-height: 1; }
.room-tile .mini { font-family: var(--font-mono); font-size: 1rem; font-weight: 700; color: var(--bad); margin-top: auto; }
.room-tile.done { border-color: var(--good); background: color-mix(in srgb, var(--good) 8%, var(--card)); }
.room-tile.done .mini { color: var(--good); }
.room-tile.done::after { content: "✓"; position: absolute; top: 8px; right: 12px; font-size: 1.5rem; font-weight: 900; color: var(--good); }

/* ---------- device stage ---------- */
.stage-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.stage-head h2 { margin: 0; font-size: 1.5rem; }
.device-wrap { display: grid; gap: 14px; }
@media (min-width: 900px) { .device-wrap { grid-template-columns: 1.5fr 1fr; align-items: start; } }
.device {
  border-radius: 22px; padding: 18px; position: relative;
  background: linear-gradient(180deg, #e9e6e1, #c9c5be); color: #222;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.6), 0 12px 30px rgba(0,0,0,.25);
  user-select: none; -webkit-user-select: none; touch-action: manipulation; -webkit-touch-callout: none;
}
.device[hidden] { display: none !important; }
.device.solved { outline: 4px solid var(--good); outline-offset: 4px; }
.device-side { display: flex; flex-direction: column; gap: 12px; }
.msg {
  min-height: 3.2em; font-family: var(--font-mono); font-size: .9rem; padding: 10px 12px; border-radius: 12px;
  background: var(--bg2); border: 1px dashed var(--line);
}
.msg.good { border-color: var(--good); color: var(--good); font-weight: 700; }
.manual { background: #fff8d6; color: #3b3010; border-radius: 4px 14px 14px 4px; padding: 14px 16px; font-size: .92rem; box-shadow: var(--shadow); border-left: 6px solid #e2c34a; }
.manual h3 { font-size: 1rem; margin-bottom: 6px; }
.manual ol { margin: 0; padding-left: 1.2em; }
.target { font-family: var(--font-mono); font-size: .95rem; }
.target b { font-size: 1.3rem; }

/* displays */
.lcd { border-radius: 10px; padding: 10px 12px; background: #0b0f0c; box-shadow: inset 0 3px 10px rgba(0,0,0,.8); position: relative; }
.lcd svg { display: block; height: 64px; width: auto; max-width: 100%; margin: 0 auto; }
.lcd .ind { position: absolute; font: 700 .7rem/1 var(--font-mono); letter-spacing: .05em; }
.lcd .ind.off { opacity: .12; }
.blink { animation: blink 1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }

/* generic device keys */
.keys { display: grid; gap: 8px; }
.key {
  appearance: none; cursor: pointer; border: 0; border-radius: 10px; padding: 10px 6px; min-height: 44px; min-width: 44px;
  font: 700 .85rem/1.1 var(--font-body); color: #222; background: linear-gradient(180deg, #fbfaf8, #dedad3);
  box-shadow: 0 3px 0 #9d988e, 0 4px 8px rgba(0,0,0,.15);
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.key:active, .key.down { transform: translateY(2px); box-shadow: 0 1px 0 #9d988e; }
.key.dark { background: linear-gradient(180deg, #4a4a4f, #2c2c30); color: #eee; box-shadow: 0 3px 0 #111, 0 4px 8px rgba(0,0,0,.3); }
.key.red { background: linear-gradient(180deg, #e2523c, #b33522); color: #fff; box-shadow: 0 3px 0 #6e1d10; }
.key.green { background: linear-gradient(180deg, #4fbf6c, #2c8a46); color: #fff; box-shadow: 0 3px 0 #155226; }
.key small { display: block; font-weight: 500; font-size: .65rem; opacity: .75; }

/* microwave */
.dev-microwave { background: linear-gradient(180deg, #3a3d42, #22252a); color: #ddd; display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; }
.dev-microwave .window { border-radius: 12px; background: repeating-radial-gradient(circle at 2px 2px, #1a1c1f 0 1.4px, #0c0d0f 1.5px 4px); min-height: 220px; box-shadow: inset 0 0 0 6px #2f3237, inset 0 0 30px #000; position: relative; overflow: hidden; }
.dev-microwave .window .plate { position: absolute; left: 50%; bottom: 14%; width: 70%; height: 14%; transform: translateX(-50%); border-radius: 50%; background: rgba(255,255,255,.07); }
.dev-microwave .window.on { background: repeating-radial-gradient(circle at 2px 2px, #3b2a10 0 1.4px, #1d1406 1.5px 4px); }
.dev-microwave .panel { display: flex; flex-direction: column; gap: 10px; }
.dev-microwave .keys { grid-template-columns: repeat(3, 1fr); }
.dev-microwave .key { background: linear-gradient(180deg, #55585e, #3b3e43); color: #eee; box-shadow: 0 3px 0 #15171a; font-size: .8rem; }
@media (max-width: 520px) { .dev-microwave { grid-template-columns: 1fr; } .dev-microwave .window { min-height: 90px; } }

/* oven */
.dev-oven { background: linear-gradient(180deg, #f2f2f2, #cfd2d6); }
.dev-oven .top { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: center; }
.dev-oven .knob { width: 64px; height: 64px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, #a9adb3); box-shadow: 0 4px 8px rgba(0,0,0,.3); position: relative; }
.dev-oven .knob::after { content: ""; position: absolute; left: 50%; top: 6px; width: 4px; height: 22px; background: #333; transform: translateX(-50%); border-radius: 2px; }
.dev-oven .door { margin-top: 14px; height: 130px; border-radius: 12px; background: linear-gradient(180deg, #2b2e33, #111316); box-shadow: inset 0 0 0 8px #d7d9dc; position: relative; }
.dev-oven .door .handle { position: absolute; top: -6px; left: 10%; right: 10%; height: 12px; border-radius: 6px; background: linear-gradient(180deg, #fafafa, #a8acb2); }
.dev-oven .door.lit { background: radial-gradient(ellipse at 50% 30%, #ffcf7a, #8a4b12 70%, #2b1606); }
.dev-oven .keys { grid-template-columns: repeat(3, minmax(56px, 1fr)); }

/* car */
.dev-car { background: linear-gradient(180deg, #2a2b30, #121316); color: #ccc; }
.dev-car .dash { display: grid; gap: 12px; }
.dev-car .lcd { background: #120a00; }
.dev-car .keys { grid-template-columns: repeat(4, 1fr); }
.dev-car .key { background: linear-gradient(180deg, #3d3e44, #26272b); color: #ffb000; box-shadow: 0 3px 0 #000; }
.dev-car .vent { height: 26px; border-radius: 8px; background: repeating-linear-gradient(90deg, #1a1b1f 0 6px, #2d2e33 6px 9px); }

/* watch */
.dev-watch { background: radial-gradient(circle at 50% 40%, #3b3d42, #17181b); display: grid; place-items: center; padding: 28px 10px; }
.watch { position: relative; width: min(330px, 100%); }
.watch .case { background: linear-gradient(180deg, #2d2f34, #0f1012); border-radius: 30px; padding: 20px 40px; box-shadow: inset 0 2px 0 rgba(255,255,255,.15), 0 10px 30px rgba(0,0,0,.6); }
.watch .face { background: #1d1e22; border-radius: 14px; padding: 10px; }
.watch .brandline { color: #c9c9c9; font: 700 .6rem/1 var(--font-mono); letter-spacing: .3em; text-align: center; margin-bottom: 6px; }
.watch .lcd { background: #a9b39a; box-shadow: inset 0 2px 6px rgba(0,0,0,.4); }
.watch .lcd .label { font: 700 .75rem/1 var(--font-mono); color: #1d2318; display: flex; justify-content: space-between; margin-bottom: 4px; }
.watch .wmain svg { height: 58px; }
.watch .wsmall svg { height: 30px; }
.watch .wbtn { position: absolute; width: 40px; height: 52px; border: 0; cursor: pointer; border-radius: 6px; background: linear-gradient(90deg, #8b8f96, #d8dbe0, #8b8f96); font: 700 .6rem/1 var(--font-mono); color: #111; padding: 0; }
.watch .wbtn.l { left: -6px; } .watch .wbtn.r { right: -6px; }
.watch .wbtn.t { top: 22%; } .watch .wbtn.b { bottom: 22%; }
.watch .wbtn:active, .watch .wbtn.down { filter: brightness(.8); }
.watch .wlabel { position: absolute; color: #ddd; font: 700 .6rem/1 var(--font-mono); letter-spacing: .05em; }

/* wall clock */
.dev-wall { background: linear-gradient(180deg, #d9c7a7, #b89d73); display: grid; place-items: center; }
.dev-wall svg { width: min(340px, 82vw); height: auto; touch-action: none; cursor: grab; }
.dev-wall svg:active { cursor: grabbing; }

/* radio */
.dev-radio { background: linear-gradient(180deg, #5b3b2a, #3a2418); color: #f1e2cf; }
.dev-radio .lcd { background: #160404; }
.dev-radio .controls { display: grid; gap: 12px; grid-template-columns: 1fr; margin-top: 12px; }
.dev-radio .keys { grid-template-columns: repeat(3, 1fr); }
.switch3 { display: inline-grid; grid-template-columns: repeat(3, 1fr); background: #1d120b; border-radius: 12px; padding: 4px; gap: 4px; }
.switch3 button { border: 0; border-radius: 9px; padding: 9px 6px; font: 700 .78rem/1 var(--font-mono); background: transparent; color: #bba58c; cursor: pointer; min-height: 40px; }
.switch3 button[aria-checked="true"] { background: #e8dccb; color: #2a1a10; }

/* vcr */
.dev-vcr { background: linear-gradient(180deg, #2b2c30, #17181b); color: #ccc; display: grid; gap: 14px; }
.tv { border-radius: 16px; background: #0b0b0d; padding: 12px; box-shadow: inset 0 0 0 4px #333; }
.tv .screen { border-radius: 10px; min-height: 170px; background: #1636a8; color: #fff; font: 700 .95rem/1.5 var(--font-mono); padding: 12px 14px; text-transform: uppercase; position: relative; overflow: hidden; }
.tv .screen.off { background: radial-gradient(circle, #222, #000); color: #666; }
.tv .screen .sel { background: #fff; color: #1636a8; }
.tv .screen .fld { padding: 0 3px; }
.tv .screen .fld.on { background: #ffe14d; color: #111; }
.vcr-box { border-radius: 10px; background: linear-gradient(180deg, #3a3b40, #222327); padding: 10px 12px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.vcr-box .slot { flex: 1; min-width: 120px; height: 18px; border-radius: 4px; background: #0b0b0c; box-shadow: inset 0 2px 4px #000; }
.vcr-box .lcd { background: #021412; padding: 6px 10px; }
.vcr-box .lcd svg { height: 34px; }
.remote { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 280px; margin: 0 auto; background: #202125; padding: 14px; border-radius: 30px 30px 18px 18px; }
.remote .key { background: linear-gradient(180deg, #4b4c52, #2d2e33); color: #eee; box-shadow: 0 3px 0 #0b0b0c; }
.remote .spacer { visibility: hidden; }

/* boiler */
.dev-boiler { background: linear-gradient(180deg, #f6f6f3, #d7d8d2); display: grid; place-items: center; gap: 8px; }
.dev-boiler svg { width: min(340px, 82vw); height: auto; touch-action: none; cursor: grab; }
.dev-boiler .shake { animation: shake .35s; }
@keyframes shake { 25% { transform: rotate(-2deg); } 75% { transform: rotate(2deg); } }

/* ---------- results ---------- */
.result-card {
  border-radius: 24px; padding: 22px; color: #fff4e6; position: relative; overflow: hidden;
  background: radial-gradient(circle at 85% 10%, #ffb347 0, transparent 35%), linear-gradient(160deg, #27307a, #13163a 70%);
  box-shadow: var(--shadow);
}
.result-card .rank { font-family: var(--font-display); font-weight: 800; font-size: clamp(1.8rem, 6vw, 2.6rem); line-height: 1.05; margin: 4px 0 10px; color: #ffcf7a; }
.result-card .big { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0; }
.result-card .big div { background: rgba(255,255,255,.08); border-radius: 14px; padding: 10px; text-align: center; }
.result-card .big b { display: block; font-family: var(--font-mono); font-size: clamp(1.1rem, 4.5vw, 1.6rem); }
.result-card .big span { font-size: .75rem; opacity: .8; }
.result-card .eyebrow { color: #ffcf7a; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.badge { background: rgba(255,255,255,.14); border-radius: 999px; padding: 4px 10px; font-size: .82rem; font-weight: 600; }
.splits { width: 100%; border-collapse: collapse; font-size: .92rem; margin-top: 12px; }
.splits th, .splits td { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--line); }
.splits td.num, .splits th.num { text-align: right; font-family: var(--font-mono); }
.splits tr.nemesis td { color: var(--bad); font-weight: 700; }
.shared-banner { border: 2px dashed var(--accent); }

/* toast */
.toast { position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 140%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 600; z-index: 99; transition: transform .25s; max-width: 90vw; text-align: center; }
.toast.show { transform: translate(-50%, 0); }

/* confetti-ish clocks */
.pop { position: fixed; pointer-events: none; font-size: 1.6rem; z-index: 90; animation: pop 1.1s ease-out forwards; }
@keyframes pop { from { opacity: 1; transform: translate(0,0) scale(.6); } to { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(1.2) rotate(var(--rot)); } }

/* ---------- generic sections ---------- */
.section { margin: 40px 0; }
.grid2 { display: grid; gap: 16px; }
@media (min-width: 820px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.grid3 { display: grid; gap: 14px; }
@media (min-width: 720px) { .grid3 { grid-template-columns: repeat(3, 1fr); } }
.factstrip { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.fact b { display: block; font-family: var(--font-display); font-size: 1.8rem; color: var(--accent); line-height: 1.1; }

/* ---------- forms ---------- */
select, input[type="search"], input[type="text"] {
  font: inherit; color: var(--ink); background: var(--card); border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px; min-height: 44px; max-width: 100%;
}
select:focus, input:focus { border-color: var(--accent); outline: none; }
label.field { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .9rem; }
.seg { display: inline-flex; background: var(--bg2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; color: var(--muted); font: 700 .88rem var(--font-body); padding: 8px 12px; border-radius: 999px; cursor: pointer; min-height: 38px; }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

/* ---------- lab ---------- */
.chart-wrap { position: relative; }
.chart-wrap svg { width: 100%; height: auto; display: block; }
.chart-tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--bg); font-size: .82rem; padding: 8px 10px; border-radius: 10px; white-space: nowrap; transform: translate(-50%, -110%); opacity: 0; transition: opacity .1s; z-index: 5; }
.chart-tip.show { opacity: 1; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .88rem; color: var(--muted); }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin-right: 6px; }
.ch-night { fill: #1f2558; }
:root[data-theme="dark"] .ch-night { fill: #0a0d22; }
.ch-day { fill: #ffc861; stroke: #e8951c; stroke-width: 1; }
.ch-ghost { fill: none; stroke: #ffffff; stroke-width: 2; stroke-dasharray: 5 4; opacity: .85; }
.ch-grid { stroke: rgba(255,255,255,.12); stroke-width: 1; }
.ch-ax { fill: var(--muted); font: 600 11px var(--font-body); }
.ch-ref { stroke: #d9481f; stroke-width: 1.5; stroke-dasharray: 2 4; }
.ch-reflabel { fill: #fff; font: 700 11px var(--font-body); paint-order: stroke; stroke: #1f2558; stroke-width: 3px; }
.ch-today { stroke: #fff; stroke-width: 2; }
.ch-cross { stroke: #fff; stroke-width: 1.5; }
.regime-cards { display: grid; gap: 12px; }
@media (min-width: 760px) { .regime-cards { grid-template-columns: repeat(3, 1fr); } }
.regime { border: 2px solid var(--line); border-radius: var(--radius); padding: 14px; background: var(--card); }
.regime.active { border-color: var(--accent); }
.regime h3 { margin-bottom: 4px; }
.regime dl { margin: 8px 0 0; display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: .9rem; }
.regime dt { color: var(--muted); }
.regime dd { margin: 0; font-family: var(--font-mono); font-weight: 700; text-align: right; }
.table-scroll { overflow-x: auto; }
table.data { border-collapse: collapse; width: 100%; font-size: .88rem; }
table.data th, table.data td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: right; font-family: var(--font-mono); white-space: nowrap; }
table.data th:first-child, table.data td:first-child { text-align: left; font-family: var(--font-body); }
table.data thead th { color: var(--muted); font-family: var(--font-body); font-weight: 700; }

/* ---------- atlas ---------- */
.atlas-list { display: grid; gap: 10px; }
@media (min-width: 720px) { .atlas-list { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1020px) { .atlas-list { grid-template-columns: repeat(3, 1fr); } }
.zone { border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: 12px 14px; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; }
.zone .city { font-weight: 700; }
.zone .now { font-family: var(--font-mono); font-weight: 700; font-size: 1.1rem; text-align: right; }
.zone .sub { color: var(--muted); font-size: .85rem; }
.zone .chg { grid-column: 1 / -1; font-size: .85rem; margin-top: 4px; }
.zone.soon { border-color: var(--accent); box-shadow: inset 4px 0 0 var(--accent); }
.tag { display: inline-block; font: 700 .7rem/1 var(--font-mono); padding: 3px 7px; border-radius: 6px; background: var(--bg2); border: 1px solid var(--line); margin-right: 4px; }
.tag.back { color: var(--night); }
.tag.fwd { color: var(--gold); }
.tag.none { color: var(--muted); }

/* ---------- history ---------- */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 14px; top: 0; bottom: 0; width: 3px; background: var(--line); border-radius: 2px; }
.timeline li { position: relative; padding: 0 0 22px 44px; }
.timeline li::before { content: ""; position: absolute; left: 6px; top: 6px; width: 19px; height: 19px; border-radius: 50%; background: var(--card); border: 3px solid var(--accent); }
.timeline .yr { font: 800 1.3rem/1.1 var(--font-display); color: var(--accent); }
.timeline h3 { margin: 2px 0 4px; font-size: 1.05rem; }
.timeline p { margin: 0; color: var(--muted); }
.quiz-q { font-family: var(--font-display); font-size: 1.35rem; font-weight: 700; line-height: 1.25; margin-bottom: 14px; }
.answers { display: grid; gap: 10px; }
.answer { text-align: left; font: 600 1rem var(--font-body); padding: 13px 16px; border-radius: 14px; border: 2px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; }
.answer:hover:not([disabled]) { border-color: var(--accent); }
.answer.right { border-color: var(--good); background: color-mix(in srgb, var(--good) 14%, var(--card)); }
.answer.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, var(--card)); }
.answer[disabled] { cursor: default; }
.explain { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: var(--bg2); }
.progress { height: 8px; background: var(--bg2); border-radius: 99px; overflow: hidden; margin-bottom: 14px; }
.progress span { display: block; height: 100%; background: var(--accent); width: 0; transition: width .3s; }

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