/* aliens.fyi — UI styling per design spec (dossier lines 51–61). Zero dependencies. */

/* ---------------------------------------------------------------- tokens */
:root {
  color-scheme: dark;

  --bg: #020307;            /* WebGL clear color, oklch(0.10 0.015 270) */
  --bg-raise: #0C0F18;      /* radial-gradient center, oklch(0.17 0.02 270) */

  --accent: #5CD0EA;        /* interactive/primary, oklch(0.80 0.11 215) */
  --accent-hi: #88E0F6;     /* hover/focus */
  --accent-dim: rgba(92, 208, 234, 0.5);
  --focus-ring: rgba(92, 208, 234, 0.45);

  --amber: #EEB154;         /* event/contact markers, oklch(0.80 0.13 75) */
  --red: #F3625D;           /* earth-claimed / destructive */
  --ghost: #4D5660;         /* not-yet-visible ghost */
  --silver: #D0D8E1;        /* humanity */

  --text-1: rgba(235, 240, 255, 0.92);
  --text-2: rgba(235, 240, 255, 0.60);
  --text-3: rgba(235, 240, 255, 0.52); /* 4.5:1 floor; hierarchy 0.92 > 0.60 > 0.52 holds */
  --text-label: rgba(235, 240, 255, 0.55);

  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);

  --glass-bg: rgba(10, 12, 24, 0.55);
  --glass-blur: blur(16px) saturate(140%);
  --glass-shadow: 0 8px 40px rgba(0, 0, 0, 0.45);

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, "Cascadia Mono", "Roboto Mono", Consolas, monospace;

  --panel-ease: cubic-bezier(0.3, 0, 0.2, 1);
}

/* ---------------------------------------------------------------- base */
* { box-sizing: border-box; margin: 0; padding: 0; }

/* The hidden attribute must always win: author display rules (e.g. the
   #sheet-pill mobile display:block, #webgl-fallback display:grid) otherwise
   override the UA's [hidden] { display: none } and show dead elements. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
}

body {
  font-family: var(--sans);
  color: var(--text-1);
  -webkit-font-smoothing: antialiased;
  /* "lit nebula" depth: center raise fading to bg at the corners (under the HUD;
     the renderer redraws this in-canvas — this is the first-paint / fallback layer) */
  background:
    radial-gradient(120vmax 90vmax at 50% 46%, var(--bg-raise) 0%, var(--bg) 62%) fixed,
    var(--bg);
}

.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--accent-hi); }

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 4px;
}

.glass {
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--line);
  box-shadow: var(--glass-shadow);
}

/* ---------------------------------------------------------------- z-0: scene */
#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: block;
  touch-action: none;
}

/* ------------------------------------------------------ fill progress hairline */
#fill-progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 2px;
  z-index: 60;
  pointer-events: none;
}
#fill-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, rgba(92, 208, 234, 0.4), var(--accent));
  transition: width 120ms linear;
}

/* ---------------------------------------------------------------- z-10: HUD */
#title-block, #mode-toggle, #stats, #timeline {
  position: fixed;
  z-index: 10;
  pointer-events: none; /* drag-to-orbit passes through; re-enable on children */
}

/* title block */
#title-block {
  top: 24px;
  left: 28px;
  max-width: 320px;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
}
.wordmark {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-1);
}
.subtitle {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--text-2);
}
.domain-chip {
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
}

/* mode toggle: segmented glass pill, top-center */
#mode-toggle {
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
}
.mode-seg {
  pointer-events: auto;
  display: flex;
  height: 36px;
  border-radius: 18px;
  overflow: hidden;
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--line);
  box-shadow: var(--glass-shadow);
}
.mode-seg button {
  padding: 0 18px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-2);
  border-radius: 17px;
  white-space: nowrap;
}
.mode-seg button .short { display: none; }
.mode-seg button[aria-pressed="true"] {
  background: rgba(92, 208, 234, 0.18);
  color: var(--accent-hi);
  box-shadow: inset 0 0 0 1px rgba(92, 208, 234, 0.4);
}

/* caption / status banner under the toggle */
#banner {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  pointer-events: none;
  font-size: 11px;
  color: var(--text-2);
  background: rgba(4, 5, 12, 0.7);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 14px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 300ms ease;
}
#banner.show { opacity: 1; }

/* stats overlay: glass-backed HUD text, LEFT column under the title block —
   the old top-right placement collided with the centered mode toggle whenever
   the parameter panel pushed it 392px leftward. The left column has no
   neighbors, so the panel-open shift/hide rules are gone with it. (Values keep
   the right-aligned ledger column; the glass keeps them >= 4.5:1 over bright
   domain faces.) */
