/* ================= Roadster 逃离收费站 ================= */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #0a1220;
  color: #eaf2ff;
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, sans-serif;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

#scene { display: block; width: 100%; height: 100%; }

kbd {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 5px;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.22);
  font-family: inherit; font-size: .92em;
}

/* ================= HUD ================= */
#hud {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 10;
}

.hud-top {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 18px 20px;
}

.panel {
  background: rgba(8, 18, 32, .55);
  border: 1px solid rgba(120, 200, 255, .18);
  border-radius: 14px;
  padding: 10px 16px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .3);
}

.score-main {
  font-size: 34px; font-weight: 800; line-height: 1.05;
  letter-spacing: .5px;
  color: #ffffff;
  text-shadow: 0 0 22px rgba(90, 200, 255, .55);
  font-variant-numeric: tabular-nums;
}
.score-sub { margin-top: 3px; font-size: 12px; color: #9fc0dd; letter-spacing: .4px; }
.score-sub b { color: #7fe0ff; font-weight: 700; }

.speed-panel { text-align: right; min-width: 108px; }
.speed-num {
  font-size: 30px; font-weight: 800; line-height: 1;
  color: #ffd166;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 20px rgba(255, 190, 60, .5);
}
.speed-unit { font-size: 11px; color: #9fc0dd; letter-spacing: 2px; margin-top: 3px; }

/* ---- 仪表组（冷气 + 高度） ---- */
.gauges {
  position: absolute; right: 22px; top: 50%;
  transform: translateY(-50%);
  display: flex; align-items: flex-start; gap: 14px;
}
.gauge {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.gauge-track {
  position: relative;
  width: 12px; height: 240px;
  border-radius: 8px;
  background: rgba(8, 18, 32, .6);
  border: 1px solid rgba(120, 200, 255, .2);
  overflow: hidden;
  backdrop-filter: blur(6px);
}
.gauge-safe {
  position: absolute; left: 0; right: 0;
  background: linear-gradient(180deg, rgba(60, 230, 170, .35), rgba(60, 230, 170, .6));
}
.gauge-danger {
  position: absolute; left: 0; right: 0;
  background: repeating-linear-gradient(45deg, rgba(255,80,90,.75) 0 5px, rgba(255,80,90,.35) 5px 10px);
}
.gauge-marker {
  position: absolute; left: -4px; right: -4px; height: 4px;
  border-radius: 3px;
  background: #fff;
  box-shadow: 0 0 12px rgba(255,255,255,.9), 0 0 4px #fff;
  transition: bottom .04s linear;
}
.gauge-caption { font-size: 10px; color: #9fc0dd; letter-spacing: 2px; white-space: nowrap; }
.gauge-caption.low { color: #ffb06b; }

/* ---- 冷气余量（只减不增） ---- */
.gas-track { width: 14px; }
.gas-fill {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 100%;
  background: linear-gradient(180deg, #cdf3ff, #4cc4ff 45%, #2f9ae0);
  box-shadow: 0 0 14px rgba(90, 200, 255, .55), inset 0 1px 0 rgba(255,255,255,.5);
  transition: height .08s linear, background .25s;
}
.gas-fill.low {
  background: linear-gradient(180deg, #ffd89a, #ff9a3c 50%, #f0652a);
  box-shadow: 0 0 16px rgba(255, 150, 60, .7);
}
.gas-fill.empty {
  background: rgba(120, 60, 50, .55);
  box-shadow: none;
}
.gas-track.low {
  border-color: rgba(255, 150, 80, .55);
  animation: gasPulse .62s ease-in-out infinite alternate;
}
@keyframes gasPulse {
  from { box-shadow: 0 0 0 rgba(255, 140, 60, 0); }
  to   { box-shadow: 0 0 20px rgba(255, 140, 60, .6); }
}

/* ---- 底部距离 ---- */
.hud-bottom {
  position: absolute; left: 0; right: 0; bottom: 26px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.dist-row {
  display: flex; align-items: baseline; gap: 10px;
  background: rgba(8, 18, 32, .55);
  border: 1px solid rgba(120, 200, 255, .18);
  border-radius: 999px;
  padding: 8px 22px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.dist-label { font-size: 12px; color: #9fc0dd; letter-spacing: 1px; }
.dist-val { font-size: 15px; color: #eaf2ff; font-variant-numeric: tabular-nums; }
.dist-val b { font-size: 24px; font-weight: 800; color: #7fe0ff; }

.prompt {
  font-size: 13px; letter-spacing: .6px;
  color: #cfe6ff;
  background: rgba(8, 18, 32, .5);
  border: 1px solid rgba(120, 200, 255, .16);
  padding: 7px 18px; border-radius: 999px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: .85;
  transition: opacity .2s, color .2s, transform .2s;
}
.prompt.hot {
  opacity: 1;
  color: #06121f;
  background: linear-gradient(90deg, #6ff0c0, #7fe0ff);
  border-color: transparent;
  font-weight: 800;
  transform: scale(1.06);
  box-shadow: 0 0 26px rgba(110, 240, 190, .6);
  animation: pulse .55s ease-in-out infinite alternate;
}
@keyframes pulse { from { transform: scale(1.02); } to { transform: scale(1.1); } }
.prompt.dry {
  opacity: 1;
  color: #ffd9c4;
  background: rgba(70, 26, 12, .72);
  border-color: rgba(255, 130, 70, .45);
  font-weight: 700;
  box-shadow: 0 0 22px rgba(255, 120, 60, .28);
}

/* ---- Toast ---- */
.toast {
  position: absolute; left: 50%; top: 22%;
  transform: translate(-50%, 0) scale(.9);
  font-size: 30px; font-weight: 900; letter-spacing: 3px;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  text-shadow: 0 4px 24px rgba(0,0,0,.5);
}
.toast.show { animation: toastPop 1s ease-out forwards; }
@keyframes toastPop {
  0%   { opacity: 0; transform: translate(-50%, 14px) scale(.85); }
  18%  { opacity: 1; transform: translate(-50%, 0) scale(1.08); }
  70%  { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -26px) scale(1); }
}

/* ================= 遮罩层 ================= */
.overlay {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  padding: 22px;
  background: radial-gradient(120% 90% at 50% 20%, rgba(16, 40, 70, .72), rgba(4, 8, 16, .9));
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  animation: fadeIn .35s ease both;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.hidden { display: none !important; }

.card {
  width: min(560px, 100%);
  max-height: 100%;
  overflow-y: auto;
  background: linear-gradient(165deg, rgba(20, 36, 60, .96), rgba(9, 17, 30, .98));
  border: 1px solid rgba(120, 200, 255, .22);
  border-radius: 22px;
  padding: 30px 30px 26px;
  text-align: center;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .65), inset 0 1px 0 rgba(255,255,255,.06);
  animation: cardIn .42s cubic-bezier(.2, .9, .25, 1.1) both;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(22px) scale(.96); } to { opacity: 1; transform: none; } }

.tag {
  display: inline-block;
  font-size: 10.5px; letter-spacing: 2.4px;
  color: #7fe0ff;
  border: 1px solid rgba(127, 224, 255, .35);
  border-radius: 999px;
  padding: 5px 14px;
  margin-bottom: 18px;
}

.card h1 {
  font-size: clamp(30px, 7vw, 44px);
  line-height: 1.08;
  font-weight: 900;
  letter-spacing: 1px;
  margin-bottom: 14px;
}
.card h1 span {
  background: linear-gradient(100deg, #ff5a6e 0%, #ff9d4d 55%, #ffd166 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 26px rgba(255, 110, 90, .35));
}

.lead { font-size: 14.5px; color: #bcd4ec; line-height: 1.7; margin-bottom: 18px; }

.rules {
  list-style: none; text-align: left;
  display: flex; flex-direction: column; gap: 9px;
  margin: 0 auto 22px;
  max-width: 430px;
}
.rules li {
  position: relative;
  font-size: 13.5px; line-height: 1.6;
  color: #cfe0f2;
  padding-left: 20px;
}
.rules li::before {
  content: ""; position: absolute; left: 4px; top: 8px;
  width: 7px; height: 7px; border-radius: 50%;
  background: #7fe0ff; box-shadow: 0 0 10px #7fe0ff;
}
.rules b { color: #ffffff; }
.rules .bad { color: #ff7a86; font-weight: 700; }
.rules .warn { color: #ffc46b; }
.cyan { color: #7fe0ff; }

.btn {
  appearance: none; border: 0; cursor: pointer;
  font-family: inherit;
  font-size: 17px; font-weight: 800; letter-spacing: 2px;
  color: #04121e;
  padding: 15px 44px;
  border-radius: 999px;
  background: linear-gradient(100deg, #6ff0c0, #7fe0ff 55%, #9fc0ff);
  box-shadow: 0 12px 34px rgba(90, 200, 255, .38);
  transition: transform .16s ease, box-shadow .16s ease, filter .16s;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 18px 42px rgba(90, 200, 255, .5); filter: brightness(1.06); }
.btn:active { transform: translateY(0) scale(.98); }

.hint { margin-top: 16px; font-size: 12px; color: #8fadc8; letter-spacing: .4px; }

/* ---- 结算 ---- */
.over-card { border-color: rgba(255, 120, 130, .28); }
.over-reason {
  font-size: clamp(24px, 6vw, 32px); font-weight: 900; letter-spacing: 2px;
  color: #ff6a78;
  text-shadow: 0 0 30px rgba(255, 80, 90, .45);
  margin-bottom: 6px;
}
.over-reason.win { color: #6ff0c0; text-shadow: 0 0 30px rgba(110, 240, 190, .45); }
.over-desc { font-size: 13px; color: #a9c2da; line-height: 1.6; margin-bottom: 18px; }

.over-score { margin-bottom: 18px; }
.over-score .big {
  font-size: 60px; font-weight: 900; line-height: 1;
  color: #fff;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 34px rgba(120, 220, 255, .55);
}
.over-score .small { font-size: 11px; letter-spacing: 3px; color: #8fadc8; margin-top: 6px; }

.over-stats {
  display: flex; justify-content: center; gap: 10px;
  margin-bottom: 22px;
}
.over-stats > div {
  flex: 1; min-width: 0;
  background: rgba(255,255,255,.045);
  border: 1px solid rgba(120, 200, 255, .14);
  border-radius: 13px;
  padding: 11px 6px;
}
.over-stats b { display: block; font-size: 21px; font-weight: 800; color: #7fe0ff; font-variant-numeric: tabular-nums; }
.over-stats span { display: block; font-size: 10.5px; color: #8fadc8; margin-top: 3px; letter-spacing: .3px; }

/* ---- 本地排行榜 ---- */
.board {
  margin: 0 0 20px;
  background: rgba(255,255,255,.035);
  border: 1px solid rgba(120, 200, 255, .13);
  border-radius: 14px;
  padding: 12px 14px 10px;
  text-align: left;
}
.board-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; margin-bottom: 9px;
}
.board-title { font-size: 12px; font-weight: 800; letter-spacing: 2.4px; color: #9fd4f2; }
.board-note { font-size: 10px; color: #6f8ba6; letter-spacing: .3px; }

.board-list { list-style: none; margin: 0; padding: 0; }
.board-row {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 0;
  border-top: 1px solid rgba(120, 200, 255, .08);
  font-size: 12px;
}
.board-row:first-child { border-top: 0; }
.board-row > i {
  flex: 0 0 20px; text-align: center;
  font-style: normal; font-weight: 800; color: #5f7f9c;
  font-variant-numeric: tabular-nums;
}
/* 前三名用奖牌色 */
.board-row:nth-child(1) > i { color: #ffd76a; }
.board-row:nth-child(2) > i { color: #d3dde8; }
.board-row:nth-child(3) > i { color: #e0a273; }
.board-row > b {
  flex: 0 0 62px; text-align: right;
  font-weight: 800; color: #bfe8ff;
  font-variant-numeric: tabular-nums;
}
.board-row > span { flex: 1; min-width: 0; color: #8fadc8; }
.board-row > time { flex: 0 0 auto; color: #5f7f9c; font-size: 10.5px; font-variant-numeric: tabular-nums; }
/* 本次成绩高亮 */
.board-row.me {
  background: linear-gradient(90deg, rgba(120,220,255,.13), rgba(120,220,255,0));
  border-radius: 8px;
  box-shadow: inset 2px 0 0 #7fe0ff;
}
.board-row.me > b { color: #fff; text-shadow: 0 0 14px rgba(120,220,255,.6); }
.board-row.me > i { color: #7fe0ff; }

.board-empty {
  padding: 12px 0 6px; text-align: center;
  font-size: 12px; color: #6f8ba6; letter-spacing: .4px;
}
.board-empty.hidden { display: none; }

/* ---- 闪光 ---- */
#flash {
  position: fixed; inset: 0; z-index: 25;
  pointer-events: none;
  background: #fff;
  opacity: 0;
  transition: opacity .32s ease-out;
}
#flash.on { opacity: .32; transition: none; }

/* ---- Loading ---- */
#loading { background: #0a1220; }
.load-txt { font-size: 14px; letter-spacing: 4px; color: #7fa8cc; animation: blink 1.2s infinite; }
@keyframes blink { 0%,100% { opacity: .35; } 50% { opacity: 1; } }

@media (max-width: 560px) {
  .gauges { right: 10px; gap: 10px; }
  .gauge { min-width: 58px; }
  .gauge-track { height: 170px; }
  .gauge-caption { font-size: 9px; letter-spacing: 0; }
  .hud-top { padding: 12px; }
  .score-main { font-size: 26px; }
  .speed-num { font-size: 22px; }
  .card { padding: 20px 18px 18px; border-radius: 18px; }
  .over-score .big { font-size: 46px; }
  /* 底部让开左下角约 66px 高的 GitHub 悬浮入口，避免遮挡提示语 */
  .hud-bottom { bottom: 84px; }
  .overlay { padding: 14px 14px 84px; }
  .rules { gap: 7px; margin-bottom: 18px; }
  .rules li { font-size: 12.5px; line-height: 1.52; padding-left: 18px; }
  .rules li::before { top: 7px; width: 6px; height: 6px; }
}
