:root {
  --void: #06040a;
  --void2: #0c0814;
  --gold: #ff9c5a;
  --cosmic: #8B5CF6;
  --electric: #22D3EE;
  --peach: #ffb89d;
  --rose: #F43F5E;
  --text: rgba(255,255,255,.88);
  --text-dim: rgba(255,255,255,.45);
  --text-mute: rgba(255,255,255,.18);
  --glass: rgba(255,255,255,.04);
  --glass-b: rgba(255,255,255,.08);
  --fire: linear-gradient(135deg, #c73200, #e84500, #ff6500, #ff9f00, #ffd700);
  --hud-font: 'Space Grotesk', system-ui, sans-serif;
  --display-font: 'Cinzel', serif;
  --mono-font: 'Space Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; background: var(--void); color: var(--text); overflow: hidden; font-family: var(--hud-font); }
body { cursor: grab; }
body:active { cursor: grabbing; }

#stage { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; }
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud > * { pointer-events: auto; }

/* Vignette overlay — pure CSS, drawn over the scene for cinematic edges */
#vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 5;
  background:
    radial-gradient(ellipse at center, transparent 30%, rgba(0,0,0,.35) 75%, rgba(0,0,0,.7) 100%),
    radial-gradient(circle at center, transparent 60%, rgba(255,156,90,.025) 90%);
  mix-blend-mode: multiply;
}

/* Warp / Einstein effect overlay — fires during mode transitions.
   Combines a radial gradient ring sweep + chromatic flicker + edge bend. */
#warp-fx {
  position: fixed; inset: 0; pointer-events: none; z-index: 8;
  opacity: 0; transition: opacity .35s ease;
  background:
    radial-gradient(circle at center,
      transparent 0%,
      transparent 30%,
      rgba(255,156,90,.18) 45%,
      rgba(34,211,238,.22) 52%,
      rgba(139,92,246,.18) 58%,
      transparent 75%
    );
  mix-blend-mode: screen;
}
#warp-fx.warping {
  animation: warp-burst 1.4s cubic-bezier(.18,.7,.18,1) forwards;
}
@keyframes warp-burst {
  0%   { opacity: 0;   transform: scale(0.5);  filter: blur(0); }
  18%  { opacity: 0.95; transform: scale(1.05); filter: blur(.5px); }
  40%  { opacity: 0.85; transform: scale(2.4);  filter: blur(2px) hue-rotate(20deg); }
  70%  { opacity: 0.45; transform: scale(4.6);  filter: blur(6px) hue-rotate(-15deg); }
  100% { opacity: 0;    transform: scale(7.5);  filter: blur(10px); }
}

/* Chromatic aberration on the canvas during warps */
body.warping #stage {
  animation: stage-warp 1.2s cubic-bezier(.4,.0,.2,1) forwards;
}
@keyframes stage-warp {
  0%   { filter: blur(0); }
  35%  { filter: blur(1.2px) saturate(1.4) contrast(1.15); }
  70%  { filter: blur(.4px) saturate(1.2); }
  100% { filter: blur(0); }
}

/* Subtle gravitational shimmer ring on the star while in WORLDS — a
   stationary halo that lives in CSS coordinates locked to screen center
   (the system's parent star is centered by the camera framing). */
body[data-mode="worlds"]::after {
  content: '';
  position: fixed; left: 50%; top: 50%;
  width: 220px; height: 220px;
  transform: translate(-50%, -50%);
  pointer-events: none; z-index: 4;
  background:
    radial-gradient(circle,
      transparent 28%,
      rgba(255,156,90,.06) 32%,
      transparent 36%,
      rgba(34,211,238,.04) 44%,
      transparent 56%
    );
  animation: lens-shimmer 6s ease-in-out infinite;
  mix-blend-mode: screen;
}
@keyframes lens-shimmer {
  0%,100% { opacity: 0.7; transform: translate(-50%, -50%) scale(1);    }
  50%     { opacity: 1.0; transform: translate(-50%, -50%) scale(1.06); }
}

/* Boot layer */
.boot-layer {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, #0c0814 0%, #06040a 70%);
  transition: opacity .9s ease;
  z-index: 100;
}
.boot-layer.gone { opacity: 0; pointer-events: none; }