#stats {
  top: 124px;            /* clears the title block (ends ~114px) */
  left: 28px;
  width: 330px;
  text-align: right;
  line-height: 1.7;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
  background: rgba(4, 5, 12, 0.65);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  transition: opacity 200ms ease, visibility 200ms;
}

/* each row is a wrapping flex line: key / value / suffix are nowrap atoms, so
   narrow widths drop whole units to the next line instead of splitting "Myr)" */
.stat-row {
  pointer-events: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  column-gap: 8px;
  align-items: baseline;
}
/* tooltip-bearing rows re-enable hit-testing under #stats's pointer-events:none
   (the #stats click handler is inert on desktop — .expanded only styles <768px) */
.stat-row.has-tip { pointer-events: auto; cursor: help; }
.stat-row.has-tip .stat-key {
  text-decoration: underline dotted rgba(235, 240, 255, 0.35);
  text-underline-offset: 3px;
}
.stat-key {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-label);
  margin-right: 0;
}
.stat-val {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-1);
  white-space: nowrap;
}
.stat-row.headline .stat-val { font-size: 20px; }
.stat-row { transition: opacity 250ms ease; }
.stat-row.dimmed { opacity: 0.5; }
.stat-row.accented .stat-val, .stat-row.accented .stat-key { color: var(--accent-hi); }
.stat-suffix {
  color: var(--text-2);
  font-weight: 500;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums; /* live count must not jitter the right-aligned block */
  font-size: 12px;
  white-space: nowrap;
}
/* empty suffixes must not occupy a flex slot (their column-gap would push the
   value off the shared right edge) */
.stat-suffix:empty { display: none; }
.stat-row.humanity .stat-val { color: var(--silver); }

/* value-change flash: snap to white, decay 600ms */
.stat-val { transition: color 600ms ease; }
.stat-val.flash { color: #FFFFFF; transition: none; }

/* twin claimed/visible bars */
.twin-bars {
  display: inline-flex;
  flex-direction: column;
  gap: 3px;
  margin: 4px 0 2px;
}
.twin-bars .bar {
  width: 200px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
.twin-bars .bar i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 2px;
  transition: width 200ms ease;
}
.twin-bars .bar.claimed i { background: #FFFFFF; }
.twin-bars .bar.visible i { background: var(--accent); }

.stat-whisper {
  font-size: 11px;
  font-style: italic;
  color: var(--text-3);
  opacity: 0;
  transition: opacity 400ms ease;
}
.stat-whisper.show { opacity: 1; }

/* ---------------------------------------------------------------- z-20: panel */
#panel {
  position: fixed;
  z-index: 20;
  top: 88px;
  bottom: 116px;
  right: 16px;
  width: 340px;
  border-radius: 14px;
  padding: 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
  transform: translateX(360px);
  transition: transform 280ms var(--panel-ease);
}
#panel::-webkit-scrollbar { width: 4px; }
#panel::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: 2px; }
#panel::-webkit-scrollbar-track { background: transparent; }
body.panel-open #panel { transform: translateX(0); }
@media (max-height: 720px) {
  #panel { top: 24px; }
}

/* collapsed-state vertical tab at right edge */
#panel-tab {
  position: fixed;
  z-index: 20;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 88px;
  border-radius: 10px 0 0 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-2);
  transition: opacity 280ms var(--panel-ease), visibility 280ms;
}
#panel-tab .chev { font-size: 16px; line-height: 1; }
#panel-tab .tab-label {
  writing-mode: vertical-rl;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
body.panel-open #panel-tab { opacity: 0; visibility: hidden; pointer-events: none; }
#panel-tab:hover { color: var(--text-1); }

/* panel internals */
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.label, .panel-head h2 {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-label);
}
.panel-collapse {
  width: 28px; height: 28px;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 16px;
}
.panel-collapse:hover { color: var(--text-1); background: rgba(255, 255, 255, 0.06); }
/* desktop slides right (›); the mobile sheet dismisses downward (⌄) */
.panel-collapse .chev-sheet { display: none; }

.about-link {
  display: inline-block;
  margin-bottom: 18px;
  font-size: 13px;
  color: var(--accent);
}
.about-link:hover { text-decoration: underline; color: var(--accent-hi); }

.param-row { margin-bottom: 18px; }
.param-row .row-head {
  display: flex;
  align-items: center;
  gap: 6px;
}
.param-row .row-head .val {
  margin-left: auto;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
}
.info-btn {
  width: 16px; height: 16px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--text-3);
  color: var(--text-3);
  font-size: 10px;
  font-style: italic;
  font-family: Georgia, serif;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.info-btn:hover, .info-btn[aria-expanded="true"] { color: var(--accent); border-color: var(--accent); }

