: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 */
.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: 1.1rem;
  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; }
