/* Scientist mode gets its own accent so the switch is visible at a glance */
:root[data-level="scientist"] { --accent: #c3a6ff; --accent-ink: #1c0f3a; }
:root {
  --bg: #0b1020;
  --bg-2: #10172e;
  --panel: #151d38;
  --panel-2: #1b2547;
  --line: #2a3663;
  --text: #eef2ff;
  --muted: #a8b3d6;
  --cyan: #5ce1e6;
  --accent: var(--cyan);
  --accent-ink: #04202a;
  --lime: #b8f35a;
  --amber: #ffb454;
  --pink: #ff7eb6;
  --violet: #c3a6ff;
  --radius: 18px;
  --display: 'Fredoka', ui-rounded, system-ui, sans-serif;
  --body: 'Nunito Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.6 var(--body); -webkit-font-smoothing: antialiased;
  background-image: radial-gradient(1200px 600px at 80% -10%, #1d2a5a 0%, transparent 60%), radial-gradient(900px 500px at -10% 30%, #13254a 0%, transparent 55%);
  background-attachment: fixed;
}
h1, h2, h3, h4 { font-family: var(--display); font-weight: 600; line-height: 1.15; margin: 0 0 .5em; letter-spacing: .005em; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 8px; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: rgba(11, 16, 32, .78); backdrop-filter: blur(12px); border-bottom: 1px solid rgba(255,255,255,.06);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--display); font-size: 1.35rem; font-weight: 700; color: var(--accent); }
.brand svg { width: 30px; height: 30px; }
.brand span { color: var(--text); }
.toggles { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 5px 12px; border-radius: 999px; font-size: .85rem; font-weight: 700; color: var(--muted); white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

/* ---------- hero ---------- */
.hero { position: relative; overflow: hidden; padding: 72px 16px 56px; }
#hero-bg { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero-inner { position: relative; max-width: 860px; margin: 0 auto; text-align: center; }
.hero::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse 48% 55% at 50% 52%, rgba(11,16,32,.82), rgba(11,16,32,0) 75%); }
.hero-inner { z-index: 1; }
.eyebrow { display: inline-block; margin: 0 0 14px; padding: 4px 14px; border-radius: 999px; background: rgba(184,243,90,.12); color: var(--lime); font-weight: 800; font-size: .85rem; letter-spacing: .08em; text-transform: uppercase; }
.hero h1 { font-size: clamp(2.1rem, 5.5vw, 3.9rem); font-weight: 700; margin-bottom: 16px; }
.lede { font-size: clamp(1.05rem, 2vw, 1.25rem); color: var(--muted); max-width: 660px; margin: 0 auto 28px; }
.mode { display: inline-block; margin: -8px auto 26px; padding: 8px 16px; max-width: 620px; border-radius: 14px; border: 1px solid var(--accent); color: var(--accent); background: rgba(11,16,32,.6); font-weight: 700; font-size: .95rem; }
.progress { max-width: 520px; margin: 0 auto; }
.bar { height: 12px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--lime)); border-radius: 999px; transition: width .8s cubic-bezier(.2,.7,.3,1); }
.dots { display: flex; justify-content: center; gap: 6px; margin: 12px 0 6px; flex-wrap: wrap; }
.dots i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line); background: transparent; }
.dots i.on { background: var(--lime); border-color: var(--lime); box-shadow: 0 0 10px rgba(184,243,90,.6); }
#progress-text { margin: 0; color: var(--muted); font-weight: 600; }

/* ---------- basics ---------- */
.basics { margin-top: 24px; }
.basics > h2, .missions > h2 { font-size: clamp(1.6rem, 3vw, 2.2rem); }
.basics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.basics article { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; position: relative; }
.basics .num { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--panel-2); color: var(--amber); font: 700 1.3rem var(--display); margin-bottom: 12px; }
.basics h3 { font-size: 1.2rem; }
.basics p, .basics ul { margin: 0; color: var(--muted); }
.basics ul { padding-left: 1.1em; }

