/* ============================================================
   Trench World — 8-bit fortress canyon
   void / hull / cyan / magenta / shrine clay / core orange
   ============================================================ */

:root {
  --void:     #07060b;
  --hull:     #8b9bb4;
  --navy:     #2a3344;
  --cyan:     #3de0ff;
  --magenta:  #ff4ad2;
  --clay:     #c4a574;
  --core:     #ff6a12;
  --paper:    #e8eef4;
  --dim:      rgba(232, 238, 244, 0.55);

  --font-display: "Silkscreen", monospace;
  --font-mono:    "Share Tech Mono", monospace;
}

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

html { scroll-behavior: smooth; }

html, body {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
::selection { background: transparent; color: inherit; }

body {
  background: var(--void);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 1.12rem;
  line-height: 1.5;
  overflow-x: hidden;
  touch-action: pan-y;
}
body.gun { cursor: none; }
body.gun a,
body.gun button { cursor: pointer; }

#world {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: block;
  image-rendering: pixelated;
}

/* CRT glass — scanlines + phosphor + barrel vignette */
.crt {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0) 0px,
      rgba(0, 0, 0, 0) 2px,
      rgba(0, 0, 0, 0.18) 2px,
      rgba(0, 0, 0, 0.18) 3px
    );
  box-shadow:
    inset 0 0 80px 28px rgba(0, 0, 0, 0.62),
    inset 0 0 180px 60px rgba(0, 0, 0, 0.35);
}
.crt::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(70, 210, 190, 0.035);
  mix-blend-mode: overlay;
}

.progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 4px;
  z-index: 40;
  background: rgba(232, 238, 244, 0.08);
  image-rendering: pixelated;
}
.progress span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--cyan), var(--magenta));
}

.hud {
  position: fixed;
  left: 1.2rem;
  bottom: 1.1rem;
  z-index: 40;
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  font-family: var(--font-display);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  color: var(--cyan);
  text-shadow: 2px 0 0 rgba(255, 74, 210, 0.35);
}
.hud__lab {
  color: var(--dim);
  letter-spacing: 0.2em;
  font-size: 0.52rem;
  margin-left: 0.45rem;
}
.hud__lab:first-child { margin-left: 0; }
#hud-stage, #hud-range, #hud-speed, #hud-score, #hud-hi { color: var(--cyan); }
#hud-combo { color: var(--magenta); }
.hud__combo-lab, #hud-combo { opacity: 0; }
.hud.is-combo .hud__combo-lab,
.hud.is-combo #hud-combo { opacity: 1; }

.reticle {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  z-index: 25;
  pointer-events: none;
  image-rendering: pixelated;
  border: 2px solid var(--cyan);
  box-shadow: 3px 0 0 rgba(255, 74, 210, 0.45);
}
.reticle::before,
.reticle::after {
  content: "";
  position: absolute;
  background: var(--cyan);
}
.reticle::before {
  left: 50%;
  top: -6px;
  width: 2px;
  height: 32px;
  margin-left: -1px;
}
.reticle::after {
  top: 50%;
  left: -6px;
  height: 2px;
  width: 32px;
  margin-top: -1px;
}
.reticle.is-charge {
  border-color: var(--core);
  box-shadow: 3px 0 0 rgba(61, 224, 255, 0.45);
  transform: scale(1.35);
}
.reticle.is-charge::before,
.reticle.is-charge::after { background: var(--core); }

.hint {
  position: fixed;
  left: 50%;
  bottom: 3.4rem;
  transform: translateX(-50%);
  z-index: 26;
  pointer-events: none;
  font-family: var(--font-display);
  font-size: 0.62rem;
  letter-spacing: 0.22em;
  color: var(--cyan);
  text-shadow: 2px 0 0 rgba(255, 74, 210, 0.4);
  opacity: 0.85;
  transition: opacity 0.4s steps(4);
}
.hint.is-gone { opacity: 0; }

