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

body {
  background: #000;
  overflow: hidden;
  font-family: 'Segoe UI', 'Arial', sans-serif;
  color: #fff;
}

#renderCanvas {
  width: 100vw;
  height: 100vh;
  display: block;
  touch-action: none;
}

/* ── Overlays ── */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
}

.overlay.hidden {
  display: none;
}

/* ── Start Screen ── */
#startScreen h1 {
  font-size: clamp(2.4rem, 7vw, 5rem);
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: linear-gradient(135deg, #00e5ff 0%, #ffd700 60%, #ff6b35 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  margin-bottom: 0.3em;
  animation: titlePulse 3s ease-in-out infinite;
}

@keyframes titlePulse {
  0%, 100% { filter: brightness(1); }
  50%       { filter: brightness(1.25); }
}

#startScreen .subtitle {
  font-size: clamp(0.9rem, 2.5vw, 1.2rem);
  color: #aaa;
  margin-bottom: 0.5em;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

#startScreen .version {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.3);
  letter-spacing: 0.15em;
  margin-bottom: 2em;
  font-family: 'Courier New', monospace;
}

.controls-hint {
  margin-top: 2em;
  font-size: 0.85rem;
  color: #666;
  text-align: center;
  line-height: 1.9;
  letter-spacing: 0.05em;
}

.controls-hint span {
  color: #00e5ff;
}

/* ── End Screen ── */
#endScreen h2 {
  font-size: clamp(1.8rem, 5vw, 3.2rem);
  font-weight: 800;
  text-transform: uppercase;
  color: #ffd700;
  margin-bottom: 0.5em;
  letter-spacing: 0.08em;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2em 3em;
  margin: 1.5em 0 2.5em;
  text-align: center;
}

.result-item label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: #888;
  margin-bottom: 0.3em;
}

.result-item .value {
  font-size: 2rem;
  font-weight: 700;
  color: #00e5ff;
}

/* ── Crash Screen ── */
#crashScreen h2 {
  font-size: clamp(1.8rem, 5vw, 3rem);
  font-weight: 800;
  color: #ff4444;
  text-transform: uppercase;
  margin-bottom: 0.5em;
  letter-spacing: 0.08em;
}

#crashScreen p {
  color: #aaa;
  margin-bottom: 2em;
  font-size: 1rem;
}

/* ── Buttons ── */
.btn {
  padding: 0.85em 2.8em;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
  position: relative;
  overflow: hidden;
}

.btn-primary {
  background: linear-gradient(135deg, #00b4cc, #0077ff);
  color: #fff;
  box-shadow: 0 0 24px rgba(0, 180, 255, 0.5);
}

.btn-primary:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 0 36px rgba(0, 200, 255, 0.7);
  filter: brightness(1.15);
}

.btn-danger {
  background: linear-gradient(135deg, #cc3300, #ff5500);
  color: #fff;
  box-shadow: 0 0 24px rgba(255, 80, 0, 0.4);
}

.btn-danger:hover {
  transform: translateY(-2px) scale(1.03);
  filter: brightness(1.15);
}

/* ── HUD ── */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

#hud.hidden { display: none; }

.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 18px 24px;
}

.hud-panel {
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px 18px;
  min-width: 120px;
  text-align: center;
  backdrop-filter: blur(6px);
}

.hud-panel label {
  display: block;
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #777;
  margin-bottom: 3px;
}

.hud-panel .val {
  font-size: 1.45rem;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}

#scoreVal  { color: #ffd700; }
#timerVal  { color: #00e5ff; }
#speedVal  { color: #90ff90; }

/* speed bar */
.speed-bar-wrap {
  margin-top: 5px;
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  overflow: hidden;
}
#speedBar {
  height: 100%;
  width: 50%;
  background: linear-gradient(90deg, #00cc44, #90ff90);
  border-radius: 2px;
  transition: width 0.1s linear;
}

/* ── Ring counter ── */
#ringCounter {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 7px;
  z-index: 5;
  pointer-events: none;
}

.ring-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  border: 1.5px solid rgba(0, 229, 255, 0.35);
  transition: background 0.25s, box-shadow 0.25s;
}

.ring-dot.collected {
  background: #00e5ff;
  box-shadow: 0 0 8px #00e5ff;
}

/* ── Altitude warning ── */
#altWarning {
  position: fixed;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 20px;
  background: rgba(255, 60, 0, 0.75);
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  z-index: 6;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

#altWarning.show { opacity: 1; }

/* ── Perf bar ── */
#perfBar {
  position: fixed;
  bottom: 10px;
  right: 12px;
  display: block;
  gap: 10px;
  z-index: 20;
  pointer-events: none;
}

#perfBar span {
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 5px;
  padding: 3px 8px;
  font-size: 0.72rem;
  font-family: 'Courier New', monospace;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #aef;
}

#perfFps  { color: #7fff7f; }
#perfPing { color: #ffd070; }
#perfEngine { color: #70cfff; text-transform: uppercase; }

/* ── Mobile touch areas (visual hint) ── */
@media (pointer: coarse) {
  .controls-hint .desktop { display: none; }
}

/* ── Params panel ── */
#paramsPanel {
  position: fixed;
  top: 10px;
  right: 12px;
  z-index: 9999;
  font-family: 'Courier New', monospace;
}

#paramsToggle {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: rgba(0,0,0,0.75);
  border: 1px solid rgba(255,255,255,0.2);
  color: #aef;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  margin-left: auto;
}
#paramsToggle:hover { background: rgba(0,100,180,0.7); }

#paramsContent {
  margin-top: 4px;
  background: rgba(0,0,0,0.85);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 10px 12px;
  min-width: 220px;
}
#paramsContent.hidden { display: none; }

.params-title {
  font-size: 0.7rem;
  color: #70cfff;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 8px;
  font-weight: 700;
}

#engineSelect {
  flex: 1;
  background: rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 4px;
  color: #7fff7f;
  font-family: 'Courier New', monospace;
  font-size: 0.68rem;
  padding: 2px 4px;
  cursor: pointer;
}
#engineSelect option:disabled { color: #555; }

#paramsContent label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.68rem;
  color: #cde;
  margin-bottom: 6px;
  white-space: nowrap;
}

#paramsContent input[type=range] {
  flex: 1;
  accent-color: #00e5ff;
  cursor: pointer;
}

.pval {
  color: #7fff7f;
  min-width: 32px;
  text-align: right;
  font-size: 0.68rem;
}

#paramsReset {
  margin-top: 6px;
  width: 100%;
  padding: 4px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 4px;
  color: #aef;
  font-size: 0.68rem;
  cursor: pointer;
  font-family: inherit;
}
#paramsReset:hover { background: rgba(255,100,100,0.25); }
