:root {
  --page: #eef2f8;
  --panel: #ffffff;
  --ink: #14213d;
  --muted: #5b6b86;
  --accent: #2f80ed;
  --line: #d5dceb;
  --btn: #eef2fa;
  --gold: #ffd166;
  --ok: #4ade80;
  --bad: #ff8a8a;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #0b1220;
    --panel: #131c2e;
    --ink: #e8eefc;
    --muted: #9aa8c4;
    --accent: #6aa8ff;
    --line: #26324a;
    --btn: #1c2840;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--page);
  color: var(--ink);
}

.page { max-width: 1120px; margin: 0 auto; padding: 24px 16px 40px; }

header h1 { font-size: clamp(20px, 3vw, 28px); margin: 0 0 4px; }
.home-link { display: inline-block; margin-bottom: 8px; font-size: 14px; font-weight: 600; color: var(--accent); text-decoration: none; }
.home-link:hover { text-decoration: underline; }
header p { margin: 0 0 16px; color: var(--muted); }

.player {
  background: var(--panel);
  border-radius: 20px;
  padding: 12px;
  box-shadow: 0 10px 30px rgba(20, 33, 61, .12);
}

/* ---------- Stage ---------- */

.stage {
  position: relative;
  aspect-ratio: 16 / 9;
  container-type: inline-size;
  border-radius: 14px;
  overflow: hidden;
  background: radial-gradient(120% 90% at 50% 40%, #1b2f55 0%, #0b1428 70%);
  color: #fff;
  user-select: none;
}

.viewport { position: absolute; inset: 0; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; transition: filter .6s; }
.stage.activity-on #scene { filter: blur(4px) brightness(.4); }

.layer {
  transform-box: view-box;
  transition: transform 1.6s cubic-bezier(.65, 0, .25, 1), opacity .9s ease .35s;
}
.layer.is-future { opacity: 0; transform: scale(.12); transform-origin: var(--from); }
.layer.is-active { opacity: 1; transform: scale(1); transform-origin: var(--from); }
.layer.is-past {
  opacity: 0;
  transform: scale(7);
  transform-origin: var(--to);
  transition: transform 1.6s cubic-bezier(.65, 0, .25, 1), opacity .7s ease .5s;
}
.layer.fade, .layer.fade.is-past, .layer.fade.is-future { transform: none; transition: opacity .8s ease .3s; }
.layer.fade.is-past, .layer.fade.is-future { opacity: 0; }

#scene [data-el] { opacity: 0; transition: opacity .6s; }
#scene [data-el].on { opacity: 1; }

.pointer path, .callout {
  fill: none;
  stroke: rgba(255, 255, 255, .75);
  stroke-width: 4;
  stroke-dasharray: 10 8;
  stroke-linecap: round;
}

.question {
  font: 800 190px system-ui, sans-serif;
  fill: var(--gold);
  transform-box: fill-box;
  transform-origin: center;
}
.question.on { animation: pop .8s cubic-bezier(.2, 1.6, .4, 1); }

.pulse { transform-box: fill-box; transform-origin: center; }
.pulse.on { animation: pulse 1.6s ease-out infinite; }

.strand { fill: none; stroke: #f3d9a4; stroke-width: 16; stroke-linecap: round; }
#helix line, #nt-helix-strands line { stroke-width: 10; stroke-linecap: round; }
.bond { stroke: #e8eefc; stroke-width: 6; stroke-linecap: round; }
.beam { animation: beam 1s linear infinite; }

.base-letter { font: 800 36px system-ui, sans-serif; fill: #0d1730; }
.base-letter.light { fill: #fff; }
.part-letter { font: 800 24px system-ui, sans-serif; fill: #0d1730; }
.part-letter.big { font-size: 36px; }
.allele-letter { font: 800 34px system-ui, sans-serif; fill: #fff; }
.amino-letter { font: 800 24px system-ui, sans-serif; fill: #0d1730; }
.svg-small { font: 600 24px system-ui, sans-serif; fill: #fff; }
.row-label { font: 700 30px system-ui, sans-serif; fill: #cfd9ef; }
.row-label.small { font-size: 24px; }
.word-letter { font: 800 44px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 6px; fill: #fff; }
.word-letter .hl { fill: var(--gold); }
.base-letter.ghost { fill: #ff8a8a; opacity: .75; }
.allele-label { font: 800 30px system-ui, sans-serif; fill: #fff; }
.allele-label.small { font-size: 22px; }
.badge-text { font: 800 34px system-ui, sans-serif; fill: #14213d; }
.badge-text.light { fill: #fff; }
.badge-text.small { font-size: 24px; }
.big-question { font: 800 120px system-ui, sans-serif; fill: #ff8a8a; }
.step-caption { font: 600 22px system-ui, sans-serif; fill: #e8eefc; }
.sim-label { font: 600 16px system-ui, sans-serif; fill: #9fb4dd; }
.sim-combo { font: 800 15px ui-monospace, SFMono-Regular, Menlo, monospace; fill: #fff; letter-spacing: 1px; }
.sim-combo.big { font-size: 26px; }
.sim-axis { font: 600 22px system-ui, sans-serif; fill: #9fb4dd; }
.bead-letter { font-weight: 800; font-family: system-ui, sans-serif; }
.pop-in.on { animation: pop .6s cubic-bezier(.2, 1.6, .4, 1); transform-box: fill-box; transform-origin: center; }

@keyframes pop { 0% { transform: scale(.2); } 100% { transform: scale(1); } }
@keyframes pulse { 0% { transform: scale(.95); opacity: .9; } 100% { transform: scale(1.3); opacity: 0; } }
@keyframes beam { to { stroke-dashoffset: -32; } }

.chip {
  position: absolute;
  top: 2cqw;
  left: 2cqw;
  font-size: max(10px, 1.3cqw);
  font-weight: 600;
  padding: .4em .9em;
  border-radius: 999px;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .2);
}

.lbl, .flow {
  position: absolute;
  left: var(--x);
  top: var(--y);
  transform: translate(-50%, -50%) scale(.85);
  opacity: 0;
  transition: opacity .5s, transform .5s;
  pointer-events: none;
}
.lbl.on, .flow.on { opacity: 1; transform: translate(-50%, -50%) scale(1); }

.lbl {
  font-size: max(10px, 1.6cqw);
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  padding: .35em .85em;
  border-radius: .7em;
  background: rgba(8, 14, 30, .82);
  border: 1px solid rgba(255, 255, 255, .28);
}
.lbl small { display: block; font-size: .7em; font-weight: 500; opacity: .8; }
.lbl.gold { border-color: var(--gold); color: #ffe7a8; }

.flow {
  display: flex;
  align-items: center;
  gap: .4em;
  font-size: max(9px, 1.3cqw);
  font-weight: 700;
  white-space: nowrap;
}
.flow span { padding: .4em .7em; border-radius: .6em; background: rgba(8, 14, 30, .85); border: 1px solid var(--gold); }
.flow i { font-style: normal; color: var(--gold); }

.defcard {
  position: absolute;
  top: 6cqw;
  left: 2cqw;
  width: 33cqw;
  padding: 1.1cqw 1.4cqw;
  border-radius: 1cqw;
  background: rgba(8, 14, 30, .88);
  border: 1px solid rgba(255, 255, 255, .18);
  border-left: 5px solid var(--gold);
  opacity: 0;
  transform: translateX(-12px);
  transition: opacity .5s, transform .5s;
  pointer-events: none;
}
.defcard.on { opacity: 1; transform: none; }
.defcard p { margin: 0; }
.defcard-tag { font-size: max(9px, 1.05cqw); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--gold); }
.defcard-term { font-size: max(13px, 2cqw); font-weight: 800; margin: .2em 0 .3em !important; }
.defcard-def { font-size: max(11px, 1.45cqw); line-height: 1.4; }

.recap {
  position: absolute;
  left: 50%;
  top: 45%;
  transform: translate(-50%, -50%);
  width: min(84cqw, 100% - 24px);
  padding: 2cqw 2.6cqw;
  border-radius: 1.4cqw;
  background: rgba(8, 14, 30, .88);
  border: 1px solid rgba(255, 255, 255, .2);
  opacity: 0;
  transition: opacity .6s;
}
.recap.on { opacity: 1; }
.recap-title { margin: 0 0 .6em; font-size: max(14px, 2.2cqw); font-weight: 800; color: var(--gold); }
.recap ul { margin: 0; padding-left: 1.2em; display: grid; gap: .6em; }
.recap li { font-size: max(11px, 1.55cqw); line-height: 1.4; opacity: .15; transition: opacity .6s; }
.recap li.on { opacity: 1; }
.recap li.next-up { list-style: "→ "; color: #ffe7a8; }

.caption {
  position: absolute;
  left: 50%;
  bottom: 3cqw;
  transform: translateX(-50%);
  width: max-content;
  max-width: 86%;
  text-align: center;
  font-size: max(12px, 2.1cqw);
  line-height: 1.35;
  padding: .45em .9em;
  border-radius: .5em;
  background: rgba(6, 10, 20, .8);
}
.caption:empty, .stage.cc-off .caption, .stage.activity-on .caption { display: none; }
.stage.activity-on .chip, .stage.activity-on .defcard { opacity: 0; }

/* ---------- Activities ---------- */

.activity {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  display: flex;
  padding: 2.4cqw;
  font-size: max(12px, 1.55cqw);
}
.activity[hidden] { display: none; }

.act {
  margin: auto;
  width: min(100%, 78cqw);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: max(8px, 1.3cqw);
}
.act[hidden] { display: none; }
.act.wide { width: min(100%, 84cqw); align-items: stretch; }

.act-title { margin: 0; font-size: max(14px, 2.2cqw); font-weight: 800; text-align: center; line-height: 1.3; }
.act-title b { color: var(--gold); }
code.seq { font: 800 1em ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; padding: .1em .4em; border-radius: .3em; background: rgba(255, 255, 255, .1); white-space: pre; }
code.seq mark { background: var(--gold); color: #14213d; border-radius: .2em; padding: 0 .1em; }
.act-title code.seq { font-size: .95em; }
.keypad.small .key { width: max(40px, 5cqw); height: max(40px, 5cqw); font-size: 1.15em; }
.keypad[hidden] { display: none; }
.keypad .lab-label { align-self: center; }
.key:disabled { opacity: .3; cursor: default; }
.lab-result { display: flex; flex-direction: column; align-items: center; gap: max(4px, .6cqw); width: 100%; }
.lab-base.ghost-base { background: transparent !important; color: #ff8a8a; border: 2px dashed #ff8a8a; text-decoration: line-through; }
.act-counter { margin: 0; font-size: max(11px, 1.3cqw); font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: #9fb4dd; text-align: center; }
.act-feedback { margin: 0; min-height: 1.4em; text-align: center; line-height: 1.4; }
.act-feedback.ok { color: #c9f7d4; }
.act-feedback.wrong { color: #ffd0d0; }
.act-actions { display: flex; gap: 10px; justify-content: center; }

.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes land { from { transform: scale(.8); } to { transform: scale(1); } }

.row4 {
  display: grid;
  grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr));
  gap: max(6px, 1.4cqw);
  width: 100%;
}

.slot {
  position: relative;
  height: max(52px, 10cqw);
  border: 2px dashed rgba(255, 255, 255, .35);
  border-radius: .8em;
  display: grid;
  place-items: center;
  white-space: nowrap;
  color: rgba(255, 255, 255, .6);
}
.slot > .tile { position: absolute; inset: -2px; height: auto; }

.tile, .chip-btn, .key {
  font: inherit;
  color: #fff;
  background: #1d2b4b;
  border: 2px solid #3a4f7d;
  border-radius: .8em;
  cursor: pointer;
  transition: background .2s, border-color .2s, transform .15s;
}
.tile:hover:not(:disabled), .chip-btn:hover:not(:disabled), .key:hover { border-color: #6f8bc4; }
.tile:focus-visible, .chip-btn:focus-visible, .key:focus-visible, .part:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.tile:disabled, .chip-btn:disabled { cursor: default; }

.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .3em;
  height: max(52px, 10cqw);
  font-weight: 700;
}
.tile svg { width: max(20px, 3.6cqw); height: max(20px, 3.6cqw); }
.tile.ghost { visibility: hidden; }
.tile.hint { box-shadow: 0 0 0 3px var(--gold); }

.correct { background: #1f5a3a !important; border-color: var(--ok) !important; animation: land .35s ease-out; }
.wrong, .shake { border-color: var(--bad) !important; }
.selected { border-color: var(--gold) !important; background: #2c3d66 !important; }

.match { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2.2fr); gap: max(8px, 1.4cqw); width: 100%; }
.match-col { display: flex; flex-direction: column; gap: max(6px, .9cqw); }
.chip-btn { padding: .55em .9em; text-align: left; line-height: 1.3; }
.chip-btn.term { font-weight: 800; text-align: center; }
.chip-btn.def { font-weight: 500; }

.nt-figure { width: min(100%, 62cqw); }
.nt-figure svg { width: 100%; height: auto; display: block; }
.part { cursor: pointer; transition: filter .2s; }
.part:hover { filter: brightness(1.15); }
.part-name { font: 700 26px system-ui, sans-serif; fill: #fff; opacity: 0; transition: opacity .4s; }
.part.found .part-name { opacity: 1; }
.part.found circle, .part.found polygon, .part.found rect { stroke: var(--ok); stroke-width: 6; }

.strand-box { display: grid; grid-template-columns: auto auto; align-items: center; gap: max(6px, 1cqw) max(8px, 1.4cqw); }
.strand-label { font-size: .85em; font-weight: 700; color: #9fb4dd; white-space: nowrap; }
.strand-row { display: flex; gap: max(4px, .7cqw); }
.base {
  width: max(30px, 4.6cqw);
  height: max(30px, 4.6cqw);
  display: grid;
  place-items: center;
  border-radius: .5em;
  font-weight: 800;
  font-size: 1.15em;
  color: #0d1730;
}
.b-A { background: #5cc96b; }
.b-T { background: #ff6b6b; }
.b-C { background: #4dabf7; }
.b-G { background: #ffd43b; }
.slot-base { background: transparent; border: 2px dashed rgba(255, 255, 255, .4); color: rgba(255, 255, 255, .6); }
.slot-base.next { border-color: var(--gold); border-style: solid; color: var(--gold); }
.base.placed { animation: land .3s ease-out; }
.keypad { display: flex; gap: max(8px, 1.4cqw); }
.key { width: max(48px, 6.4cqw); height: max(48px, 6.4cqw); font-size: 1.4em; color: #0d1730; border-color: rgba(255, 255, 255, .5); }

.options { display: flex; flex-direction: column; gap: max(6px, .9cqw); width: 100%; }
.option { width: 100%; }

.triplets { display: flex; flex-wrap: wrap; justify-content: center; gap: max(8px, 1.4cqw); }
.triplet { display: flex; gap: 3px; padding: 4px; border-radius: .6em; border: 2px solid transparent; transition: opacity .3s, border-color .3s; }
.triplet span {
  width: max(24px, 3.2cqw);
  height: max(28px, 3.8cqw);
  display: grid;
  place-items: center;
  border-radius: .35em;
  font-weight: 800;
  color: #0d1730;
}
.triplet.current { border-color: var(--gold); }
.triplet.done { opacity: .45; }
.codon-grid { display: grid; grid-template-columns: auto 1fr; gap: max(10px, 2cqw); align-items: start; width: 100%; }
.codon-key { display: flex; flex-direction: column; gap: 2px; padding: .6em .9em; border-radius: .7em; background: rgba(255, 255, 255, .07); font-size: .92em; }
.key-title { font-weight: 800; color: var(--gold); margin-bottom: .2em; }
.key-item code { font: 700 1em ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; }
.amino-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(max(64px, 8cqw), 1fr)); gap: max(6px, 1cqw); }
.chip-btn.amino { text-align: center; font-weight: 800; border-left: 6px solid var(--amino); }
.chain { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; min-height: max(34px, 4.6cqw); }
.chain-label { font-weight: 700; color: #9fb4dd; margin-right: .4em; }
.bead {
  width: max(34px, 4.6cqw);
  height: max(34px, 4.6cqw);
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--amino);
  color: #0d1730;
  font-weight: 800;
  font-size: .85em;
  animation: land .3s ease-out;
}

.answer {
  width: 100%;
  font: inherit;
  line-height: 1.45;
  padding: .7em .9em;
  border-radius: .7em;
  border: 2px solid #3a4f7d;
  background: #0f1a33;
  color: #fff;
  resize: vertical;
  user-select: text;
}
.answer:focus { outline: none; border-color: var(--gold); }
.exam-result { padding: .8em 1em; border-radius: .8em; background: rgba(255, 255, 255, .07); line-height: 1.45; }
.exam-result[hidden] { display: none; }
.exam-score { margin: 0 0 .4em; font-weight: 800; color: var(--gold); }
.ideas { margin: 0 0 .6em; padding: 0; list-style: none; display: grid; gap: .2em; }
.ideas .hit { color: #c9f7d4; }
.ideas .miss { color: #b9c3d8; }
.model { margin: 0; }
.exam-note { margin: .6em 0 0; font-size: .85em; color: #9fb4dd; }

.sort-card {
  align-self: center;
  min-width: min(100%, 40cqw);
  padding: .9em 1.4em;
  border-radius: .9em;
  background: #f6f2ea;
  color: #14213d;
  font-size: 1.2em;
  font-weight: 800;
  text-align: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
}
.sort-buttons { display: flex; justify-content: center; gap: max(8px, 1.4cqw); }
.sort-btn { font-weight: 800; text-align: center; padding: .6em 1.2em; }
.sort-bins { display: grid; grid-template-columns: 1fr 1fr; gap: max(8px, 1.4cqw); width: 100%; }
.sort-bin { min-height: 4em; padding: .6em .9em; border-radius: .8em; border: 2px dashed rgba(255, 255, 255, .3); }
.sort-bin-title { margin: 0 0 .3em; font-weight: 800; color: var(--gold); }
.sort-list { margin: 0; padding-left: 1.1em; display: grid; gap: .15em; }

.lab-row { display: flex; flex-wrap: wrap; justify-content: center; gap: max(6px, 1cqw) max(8px, 1.2cqw); }
.lab-triplet { display: flex; gap: max(3px, .4cqw); }
.lab-base {
  width: max(26px, 3.6cqw);
  height: max(30px, 4.2cqw);
  display: grid;
  place-items: center;
  border-radius: .4em;
  font-weight: 800;
  color: #0d1730;
  border: 2px solid transparent;
  cursor: pointer;
}
.lab-base.picked { border-color: #fff; box-shadow: 0 0 0 3px var(--gold); }
.lab-base.changed { outline: 3px dashed #fff; outline-offset: 2px; }
.lab-label { margin: 0; font-size: .85em; font-weight: 700; color: #9fb4dd; }
.lab-tools { display: flex; flex-wrap: wrap; justify-content: center; gap: max(6px, 1cqw); }
.lab-tools .chip-btn { text-align: center; font-weight: 700; }
.lab-tools .chip-btn.on { border-color: var(--gold); background: #2c3d66; }
.lab-chain { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; min-height: max(34px, 4.6cqw); }
.lab-chain .bead.diff { box-shadow: 0 0 0 3px #fff; }
.lab-chain .bead.stop { border-radius: .4em; width: auto; padding: 0 .6em; }
.lab-goals { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 0; padding: 0; list-style: none; }
.lab-goals li { padding: .3em .8em; border-radius: 999px; background: rgba(255, 255, 255, .08); font-weight: 700; font-size: .9em; }
.lab-goals li.met { background: #1f5a3a; color: #c9f7d4; }

.sim-stage { width: min(100%, 50cqw); }
.sim-stage svg { width: 100%; height: auto; display: block; }
.sim-results { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.sim-results span { padding: .3em .7em; border-radius: .6em; background: rgba(255, 255, 255, .08); font-weight: 800; letter-spacing: .05em; }
.sim-results span.found { background: #1f5a3a; color: #c9f7d4; }
.sim-results span.new { box-shadow: 0 0 0 3px var(--gold); }
.sim-stage.wide { width: min(100%, 66cqw); }
.sim-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; font-weight: 700; font-size: .9em; }
.sim-legend i { display: inline-block; width: 14px; height: 14px; border-radius: 4px; margin-right: 6px; vertical-align: -2px; }
.pool-inline { display: block; width: min(100%, 360px); margin: 0 auto .4em; }
.hunt-stage { width: min(100%, 64cqw); align-self: center; border-radius: 12px; overflow: hidden; }
.hunt-stage svg { display: block; width: 100%; height: auto; }
.hunt-moth { cursor: pointer; transition: opacity .3s; }
.hunt-moth:focus-visible { outline: 3px solid var(--gold); }
.hunt-moth.eaten { opacity: 0; pointer-events: none; }
.hunt-chart { display: grid; gap: 4px; width: 100%; }
.hunt-row { display: grid; grid-template-columns: minmax(90px, 9em) 1fr auto; align-items: center; gap: 8px; font-size: .9em; }
.hunt-label { font-weight: 700; color: #cfd9ef; }
.hunt-bar { display: flex; height: 16px; border-radius: 8px; overflow: hidden; background: rgba(255, 255, 255, .1); }
.hunt-black { background: #1f1c1b; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .3); transition: width .5s; }
.hunt-pep { background: #ece6d6; transition: width .5s; }
.hunt-value { color: #cfd9ef; white-space: nowrap; }

/* ---------- Overlays ---------- */

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: max(6px, 1cqw);
  padding: 4cqw;
  text-align: center;
  background: rgba(6, 10, 22, .62);
  backdrop-filter: blur(4px);
}
.overlay[hidden] { display: none; }
.overlay-title { margin: 0; font-size: max(16px, 3cqw); font-weight: 800; }
.overlay-sub { margin: 0; font-size: max(12px, 1.7cqw); opacity: .85; max-width: 60cqw; line-height: 1.45; }

.big-play {
  flex: none;
  width: max(64px, 11cqw);
  height: max(64px, 11cqw);
  border-radius: 50%;
  border: 0;
  background: var(--gold);
  cursor: pointer;
  display: grid;
  place-items: center;
  animation: glow 2s infinite;
  margin-bottom: 1cqw;
}
.big-play svg { width: 50%; height: 50%; fill: #1b2340; margin-left: 8%; }
@keyframes glow { 0% { box-shadow: 0 0 0 0 rgba(255, 209, 102, .6); } 70%, 100% { box-shadow: 0 0 0 2.4cqw rgba(255, 209, 102, 0); } }

.end-card { display: flex; flex-direction: column; align-items: center; gap: max(8px, 1.4cqw); }
.btn {
  font: 700 max(13px, 1.7cqw) system-ui, sans-serif;
  padding: .6em 1.4em;
  border-radius: 999px;
  border: 0;
  background: var(--gold);
  color: #1b2340;
  cursor: pointer;
}
.btn.small { font-size: max(12px, 1.45cqw); padding: .5em 1.2em; align-self: center; }
.btn.ghost { background: transparent; color: #fff; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .6); }
a.btn { text-decoration: none; display: inline-block; }
.btn:disabled { opacity: .5; cursor: default; }
.end-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.btn[hidden] { display: none; }
.link-btn {
  font: 600 max(12px, 1.5cqw) system-ui, sans-serif;
  color: #fff;
  background: none;
  border: 0;
  text-decoration: underline;
  cursor: pointer;
  opacity: .85;
}
.link-btn[hidden] { display: none; }

/* ---------- Controls ---------- */

.controls {
  display: grid;
  grid-template-columns: auto auto 1fr auto auto;
  align-items: center;
  gap: 8px 10px;
  padding: 10px 4px 4px;
}
.controls .timeline { grid-column: 1 / -1; order: -1; }

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--btn);
  color: var(--ink);
  cursor: pointer;
  display: grid;
  place-items: center;
  font: 800 13px system-ui, sans-serif;
}
.icon-btn svg { width: 22px; height: 22px; fill: currentColor; }
.icon-btn[aria-pressed="false"].cc { opacity: .5; text-decoration: line-through; }
#playBtn .i-pause, #playBtn.playing .i-play { display: none; }
#playBtn.playing .i-pause { display: block; }
#soundBtn .i-off, #soundBtn[aria-pressed="false"] .i-on { display: none; }
#soundBtn[aria-pressed="false"] .i-off { display: block; }

.timeline { min-width: 0; padding-top: 4px; }
.track { position: relative; height: 8px; border-radius: 999px; background: var(--line); cursor: pointer; }
.fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: inherit; background: var(--accent); }
.ticks span { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--panel); }

.time { font: 600 13px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); padding-left: 4px; }

.sections { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 4px 2px; }
.sections button {
  font: 600 13px system-ui, sans-serif;
  color: var(--ink);
  background: var(--btn);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 11px;
  cursor: pointer;
}
.sections button b { color: var(--muted); margin-right: 2px; }
.sections button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.sections button.active b { color: rgba(255, 255, 255, .8); }

.settings {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 8px 4px 2px;
  font-size: 13px;
  color: var(--muted);
}
.settings select {
  margin-left: 6px;
  max-width: min(260px, 100%);
  padding: 4px 6px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--btn);
  color: var(--ink);
}

@container (max-width: 620px) {
  .defcard { width: 46cqw; top: 9cqw; }
  .lbl { font-size: 9px; padding: .3em .6em; }
  .lbl small { display: none; }
  .lbl[data-el="lbl-mouse-white"] { --x: 57%; }
  .lbl[data-el="lbl-mouse-brown"] { --x: 88%; }
  .slot-note { display: none; }
  .slot, .tile { height: 44px; }
  .tile svg { width: 16px; height: 16px; }
  .act { width: 100%; }
  .match { grid-template-columns: minmax(0, 1fr) minmax(0, 1.8fr); }
  .codon-grid { grid-template-columns: 1fr; }
  .flow { flex-wrap: wrap; justify-content: center; width: 60cqw; white-space: normal; }
  .sim-stage, .sim-stage.wide, .hunt-stage { width: 100%; }
  .hunt-row { grid-template-columns: 1fr; gap: 2px; }
}

/* On small screens the 16:9 picture is too short to share with text, so the caption,
   key-term card and recap move below it. */
@media (max-width: 760px) {
  .stage { aspect-ratio: auto; display: flex; flex-direction: column; padding-bottom: 10px; }
  .viewport { position: relative; inset: auto; flex: none; aspect-ratio: 16 / 9; }
  .caption, .defcard, .recap { position: static; transform: none; width: auto; max-width: none; margin: 10px 10px 0; }
  .caption { order: 1; font-size: 15px; text-align: left; background: rgba(255, 255, 255, .06); }
  .defcard { order: 2; padding: 10px 12px; border-radius: 10px; }
  .recap { order: 3; padding: 12px 14px; border-radius: 12px; }
  .defcard:not(.on), .recap:not(.on) { display: none; }
  .defcard-tag { font-size: 10px; }
  .defcard-term { font-size: 16px; }
  .defcard-def, .recap li { font-size: 14px; }
  .recap-title { font-size: 16px; }
  .stage.activity-on { height: min(640px, 85vh); }
  .stage.activity-on .defcard, .stage.activity-on .recap { display: none; }
}

@media (max-width: 560px) {
  .time { font-size: 12px; }
  .icon-btn { width: 36px; height: 36px; }
  .controls { column-gap: 6px; }
  .sections button { font-size: 12px; padding: 4px 9px; }
}

@media (prefers-reduced-motion: reduce) {
  .layer, .layer.is-past { transition: opacity .6s; }
  .layer.is-future, .layer.is-past { transform: scale(1); }
  .pulse.on, .question.on, .big-play, .beam { animation: none; }
}
