:root {
  --neon: #00f0ff;
  --magenta: #ff00cc;
  --danger: #ff2d55;
  --bg: #06001a;
  --text: #eaf6ff;
  --text-dim: #9db4cc;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
}

#renderer {
  position: fixed;
  inset: 0;
  z-index: 1;
  touch-action: none;
}
#renderer canvas { display: block; }

.hidden { display: none !important; }

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

#hud-score {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Courier New', monospace;
  font-weight: 700;
  font-size: clamp(36px, 7vw, 64px);
  color: var(--neon);
  text-shadow: 0 0 18px rgba(0, 240, 255, 0.7);
  letter-spacing: 2px;
  line-height: 1;
}
#hud-score .unit {
  font-size: 0.4em;
  color: var(--text-dim);
  margin-left: 4px;
}

#hud-speed {
  position: absolute;
  top: max(20px, env(safe-area-inset-top));
  right: 70px;
  width: clamp(80px, 16vw, 160px);
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(0, 240, 255, 0.25);
  border-radius: 4px;
  overflow: hidden;
}
#hud-speed-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--neon), var(--magenta));
  box-shadow: 0 0 10px var(--neon);
  transition: width 0.15s linear;
}

#btn-pause {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: 14px;
  width: 42px;
  height: 42px;
  pointer-events: auto;
  background: rgba(20, 20, 50, 0.6);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(0, 240, 255, 0.35);
  border-radius: 10px;
  color: var(--neon);
  font-size: 14px;
  cursor: pointer;
}

/* ---------- Touch-Hinweis ---------- */
#touch-hint {
  position: fixed;
  inset: 0;
  z-index: 9;
  display: flex;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.6s;
}
#touch-hint.fade { opacity: 0; }
#touch-hint .zone {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 56px;
  color: rgba(0, 240, 255, 0.35);
}
#touch-hint .zone:first-child { background: linear-gradient(90deg, rgba(0,240,255,0.08), transparent); }
#touch-hint .zone:last-child  { background: linear-gradient(270deg, rgba(255,0,204,0.08), transparent); }

/* ---------- Crash-Blitz ---------- */
#flash {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease-out;
}
#flash.on { opacity: 0.75; transition: none; }

/* ---------- Overlays / Panels ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(ellipse at center, rgba(6, 0, 26, 0.55) 0%, rgba(6, 0, 26, 0.9) 100%);
}

.panel {
  width: min(440px, 92vw);
  max-height: 92vh;
  overflow-y: auto;
  text-align: center;
  padding: 32px 28px;
  background: rgba(14, 10, 40, 0.65);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(0, 240, 255, 0.25);
  border-radius: 18px;
  box-shadow: 0 0 50px rgba(0, 240, 255, 0.12), inset 0 0 30px rgba(0, 0, 60, 0.4);
}

.title {
  margin: 0 0 8px;
  font-size: clamp(40px, 9vw, 64px);
  font-weight: 900;
  letter-spacing: 6px;
  line-height: 1.05;
  background: linear-gradient(135deg, var(--neon) 0%, #4a8cff 50%, var(--magenta) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 14px rgba(0, 240, 255, 0.45));
}
.title.small { font-size: clamp(30px, 6vw, 44px); }

.tagline {
  color: var(--text-dim);
  margin: 0 0 22px;
  font-size: 15px;
}

.stats {
  display: flex;
  justify-content: center;
  gap: 36px;
  margin: 18px 0 22px;
}
.stats .num {
  font-family: 'Courier New', monospace;
  font-size: 34px;
  font-weight: 700;
  color: var(--neon);
  text-shadow: 0 0 12px rgba(0, 240, 255, 0.6);
}
.stats .label {
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-top: 2px;
}

.record {
  display: inline-block;
  margin-bottom: 12px;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #1a1200;
  background: linear-gradient(90deg, #ffd34d, #ff9d2e);
  box-shadow: 0 0 22px rgba(255, 200, 60, 0.7);
  animation: recordPop 0.5s ease-out, recordGlow 1.4s ease-in-out infinite alternate 0.5s;
}
@keyframes recordPop { 0% { transform: scale(0.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes recordGlow { from { box-shadow: 0 0 14px rgba(255, 200, 60, 0.5); } to { box-shadow: 0 0 32px rgba(255, 200, 60, 0.95); } }

.controls-hint {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 24px;
  font-size: 13px;
  color: var(--text-dim);
}
.controls-hint b { color: var(--text); }
.touch-only { display: none; }
@media (pointer: coarse) { .touch-only { display: block; } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  border: none;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  font-weight: 700;
  border-radius: 26px;
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(1px); }

.btn.primary {
  padding: 16px 52px;
  font-size: 20px;
  letter-spacing: 3px;
  color: #fff;
  background: linear-gradient(135deg, #00c2ff 0%, #2456ff 55%, var(--magenta) 100%);
  box-shadow: 0 0 24px rgba(0, 180, 255, 0.45);
}

.btn.ghost {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(0, 240, 255, 0.2);
}
.btn.ghost:hover { color: var(--text); border-color: rgba(0, 240, 255, 0.5); }

.row {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.pulse { animation: pulse 2s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(0, 240, 255, 0.6); }
  70% { box-shadow: 0 0 0 16px rgba(0, 240, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 240, 255, 0); }
}

/* ---------- Settings ---------- */
.setting-rows {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 8px 0 22px;
  text-align: left;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 4px;
  border-bottom: 1px solid rgba(0, 240, 255, 0.12);
}
.setting-row:last-child { border-bottom: none; }

