/* ===========================================================
   NEON DRIVE — Synthwave UI
   =========================================================== */

:root {
  --neon-pink: #ff2bd6;
  --neon-cyan: #00f0ff;
  --neon-purple: #b026ff;
  --neon-yellow: #ffe600;
  --bg-deep: #0b0416;
  --bg-mid: #1b0733;
  --panel: rgba(20, 6, 40, 0.72);
  --font-display: "Impact", "Haettenschweiler", "Arial Black", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-ui: "SF Mono", "Menlo", "Consolas", "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: #fff;
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #0b0416;
}

.hidden { display: none !important; }

/* ---------------- HUD ---------------- */

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  padding: 16px clamp(12px, 3vw, 40px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  z-index: 5;
}

.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.hud-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 92px;
}

.hud-center { align-items: center; }
.hud-right { align-items: flex-end; text-align: right; }

.label {
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.35);
}

.value {
  font-family: var(--font-display);
  font-size: clamp(20px, 3.4vw, 34px);
  line-height: 1;
  letter-spacing: 0.04em;
  color: #fff;
  text-shadow:
    0 0 6px rgba(0, 240, 255, 0.9),
    0 0 18px rgba(0, 240, 255, 0.55),
    0 0 38px rgba(255, 43, 214, 0.35);
}

.hud-bottom {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
}

/* 速度表 */
.dial {
  position: relative;
  width: clamp(96px, 13vw, 140px);
  aspect-ratio: 1;
  filter: drop-shadow(0 0 14px rgba(0, 240, 255, 0.35));
}

#dial-svg { width: 100%; height: 100%; overflow: visible; }

.dial-ring {
  fill: none;
  stroke: url(#dialGrad);
  stroke-width: 2;
  opacity: 0.85;
}

.dial-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 7;
  stroke-linecap: round;
}

.dial-fill {
  fill: none;
  stroke: url(#dialGrad);
  stroke-width: 7;
  stroke-linecap: round;
  filter: drop-shadow(0 0 6px rgba(255, 43, 214, 0.9));
  transition: stroke-dashoffset 0.08s linear;
}

.dial-needle {
  stroke: var(--neon-pink);
  stroke-width: 2.5;
  stroke-linecap: round;
  filter: drop-shadow(0 0 6px rgba(255, 43, 214, 1));
  transform-origin: 60px 60px;
}

.dial-hub {
  fill: #0b0416;
  stroke: var(--neon-cyan);
  stroke-width: 2;
}

.dial-num {
  fill: #fff;
  font-family: var(--font-display);
  font-size: 22px;
  text-anchor: middle;
  letter-spacing: 0.02em;
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.8);
}

.dial-unit {
  fill: rgba(255, 255, 255, 0.4);
  font-size: 8px;
  letter-spacing: 0.3em;
  text-anchor: middle;
}

.gear {
  position: absolute;
  top: -6px;
  right: -4px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 16px;
  color: #0b0416;
  background: linear-gradient(135deg, var(--neon-cyan), var(--neon-pink));
  border-radius: 8px;
  box-shadow: 0 0 16px rgba(255, 43, 214, 0.6);
}

.hud-right-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.nitro-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.nitro-bar {
  width: clamp(110px, 20vw, 200px);
  height: 12px;
  border: 1px solid rgba(0, 240, 255, 0.45);
  border-radius: 7px;
  background: rgba(0, 240, 255, 0.08);
  overflow: hidden;
  box-shadow: inset 0 0 10px rgba(0, 240, 255, 0.25);
}

.nitro-fill {
  height: 100%;
  width: 0%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-purple), var(--neon-pink));
  box-shadow: 0 0 14px rgba(255, 43, 214, 0.8);
  transition: width 0.1s linear;
}

.hint {
  font-size: 9px;
  letter-spacing: 0.22em;
  color: rgba(255, 255, 255, 0.35);
}

.lives {
  display: flex;
  gap: 6px;
}

.life {
  width: 18px;
  height: 8px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-pink));
  box-shadow: 0 0 10px rgba(255, 43, 214, 0.75);
}

.life.dead {
  background: rgba(255, 255, 255, 0.12);
  box-shadow: none;
}

/* 中央提示 / 撞击闪屏 */

