﻿/* ============================================================
   海岸环道 · 3D 竞速界面
   ============================================================ */
:root {
  --ink: #eaf4fb;
  --muted: rgba(234, 244, 251, 0.54);
  --faint: rgba(234, 244, 251, 0.34);
  --line: rgba(255, 255, 255, 0.13);
  --panel: rgba(8, 19, 29, 0.78);
  --panel-soft: rgba(9, 22, 34, 0.56);
  --cyan: #87d9ff;
  --gold: #ffd166;
  --orange: #ffb36b;
  --danger: #ff8f8f;
  --green: #7ef0b0;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: #081018; color: var(--ink);
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  overscroll-behavior: none;
}
#app { position: fixed; inset: 0; }
#app canvas { display: block; width: 100%; height: 100%; outline: none; touch-action: none; }
button, a { -webkit-tap-highlight-color: transparent; }

/* ---------------- 顶栏 ---------------- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 70;
  height: 58px; padding: 10px 20px;
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(180deg, rgba(5, 12, 19, 0.72), rgba(5, 12, 19, 0));
  pointer-events: none;
}
#topbar > * { pointer-events: auto; }
.brand-mini { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); }
.brand-dot {
  width: 20px; height: 20px; border-radius: 6px;
  background: radial-gradient(circle at 30% 25%, #b9f0ff, #2a9fd0 60%, #0d3b52);
  box-shadow: 0 0 18px rgba(92, 209, 255, 0.45);
}
.brand-copy-mini { display: flex; flex-direction: column; line-height: 1.05; }
.brand-copy-mini strong { font-size: 14px; letter-spacing: 0.06em; }
.brand-copy-mini small { margin-top: 3px; color: var(--faint); font-size: 8px; letter-spacing: 0.22em; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.account-badge {
  display: inline-flex; align-items: center; min-height: 32px; padding: 0 11px;
  border: 1px solid var(--line); border-radius: 9px;
  background: rgba(8, 19, 29, 0.58); backdrop-filter: blur(10px);
  color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden;
}
.account-badge a { color: rgba(255, 209, 137, 0.92); text-decoration: none; }
.account-badge .account-name { color: var(--ink); margin-right: 7px; }
.account-badge.is-loading { opacity: 0.7; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line);
  background: rgba(8, 19, 29, 0.62); color: var(--ink); font-family: inherit;
  font-size: 12px; cursor: pointer; backdrop-filter: blur(10px);
}
.icon-btn.is-on { border-color: rgba(135, 217, 255, 0.5); color: var(--cyan); }

/* ---------------- HUD ---------------- */
#hud {
  position: fixed; top: 72px; left: 20px; z-index: 20;
  width: 300px; padding: 15px 17px 14px;
  border: 1px solid var(--line); border-radius: 18px;
  background: linear-gradient(150deg, rgba(11, 26, 40, 0.88), rgba(8, 18, 28, 0.60));
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(16px); user-select: none; overflow: hidden;
}
#hud::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle at 92% -20%, rgba(95, 209, 255, 0.15), transparent 55%);
  pointer-events: none;
}
.hud-kicker {
  position: relative; z-index: 1;
  display: flex; justify-content: space-between;
  color: var(--cyan); font-size: 9px; font-weight: 800; letter-spacing: 0.16em;
  margin-bottom: 8px;
}
.hud-kicker span:last-child { color: var(--faint); letter-spacing: 0.12em; }
.hud-title { position: relative; z-index: 1; font-size: 16px; font-weight: 800; letter-spacing: 0.05em; line-height: 1.1; }
.hud-sub { position: relative; z-index: 1; color: var(--muted); font-size: 8.5px; letter-spacing: 0.12em; margin: 4px 0 9px; }
.speed-line {
  position: relative; z-index: 1; display: flex; align-items: baseline; gap: 7px;
  padding: 8px 0 7px; border-top: 1px solid rgba(255,255,255,0.09); border-bottom: 1px solid rgba(255,255,255,0.09);
}
#speedVal { font-size: 40px; line-height: 0.92; font-weight: 900; font-variant-numeric: tabular-nums; color: var(--gold); text-shadow: 0 0 26px rgba(255,179,71,0.18); }
.speed-unit { color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: 0.10em; }
.gear { margin-left: auto; align-self: center; min-width: 34px; padding: 3px 0; border: 1px solid rgba(135,217,255,0.25); border-radius: 8px; color: var(--cyan); font-size: 13px; font-weight: 800; text-align: center; }
.hud-stats { position: relative; z-index: 1; display: grid; grid-template-columns: 0.9fr 1.1fr; gap: 5px 12px; margin-top: 9px; }
.stat { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.stat span { color: var(--faint); font-size: 8.5px; white-space: nowrap; }
.stat b { color: #e9f5ff; font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat b.gold { color: var(--gold); }
.stat b.warn { color: var(--orange); }
.nitro-line { position: relative; z-index: 1; display: flex; align-items: center; gap: 8px; margin-top: 9px; }
.nitro-line > span { color: var(--cyan); font-size: 8px; font-weight: 800; letter-spacing: 0.12em; }
.nitro-track { flex: 1; height: 5px; border-radius: 99px; background: rgba(255,255,255,0.09); overflow: hidden; }
.nitro-track i { display: block; height: 100%; width: 0%; border-radius: 99px; background: linear-gradient(90deg, #53d6ff, #9cffdc); box-shadow: 0 0 12px rgba(83,214,255,0.55); transition: width 0.12s linear; }
.nitro-line b { min-width: 22px; color: var(--cyan); font-size: 9px; font-variant-numeric: tabular-nums; text-align: right; }
.nitro-line.is-active .nitro-track { box-shadow: 0 0 14px rgba(83,214,255,0.75); }
.nitro-line.is-active .nitro-track i { background: linear-gradient(90deg, #a8f6ff, #ffffff); }
.nitro-line.is-active > b { color: #fff; text-shadow: 0 0 10px rgba(150,235,255,0.9); }
.hud-style { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 7px; color: var(--faint); font-size: 7.5px; letter-spacing: 0.05em; position: relative; z-index: 1; }
.hud-style b { color: var(--cyan); font-size: 9px; font-variant-numeric: tabular-nums; }
.hud-style em { color: var(--gold); font-size: 9px; font-style: normal; font-weight: 800; }
.lap-progress { position: relative; z-index: 1; height: 2px; margin-top: 10px; border-radius: 99px; background: rgba(255,255,255,0.08); overflow: hidden; }
.lap-progress i { display: block; height: 100%; width: 0%; border-radius: 99px; background: linear-gradient(90deg, #58c7ff, #ffd166); box-shadow: 0 0 10px rgba(135,217,255,0.5); transition: width 0.15s linear; }

/* 发车灯 */
#startLightsHUD {
  position: fixed; top: 68px; left: 50%; transform: translateX(-50%); z-index: 22;
  display: flex; gap: 7px; padding: 8px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: rgba(6, 15, 24, 0.62);
  backdrop-filter: blur(10px);
}
#startLightsHUD .light { width: 9px; height: 9px; border-radius: 50%; background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.16); }
#startLightsHUD .light.on { background: #ff3b3b; border-color: #ff9898; box-shadow: 0 0 10px rgba(255,59,59,0.85); }

/* 氮气加速时的屏幕边缘速度感 */
#boostFx {
  position: fixed; inset: 0; z-index: 14; pointer-events: none;
  opacity: 0; transition: opacity 0.15s ease;
  background:
    radial-gradient(ellipse at center, rgba(40, 190, 255, 0) 38%, rgba(66, 205, 255, 0.18) 78%, rgba(160, 240, 255, 0.25) 100%);
}
#boostFx::after {
  content: ''; position: absolute; inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 46px, rgba(150, 235, 255, 0.055) 46px 48px);
  mask-image: radial-gradient(circle at center, transparent 28%, #000 82%);
  -webkit-mask-image: radial-gradient(circle at center, transparent 28%, #000 82%);
}
#boostFx.show { opacity: 1; animation: boostPulse 0.45s ease-in-out infinite alternate; }
@keyframes boostPulse { from { filter: brightness(0.9); } to { filter: brightness(1.18); } }
#rainFx { position: fixed; inset: 0; z-index: 13; pointer-events: none; opacity: 0; background: rgba(40, 70, 100, 0.10); }
body.weather-rain #rainFx { opacity: 1; }
#rainFx::before {
  content: ''; position: absolute; inset: -30%;
  background: repeating-linear-gradient(112deg, transparent 0 27px, rgba(190, 225, 255, 0.18) 27px 29px, transparent 29px 58px);
  animation: rainFall 0.55s linear infinite;
}
@keyframes rainFall { from { transform: translate3d(0, -8%, 0); } to { transform: translate3d(-3%, 8%, 0); } }
body.weather-rain #app { filter: saturate(0.88) brightness(0.94); }
body.paused #boostFx, body.results-open #boostFx, body.menu-open #boostFx { display: none !important; }

#status {
  position: fixed; top: 112px; left: 50%; transform: translateX(-50%);
  z-index: 24; padding: 7px 16px; border-radius: 999px;
  background: rgba(8,18,28,0.68); border: 1px solid rgba(255,255,255,0.12);
  color: #c7e9ff; font-size: 10px; font-weight: 800; letter-spacing: 0.12em;
  opacity: 0; transition: opacity 0.16s ease; pointer-events: none;
  backdrop-filter: blur(12px); white-space: nowrap;
}
#status.show { opacity: 1; }
#status.warn { color: #ffd2a2; border-color: rgba(255,174,99,0.34); }
#status.good { color: #9df5c9; border-color: rgba(103,255,183,0.28); }
#status.info { color: #c7e9ff; }

#sectorDelta {
  position: fixed; top: 156px; left: 50%; transform: translateX(-50%);
  z-index: 23; padding: 6px 13px; border-radius: 8px;
  background: rgba(6, 15, 24, 0.72); border: 1px solid var(--line);
  color: var(--muted); font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums;
  opacity: 0; transition: opacity 0.15s ease; pointer-events: none; backdrop-filter: blur(10px);
}
#sectorDelta.show { opacity: 1; }
#sectorDelta.fast { color: var(--green); border-color: rgba(126,240,176,0.35); }
#sectorDelta.slow { color: var(--danger); border-color: rgba(255,143,143,0.35); }
#sectorDelta.neutral { color: var(--cyan); }

#countdown {
  position: fixed; left: 50%; top: 34%; transform: translate(-50%, -50%);
  z-index: 30; color: #fff; font-size: 88px; font-weight: 900; letter-spacing: 0.04em;
  text-shadow: 0 6px 36px rgba(0,0,0,0.55), 0 0 30px rgba(135,217,255,0.35);
  opacity: 0; pointer-events: none; transition: opacity 0.14s ease;
}
#countdown.show { opacity: 1; }

/* ---------------- 小地图 ---------------- */
#minimap {
  position: fixed; right: 20px; bottom: 20px; z-index: 20;
  width: 172px; height: 172px; padding: 9px;
  border: 1px solid var(--line); border-radius: 18px;
  background: linear-gradient(150deg, rgba(11,26,40,0.80), rgba(8,18,28,0.52));
  box-shadow: 0 18px 44px rgba(0,0,0,0.28); backdrop-filter: blur(14px);
  user-select: none; pointer-events: none;
}
#minimapCanvas { display: block; width: 100%; height: 100%; }
.minimap-label { position: absolute; top: 10px; left: 13px; color: var(--faint); font-size: 8px; font-weight: 800; letter-spacing: 0.16em; }

/* ---------------- 工具按钮 ---------------- */
#toolbar { position: fixed; top: 72px; right: 20px; z-index: 22; display: flex; gap: 8px; }
#toolbar button {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line);
  background: rgba(8,19,29,0.62); color: rgba(239,248,255,0.74);
  font-family: inherit; font-size: 15px; cursor: pointer; backdrop-filter: blur(12px);
  transition: color 0.15s ease, border-color 0.15s ease;
}
#toolbar button:hover { color: #fff; border-color: rgba(135,217,255,0.36); }

/* ---------------- 操作提示 ---------------- */
#help {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  z-index: 20; white-space: nowrap; padding: 9px 16px; border-radius: 999px;
  background: rgba(7,16,25,0.60); border: 1px solid rgba(255,255,255,0.10);
  color: rgba(239,248,255,0.72); font-size: 10.5px; letter-spacing: 0.02em;
  backdrop-filter: blur(12px); user-select: none;
}
#help kbd {
  display: inline-block; min-width: 20px; padding: 1px 5px; margin: 0 2px;
  border-radius: 5px; background: rgba(255,255,255,0.11); border: 1px solid rgba(255,255,255,0.17);
  color: #fff; font-family: inherit; font-size: 9.5px; text-align: center;
}

