@font-face {
  font-family: 'PressStart';
  src: url('./assets/fonts/press-start-2p.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}

:root {
  --neon-pink: #ff4fa3;
  --neon-cyan: #43e8ff;
  --neon-amber: #ffc23c;
  --ink: #0a0d1c;
}

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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #05060f;
  font-family: 'PressStart', 'Microsoft YaHei', monospace;
  -webkit-user-select: none; user-select: none;
  touch-action: none;
}

#c {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.hidden { display: none !important; }

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

#topbar {
  position: absolute; top: 14px; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 0 58px 0 22px;
}

#hearts { font-size: 22px; letter-spacing: 4px; text-shadow: 0 0 8px #ff2b55, 2px 2px 0 #400; }
#hearts .lost { opacity: .18; text-shadow: none; }

/* HP 血条 */
#hp-wrap { width: 230px; }
#hp-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
#hp-label { font-size: 10px; letter-spacing: 4px; color: #ff5577; text-shadow: 0 0 8px #ff2b55; }
#hp-num { font-size: 15px; color: #fff; text-shadow: 0 0 8px #ff5577, 2px 2px 0 #300; }
#hp-bar {
  height: 14px; background: rgba(20,8,20,.85);
  border: 2px solid rgba(255,90,120,.75);
  box-shadow: 0 0 10px rgba(255,60,90,.35), inset 0 0 6px rgba(0,0,0,.6);
}
#hp-fill {
  height: 100%; width: 100%;
  background: linear-gradient(180deg, #ff7d97, #ff2b55);
  box-shadow: 0 0 10px rgba(255,43,85,.8);
  transition: width .18s steps(8);
}
#hp-fill.low { background: linear-gradient(180deg, #ffb347, #ff3b2f); animation: blink .4s steps(2) infinite; }

/* 通缉星 / 热度 / 分数 */
#star-wrap { text-align: right; min-width: 210px; }
#stars { font-size: 20px; letter-spacing: 5px; color: var(--neon-amber); text-shadow: 0 0 10px #a06a00, 2px 2px 0 #301f00; height: 24px; }
#stars .off { opacity: .22; text-shadow: none; }
#heat-bar {
  height: 8px; margin-top: 7px;
  background: rgba(10,14,34,.85); border: 2px solid rgba(67,232,255,.5);
}
#heat-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--neon-cyan), var(--neon-pink)); box-shadow: 0 0 8px rgba(67,232,255,.7); transition: width .3s; }
#score { margin-top: 7px; font-size: 17px; color: #fff; letter-spacing: 3px; text-shadow: 0 0 10px var(--neon-cyan), 2px 2px 0 #10203a; }

#timer-wrap { text-align: center; }
#timer {
  font-size: 40px; color: #fff;
  text-shadow: 0 0 12px var(--neon-cyan), 3px 3px 0 #10203a;
}
#timer-label { font-size: 9px; letter-spacing: 6px; color: var(--neon-cyan); opacity: .8; margin-top: 6px; }

#best-wrap { text-align: right; }
#best { font-size: 11px; color: var(--neon-amber); text-shadow: 0 0 8px #a06a00; letter-spacing: 2px; }
#combo { font-size: 13px; color: var(--neon-pink); margin-top: 8px; text-shadow: 0 0 10px var(--neon-pink); height: 16px; }
#combo.on { animation: blink .5s steps(2) infinite; }

#speedo {
  position: absolute; right: 24px; bottom: 20px;
  text-align: right; color: #fff;
}
#speed-val { font-size: 46px; text-shadow: 0 0 14px var(--neon-amber), 3px 3px 0 #3a2a00; }
#speed-unit { display: block; font-size: 10px; letter-spacing: 5px; color: var(--neon-amber); opacity: .85; margin-top: 4px; }

#hint {
  position: absolute; left: 24px; bottom: 24px;
  font-size: 9px; letter-spacing: 1.5px; color: #9fb4e8; opacity: .75;
  text-shadow: 1px 1px 0 #000;
  transition: opacity 1.2s;
}

#drift-pop {
  position: absolute; left: 50%; top: 34%;
  transform: translate(-50%, -50%) scale(.6);
  font-size: 30px; color: var(--neon-pink);
  text-shadow: 0 0 16px var(--neon-pink), 4px 4px 0 #40102a;
  opacity: 0; transition: none;
}
#drift-pop.show { animation: pop .9s ease-out forwards; }
@keyframes pop {
  0%   { opacity: 0; transform: translate(-50%,-50%) scale(.5); }
  18%  { opacity: 1; transform: translate(-50%,-50%) scale(1.15); }
  40%  { transform: translate(-50%,-50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%,-64%) scale(1); }
}

