* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: #000;
  overflow: hidden;
  font-family: 'Orbitron', sans-serif;
  -webkit-user-select: none;
  user-select: none;
}

#scene {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

/* ---------------------------------------------------------------- title */
#titleScreen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #1a0a2e;
}

#titleBgImg {
  position: absolute;
  inset: 0;
  background: url('assets/img/title-bg.png') center 38% / cover no-repeat;
  filter: saturate(1.15) contrast(1.05);
}

#titleGrid {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 45%;
  background-image:
    linear-gradient(rgba(255, 61, 168, 0.55) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 61, 168, 0.55) 1px, transparent 1px);
  background-size: 60px 40px, 60px 40px;
  transform: perspective(300px) rotateX(62deg);
  transform-origin: bottom;
  mix-blend-mode: screen;
  -webkit-mask-image: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
  mask-image: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
}

#titleVignette {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(20, 4, 40, 0.55) 0%, rgba(30, 5, 40, 0.15) 30%, rgba(20, 2, 20, 0.35) 62%, rgba(10, 0, 15, 0.92) 100%),
    linear-gradient(90deg, rgba(255, 60, 170, 0.18), rgba(255, 140, 60, 0.08) 45%, rgba(90, 30, 200, 0.2));
}

#titleScanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.18) 3px,
    rgba(0, 0, 0, 0.18) 4px
  );
  mix-blend-mode: multiply;
  opacity: 0.6;
}

#titleContent {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1rem;
}

#titleLogoWrap {
  position: relative;
  display: inline-block;
}

#titleGlowHalo {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(1);
  width: 130%;
  height: 260%;
  background: radial-gradient(ellipse at center,
    rgba(255, 220, 130, 0.65) 0%,
    rgba(255, 61, 158, 0.5) 30%,
    rgba(178, 61, 255, 0.32) 52%,
    rgba(107, 216, 255, 0.16) 70%,
    transparent 82%);
  filter: blur(22px);
  z-index: -1;
  pointer-events: none;
  animation: haloPulse 2.2s ease-in-out infinite;
}

#titleLogo {
  position: relative;
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(1.9rem, 8.5vw, 5rem);
  margin: 0;
  line-height: 1.3;
  letter-spacing: 3px;
  animation: titleGlowPulse 2.2s ease-in-out infinite;
}
#titleLogo span {
  display: inline-block;
  background: linear-gradient(180deg, #fff9e6 0%, #ffe94d 16%, #ff8a3d 40%, #ff3d9e 66%, #b23dff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter:
    drop-shadow(0 0 2px rgba(255, 255, 255, 0.95))
    drop-shadow(0 0 8px rgba(255, 178, 61, 0.95))
    drop-shadow(0 0 20px rgba(255, 61, 158, 0.85))
    drop-shadow(0 0 42px rgba(255, 61, 158, 0.55))
    drop-shadow(0 0 80px rgba(178, 61, 255, 0.45));
}
#titleMonium {
  background: linear-gradient(180deg, #eafcff 0%, #9df5ff 16%, #6bd8ff 42%, #3d8eff 68%, #3dffc7 100%) !important;
  -webkit-background-clip: text !important;
  background-clip: text !important;
  filter:
    drop-shadow(0 0 2px rgba(255, 255, 255, 0.95))
    drop-shadow(0 0 8px rgba(157, 245, 255, 0.95))
    drop-shadow(0 0 20px rgba(107, 216, 255, 0.85))
    drop-shadow(0 0 42px rgba(107, 216, 255, 0.55))
    drop-shadow(0 0 80px rgba(61, 255, 199, 0.45)) !important;
}

