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

:root {
  --cyan: #00ffe0;
  --magenta: #ff2bd6;
  --amber: #ffcc33;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  /* Retro arcade monospace */
  font-family: "Courier New", "Lucida Console", monospace;
  color: var(--cyan);
  cursor: none;
  text-transform: uppercase;
  touch-action: none;           /* no scroll/zoom from game touches */
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

#game { display: block; width: 100vw; height: 100vh; }

/* ESP overlay sits above the 3D view but below the HUD text. */
#esp {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

/* ---------- Global CRT overlay (on top of the DOM HUD too) ---------- */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  /* Faint horizontal scanlines + corner vignette to match the WebGL CRT pass */
  /* Kept light — the WebGL CRT pass already does the heavy scanlines/vignette.
     This is just a faint extra texture over the DOM HUD. */
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0) 0px,
      rgba(0, 0, 0, 0) 2px,
      rgba(0, 0, 0, 0.06) 3px,
      rgba(0, 0, 0, 0.06) 4px),
    radial-gradient(ellipse at center, rgba(0,0,0,0) 70%, rgba(0,0,0,0.25) 100%);
}

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.6s ease;
  letter-spacing: 2px;
}
#hud.active { opacity: 1; }

#crosshair {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 30px;
  font-weight: 700;
  color: var(--cyan);
  text-shadow: 0 0 8px var(--cyan), 0 0 16px var(--cyan);
}

#stats {
  position: absolute;
  left: 32px;
  bottom: 32px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 13px;
}
.stat { display: flex; align-items: center; gap: 12px; }
.label { color: var(--magenta); min-width: 56px; text-shadow: 0 0 6px var(--magenta); }
#speed {
  font-variant-numeric: tabular-nums;
  color: var(--cyan);
  font-size: 18px;
  text-shadow: 0 0 8px var(--cyan);
}

.bar {
  width: 160px; height: 9px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid var(--magenta);
  box-shadow: 0 0 8px rgba(255, 43, 214, 0.6);
}
#boost-fill {
  height: 100%;
  width: 100%;
  background: var(--magenta);
  box-shadow: 0 0 12px var(--magenta);
  transition: width 0.08s linear;
}

#health-fill {
  height: 100%;
  width: 100%;
  background: var(--cyan);
  box-shadow: 0 0 12px var(--cyan);
  transition: width 0.12s linear, background 0.2s;
}
/* Hull bar only shown in modes where you can die. */
#health-stat { display: none; }
#hud.lethal #health-stat { display: flex; }

#score {
  position: absolute;
  right: 32px;
  top: 28px;
  font-size: 14px;
  letter-spacing: 3px;
  color: var(--magenta);
  text-shadow: 0 0 8px var(--magenta);
}
#score-val { color: var(--cyan); font-size: 20px; text-shadow: 0 0 8px var(--cyan); }

/* Wave / mode readout, top-centre */
#wave-info {
  position: absolute;
  top: 22px; left: 50%;
  transform: translateX(-50%);
  text-align: center;
}
#wave-label { color: var(--magenta); font-size: 18px; letter-spacing: 5px; text-shadow: 0 0 10px var(--magenta); }
#wave-sub { color: var(--cyan); font-size: 12px; letter-spacing: 4px; margin-top: 3px; text-shadow: 0 0 8px var(--cyan); }

