:root {
  /* Drosophila: tan and yellow-brown body, banana-yellow accent, red compound eyes for danger. */
  --bg: #100d0a;
  --surface: #181310;
  --surface-2: #221b15;
  --surface-3: #2c241c;
  --line: #3a2f25;
  --line-2: #58493a;
  --text: #f4ecdf;
  --subtle: #a3927c;
  --accent: #ffcf3f; /* banana: the colour of a spike, of "on", of the primary action */
  --accent-ink: #2a1e00;
  --danger: #e0473c; /* the fly's eyes: lesions, scrambled wiring, warnings */
  --ok: #8fd672;
  --in: #6fa8ff;
  --out: #ff9f3c;
  --highlight: #5ee1ff; /* the one cool colour: what you are pointing at, in the panel and in the brain alike */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --panel-width: 360px;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, monospace;
}

* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html,
body {
  height: 100%;
  margin: 0;
}
body {
  display: grid;
  grid-template: "top top" auto "stage panel" 1fr / 1fr var(--panel-width);
  background: var(--bg);
  color: var(--text);
  font: 400 13px/1.45 Lexend, system-ui, sans-serif;
  overflow: hidden;
}
.subtle {
  color: var(--subtle);
}
b {
  font-weight: 500;
}
a {
  color: var(--highlight);
}

/* -- top bar ---------------------------------------------------------------- */

.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: var(--s4) var(--s5);
  padding: var(--s2) var(--s4);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: var(--s2);
  min-width: 0;
}
.brand h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.brand .mark {
  width: 22px;
  height: 22px;
  align-self: center;
  flex: none;
}
#brain-switch {
  align-self: center;
}
.button.what {
  border-color: var(--line-2);
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  align-self: center;
  background: var(--subtle);
}
.status-dot[data-state="open"] {
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
}
.status-dot[data-state="error"] {
  background: var(--danger);
}
.transport {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  align-items: center;
  min-width: 0;
}
.readouts {
  display: flex;
  gap: var(--s4);
  margin: 0 0 0 auto;
}
.readouts div {
  min-width: 78px;
}
.readouts dt {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--subtle);
}
.readouts dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 13px;
  white-space: nowrap;
}
.readouts dd.warn {
  color: var(--danger);
}

/* -- controls --------------------------------------------------------------- */

.button,
.segmented button,
.tabs button,
.help,
.options button {
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px var(--s3);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.button:hover,
.segmented button:hover,
.options button:hover,
.help:hover {
  border-color: var(--line-2);
  background: var(--surface-3);
}
:is(.button, .segmented button, .tabs button, .help, .options button, input[type="range"], .status-dot, .label):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.button.lesion[aria-pressed="true"],
#scramble[aria-pressed="true"] {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff5f4;
}
.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 500;
}
.button.small {
  padding: 3px var(--s2);
  font-size: 12px;
}
.button:disabled {
  opacity: 0.4;
  cursor: default;
}
.segmented {
  display: inline-flex;
}
.segmented button {
  border-radius: 0;
  margin-left: -1px;
}
.segmented button:first-child {
  border-radius: 6px 0 0 6px;
  margin-left: 0;
}
.segmented button:last-child {
  border-radius: 0 6px 6px 0;
}
.segmented button[aria-checked="true"] {
  background: #3d2f1c;
  border-color: #7a5f2c;
  color: #fff;
  position: relative;
}
.segmented.small button {
  padding: 3px var(--s2);
  font-size: 12px;
}
.help {
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 600;
  color: var(--subtle);
  flex: none;
}
.help:hover {
  color: var(--text);
}
input[type="range"] {
  width: 100%;
  min-width: 0;
  accent-color: var(--accent);
  height: 18px;
  cursor: pointer;
}

/* -- stage ------------------------------------------------------------------ */