.row-expl {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 150ms ease, opacity 150ms ease;
  font-size: 13px;
  line-height: 1.55;
  color: rgba(235, 240, 255, 0.78);
}
.row-expl.open { max-height: 280px; opacity: 1; }
.row-expl p {
  margin-top: 8px;
  border-left: 2px solid rgba(92, 208, 234, 0.4);
  padding-left: 10px;
}

/* custom range inputs: the input itself is the 3px track; --p = fill percent */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 14px; /* hit area; track painted as centered gradient band */
  margin-top: 10px;
  background:
    linear-gradient(to right,
      rgba(92, 208, 234, 0.5) 0%,
      var(--accent) var(--p, 50%),
      rgba(255, 255, 255, 0.15) var(--p, 50%))
    no-repeat 0 50% / 100% 3px;
  border-radius: 999px;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid rgba(4, 5, 12, 0.9);
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid rgba(4, 5, 12, 0.9);
}
input[type="range"]::-moz-range-track { background: transparent; }
input[type="range"]:focus-visible {
  outline: none;
}
input[type="range"]:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 4px rgba(92, 208, 234, 0.25);
}
input[type="range"]:focus-visible::-moz-range-thumb {
  box-shadow: 0 0 0 4px rgba(92, 208, 234, 0.25);
}

/* GC birth-date sparkline under the rank slider */
#sparkline {
  display: block;
  width: 100%;
  max-width: 300px;
  height: 48px;
  margin-top: 8px;
}
.spark-cap { font-size: 11px; color: var(--text-3); margin: 2px 0 6px; }

/* segmented control (voxel resolution) */
.seg-ctrl {
  display: flex;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
}
.seg-ctrl button {
  flex: 1;
  padding: 6px 0;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}
.seg-ctrl button + button { border-left: 1px solid var(--line); }
.seg-ctrl button[aria-pressed="true"] {
  background: rgba(92, 208, 234, 0.18);
  color: var(--accent-hi);
}

/* seed row + die button */
.seed-row .row-head .val { color: var(--text-1); }
.die-btn {
  position: relative;
  width: 28px; height: 28px;
  flex: none;
  margin-left: 10px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line-2);
  display: inline-grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  place-items: center;
  padding: 5px;
}
.die-btn:hover { border-color: rgba(92, 208, 234, 0.5); }
.die-btn .pip {
  width: 3px; height: 3px;
  border-radius: 50%;
  background: var(--text-1);
  opacity: 0;
}
.die-btn .pip.on { opacity: 1; }
@keyframes die-shake {
  0% { transform: rotate(0); }
  25% { transform: rotate(-12deg); }
  60% { transform: rotate(12deg); }
  100% { transform: rotate(0); }
}
.die-btn.shake { animation: die-shake 300ms ease; }

/* advanced collapsible */
.adv-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 8px 0;
  margin-bottom: 4px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-label);
}
.adv-toggle .chev { transition: transform 150ms ease; font-size: 10px; }
.adv-toggle[aria-expanded="true"] .chev { transform: rotate(90deg); }
.adv-body {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 200ms ease, opacity 200ms ease;
}
.adv-body.open { max-height: 720px; opacity: 1; }

/* toggles section */
.panel-divider {
  border: none;
  border-top: 1px solid var(--line-2);
  margin: 4px 0 16px;
}
.toggle-row { margin-bottom: 16px; }
.toggle-row .row-head { display: flex; align-items: flex-start; gap: 6px; }
.toggle-row .tog-text { flex: 1; }
.toggle-row .sub {
  display: block;
  font-size: 11px;
  color: var(--text-2);
  margin-top: 2px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}
.switch {
  position: relative;
  flex: none;
  width: 36px; height: 20px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.15);
  transition: background 150ms ease;
  margin-left: 8px;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 150ms ease;
}
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(16px); }

/* sticky footer: Reset/Replay stay above the fold; content scrolls beneath
   (#panel is the scroll container; bottom: -20px sinks into its 20px padding) */
.panel-footer {
  position: sticky;
  bottom: -20px;
  margin-top: auto;
  padding: 12px 0 6px;
  background: linear-gradient(to top, rgba(10, 12, 24, 0.92) 70%, transparent);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.reset-btn { font-size: 12px; color: var(--text-2); }
.reset-btn:hover { color: var(--text-1); text-decoration: underline; }

/* ---------------------------------------------------------------- timeline */
#timeline {
  bottom: 0;
  left: 0;
  right: 0;
  height: 96px;
  padding: 0 24px;
  background: linear-gradient(to top,
    rgba(4, 5, 12, 0.88) 0%, rgba(4, 5, 12, 0.55) 55%, transparent 100%);
}

