/* 3D 停车大师 - 全部样式（原创，无外部资源） */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #0b0e13; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  color: #e8ecf1;
  user-select: none;
  -webkit-user-select: none;
}
.hidden { display: none !important; }

#scene-container, #scene-container canvas { position: fixed; inset: 0; display: block; }

/* ---------- 后视镜 ---------- */
#mirror-frame {
  position: fixed; top: 8px; left: 50%; transform: translateX(-50%);
  width: 26vw; height: calc(26vw * 0.34);
  border: 4px solid #1a1d22; border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,.6), inset 0 0 0 1px rgba(255,255,255,.08);
  pointer-events: none; z-index: 5;
}
.mirror-label {
  position: absolute; right: 6px; bottom: 2px; font-size: 10px;
  color: rgba(255,255,255,.45); letter-spacing: 2px;
}

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.panel-mini {
  background: rgba(10, 14, 20, .62);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 10px; padding: 8px 12px;
  backdrop-filter: blur(4px);
}
#hud-top-left { position: absolute; top: 10px; left: 10px; font-size: 15px; line-height: 1.5; min-width: 110px; }
#hud-level { font-weight: 700; color: #8fd3ff; font-size: 13px; }
#hud-time { font-variant-numeric: tabular-nums; font-size: 18px; font-weight: 700; }
#hud-time.time-low { color: #ff5d5d; animation: blink .5s steps(2) infinite; }
@keyframes blink { 50% { opacity: .35; } }
#hud-hits { font-size: 13px; color: #ffb4b4; }

#hud-top-right { position: absolute; top: 10px; right: 10px; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
#minimap, #radar {
  background: rgba(10, 14, 20, .72);
  border: 1px solid rgba(255,255,255,.14); border-radius: 10px;
}

#hud-bottom-center {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
#hud-speed { font-size: 15px; font-variant-numeric: tabular-nums; }
#speed-val { font-size: 22px; font-weight: 800; }
#gear { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 6px; font-weight: 800; background: #2a2f38; }
.gear-d { color: #6fe38a; } .gear-r { color: #ffb84d; } .gear-n { color: #9aa4b0; }

#park-progress-wrap { width: 240px; text-align: center; }
#park-progress-label { font-size: 12px; color: #9fe8b0; margin-bottom: 4px; text-shadow: 0 1px 3px #000; }
#park-progress { height: 10px; border-radius: 5px; background: rgba(0,0,0,.55); border: 1px solid rgba(255,255,255,.2); overflow: hidden; }
#park-progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #3ddc74, #b6ff6b); transition: width .1s linear; }

#hud-buttons { position: absolute; bottom: 12px; right: 10px; display: flex; flex-direction: column; gap: 6px; }
.hbtn {
  pointer-events: auto; cursor: pointer;
  background: rgba(10,14,20,.68); color: #e8ecf1;
  border: 1px solid rgba(255,255,255,.16); border-radius: 10px;
  font-size: 13px; padding: 8px 12px; min-width: 92px;
}
.hbtn:hover { background: rgba(50,60,75,.8); }
.hbtn.active { background: #1f6f43; border-color: #3ddc74; }

#hit-flash {
  position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(255,30,30,.5) 100%);
}
#hit-flash.flash { animation: hitflash .45s ease-out; }
@keyframes hitflash { 0% { opacity: 1; } 100% { opacity: 0; } }

#countdown {
  position: absolute; top: 38%; left: 50%; transform: translate(-50%, -50%);
  font-size: 92px; font-weight: 900; color: #fff;
  text-shadow: 0 4px 24px rgba(0,0,0,.8), 0 0 40px rgba(80,180,255,.5);
}
#countdown.go { color: #6fe38a; font-size: 72px; }

/* ---------- 触控 ---------- */
#touch-controls { position: fixed; inset: 0; pointer-events: none; z-index: 20; }
#tc-left { position: absolute; left: 14px; bottom: 20px; display: flex; gap: 14px; }
#tc-right { position: absolute; right: 14px; bottom: 20px; display: flex; gap: 14px; align-items: flex-end; }
.tc-btn {
  pointer-events: auto; width: 74px; height: 74px; border-radius: 50%;
  font-size: 22px; font-weight: 700; color: #fff; line-height: 1.15;
  background: rgba(20, 28, 40, .6); border: 2px solid rgba(255,255,255,.28);
  touch-action: none;
}
.tc-btn.pressed { background: rgba(70, 140, 220, .75); transform: scale(.94); }
.tc-gas { width: 84px; height: 84px; background: rgba(30, 90, 50, .65); border-color: rgba(110,230,140,.5); }
.tc-brake { background: rgba(100, 35, 35, .65); border-color: rgba(255,120,120,.5); font-size: 15px; }