.stage {
  grid-area: stage;
  position: relative;
  min-width: 0;
  min-height: 0;
}
#brain {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
.labels {
  transition: opacity 0.25s;
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.label {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(24, 19, 16, 0.78);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 11px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  cursor: default;
  transition: opacity 0.2s;
}
.label:hover,
.label.active {
  border-color: var(--highlight);
  color: var(--highlight);
}
.labels.far {
  opacity: 0;
  visibility: hidden;
}
.labels[hidden] {
  display: none;
}

.predicts-stack {
  position: absolute;
  top: var(--s3);
  left: var(--s4);
  display: grid;
  gap: 6px;
  justify-items: start;
  max-width: calc(100% - 2 * var(--s4));
  pointer-events: none;
}
.predicts-stack > * {
  pointer-events: auto;
}
.muscle-list {
  list-style: none;
  margin: 0;
  padding: 6px 10px;
  display: grid;
  gap: 3px;
  min-width: 250px;
  background: rgba(24, 19, 16, 0.82);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 11px;
  color: var(--subtle);
}
.muscle-list li {
  display: grid;
  grid-template-columns: 1fr 56px;
  gap: var(--s2);
  align-items: center;
  white-space: nowrap;
}
.muscle-list .bar {
  height: 3px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
}
.muscle-list .bar span {
  display: block;
  height: 100%;
  background: var(--accent);
}
.predicts {
  margin: 0;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(24, 19, 16, 0.82);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--subtle);
}
.predicts b {
  color: var(--text);
  font-weight: 500;
}
.predicts.active {
  border-color: rgba(255, 207, 63, 0.5);
}
.predicts.active b {
  color: var(--accent);
}

.hud {
  position: absolute;
  left: var(--s4);
  bottom: var(--s4);
  display: grid;
  gap: var(--s2);
  padding: var(--s3);
  background: rgba(24, 19, 16, 0.82);
  border: 1px solid var(--line);
  border-radius: 8px;
  backdrop-filter: blur(6px);
  max-width: calc(100% - 2 * var(--s4));
}
.hud-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  align-items: center;
}
.hud ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px var(--s3);
  font-size: 11px;
  color: var(--subtle);
}
.hud li {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.hud li i,
.swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
  display: inline-block;
}
.swatch {
  margin-right: 6px;
}
.swatch.in {
  background: var(--in);
}
.swatch.out {
  background: var(--out);
}
#activity-chart {
  width: 220px;
  height: 44px;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  gap: var(--s2);
  background: rgba(16, 13, 10, 0.84);
  font-size: 15px;
}
.overlay p {
  margin: 0;
  max-width: 48ch;
  padding: 0 var(--s4);
}
.overlay[hidden] {
  display: none;
}
.progress {
  width: 240px;
  height: 4px;
  margin: 0 auto;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
}
.progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
}
.toast {
  position: absolute;
  top: var(--s4);
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: var(--s2) var(--s4);
  background: #3d1b17;
  border: 1px solid var(--danger);
  border-radius: 6px;
  max-width: min(90%, 60ch);
  z-index: 3;
}

.welcome {
  position: absolute;
  top: 52px; /* clear of the model-predicts strip */
  left: 50%;
  transform: translateX(-50%);
  width: min(460px, calc(100% - 2 * var(--s4)));
  padding: var(--s4);
  background: rgba(24, 19, 16, 0.92);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  backdrop-filter: blur(8px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  z-index: 2;
}
.welcome h2 {
  margin: 0 0 var(--s2);
  font-size: 16px;
  font-weight: 500;
}
.welcome p {
  margin: 0 0 var(--s3);
  font-weight: 300;
  line-height: 1.5;
}
.welcome-actions {
  display: flex;
  gap: var(--s2);
  flex-wrap: wrap;
}

/* -- tooltip ---------------------------------------------------------------- */

.tooltip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 50;
  padding: 6px 10px;
  background: #2a221a;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.4;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

/* -- side panel ------------------------------------------------------------- */

.panel {
  grid-area: panel;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  border-left: 1px solid var(--line);
  background: var(--surface);
}
.tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.tabs button {
  flex: 1;
  border: 0;
  border-radius: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--subtle);
  padding: var(--s2);
  font-weight: 500;
}
.tabs button[aria-selected="true"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.tab {
  overflow-y: auto;
  padding: var(--s3) var(--s3) var(--s5);
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
  flex: 1;
  min-height: 0;
}
.tab[hidden] {
  display: none;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  margin: var(--s3) var(--s1) var(--s2);
}
.section-head:first-child {
  margin-top: var(--s1);
}
.section-head h2,
.panel h2 {
  margin: 0;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--subtle);
}