.crit {
  position: fixed;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%);
  z-index: 27;
  pointer-events: none;
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 4vw, 2.6rem);
  letter-spacing: 0.18em;
  color: var(--core);
  text-shadow: 3px 0 0 rgba(61, 224, 255, 0.55);
  opacity: 0;
}
.crit.is-on { opacity: 1; animation: critpop 0.7s steps(4); }
@keyframes critpop {
  0% { transform: translate(-50%, -50%) scale(0.6); }
  40% { transform: translate(-50%, -50%) scale(1.15); }
  100% { transform: translate(-50%, -50%) scale(1); }
}

.pips { position: fixed; inset: 0; z-index: 28; pointer-events: none; }
.pip {
  position: absolute;
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--cyan);
  text-shadow: 2px 0 0 rgba(255, 74, 210, 0.45);
  transform: translate(-50%, 0);
  animation: pipup 0.72s steps(6) forwards;
  white-space: nowrap;
}
.pip.is-crit { color: var(--core); font-size: 0.9rem; }
@keyframes pipup {
  0% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -52px); }
}

.tally {
  position: fixed;
  left: 50%;
  bottom: 18%;
  transform: translateX(-50%);
  z-index: 26;
  pointer-events: none;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  font-family: var(--font-display);
  letter-spacing: 0.18em;
  color: var(--paper);
  text-shadow: 3px 0 0 rgba(255, 74, 210, 0.3);
}
.tally.is-on { display: flex; }
.tally__lab {
  font-size: 0.58rem;
  color: var(--dim);
  margin-top: 0.55rem;
}
#tally-score {
  font-size: clamp(1.8rem, 5vw, 3.2rem);
  color: var(--cyan);
}
#tally-hi { font-size: 0.9rem; color: var(--paper); }

@media (max-width: 700px) {
  .hud {
    left: 0.6rem;
    bottom: 0.7rem;
    font-size: 0.5rem;
    flex-wrap: wrap;
    max-width: 70%;
  }
  .hint { bottom: 4.6rem; font-size: 0.52rem; }
}

.sound {
  position: fixed;
  top: 1.1rem;
  left: 1.2rem;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: transparent;
  border: 2px solid rgba(61, 224, 255, 0.45);
  color: var(--paper);
  font-family: var(--font-display);
  font-size: 0.58rem;
  letter-spacing: 0.18em;
  padding: 0.45rem 0.7rem;
  cursor: pointer;
  image-rendering: pixelated;
}
.sound:hover,
.sound.on { border-color: var(--cyan); color: var(--cyan); }
.sound__bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 12px;
}
.sound__bars i {
  display: block;
  width: 3px;
  height: 4px;
  background: currentColor;
}
.sound.on .sound__bars i:nth-child(1) { animation: eq 0.46s steps(2) infinite; }
.sound.on .sound__bars i:nth-child(2) { animation: eq 0.38s steps(2) infinite 0.08s; height: 8px; }
.sound.on .sound__bars i:nth-child(3) { animation: eq 0.52s steps(2) infinite 0.04s; height: 11px; }
.sound.on .sound__bars i:nth-child(4) { animation: eq 0.4s steps(2) infinite 0.12s; height: 6px; }
@keyframes eq {
  0%, 100% { transform: scaleY(0.45); }
  50% { transform: scaleY(1); }
}

.chapter-nav {
  position: fixed;
  right: 1.3rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 1.05rem;
}
.chapter-nav a {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
  text-decoration: none;
  color: var(--paper);
}
.chapter-nav i {
  width: 8px; height: 8px;
  border: 2px solid var(--cyan);
  background: transparent;
  flex: none;
  image-rendering: pixelated;
  transition: background 0.15s steps(2), transform 0.15s steps(2);
}
.chapter-nav em {
  font-family: var(--font-display);
  font-style: normal;
  font-size: 0.58rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0;
  transform: translateX(6px);
  transition: opacity 0.2s steps(2), transform 0.2s steps(2);
  white-space: nowrap;
}
.chapter-nav a:hover em,
.chapter-nav a.active em { opacity: 0.92; transform: none; }
.chapter-nav a.active i { background: var(--cyan); transform: scale(1.25); }

@media (max-width: 900px) { .chapter-nav { display: none; } }