/* ---------------- 触屏 ---------------- */
#touchControls {
  position: fixed; inset: auto 0 0 0; z-index: 26;
  display: none; align-items: flex-end; justify-content: space-between;
  padding: 0 16px 14px; pointer-events: none;
}
#touchControls.is-on { display: flex; }
.touch-cluster { display: grid; gap: 8px; align-items: end; pointer-events: auto; }
.touch-left { grid-template-columns: repeat(2, 64px); }
.touch-right { grid-template-columns: repeat(2, 64px); grid-template-rows: repeat(2, 54px); }
.touch-btn {
  width: 64px; height: 54px; border-radius: 17px; border: 1px solid rgba(255,255,255,0.20);
  background: rgba(8,20,32,0.68); color: rgba(255,255,255,0.92);
  font-family: inherit; font-size: 14px; font-weight: 800; backdrop-filter: blur(10px);
  box-shadow: 0 10px 26px rgba(0,0,0,0.30); touch-action: none; user-select: none;
}
.touch-left .touch-btn { height: 64px; font-size: 23px; }
.touch-right .touch-btn { height: 54px; }
.touch-btn.is-active { background: rgba(92,192,255,0.32); border-color: rgba(135,217,255,0.65); transform: scale(0.96); }
.touch-btn.mini { width: 44px; height: 44px; border-radius: 13px; font-size: 12px; }
.touch-btn.pedal { font-size: 12px; letter-spacing: 0.04em; }
.touch-btn.nitro { color: var(--gold); }
.touch-right .touch-btn:nth-child(1) { border-color: rgba(255, 209, 102, 0.32); }
.touch-right .touch-btn:nth-child(4) { border-color: rgba(126, 240, 176, 0.34); }

