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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #000;
  font-family: 'Segoe UI', Arial, sans-serif;
}

#sky-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  z-index: 1;
  pointer-events: none;
}

#canvas-wrap {
  position: absolute; inset: 0;
  z-index: 2;
}
#canvas-wrap canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  background: transparent;
}

/* ── Loading ── */
#loading {
  position: absolute; inset: 0; z-index: 200;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: #000;
  transition: opacity 0.6s;
}
.loading-title {
  font-size: 4vw; font-weight: 900;
  letter-spacing: 0.4em;
  color: #ff6600;
  text-shadow: 0 0 40px #ff6600, 0 0 80px #ff4400;
  animation: throb 0.8s ease-in-out infinite alternate;
}
.loading-sub {
  margin-top: 1.2rem;
  font-size: 0.9vw; letter-spacing: 0.25em; color: #666;
}

/* ── Start screen ── */
#start-screen {
  position: absolute; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 60%, rgba(20,0,50,0.96) 0%, rgba(0,0,0,0.98) 100%);
  transition: opacity 0.5s;
}
.start-inner { text-align: center; }
.start-title {
  font-size: 8vw; font-weight: 900;
  letter-spacing: 0.35em;
  background: linear-gradient(160deg, #fff 0%, #ffcc00 40%, #ff6600 70%, #ff0088 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 40px rgba(255,120,0,0.7));
  line-height: 1;
}
.start-sub {
  margin: 1rem 0 2.5rem;
  font-size: 1.1vw; color: #888; letter-spacing: 0.12em;
}
.mode-buttons {
  display: flex;
  gap: 1.8vw;
  justify-content: center;
  margin-bottom: 0.5rem;
}

.mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.9rem 3.2vw; font-size: 1.2vw;
  font-weight: 800; letter-spacing: 0.22em;
  color: #fff;
  background: linear-gradient(135deg, #ff6600 0%, #ff0088 100%);
  border: none; border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 0 30px rgba(255,80,0,0.5), 0 0 60px rgba(255,0,120,0.3);
  transition: transform 0.1s, box-shadow 0.2s;
  line-height: 1.1;
}
.mode-btn:hover {
  transform: scale(1.06);
  box-shadow: 0 0 50px rgba(255,80,0,0.8), 0 0 100px rgba(255,0,120,0.5);
}
.mode-btn:active { transform: scale(0.97); }
.mode-btn-inf {
  background: linear-gradient(135deg, #0088ff 0%, #00ffcc 100%);
  box-shadow: 0 0 30px rgba(0,160,255,0.5), 0 0 60px rgba(0,255,200,0.3);
}
.mode-btn-inf:hover {
  box-shadow: 0 0 50px rgba(0,160,255,0.8), 0 0 100px rgba(0,255,200,0.5);
}
.mode-desc {
  font-size: 0.65vw;
  font-weight: 400;
  letter-spacing: 0.12em;
  color: rgba(255,255,255,0.7);
  margin-top: 0.3rem;
  text-transform: none;
}
.start-hint {
  margin-top: 1.2rem;
  font-size: 0.75vw; color: #444; letter-spacing: 0.15em;
}

/* ── HUD ── */
#hud {
  position: absolute; inset: 0; pointer-events: none; z-index: 50;
}
#hud.hidden { display: none; }

#speed-panel {
  position: absolute; bottom: 2.5rem; right: 2.5rem;
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 0.7rem 1.2rem;
  text-align: center; color: #fff;
}
.hud-label { display: block; font-size: 0.55rem; letter-spacing: 0.25em; color: #777; margin-bottom: 0.1rem; }
#speed-val { font-size: 2.6rem; font-weight: 700; color: #00ffcc; line-height: 1; text-shadow: 0 0 15px #00ffcc; }
.hud-unit { display: block; font-size: 0.6rem; color: #666; margin-top: 0.1rem; }

#gforce-panel {
  position: absolute; bottom: 2.5rem; left: 2.5rem;
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 0.5rem 1rem;
  font-size: 0.85rem; color: #ccc;
}
#g-val { color: #ff9900; font-weight: 700; }

#zone-label {
  position: absolute; top: 1.8rem; left: 50%;
  transform: translateX(-50%);
  font-size: 0.7vw; letter-spacing: 0.35em;
  color: rgba(255,255,255,0.5); text-transform: uppercase;
  text-shadow: 0 0 10px rgba(255,255,255,0.3);
}

#event-banner {
  position: absolute; top: 22%; left: 50%;
  transform: translateX(-50%);
  font-size: 4.5vw; font-weight: 900;
  letter-spacing: 0.15em; white-space: nowrap;
  text-shadow: 0 0 40px currentColor, 0 0 80px currentColor;
  animation: bannerPop 0.15s cubic-bezier(0.2,1.4,0.5,1);
  pointer-events: none;
}
#event-banner.hidden { display: none; }