.tl-row1 {
  position: relative;
  height: 40px;
  display: flex;
  align-items: center;
}
.tl-hero { pointer-events: none; }
#hero-t {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #FFFFFF;
}
#hero-suffix {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 15px;
  font-weight: 500;
  color: rgba(235, 240, 255, 0.7);
  margin-left: 8px;
}
#hero-eta {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: var(--text-2);
  margin-top: -2px;
  pointer-events: auto; /* its title explains conformal time — must be hoverable */
  cursor: help;
}

.tl-transport {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}
#play-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--line-2);
  display: grid;
  place-items: center;
  color: var(--text-1);
}
#play-btn:hover { border-color: rgba(92, 208, 234, 0.5); }
#play-btn .icon-play {
  width: 0; height: 0;
  border-left: 11px solid currentColor;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  margin-left: 3px;
}
#play-btn .icon-pause { display: none; gap: 3px; }
#play-btn .icon-pause i { width: 3px; height: 13px; background: currentColor; border-radius: 1px; }
#play-btn.playing .icon-play { display: none; }
#play-btn.playing .icon-pause { display: flex; }

.speed-pills { display: flex; gap: 4px; }
.speed-pills button {
  height: 26px;
  padding: 0 9px;
  border-radius: 13px;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
}
.speed-pills button[aria-pressed="true"] {
  background: rgba(92, 208, 234, 0.18);
  color: var(--accent-hi);
  border-color: rgba(92, 208, 234, 0.4);
}

#tl-hint {
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--text-2);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 600ms ease;
  pointer-events: none;
}
#tl-hint.show { opacity: 1; }

/* row 2: scrubber */
.tl-row2 {
  position: relative;
  height: 52px;
  pointer-events: auto;
}
#tl-hit {
  position: absolute;
  left: 0; right: 0;
  top: 2px;
  height: 36px;   /* invisible hit area */
  cursor: pointer;
}
.tl-track {
  position: absolute;
  left: 0; right: 0;
  top: 18px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.18);
  pointer-events: none;
}
#tl-played {
  position: absolute;
  left: 0;
  top: 18px;
  height: 4px;
  border-radius: 2px;
  width: 0%;
  background: var(--accent);
  opacity: 0.7;
  pointer-events: none;
}
#tl-playhead {
  position: absolute;
  top: 20px;
  left: 0%;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 2px solid rgba(4, 5, 12, 0.9);
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: transform 120ms ease;
}
.tl-row2.dragging #tl-playhead { transform: translate(-50%, -50%) scale(1.15); }

/* ticks */
.tl-tick {
  position: absolute;
  top: 12px;
  width: 1px;
  height: 8px;
  background: rgba(255, 255, 255, 0.25);
  transform: translateX(-0.5px);
  pointer-events: none;
}
.tl-tick-label {
  position: absolute;
  top: 28px;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-label);
  pointer-events: none;
  white-space: nowrap;
}
.tl-cap-left { transform: none; }
.tl-cap-right { transform: translateX(-100%); }
/* end caps carry explanatory titles (Big-Bang anchor / η∞ freeze) */
.tl-cap-left, .tl-cap-right { pointer-events: auto; cursor: help; }

/* permanent axis declaration under the track */
#timeline .tl-axis-note {
  position: absolute;
  left: 50%;
  top: 40px;
  transform: translateX(-50%);
  font: 500 10px var(--mono);
  color: var(--text-3);
  letter-spacing: 0.04em;
  white-space: nowrap;
  pointer-events: none;
}
#tl-now-pill {
  position: absolute;
  top: 26px;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-hi);
  background: rgba(92, 208, 234, 0.18);
  border-radius: 3px;
  padding: 2px 6px;
  pointer-events: none;
}
@keyframes now-pop {
  0% { transform: translateX(-50%) scale(0.9); }
  100% { transform: translateX(-50%) scale(1); }
}
#tl-now-pill.pop { animation: now-pop 250ms cubic-bezier(0.2, 1.4, 0.4, 1); }

