/* 低多边形赛车 — 全局样式 */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #0b0f1a; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  color: #e8ecf4; user-select: none; -webkit-user-select: none; touch-action: none;
}
#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

/* ---------- 全屏界面 ---------- */
.screen {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  background: rgba(6, 10, 20, 0.72); backdrop-filter: blur(6px);
  overflow-y: auto; padding: 12px;
}
.panel {
  width: min(680px, 96vw); max-height: 94vh; overflow-y: auto;
  background: rgba(16, 22, 38, 0.92); border: 1px solid rgba(120, 160, 255, 0.25);
  border-radius: 16px; padding: 20px 22px; text-align: center;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.6);
}
.panel.narrow { width: min(360px, 92vw); }
.title { font-size: clamp(28px, 6vw, 44px); letter-spacing: 6px; color: #ffd43b;
  text-shadow: 0 3px 0 #b8860b, 0 8px 24px rgba(0, 0, 0, 0.6); }
.sub-title { font-size: 12px; letter-spacing: 8px; color: #7aa2e8; margin: 4px 0 10px; }
.panel h1 { font-size: 26px; margin-bottom: 12px; color: #ffd43b; }
.panel h2 { font-size: 15px; text-align: left; margin: 14px 0 8px; color: #8fd3ff; letter-spacing: 2px; }
.coins-row { font-size: 15px; color: #ffe9a8; }
.coins-row b { color: #ffd43b; font-size: 19px; }
.record { margin-left: 12px; font-size: 12px; color: #9ab; }

/* ---------- 卡片 ---------- */
.cards { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 8px; }
.card {
  flex: 0 0 150px; border-radius: 12px; padding: 10px;
  background: rgba(30, 40, 66, 0.85); border: 2px solid transparent;
  cursor: pointer; transition: border-color .15s, transform .15s; text-align: left;
}
.card:hover { transform: translateY(-2px); }
.card.sel { border-color: #ffd43b; }
.card.locked { opacity: 0.82; }
.card .name { font-size: 16px; font-weight: 700; }
.card .en { font-size: 10px; color: #7aa2e8; letter-spacing: 1px; }
.card .swatch { height: 34px; border-radius: 8px; margin: 6px 0; }
.card .desc { font-size: 11px; color: #aab6cc; min-height: 28px; margin: 4px 0; }
.stat { display: flex; align-items: center; gap: 6px; font-size: 10px; color: #9ab; margin-top: 3px; }
.stat span { width: 26px; }
.bar { flex: 1; height: 6px; background: #232c44; border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, #4dabf7, #ffd43b); border-radius: 3px; }
.card .act {
  margin-top: 8px; width: 100%; padding: 6px 0; border: none; border-radius: 8px;
  font-size: 13px; font-weight: 700; cursor: pointer;
  background: #2b3a5e; color: #cfe0ff;
}
.card .act.buy { background: #b8860b; color: #fff; }
.card .act.on { background: #2f9e44; color: #fff; }
.card .meta { font-size: 11px; color: #9ab; margin-top: 4px; }
.card .best { font-size: 11px; color: #8fd3ff; margin-top: 2px; }

/* ---------- 选项与按钮 ---------- */
.opts { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; align-items: center; margin: 12px 0; font-size: 14px; }
.opts select {
  background: #1c2740; color: #e8ecf4; border: 1px solid #3a4a72; border-radius: 6px;
  padding: 5px 8px; font-size: 13px; margin-left: 6px;
}
.opts .chk { display: flex; align-items: center; gap: 5px; }
.big-btn {
  display: block; width: 100%; margin: 10px 0 0; padding: 13px 0;
  font-size: 18px; font-weight: 800; letter-spacing: 4px; color: #1a1200;
  background: linear-gradient(180deg, #ffd43b, #f0a832); border: none; border-radius: 12px;
  cursor: pointer; box-shadow: 0 4px 0 #a8720c, 0 8px 20px rgba(0, 0, 0, 0.4);
}
.big-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #a8720c; }
.big-btn.ghost { background: #2b3a5e; color: #cfe0ff; box-shadow: 0 4px 0 #16203a; }
.small { font-size: 12px; padding: 6px 12px; border-radius: 8px; border: none; cursor: pointer; margin-top: 12px; }
.small.danger { background: #5e2b2b; color: #ffb3b3; }
.help { font-size: 11px; color: #8894aa; line-height: 1.7; margin-top: 12px; }
.row-btns { display: flex; gap: 10px; }
.row-btns .big-btn { flex: 1; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
#hud button { pointer-events: auto; }
#hud-left { position: absolute; left: 12px; top: 12px; }
#hud-pos {
  font-size: 42px; font-weight: 900; color: #ffd43b; line-height: 1;
  text-shadow: 0 2px 0 #7a5b00, 0 4px 12px rgba(0, 0, 0, 0.7);
}
#hud-ranks { margin-top: 6px; font-size: 12px; color: #cfe0ff; text-shadow: 0 1px 3px #000; line-height: 1.5; }
#hud-ranks .me { color: #ffd43b; font-weight: 700; }
#hud-top {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 16px; font-size: 17px; font-weight: 700;
  text-shadow: 0 2px 4px #000; background: rgba(10, 14, 26, 0.45);
  padding: 6px 16px; border-radius: 10px;
}
#hud-times {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  font-size: 12px; color: #cfe0ff; text-shadow: 0 1px 3px #000; line-height: 1.8;
  background: rgba(10, 14, 26, 0.35); padding: 6px 10px; border-radius: 8px;
}
#hud-times span { color: #fff; font-weight: 700; }
#hud-right { position: absolute; right: 14px; bottom: 14px; text-align: right; }
#hud-speed { font-size: 52px; font-weight: 900; line-height: 1; text-shadow: 0 3px 6px #000; }
.kmh { font-size: 12px; color: #9ab; margin-bottom: 6px; }
#nitro-bar { width: 130px; height: 12px; background: rgba(10, 14, 26, 0.6); border: 1px solid #3a4a72; border-radius: 6px; overflow: hidden; margin-left: auto; }
#nitro-fill { height: 100%; width: 50%; background: linear-gradient(90deg, #15aabf, #66d9e8); border-radius: 6px; transition: width .1s linear; }
.nitro-label { font-size: 10px; color: #66d9e8; margin-top: 2px; }
.tag { display: inline-block; margin-top: 6px; font-size: 12px; padding: 2px 8px; border-radius: 6px; background: rgba(21, 170, 191, 0.25); color: #66d9e8; }
.tag.warn { background: rgba(224, 49, 49, 0.3); color: #ff8787; }
#hud-btns { position: absolute; top: 10px; right: 12px; display: flex; gap: 8px; }
#hud-btns button {
  width: 42px; height: 42px; border-radius: 10px; border: 1px solid #3a4a72;
  background: rgba(16, 22, 38, 0.7); color: #cfe0ff; font-size: 17px; cursor: pointer;
}
#wrongway {
  position: absolute; top: 26%; left: 50%; transform: translateX(-50%);
  font-size: 34px; font-weight: 900; color: #ff5252; text-shadow: 0 3px 8px #000;
  animation: blink .5s infinite alternate;
}
@keyframes blink { from { opacity: 1; } to { opacity: 0.35; } }
#msg {
  position: absolute; top: 18%; left: 50%; transform: translateX(-50%);
  font-size: 22px; font-weight: 800; color: #8fd3ff; text-shadow: 0 2px 6px #000;
  opacity: 0; transition: opacity .25s;
}
#msg.show { opacity: 1; }

/* ---------- 倒计时 ---------- */
#countdown {
  position: fixed; inset: 0; z-index: 25; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(80px, 22vw, 180px); font-weight: 900; color: #ffd43b;
  text-shadow: 0 6px 0 #a8720c, 0 12px 40px rgba(0, 0, 0, 0.8);
}
#countdown.go { color: #40c057; text-shadow: 0 6px 0 #1f6b2e, 0 12px 40px rgba(0, 0, 0, 0.8); }

/* ---------- 结算 ---------- */
#results-reward { font-size: 16px; color: #ffe9a8; margin-bottom: 10px; line-height: 1.7; }
#results-reward b { color: #ffd43b; font-size: 22px; }
#results-table { width: 100%; border-collapse: collapse; font-size: 14px; margin-bottom: 8px; }
#results-table td { padding: 7px 6px; border-bottom: 1px solid rgba(120, 160, 255, 0.15); }
#results-table tr.me td { color: #ffd43b; font-weight: 700; background: rgba(255, 212, 59, 0.08); }
#results-table td.r { text-align: right; color: #9ab; }

/* ---------- 触控 ---------- */
#touch { position: fixed; inset: 0; z-index: 22; pointer-events: none; }
#wheel {
  position: absolute; left: 4vw; bottom: 6vh; width: 34vmin; height: 34vmin; max-width: 190px; max-height: 190px;
  border-radius: 50%; border: 5px solid rgba(200, 215, 245, 0.55);
  background: radial-gradient(circle, rgba(30, 40, 66, 0.35) 58%, rgba(30, 40, 66, 0.75) 60%);
  pointer-events: auto; touch-action: none;
}
#wheel-inner {
  position: absolute; inset: 0; border-radius: 50%;
}
#wheel-inner::before, #wheel-inner::after {
  content: ""; position: absolute; left: 50%; top: 8%; width: 5px; height: 42%;
  background: rgba(200, 215, 245, 0.55); transform-origin: 50% 100%;
}
#wheel-inner::before { transform: translateX(-50%) rotate(60deg); }
#wheel-inner::after { transform: translateX(-50%) rotate(-60deg); }
#pedals { position: absolute; right: 4vw; bottom: 5vh; display: flex; gap: 3vw; pointer-events: auto; }
.pedal {
  width: 17vmin; height: 24vmin; max-width: 96px; max-height: 136px;
  border-radius: 14px; display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 800; color: #ffd7d7;
  background: rgba(120, 40, 40, 0.55); border: 2px solid rgba(255, 130, 130, 0.5);
  touch-action: none;
}
.pedal.go { color: #d3f9d8; background: rgba(40, 110, 55, 0.55); border-color: rgba(140, 230, 160, 0.5); }
.pedal.on { filter: brightness(1.6); }
#touch-btns { position: absolute; right: 4vw; bottom: calc(5vh + 26vmin); display: flex; flex-direction: column; gap: 10px; pointer-events: auto; }
.tbtn {
  width: 17vmin; height: 11vmin; max-width: 96px; max-height: 62px;
  border-radius: 12px; display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 800; color: #e7f5ff;
  background: rgba(40, 60, 110, 0.55); border: 2px solid rgba(130, 170, 255, 0.5);
  touch-action: none;
}
.tbtn.nitro { color: #c3fae8; background: rgba(20, 90, 100, 0.55); border-color: rgba(102, 217, 232, 0.55); }
.tbtn.small { height: 8vmin; max-height: 44px; font-size: 12px; opacity: 0.9; }
.tbtn.on { filter: brightness(1.7); }

@media (max-width: 760px) {
  #hud-times { display: none; }
  #hud-speed { font-size: 40px; }
  #hud-right { bottom: calc(5vh + 30vmin); right: 5vw; }
  #hud-ranks { display: none; }
}

.fatal {
  position: fixed; inset: 0; z-index: 99; display: flex; align-items: center; justify-content: center;
  background: #0b0f1a; color: #ff8787; font-size: 18px; text-align: center; padding: 20px;
}