.boot-title {
  font-family: var(--display-font); font-weight: 700;
  font-size: clamp(1.6rem, 4vw, 3rem); letter-spacing: .32em;
  opacity: 0; transform: translateY(8px);
  transition: opacity 1.2s ease .2s, transform 1.2s ease .2s;
  background: linear-gradient(135deg, #fff 0%, #ff9c5a 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 60px rgba(255, 156, 90, .4);
}
.boot-layer.show-title .boot-title { opacity: 1; transform: none; }

.boot-sub, .boot-hail {
  font-family: var(--mono-font); font-size: .75rem;
  color: var(--electric); margin-top: 1.4rem; opacity: 0;
  min-height: 1.1em; letter-spacing: .18em;
  transition: opacity .8s ease;
}
.boot-layer.show-sub .boot-sub { opacity: .8; }
.boot-layer.show-hail .boot-hail { opacity: 1; color: var(--peach); }

.boot-sub::before { content: '› '; opacity: .5; }
.boot-hail::after { content: '_'; animation: cursor-blink 1s steps(2) infinite; }
@keyframes cursor-blink { 50% { opacity: 0; } }

/* Status badge */
#status-badge {
  position: absolute; top: 1rem; left: 1rem;
  font-family: var(--mono-font); font-size: .7rem; letter-spacing: .22em;
  padding: .35rem .8rem;
  background: var(--glass); border: 1px solid var(--glass-b);
  border-radius: 999px; backdrop-filter: blur(12px);
  color: var(--text-dim);
}
#status-badge.live { color: var(--electric); border-color: rgba(34, 211, 238, .4); box-shadow: 0 0 18px rgba(34, 211, 238, .15); }
#status-badge.degraded { color: var(--gold); border-color: rgba(255, 156, 90, .4); }
#status-badge.offline  { color: var(--text-dim); }

/* Crosshair */
.crosshair {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%); pointer-events: none;
  opacity: .55;
}
.crosshair[hidden] { display: none; }
.reticle {
  width: 72px; height: 72px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 50%;
  position: relative;
}
.reticle::before, .reticle::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  background: rgba(255,255,255,.18);
}
.reticle::before { width: 1px; height: 14px; transform: translate(-50%, -50%); }
.reticle::after  { width: 14px; height: 1px; transform: translate(-50%, -50%); }

/* Mode dial */
.dial {
  position: absolute; left: 50%; bottom: 1.6rem;
  transform: translateX(-50%);
  display: flex; gap: .35rem;
  padding: .45rem; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--glass-b);
  backdrop-filter: blur(14px);
}
.dial[hidden] { display: none; }
.rune {
  all: unset; cursor: pointer;
  padding: .55rem 1rem;
  font-family: var(--display-font); font-weight: 700;
  font-size: .72rem; letter-spacing: .22em;
  color: var(--text-dim);
  border-radius: 999px;
  transition: color .25s, background .25s, box-shadow .25s;
}
.rune:hover:not(.locked) { color: var(--text); }
.rune.active { color: var(--void); background: var(--fire); box-shadow: 0 0 26px rgba(255, 156, 90, .5); }
.rune.locked { color: var(--text-mute); cursor: not-allowed; }

/* Exit + legend */
#exit {
  position: absolute; left: 1rem; bottom: 1rem;
  color: var(--text-dim); text-decoration: none;
  font-family: var(--mono-font); font-size: .72rem; letter-spacing: .2em;
  padding: .45rem .8rem; border-radius: 6px;
  border: 1px solid var(--glass-b); background: var(--glass);
  backdrop-filter: blur(12px);
}
#exit:hover { color: var(--text); border-color: var(--peach); }

.mute-btn {
  all: unset; cursor: pointer; position: absolute; left: 5.6rem; bottom: 1rem;
  width: 2.2rem; height: 2rem; display: grid; place-items: center;
  border-radius: 6px; border: 1px solid var(--glass-b);
  background: var(--glass); backdrop-filter: blur(12px);
  color: var(--electric); font-size: 1rem; line-height: 1;
}
.mute-btn:hover { color: var(--peach); border-color: var(--peach); }
.mute-btn.muted { color: var(--text-mute); opacity: .6; }
.mute-btn.muted::after { content: '/'; position: absolute; }