/* ---------- 覆盖层 / 菜单 ---------- */
#overlay { position: fixed; inset: 0; z-index: 30; display: none; }
#overlay.show { display: flex; align-items: center; justify-content: center; background: rgba(5, 8, 12, .72); backdrop-filter: blur(6px); overflow-y: auto; }
.panel {
  background: linear-gradient(160deg, #161c26, #0e1219);
  border: 1px solid rgba(255,255,255,.12); border-radius: 18px;
  padding: 28px 32px; max-width: 720px; width: min(92vw, 720px);
  max-height: 92vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
  text-align: center; margin: 20px 0;
}
.panel h1 { font-size: 34px; letter-spacing: 4px; margin-bottom: 4px; background: linear-gradient(90deg, #8fd3ff, #b6ff6b); -webkit-background-clip: text; background-clip: text; color: transparent; }
.panel h2 { font-size: 24px; margin-bottom: 12px; }
.panel .sub { color: #93a0b0; font-size: 13px; margin-bottom: 18px; }

.section-title { font-size: 14px; color: #8fd3ff; margin: 16px 0 8px; text-align: left; font-weight: 700; }

.car-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.car-card {
  cursor: pointer; width: 150px; padding: 12px 10px; border-radius: 12px;
  background: rgba(255,255,255,.05); border: 2px solid transparent;
}
.car-card:hover { background: rgba(255,255,255,.1); }
.car-card.selected { border-color: #3ddc74; background: rgba(61, 220, 116, .12); }
.car-swatch { width: 100%; height: 44px; border-radius: 8px; margin-bottom: 8px; position: relative; overflow: hidden; }
.car-swatch::after { content: ""; position: absolute; left: 12%; right: 12%; top: 30%; bottom: 22%; background: rgba(20,26,34,.85); border-radius: 4px; }
.car-name { font-weight: 700; font-size: 14px; }
.car-desc { font-size: 11px; color: #93a0b0; margin-top: 3px; }
.stat { display: flex; align-items: center; gap: 5px; font-size: 10px; color: #7d8896; margin-top: 3px; }
.stat .bar { flex: 1; height: 4px; border-radius: 2px; background: #2a2f38; overflow: hidden; }
.stat .bar i { display: block; height: 100%; background: #5db4ff; }

.level-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.level-btn {
  cursor: pointer; padding: 12px 8px; border-radius: 12px;
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.1);
  color: #e8ecf1; font-size: 14px; font-weight: 700;
  display: flex; flex-direction: column; gap: 5px; align-items: center;
}
.level-btn:hover:not(.locked) { background: rgba(90, 160, 255, .16); border-color: #5db4ff; }
.level-btn .lv-num { font-size: 11px; color: #7d8896; font-weight: 400; }
.level-btn .lv-stars { font-size: 14px; letter-spacing: 2px; }
.level-btn.locked { opacity: .38; cursor: not-allowed; }
.star-on { color: #f5c542; } .star-off { color: #3a4150; }

.btn-row { display: flex; gap: 10px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.btn {
  cursor: pointer; border: none; border-radius: 10px; padding: 12px 26px;
  font-size: 15px; font-weight: 700; color: #0b0e13;
  background: linear-gradient(90deg, #57c785, #2fae64);
}
.btn:hover { filter: brightness(1.12); }
.btn.ghost { background: rgba(255,255,255,.1); color: #e8ecf1; border: 1px solid rgba(255,255,255,.2); }
.btn.warn { background: linear-gradient(90deg, #ff9a5c, #f2703f); color: #fff; }

.settings-row { display: flex; gap: 10px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.set-btn {
  cursor: pointer; padding: 8px 16px; border-radius: 20px; font-size: 13px;
  background: rgba(255,255,255,.07); color: #cfd8e3; border: 1px solid rgba(255,255,255,.15);
}
.set-btn.on { background: rgba(61, 220, 116, .18); border-color: #3ddc74; color: #9fe8b0; }

.help-text { margin-top: 18px; font-size: 12px; color: #7d8896; line-height: 1.8; }
kbd {
  display: inline-block; padding: 1px 7px; border-radius: 5px; font-size: 11px;
  background: #222936; border: 1px solid #3a4252; border-bottom-width: 2px; font-family: inherit;
}

/* 结算 */
.stars-big { font-size: 52px; letter-spacing: 10px; margin: 6px 0 10px; }
.stars-big .star-on { text-shadow: 0 0 22px rgba(245, 197, 66, .65); }
.score-lines { text-align: left; width: min(320px, 86%); margin: 0 auto; font-size: 14px; }
.score-lines .row { display: flex; justify-content: space-between; padding: 5px 2px; border-bottom: 1px dashed rgba(255,255,255,.08); }
.score-lines .row.total { font-size: 18px; font-weight: 800; color: #b6ff6b; border-bottom: none; margin-top: 4px; }
.score-lines .neg { color: #ff8d8d; }
.comment { margin-top: 10px; font-size: 13px; color: #93a0b0; }

/* 加载失败提示 */
#boot-error { display: none; position: fixed; inset: 0; z-index: 99; background: #0b0e13; align-items: center; justify-content: center; }
.boot-box { max-width: 520px; padding: 30px; text-align: center; line-height: 2; font-size: 14px; color: #cfd8e3; }
.boot-box code { display: inline-block; background: #1a212c; padding: 4px 10px; border-radius: 6px; color: #8fd3ff; font-size: 12px; }

/* ---------- 小屏适配 ---------- */
@media (max-width: 760px) {
  #minimap { width: 110px; height: 110px; }
  #radar { width: 130px; height: 70px; }
  #countdown { font-size: 64px; }
  .panel { padding: 20px 16px; }
  .panel h1 { font-size: 26px; }
  #hud-buttons { flex-direction: row; bottom: 116px; right: 10px; }
  .hbtn { min-width: 0; padding: 7px 9px; font-size: 12px; }
  #hud-bottom-center { bottom: 108px; }
}