@keyframes titleGlowPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.28); }
}
@keyframes haloPulse {
  0%, 100% { opacity: 0.7; transform: translate(-50%, -50%) scale(0.96); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
}

.subtitle {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(0.7rem, 2vw, 1rem);
  letter-spacing: 4px;
  color: #ffe0f0;
  opacity: 0.9;
  margin-top: 0.9rem;
  margin-bottom: 2.2rem;
  text-transform: uppercase;
  text-shadow: 0 0 10px rgba(255, 61, 158, 0.7);
}

#startBtn {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.7rem, 1.8vw, 1rem);
  padding: 1rem 1.8rem;
  background: rgba(10, 2, 20, 0.55);
  color: #3dffe6;
  border: 2px solid #ff3d9e;
  border-radius: 4px;
  letter-spacing: 1px;
  cursor: pointer;
  text-shadow: 0 0 8px rgba(61, 255, 230, 0.9);
  box-shadow: 0 0 12px rgba(255, 61, 158, 0.7), inset 0 0 12px rgba(255, 61, 158, 0.25);
  animation: titlePulse 1.3s ease-in-out infinite;
}
#startBtn kbd {
  font-family: inherit;
  background: rgba(255, 210, 63, 0.15);
  border: 1px solid #ffd23f;
  color: #ffd23f;
  padding: 2px 6px;
  border-radius: 3px;
}
#startBtn:active { transform: translateY(2px); }

@keyframes titlePulse {
  0%, 100% { box-shadow: 0 0 12px rgba(255, 61, 158, 0.7), inset 0 0 12px rgba(255, 61, 158, 0.25); opacity: 1; }
  50% { box-shadow: 0 0 26px rgba(61, 255, 230, 0.9), inset 0 0 18px rgba(61, 255, 230, 0.3); opacity: 0.85; }
}

#controlsHelp {
  margin-top: 1.8rem;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.8rem;
  line-height: 1.9;
  color: #ffe0f0;
  opacity: 0.92;
  background: rgba(10, 2, 20, 0.5);
  border: 1px solid rgba(255, 61, 158, 0.4);
  padding: 1rem 1.6rem;
  border-radius: 10px;
  backdrop-filter: blur(2px);
}
#controlsHelp b { color: #3dffe6; }

#titleCredit {
  position: absolute;
  right: 18px;
  bottom: 12px;
  z-index: 3;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.7rem;
  letter-spacing: 1px;
  color: rgba(255, 224, 240, 0.65);
  text-transform: lowercase;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

/* ------------------------------------------------------------ countdown */
#countdownScreen {
  position: fixed;
  inset: 0;
  z-index: 18;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(20, 4, 40, 0.15), rgba(5, 0, 10, 0.55));
}
#countdownScreen.show { display: flex; }

#countdownNum {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(4rem, 18vw, 10rem);
  color: #ffd23f;
  text-shadow:
    0 0 20px rgba(255, 210, 63, 0.95),
    0 0 60px rgba(255, 61, 158, 0.7),
    4px 4px 0 #2b0a3d;
  animation: countPop 0.8s ease-out;
}
#countdownNum.go {
  color: #3dffc7;
  text-shadow:
    0 0 24px rgba(61, 255, 199, 1),
    0 0 70px rgba(61, 216, 255, 0.8),
    4px 4px 0 #2b0a3d;
}
@keyframes countPop {
  0% { transform: scale(0.3); opacity: 0; }
  35% { transform: scale(1.15); opacity: 1; }
  55% { transform: scale(1); }
  100% { transform: scale(1); opacity: 1; }
}

/* ---------------------------------------------------------------- pause */
#pauseScreen {
  position: fixed;
  inset: 0;
  z-index: 21;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(8, 2, 18, 0.88);
  backdrop-filter: blur(3px);
}
#pauseScreen.show { display: flex; }

#pauseContent {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1rem;
  max-width: 640px;
}

#pauseTitle {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(1.6rem, 5vw, 2.6rem);
  color: #ffd23f;
  letter-spacing: 4px;
  margin: 0 0 1.4rem;
  text-shadow: 0 0 16px rgba(255, 210, 63, 0.8), 0 0 40px rgba(255, 61, 158, 0.5);
}

#pauseHelp {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.85rem;
  line-height: 2.1;
  color: #ffe0f0;
  background: rgba(10, 2, 20, 0.5);
  border: 1px solid rgba(107, 216, 255, 0.4);
  border-radius: 10px;
  padding: 1.2rem 1.8rem;
  text-align: left;
}
#pauseHelp b { color: #3dffe6; display: inline-block; min-width: 92px; }
.pauseDesc { color: rgba(255, 224, 240, 0.65); font-size: 0.78rem; margin-left: 6px; }