#warn {
  position: absolute; left: 50%; bottom: 15%;
  transform: translateX(-50%);
  font-size: 16px; color: #ff3b3b; letter-spacing: 6px;
  text-shadow: 0 0 12px #ff0000;
  opacity: 0;
}
#warn.on { animation: blink .5s steps(2) infinite; }
@keyframes blink { 50% { opacity: 1; } }

#heli-warn {
  position: absolute; left: 50%; top: 16%;
  transform: translateX(-50%);
  font-size: 15px; letter-spacing: 5px; color: #ffd23c;
  text-shadow: 0 0 12px #ffb300, 2px 2px 0 #301f00;
  opacity: 0;
}
#heli-warn.on { animation: blink .7s steps(2) infinite; }

/* ---------- 屏幕 ---------- */
.screen {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, rgba(10,14,40,.55), rgba(4,5,14,.92) 75%);
}
.scan {
  position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.22) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
}
.panel {
  position: relative; text-align: center; color: #e8eeff;
  padding: 46px 58px;
  background: rgba(8, 10, 26, .72);
  border: 3px solid var(--neon-cyan);
  box-shadow: 0 0 0 3px #0a1030, 0 0 34px rgba(67,232,255,.35), inset 0 0 40px rgba(67,232,255,.07);
  max-width: min(92vw, 640px);
}
.panel::before, .panel::after {
  content: ''; position: absolute; width: 14px; height: 14px; background: var(--neon-pink);
  box-shadow: 0 0 10px var(--neon-pink);
}
.panel::before { top: -8px; left: -8px; }
.panel::after { bottom: -8px; right: -8px; }

.kicker { font-size: 10px; letter-spacing: 7px; color: var(--neon-pink); text-shadow: 0 0 10px var(--neon-pink); }
.panel h1 {
  font-family: 'Microsoft YaHei', 'PressStart', sans-serif;
  font-weight: 900; font-size: clamp(44px, 9vw, 76px); letter-spacing: 14px; margin: 18px 0 6px;
  color: #fff; text-shadow: 0 0 22px var(--neon-cyan), 5px 5px 0 #14224a, -2px -2px 0 #3a1040;
}
.sub { font-size: clamp(13px, 2.4vw, 18px); letter-spacing: 10px; color: var(--neon-cyan); text-shadow: 0 0 12px var(--neon-cyan); }
.desc {
  font-family: 'Microsoft YaHei', sans-serif; font-size: 15px; line-height: 1.9;
  color: #b9c6ea; margin: 22px 0 18px;
}
.ctrls { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; font-size: 9px; color: #8fa3d8; margin-bottom: 26px; }
.ctrls b { color: var(--neon-amber); }

.cta {
  display: inline-block; font-size: 13px; letter-spacing: 3px;
  color: #06121c; background: var(--neon-cyan);
  padding: 14px 26px; cursor: pointer;
  box-shadow: 0 0 18px rgba(67,232,255,.7), 4px 4px 0 #083040;
  animation: ctaPulse 1.4s ease-in-out infinite;
}
@keyframes ctaPulse { 50% { filter: brightness(1.25); transform: translateY(-2px); } }
.cta:hover { filter: brightness(1.2); }

.best-line { margin-top: 20px; font-size: 10px; letter-spacing: 3px; color: var(--neon-amber); min-height: 14px; }

.result-row {
  display: flex; justify-content: space-between; gap: 40px;
  font-family: 'Microsoft YaHei', sans-serif; font-size: 17px; color: #aab8e0;
  padding: 12px 4px; border-bottom: 1px dashed rgba(120,150,220,.3);
  margin-top: 8px;
}
.result-row b { font-family: 'PressStart', monospace; font-size: 22px; color: #fff; text-shadow: 0 0 10px var(--neon-cyan); }
.result-row.new {
  justify-content: center; border: none; color: var(--neon-amber);
  font-family: 'PressStart', monospace; font-size: 15px;
  text-shadow: 0 0 12px var(--neon-amber); animation: blink .6s steps(2) infinite;
}
#screen-over .panel { border-color: var(--neon-pink); box-shadow: 0 0 0 3px #2a0a20, 0 0 34px rgba(255,79,163,.4), inset 0 0 40px rgba(255,79,163,.07); }
#screen-over .cta { background: var(--neon-pink); box-shadow: 0 0 18px rgba(255,79,163,.7), 4px 4px 0 #40102a; }

/* ---------- 特效层 ---------- */
#flash { position: fixed; inset: 0; z-index: 8; pointer-events: none; background: #fff; opacity: 0; }
#vignette {
  position: fixed; inset: 0; z-index: 7; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(2,3,10,.55) 100%);
}
body.hurt #vignette { background: radial-gradient(ellipse at center, transparent 45%, rgba(190,10,40,.55) 100%); }

