:root {
  --cyan: #00ffe1;
  --magenta: #ff2fd6;
  --yellow: #ffe95c;
  --bg: #05010f;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: 'Rajdhani', 'Microsoft YaHei', sans-serif;
  color: #d8e6ff;
  user-select: none;
}

#game-container { position: fixed; inset: 0; }
#game-container canvas { display: block; }

.hidden { display: none !important; }

/* ---- CRT 扫描线氛围 ---- */
.scanlines {
  position: fixed; inset: 0; pointer-events: none; z-index: 50;
  background: repeating-linear-gradient(
    to bottom, rgba(0,0,0,0) 0px, rgba(0,0,0,0) 3px, rgba(0,0,0,.14) 4px);
  mix-blend-mode: multiply;
  box-shadow: inset 0 0 220px rgba(2, 0, 20, .85);
}

/* ================= 开始 / 结束界面 ================= */
#start-screen, #end-screen {
  position: fixed; inset: 0; z-index: 40;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 22px;
  background: radial-gradient(ellipse at 50% 120%, rgba(255,47,214,.16), transparent 60%),
              radial-gradient(ellipse at 50% -20%, rgba(0,255,225,.12), transparent 55%),
              rgba(4, 1, 14, .82);
  backdrop-filter: blur(3px);
  text-align: center;
}

.title {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: clamp(52px, 9vw, 108px);
  letter-spacing: .12em;
  color: #fff;
  text-shadow: 0 0 8px var(--cyan), 0 0 28px var(--cyan), 0 0 60px rgba(0,255,225,.6);
  animation: flicker 4s infinite;
}
.title span {
  color: var(--magenta);
  text-shadow: 0 0 8px var(--magenta), 0 0 28px var(--magenta), 0 0 60px rgba(255,47,214,.6);
  margin-left: .18em;
}
.title.small { font-size: clamp(26px, 4vw, 44px); }

@keyframes flicker {
  0%, 91%, 94%, 100% { opacity: 1; }
  92% { opacity: .55; }
  93% { opacity: .85; }
}

.subtitle {
  font-size: clamp(16px, 2.2vw, 24px);
  letter-spacing: .55em; text-indent: .55em;
  color: var(--cyan);
  text-shadow: 0 0 12px rgba(0,255,225,.8);
}

.rules { font-size: 17px; color: #9fb0d8; letter-spacing: .12em; }

.controls-grid {
  display: grid; grid-template-columns: repeat(3, auto);
  gap: 10px 34px;
  padding: 18px 30px;
  border: 1px solid rgba(0,255,225,.35);
  border-radius: 6px;
  background: rgba(0, 20, 30, .35);
  box-shadow: 0 0 24px rgba(0,255,225,.12), inset 0 0 24px rgba(0,255,225,.05);
  font-size: 16px; color: #b9c8ea;
}
.controls-grid b {
  font-family: 'Orbitron', sans-serif; font-size: 13px;
  color: var(--yellow); margin-right: 8px;
  text-shadow: 0 0 8px rgba(255,233,92,.7);
}

button {
  font-family: 'Orbitron', sans-serif;
  font-size: 20px; font-weight: 700; letter-spacing: .2em;
  padding: 16px 54px;
  color: #041018;
  background: linear-gradient(90deg, var(--cyan), #43ffd9);
  border: none; border-radius: 4px;
  cursor: pointer;
  clip-path: polygon(12px 0, 100% 0, calc(100% - 12px) 100%, 0 100%);
  box-shadow: 0 0 24px rgba(0,255,225,.55);
  transition: transform .12s ease, box-shadow .12s ease, filter .12s;
}
button:hover { transform: scale(1.05); box-shadow: 0 0 44px rgba(0,255,225,.9); filter: brightness(1.1); }
button:active { transform: scale(.97); }

#end-rank {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(40px, 7vw, 84px); font-weight: 900; letter-spacing: .1em;
  color: var(--yellow);
  text-shadow: 0 0 12px var(--yellow), 0 0 42px rgba(255,233,92,.65);
}
#end-stats {
  font-family: 'Orbitron', sans-serif;
  font-size: 16px; line-height: 2.1; letter-spacing: .14em;
  color: #cfe0ff;
}
#end-stats .k { color: #7f8fb8; margin-right: 14px; }
#end-stats .v { color: var(--cyan); text-shadow: 0 0 10px rgba(0,255,225,.7); }

