:root {
  --void: #020208;
  --white: #f0ece2;
  --pink: #ff2d6b;
  --blue: #3d5af1;
  --violet: #9d4edd;
  --gold: #fbbf24;
  --green: #10b981;
  --teal: #06b6d4;
  --amber: #f59e0b;
  --font-display: 'Syne', sans-serif;
  --font-serif: 'Playfair Display', Georgia, serif;
  --font-mono: 'JetBrains Mono', monospace;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; }
body {
  background: var(--void);
  color: var(--white);
  font-family: var(--font-mono);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .scroll-space { height: auto !important; }
  .pin-frame { position: relative !important; }
  .chapter { position: relative !important; opacity: 1 !important; min-height: 100vh; display: flex; }
  .reduced-motion-msg { display: block !important; }
}

.reduced-motion-msg {
  display: none !important;
  position: fixed; top: 0; left: 0; right: 0; z-index: 9999;
  background: var(--violet); color: white; text-align: center;
  padding: 0.8rem; font-size: 0.75rem; font-family: var(--font-mono);
}

/* ── PROGRESS ── */
.progress-track {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 1000;
  background: rgba(255,255,255,0.05);
}
.progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--pink), var(--blue), var(--violet), var(--gold), var(--green), var(--teal), var(--amber));
  will-change: width;
}

/* ── NAV DOTS ── */
.nav-dots {
  position: fixed; right: 1.5rem; top: 50%; transform: translateY(-50%);
  z-index: 100; display: flex; flex-direction: column; gap: 10px;
}
.nav-dot {
  width: 8px; height: 8px; border-radius: 50%; border: none; padding: 0; cursor: pointer;
  background: rgba(240,236,226,0.15); transition: all 0.5s cubic-bezier(0.16,1,0.3,1);
}
.nav-dot:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }
.nav-dot.active { background: var(--white); transform: scale(2); box-shadow: 0 0 20px rgba(240,236,226,0.6); }

/* ── SCROLL CTA ── */
.scroll-hint {
  position: fixed; bottom: 2.5rem; left: 50%; transform: translateX(-50%);
  z-index: 100; text-align: center; pointer-events: none;
  font-family: var(--font-mono); font-size: 0.65rem; letter-spacing: 0.25em;
  text-transform: uppercase; opacity: 0.4;
}
.scroll-hint .line {
  width: 1px; height: 40px; margin: 8px auto 0;
  background: linear-gradient(to bottom, transparent, var(--white));
  animation: hintPulse 1.8s ease-in-out infinite;
}
@keyframes hintPulse {
  0%, 100% { transform: scaleY(0.5); opacity: 0.2; }
  50% { transform: scaleY(1); opacity: 1; }
}

/* ── FLASH OVERLAY ── */
.flash-overlay {
  position: fixed; inset: 0; z-index: 50;
  pointer-events: none; opacity: 0;
  will-change: opacity;
}

/* ── SHAKE CONTAINER ── */
.shake-wrapper {
  position: fixed; inset: 0; z-index: 1;
  will-change: transform;
}

/* ── CANVAS ── */
#bg-canvas {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
}

/* ── SCROLL SPACE ── */
.scroll-space {
  width: 100%; height: 3500vh;
  position: relative;
}

/* ── PIN FRAME ── */
.pin-frame {
  width: 100vw; height: 100vh; position: relative; overflow: hidden;
}

/* ── CHAPTERS ── */
.chapter {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; will-change: opacity, transform;
  z-index: 2;
}
.ch-inner {
  width: 90vw; max-width: 1100px;
  text-align: center; position: relative; z-index: 2;
}

/* ── BG COLOR WASH ── */
.color-wash {
  position: fixed; inset: 0; z-index: -1; opacity: 0;
  will-change: opacity;
  pointer-events: none;
}

/* ── TYPE ── */
.ch-num {
  font-family: var(--font-mono); font-size: clamp(0.6rem,1vw,0.8rem);
  letter-spacing: 0.35em; text-transform: uppercase; opacity: 0.35; margin-bottom: 1.2rem;
}
.ch-title {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(3rem, 10vw, 9rem); line-height: 0.9;
  margin-bottom: 1.2rem; will-change: transform, opacity;
}
.ch-sub {
  font-family: var(--font-serif); font-style: italic;
  font-size: clamp(1rem, 2.5vw, 1.5rem);
  opacity: 0.6; max-width: 550px; margin: 0 auto 1.8rem; line-height: 1.5;
}
.ch-body {
  font-family: var(--font-mono); font-size: clamp(0.7rem, 1.1vw, 0.85rem);
  line-height: 1.9; opacity: 0.45; max-width: 480px; margin: 0 auto;
}

/* ── SPLIT CHARS ── */
.split-char {
  display: inline-block; will-change: transform, opacity;
}

/* ── CH1 intro ── */
#ch1 .ch-title {
  color: rgba(240,236,226,0);
  -webkit-text-stroke: 1.5px rgba(240,236,226,0.16);
  text-shadow: 0 0 16px rgba(240,236,226,0.045);
}