/* populations */
.pop {
  padding: var(--s2) var(--s2) var(--s3);
  border: 1px solid transparent;
  border-radius: 8px;
}
.pop + .pop {
  margin-top: 2px;
}
.pop:hover,
.pop:focus-within {
  background: var(--surface-2);
  border-color: var(--line);
}
.pop.stimulated {
  border-color: rgba(255, 210, 122, 0.45);
}
.pop.lesioned {
  border-color: rgba(255, 107, 107, 0.45);
}
.pop.lesioned .pop-name {
  text-decoration: line-through;
  text-decoration-color: var(--danger);
}
.pop.selected {
  border-color: var(--highlight);
}
.pop header {
  display: flex;
  align-items: baseline;
  gap: var(--s2);
}
.pop-name {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: help;
}
.pop-size {
  font-size: 11px;
  white-space: nowrap;
}
.pop-rate {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 12px;
  white-space: nowrap;
  color: var(--subtle);
}
.pop-rate output {
  color: var(--text);
}
.pop.firing .pop-rate output {
  color: var(--accent);
}
.meter {
  height: 3px;
  margin: 5px 0 6px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
}
.meter span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.1s linear;
}
.pop-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px auto auto auto;
  align-items: center;
  gap: var(--s2);
}
/* Actions are for watching: no input slider, just the buttons. */
.pop[data-role="output"] .pop-controls {
  grid-template-columns: repeat(3, auto);
  justify-content: start;
}
.pop[data-role="output"] input[type="range"],
.pop[data-role="output"] .stim-value {
  display: none;
}
.pop-controls.single {
  grid-template-columns: 1fr;
}
.stim-value {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--subtle);
  text-align: right;
}
.pop.stimulated .stim-value {
  color: var(--accent);
}

/* lessons */
.lesson {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 2px var(--s3);
  align-items: start;
  width: 100%;
  text-align: left;
  padding: var(--s3);
  margin-bottom: var(--s2);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.lesson:hover {
  border-color: var(--line-2);
  background: var(--surface-3);
}
.lesson .num {
  grid-row: 1 / 3;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 12px;
}
.lesson h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
}
.lesson p {
  margin: 0;
  grid-column: 2 / 4;
  font-size: 12px;
  color: var(--subtle);
}
.lesson .minutes {
  font-size: 11px;
  color: var(--subtle);
  white-space: nowrap;
}
.lesson:hover .minutes::after {
  content: " · start →";
  color: var(--accent);
}
.lesson-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--s3);
}
#step-title {
  margin: 0 0 var(--s2);
  font-size: 16px;
  font-weight: 500;
}
#step-text {
  margin: 0 0 var(--s3);
  font-size: 13px;
  line-height: 1.55;
  font-weight: 300;
}
#step-action {
  margin-bottom: var(--s3);
}
.watch {
  display: grid;
  gap: 6px;
  margin-bottom: var(--s3);
}
.watch .row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--s2);
  align-items: baseline;
  font-family: var(--mono);
  font-size: 12px;
}
.watch .row output {
  color: var(--text);
}
.watch .row.firing output {
  color: var(--accent);
}
.watch .meter {
  grid-column: 1 / -1;
  margin: 0;
}
.question {
  padding: var(--s3);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--surface-2);
  margin-bottom: var(--s3);
}
.question-text {
  margin: 0 0 var(--s2);
  font-weight: 500;
}
.options {
  display: grid;
  gap: 6px;
}
.options button {
  text-align: left;
}
.options button.correct {
  border-color: var(--ok);
  color: var(--ok);
}
.options button.wrong {
  border-color: var(--danger);
  color: var(--danger);
}
.explain {
  margin: var(--s2) 0 0;
  font-size: 12px;
  line-height: 1.5;
}
.lesson-nav {
  display: flex;
  justify-content: space-between;
  gap: var(--s2);
}

.section-note {
  margin: 0 var(--s2) var(--s2);
  font-size: 12px;
  color: var(--subtle);
  line-height: 1.45;
}

/* neuron card */
.facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px var(--s3);
  margin: 0 0 var(--s3);
  font-size: 12px;
}
.facts div {
  display: grid;
  grid-template-columns: subgrid;
  grid-column: 1 / -1;
}
.facts dt {
  color: var(--subtle);
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.08em;
  padding-top: 2px;
}
.facts dd {
  margin: 0;
  font-family: var(--mono);
  overflow-wrap: anywhere;
}
#tab-neuron h4 {
  margin: var(--s3) 0 var(--s1);
  font-size: 12px;
  font-weight: 500;
}
.partners {
  list-style: none;
  margin: 0;
  padding: 0;
}
.partners li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--s2);
  padding: 3px var(--s2);
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}
.partners li:hover {
  background: var(--surface-2);
}
.partners .ptype {
  font-family: var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.partners .pw {
  font-family: var(--mono);
  color: var(--subtle);
}
.partners .pop-tag {
  color: var(--highlight);
  font-size: 10px;
  margin-left: 6px;
}

/* help sheet */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.45);
}
.sheet-backdrop[hidden] {
  display: none;
}
/* Positioned by script next to the button that opened it. */
.sheet {
  position: fixed;
  width: min(480px, calc(100vw - 16px));
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  padding: var(--s4) var(--s4) var(--s5);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
}
.sheet header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.sheet h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
}
.sheet dl {
  margin: var(--s3) 0 0;
}
.sheet dt {
  font-weight: 500;
  margin-top: var(--s2);
}
.sheet dd {
  margin: 2px 0 0;
  color: var(--subtle);
  font-size: 12px;
  line-height: 1.5;
}