/* TIME scrubber */
.time-scrubber {
  position: absolute; left: 50%; bottom: 5.6rem;
  transform: translateX(-50%);
  width: min(640px, 90vw);
  padding: .85rem 1.1rem;
  background: var(--glass); border: 1px solid var(--glass-b);
  border-radius: 14px; backdrop-filter: blur(14px);
}
.time-scrubber[hidden] { display: none; }
.ts-eyebrow {
  font-family: var(--mono-font); font-size: .68rem; letter-spacing: .22em;
  color: var(--gold); text-transform: uppercase;
  margin-bottom: .55rem; display: flex; justify-content: space-between;
}
.ts-eyebrow #ts-age { color: var(--text-dim); letter-spacing: .14em; }
.ts-track {
  position: relative; height: 22px;
}
.ts-track .ts-fill {
  position: absolute; inset: 9px 0; border-radius: 2px;
  background: linear-gradient(to right,
    #c73200 0%, #e84500 12%, #ff9f00 36%,
    #ffd700 55%, #22D3EE 75%, #8B5CF6 90%, #06040a 100%);
  opacity: .85;
}
.ts-track input[type=range] {
  position: absolute; inset: 0; width: 100%; height: 100%;
  -webkit-appearance: none; appearance: none; background: transparent;
  margin: 0; padding: 0; cursor: ew-resize;
}
.ts-track input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 22px; border-radius: 4px;
  background: #fff; border: 1px solid var(--peach);
  box-shadow: 0 0 14px rgba(255,156,90,.55);
}
.ts-track input[type=range]::-moz-range-thumb {
  width: 14px; height: 22px; border-radius: 4px;
  background: #fff; border: 1px solid var(--peach);
  box-shadow: 0 0 14px rgba(255,156,90,.55);
}
.ts-ticks {
  position: absolute; inset: 0; pointer-events: none;
}
.ts-ticks span {
  position: absolute; top: 2px; width: 1px; height: 18px;
  background: rgba(255,255,255,.25);
}
.ts-labels {
  display: flex; justify-content: space-between;
  font-family: var(--mono-font); font-size: .56rem;
  color: var(--text-mute); letter-spacing: .25em;
  margin-top: .45rem;
}
@media (max-width: 720px) {
  .time-scrubber { bottom: 4.6rem; padding: .55rem .7rem; }
  .ts-eyebrow { font-size: .58rem; }
  .ts-labels { font-size: .5rem; }
}

/* Named bright stars overlay — DOM labels positioned per frame */
#hud > .named-stars,
.named-stars {
  position: fixed; inset: 0; pointer-events: none; z-index: 6;
}
.named-stars[hidden] { display: none; }
.named-star {
  position: absolute; left: 0; top: 0;
  display: flex; flex-direction: column;
  padding: 0 0 0 14px;
  font-family: var(--mono-font);
  font-size: .68rem;
  letter-spacing: .12em;
  color: var(--text);
  text-shadow: 0 0 8px rgba(0,0,0,.7);
  opacity: 0;
  transition: opacity .25s ease;
  white-space: nowrap;
  pointer-events: none;
}
.named-star::before {
  content: '';
  position: absolute; left: 0; top: 50%;
  width: 8px; height: 1px;
  background: var(--electric);
  box-shadow: 0 0 6px var(--electric);
}
.ns-name {
  color: var(--peach);
  text-transform: uppercase;
  letter-spacing: .2em;
}
.ns-note {
  color: var(--text-dim);
  font-size: .55rem;
  letter-spacing: .08em;
  margin-top: 1px;
}

#legend {
  position: absolute; right: 1rem; bottom: 1rem;
  font-family: var(--mono-font); font-size: .65rem;
  color: var(--text-dim); letter-spacing: .12em;
  display: flex; align-items: center; gap: .5rem;
  padding: .4rem .7rem; border-radius: 6px;
  background: var(--glass); border: 1px solid var(--glass-b);
  backdrop-filter: blur(12px);
}
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--electric); box-shadow: 0 0 8px var(--electric); }