#pauseResume {
  margin-top: 1.6rem;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.85rem;
  letter-spacing: 1px;
  color: #3dffc7;
  text-shadow: 0 0 10px rgba(61, 255, 199, 0.8);
  animation: titlePulse 1.3s ease-in-out infinite;
}
#pauseResume kbd {
  font-family: inherit;
  background: rgba(255, 210, 63, 0.15);
  border: 1px solid #ffd23f;
  color: #ffd23f;
  padding: 2px 6px;
  border-radius: 3px;
}

#pauseCredit {
  position: absolute;
  right: 18px;
  bottom: 12px;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.7rem;
  letter-spacing: 1px;
  color: rgba(255, 224, 240, 0.5);
  text-transform: lowercase;
}

/* --------------------------------------------------------------- HUD */
#hud {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  color: #fff;
  font-weight: bold;
  text-shadow: 2px 2px 3px rgba(0,0,0,0.7);
}

#speedo {
  position: absolute;
  right: 24px;
  bottom: 24px;
  text-align: right;
  font-family: 'Orbitron', sans-serif;
}
#speedVal {
  font-family: 'Press Start 2P', monospace;
  font-size: 2.6rem;
  line-height: 1;
  color: #ffd23f;
  text-shadow: 0 0 10px rgba(255, 210, 63, 0.8), 2px 2px 3px rgba(0,0,0,0.7);
}
#speedUnit {
  font-size: 0.85rem;
  letter-spacing: 3px;
  opacity: 0.85;
}

#boosterHud {
  position: absolute;
  right: 24px;
  bottom: 92px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Press Start 2P', monospace;
}
#boosterPips {
  display: inline-flex;
  gap: 5px;
}
#boosterPips .pip {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #3dffc7;
  box-shadow: 0 0 8px rgba(61, 255, 199, 0.9);
}
#boosterPips .pip.spent {
  background: rgba(255, 255, 255, 0.12);
  box-shadow: none;
}
#boosterLabel {
  font-size: 0.6rem;
  letter-spacing: 2px;
  color: #3dffc7;
  opacity: 0.85;
}

#statusBadge {
  position: absolute;
  left: 24px;
  top: 24px;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.75rem;
  letter-spacing: 2px;
  padding: 8px 14px;
  border-radius: 6px;
  background: rgba(10, 2, 20, 0.5);
  border: 1px solid rgba(61, 255, 199, 0.5);
  color: #3dffc7;
  transition: opacity 0.2s;
  opacity: 0;
}
#statusBadge.show { opacity: 1; }
#statusBadge.air { color: #6bd8ff; border-color: rgba(107, 216, 255, 0.6); }

#crashBanner {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%) scale(0.8);
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(1.6rem, 5vw, 3.2rem);
  color: #ff3d3d;
  letter-spacing: 4px;
  text-shadow: 4px 4px 0 #2b0a3d, 0 0 40px rgba(255,61,61,0.9);
  opacity: 0;
  transition: opacity 0.15s, transform 0.15s;
}
#crashBanner.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

#replayBadge {
  position: absolute;
  left: 24px;
  bottom: 24px;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.7rem;
  letter-spacing: 3px;
  color: #ff3d6b;
  opacity: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
#replayBadge.show { opacity: 1; }
#replayBadge::before {
  content: '';
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ff3d6b;
  animation: blink 1s infinite;
}
@keyframes blink { 50% { opacity: 0.2; } }

/* ---------------------------------------------------------- audio panel */
#audioPanel {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(10, 2, 20, 0.55);
  border: 1px solid rgba(107, 216, 255, 0.45);
  border-radius: 24px;
  padding: 8px 14px;
  backdrop-filter: blur(3px);
  box-shadow: 0 0 10px rgba(107, 216, 255, 0.25);
}
#muteBtn {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}
#volumeSlider {
  width: 100px;
  accent-color: #3dffe6;
  cursor: pointer;
}

.hidden { display: none !important; }