/* 手机：左侧圆形方向盘 + 右侧大油门圆钮 */
#touchControls { padding: 0 10px 12px; gap: 6px; }
.steer-wheel {
  position: relative; flex: 0 0 149px; width: 149px; height: 149px; border-radius: 50%;
  pointer-events: auto; touch-action: none; user-select: none;
  border: 1px solid rgba(216, 226, 214, 0.24);
  background: radial-gradient(circle, rgba(255,255,255,0.055), rgba(8,16,22,0.25) 65%, rgba(8,16,22,0.50));
  transition: border-color 0.15s ease;
  touch-action: none;
}
.steer-wheel::before {
  content: ''; position: absolute; inset: 33px; border-radius: 50%;
  border: 1px solid rgba(196, 228, 240, 0.15);
}
.steer-knob {
  position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px 0 0 -29px;
  border-radius: 50%;
  border: 1px solid rgba(126, 220, 255, 0.55);
  background: rgba(76, 190, 235, 0.18);
  box-shadow: 0 0 16px rgba(76, 190, 235, 0.13);
  pointer-events: none; will-change: transform;
}
.steer-wheel.is-active { border-color: rgba(126, 220, 255, 0.70); }
.steer-label { position: absolute; left: 50%; bottom: 7px; transform: translateX(-50%); color: var(--faint); font-size: 7px; letter-spacing: 0.12em; pointer-events: none; white-space: nowrap; }