#progress-bar {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 3px; background: rgba(255,255,255,0.08);
}
#progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #ff6600, #ff00cc, #00ccff);
  box-shadow: 0 0 6px rgba(255,100,200,0.6);
  transition: width 0.15s linear;
  width: 0%;
}

/* ── Infinite distance counter ── */
#inf-distance {
  position: absolute; bottom: 0; left: 0; right: 0;
  text-align: center;
  font-size: 0.62rem; color: rgba(255,255,255,0.4);
  letter-spacing: 0.25em; padding: 0.35rem 0;
  background: rgba(0,0,0,0.25);
}
#inf-distance.hidden { display: none; }

/* ── Camera swing controls ── */
#cam-swing-wrap {
  position: absolute; top: 1.4rem; right: 2.5rem;
  display: flex; flex-direction: column; align-items: center; gap: 0.35rem;
  pointer-events: auto;
}
#cam-swing-btn {
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  padding: 0.35rem 0.8rem;
  font-size: 0.6rem; font-weight: 700;
  letter-spacing: 0.18em; color: rgba(255,255,255,0.45);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, box-shadow 0.2s;
  text-transform: uppercase;
  width: 100%;
}
#cam-swing-btn:hover {
  color: rgba(255,255,255,0.75);
  border-color: rgba(255,255,255,0.4);
}
#cam-swing-btn.active {
  color: #00ffcc;
  border-color: #00ffcc;
  box-shadow: 0 0 10px rgba(0,255,204,0.35);
}
#swing-speed-row {
  display: flex; align-items: center; gap: 0.3rem;
}
.swing-speed-label {
  font-size: 0.5rem; font-weight: 700; letter-spacing: 0.1em;
  color: rgba(255,255,255,0.35); text-transform: uppercase;
  white-space: nowrap;
}
#swing-speed-slider {
  -webkit-appearance: none; appearance: none;
  width: 6rem; height: 3px;
  border-radius: 2px;
  background: rgba(255,255,255,0.15);
  outline: none; cursor: pointer;
}
#swing-speed-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px; border-radius: 50%;
  background: rgba(255,255,255,0.5);
  border: none; cursor: pointer;
  transition: background 0.15s;
}
#swing-speed-slider::-webkit-slider-thumb:hover {
  background: #00ffcc;
}
#swing-speed-slider::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%;
  background: rgba(255,255,255,0.5);
  border: none; cursor: pointer;
}
#debug-box-btn {
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  padding: 0.35rem 0.8rem;
  font-size: 0.6rem; font-weight: 700;
  letter-spacing: 0.18em; color: rgba(255,255,255,0.35);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, box-shadow 0.2s;
  text-transform: uppercase;
  width: 100%;
}
#debug-box-btn:hover {
  color: rgba(255,80,0,0.85);
  border-color: rgba(255,80,0,0.5);
}
#debug-box-btn.active {
  color: #ff3300;
  border-color: #ff3300;
  box-shadow: 0 0 10px rgba(255,51,0,0.45);
}

/* ── Overlays ── */
#screen-flash {
  position: absolute; inset: 0; z-index: 60;
  pointer-events: none; opacity: 0;
  background: #fff;
  transition: opacity 0.05s;
}
#speed-vignette {
  position: absolute; inset: 0; z-index: 44;
  pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at 50% 50%,
    transparent 26%, rgba(0,0,0,0.28) 56%,
    rgba(0,5,25,0.68) 78%, rgba(0,0,20,0.90) 100%);
  transition: opacity 0.3s;
}

#gforce-fx {
  position: absolute; inset: 0; z-index: 47;
  pointer-events: none; opacity: 0;
}

#edge-blur {
  position: absolute; inset: 0; z-index: 45;
  pointer-events: none; opacity: 0;
  transition: opacity 0.1s;
  -webkit-mask-image: radial-gradient(ellipse 52% 52% at 50% 50%, transparent 48%, black 78%);
  mask-image: radial-gradient(ellipse 52% 52% at 50% 50%, transparent 48%, black 78%);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
}

#speed-lines {
  position: absolute; inset: 0; z-index: 46;
  pointer-events: none; opacity: 0;
}

@keyframes throb {
  from { text-shadow: 0 0 20px #ff6600, 0 0 40px #ff4400; }
  to   { text-shadow: 0 0 50px #ff8800, 0 0 100px #ff6600; }
}
@keyframes bannerPop {
  0%   { transform: translateX(-50%) scale(1.4); opacity: 0; }
  100% { transform: translateX(-50%) scale(1);   opacity: 1; }
}