.setting-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.setting-label small {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-dim);
}

.setting-control { display: flex; align-items: center; gap: 12px; }

/* Segment-Buttons (Grafik) */
.segment {
  display: flex;
  border: 1px solid rgba(0, 240, 255, 0.3);
  border-radius: 10px;
  overflow: hidden;
}
.segment button {
  padding: 7px 13px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-dim);
  background: transparent;
  border: none;
  cursor: pointer;
}
.segment button + button { border-left: 1px solid rgba(0, 240, 255, 0.2); }
.segment button.active {
  color: #021018;
  background: var(--neon);
  text-shadow: none;
}

/* Toggle-Switch */
.toggle { position: relative; display: inline-block; width: 46px; height: 24px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .knob {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(0, 240, 255, 0.25);
  cursor: pointer;
  transition: background 0.2s;
}
.toggle .knob::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 3px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform 0.2s, background 0.2s;
}
.toggle input:checked + .knob { background: rgba(0, 240, 255, 0.35); }
.toggle input:checked + .knob::after {
  transform: translateX(21px);
  background: var(--neon);
  box-shadow: 0 0 8px var(--neon);
}

/* Range-Slider */
input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 110px;
  height: 5px;
  border-radius: 3px;
  background: rgba(0, 240, 255, 0.25);
  outline: none;
  cursor: pointer;
}
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--neon);
  box-shadow: 0 0 8px var(--neon);
  border: none;
}
input[type='range']::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--neon);
  box-shadow: 0 0 8px var(--neon);
  border: none;
}
input[type='range']:disabled { opacity: 0.35; cursor: default; }

.btn.ghost.danger {
  color: #ffb4c0;
  border-color: rgba(255, 45, 85, 0.5);
}
.btn.ghost.danger:hover { color: #fff; border-color: var(--danger); }

/* ---------- FPS-Anzeige ---------- */
#hud-fps {
  position: absolute;
  top: max(64px, calc(env(safe-area-inset-top) + 52px));
  left: 14px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  color: var(--text-dim);
  background: rgba(10, 10, 35, 0.5);
  padding: 3px 8px;
  border-radius: 6px;
}

/* ---------- Power-up-Status ---------- */
#powerup-status {
  position: absolute;
  top: max(76px, calc(env(safe-area-inset-top) + 64px));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
}
.pu-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 14px;
  background: rgba(14, 10, 40, 0.65);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(0, 240, 255, 0.3);
  animation: puPop 0.25s ease-out;
}
@keyframes puPop { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.pu-icon { font-size: 13px; font-weight: 700; color: var(--neon); }
#pu-slow .pu-icon { color: #c9a6ff; }
#pu-multi .pu-icon { color: #ffd34d; }
.pu-bar {
  width: 40px;
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
.pu-bar span {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--neon);
  border-radius: 3px;
}
#pu-slow-fill { background: #c9a6ff; }
#pu-multi-fill { background: #ffd34d; }

/* ---------- Meilenstein-Toast ---------- */
#milestone-toast {
  position: absolute;
  top: 22%;
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(22px, 4vw, 34px);
  font-weight: 800;
  letter-spacing: 3px;
  color: var(--neon);
  text-shadow: 0 0 22px rgba(0, 240, 255, 0.8);
  pointer-events: none;
}
#milestone-toast.show {
  animation: milestonePop 1.6s ease-out forwards;
}
@keyframes milestonePop {
  0% { opacity: 0; transform: translateX(-50%) scale(0.5); }
  15% { opacity: 1; transform: translateX(-50%) scale(1.15); }
  25% { transform: translateX(-50%) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) scale(1) translateY(-18px); }
}