/* Big transient announcement (WAVE N, etc.) */
#banner {
  position: absolute;
  top: 38%; left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  font-size: 52px;
  letter-spacing: 12px;
  color: var(--cyan);
  text-shadow: 0 0 20px var(--cyan), 4px 4px 0 var(--magenta);
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
#banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* ---------- Mode picker ---------- */
.modes {
  display: flex;
  gap: 14px;
  justify-content: center;
  margin-bottom: 28px;
}
.mode-card {
  width: 200px;
  text-align: left;
  padding: 16px 18px;
  cursor: pointer;
  font-family: inherit;
  color: var(--cyan);
  background: rgba(0, 255, 224, 0.04);
  border: 1px solid rgba(0, 255, 224, 0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.mode-card:hover { transform: translateY(-3px); border-color: var(--cyan); box-shadow: 0 0 18px rgba(0,255,224,0.4); }
.mode-card.selected {
  border-color: var(--magenta);
  background: rgba(255, 43, 214, 0.08);
  box-shadow: 0 0 22px rgba(255, 43, 214, 0.5);
}
.mode-name {
  display: block;
  font-size: 18px;
  letter-spacing: 3px;
  margin-bottom: 8px;
  color: #fff;
  text-shadow: 0 0 10px var(--cyan);
}
.mode-card.selected .mode-name { text-shadow: 0 0 10px var(--magenta); }
.mode-desc {
  display: block;
  font-size: 11px;
  line-height: 1.5;
  letter-spacing: 1px;
  color: #7fb6da;
  text-transform: none;
}

/* ---------- Game over ---------- */
#gameover-overlay {
  --red: #ff2030;
  position: fixed;
  inset: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(90, 0, 10, 0.72), rgba(8, 0, 0, 0.985));
  cursor: default;
  transition: opacity 0.5s ease;
}
#gameover-overlay.hidden { opacity: 0; pointer-events: none; }
#gameover-overlay .panel {
  border-color: var(--red);
  background: rgba(20, 0, 2, 0.62);
  box-shadow: 0 0 50px rgba(255, 30, 40, 0.45), inset 0 0 34px rgba(255, 30, 40, 0.18);
}
#gameover-overlay h1 {
  color: var(--red);
  text-shadow: 0 0 16px var(--red), 0 0 36px rgba(255,30,40,0.7), 4px 4px 0 #5a0008;
}
#gameover-overlay .tagline { color: #ff6a6a; text-shadow: 0 0 10px rgba(255,40,40,0.8); }
.go-stats { color: #ff8a8a; letter-spacing: 3px; font-size: 15px; margin-bottom: 28px; text-shadow: 0 0 8px rgba(255,60,60,0.8); }
#go-menu {
  padding: 14px 44px;
  font-size: 15px;
  letter-spacing: 5px;
  color: #1a0000;
  font-weight: 700;
  font-family: inherit;
  text-transform: uppercase;
  border: none;
  cursor: pointer;
  background: var(--red);
  box-shadow: 0 0 26px var(--red);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
#go-menu:hover { transform: scale(1.05); box-shadow: 0 0 44px var(--red); }

/* ---------- Mobile touch controls ---------- */
#touch-controls { display: none; }
body.mobile.playing #touch-controls {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 15;
  pointer-events: none; /* children re-enable */
}

.joystick {
  position: absolute;
  bottom: 34px;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: 2px solid rgba(0, 255, 224, 0.4);
  background: rgba(0, 255, 224, 0.05);
  box-shadow: 0 0 18px rgba(0, 255, 224, 0.25), inset 0 0 24px rgba(0,255,224,0.08);
  pointer-events: auto;
  touch-action: none;
}
#joy-left { left: 30px; }
#joy-right {
  right: 30px;
  border-color: rgba(255, 43, 214, 0.45);
  background: rgba(255, 43, 214, 0.05);
  box-shadow: 0 0 18px rgba(255, 43, 214, 0.25), inset 0 0 24px rgba(255,43,214,0.08);
}
.stick {
  position: absolute;
  top: 50%; left: 50%;
  width: 60px; height: 60px;
  margin: -30px 0 0 -30px;
  border-radius: 50%;
  background: rgba(0, 255, 224, 0.25);
  border: 1px solid var(--cyan);
  box-shadow: 0 0 16px rgba(0, 255, 224, 0.6);
}
#joy-right .stick {
  background: rgba(255, 43, 214, 0.25);
  border-color: var(--magenta);
  box-shadow: 0 0 16px rgba(255, 43, 214, 0.6);
}
.joy-label {
  position: absolute;
  top: -22px; left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  letter-spacing: 2px;
  color: rgba(160, 220, 240, 0.7);
  white-space: nowrap;
}

.touch-btn {
  position: absolute;
  pointer-events: auto;
  touch-action: none;
  width: 104px; height: 104px;
  border-radius: 50%;
  font-family: inherit;
  font-size: 15px;
  letter-spacing: 2px;
  font-weight: 700;
  color: #02000a;
  border: none;
  transition: transform 0.08s ease, filter 0.08s ease;
}
#btn-fire {
  right: 184px; bottom: 56px;
  background: var(--cyan);
  box-shadow: 0 0 22px var(--cyan);
}
#btn-boost {
  left: 184px; bottom: 56px;
  background: var(--magenta);
  color: #fff;
  box-shadow: 0 0 22px var(--magenta);
}
.touch-btn.active { transform: scale(0.9); filter: brightness(1.35); }

/* Rotate-to-landscape prompt (mobile portrait fallback) */
#rotate-prompt { display: none; }
@media (orientation: portrait) {
  body.mobile #rotate-prompt {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 200;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 5, 0.96);
    text-align: center;
  }
}
.rotate-inner {
  color: var(--cyan);
  font-size: 26px;
  letter-spacing: 5px;
  line-height: 1.8;
  text-shadow: 0 0 16px var(--cyan);
}
.rotate-inner span { font-size: 13px; color: var(--magenta); letter-spacing: 4px; }