/* event markers: 10px diamonds centered on the line; glide 200ms on change */
.tl-mk {
  position: absolute;
  top: 20px;
  width: 10px; height: 10px;
  transform: translate(-50%, -50%) rotate(45deg);
  pointer-events: auto;
  transition: left 200ms ease, opacity 200ms ease;
}
.tl-mk[hidden] { display: none; }
#mk-see { border: 1.5px solid var(--accent); background: transparent; }
#mk-contact { background: var(--amber); }
#mk-earth-claimed { background: var(--red); border-radius: 50%; } /* red dot vs amber diamond: shape codes the event */
.tl-mk.near { transform: translate(-50%, -50%) rotate(45deg) scale(1.4); }
#mk-median {
  position: absolute;
  top: 20px;
  width: 1px;
  height: 20px;
  transform: translate(-50%, -50%);
  background: repeating-linear-gradient(to bottom, var(--amber) 0 3px, transparent 3px 6px);
  opacity: 0.5;
  pointer-events: auto;
  transition: left 200ms ease;
}
#mk-median.near { transform: translate(-50%, -50%) scaleY(1.3); }
#mk-band {
  position: absolute;
  top: 18.5px;
  height: 3px;
  background: rgba(238, 177, 84, 0.25);
  pointer-events: none;
  transition: left 200ms ease, width 200ms ease;
}

/* ghost hover readout */
#tl-ghost {
  position: absolute;
  top: -10px;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: var(--text-1);
  background: rgba(4, 5, 12, 0.8);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
}
.tl-row2:hover #tl-ghost { opacity: 1; }
.tl-row2.dragging #tl-ghost { opacity: 1; } /* touch drags have no :hover */
.ghost-tip {
  font: 600 10px var(--sans);
  color: var(--accent-hi);
  letter-spacing: 0.04em;
}

/* ---------------------------------------------------------------- earth label */
#earth-label {
  position: fixed;
  z-index: 10;
  left: 0; top: 0;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(235, 240, 255, 0.85);
  text-shadow: 0 0 4px rgba(2, 3, 8, 0.95), 0 1px 3px rgba(2, 3, 8, 0.9);
  pointer-events: none;
  white-space: nowrap;
  transition: opacity 300ms ease;
}
#earth-label.hidden { opacity: 0; }

/* ---------------------------------------------------------------- about modal */
#about-modal { position: fixed; inset: 0; z-index: 50; }
#about-scrim {
  position: absolute;
  inset: 0;
  background: rgba(2, 3, 8, 0.6);
  opacity: 0;
  transition: opacity 200ms ease;
}
#about-card {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.97);
  width: min(560px, calc(100vw - 32px));
  max-height: 80vh;
  overflow-y: auto;
  background: rgba(8, 10, 20, 0.82);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  backdrop-filter: blur(24px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 16px;
  padding: 32px;
  opacity: 0;
  transition: opacity 200ms ease, transform 200ms ease;
}
#about-modal.open #about-scrim { opacity: 1; }
#about-modal.open #about-card { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#about-card h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: 14px;
  padding-right: 32px;
}
.about-body p, .fallback-card p {
  font-size: 13px;
  line-height: 1.55;
  color: rgba(235, 240, 255, 0.78);
  margin-bottom: 12px;
}
.about-note {
  font-size: 12px !important;
  color: var(--text-2) !important;
  border-left: 2px solid rgba(92, 208, 234, 0.4);
  padding-left: 10px;
}
.about-keys {
  font: 500 11px var(--mono);
  color: var(--text-3);
  letter-spacing: 0.04em;
  margin-top: 14px;
}
.about-links { font-size: 13px; margin-top: 4px; color: var(--text-3); }
.about-links a { margin: 0 2px; }
#about-close {
  position: absolute;
  top: 12px; right: 12px;
  width: 32px; height: 32px;
  border-radius: 8px;
  font-size: 20px;
  line-height: 1;
  color: var(--text-2);
}
#about-close:hover { color: var(--text-1); background: rgba(255, 255, 255, 0.06); }

/* ---------------------------------------------------------------- fallbacks */
#webgl-fallback {
  position: fixed;
  inset: 0;
  z-index: 40;
  overflow-y: auto;
  display: grid;
  place-items: center;
  padding: 24px;
}
.fallback-card {
  max-width: 560px;
  background: rgba(8, 10, 20, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 16px;
  padding: 32px;
  margin: auto;
}
.fallback-card h2 { font-size: 18px; font-weight: 700; letter-spacing: 0.04em; margin-bottom: 10px; }
.fallback-card h3 { font-size: 14px; font-weight: 700; margin: 14px 0 8px; }
.fallback-sub { color: var(--text-2) !important; }
.noscript-card {
  position: fixed;
  z-index: 70;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 32px));
}

/* mobile parameters pill (hidden on desktop) */
#sheet-pill {
  display: none;
  position: fixed;
  z-index: 20;
  right: 16px;
  bottom: 112px; /* 16px above the 96px timeline */
  height: 40px;
  padding: 0 18px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-1);
}