/* -- narrow screens: panel becomes a bottom sheet ---------------------------- */

@media (max-width: 860px) {
  body {
    grid-template: "top" auto "stage" minmax(0, 1fr) "panel" 46vh / 1fr;
  }
  .panel {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .readouts {
    margin-left: 0;
    gap: var(--s3);
  }
  .readouts div {
    min-width: 0;
  }
  .hud ul,
  #activity-chart {
    display: none;
  }
  .hud {
    padding: var(--s2);
  }
  .pop-controls {
    grid-template-columns: minmax(0, 1fr) 44px auto auto auto;
  }
  .label {
    font-size: 10px;
    padding: 1px 6px;
  }
  .topbar {
    gap: var(--s2) var(--s3);
    min-width: 0;
  }
  .brand .subtle {
    display: none; /* the dataset line is in the About sheet; the phone header has no room for it */
  }
  #speed button {
    padding: 4px 7px;
    font-size: 12px;
  }
}

/* Activities: one-press things to make the fly do, at the top of the Experiment tab */
.activities { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 18px; }
.activities .button[aria-pressed="true"] { background: var(--accent); color: #1a1408; border-color: var(--accent); }

/* ==========================================================================
   Rooms. Play is the front door: the fly, one button, nothing with a number
   in it. How it works is the lessons. Lab holds every expert tool.
   ========================================================================== */

body {
  grid-template: "top top" auto "tools tools" auto "stage panel" 1fr / 1fr var(--panel-width);
}
.tools {
  grid-area: tools;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s2) var(--s4);
  padding: var(--s2) var(--s4);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  min-width: 0;
}
.tools .readouts { margin-left: auto; }
.rooms {
  margin-left: auto;
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
}
.rooms button {
  background: none;
  border: 0;
  color: var(--subtle);
  font: inherit;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  min-height: 40px;
}
.rooms button small { font-size: 10.5px; opacity: 0.75; margin-left: 2px; }
.rooms button:hover { color: var(--text); background: var(--surface-2); }
.rooms button[aria-current="page"] { color: var(--accent); }
.rooms button:focus-visible, .cta:focus-visible, .hero-cards button:focus-visible { outline: 2px solid var(--highlight); outline-offset: 2px; }

body[data-room="play"] { grid-template: "top" auto "stage" 1fr / 1fr; }
body[data-room="play"] .panel,
body[data-room="play"] .tools,
body[data-room="play"] .hud,
body[data-room="play"] .labels,
body[data-room="play"] .predicts-stack { display: none; }
body[data-room="learn"] .tabs,
body[data-room="learn"] .hud ul,
body[data-room="learn"] #activity-chart,
body[data-room="learn"] #brain-switch,
body[data-room="learn"] .readouts,
body[data-room="learn"] #dataset { display: none; }
body[data-room="lab"] .tabs [data-tab="learn"] { display: none; }
body:not([data-room="play"]) .hero,
body:not([data-room="play"]) .endcard { display: none; }

/* -- the front door -------------------------------------------------------- */

.hero {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0 clamp(20px, 6vw, 72px) clamp(28px, 7vh, 72px);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  pointer-events: none;
  background: linear-gradient(to top, rgba(16, 13, 10, 0.92) 30%, rgba(16, 13, 10, 0));
}
.hero > * { pointer-events: auto; }
.hero h2 {
  margin: 0;
  font-size: clamp(28px, 5vw, 52px);
  line-height: 1.05;
  font-weight: 600;
  letter-spacing: -0.02em;
  max-width: 17ch;
  text-wrap: balance;
}
.hero p { margin: 0; font-size: clamp(14px, 1.5vw, 17px); color: var(--subtle); max-width: 46ch; }
.cta {
  background: var(--accent);
  color: var(--accent-ink);
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-weight: 600;
  font-size: 18px;
  padding: 14px 30px;
  min-height: 52px;
  cursor: pointer;
  box-shadow: 0 0 0 7px rgba(255, 207, 63, 0.14);
  transition: transform 0.15s, box-shadow 0.15s;
}
.cta:hover { transform: translateY(-1px); box-shadow: 0 0 0 10px rgba(255, 207, 63, 0.18); }
.hero-cards { display: flex; flex-wrap: wrap; gap: 8px; }
.hero-cards button {
  background: rgba(24, 19, 16, 0.85);
  border: 1px solid var(--line-2);
  color: var(--text);
  border-radius: 12px;
  font: inherit;
  font-size: 14px;
  padding: 10px 14px;
  min-height: 44px;
  cursor: pointer;
}
.hero-cards button:hover { border-color: var(--accent); }