main { position: relative; z-index: 10; pointer-events: none; }

.chapter { position: relative; }
.chapter--hero   { min-height: 100vh; min-height: 100dvh; }
.chapter--canyon { min-height: 220vh; }
.chapter--shrine { min-height: 200vh; }
.chapter--core   { min-height: 210vh; }
.chapter--pullup { min-height: 200vh; }

.copy-wrap {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  padding: 0 clamp(1.4rem, 6vw, 6rem);
  pointer-events: none;
}
.copy-wrap a { pointer-events: auto; }

.copy {
  max-width: 34rem;
  text-shadow:
    3px 0 0 rgba(255, 74, 210, 0.28),
    -2px 0 0 rgba(61, 224, 255, 0.28),
    0 3px 18px rgba(0, 0, 0, 0.9);
}
.copy--left   { margin-right: auto; }
.copy--right  { margin-left: auto; text-align: right; }
.copy--center { margin: 0 auto; text-align: center; max-width: 46rem; }

.copy > * {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.55s steps(6), transform 0.55s steps(6);
}
.copy > *:nth-child(2) { transition-delay: 0.08s; }
.copy > *:nth-child(3) { transition-delay: 0.16s; }
.copy > *:nth-child(4) { transition-delay: 0.24s; }
.is-inview .copy > * { opacity: 1; transform: none; }

.kicker {
  font-family: var(--font-display);
  font-size: clamp(0.62rem, 1.1vw, 0.78rem);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--cyan);
  margin-bottom: 1rem;
}
.chapter--shrine .kicker { color: var(--clay); }
.chapter--core .kicker { color: var(--core); }
.chapter--pullup .kicker { color: var(--paper); }

.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(3.2rem, 12vw, 8.4rem);
  line-height: 0.9;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin-bottom: 1.3rem;
  color: var(--paper);
}

.copy h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.7rem, 4.2vw, 3.1rem);
  line-height: 1.05;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  margin-bottom: 1rem;
}

.lede {
  font-size: clamp(1.02rem, 1.6vw, 1.22rem);
  opacity: 0.94;
}
.lede em { color: var(--cyan); font-style: normal; }
.chapter--shrine .lede em { color: var(--clay); }
.chapter--core .lede em { color: var(--core); }

.cta-row { margin-top: 2rem; }
.cta {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--paper);
  text-decoration: none;
  border: 2px solid var(--cyan);
  padding: 0.8rem 1.5rem;
  image-rendering: pixelated;
  transition: background 0.12s steps(2), color 0.12s steps(2);
}
.cta:hover { background: var(--cyan); color: var(--void); }
.chapter--pullup .cta { border-color: var(--paper); }
.chapter--pullup .cta:hover { background: var(--paper); color: var(--void); }

/* no-webgl posters — still readable */
body.no-webgl #world { display: none; }
body.no-webgl .chapter--hero {
  background:
    radial-gradient(ellipse at 50% 70%, #1a3044 0%, transparent 55%),
    repeating-linear-gradient(0deg, #07060b 0 3px, #0c1018 3px 6px);
}
body.no-webgl .chapter--canyon {
  background:
    linear-gradient(90deg, #2a3344 0 18%, transparent 22% 78%, #2a3344 82%),
    repeating-linear-gradient(90deg, #121820 0 8px, #0a0e14 8px 16px);
}
body.no-webgl .chapter--shrine {
  background:
    radial-gradient(ellipse at 80% 50%, #c4a57433 0%, transparent 50%),
    linear-gradient(180deg, #1a1410, #07060b);
}
body.no-webgl .chapter--core {
  background:
    radial-gradient(ellipse at 50% 55%, #ff6a12 0%, #3a1008 28%, #07060b 70%);
}
body.no-webgl .chapter--pullup {
  background:
    radial-gradient(ellipse at 50% 40%, #1c2838 0%, #07060b 70%);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .copy > * { transition: none; opacity: 1; transform: none; }
  .sound.on .sound__bars i { animation: none; }
  .crt { background: none; box-shadow: inset 0 0 60px 20px rgba(0, 0, 0, 0.4); }
}