/* ================= HUD ================= */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 30; }

.hud-top {
  position: absolute; top: 18px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 14px; align-items: stretch;
}
.hud-box {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 96px;
  padding: 8px 18px;
  background: rgba(5, 8, 26, .55);
  border: 1px solid rgba(0,255,225,.4);
  border-radius: 4px;
  box-shadow: 0 0 16px rgba(0,255,225,.12);
}
.label {
  font-family: 'Orbitron', sans-serif; font-size: 10px;
  letter-spacing: .3em; color: var(--magenta);
  text-shadow: 0 0 8px rgba(255,47,214,.8);
}
.big {
  font-family: 'Orbitron', sans-serif; font-size: 26px; font-weight: 700;
  color: #fff; text-shadow: 0 0 10px rgba(0,255,225,.9);
}
.time-box { min-width: 220px; }
.sub-times { display: flex; gap: 16px; font-size: 13px; color: #8fa3cf; font-family: 'Orbitron', sans-serif; }
#hud-best { color: var(--yellow); }

.hud-bottom {
  position: absolute; bottom: 24px; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-end;
  padding: 0 36px;
}

#nitro-box { width: 300px; }
#nitro-box .label { margin-bottom: 6px; text-align: left; }
#nitro-bar {
  height: 14px;
  border: 1px solid rgba(0,255,225,.55);
  border-radius: 3px;
  background: rgba(0, 20, 30, .5);
  overflow: hidden;
  transform: skewX(-18deg);
}
#nitro-fill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, #0066ff, var(--cyan));
  box-shadow: 0 0 14px var(--cyan);
  transition: width .08s linear;
}
#nitro-fill.burning { background: linear-gradient(90deg, #7b2fff, var(--magenta)); box-shadow: 0 0 18px var(--magenta); }

#speed-box { display: flex; align-items: baseline; gap: 10px; }
#hud-speed {
  font-family: 'Orbitron', sans-serif; font-weight: 900;
  font-size: 64px; color: #fff;
  text-shadow: 0 0 12px var(--cyan), 0 0 40px rgba(0,255,225,.5);
}
.unit { font-family: 'Orbitron', sans-serif; font-size: 14px; color: var(--magenta); letter-spacing: .2em; }

#toast {
  position: absolute; top: 34%; left: 50%; transform: translateX(-50%);
  font-family: 'Orbitron', sans-serif; font-size: 44px; font-weight: 900;
  letter-spacing: .25em; color: var(--yellow);
  text-shadow: 0 0 14px var(--yellow), 0 0 50px rgba(255,233,92,.7);
  opacity: 0; transition: opacity .25s;
  white-space: nowrap;
}
#toast.show { opacity: 1; }

#mute-ind {
  position: absolute; top: 18px; right: 22px;
  font-family: 'Orbitron', sans-serif; font-size: 12px; letter-spacing: .2em;
  color: #ff6a6a; text-shadow: 0 0 8px rgba(255,80,80,.8);
}

/* ================= 倒计时 ================= */
#countdown {
  position: fixed; inset: 0; z-index: 35;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  font-family: 'Orbitron', sans-serif; font-weight: 900;
  font-size: clamp(90px, 18vw, 220px);
  color: var(--cyan);
  text-shadow: 0 0 20px var(--cyan), 0 0 90px rgba(0,255,225,.8);
}
#countdown.go { color: var(--yellow); text-shadow: 0 0 20px var(--yellow), 0 0 90px rgba(255,233,92,.9); }
#countdown.pop { animation: pop .9s ease-out; }
@keyframes pop {
  0% { transform: scale(1.7); opacity: 0; }
  25% { transform: scale(1); opacity: 1; }
  80% { opacity: 1; }
  100% { opacity: .2; }
}