.center-msg {
  position: absolute;
  left: 0;
  right: 0;
  top: 30%;
  text-align: center;
  font-family: var(--font-display);
  font-size: clamp(28px, 6vw, 64px);
  letter-spacing: 0.06em;
  color: #fff;
  text-shadow:
    0 0 10px var(--neon-cyan),
    0 0 30px var(--neon-pink),
    0 0 60px rgba(255, 43, 214, 0.6);
  opacity: 0;
  transform: scale(0.85);
}

.center-msg.show {
  animation: pop 0.9s ease-out forwards;
}

.center-msg.gold { text-shadow: 0 0 12px var(--neon-yellow), 0 0 34px rgba(255, 230, 0, 0.8); }

@keyframes pop {
  0%   { opacity: 0; transform: scale(0.6); }
  18%  { opacity: 1; transform: scale(1.08); }
  70%  { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.02); }
}

.flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at 50% 55%, rgba(255, 43, 214, 0.1), rgba(255, 0, 90, 0.55));
  mix-blend-mode: screen;
}

.flash.hit {
  animation: flashfx 0.45s ease-out;
}

@keyframes flashfx {
  0%   { opacity: 0.9; }
  100% { opacity: 0; }
}

/* ---------------- 覆盖层页面 ---------------- */

.screen {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
  text-align: center;
  background:
    radial-gradient(ellipse at 50% 120%, rgba(255, 43, 214, 0.28), transparent 62%),
    radial-gradient(ellipse at 50% -20%, rgba(0, 240, 255, 0.2), transparent 58%),
    rgba(8, 2, 20, 0.78);
  backdrop-filter: blur(3px);
  animation: fadein 0.35s ease-out;
}

@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.logo {
  font-family: var(--font-display);
  font-size: clamp(46px, 12vw, 130px);
  line-height: 0.9;
  letter-spacing: 0.02em;
  transform: skewX(-6deg);
}

.logo span {
  display: block;
  color: #fff;
  text-shadow:
    0 0 8px var(--neon-cyan),
    0 0 26px var(--neon-cyan),
    0 0 60px rgba(0, 240, 255, 0.55);
}

.logo em {
  display: block;
  font-style: normal;
  color: transparent;
  -webkit-text-stroke: 2px var(--neon-pink);
  text-shadow: 0 0 26px rgba(255, 43, 214, 0.7);
}

.tagline {
  font-size: clamp(10px, 1.6vw, 13px);
  letter-spacing: 0.5em;
  text-indent: 0.5em;
  color: var(--neon-cyan);
  opacity: 0.75;
}

.controls-hint {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 22px;
  margin: 6px 0 4px;
}

.controls-hint > div {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.6);
}

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  padding: 0 7px;
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--neon-cyan);
  background: rgba(0, 240, 255, 0.08);
  border: 1px solid rgba(0, 240, 255, 0.4);
  border-radius: 6px;
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.2), inset 0 0 8px rgba(0, 240, 255, 0.12);
}

.btn {
  font-family: var(--font-display);
  font-size: clamp(17px, 2.6vw, 24px);
  letter-spacing: 0.16em;
  text-indent: 0.16em;
  padding: 14px 46px;
  color: #0b0416;
  background: linear-gradient(100deg, var(--neon-cyan), var(--neon-pink));
  border: none;
  border-radius: 999px;
  cursor: pointer;
  position: relative;
  box-shadow: 0 0 22px rgba(255, 43, 214, 0.5);
  transition: transform 0.14s ease, box-shadow 0.14s ease, filter 0.14s ease;
}

.btn:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 0 34px rgba(0, 240, 255, 0.6), 0 0 60px rgba(255, 43, 214, 0.4);
  filter: saturate(1.2);
}

.btn:active { transform: translateY(0) scale(0.98); }

.hint-line {
  font-size: 11px;
  letter-spacing: 0.16em;
  color: rgba(255, 255, 255, 0.35);
}

.best-line {
  font-size: 12px;
  letter-spacing: 0.2em;
  color: rgba(255, 255, 255, 0.5);
}

.best-line strong {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--neon-yellow);
  text-shadow: 0 0 16px rgba(255, 230, 0, 0.7);
}

/* 倒计时 */
#countdown {
  background: rgba(8, 2, 20, 0.42);
  backdrop-filter: none;
}

.count-num {
  font-family: var(--font-display);
  font-size: clamp(90px, 22vw, 220px);
  line-height: 1;
  color: #fff;
  text-shadow:
    0 0 14px var(--neon-cyan),
    0 0 40px var(--neon-pink),
    0 0 90px rgba(255, 43, 214, 0.8);
  animation: countpop 0.75s ease-out;
}

