/* ============================================================
 * 极速赛车 Turbo Racer —— 界面样式
 * 赛博霓虹风格，竖版 480x720 画布，自适应屏幕缩放
 * ============================================================ */
:root {
  --accent: #ff9f43;
  --accent2: #ffd166;
  --bg: #0b0e1a;
}

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

html,
body {
  height: 100%;
}

body {
  background:
    radial-gradient(1200px 600px at 50% -10%, #1b2440 0%, var(--bg) 55%),
    var(--bg);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* 舞台：保持 480:720 比例的容器 */
#stage {
  position: relative;
  width: min(96vw, calc(94vh * 480 / 720));
  aspect-ratio: 480 / 720;
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 14px;
  box-shadow: 0 0 0 2px #2a3350, 0 18px 60px rgba(0, 0, 0, 0.6);
  touch-action: none;
}

canvas.dim {
  filter: brightness(0.55);
}

.hidden {
  display: none !important;
}

/* ---------------- HUD ---------------- */
#hud {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  padding: 14px 16px;
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.hud-right {
  text-align: right;
}

.label {
  font-size: 11px;
  letter-spacing: 2px;
  opacity: 0.7;
}

.value {
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

.speed {
  font-size: 26px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--accent2);
  text-shadow: 0 0 14px rgba(255, 209, 102, 0.55);
  margin-top: 10px;
}

.hud-btns {
  margin-top: 8px;
  pointer-events: auto;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  background: rgba(15, 20, 40, 0.55);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
  margin-left: 6px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover {
  background: rgba(255, 159, 67, 0.35);
  border-color: var(--accent);
}

/* ---------------- 遮罩层 ---------------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: rgba(8, 10, 22, 0.78);
  backdrop-filter: blur(8px);
  color: #fff;
  text-align: center;
  padding: 24px;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.title {
  font-size: 52px;
  letter-spacing: 6px;
  font-weight: 900;
  background: linear-gradient(180deg, #fff 20%, var(--accent2) 60%, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 18px rgba(255, 159, 67, 0.45));
}

.title span {
  background: linear-gradient(180deg, #fff 10%, var(--accent) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  letter-spacing: 8px;
  color: #8fa3c8;
  font-size: 13px;
  margin-top: -10px;
}

.menu-best {
  color: #ffd166;
  font-size: 15px;
}

.tips {
  font-size: 12px;
  color: #9fb0d0;
  line-height: 2;
  margin-top: 6px;
}

.btn {
  border: none;
  cursor: pointer;
  padding: 14px 42px;
  border-radius: 999px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #1a1206;
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  box-shadow: 0 8px 24px rgba(255, 159, 67, 0.4);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.btn:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 12px 30px rgba(255, 159, 67, 0.55);
}

.btn:active {
  transform: scale(0.97);
}

.over-title {
  font-size: 30px;
  letter-spacing: 2px;
}

.record {
  color: #ffd166;
  font-weight: 900;
  letter-spacing: 2px;
  font-size: 18px;
  animation: pulse 1s ease infinite;
}

@keyframes pulse {
  50% { transform: scale(1.12); }
}

.stat {
  font-size: 17px;
  color: #dfe8f7;
}

.stat span {
  color: #fff;
  font-weight: 800;
  font-size: 22px;
}

h2 {
  color: #fff;
}

/* ---------------- 触屏操控 ---------------- */
#touch-controls {
  position: absolute;
  inset: 0;
  z-index: 5;               /* 画布之上；HUD(10) 之下；覆盖层(20)之下 */
  pointer-events: none;
}

.tc-cluster {
  position: absolute;
  bottom: 14px;
  display: flex;
  gap: 10px;
  pointer-events: none;
}

.tc-steer {
  left: 14px;
}

.tc-pedals {
  right: 14px;
  flex-direction: column;
  align-items: flex-end;
}

.tc-btn {
  pointer-events: auto;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  border-radius: 16px;
  background: rgba(12, 18, 38, 0.55);
  backdrop-filter: blur(6px);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: transform 0.08s ease, background 0.12s ease, border-color 0.12s ease;
}

.tc-btn span {
  font-size: 11px;
  letter-spacing: 1px;
  opacity: 0.85;
}

.tc-btn:active,
.tc-btn.active {
  transform: scale(0.94);
  border-color: var(--accent2);
  background: rgba(255, 159, 67, 0.45);
}

.tc-steer-btn {
  width: clamp(52px, 24%, 84px);
  aspect-ratio: 1;
  font-size: clamp(20px, 8vw, 30px);
}

.tc-gas-btn {
  width: clamp(64px, 28%, 96px);
  aspect-ratio: 1;
  font-size: clamp(22px, 9vw, 32px);
  border-color: rgba(255, 180, 70, 0.5);
}

.tc-gas-btn.active {
  background: rgba(46, 204, 113, 0.55);
  border-color: #2ecc71;
}

.tc-brake-btn {
  width: clamp(48px, 21%, 72px);
  aspect-ratio: 1;
  font-size: clamp(16px, 7vw, 24px);
  border-color: rgba(255, 80, 80, 0.5);
}

.tc-brake-btn.active {
  background: rgba(231, 76, 60, 0.6);
  border-color: #e74c3c;
}

/* 触屏设备：加大顶部 HUD 按钮，避免误触 */
body.touch .icon-btn {
  width: 44px;
  height: 44px;
  font-size: 18px;
}

body.touch #hud {
  padding: 16px 18px;
}