.noscript-fallback {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 2rem;
  background: var(--void); color: var(--text); font-family: var(--display-font); text-align: center;
}

/* Caption card */
.caption-card {
  position: absolute; left: 1.4rem; bottom: 7rem;
  max-width: 30rem; padding: 1rem 1.2rem;
  background: var(--glass); border: 1px solid var(--glass-b);
  border-radius: 12px; backdrop-filter: blur(14px);
  font-family: var(--hud-font);
  color: var(--text); font-size: .92rem; line-height: 1.55;
  opacity: 0; transform: translateY(8px);
  transition: opacity .45s ease, transform .45s ease;
  pointer-events: none;
}
.caption-card[hidden] { display: none; }
.caption-card.caption-in { opacity: 1; transform: none; }
.caption-eyebrow {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: var(--mono-font); font-size: .68rem;
  letter-spacing: .22em;
  color: var(--gold);
  margin-bottom: .5rem;
  text-transform: uppercase;
}
.caption-eyebrow #caption-meta { color: var(--text-dim); font-size: .62rem; letter-spacing: .15em; }
#caption-text { font-family: var(--hud-font); }

/* System picker pills */
.system-picker {
  position: absolute; left: 50%; bottom: 5.6rem;
  transform: translateX(-50%);
  display: flex; gap: .35rem;
  padding: .35rem;
  background: var(--glass); border: 1px solid var(--glass-b);
  border-radius: 999px; backdrop-filter: blur(14px);
  max-width: calc(100vw - 2rem); overflow-x: auto; scrollbar-width: none;
}
.system-picker::-webkit-scrollbar { display: none; }
.system-picker[hidden] { display: none; }
.sys-pill {
  all: unset; cursor: pointer; white-space: nowrap;
  display: inline-flex; flex-direction: column; align-items: center;
  padding: .35rem .8rem; border-radius: 999px;
  font-family: var(--hud-font); color: var(--text-dim);
  line-height: 1.05;
  transition: background .25s, color .25s;
}
.sys-pill:hover { color: var(--text); background: rgba(255,255,255,.05); }
.sys-pill.active { color: var(--gold); background: rgba(255,156,90,.10); box-shadow: inset 0 0 0 1px rgba(255,156,90,.35); }
.sys-name { font-size: .72rem; font-weight: 600; letter-spacing: .04em; }
.sys-dist { font-family: var(--mono-font); font-size: .58rem; color: var(--text-mute); letter-spacing: .1em; }
.sys-pill.active .sys-dist { color: var(--peach); }

/* Mobile */
@media (max-width: 720px) {
  .dial { padding: .3rem; gap: .2rem; bottom: 1rem; }
  .rune { padding: .35rem .55rem; font-size: .58rem; letter-spacing: .15em; }
  #legend { display: none; }
  .reticle { width: 56px; height: 56px; }
  #exit { font-size: .65rem; padding: .35rem .6rem; }
  .caption-card { left: .8rem; right: .8rem; bottom: 8rem; max-width: none; font-size: .8rem; }
  .system-picker { bottom: 4.6rem; max-width: calc(100vw - 1rem); }
  .sys-name { font-size: .64rem; }
  .sys-dist { font-size: .5rem; }
}

/* ── ACCELERATE button ───────────────────────────────────────────────── */
.accel-btn {
  all: unset; cursor: pointer;
  position: absolute; left: 50%; bottom: 5rem;
  transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: .55rem;
  padding: .6rem 1.1rem .6rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--glass-b);
  background: linear-gradient(180deg, rgba(34,211,238,.08), rgba(139,92,246,.06));
  backdrop-filter: blur(14px);
  color: var(--text);
  font-family: var(--mono-font);
  font-size: .72rem; letter-spacing: .22em;
  user-select: none; -webkit-user-select: none;
  touch-action: none;
  transition: transform .12s ease, border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.accel-btn:hover { border-color: var(--electric); }
