/* Halley's Crumbs — shared styles */
:root {
  --bg: #070b1f;
  --bg-2: #0e1533;
  --panel: #131c42;
  --panel-2: #1a2552;
  --line: #2a3770;
  --text: #eef1ff;
  --muted: #a9b3dc;
  --accent: #ffb547;      /* ember gold — a burning grain */
  --accent-2: #66e3ff;    /* comet ion-tail blue */
  --accent-3: #ff7aa8;    /* fireball pink */
  --good: #6ef0a8;
  --bad: #ff6b6b;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --radius: 16px;
  --font-display: "Bricolage Grotesque", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, Segoe UI, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #fbf5ea;
  --bg-2: #f3e9d7;
  --panel: #ffffff;
  --panel-2: #f6efe1;
  --line: #e0d3bb;
  --text: #17183a;
  --muted: #555a7d;
  --accent: #b35c00;
  --accent-2: #0b6f8a;
  --accent-3: #b8235a;
  --good: #17804a;
  --bad: #c22c2c;
  --shadow: 0 8px 24px rgba(40, 30, 10, .12);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
}
body::before {
  /* faint starfield behind every page */
  content: "";
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(1px 1px at 12% 18%, rgba(255,255,255,.7), transparent 60%),
    radial-gradient(1px 1px at 78% 12%, rgba(255,255,255,.5), transparent 60%),
    radial-gradient(1.5px 1.5px at 40% 70%, rgba(255,255,255,.5), transparent 60%),
    radial-gradient(1px 1px at 88% 64%, rgba(255,255,255,.6), transparent 60%),
    radial-gradient(1px 1px at 22% 88%, rgba(255,255,255,.4), transparent 60%),
    radial-gradient(1.2px 1.2px at 60% 35%, rgba(255,255,255,.5), transparent 60%),
    radial-gradient(ellipse at 70% -10%, rgba(102,227,255,.12), transparent 55%),
    radial-gradient(ellipse at 10% 110%, rgba(255,181,71,.10), transparent 55%);
}
:root[data-theme="light"] body::before {
  background:
    radial-gradient(ellipse at 70% -10%, rgba(11,111,138,.10), transparent 55%),
    radial-gradient(ellipse at 10% 110%, rgba(179,92,0,.10), transparent 55%);
}