/* ── CH2 BANG: rings ── */
.bang-ring {
  position: absolute; top: 50%; left: 50%;
  width: 0; height: 0; border-radius: 50%;
  transform: translate(-50%,-50%);
  will-change: width, height, opacity, border-color;
}
#ring1 { border: 2px solid var(--pink); }
#ring2 { border: 2px solid var(--violet); }
#ring3 { border: 1px solid var(--blue); }
#ring4 { border: 1px solid var(--gold); }

/* ── CH3 ELEMENTS: orbits ── */
.orbit-system { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); }
.orbit { position: absolute; top: 50%; left: 50%; border-radius: 50%; border: 1px solid rgba(240,236,226,0.06); transform: translate(-50%,-50%); }
.orb {
  position: absolute; top: -5px; left: 50%; transform: translateX(-50%);
  width: 10px; height: 10px; border-radius: 50%; will-change: transform;
}

/* ── CH4 STARS ── */
.star-layer { position: absolute; inset: 0; overflow: hidden; }
.star {
  position: absolute; font-family: var(--font-display);
  opacity: 0; will-change: transform, opacity;
  text-shadow: 0 0 10px currentColor;
}

/* ── CH5 LIFE: helix ── */
.helix-wrap { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); width: 200px; height: 400px; }
.helix-node {
  position: absolute; width: 10px; height: 10px; border-radius: 50%;
  will-change: transform, opacity;
}
.helix-bar {
  position: absolute; height: 2px; will-change: transform, opacity;
  border-radius: 1px;
}

/* ── CH6 MIND ── */
.brain-grid { position: absolute; inset: 0; }
.node {
  position: absolute; width: 5px; height: 5px; border-radius: 50%;
  background: var(--teal); opacity: 0; will-change: opacity, transform, box-shadow;
}
.wire {
  position: absolute; height: 1px; opacity: 0;
  background: linear-gradient(90deg, transparent, var(--teal), transparent);
  transform-origin: left center; will-change: opacity;
}

/* ── CH7 EYE ── */
.eye-wrap {
  position: relative; width: clamp(220px, 45vw, 450px); height: clamp(100px, 20vw, 200px);
  margin: 0 auto 2.5rem;
}
.eye-shell {
  width: 100%; height: 100%; border-radius: 50%;
  border: 2px solid var(--amber); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.eye-iris {
  width: 55%; height: 110%; border-radius: 50%;
  background: radial-gradient(circle, var(--amber) 25%, rgba(245,158,11,0.3) 60%, transparent 75%);
  display: flex; align-items: center; justify-content: center;
}
.eye-pupil {
  width: 28%; aspect-ratio: 1; border-radius: 50%;
  background: var(--void); will-change: transform;
  box-shadow: inset 0 0 20px rgba(245,158,11,0.3);
}
.eye-glint {
  position: absolute; width: 8px; height: 8px; border-radius: 50%;
  background: white; top: 30%; right: 35%; opacity: 0;
}

/* ── COUNTER ── */
.epoch-counter {
  font-family: var(--font-mono); font-size: clamp(0.6rem, 0.9vw, 0.75rem);
  position: fixed; bottom: 2rem; left: 2rem; z-index: 100;
  opacity: 0.25; letter-spacing: 0.1em;
  font-variant-numeric: tabular-nums;
}

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .nav-dots { right: 0.6rem; gap: 7px; }
  .nav-dot { width: 6px; height: 6px; }
  .epoch-counter { display: none; }
}
@media (max-width: 480px) { .nav-dots { display: none; } }

/* ── A11Y ── */
:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }
.skip {
  position: fixed; top: -100px; left: 1rem; background: var(--violet); color: white;
  padding: 0.5rem 1rem; z-index: 10000; font-family: var(--font-mono);
  font-size: 0.8rem; border-radius: 4px; text-decoration: none; transition: top 0.3s;
}
.skip:focus { top: 1rem; }


/* ================================================================
   CONSTELLATION SYSTEM
   ================================================================ */
#interact-canvas {
  position: fixed; inset: 0; z-index: 3;
  cursor: crosshair;
}

.star-counter {
  position: fixed; top: 1.2rem; left: 1.5rem; z-index: 100;
  font-family: var(--font-mono); font-size: 0.7rem;
  letter-spacing: 0.15em; opacity: 0;
  transition: opacity 0.6s;
  pointer-events: none;
  color: var(--gold);
}
.star-counter.visible { opacity: 0.6; }
.star-counter .count { font-weight: bold; font-size: 0.85rem; }

.click-tooltip {
  position: fixed; bottom: 5rem; left: 50%; transform: translateX(-50%);
  z-index: 100; font-family: var(--font-mono); font-size: 0.6rem;
  letter-spacing: 0.2em; text-transform: uppercase;
  opacity: 0; transition: opacity 1s;
  pointer-events: none; color: rgba(240,236,226,0.35);
  text-align: center;
}
.click-tooltip.visible { opacity: 1; }