.drive-cluster { position: relative; flex: 0 0 209px; width: 209px; height: 207px; pointer-events: none; }
.drive-btn, .throttle-btn {
  position: absolute; border-radius: 50%; border: 1px solid rgba(255,255,255,0.22);
  color: rgba(255,255,255,0.94); font-family: inherit; font-weight: 900;
  pointer-events: auto; touch-action: none; user-select: none;
  background: radial-gradient(circle at 35% 25%, rgba(45, 80, 104, 0.95), rgba(7, 20, 32, 0.92));
  box-shadow: 0 10px 26px rgba(0,0,0,0.34), inset 0 0 18px rgba(130, 215, 255, 0.08);
  backdrop-filter: blur(10px);
}
.drive-btn { width: 72px; height: 72px; font-size: 12px; letter-spacing: 0.02em; }
.drive-btn.drift { left: 35px; top: 33px; border-color: rgba(255, 209, 102, 0.42); color: #ffe49a; }
.drive-btn.brake { left: 0; bottom: 0; border-color: rgba(255, 120, 90, 0.38); }
.drive-btn.nitro { left: 109px; top: 0; width: 74px; height: 74px; color: var(--gold); border-color: rgba(255, 209, 102, 0.45); }
.throttle-btn {
  right: 0; bottom: 0; width: 125px; height: 125px;
  border-color: rgba(126, 240, 176, 0.48);
  background: radial-gradient(circle at 34% 25%, rgba(126, 240, 176, 0.55), rgba(17, 100, 74, 0.92) 55%, rgba(5, 38, 30, 0.98));
  color: #f1fff7; font-size: 18px; letter-spacing: 0.06em;
  box-shadow: 0 12px 30px rgba(0,0,0,0.38), 0 0 26px rgba(87, 255, 177, 0.16);
}
.drive-btn.is-active, .throttle-btn.is-active { transform: scale(0.93); filter: brightness(1.25); }
.steer-wheel.is-active .steer-knob { box-shadow: 0 0 28px rgba(126, 220, 255, 0.48); }

/* ---------------- 菜单 / 覆盖层 ---------------- */
.overlay {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center; padding: 24px;
  background: radial-gradient(circle at 24% 38%, rgba(10, 38, 58, 0.60), rgba(4, 10, 16, 0.82) 68%);
  backdrop-filter: blur(2px);
}
#menuOverlay {
  place-items: center start;
  padding-left: max(24px, 6vw);
  background: linear-gradient(90deg, rgba(4, 10, 16, 0.90) 0%, rgba(4, 10, 16, 0.62) 44%, rgba(4, 10, 16, 0.26) 100%);
}
.overlay.hidden { display: none; }
.menu-card {
  width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  padding: 30px 32px 24px;
  border: 1px solid var(--line); border-radius: 24px;
  background: linear-gradient(150deg, rgba(11, 30, 46, 0.94), rgba(7, 16, 26, 0.90));
  box-shadow: 0 40px 100px rgba(0,0,0,0.5);
}
.menu-kicker, .panel-kicker { color: var(--cyan); font-size: 9px; font-weight: 800; letter-spacing: 0.20em; }
.menu-card h1 { margin: 8px 0 6px; font-size: 42px; letter-spacing: 0.06em; line-height: 1.05; }
.menu-lead { color: var(--muted); font-size: 12px; line-height: 1.8; margin-bottom: 20px; }
.mode-select { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.difficulty-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 10px; color: var(--faint); font-size: 8.5px; letter-spacing: 0.08em; }
.difficulty-options { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
.difficulty-options .chip { padding: 4px 7px; font-size: 8px; }
.difficulty-options .chip.is-active { color: var(--gold); border-color: rgba(255,209,102,0.45); background: rgba(255,209,102,0.08); }
.map-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 2px 0 7px; color: var(--faint); font-size: 8.5px; letter-spacing: 0.10em; text-transform: uppercase; }
.map-head b { color: var(--cyan); font-size: 9px; font-weight: 700; letter-spacing: 0.04em; text-transform: none; }
.map-cards { display: flex; gap: 8px; overflow-x: auto; padding: 1px 1px 7px; margin-bottom: 13px; scrollbar-width: thin; scrollbar-color: rgba(125,210,255,0.3) transparent; }
.map-cards::-webkit-scrollbar { height: 5px; }
.map-cards::-webkit-scrollbar-thumb { background: rgba(125,210,255,0.28); border-radius: 4px; }
.map-card {
  flex: 0 0 142px; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  padding: 10px 11px 9px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(255,255,255,0.028); color: var(--ink); font-family: inherit; text-align: left; cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}
