:root {
  --bg: #0B1026;
  --teal: #2EE6D6;
  --acid: #A6FF3B;
  --red: #FF4D5E;
  --white: #F4F1E8;
  --ink: #070A1A;
  --mono: 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, Menlo, Consolas, monospace;
  --grotesk: 'Space Grotesk', 'Onest', system-ui, sans-serif;
  --u: 1px; /* px per design unit, set from JS */
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--white);
  overflow: hidden;
  font-family: var(--mono);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.intro {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--bg);
  contain: strict;
}

/* ---------- background ---------- */
.sky {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 70% at 50% 108%, rgba(46, 230, 214, .16) 0%, rgba(46, 230, 214, 0) 55%),
    radial-gradient(90% 60% at 50% 0%, #121a44 0%, rgba(18, 26, 68, 0) 70%),
    linear-gradient(180deg, #0a0e22 0%, #0B1026 45%, #111a3d 100%);
}

.bg-parallax {
  position: absolute;
  inset: -4%;
  will-change: transform;
  opacity: 0;
}

.moon {
  position: absolute;
  right: 12%;
  top: 9%;
  width: 11vmin;
  height: 11vmin;
  border-radius: 50%;
  background:
    radial-gradient(circle at 36% 34%, #fffdf6 0%, #f4f1e8 38%, #d9d3c4 100%);
  box-shadow:
    0 0 3vmin rgba(244, 241, 232, .35),
    0 0 12vmin rgba(46, 230, 214, .16);
  will-change: transform, opacity;
}
.moon i {
  position: absolute;
  border-radius: 50%;
  background: rgba(150, 140, 125, .28);
}
.moon i:nth-child(1) { width: 22%; height: 22%; left: 56%; top: 24%; }
.moon i:nth-child(2) { width: 14%; height: 14%; left: 28%; top: 58%; }
.moon i:nth-child(3) { width: 9%;  height: 9%;  left: 62%; top: 66%; }

.stars { position: absolute; inset: 0; }
.star-layer {
  position: absolute;
  inset: 0;
  will-change: opacity;
}
.star {
  position: absolute;
  width: 3px;
  height: 3px;
  background: var(--white);
  box-shadow: 0 0 6px rgba(46, 230, 214, .8);
}
.star.is-big { width: 4px; height: 4px; }
.star.is-teal { background: var(--teal); }
.star.is-plus {
  width: 11px; height: 11px;
  background: none;
  box-shadow: none;
}
.star.is-plus::before, .star.is-plus::after {
  content: '';
  position: absolute;
  background: var(--white);
  box-shadow: 0 0 6px rgba(166, 255, 59, .9);
}
.star.is-plus::before { left: 4px; top: 0; width: 3px; height: 11px; }
.star.is-plus::after  { left: 0; top: 4px; width: 11px; height: 3px; }

.rain { position: absolute; inset: 0; overflow: hidden; }
.rain-line {
  position: absolute;
  top: 0;
  left: 0;
  white-space: pre;
  font-family: var(--mono);
  font-weight: 500;
  color: var(--teal);
  will-change: transform;
  line-height: 1;
  pointer-events: none;
}
.rain-line b { color: var(--acid); font-weight: 500; }

/* ---------- stage ---------- */
.stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  overflow: hidden;
}
.stage text { font-family: var(--mono); }
.stage .t-grotesk { font-family: var(--grotesk); }

/* ---------- CRT ---------- */
.crt {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, .16) 0 1px, rgba(0, 0, 0, 0) 1px 3px),
    radial-gradient(ellipse 80% 75% at 50% 50%, rgba(0, 0, 0, 0) 60%, rgba(2, 4, 14, .72) 100%);
  mix-blend-mode: normal;
}
.crt__flicker {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 45%, rgba(46, 230, 214, .05), rgba(46, 230, 214, 0) 70%);
  opacity: 0;
  will-change: opacity;
}
.flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 40%, rgba(244, 241, 232, .9), rgba(46, 230, 214, .35) 45%, rgba(11, 16, 38, 0) 75%);
  opacity: 0;
  will-change: opacity;
}

/* ---------- UI ---------- */
.ui-btn {
  position: absolute;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: .55em;
  padding: .7em 1.05em;
  font: 600 14px/1 var(--mono);
  letter-spacing: .02em;
  color: var(--white);
  background: rgba(8, 12, 30, .82);
  border: 1px solid rgba(46, 230, 214, .45);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color .2s, background-color .2s, color .2s, box-shadow .2s;
}
.ui-btn:hover { border-color: var(--teal); box-shadow: 0 0 18px rgba(46, 230, 214, .35); }
.ui-btn:focus-visible { outline: 2px solid var(--acid); outline-offset: 3px; }

.sound-btn {
  left: calc(20px + var(--safe-l));
  bottom: calc(20px + var(--safe-b));
}
.sound-btn__icon { font-size: 16px; line-height: 1; }
.sound-btn[aria-pressed="true"] { border-color: var(--acid); color: var(--acid); }