/* drag handle (visible only in sheet mode) */
.sheet-handle {
  display: none;
  width: 100%;
  padding: 10px 0 6px;
  cursor: pointer;
  touch-action: none; /* the pointer drag owns the gesture — no scroll steal */
}
.sheet-handle::after {
  content: "";
  display: block;
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.25);
  margin: 0 auto;
}

/* ------------------------------------------------------ load-in choreography
   The HUD stays dark until main.js decides the boot path: body.hud-on (free
   play, staggered reveal) or body.tour-active (the story owns the screen and
   re-shows pieces per beat via tour-show-* classes). */
@keyframes hud-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.hud-in { opacity: 0; }
body.hud-on .hud-in { animation: hud-in 800ms ease forwards; }
body.hud-on .hud-in-1 { animation-delay: 120ms; }
body.hud-on .hud-in-2 { animation-delay: 200ms; }
body.hud-on .hud-in-3 { animation-delay: 280ms; }
body.hud-on .hud-in-4 { animation-delay: 360ms; }
/* mode-toggle/timeline are positioned with transforms of their own — fade only */
body.hud-on #mode-toggle.hud-in, body.hud-on #timeline.hud-in {
  animation-name: hud-fade;
}
@keyframes hud-fade { from { opacity: 0; } to { opacity: 1; } }
#panel { opacity: 0; }
body.hud-on #panel { animation: hud-fade 800ms ease 440ms forwards; }
/* interactive chrome that isn't part of the stagger set */
body:not(.hud-on) :is(#panel-tab, #sheet-pill, #earth-label) { display: none !important; }

/* ------------------------------------------------------------- guided tour */
#tour { position: fixed; inset: 0; z-index: 30; pointer-events: none; }

/* beats can surface the timeline (display-only) and stats over the story */
body.tour-active #timeline,
body.tour-active #stats { transition: opacity 700ms ease; }
body.tour-active.tour-show-timeline #timeline { opacity: 1; pointer-events: none; }
body.tour-active.tour-show-stats #stats { opacity: 1; }
body.tour-active #stats { top: 24px; } /* title block is hidden during the story */
body.tour-active #timeline { pointer-events: none; }
body.tour-active #tl-hint { display: none; }

.tour-card {
  position: absolute;
  left: 50%;
  bottom: 132px;
  transform: translateX(-50%);
  width: min(660px, calc(100vw - 32px));
  padding: 22px 26px 16px;
  border-radius: 16px;
  pointer-events: auto;
}
.tour-card.beat-in { animation: tour-beat-in 360ms cubic-bezier(0.2, 0.8, 0.3, 1); }
@keyframes tour-beat-in {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.tour-kicker {
  font: 600 10px/1 var(--sans);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}
.tour-h {
  font: 700 22px/1.25 var(--sans);
  letter-spacing: 0.01em;
  color: var(--text-1);
  margin-bottom: 8px;
}
.tour-p {
  font: 400 14.5px/1.62 var(--sans);
  color: rgba(235, 240, 255, 0.82);
}
.tour-p b { color: var(--text-1); font-weight: 650; }
.tour-p i { color: var(--accent-hi); font-style: italic; }
.tour-aside { display: block; margin-top: 8px; font-size: 12px; color: var(--text-3); }

.tour-inset { margin: 14px 0 2px; }
.tour-inset svg { width: 100%; height: auto; display: block; }
.svg-label { font: 600 11px var(--sans); fill: var(--text-2); }
.svg-num { font: 600 11px var(--mono); fill: var(--text-1); }
.svg-axis { font: 500 9px var(--sans); fill: var(--text-3); letter-spacing: 0.08em; }
.svg-bar-sun { fill: rgba(238, 177, 84, 0.75); }
.svg-bar-dwarf { fill: rgba(243, 98, 93, 0.65); }
.svg-now { stroke: var(--accent-hi); stroke-width: 1.5; stroke-dasharray: 3 3; }
.svg-now-label { font: 700 10px var(--mono); fill: var(--accent-hi); }

.tour-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
}
.tour-back {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-2);
  font: 600 15px var(--sans);
  cursor: pointer;
}
.tour-back:disabled { opacity: 0.25; cursor: default; }
.tour-back:not(:disabled):hover { color: var(--text-1); border-color: rgba(255, 255, 255, 0.25); }
.tour-dots { display: flex; gap: 7px; flex: 1; justify-content: center; }
.tour-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.18);
  padding: 0;
  cursor: pointer;
  transition: background 200ms ease, transform 200ms ease;
}
.tour-dot.on { background: var(--accent); }
.tour-dot:hover { transform: scale(1.5); }
.tour-next {
  height: 36px;
  padding: 0 18px;
  border-radius: 18px;
  border: 1px solid rgba(92, 208, 234, 0.45);
  background: rgba(92, 208, 234, 0.16);
  color: var(--accent-hi);
  font: 600 13px var(--sans);
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 150ms ease;
}
.tour-next:hover { background: rgba(92, 208, 234, 0.28); }
.tour-next:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus-ring); }
.tour-hint {
  margin-top: 10px;
  text-align: center;
  font: 500 10.5px var(--mono);
  color: var(--text-3);
}