/* ---------- missions ---------- */
.missions { margin-top: 56px; padding-bottom: 40px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.chip { border: 1px solid var(--line); background: var(--panel); padding: 6px 14px; border-radius: 999px; font-weight: 700; font-size: .9rem; color: var(--muted); }
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.card {
  display: flex; flex-direction: column; text-decoration: none; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.card:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: 0 14px 40px rgba(0,0,0,.35); }
.thumb { position: relative; display: grid; place-items: center; padding: 22px 0 12px; background: radial-gradient(circle at 50% 45%, #1f2b55 0%, var(--panel) 70%); }
.thumb canvas { width: 150px; height: 150px; border-radius: 50%; box-shadow: 0 0 0 6px #070a14, 0 0 0 8px #2f3b6b, 0 10px 30px rgba(0,0,0,.5); filter: blur(9px) saturate(.7); transform: scale(.98); transition: filter .6s ease; }
.card.is-focused .thumb canvas { filter: none; }
.thumb-state { position: absolute; top: 12px; right: 12px; font-size: .75rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; padding: 3px 10px; border-radius: 999px; background: rgba(255,255,255,.08); color: var(--muted); }
.card.is-focused .thumb-state { background: rgba(184,243,90,.15); color: var(--lime); }
.card-body { padding: 14px 18px 18px; display: flex; flex-direction: column; flex: 1; }
.kicker { margin: 0 0 4px; font-size: .78rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--accent); }
.kicker .bonus, .bonus { color: var(--pink); }
.card h3 { font-size: 1.3rem; margin-bottom: 6px; }
.card .hook { margin: 0 0 14px; color: var(--muted); font-size: .95rem; flex: 1; }
.meta { display: flex; justify-content: space-between; margin: 0; font-size: .85rem; font-weight: 700; color: var(--muted); }
.diff.d1 { color: var(--lime); } .diff.d2 { color: var(--amber); } .diff.d3 { color: var(--pink); }

/* ---------- gear for grown-ups ---------- */
.gear { margin-top: 56px; }
.gear > h2 { font-size: clamp(1.4rem, 2.6vw, 1.9rem); }
.gear-lede, .gear-note, .gear-kitchen { color: var(--muted); max-width: 72ch; }
.gear-note { font-size: .88rem; border-left: 3px solid var(--line); padding-left: 10px; }
.gear-filter { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 8px 0 14px; font-weight: 700; }
.gear-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; margin-top: 14px; }
.gear-grid article { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; }
.gear-grid h3 { font-size: 1.05rem; margin: 0; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.gear-grid .price { color: var(--muted); font: 700 .85rem var(--body); white-space: nowrap; }
.gear-grid p { margin: 0; color: var(--muted); font-size: .92rem; }
.gear-grid .used { font-size: .8rem; }
.gear-grid .used a { color: var(--accent); text-decoration: none; }
.gear-grid .used a:hover { text-decoration: underline; }
.gear-grid .shops { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 4px; }
.gear-grid .shops a { border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: .85rem; font-weight: 700; color: var(--text); text-decoration: none; }
.gear-grid .shops a:hover { border-color: var(--accent); }
.gear-link { display: block; margin-top: 8px; font-size: .9rem; text-align: left; }
footer { padding: 28px 16px 48px; color: var(--muted); font-size: .92rem; text-align: center; border-top: 1px solid rgba(255,255,255,.06); }

/* ---------- dialog ---------- */
dialog { border: 0; padding: 0; background: transparent; color: var(--text); max-width: min(1180px, calc(100vw - 32px)); width: 100%; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); }
dialog:focus, dialog:focus-visible, .dlg-scroll:focus, .dlg-scroll:focus-visible { outline: none; }
dialog::backdrop { background: rgba(4, 7, 16, .78); backdrop-filter: blur(6px); }
dialog[open] { animation: pop .28s cubic-bezier(.2,.8,.3,1.1); }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.98); } }
.dlg-scroll { background: var(--bg-2); border: 1px solid var(--line); border-radius: 24px; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow: auto; overscroll-behavior: contain; }
.dlg-bar { position: sticky; top: 0; z-index: 3; display: flex; gap: 8px; justify-content: flex-end; padding: 10px 12px 0; pointer-events: none; }
.icon-btn { pointer-events: auto; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); font-size: 1.3rem; line-height: 1; display: grid; place-items: center; }
.icon-btn:hover:not(:disabled) { border-color: var(--accent); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.dlg-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 32px; padding: 0 32px 32px; margin-top: -30px; }
.dlg-lens { position: sticky; top: 20px; align-self: start; padding-top: 20px; }
.scope { padding: 18px; border-radius: 50%; background: radial-gradient(circle, #0a0d18 62%, #1a2244 63%, #0c1022 72%); box-shadow: 0 30px 60px rgba(0,0,0,.5), inset 0 0 0 2px #2f3b6b; }
.lens-wrap { position: relative; width: 100%; aspect-ratio: 1; border-radius: 50%; overflow: hidden; background: #000; }
#lens { display: block; width: 100%; height: 100%; border-radius: 50%; transition: filter .25s ease; }
#lens-labels { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.names-hint { align-self: end; margin: 0 0 6px; font-size: .85rem; color: var(--muted); line-height: 1.35; }
.names-hint::before { content: ''; display: inline-block; width: 7px; height: 7px; margin-right: 7px; vertical-align: 1px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1.5px rgba(22,28,52,.7), 0 0 0 4px rgba(255,255,255,.35); }
.names-hint:empty { display: none; }
#names button:disabled { opacity: .4; cursor: default; }
.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; }
.lens-overlay { position: absolute; inset: 0; display: grid; place-items: center; font: 600 1.4rem var(--display); color: rgba(255,255,255,.92); text-shadow: 0 2px 12px rgba(0,0,0,.6); letter-spacing: .04em; pointer-events: none; }
.spark { position: absolute; left: 50%; top: 50%; border-radius: 50%; pointer-events: none; }
.controls { display: grid; grid-template-columns: auto 1fr; gap: 12px 22px; margin-top: 10px; align-items: start; }
.ctl { display: flex; flex-direction: column; gap: 4px; font-size: .82rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); min-width: 0; }
.ctl.wide { grid-column: 1 / -1; }
.objs { align-self: flex-start; }
.objs button { font-size: .95rem; padding: 5px 14px; letter-spacing: 0; }
.objs button:disabled { opacity: .4; cursor: default; }
.readout { margin-top: 12px; padding: 10px 14px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); font-size: .9rem; color: var(--muted); }
.readout p { margin: 0; }
.readout p:first-child { color: var(--text); font-weight: 700; }
.readout p:empty { display: none; }
#camout { color: var(--amber); }
.scalebar { position: absolute; left: 0; right: 0; bottom: 13%; display: flex; flex-direction: column; align-items: center; gap: 3px; pointer-events: none; }
.scalebar i { display: block; height: 5px; background: #fff; border: 1px solid #111; border-radius: 2px; box-shadow: 0 0 6px rgba(0,0,0,.5); transition: width .25s ease; }
.scalebar span { font: 700 .8rem var(--body); color: #fff; background: rgba(10,12,20,.72); padding: 1px 8px; border-radius: 999px; }
.lens-hint { text-align: center; font-weight: 700; color: var(--amber); margin: 14px 0 0; min-height: 1.6em; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 30px; background: transparent; }
input[type=range]::-webkit-slider-runnable-track { height: 10px; border-radius: 999px; background: linear-gradient(90deg, var(--panel-2), var(--line)); border: 1px solid var(--line); }
input[type=range]::-moz-range-track { height: 10px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; margin-top: -9px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff, var(--accent) 60%); border: 3px solid #0b1020; box-shadow: 0 0 0 2px var(--accent); }
input[type=range]::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); border: 3px solid #0b1020; box-shadow: 0 0 0 2px var(--accent); }
input[type=range]:disabled { opacity: .4; }
input[type=range]:disabled::-webkit-slider-thumb { background: #59607a; box-shadow: 0 0 0 2px #59607a; }
.dlg-body { padding-top: 34px; }
.dlg-body h2 { font-size: clamp(1.8rem, 3.5vw, 2.5rem); font-weight: 700; }
.dlg-body .hook { font-size: 1.12rem; color: var(--muted); margin-top: 0; }
.dlg-body h3 { font-size: 1.15rem; color: var(--accent); margin-top: 1.4em; }
.dlg-body ul, .dlg-body ol { padding-left: 1.2em; margin: 0; }
.dlg-body li { margin-bottom: .3em; }
.two { display: grid; grid-template-columns: 1fr 1.3fr; gap: 24px; }
.safety { margin: 20px 0 0; padding: 12px 16px; border-radius: 12px; background: rgba(255,180,84,.1); border-left: 4px solid var(--amber); }
.safety strong { color: var(--amber); }
.extra { margin: 14px 0 0; padding: 12px 16px; border-radius: 12px; background: var(--panel); border-left: 4px solid var(--accent); }
.extra h4 { margin: 0 0 4px; font-size: 1.02rem; color: var(--accent); }
.extra p { margin: 0; }
.other { margin-top: 10px; padding: 12px 16px; border-radius: 12px; background: var(--panel); border: 1px dashed var(--line); color: var(--muted); }
textarea { width: 100%; resize: vertical; font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
textarea:focus { outline: none; border-color: var(--accent); }
.did-it-wrap { margin-top: 22px; }
.cta { width: 100%; border: 0; border-radius: 14px; padding: 16px 20px; font: 600 1.15rem var(--display); background: linear-gradient(135deg, var(--lime), var(--accent)); color: #06202a; box-shadow: 0 10px 30px rgba(92,225,230,.25); transition: transform .15s ease; }
.cta:hover { transform: translateY(-2px); }
.note { color: var(--muted); font-size: .92rem; margin: 10px 0 0; text-align: center; }
.results { margin-top: 10px; animation: rise .6s ease both; scroll-margin-top: 60px; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
.pred { margin-top: 12px; padding: 12px 16px; border-radius: 12px; background: var(--panel); border: 1px dashed var(--line); color: var(--muted); }
.pred strong { color: var(--violet); }
.callouts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 22px; }
.callout { padding: 16px 18px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); }
.callout h4 { margin: 0 0 6px; font-size: 1.05rem; }
.callout p { margin: 0; }
.callout.fact h4 { color: var(--lime); }
.callout.chal h4 { color: var(--pink); }
.size { margin-top: 18px; color: var(--muted); }
.size strong { color: var(--text); }
.link-btn { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; font-size: .9rem; margin-top: 12px; }

@media (min-width: 861px) {
  /* on a short screen the lens gives way, so the knobs and names under it stay in view */
  .scope { max-width: max(280px, min(100%, calc(100vh - 362px))); margin: 0 auto; }
}
@media (max-width: 860px) {
  .dlg-grid { grid-template-columns: 1fr; padding: 0 16px 24px; gap: 8px; }
  .dlg-lens { position: static; max-width: 420px; width: 100%; margin: 0 auto; }
  .two, .callouts { grid-template-columns: 1fr; }
  .dlg-body { padding-top: 8px; }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  dialog { max-width: 100vw; max-height: 100dvh; margin: 0; height: 100dvh; }
  .dlg-scroll { border-radius: 0; max-height: 100dvh; height: 100dvh; border: 0; }
  .top { flex-wrap: wrap; }
  .seg button { padding: 5px 9px; }
  .hero { padding: 48px 16px 40px; }
  .scope { padding: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}