/* ---------- 触屏 ---------- */
#touch { position: fixed; inset: 0; z-index: 6; pointer-events: none; }
.tbtn {
  position: absolute; bottom: 26px; width: 84px; height: 84px;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; color: rgba(255,255,255,.85);
  background: rgba(30,40,80,.4); border: 2px solid rgba(120,160,255,.5);
  pointer-events: auto; border-radius: 4px;
}
#t-left { left: 20px; }
#t-right { left: 124px; }
#t-drift { right: 20px; font-size: 14px; color: var(--neon-pink); border-color: rgba(255,79,163,.6); }
#t-brake { right: 124px; font-size: 14px; color: var(--neon-cyan); border-color: rgba(67,232,255,.6); }
.tbtn.on { background: rgba(90,130,255,.55); }
.gyro-hint {
  position: absolute; left: 50%; bottom: 132px; transform: translateX(-50%);
  font-size: 12px; letter-spacing: 3px; color: var(--neon-cyan);
  text-shadow: 0 0 10px var(--neon-cyan); opacity: 0; transition: opacity .4s;
  white-space: nowrap;
}
.gyro-hint.on { opacity: .9; }

/* ---------- 暂停 ---------- */
#btn-pause {
  position: absolute; top: 14px; right: 10px;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: rgba(255,255,255,.85);
  background: rgba(30,40,80,.45); border: 2px solid rgba(120,160,255,.55);
  border-radius: 4px; pointer-events: auto; cursor: pointer;
  text-shadow: 0 0 8px var(--neon-cyan);
}
#btn-pause.on { background: rgba(90,130,255,.6); }
#pause-ov {
  position: fixed; inset: 0; z-index: 9;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4,6,18,.62); backdrop-filter: blur(2px);
  pointer-events: auto; cursor: pointer;
}
.pause-box {
  font-size: 46px; text-align: center; color: #fff;
  text-shadow: 0 0 16px var(--neon-cyan);
}
.pause-t { font-size: 26px; letter-spacing: 10px; margin-top: 14px; }
.pause-s { font-size: 12px; letter-spacing: 3px; color: var(--neon-cyan); opacity: .85; margin-top: 14px; text-shadow: 0 0 8px var(--neon-cyan); }

body.touch #hint { display: none; }

/* ---------- 竖屏适配 ---------- */
@media (orientation: portrait) {
  #topbar { padding: 0 46px 0 8px; gap: 6px; }
  #hp-wrap { width: 104px; }
  #hp-num { font-size: 11px; }
  #hp-bar { height: 12px; }
  #timer { font-size: 23px; }
  #timer-label { font-size: 7px; letter-spacing: 3px; }
  #star-wrap { min-width: 0; }
  #stars { font-size: 13px; letter-spacing: 2px; height: 18px; }
  #heat-bar { margin-top: 5px; }
  #score { font-size: 11px; letter-spacing: 1px; margin-top: 5px; }
  #speed-val { font-size: 34px; }
  #speedo { right: 16px; bottom: 130px; }
  #warn { bottom: 24%; font-size: 14px; letter-spacing: 3px; }
  .panel { padding: 32px 22px; }
  .panel h1 { letter-spacing: 8px; }
  .ctrls { gap: 10px; }
  /* 底部触屏按钮：缩小 + 左右分列防重叠（320px 宽验证：左 12-152，右 168-308） */
  .tbtn { width: 66px; height: 66px; font-size: 24px; bottom: 18px; }
  #t-left { left: 12px; }
  #t-right { left: 86px; }
  #t-drift { right: 12px; font-size: 12px; }
  #t-brake { right: 86px; font-size: 12px; }
  .gyro-hint { bottom: 98px; font-size: 11px; letter-spacing: 2px; }
  #btn-pause { top: 10px; right: 8px; width: 34px; height: 34px; font-size: 14px; }
}