.secret-msg {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%);
  z-index: 200; font-family: var(--font-serif); font-style: italic;
  font-size: clamp(1rem, 2.5vw, 1.4rem);
  color: var(--gold); opacity: 0;
  pointer-events: none;
  text-align: center; max-width: 500px; line-height: 1.6;
  transition: opacity 2s;
  text-shadow: 0 0 30px rgba(251,191,36,0.3);
}
.secret-msg.revealed { opacity: 0.7; }


/* ================================================================
   ASTEROID DODGE GAME
   ================================================================ */
#game-canvas {
  position: fixed; inset: 0; z-index: 0;
  pointer-events: none;
}
body.game-active #game-canvas {
  z-index: 500;
  pointer-events: auto;
}

/* Play button */
.game-btn {
  position: fixed; bottom: 1.8rem; right: 1.8rem; z-index: 600;
  font-family: var(--font-mono); font-size: 0.65rem;
  letter-spacing: 0.2em; text-transform: uppercase;
  background: rgba(240,236,226,0.06);
  border: 1px solid rgba(240,236,226,0.15);
  color: var(--white); padding: 0.6rem 1.2rem;
  border-radius: 100px; cursor: pointer;
  transition: all 0.4s cubic-bezier(0.16,1,0.3,1);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.game-btn:hover {
  background: rgba(240,236,226,0.12);
  border-color: rgba(240,236,226,0.3);
  transform: scale(1.05);
}
.game-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }

/* Game HUD */
.game-hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 610;
  display: none; justify-content: space-between; align-items: center;
  padding: 1.2rem 2rem;
  font-family: var(--font-mono); font-size: 0.75rem;
  letter-spacing: 0.15em;
  pointer-events: none;
}
body.game-active .game-hud { display: flex; }

.hud-score { color: var(--gold); }
.hud-score .val { font-size: 1.1rem; font-weight: bold; }
.hud-ammo { color: var(--blue); }
.hud-ammo .val { font-size: 1.1rem; font-weight: bold; }
.hud-ammo.low .val { color: var(--pink); }
.hud-ammo.empty .val { color: var(--pink); animation: ammoBlink 0.4s infinite; }
@keyframes ammoBlink { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.hud-lives { display: flex; gap: 6px; }
.hud-heart { color: var(--pink); font-size: 1rem; transition: opacity 0.3s; }
.hud-heart.lost { opacity: 0.15; }
.hud-highscore { color: rgba(240,236,226,0.3); }
.hud-highscore .val { color: var(--gold); }

/* Game over overlay */
.game-over {
  position: fixed; inset: 0; z-index: 620;
  display: none; flex-direction: column;
  align-items: center; justify-content: center;
  background: rgba(2,2,8,0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.game-over.visible { display: flex; }
.game-over-title {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(2rem, 6vw, 4rem); color: var(--pink);
  margin-bottom: 0.5rem;
}
.game-over-score {
  font-family: var(--font-mono); font-size: 1rem;
  color: var(--gold); margin-bottom: 0.3rem; letter-spacing: 0.1em;
}
.game-over-best {
  font-family: var(--font-mono); font-size: 0.75rem;
  color: rgba(240,236,226,0.35); margin-bottom: 2rem; letter-spacing: 0.1em;
}
.game-over-buttons {
  display: flex; gap: 1rem; align-items: center; justify-content: center;
  flex-wrap: wrap;
}
.game-over-restart {
  font-family: var(--font-mono); font-size: 0.7rem;
  letter-spacing: 0.2em; text-transform: uppercase;
  background: rgba(255,45,107,0.15); border: 1px solid var(--pink);
  color: var(--pink); padding: 0.8rem 2rem;
  border-radius: 100px; cursor: pointer;
  transition: all 0.3s;
}
.game-over-restart:hover { background: rgba(255,45,107,0.3); transform: scale(1.05); }
.game-over-return {
  font-family: var(--font-mono); font-size: 0.7rem;
  letter-spacing: 0.2em; text-transform: uppercase;
  background: rgba(240,236,226,0.06); border: 1px solid rgba(240,236,226,0.2);
  color: rgba(240,236,226,0.5); padding: 0.8rem 2rem;
  border-radius: 100px; cursor: pointer;
  transition: all 0.3s;
}
.game-over-return:hover { background: rgba(240,236,226,0.12); color: var(--white); transform: scale(1.05); }

/* Fade site content when game is active */
body.game-active .pin-frame,
body.game-active .progress-track,
body.game-active .nav-dots,
body.game-active .scroll-hint,
body.game-active .epoch-counter,
body.game-active .star-counter,
body.game-active .click-tooltip,
body.game-active #interact-canvas,
body.game-active .color-wash {
  opacity: 0 !important;
  pointer-events: none !important;
  transition: opacity 0.5s;
}
body.game-active { overflow: hidden; }