@keyframes countpop {
  0%   { opacity: 0; transform: scale(2.1); filter: blur(8px); }
  30%  { opacity: 1; transform: scale(1); filter: blur(0); }
  75%  { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.7); }
}

/* 结束页 */
.end-title {
  font-family: var(--font-display);
  font-size: clamp(40px, 9vw, 96px);
  letter-spacing: 0.06em;
  transform: skewX(-6deg);
  color: #fff;
  text-shadow:
    0 0 10px var(--neon-pink),
    0 0 34px var(--neon-pink),
    0 0 70px rgba(255, 43, 214, 0.6);
}

.end-stats {
  display: flex;
  gap: clamp(20px, 6vw, 64px);
  padding: 20px 34px;
  background: var(--panel);
  border: 1px solid rgba(0, 240, 255, 0.25);
  border-radius: 16px;
  box-shadow: 0 0 34px rgba(0, 240, 255, 0.14), inset 0 0 30px rgba(176, 38, 255, 0.12);
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat strong {
  font-family: var(--font-display);
  font-size: clamp(26px, 5vw, 44px);
  color: var(--neon-cyan);
  text-shadow: 0 0 16px rgba(0, 240, 255, 0.7);
}

.end-new {
  font-family: var(--font-display);
  font-size: clamp(16px, 2.6vw, 24px);
  letter-spacing: 0.2em;
  color: var(--neon-yellow);
  text-shadow: 0 0 18px rgba(255, 230, 0, 0.9);
  animation: blink 0.7s steps(2, end) infinite;
}

.end-new.hidden { display: none; }

@keyframes blink { 50% { opacity: 0.25; } }

/* 声音按钮 */
.icon-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 20;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  font-size: 17px;
  color: #fff;
  background: rgba(20, 6, 40, 0.6);
  border: 1px solid rgba(0, 240, 255, 0.35);
  border-radius: 10px;
  cursor: pointer;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.icon-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 0 18px rgba(0, 240, 255, 0.45);
}

.icon-btn.off { opacity: 0.45; }

/* ---------------- 触屏控制 ---------------- */

#touch {
  position: absolute;
  inset: auto 0 0 0;
  height: 100%;
  z-index: 6;
  pointer-events: none;
}

.tpad {
  position: absolute;
  bottom: max(18px, env(safe-area-inset-bottom));
  display: flex;
  gap: 12px;
  pointer-events: auto;
}

.tpad-left { left: max(14px, env(safe-area-inset-left)); }
.tpad-right { right: max(14px, env(safe-area-inset-right)); }

.tbtn {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 22px;
  color: #fff;
  background: rgba(20, 6, 40, 0.55);
  border: 1px solid rgba(0, 240, 255, 0.45);
  border-radius: 16px;
  backdrop-filter: blur(6px);
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.2);
  touch-action: none;
  cursor: pointer;
}

.tbtn:active,
.tbtn.held {
  background: rgba(255, 43, 214, 0.35);
  box-shadow: 0 0 28px rgba(255, 43, 214, 0.7);
}

.tbtn-nitro {
  border-color: rgba(255, 43, 214, 0.6);
  color: var(--neon-pink);
  font-size: 19px;
}

.tbtn-gas {
  border-color: rgba(0, 240, 255, 0.6);
  color: var(--neon-cyan);
}

/* ---------------- 响应式 ---------------- */

@media (max-width: 560px) {
  #hud { padding: 10px 12px; }
  .hud-block { min-width: 64px; }
  .hud-top { gap: 6px; }
  .hud-bottom { gap: 8px; }
  .controls-hint { gap: 6px 12px; }
  .controls-hint > div { font-size: 11px; }
  .end-stats { padding: 14px 18px; gap: 18px; }
  .tbtn { width: 58px; height: 58px; }
}

@media (hover: none) and (pointer: coarse) {
  #touch:not(.hidden) { display: block; }
  /* keep the speedometer and nitro bar clear of the touch buttons */
  #hud { padding-bottom: 92px; }
  .dial { width: clamp(80px, 24vw, 108px); }
}

@media (max-height: 480px) {
  .logo { font-size: clamp(34px, 9vh, 64px); }
  .screen { gap: 10px; }
  .btn { padding: 10px 34px; }
}

@media (prefers-reduced-motion: reduce) {
  .center-msg.show, .count-num, .end-new { animation-duration: 0.01ms; animation-iteration-count: 1; }
}
