/* ============================================================
   CYBER RIDER 3D — neon hoverbike runner UI
   Vanilla CSS · synthwave HUD · responsive · touch-ready
   ============================================================ */

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

:root {
  --accent: #ff2bd6;
  --accent2: #00fff0;
  --accent3: #8b2bff;
  --gold: #ffe14d;
  --danger: #ff3b5c;
  --ok: #4dffb0;
  --font: "Courier New", ui-monospace, Menlo, Consolas, monospace;
}

html, body {
  height: 100%;
  background: #05020c;
  color: #eef0ff;
  font-family: var(--font);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none; -webkit-user-select: none;
  touch-action: none;
}

.game-wrap {
  position: fixed;
  inset: 0;
  width: 100%; height: 100%;
  overflow: hidden;
}

#scene { display: block; width: 100%; height: 100%; touch-action: none; }

/* ---------- FX overlays ---------- */
.fx-speedlines {
  position: absolute; inset: 0; z-index: 3; pointer-events: none; opacity: 0;
  background:
    repeating-linear-gradient(90deg, transparent 0 6px, rgba(255,43,214,0.08) 6px 7px),
    radial-gradient(ellipse at center, transparent 30%, rgba(0,255,240,0.14) 100%);
  transition: opacity .2s ease;
  mix-blend-mode: screen;
}
.fx-speedlines.on { opacity: 1; animation: zoomlines .22s linear infinite; }
@keyframes zoomlines { from { background-size: 100% 100%, 120% 120%; } to { background-size: 100% 100%, 100% 100%; } }

.fx-flash {
  position: absolute; inset: 0; z-index: 4; pointer-events: none; opacity: 0;
  background: radial-gradient(circle, rgba(255,59,92,0.55), transparent 70%);
}
.fx-flash.on { animation: flash .35s ease-out; }
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }

.fx-scanlines {
  position: absolute; inset: 0; z-index: 2; pointer-events: none; opacity: 0.1;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,0.6) 0 1px, transparent 1px 3px);
  mix-blend-mode: overlay;
}

/* ---------- HUD ---------- */
.hud {
  position: absolute; inset: 0; z-index: 5; pointer-events: none;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 12px clamp(10px, 3vw, 26px);
  text-shadow: 0 0 8px rgba(255,43,214,0.5);
}
.hud.hidden { display: none; }
.hud-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.hud-mid { flex: 1; align-items: flex-start; justify-content: flex-end; }
.hud-bottom { align-items: flex-end; }