.tour-skip {
  position: absolute;
  top: 24px; right: 28px;
  height: 30px;
  padding: 0 14px;
  border-radius: 15px;
  border: 1px solid var(--line);
  background: rgba(10, 12, 24, 0.4);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  color: var(--text-2);
  font: 600 11px var(--sans);
  letter-spacing: 0.06em;
  cursor: pointer;
  pointer-events: auto;
}
.tour-skip:hover { color: var(--text-1); border-color: var(--line-2); }

.tour-scale {
  position: absolute;
  top: 24px; left: 50%;
  transform: translateX(-50%);
  padding: 7px 16px;
  border-radius: 15px;
  border: 1px solid var(--line);
  background: rgba(10, 12, 24, 0.45);
  font: 600 12px var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--accent-hi);
  white-space: nowrap;
}

.ring-label {
  position: absolute;
  top: 0; left: 0;
  padding: 4px 9px;
  border-radius: 10px;
  background: rgba(4, 6, 14, 0.65);
  border: 1px solid rgba(92, 208, 234, 0.25);
  font: 600 10.5px var(--mono);
  color: rgba(140, 220, 240, 0.95);
  white-space: nowrap;
  transition: opacity 300ms ease;
  will-change: transform;
}

/* milestone chips on the timeline track (tour beat 4; harmless in free play) */
.tl-milestone {
  position: absolute;
  bottom: 26px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  pointer-events: none;
}
.tl-milestone i {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  transition: background 300ms ease, box-shadow 300ms ease;
}
.tl-milestone span {
  font: 600 10px var(--sans);
  letter-spacing: 0.06em;
  color: var(--text-3);
  transition: color 300ms ease;
  transform: rotate(-28deg) translateX(6px);
  transform-origin: bottom left;
  white-space: nowrap;
  /* dark halo: where lanes graze at narrow widths, the upper label knocks
     out the lower one's strokes (same idea as the tour's .svg-num stroke) */
  text-shadow: 0 0 3px rgba(2, 3, 8, 0.95), 0 0 2px rgba(2, 3, 8, 0.95), 0 1px 2px rgba(2, 3, 8, 0.9);
}
/* odd-indexed labels take a second lane straight up, away from the track,
   so the hard-steps pile-up near NOW stays readable. Offsets tuned against
   1440/1024 captures: with parallel −28° lanes the perpendicular separation
   is |Δx·sin28° − raise·cos28°|, and the widest base→alt anchor gap
   (Sun & Earth → first life, ≈24px at 1440) eats a small raise — −22px left
   "first life" overprinting "Earth". −32px (plus a 6px left bias) clears
   every pair at both widths while keeping the two-lane idiom. */
.tl-milestone.alt span { transform: translate(-6px, -32px) rotate(-28deg) translateX(4px); }
.tl-milestone.lit i { background: var(--accent); box-shadow: 0 0 8px rgba(92, 208, 234, 0.8); }
.tl-milestone.lit span { color: var(--text-1); }

.replay-btn {
  background: none;
  border: none;
  color: var(--text-3);
  font: 500 12px var(--sans);
  cursor: pointer;
  padding: 4px 0;
}
.replay-btn:hover { color: var(--accent); }

@media (max-width: 767px) {
  .tour-card { bottom: 14px; padding: 18px 18px 12px; }
  body.tour-show-timeline .tour-card { bottom: 118px; } /* clear the visible timeline */
  .tour-h { font-size: 18px; }
  .tour-p { font-size: 13.5px; }
  .tour-skip { top: 14px; right: 14px; }
  body.tour-active #stats { display: none; } /* small screens: the card is the show */
}

@media (prefers-reduced-motion: reduce) {
  .tour-card.beat-in { animation: none; }
  .tour-dot:hover { transform: none; }
  body.tour-active #timeline, body.tour-active #stats { transition: none; }
}