body.touch .hud-btns {
  margin-top: 10px;
  display: flex;
  gap: 8px;
}

body.touch .hud-btns .icon-btn {
  margin-left: 0;
}

/* ---------------- 名次面板 ---------------- */
.rank-panel {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(10, 15, 32, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 12px;
  line-height: 1.7;
  color: #dfe8f7;
  text-align: left;
  min-width: 128px;
}

.rank-title {
  font-weight: 900;
  font-size: 14px;
  color: var(--accent2);
  margin-bottom: 2px;
}

.rank-row {
  display: flex;
  gap: 4px;
  white-space: nowrap;
}

.rank-row em {
  font-style: normal;
  color: #7f92b8;
  font-size: 11px;
}

.rank-row.me {
  color: #fff;
  font-weight: 800;
}

.shield-status {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 700;
  color: #5fd3ff;
  min-height: 16px;
  text-shadow: 0 0 10px rgba(95, 211, 255, 0.6);
}

/* ---------------- 技能条（桌面端） ---------------- */
#skill-hud {
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(10, 15, 32, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.16);
  font-size: 12px;
  color: #dfe8f7;
  pointer-events: none;
}

#skill-name {
  font-weight: 800;
  color: var(--accent2);
  min-width: 52px;
}

.skill-track {
  width: 96px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  overflow: hidden;
}

#skill-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width 0.15s ease;
}

#skill-hint {
  color: #7f92b8;
}

body.touch #skill-hud {
  display: none;
}

/* ---------------- 车库：车辆选择 ---------------- */
.pick-label {
  font-size: 13px;
  letter-spacing: 3px;
  color: #8fa3c8;
  margin-top: 6px;
}

.vehicle-pick {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.vp-card {
  width: 128px;
  padding: 10px;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.14);
  background: rgba(20, 28, 54, 0.7);
  color: #fff;
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 7px;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.vp-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 159, 67, 0.55);
}

.vp-card.selected {
  border-color: var(--accent);
  background: rgba(255, 159, 67, 0.16);
  box-shadow: 0 0 18px rgba(255, 159, 67, 0.35);
}

.vp-swatch {
  width: 100%;
  height: 10px;
  border-radius: 6px;
}

.vp-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.vp-head b {
  font-size: 16px;
}

.vp-head i {
  font-style: normal;
  font-size: 10.5px;
  color: #9fb0d0;
  line-height: 1.4;
}

.vp-bars {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.vp-bars i {
  font-style: normal;
  font-size: 10px;
  color: #7f92b8;
}

.vp-bars b {
  display: block;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.vp-bars u {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}

/* ---------------- 触屏技能按钮 ---------------- */
.tc-skill {
  left: 50%;
  transform: translateX(-50%);
  bottom: 22px;
}

.tc-skill-btn {
  width: clamp(56px, 25%, 88px);
  aspect-ratio: 1;
  font-size: clamp(20px, 8vw, 30px);
  border-radius: 50%;
  border-color: rgba(192, 132, 252, 0.55);
}

.tc-skill-btn.active {
  border-color: #c084fc;
  background: rgba(192, 132, 252, 0.4);
}

.tc-skill-btn.ready {
  animation: skillPulse 0.8s ease infinite;
  border-color: #ffd166;
}

@keyframes skillPulse {
  0%, 100% { box-shadow: 0 0 6px rgba(255, 209, 102, 0.4); }
  50% { box-shadow: 0 0 22px rgba(255, 209, 102, 0.95); }
}