/* -- while something plays: one caption line, one player bar ------------------ */

.caption {
  position: absolute;
  left: 50%;
  bottom: 74px;
  transform: translateX(-50%);
  width: min(92%, 640px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  background: rgba(10, 8, 6, 0.88);
  border-radius: 12px;
  padding: 12px 18px;
  text-align: center;
}
.caption p { margin: 0; font-size: clamp(16px, 2.3vw, 21px); font-weight: 500; line-height: 1.3; text-wrap: balance; }
.caption em { font-style: normal; font-family: var(--mono); font-size: 14px; color: var(--highlight); white-space: nowrap; }
.film-tag {
  position: absolute;
  left: 50%;
  bottom: 158px;
  transform: translateX(-50%);
  width: min(88%, 520px);
  margin: 0;
  text-align: center;
  font-size: 12.5px;
  color: var(--subtle);
  background: rgba(10, 8, 6, 0.7);
  border-radius: 8px;
  padding: 5px 10px;
}
.player {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  width: min(92%, 640px);
  display: flex;
  align-items: center;
  gap: 10px;
}
.player .button { min-height: 36px; }
.player-track { flex: 1; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.player-track i { display: block; height: 100%; width: 0; background: var(--accent); }
.player-speed { font-family: var(--mono); font-size: 12px; color: var(--subtle); min-width: 56px; text-align: right; }

.locator {
  position: absolute;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  pointer-events: none;
  animation: locate 1.2s ease-in-out infinite;
}
.locator span { position: absolute; left: 54px; top: 12px; font-size: 13px; color: var(--accent); white-space: nowrap; }
@keyframes locate { 50% { transform: scale(1.35); opacity: 0.55; } }

#brain.shake { animation: shake 0.22s linear; }
@keyframes shake { 25% { transform: translate(5px, -4px); } 50% { transform: translate(-4px, 3px); } 75% { transform: translate(3px, 2px); } }

/* -- the end card: the measured number is the ending ---------------------------- */

.endcard {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: clamp(48px, 10vh, 120px) clamp(20px, 6vw, 72px) clamp(28px, 6vh, 60px);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 22px;
  background: linear-gradient(to top, rgba(16, 13, 10, 0.97) 62%, rgba(16, 13, 10, 0));
}
.endcard p { margin: 0; }
.endcard-label { font-size: 14px; color: var(--subtle); letter-spacing: 0.04em; margin-bottom: -10px; }
.endcard-big { font-family: var(--mono); font-size: clamp(44px, 9vw, 84px); line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums; }
.endcard-line { font-size: clamp(15px, 1.8vw, 18px); line-height: 1.55; max-width: 46ch; text-wrap: balance; }
.endcard-note { font-size: 12.5px; line-height: 1.6; color: var(--subtle); max-width: 56ch; margin-top: 6px; }
.endcard-actions, .endcard-ask { display: flex; flex-direction: column; align-items: center; gap: 26px; margin-top: 8px; }
.endcard-actions > div, .endcard-ask > div { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.endcard .button { min-height: 46px; padding-inline: 18px; }
.endcard-ask p { font-size: 18px; font-weight: 500; }
.button.ghost { border-style: dashed; color: var(--subtle); }

@media (max-width: 860px) {
  body { grid-template: "top" auto "tools" auto "stage" minmax(0, 1fr) "panel" 46vh / 1fr; }
  body[data-room="play"] { grid-template: "top" auto "stage" 1fr / 1fr; }
  .rooms button { padding: 8px 9px; font-size: 13px; }
  .rooms button small { display: none; }
  .hero { align-items: center; text-align: center; }
  .hero-cards { justify-content: center; }
  .cta { width: min(100%, 340px); }
  .tools .readouts { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .locator, #brain.shake { animation: none; }
  .cta { transition: none; }
}