/* ---------- Responsive main menu ---------- */
/* Narrow screens (e.g. portrait phones): stack the mode cards. */
@media (max-width: 600px) {
  .modes { flex-direction: column; align-items: center; gap: 10px; }
  .mode-card { width: 100%; max-width: 320px; }
  .panel h1 { font-size: 40px; letter-spacing: 8px; }
}

/* Short screens (e.g. landscape phones): shrink everything to fit. */
@media (max-height: 560px) {
  .panel { padding: 18px 26px; }
  .panel h1 { font-size: 32px; letter-spacing: 7px; }
  .tagline { margin: 6px 0 12px; }
  .controls { font-size: 11px; line-height: 1.55; margin-bottom: 12px; }
  .modes { gap: 10px; margin-bottom: 14px; }
  .mode-card { width: 168px; padding: 10px 14px; }
  .mode-name { font-size: 14px; margin-bottom: 4px; }
  .mode-desc { font-size: 10px; line-height: 1.35; }
  #start-btn { padding: 10px 34px; font-size: 14px; }
  #gameover-overlay h1 { font-size: 34px; }
  .go-stats { margin-bottom: 16px; }
}

/* Very short + landscape: drop the controls list to save vertical space. */
@media (max-height: 430px) and (orientation: landscape) {
  .panel { padding: 14px 22px; }
  .controls { display: none; }
  .panel h1 { font-size: 28px; }
  .modes { flex-direction: row; }
}

/* ---------- Pause hint ---------- */
#pause-hint { display: none; }
body.paused { cursor: default; }
body.paused #pause-hint {
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0;
  z-index: 30;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 5, 0.55);
  color: var(--cyan);
  font-size: 44px;
  letter-spacing: 12px;
  text-align: center;
  text-shadow: 0 0 18px var(--cyan), 4px 4px 0 var(--magenta);
}
#pause-hint span { font-size: 14px; letter-spacing: 5px; color: var(--magenta); margin-top: 14px; }

/* ---------- Start overlay ---------- */
#start-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(20, 0, 30, 0.5), rgba(0, 0, 5, 0.96));
  cursor: default;
  transition: opacity 0.5s ease;
}
#start-overlay.hidden { opacity: 0; pointer-events: none; }
/* Allow the menu to scroll if it ever exceeds the viewport (small screens). */
#start-overlay, #gameover-overlay { overflow: auto; padding: 16px; }

.panel {
  text-align: center;
  margin: auto;          /* keeps it scrollable when taller than the viewport */
  padding: 48px 56px;
  border: 2px solid var(--magenta);
  background: rgba(5, 0, 12, 0.6);
  box-shadow: 0 0 40px rgba(255, 43, 214, 0.4), inset 0 0 30px rgba(255, 43, 214, 0.15);
}
.panel h1 {
  font-size: 60px;
  letter-spacing: 16px;
  font-weight: 700;
  color: var(--cyan);
  text-shadow:
    0 0 10px var(--cyan),
    0 0 24px var(--cyan),
    4px 4px 0 var(--magenta);   /* offset = chromatic-split echo */
}
.tagline { color: var(--magenta); margin: 14px 0 28px; letter-spacing: 6px; font-size: 13px;
  text-shadow: 0 0 8px var(--magenta); }

.controls {
  list-style: none;
  text-align: left;
  display: inline-block;
  margin-bottom: 28px;
  font-size: 13px;
  line-height: 2.1;
  color: var(--cyan);
}
.controls kbd {
  display: inline-block;
  min-width: 22px;
  padding: 2px 8px;
  margin-right: 6px;
  border: 1px solid var(--cyan);
  background: rgba(0, 255, 224, 0.08);
  box-shadow: 0 0 6px rgba(0, 255, 224, 0.4);
  font-size: 11px;
  text-align: center;
  font-family: inherit;
}

#start-btn {
  padding: 14px 52px;
  font-size: 16px;
  letter-spacing: 6px;
  color: #02000a;
  font-weight: 700;
  font-family: inherit;
  text-transform: uppercase;
  border: none;
  cursor: pointer;
  background: var(--cyan);
  box-shadow: 0 0 24px var(--cyan);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
#start-btn:hover {
  transform: scale(1.06);
  background: var(--magenta);
  color: #fff;
  box-shadow: 0 0 40px var(--magenta);
}