.map-card:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--map-accent) 55%, transparent); }
.map-card strong { font-size: 12px; letter-spacing: 0.02em; }
.map-card span { color: var(--muted); font-size: 8px; line-height: 1.4; }
.map-card em { color: var(--map-accent); font-size: 8px; font-style: normal; letter-spacing: 0.04em; }
.map-card.is-active { border-color: var(--map-accent); background: color-mix(in srgb, var(--map-accent) 13%, rgba(255,255,255,0.02)); box-shadow: 0 0 0 1px color-mix(in srgb, var(--map-accent) 26%, transparent) inset; }
@media (min-width: 761px) {
  .map-cards { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); overflow: visible; padding-bottom: 0; }
  .map-card { min-width: 0; padding: 8px 8px 7px; }
  .map-card strong { font-size: 11px; }
  .map-card span { display: none; }
  .map-card em { font-size: 7.5px; }
}

.vehicle-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.vehicle-card {
  min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 8px 8px 7px; border-radius: 11px; border: 1px solid var(--line);
  background: rgba(255,255,255,0.028); color: var(--ink); font-family: inherit; text-align: left; cursor: pointer;
}
.vehicle-card strong { font-size: 11px; }
.vehicle-card span { color: var(--muted); font-size: 7.5px; line-height: 1.35; }
.vehicle-card em { color: var(--vehicle-color); font-size: 7.5px; font-style: normal; }
.vehicle-card.is-active { border-color: var(--vehicle-color); background: color-mix(in srgb, var(--vehicle-color) 13%, rgba(255,255,255,0.02)); }
.vehicle-card.is-locked { opacity: 0.62; }
.vehicle-card.is-locked::after { content: 'LOCK'; color: var(--faint); font-size: 7px; letter-spacing: 0.12em; }
.daily-challenge { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 10px; padding: 10px 12px; border: 1px solid rgba(255,209,102,0.28); border-radius: 12px; background: linear-gradient(90deg, rgba(255,209,102,0.08), rgba(255,140,60,0.035)); color: var(--ink); font-family: inherit; cursor: pointer; text-align: left; }
.daily-challenge strong { color: var(--gold); font-size: 11px; letter-spacing: 0.04em; white-space: nowrap; }
.daily-challenge span { color: var(--muted); font-size: 8px; line-height: 1.4; text-align: right; }
body.challenge-mode .daily-challenge { border-color: rgba(255,209,102,0.55); box-shadow: 0 0 18px rgba(255,180,60,0.08) inset; }
body.challenge-mode .mode-card:not([data-mode="timeattack"]) { opacity: 0.45; cursor: not-allowed; }
.menu-progress { display: flex; align-items: center; gap: 10px; margin: 0 0 13px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,0.022); }
.level-badge { color: var(--gold); font-size: 9px; font-weight: 800; white-space: nowrap; }
.level-badge b { font-size: 15px; }
.xp-wrap { flex: 1; min-width: 0; }
.xp-track { height: 4px; border-radius: 999px; background: rgba(255,255,255,0.10); overflow: hidden; }
.xp-track i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #4cc9f0, #7be0ff); }
.xp-wrap span { display: block; margin-top: 3px; color: var(--faint); font-size: 7px; }
.credits { color: var(--faint); font-size: 8px; white-space: nowrap; }
.credits b { color: var(--gold); font-size: 11px; }
.mode-card {
  text-align: left; padding: 14px 15px; border-radius: 14px;
  border: 1px solid var(--line); background: rgba(255,255,255,0.035);
  color: var(--ink); font-family: inherit; cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.mode-card:hover { transform: translateY(-1px); border-color: rgba(135,217,255,0.32); }
.mode-card.is-active { border-color: rgba(135,217,255,0.65); background: rgba(76, 186, 255, 0.12); box-shadow: inset 0 0 0 1px rgba(135,217,255,0.15); }
.mode-card strong { display: block; font-size: 15px; margin-bottom: 5px; }
.mode-card span { color: var(--muted); font-size: 10px; line-height: 1.5; }
.primary-btn {
  width: 100%; min-height: 48px; border: 0; border-radius: 13px; cursor: pointer;
  background: linear-gradient(135deg, #39b9ee, #62e0c1); color: #041018;
  font-family: inherit; font-size: 15px; font-weight: 900; letter-spacing: 0.08em;
  box-shadow: 0 14px 30px rgba(57,185,238,0.22);
}
.primary-btn:hover { filter: brightness(1.06); }
.ghost-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 40px; padding: 0 16px; border-radius: 11px; cursor: pointer;
  border: 1px solid var(--line); background: rgba(255,255,255,0.04);
  color: var(--ink); font-family: inherit; font-size: 11px; font-weight: 700;
  text-decoration: none;
}
.ghost-btn:hover { border-color: rgba(135,217,255,0.35); color: #fff; }
.menu-record { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 15px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,0.025); }
.menu-record > div:first-child { display: flex; flex-direction: column; gap: 3px; }
.menu-record span { color: var(--faint); font-size: 8.5px; letter-spacing: 0.08em; }
.menu-record b { color: var(--gold); font-size: 17px; font-variant-numeric: tabular-nums; }
.menu-medals { display: flex; gap: 7px; }
.medal { display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--faint); font-size: 9px; }
.medal i { font-style: normal; font-size: 8px; }
.medal.gold.earned { color: #ffe49a; border-color: rgba(255,209,102,0.5); background: rgba(255,209,102,0.10); }
.medal.silver.earned { color: #dfeaf2; border-color: rgba(223,234,242,0.45); background: rgba(223,234,242,0.08); }
.medal.bronze.earned { color: #ffb98a; border-color: rgba(255,185,138,0.45); background: rgba(255,185,138,0.08); }
.menu-record-medals { justify-content: center; margin-top: 10px; padding: 8px 10px; }
.menu-record-medals > div:first-child { flex-direction: row; justify-content: center; gap: 7px; }
.menu-links { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 7px 17px; margin-top: 14px; }
.menu-links a, .menu-link-btn {
  color: var(--muted); font-family: inherit; font-size: 10.5px; text-decoration: none;
  background: none; border: 0; border-bottom: 1px solid transparent; padding: 0; cursor: pointer;
}
.menu-links a:hover, .menu-link-btn:hover { color: var(--cyan); border-color: rgba(135,217,255,0.4); }
.menu-link-btn.is-active { color: var(--gold); }
.menu-driver-stats { color: var(--faint); font-size: 9.5px; white-space: nowrap; }
.menu-driver-stats b { color: var(--gold); font-weight: 800; font-variant-numeric: tabular-nums; }
.menu-tools { display: none; }

/* 暂停 / 结算 */
.panel-card, .results-card {
  width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  padding: 28px 30px 24px;
  border: 1px solid var(--line); border-radius: 22px;
  background: linear-gradient(150deg, rgba(11,30,46,0.95), rgba(7,16,26,0.92));
  box-shadow: 0 40px 100px rgba(0,0,0,0.5);
}
.panel-card h2, .results-card h2 { margin: 6px 0 4px; font-size: 28px; letter-spacing: 0.04em; }
.panel-sub { color: var(--muted); font-size: 11px; margin-bottom: 16px; }
.panel-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.panel-actions .primary-btn { width: auto; flex: 1 1 170px; padding: 0 18px; }
.panel-actions .ghost-btn { flex: 1 1 120px; }
.quick-settings { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 16px; padding-top: 15px; border-top: 1px solid var(--line); }
.chip {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 32px; padding: 0 11px; border-radius: 8px; border: 1px solid var(--line);
  background: rgba(255,255,255,0.035); color: var(--muted);
  font-family: inherit; font-size: 10px; text-decoration: none; cursor: pointer;
}
.chip:hover { color: var(--cyan); border-color: rgba(135,217,255,0.3); }
#leaderboardOverlay { z-index: 85; }
.leaderboard-card { width: min(520px, 100%); }
.leaderboard-map { margin: -2px 0 2px; color: var(--ink); font-size: 12px; font-weight: 700; letter-spacing: 0.04em; }
.leaderboard-sources { display: flex; gap: 8px; margin: 8px 0 2px; }
.leaderboard-sources .chip.is-active { color: var(--gold); border-color: rgba(255,209,102,0.46); background: rgba(255,209,102,0.10); }
.leaderboard-notice { margin: 4px 0 8px; padding: 7px 10px; border-radius: 9px; border: 1px solid rgba(255,209,102,0.18); background: rgba(255,209,102,0.05); color: var(--muted); font-size: 9px; line-height: 1.5; }
.leaderboard-tabs { display: flex; gap: 8px; margin: 6px 0 12px; }
.leaderboard-tabs .chip.is-active { color: var(--cyan); border-color: rgba(135,217,255,0.5); background: rgba(87,205,255,0.10); }
.leaderboard-table td.name { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.leaderboard-table td.name small { color: var(--faint); font-size: 8px; }
.leaderboard-table td.empty { color: var(--faint); text-align: center; padding: 22px 10px; }
.leaderboard-note { margin-top: 12px; color: var(--faint); font-size: 9px; text-align: center; }
body.leaderboard-open #boostFx { display: none !important; }
.result-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.result-stats > div { padding: 11px 12px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,0.025); }
.result-stats span { display: block; color: var(--faint); font-size: 8.5px; margin-bottom: 4px; }
.result-stats b { font-size: 15px; font-variant-numeric: tabular-nums; }
.result-medal.gold { color: var(--gold); }
.result-medal.silver { color: #dfeaf2; }
.result-medal.bronze { color: #ffb98a; }
.table-wrap { max-height: 240px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
.results-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.results-table th { position: sticky; top: 0; background: rgba(9,22,34,0.98); color: var(--faint); font-size: 8.5px; letter-spacing: 0.08em; text-align: left; padding: 9px 11px; }
.results-table td { padding: 9px 11px; border-top: 1px solid rgba(255,255,255,0.06); }
.results-table tr.is-player td { background: rgba(87,205,255,0.09); color: #fff; }
.results-table td.pos { color: var(--gold); font-weight: 800; }
.results-table td.name { display: flex; align-items: center; gap: 7px; }
.results-table .dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.results-table small { color: var(--faint); font-size: 8px; }

/* ---------------- 状态小提示 ---------------- */
.toast {
  position: fixed; left: 50%; bottom: 78px; transform: translateX(-50%);
  z-index: 70; padding: 8px 14px; border-radius: 999px;
  background: rgba(6,15,24,0.82); border: 1px solid var(--line);
  color: var(--ink); font-size: 11px; font-weight: 700; backdrop-filter: blur(12px);
  pointer-events: none;
}
.toast[hidden] { display: none; }

/* ---------------- 加载 / 错误 ---------------- */
#loading, #errorBox {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-items: center; padding: 24px; text-align: center;
  background: radial-gradient(circle at 50% 42%, #10263a 0%, #081018 68%);
  color: #dbeeff;
}
#loading.hidden, #errorBox.hidden { display: none; }
.loader-card { display: flex; flex-direction: column; align-items: center; gap: 16px; color: rgba(235,247,255,0.62); font-size: 11px; letter-spacing: 0.16em; }
.loader-ring { width: 44px; height: 44px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.10); border-top-color: #71d6ff; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-card { max-width: 560px; }
#errorBox h2 { color: var(--gold); margin-bottom: 12px; font-size: 21px; }
#errorBox p { color: rgba(255,255,255,0.62); font-size: 12px; line-height: 1.9; margin-bottom: 8px; }
#errorBox code { color: #9adfff; font-family: Consolas, monospace; background: rgba(255,255,255,0.06); padding: 1px 5px; border-radius: 4px; }

/* ---------------- 状态组合 ---------------- */
body.menu-open #hud,
body.menu-open #toolbar,
body.menu-open #minimap,
body.menu-open #help,
body.menu-open #touchControls,
body.menu-open #startLightsHUD,
body.menu-open #status,
body.menu-open #sectorDelta,
body.menu-open #countdown { display: none !important; }
body.paused #help, body.results-open #help { display: none; }
body.paused #touchControls, body.results-open #touchControls { display: none !important; }
body.paused #startLightsHUD, body.results-open #startLightsHUD,
body.paused #status, body.results-open #status,
body.paused #sectorDelta, body.results-open #sectorDelta,
body.paused #countdown, body.results-open #countdown { display: none !important; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 900px) {
  #hud { width: 256px; }
  #minimap { width: 142px; height: 142px; right: 14px; bottom: 14px; }
  #help { display: none; }
  #touchControls { padding-bottom: 12px; }
  .menu-card { padding: 24px 22px 20px; }
  .menu-card h1 { font-size: 34px; }
  #menuOverlay { place-items: center; padding: 18px; background: radial-gradient(circle at 50% 40%, rgba(10,38,58,0.62), rgba(4,10,16,0.86) 70%); }
}
@media (max-width: 760px) {
  #topbar { height: 52px; padding: 8px 12px; justify-content: flex-end; }
  .brand-mini { display: none; }
  .brand-copy-mini strong { font-size: 12px; }
  .brand-copy-mini small { font-size: 7px; }
  .account-badge { max-width: 122px; font-size: 10px; }
  #hud { top: 60px; left: 12px; width: 226px; padding: 11px 13px 11px; border-radius: 15px; }
  .hud-title { font-size: 13px; }
  .hud-sub { font-size: 7.5px; margin-bottom: 7px; }
  #speedVal { font-size: 33px; }
  .hud-stats { gap: 4px 8px; margin-top: 7px; }
  .stat span { font-size: 7.8px; }
  .stat b { font-size: 9.8px; }
  .nitro-line { margin-top: 7px; }
  #startLightsHUD { display: none; }
  #status { top: 280px; font-size: 9px; padding: 6px 12px; }
  #sectorDelta { top: 318px; font-size: 11px; }
  #countdown { top: 42%; font-size: 62px; }
  #toolbar { top: 60px; right: 12px; }
  #toolbar button { width: 32px; height: 32px; font-size: 13px; }
  #minimap { width: 116px; height: 116px; bottom: 84px; }
  .mode-select { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
  .mode-card { padding: 9px 8px; border-radius: 11px; }
  .mode-card strong { font-size: 11px; }
  .mode-card span { font-size: 7.5px; line-height: 1.35; }
  .vehicle-cards { display: flex; overflow-x: auto; padding-bottom: 5px; }
  .vehicle-card { flex: 0 0 128px; }
  .menu-card h1 { font-size: 29px; }
  .menu-card { padding: 20px 17px 18px; }
  .menu-lead { font-size: 11px; }
  .result-stats { grid-template-columns: 1fr 1fr; }
  .results-table th, .results-table td { padding: 7px 8px; }
  .panel-card, .results-card { padding: 22px 18px 18px; }
  .panel-card h2, .results-card h2 { font-size: 23px; }
  .touch-left { grid-template-columns: repeat(2, 72px); gap: 8px; }
  .touch-right { grid-template-columns: repeat(2, 72px); grid-template-rows: repeat(2, 60px); gap: 8px; }
  .touch-left .touch-btn { width: 72px; height: 72px; font-size: 24px; }
  .touch-right .touch-btn { width: 72px; height: 60px; font-size: 13px; }
}
@media (max-width: 560px) {
  #minimap { display: none; }
  .touch-left { grid-template-columns: repeat(2, 68px); gap: 7px; }
  .touch-right { grid-template-columns: repeat(2, 68px); grid-template-rows: repeat(2, 58px); gap: 7px; }
  .touch-left .touch-btn { width: 68px; height: 68px; font-size: 23px; }
  .touch-right .touch-btn { width: 68px; height: 58px; font-size: 12px; }
  #touchControls { padding-left: 10px; padding-right: 10px; }
  .toast { bottom: 240px; max-width: calc(100% - 40px); white-space: normal; text-align: center; }
}

/* 矮屏手机：倒计时下移，避免压住左上 HUD */
@media (max-width: 760px) and (max-height: 700px) {
  #countdown { top: 58%; }
}
@media (max-width: 380px) {
  #hud { width: 208px; padding: 10px 11px; }
  #speedVal { font-size: 29px; }
  .hud-stats { gap: 3px 6px; }
  .stat span { font-size: 7.2px; }
  .stat b { font-size: 9.2px; }
  #touchControls { padding-left: 6px; padding-right: 6px; padding-bottom: 8px; gap: 6px; }
  .steer-wheel { flex-basis: 120px; width: 120px; height: 120px; }
  .steer-knob { width: 50px; height: 50px; margin: -25px 0 0 -25px; }
  .steer-wheel::before { inset: 27px; }
  .drive-cluster { flex-basis: 180px; width: 180px; height: 178px; }
  .drive-btn { width: 62px; height: 62px; font-size: 10px; }
  .drive-btn.drift { left: 31px; top: 29px; }
  .drive-btn.brake { left: 0; bottom: 0; }
  .drive-btn.nitro { left: 94px; top: 0; width: 64px; height: 64px; }
  .throttle-btn { width: 108px; height: 108px; font-size: 15px; }
  .toast { bottom: 210px; }
}
@media (max-height: 560px) {
  #hud { top: 54px; left: 10px; width: 240px; padding: 9px 11px; }
  .hud-sub { display: none; }
  .hud-title { font-size: 13px; }
  #speedVal { font-size: 30px; }
  .hud-stats { margin-top: 5px; }
  .nitro-line { margin-top: 5px; }
  .lap-progress { margin-top: 6px; }
  #startLightsHUD { top: 10px; }
  #status { top: 46px; }
  #sectorDelta { top: 82px; }
  #countdown { font-size: 56px; top: 42%; }
  #minimap { width: 94px; height: 94px; right: 10px; bottom: auto; top: 50px; padding: 6px; border-radius: 12px; }
  #help { display: none; }
  #toolbar { top: 150px; right: 10px; }
  #toolbar button { width: 30px; height: 30px; }
  #touchControls { padding: 0 16px 8px; }
  .steer-wheel { flex-basis: 126px; width: 126px; height: 126px; }
  .steer-knob { width: 52px; height: 52px; margin: -26px 0 0 -26px; }
  .steer-wheel::before { inset: 28px; }
  .drive-cluster { flex-basis: 168px; width: 168px; height: 168px; }
  .drive-btn { width: 60px; height: 60px; font-size: 10px; }
  .drive-btn.drift { left: 27px; top: 27px; }
  .drive-btn.brake { left: 0; bottom: 0; }
  .drive-btn.nitro { left: 84px; top: 0; width: 62px; height: 62px; }
  .throttle-btn { width: 100px; height: 100px; font-size: 14px; }
  .toast { bottom: 180px; max-width: calc(100% - 140px); white-space: normal; text-align: center; }
  .menu-card { max-height: 92vh; overflow: auto; }
}
@media (min-height: 561px) {
  body.touch-mode #minimap { bottom: 92px; }
}
/* iPad / 平板：小地图固定在右上角，避开底部触屏油门区 */
@media (min-width: 600px) and (min-height: 600px) and (any-pointer: coarse) {
  #minimap, body.touch-mode #minimap {
    top: 122px;
    right: 18px;
    bottom: auto;
    width: 150px;
    height: 150px;
  }
}