a { color: var(--accent-2); }
a:hover { color: var(--accent); }
img, svg, canvas { max-width: 100%; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.12; letter-spacing: -.01em; margin: 0 0 .5em; }
h1 { font-size: clamp(2rem, 7vw, 3.6rem); font-weight: 800; }
h2 { font-size: clamp(1.4rem, 4.5vw, 2.1rem); font-weight: 700; }
h3 { font-size: 1.15rem; font-weight: 700; }
p { margin: 0 0 1em; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.center { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--accent); color: #111; padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip-link:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; border-radius: 6px; }

/* ---------- header / nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 30;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  max-width: 1120px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 12px;
}
.brand {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-display); font-weight: 800; font-size: 1.1rem;
  color: var(--text); text-decoration: none; white-space: nowrap;
}
.brand img { width: 28px; height: 28px; }
.brand span b { color: var(--accent); }
.nav { display: flex; gap: 4px; margin-left: auto; align-items: center; }
.nav a {
  color: var(--muted); text-decoration: none; padding: 7px 10px; border-radius: 10px;
  font-size: .92rem; font-weight: 600;
}
.nav a:hover { color: var(--text); background: var(--panel); }
.nav a[aria-current="page"] { color: var(--text); background: var(--panel-2); }
.icon-btn {
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  width: 38px; height: 38px; border-radius: 10px; cursor: pointer; font-size: 1.05rem;
  display: inline-grid; place-items: center; flex: 0 0 auto;
}
.icon-btn:hover { border-color: var(--accent-2); }
.menu-btn { display: none; }
@media (max-width: 820px) {
  .menu-btn { display: inline-grid; margin-left: auto; }
  .nav {
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--bg-2); border-bottom: 1px solid var(--line);
    padding: 6px 12px 12px; display: none;
  }
  .nav.open { display: flex; }
  .nav a { padding: 12px; font-size: 1rem; }
}

/* ---------- layout ---------- */
main { display: block; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.section { padding: 40px 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.card h3 { margin-bottom: .35em; }
.eyebrow {
  display: inline-block; font-family: var(--font-mono); font-size: .78rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 10px;
}
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 4px 10px; font-size: .82rem; font-weight: 600;
}
.page-hero { padding: 36px 0 12px; }
.page-hero p { color: var(--muted); max-width: 680px; font-size: 1.05rem; }

/* ---------- buttons ---------- */
.btn {
  appearance: none; border: 0; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 700 1rem var(--font-body);
  padding: 12px 20px; border-radius: 12px; min-height: 46px;
  background: var(--accent); color: #1b1200;
  transition: transform .12s ease, box-shadow .12s ease, background .2s;
  box-shadow: 0 4px 0 color-mix(in srgb, var(--accent) 55%, #000);
}
:root[data-theme="light"] .btn { color: #fff; }
.btn:hover { transform: translateY(-1px); color: #1b1200; }
:root[data-theme="light"] .btn:hover { color: #fff; }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 color-mix(in srgb, var(--accent) 55%, #000); }
.btn.secondary {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  box-shadow: 0 4px 0 var(--line);
}
.btn.secondary:hover { color: var(--text); border-color: var(--accent-2); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); box-shadow: none; }
.btn.ghost:hover { color: var(--text); border-color: var(--accent-2); }
.btn.small { padding: 8px 14px; min-height: 38px; font-size: .9rem; }
.btn[hidden] { display: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.seg button {
  font: 600 .92rem var(--font-body); color: var(--muted); cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px;
}
.seg button[aria-pressed="true"] { color: var(--text); border-color: var(--accent); background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--accent); }

/* ---------- forms ---------- */
label { font-weight: 600; font-size: .95rem; }
select, input[type="text"], input[type="number"] {
  font: inherit; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%;
}
input[type="range"] { width: 100%; accent-color: var(--accent); }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field .val { font-family: var(--font-mono); color: var(--accent); font-weight: 600; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--line); margin-top: 40px; padding: 24px 0 40px; color: var(--muted); font-size: .9rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 12px 24px; justify-content: space-between; }
.site-footer a { color: var(--muted); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px;
  font-weight: 600; opacity: 0; pointer-events: none; transition: .25s; z-index: 200; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- home / hero ---------- */
.hero { padding: 28px 0 8px; }
.hero-grid { display: grid; gap: 20px; align-items: center; grid-template-columns: 1fr; }
.hero h1 .glow { color: var(--accent); text-shadow: 0 0 24px color-mix(in srgb, var(--accent) 50%, transparent); }
.hero .lede { font-size: 1.1rem; color: var(--muted); max-width: 640px; }
.countdown {
  display: inline-flex; gap: 10px; align-items: center; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px;
  font-family: var(--font-mono); font-size: .9rem; margin-bottom: 14px;
}
.countdown b { color: var(--accent); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 10px var(--good); display: inline-block; }
.fact-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 18px 0; }
.fact-strip div { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.fact-strip b { display: block; font-family: var(--font-display); font-size: 1.5rem; color: var(--accent-2); }
.fact-strip span { color: var(--muted); font-size: .85rem; }

/* ---------- game ---------- */
.game-shell {
  position: relative; border-radius: 18px; overflow: hidden; border: 1px solid #2a3770;
  background: #040716; box-shadow: var(--shadow);
  aspect-ratio: 16 / 10; width: 100%; max-height: 78vh; min-height: 420px;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
@media (max-width: 640px) {
  .game-shell { aspect-ratio: 9 / 14; min-height: 520px; }
  .overlay { padding: 12px; }
  .overlay-card h2 { font-size: 1.3rem; }
  .legend { grid-template-columns: 1fr 1fr; gap: 6px; font-size: .78rem; margin: 10px 0; }
  .legend div { padding: 6px 8px; }
  .result-card { padding: 14px; }
  .result-stats b { font-size: 1.1rem; }
}
.game-shell canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }
.hud {
  position: absolute; left: 0; right: 0; top: 0; padding: 10px 12px;
  display: flex; justify-content: space-between; gap: 8px; pointer-events: none;
  font-family: var(--font-mono); color: #e9eeff; font-size: .82rem;
  text-shadow: 0 1px 4px #000;
}
.hud .box { background: rgba(5, 9, 30, .55); border: 1px solid rgba(120,140,220,.25); border-radius: 10px; padding: 6px 9px; }
.hud .big { font-size: 1.15rem; font-weight: 700; color: #ffb547; }
.hud-left, .hud-right { display: flex; flex-direction: column; gap: 6px; }
.hud-right { align-items: flex-end; text-align: right; }
.combo { color: #66e3ff; }
.overlay {
  position: absolute; inset: 0; display: flex; padding: 16px;
  background: radial-gradient(ellipse at center, rgba(4,7,22,.65), rgba(4,7,22,.92));
  color: #eef1ff; z-index: 5; overflow-y: auto;
}
.overlay[hidden] { display: none; }
.overlay-card { max-width: 560px; width: 100%; text-align: center; margin: auto; }
.overlay-card h2 { color: #fff; }
.overlay-card p { color: #c5ccef; }
.overlay .seg button { background: rgba(19,28,66,.9); color: #c5ccef; border-color: #2a3770; }
.overlay .seg button[aria-pressed="true"] { color: #fff; border-color: #ffb547; box-shadow: inset 0 0 0 1px #ffb547; }
.overlay .btn.secondary { background: #1a2552; color: #eef1ff; border-color: #2a3770; box-shadow: 0 4px 0 #2a3770; }
.overlay .btn { color: #1b1200; background: #ffb547; box-shadow: 0 4px 0 #8a5d1f; }
.overlay .btn.secondary { color: #eef1ff; background: #1a2552; }
.overlay .muted { color: #a9b3dc; }
.mode-desc { min-height: 3em; font-size: .92rem; }
.legend { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; text-align: left; margin: 14px 0; font-size: .88rem; }
.legend div { background: rgba(19,28,66,.75); border: 1px solid #2a3770; border-radius: 10px; padding: 8px 10px; color: #c5ccef; }
.legend b { color: #fff; }
.legend .yes b { color: #6ef0a8; }
.legend .no b { color: #ff8a8a; }
.float-label {
  position: absolute; pointer-events: none; font: 700 .9rem var(--font-body); color: #fff;
  text-shadow: 0 1px 6px #000; transform: translate(-50%, -100%); white-space: nowrap;
  animation: floatUp 1.1s ease-out forwards; z-index: 4;
}
.float-label.good { color: #6ef0a8; }
.float-label.bad { color: #ff8a8a; }
.float-label.gold { color: #ffd27a; font-size: 1.05rem; }
.float-label small { display: block; font-weight: 500; font-size: .75rem; color: #dfe4ff; }
@keyframes floatUp { from { opacity: 1; transform: translate(-50%, -100%); } to { opacity: 0; transform: translate(-50%, -190%); } }
.game-controls { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; margin-top: 10px; }
.kbd { font-family: var(--font-mono); background: var(--panel-2); border: 1px solid var(--line); border-bottom-width: 3px; border-radius: 6px; padding: 1px 6px; font-size: .85em; }

/* results */
.result-card {
  background: linear-gradient(160deg, #141d48, #0a0f2a 70%);
  border: 1px solid #34437f; border-radius: 18px; padding: 20px; color: #eef1ff; text-align: left;
}
.result-card .rank { font-family: var(--font-display); font-size: clamp(1.6rem, 6vw, 2.4rem); font-weight: 800; color: #ffb547; line-height: 1.1; }
.result-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.result-stats div { background: rgba(255,255,255,.05); border-radius: 10px; padding: 8px; text-align: center; }
.result-stats b { display: block; font-size: 1.3rem; font-family: var(--font-display); color: #66e3ff; }
.result-stats span { font-size: .75rem; color: #a9b3dc; }
.grain-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.grain {
  font-family: var(--font-mono); font-size: .78rem; padding: 3px 8px; border-radius: 999px;
  background: rgba(255,181,71,.12); border: 1px solid rgba(255,181,71,.4); color: #ffd9a0;
}
.grain.rare { background: rgba(255,122,168,.15); border-color: rgba(255,122,168,.6); color: #ffc2d6; }

/* shared result banner */
.shared-banner {
  border: 1px solid var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--panel));
  border-radius: 14px; padding: 14px 16px; margin: 14px 0;
}

/* ---------- radiant hunt ---------- */
.hunt-shell { position: relative; border-radius: 18px; overflow: hidden; border: 1px solid #2a3770; background: #040716; aspect-ratio: 1 / 1; max-height: 74vh; width: 100%; margin: 0 auto; touch-action: manipulation; }
.hunt-shell canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; }
.hunt-layout { display: grid; gap: 18px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .hunt-layout { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: start; } }
.level-dots { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.level-dots span { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font: 700 .75rem var(--font-mono); background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); }
.level-dots span.done { background: color-mix(in srgb, var(--good) 25%, var(--panel)); color: var(--text); border-color: var(--good); }
.level-dots span.now { border-color: var(--accent); color: var(--text); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 40%, transparent); }
.shower-card dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 10px 0 0; font-size: .92rem; }
.shower-card dt { color: var(--muted); }
.shower-card dd { margin: 0; font-weight: 600; }
.score-big { font-family: var(--font-display); font-size: 2.4rem; font-weight: 800; color: var(--accent); }

/* ---------- halley ---------- */
.orbit-shell { position: relative; border-radius: 18px; overflow: hidden; border: 1px solid #2a3770; background: #040716; aspect-ratio: 16/10; width: 100%; min-height: 320px; }
@media (max-width: 640px) { .orbit-shell { aspect-ratio: 1/1; } }
.orbit-shell canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.orbit-readout { position: absolute; left: 10px; top: 10px; font-family: var(--font-mono); font-size: .8rem; color: #dfe4ff; background: rgba(5,9,30,.6); border: 1px solid rgba(120,140,220,.25); padding: 8px 10px; border-radius: 10px; pointer-events: none; }
.orbit-readout b { color: #ffb547; }
@media (max-width: 640px) { .orbit-readout { font-size: .68rem; padding: 5px 7px; left: 6px; top: 6px; } }
.timeline { position: relative; margin: 20px 0; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 9px; top: 4px; bottom: 4px; width: 2px; background: linear-gradient(var(--accent-2), var(--accent)); border-radius: 2px; }
.t-item { position: relative; margin-bottom: 14px; }
.t-item::before { content: ""; position: absolute; left: -22px; top: 8px; width: 12px; height: 12px; border-radius: 50%; background: var(--bg); border: 2px solid var(--accent); }
.t-item.collected::before { background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.t-item .yr { font-family: var(--font-mono); font-weight: 700; color: var(--accent); }
.t-item .tag { font-size: .72rem; margin-left: 6px; vertical-align: middle; }
.t-item p { margin: 4px 0 0; color: var(--muted); font-size: .95rem; }
.t-filter { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- tonight ---------- */
.calc-layout { display: grid; gap: 18px; grid-template-columns: 1fr; }
@media (min-width: 880px) { .calc-layout { grid-template-columns: 1fr 1.1fr; } }
.rate-big { font-family: var(--font-display); font-size: clamp(3rem, 12vw, 5rem); font-weight: 800; color: var(--accent); line-height: 1; }
.chart-wrap { width: 100%; }
.chart-wrap svg { width: 100%; height: auto; display: block; }
.tips { counter-reset: tip; list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.tips li { counter-increment: tip; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px 12px 50px; position: relative; }
.tips li::before { content: counter(tip); position: absolute; left: 12px; top: 12px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #1b1200; font-weight: 800; font-size: .85rem; }
.checklist label { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; padding: 8px 0; border-bottom: 1px dashed var(--line); cursor: pointer; }
.checklist input { width: 20px; height: 20px; accent-color: var(--accent); flex: 0 0 auto; margin-top: 2px; }
.red-mode { position: fixed; inset: 0; background: rgba(255,0,0,.38); mix-blend-mode: multiply; pointer-events: none; z-index: 150; display: none; }
body.night-vision .red-mode { display: block; }

/* ---------- quiz ---------- */
.quiz-card { max-width: 680px; margin: 0 auto; }
.q-progress { height: 8px; background: var(--panel-2); border-radius: 999px; overflow: hidden; margin: 10px 0 18px; }
.q-progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent-2), var(--accent)); transition: width .3s; }
.q-text { font-family: var(--font-display); font-size: clamp(1.25rem, 4.5vw, 1.6rem); font-weight: 700; line-height: 1.25; margin-bottom: 16px; }
.answers { display: grid; gap: 10px; }
.answers button {
  text-align: left; font: 600 1rem var(--font-body); color: var(--text); cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
  transition: border-color .15s, background .15s, transform .1s;
}
.answers button:hover:not(:disabled) { border-color: var(--accent-2); transform: translateX(2px); }
.answers button.right { border-color: var(--good); background: color-mix(in srgb, var(--good) 15%, var(--panel)); }
.answers button.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 15%, var(--panel)); }
.answers button:disabled { cursor: default; }
.explain { margin-top: 14px; padding: 12px 14px; border-left: 3px solid var(--accent-2); background: var(--panel-2); border-radius: 0 10px 10px 0; }

/* ---------- prose ---------- */
.prose h2 { margin-top: 1.4em; }
.prose ul { padding-left: 1.2em; }
.prose li { margin-bottom: .4em; }
.source-list { font-size: .92rem; word-break: break-word; }

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