/* ---------------------------------------------------------------- mobile */
@media (max-width: 767px) {
  /* title shrinks; subtitle + domain chip hidden */
  #title-block { left: 16px; top: 16px; }
  .wordmark { font-size: 16px; }
  .subtitle { display: none; }
  .domain-chip { display: none; }

  /* mode toggle compresses to short labels and docks right of the wordmark */
  #mode-toggle { top: 16px; left: auto; right: 16px; transform: none; }
  .mode-seg { height: 32px; }
  .mode-seg button { padding: 0 12px; }
  .mode-seg button .long { display: none; }
  .mode-seg button .short { display: inline; }

  /* stats collapses to two lines (CLAIMED % + FIRST CONTACT); tap to expand.
     Restacked below the mode pill so neither paints over the wordmark.
     Collapsed state is frameless (mobile design); .expanded re-adds the glass. */
  #stats {
    left: auto;          /* desktop pins left; mobile restacks below the mode pill */
    right: 16px;
    top: 58px;
    width: auto;
    pointer-events: auto;
    background: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    border: none;
    border-radius: 0;
    padding: 0;
  }
  #stats .stat-row:nth-child(n+2), #stats .stat-whisper, #stats .twin-bars { display: none; }
  #stats .stat-row.row-contact { display: flex; } /* rows are flex lines (T11 nowrap atoms) */
  #stats.expanded {
    background: var(--glass-bg);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 14px;
    box-shadow: var(--glass-shadow);
  }
  #stats.expanded .stat-row { display: flex; }
  #stats.expanded .stat-whisper { display: block; }
  #stats.expanded .twin-bars { display: inline-flex; }
  .stat-row.headline .stat-val { font-size: 16px; }

  /* hero readout shrinks; ticks reduce to NOW + caps (event markers stay) */
  #hero-t { font-size: 20px; }
  #hero-suffix { font-size: 12px; }
  /* ticks reduce to the NOW pill, the infinity cap, and the event markers */
  .tl-tick, .tl-tick-label { display: none; }
  .tl-tick-label.tl-cap-right { display: block; }
  .tl-axis-note { display: none; }
  /* the η sub-line collides with the centered #tl-hint at phone widths;
     like the axis note, it is a desktop-only conformal-scale annotation */
  #hero-eta { display: none; }
  #timeline { padding: 0 16px; }
  .tl-transport { position: static; transform: none; margin-left: auto; }
  .tl-row1 { gap: 8px; }

  /* desktop tab never shows; pill does */
  #panel-tab { display: none; }
  #sheet-pill { display: block; }
  body.sheet-open #sheet-pill { display: none; }

  /* panel becomes a bottom sheet: two snap states via classes (45vh / 90vh) */
  #panel {
    top: auto;
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 45vh;
    border-radius: 16px 16px 0 0;
    -webkit-backdrop-filter: blur(20px) saturate(140%);
    backdrop-filter: blur(20px) saturate(140%);
    transform: translateY(105%);
    transition: transform 280ms var(--panel-ease), height 280ms var(--panel-ease);
    padding-top: 0;
  }
  body.sheet-open #panel { transform: translateY(0); }
  body.sheet-open.sheet-tall #panel { height: 90vh; }
  body.panel-open #panel { transform: translateY(105%); } /* desktop class is inert here */
  body.sheet-open #panel { transform: translateY(0) !important; }
  .sheet-handle { display: block; position: sticky; top: 0; background: inherit; }

  /* the sheet dismisses downward, so the collapse glyph points down */
  .panel-collapse .chev-desktop { display: none; }
  .panel-collapse .chev-sheet { display: inline; }
}

/* ---------------------------------------------------------------- reduced motion */
@media (prefers-reduced-motion: reduce) {
  .hud-in, #panel {
    animation: hud-fade 100ms ease forwards;
    animation-delay: 0ms;
  }
  .die-btn.shake { animation: none; }
  #tl-now-pill.pop { animation: none; }
  .stat-val { transition: none; }
  .stat-val.flash { color: var(--text-1); }
  #panel, #stats, .tl-mk, #mk-median, #mk-band, #tl-playhead,
  .row-expl, .adv-body, .switch, .switch::after, #banner, #earth-label {
    transition: none;
  }
  #about-scrim, #about-card { transition: opacity 100ms ease; transform: translate(-50%, -50%); }
  #about-modal.open #about-card { transform: translate(-50%, -50%); }
}

/* tour */
.svg-tick { stroke: rgba(235, 240, 255, 0.10); stroke-width: 1; }
.svg-num { paint-order: stroke; stroke: rgba(8, 10, 18, 0.95); stroke-width: 3px; }
.ring-label::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 50%;
  margin-top: -2.5px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(92, 208, 234, 0.9);
}
.tour-dots { gap: 17px; }
.tour-dot { position: relative; }
.tour-dot::after { content: ""; position: absolute; inset: -8.5px; }
.tour-dot.on { background: rgba(92, 208, 234, 0.55); }
.tour-dot.cur { width: 18px; border-radius: 4px; background: var(--accent-hi); }