.accel-btn .accel-glyph {
  font-size: 1rem; line-height: 1; color: var(--electric);
  transition: transform .15s ease, color .15s ease;
}
.accel-btn.pressed {
  transform: translateX(-50%) scale(.97);
  border-color: var(--gold);
  background: linear-gradient(180deg, rgba(255,156,90,.18), rgba(255,156,90,.06));
  box-shadow: 0 0 36px -8px var(--gold);
}
.accel-btn.pressed .accel-glyph { color: var(--gold); transform: translateY(-1px); }

/* ── Speed lines overlay — fades in proportional to boost magnitude ─── */
#speed-lines {
  position: fixed; inset: 0; pointer-events: none; z-index: 5;
  opacity: 0;
  background:
    radial-gradient(circle at 50% 50%,
      transparent 0%,
      transparent 35%,
      rgba(34, 211, 238, .04) 55%,
      rgba(139, 92, 246, .06) 75%,
      rgba(255, 156, 90, .08) 95%);
  mix-blend-mode: screen;
  transition: opacity .25s linear;
}

/* Make sure mobile small viewports keep the legend visible alongside the button */
@media (max-width: 640px) {
  .accel-btn { bottom: 3.2rem; font-size: .65rem; padding: .5rem .9rem; }
}

/* Always-on-top escape hatches — HOME and mute can never be trapped by boot/splash */
#exit { z-index: 200 !important; pointer-events: auto !important; }
.mute-btn { z-index: 200 !important; pointer-events: auto !important; }

/* ── GUIDED TOUR ─────────────────────────────────────────────────────────
   A "begin the show" button (top-right) and a control bar (top-center) that
   takes over while the self-driving planetarium lesson plays. */
.tour-btn {
  all: unset; cursor: pointer;
  position: absolute; top: 1rem; right: 1rem;
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .5rem 1rem;
  border-radius: 999px;
  border: 1px solid rgba(255,156,90,.4);
  background: linear-gradient(180deg, rgba(255,156,90,.16), rgba(139,92,246,.08));
  backdrop-filter: blur(14px);
  color: var(--text);
  font-family: var(--mono-font);
  font-size: .7rem; letter-spacing: .22em;
  box-shadow: 0 0 26px -10px var(--gold);
  transition: transform .12s ease, border-color .15s, box-shadow .15s, background .15s;
}
.tour-btn[hidden] { display: none; }
.tour-btn:hover { border-color: var(--gold); box-shadow: 0 0 34px -6px var(--gold); transform: translateY(-1px); }
.tour-btn .tour-glyph { color: var(--gold); font-size: .9rem; line-height: 1; animation: tour-twinkle 3.4s ease-in-out infinite; }
@keyframes tour-twinkle { 0%,100% { opacity: .65; transform: scale(1); } 50% { opacity: 1; transform: scale(1.18); } }