.hud-box { display: flex; flex-direction: column; gap: 2px; background: rgba(10,3,24,0.4); border: 1px solid rgba(0,255,240,0.3); border-radius: 10px; padding: 6px 12px; backdrop-filter: blur(3px); }
.hud-box.center { align-items: center; }
.hud-box.right { align-items: flex-end; }
.hud-box b { font-size: clamp(15px, 2.6vw, 22px); color: #fff; }
.hud-box .lbl { font-size: clamp(8px, 1.5vw, 11px); color: #c9a9ff; letter-spacing: 1px; }
.hud-box .lbl.best { color: var(--gold); }
.hud-box .lbl i, .hud-box .lbl b { font-style: normal; }
#distVal { font-size: clamp(20px, 4vw, 34px); color: var(--accent2); }
#distVal small { font-size: 0.5em; color: #c9a9ff; }

.icon-btn {
  pointer-events: auto;
  background: rgba(139,43,255,0.2); border: 1px solid rgba(0,255,240,0.4);
  color: #fff; border-radius: 8px; width: 38px; height: 34px; font-size: 15px; cursor: pointer;
  margin-left: 8px; transition: background .2s, transform .1s;
}
.icon-btn:hover { background: rgba(0,255,240,0.3); }
.icon-btn:active { transform: scale(0.92); }

#livesVal { font-size: clamp(14px, 2.6vw, 20px); color: var(--danger); letter-spacing: 2px; }

.speedo { display: flex; flex-direction: column; align-items: center; }
.speedo b { font-size: clamp(24px, 5vw, 44px); color: #fff; line-height: 1; text-shadow: 0 0 12px var(--accent2); }
.speedo .lbl { font-size: clamp(8px,1.5vw,11px); color: #c9a9ff; letter-spacing: 2px; }

.boost-box { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; min-width: 110px; }
.boost-box .lbl { font-size: clamp(8px,1.5vw,11px); color: var(--gold); letter-spacing: 2px; }
.boost-track { width: clamp(90px, 22vw, 160px); height: 12px; background: rgba(255,255,255,0.12); border: 1px solid rgba(255,225,77,0.5); border-radius: 6px; overflow: hidden; }
.boost-fill { height: 100%; width: 100%; background: linear-gradient(90deg, var(--accent3), var(--gold)); transition: width .1s linear; }

/* ---------- Countdown ---------- */
.countdown {
  position: absolute; inset: 0; z-index: 9; display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.countdown.hidden { display: none; }
.countdown span {
  font-size: clamp(70px, 22vw, 180px); font-weight: 800; color: #fff;
  text-shadow: 0 0 24px var(--accent2), 0 0 60px var(--accent3);
  animation: countPop .8s ease-out;
}
@keyframes countPop { from { transform: scale(2.2); opacity: 0; } 40% { opacity: 1; } to { transform: scale(1); opacity: 0.15; } }

/* ---------- Overlays / panels ---------- */
.overlay {
  position: absolute; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background: rgba(5,2,12,0.82); backdrop-filter: blur(4px); padding: 16px;
}
.overlay.hidden { display: none; }
.panel {
  text-align: center; padding: clamp(20px, 4vw, 40px); width: 100%; max-width: 460px;
  border: 2px solid rgba(0,255,240,0.35); border-radius: 18px;
  background: linear-gradient(160deg, rgba(139,43,255,0.16), rgba(255,43,214,0.08));
  box-shadow: 0 0 48px rgba(255,43,214,0.25);
}
.title { font-size: clamp(30px, 8vw, 56px); font-weight: 800; letter-spacing: 3px; color: #fff; text-shadow: 0 0 14px var(--accent2), 0 0 34px var(--accent); animation: flicker 4s infinite; }
.title.small { font-size: clamp(22px, 6vw, 38px); }
@keyframes flicker { 0%,92%,100%{opacity:1} 93%{opacity:.7} 95%{opacity:1} 97%{opacity:.8} }
.tagline { margin: 10px 0 20px; color: #c9a9ff; font-size: clamp(12px, 2.6vw, 16px); letter-spacing: 1px; }

.menu-btns { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.btn {
  pointer-events: auto; padding: 13px 22px; font-family: var(--font); font-weight: 700;
  font-size: clamp(13px, 2.4vw, 16px); letter-spacing: 1.5px; color: #fff;
  background: rgba(255,255,255,0.06); border: 2px solid rgba(0,255,240,0.5); border-radius: 12px;
  cursor: pointer; transition: transform .12s, box-shadow .2s, background .2s;
}
.btn:hover { background: rgba(0,255,240,0.15); box-shadow: 0 0 18px rgba(0,255,240,.35); }
.btn:active { transform: scale(0.96); }
.btn.primary { background: linear-gradient(135deg, var(--accent3), var(--accent)); border-color: transparent; box-shadow: 0 6px 20px rgba(255,43,214,.5); }
.btn.ghost { border-color: rgba(201,169,255,0.35); color: #e3d9ff; font-size: clamp(12px,2.2vw,14px); padding: 10px 18px; }
.hint { margin-top: 12px; font-size: 11px; color: #8b7fb5; line-height: 1.6; }

.help-list { text-align: left; list-style: none; display: flex; flex-direction: column; gap: 10px; margin: 10px 0 20px; font-size: clamp(12px, 2.2vw, 14px); color: #e3d9ff; line-height: 1.5; }

.result { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0 18px; }
.result div { background: rgba(255,255,255,0.05); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 3px; }
.result span { font-size: 10px; color: #c9a9ff; letter-spacing: 1px; }
.result b { font-size: clamp(15px,3vw,20px); color: var(--gold); }
.new-high { color: var(--gold); letter-spacing: 2px; margin-bottom: 6px; animation: flicker 1.1s infinite; }
#overScreen .btn, #pauseScreen .btn, #menuScreen .btn { width: 100%; }
#overScreen .btn + .btn, #pauseScreen .btn + .btn { margin-top: 8px; }

.scores-list { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 18px; }
.scores-list .row { display: flex; justify-content: space-between; background: rgba(255,255,255,0.05); padding: 9px 12px; border-radius: 8px; font-size: clamp(11px,2.2vw,14px); }
.scores-list .row span { color: #c9a9ff; }
.scores-list .row b { color: #fff; }

/* ---------- Touch controls ---------- */
.touch {
  position: absolute; inset: auto 0 0 0; z-index: 8;
  display: none; justify-content: space-between; align-items: flex-end;
  padding: 16px clamp(14px, 4vw, 34px) calc(16px + env(safe-area-inset-bottom));
  pointer-events: none;
}
.touch-left { display: none !important; }
.touch-right { display: flex; align-items: center; gap: 12px; pointer-events: none; margin-left: auto; }
.tbtn {
  pointer-events: auto;
  width: 62px; height: 62px; border-radius: 16px;
  background: rgba(139,43,255,0.3); border: 1px solid rgba(0,255,240,0.5);
  color: #fff; font-size: 22px; display: flex; align-items: center; justify-content: center;
  touch-action: none; transition: background .1s, transform .05s;
}
.tbtn:active, .tbtn.active { background: rgba(0,255,240,0.5); transform: scale(0.92); }
.tbtn.nitro {
  width: 78px; height: 78px; border-radius: 50%; font-size: 13px; font-weight: 800; letter-spacing: 1px;
  background: radial-gradient(circle at 40% 35%, rgba(255,225,77,.75), rgba(139,43,255,.55));
  border: 2px solid rgba(255,225,77,0.7); opacity: 0.92;
}
@media (hover: none) and (pointer: coarse) { .touch { display: flex; } }
body.touch-mode .touch { display: flex; }

.back-home {
  position: absolute; left: 10px; top: 8px; z-index: 6;
  font-size: 11px; color: #a393d9; text-decoration: none;
  background: rgba(0,0,0,.3); padding: 4px 8px; border-radius: 6px;
}
.back-home:hover { color: var(--accent2); }
@media (max-width: 620px) { .back-home { top: auto; bottom: 8px; left: 50%; transform: translateX(-50%); z-index: 2; } }