.skip-btn {
  right: calc(20px + var(--safe-r));
  bottom: calc(20px + var(--safe-b));
  opacity: 0;
  visibility: hidden;
}

.cta {
  position: absolute;
  z-index: 4;
  left: 0;
  top: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .6em;
  padding: .85em 1.7em;
  font: 800 22px/1 var(--mono);
  letter-spacing: .02em;
  color: var(--bg);
  background: var(--acid);
  border-radius: .45em;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 0 0 1px rgba(166, 255, 59, .5), 0 0 28px rgba(166, 255, 59, .45), 0 0 80px rgba(46, 230, 214, .25);
  opacity: 0;
  visibility: hidden;
  will-change: transform, opacity;
}
.cta::after { content: '→'; font-weight: 700; transition: transform .25s cubic-bezier(.34, 1.56, .64, 1); }
.cta:hover::after { transform: translateX(.3em); }
.cta:hover { background: #b9ff63; }
.cta:focus-visible { outline: 3px solid var(--teal); outline-offset: 4px; }

.replay-btn {
  position: absolute;
  z-index: 5;
  right: calc(18px + var(--safe-r));
  bottom: calc(18px + var(--safe-b));
  padding: .5em .8em;
  font: 500 13px/1 var(--mono);
  color: rgba(244, 241, 232, .6);
  background: none;
  border: 0;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
}
.replay-btn:hover { color: var(--teal); }
.replay-btn:focus-visible { outline: 2px solid var(--acid); outline-offset: 2px; }

.noscript { position: fixed; inset: auto 0 40% 0; text-align: center; font: 700 22px var(--mono); }

/* GSAP could not load (offline CDN): readable static fallback */
.fallback { display: none; }
body.no-gsap .fallback {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 24px; text-align: center;
}
body.no-gsap .fallback b { font: 800 clamp(30px, 6vw, 96px)/1 var(--mono); color: var(--acid); }
body.no-gsap .fallback span { font: 700 clamp(18px, 2.4vw, 40px)/1.25 var(--grotesk); }
body.no-gsap .stage, body.no-gsap .ui-btn, body.no-gsap .replay-btn { display: none; }
body.no-gsap .cta { position: static; opacity: 1; visibility: visible; margin-top: 12px; }
body.no-gsap .fallback { pointer-events: none; }
body.no-gsap .intro { display: flex; align-items: center; justify-content: center; }

/* loading: keep things dark until fonts + GSAP are ready */
body.is-loading .stage,
body.is-loading .ui-btn { opacity: 0; }

/* reduced motion: static final frame, soft fade-in */
body.is-static .intro { animation: introFade 1.2s ease-out both; }
body.is-static .sound-btn,
body.is-static .skip-btn { display: none; }
@keyframes introFade { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 520px) {
  .ui-btn { font-size: 12.5px; padding: .65em .9em; }
  .sound-btn { left: calc(12px + var(--safe-l)); bottom: calc(14px + var(--safe-b)); }
  .skip-btn { right: calc(12px + var(--safe-r)); bottom: calc(14px + var(--safe-b)); }
  .replay-btn { right: calc(8px + var(--safe-r)); bottom: calc(12px + var(--safe-b)); font-size: 12px; }
}

/* ---------- debug ---------- */
.dbg {
  position: fixed;
  z-index: 50;
  left: 50%;
  top: 12px;
  transform: translateX(-50%);
  width: min(760px, calc(100vw - 24px));
  padding: 10px 12px 12px;
  font: 500 12px/1.3 var(--mono);
  color: var(--white);
  background: rgba(5, 8, 22, .86);
  border: 1px solid rgba(46, 230, 214, .5);
  border-radius: 10px;
}
.dbg__row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dbg__time { color: var(--acid); font-weight: 800; font-size: 15px; min-width: 128px; font-variant-numeric: tabular-nums; }
.dbg__scene { color: var(--teal); font-weight: 700; min-width: 120px; }
.dbg__fps { margin-left: auto; opacity: .75; font-variant-numeric: tabular-nums; }
.dbg button {
  font: 700 12px/1 var(--mono);
  color: var(--bg);
  background: var(--teal);
  border: 0;
  border-radius: 6px;
  padding: 6px 9px;
  cursor: pointer;
}
.dbg__track { position: relative; margin-top: 10px; }
.dbg input[type="range"] { width: 100%; margin: 0; accent-color: var(--acid); }
.dbg__marks { position: relative; height: 14px; margin-top: 2px; }
.dbg__mark {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  font-size: 10px;
  color: rgba(244, 241, 232, .7);
  cursor: pointer;
  white-space: nowrap;
}
.dbg__mark::before { content: ''; position: absolute; left: 50%; top: -6px; width: 1px; height: 5px; background: var(--teal); }