.tour-bar {
  position: absolute; top: 1rem; left: 50%;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 1rem;
  padding: .5rem .6rem .5rem 1rem;
  border-radius: 999px;
  border: 1px solid rgba(255,156,90,.32);
  background: var(--glass); backdrop-filter: blur(16px);
  box-shadow: 0 6px 30px -14px rgba(0,0,0,.8);
  max-width: calc(100vw - 2rem);
}
.tour-bar[hidden] { display: none; }
.tour-bar-info { display: flex; align-items: baseline; gap: .6rem; min-width: 0; }
.tour-counter {
  font-family: var(--mono-font); font-size: .62rem; letter-spacing: .18em;
  color: var(--gold); white-space: nowrap;
}
.tour-stop-title {
  font-family: var(--display-font); font-weight: 600;
  font-size: .82rem; letter-spacing: .12em; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tour-bar-controls { display: flex; align-items: center; gap: .25rem; }
.tour-ctl {
  all: unset; cursor: pointer;
  display: grid; place-items: center;
  min-width: 1.9rem; height: 1.9rem; padding: 0 .55rem;
  border-radius: 999px;
  border: 1px solid var(--glass-b);
  color: var(--text-dim);
  font-family: var(--mono-font); font-size: .72rem; letter-spacing: .12em;
  transition: color .15s, border-color .15s, background .15s;
}
.tour-ctl:hover { color: var(--text); border-color: var(--peach); }
.tour-ctl-exit { color: var(--text-mute); letter-spacing: .2em; font-size: .6rem; }
.tour-ctl-exit:hover { color: var(--rose); border-color: var(--rose); }

@media (max-width: 720px) {
  .tour-btn { top: .6rem; right: .6rem; padding: .4rem .7rem; font-size: .58rem; letter-spacing: .15em; }
  .tour-btn .tour-label { display: none; }
  .tour-bar { gap: .5rem; padding: .4rem .45rem .4rem .7rem; top: .6rem; }
  .tour-stop-title { font-size: .68rem; max-width: 36vw; }
  .tour-counter { font-size: .54rem; }
  .tour-ctl { min-width: 1.7rem; height: 1.7rem; }
}

/* ── FIRST CONTACT · DISCLOSURE FILE ──────────────────────────────────────
   The file that opens when a living world answers. A scanned bioluminescent
   portrait above a decrypted dossier — disclosure-doc framing, Spielberg awe. */
.contact-dossier {
  position: absolute; top: 50%; right: 1.4rem;
  transform: translate(28px, -50%);
  width: 22rem; max-width: calc(100vw - 2.8rem);
  padding: 1px;                 /* room for the gradient border */
  border-radius: 16px;
  background:
    linear-gradient(160deg,
      rgba(34,211,238,.55), rgba(139,92,246,.35) 45%, rgba(255,156,90,.30));
  box-shadow:
    0 24px 80px -30px rgba(0,0,0,.9),
    0 0 60px -24px rgba(34,211,238,.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity .6s cubic-bezier(.18,.7,.18,1),
              transform .6s cubic-bezier(.18,.7,.18,1);
  overflow: hidden;
  z-index: 40;
}
.contact-dossier[hidden] { display: none; }
.contact-dossier.cd-in { opacity: 1; transform: translate(0, -50%); }

/* The inner pane sits on the gradient border to leave a 1px luminous rim. */
.contact-dossier::before {
  content: ""; position: absolute; inset: 1px;
  border-radius: 15px;
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(34,211,238,.10), transparent 60%),
    linear-gradient(180deg, rgba(12,8,20,.94), rgba(6,4,10,.97));
  backdrop-filter: blur(18px);
  z-index: 0;
}
.contact-dossier > * { position: relative; z-index: 2; }

/* CRT scanline veil across the whole file */
.cd-scanlines {
  position: absolute; inset: 1px; z-index: 1; border-radius: 15px;
  pointer-events: none; opacity: .5; mix-blend-mode: overlay;
  background: repeating-linear-gradient(
    to bottom, rgba(255,255,255,.05) 0 1px, transparent 1px 3px);
}

/* ── Portrait scan plate ── */
.cd-portrait-frame {
  position: relative; height: 13rem; margin: 14px 14px 0;
  border-radius: 10px; overflow: hidden;
  background: radial-gradient(circle at 50% 45%, rgba(20,28,42,.7), rgba(2,3,8,.95));
  box-shadow: inset 0 0 0 1px rgba(34,211,238,.18), inset 0 0 40px -10px rgba(34,211,238,.25);
}
.cd-portrait { display: block; width: 100%; height: 100%; }
.cd-corner {
  position: absolute; width: 16px; height: 16px; pointer-events: none;
  border: 2px solid var(--electric); opacity: .8;
  filter: drop-shadow(0 0 4px var(--electric));
  animation: cd-corner-pulse 2.6s ease-in-out infinite;
}
.cd-corner-tl { top: 8px; left: 8px;  border-right: 0; border-bottom: 0; }
.cd-corner-tr { top: 8px; right: 8px; border-left: 0;  border-bottom: 0; }
.cd-corner-bl { bottom: 8px; left: 8px;  border-right: 0; border-top: 0; }
.cd-corner-br { bottom: 8px; right: 8px; border-left: 0;  border-top: 0; }
@keyframes cd-corner-pulse { 0%,100% { opacity: .35; } 50% { opacity: .9; } }

/* ── Dossier body ── */
.cd-body { padding: .9rem 1.1rem 1.1rem; }
.cd-eyebrow {
  font-family: var(--mono-font); font-size: .6rem; letter-spacing: .28em;
  text-transform: uppercase; color: var(--electric);
  text-shadow: 0 0 12px rgba(34,211,238,.6);
}
.cd-species {
  font-family: var(--display-font); font-weight: 700;
  font-size: 1.5rem; line-height: 1.1; letter-spacing: .06em;
  margin: .35rem 0 .15rem;
  background: linear-gradient(100deg, #fff, var(--electric) 55%, var(--cosmic));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  text-shadow: 0 0 30px rgba(34,211,238,.25);
}
.cd-origin {
  font-family: var(--mono-font); font-size: .64rem; letter-spacing: .12em;
  color: var(--text-dim); margin-bottom: .7rem;
}
.cd-bio-row {
  display: flex; flex-direction: column; gap: .15rem;
  padding: .5rem .6rem; margin-bottom: .7rem;
  border-radius: 8px;
  background: rgba(34,211,238,.05);
  box-shadow: inset 0 0 0 1px rgba(34,211,238,.14);
}
.cd-bio-tag {
  font-family: var(--mono-font); font-size: .52rem; letter-spacing: .26em;
  color: var(--text-mute); text-transform: uppercase;
}
.cd-bio {
  font-family: var(--mono-font); font-size: .66rem; line-height: 1.45;
  letter-spacing: .04em; color: var(--peach);
}
.cd-fact {
  font-family: var(--hud-font); font-size: .78rem; line-height: 1.5;
  color: var(--text-dim); margin-bottom: .9rem;
}
/* The signal horizon — exact light-travel physics, rendered as a verdict.
   'heard' = our radio already washed over them. 'biosphere' = they only ever
   saw Earth's living atmosphere; our voice is still in flight. */
.cd-reach {
  font-family: var(--hud-font); font-size: .66rem; line-height: 1.5;
  letter-spacing: .06em; text-transform: uppercase;
  margin: 0 0 .9rem; padding: .5rem .6rem;
  border-left: 2px solid currentColor; border-radius: 3px;
  position: relative;
}
.cd-reach::before {
  content: "◂ SIGNAL HORIZON"; display: block;
  font-size: .56rem; letter-spacing: .14em; opacity: .55;
  margin-bottom: .25rem;
}
.cd-reach[data-state="heard"] {
  color: #7dd3fc;
  background: linear-gradient(90deg, rgba(56,189,248,.12), rgba(56,189,248,0));
  text-shadow: 0 0 18px rgba(56,189,248,.4);
}
.cd-reach[data-state="biosphere"] {
  color: #c4b5fd;
  background: linear-gradient(90deg, rgba(167,139,250,.10), rgba(167,139,250,0));
  text-shadow: 0 0 18px rgba(167,139,250,.32);
}
/* The decoded message is the emotional climax — it must win the page. */
.cd-message {
  font-family: var(--display-font); font-style: italic;
  font-size: 1.22rem; line-height: 1.42; letter-spacing: .005em;
  color: #f2fbff; min-height: 1.3em;
  margin: 0 0 1rem; padding-top: .9rem;
  border-top: 1px solid rgba(125,211,252,.16);
  text-shadow: 0 0 26px rgba(125,211,252,.6), 0 0 60px rgba(125,211,252,.25);
}
.cd-message:not(:empty)::after {
  content: ""; display: inline-block; width: .5ch; height: 1.05em;
  margin-left: 2px; vertical-align: -.18em;
  background: var(--electric); box-shadow: 0 0 8px var(--electric);
  animation: cd-caret 1s steps(1) infinite;
}
/* Transmission sent — kill the live cursor once contact is established.
   Placed after the caret rule (equal specificity) so source order wins. */
.cd-live .cd-message::after { display: none; }
@keyframes cd-caret { 50% { opacity: 0; } }

/* ── Transmit Reply — humanity answers ──
   Hidden until CONTACT ESTABLISHED, then it rises in: a warm "human" gold,
   deliberately the opposite of the cold cyan they hailed us with. */
.cd-reply {
  display: none;
  width: 100%; margin: 0 0 .7rem; padding: .6rem .8rem;
  font-family: var(--mono-font); font-size: .68rem; font-weight: 700;
  letter-spacing: .18em; text-transform: uppercase; cursor: pointer;
  color: #fde68a; background: linear-gradient(90deg, rgba(251,191,36,.16), rgba(251,146,60,.06));
  border: 1px solid rgba(251,191,36,.5); border-radius: 5px;
  text-shadow: 0 0 12px rgba(251,191,36,.5);
  box-shadow: 0 0 0 rgba(251,191,36,0);
  transition: box-shadow .25s ease, background .25s ease, transform .12s ease, opacity .4s ease;
  opacity: 0; transform: translateY(6px);
}
.cd-live .cd-reply { display: block; opacity: 1; transform: translateY(0); animation: cd-reply-pulse 2.6s ease-in-out infinite; }
.cd-reply:hover:not(:disabled) {
  background: linear-gradient(90deg, rgba(251,191,36,.28), rgba(251,146,60,.12));
  box-shadow: 0 0 22px rgba(251,191,36,.45); transform: translateY(-1px);
}
.cd-reply:disabled {
  cursor: default; animation: none; color: #34d399;
  border-color: rgba(52,211,153,.5);
  background: linear-gradient(90deg, rgba(52,211,153,.14), rgba(52,211,153,0));
  text-shadow: 0 0 12px rgba(52,211,153,.55);
}
@keyframes cd-reply-pulse {
  0%,100% { box-shadow: 0 0 0 rgba(251,191,36,0); }
  50%     { box-shadow: 0 0 18px rgba(251,191,36,.35); }
}

/* The round-trip verdict — when our reply lands, when an answer could return. */
.cd-roundtrip {
  font-family: var(--mono-font); font-size: .62rem; line-height: 1.5;
  letter-spacing: .08em; text-transform: uppercase;
  color: #fcd34d; margin: 0 0 .8rem; padding: .45rem .6rem;
  border-left: 2px solid currentColor; border-radius: 3px;
  background: linear-gradient(90deg, rgba(251,191,36,.10), rgba(251,191,36,0));
  text-shadow: 0 0 14px rgba(251,191,36,.35);
}

/* ── Status line — the decode state machine ── */
.cd-status {
  font-family: var(--mono-font); font-size: .64rem; letter-spacing: .2em;
  text-transform: uppercase; padding-top: .5rem;
  border-top: 1px solid var(--glass-b);
  display: flex; align-items: center; gap: .5rem;
}
.cd-status::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: currentColor; box-shadow: 0 0 10px currentColor;
}
.cd-status[data-state="scan"]   { color: var(--gold); animation: cd-blink 1s steps(2) infinite; }
.cd-status[data-state="decode"] { color: var(--electric); animation: cd-flicker .35s steps(2) infinite; }
.cd-status[data-state="msg"]    { color: var(--cosmic); }
.cd-status[data-state="live"]   { color: #34d399; animation: cd-live-glow 2.4s ease-in-out infinite; }
.cd-status[data-state="reply"]  { color: var(--gold); animation: cd-flicker .35s steps(2) infinite; }
@keyframes cd-blink   { 50% { opacity: .4; } }
@keyframes cd-flicker { 0%,100% { opacity: 1; } 50% { opacity: .55; } }
@keyframes cd-live-glow { 0%,100% { text-shadow: 0 0 8px rgba(52,211,153,.4); } 50% { text-shadow: 0 0 18px rgba(52,211,153,.9); } }

/* Mobile: dock the file to the bottom so it never covers the planet */
@media (max-width: 720px) {
  .contact-dossier {
    top: auto; bottom: 9.5rem; right: .8rem; left: .8rem;
    width: auto; max-width: none;
    transform: translate(0, 18px);
  }
  .contact-dossier.cd-in { transform: translate(0, 0); }
  .cd-portrait-frame { height: 9rem; }
  .cd-species { font-size: 1.2rem; }
  .cd-fact { font-size: .72rem; }
  .cd-message { font-size: 1.06rem; }
}
