/* ===================== 基础 ===================== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: #0b1030;
  user-select: none; -webkit-user-select: none;
  touch-action: none;
}
#game-container { position: fixed; inset: 0; }
#game-canvas { display: block; width: 100%; height: 100%; }
.hidden { display: none !important; }

/* ===================== HUD ===================== */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 10; }
.hud-panel {
  position: absolute;
  background: rgba(10, 14, 40, 0.55);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 14px;
  padding: 8px 14px;
  color: #fff;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.top-left { top: calc(10px + env(safe-area-inset-top)); left: 10px; font-size: 15px; }
.top-left .hud-row { display: flex; align-items: center; gap: 6px; line-height: 1.4; }
.hud-row.small { font-size: 12px; opacity: 0.85; }
.divider { opacity: 0.4; margin: 0 2px; }
.icon { display: inline-block; width: 16px; height: 16px; border-radius: 50%; }
.coin-icon { background: radial-gradient(circle at 35% 30%, #ffe98a, #f7b500); box-shadow: 0 0 6px #f7b50088; }
.star-icon { background: radial-gradient(circle at 35% 30%, #c9b8ff, #7a5cff); box-shadow: 0 0 6px #7a5cff88; clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }
#combo-line b { color: #ffd93d; }

.top-center { top: calc(10px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); text-align: center; min-width: 96px; }
#rank-badge { font-size: 26px; font-weight: 800; color: #ffd93d; line-height: 1; text-shadow: 0 2px 8px rgba(255,217,61,.4); }
.rank-total { font-size: 13px; color: rgba(255,255,255,.6); font-weight: 400; }
#rank-label { font-size: 12px; opacity: .8; margin-top: 2px; }
.mini-bars { display: flex; gap: 3px; justify-content: center; margin-top: 6px; }
.mini-bars .bar { width: 10px; height: 6px; border-radius: 2px; background: rgba(255,255,255,.18); transition: background .3s; }
.mini-bars .bar.me { background: #ffd93d; }

.top-right { top: calc(10px + env(safe-area-inset-top)); right: 10px; text-align: right; }
#hearts { font-size: 18px; letter-spacing: 2px; color: #ff5d6c; text-shadow: 0 0 8px rgba(255,93,108,.6); }
#hearts .lost { color: rgba(255,255,255,.18); }
#powerup-icons { min-height: 22px; font-size: 20px; letter-spacing: 4px; margin-top: 4px; }
#powerup-icons .p { display: inline-block; opacity: 0; transform: scale(.5); transition: all .3s; }
#powerup-icons .p.on { opacity: 1; transform: scale(1); }
#boost-wrap { margin-top: 6px; width: 120px; }
#boost-label { font-size: 10px; color: rgba(255,255,255,.7); margin-bottom: 2px; }
#boost-bar { height: 8px; border-radius: 4px; background: rgba(255,255,255,.18); overflow: hidden; }
#boost-fill { height: 100%; width: 100%; border-radius: 4px; background: linear-gradient(90deg, #37e6ff, #5dff9d); transition: width .1s; }
#boost-fill.low { background: linear-gradient(90deg, #ff9d3d, #ff5d6c); }

#pause-btn {
  position: absolute; right: 10px; top: calc(96px + env(safe-area-inset-top));
  width: 46px; height: 46px; border-radius: 50%;
  background: rgba(10,14,40,.55); color: #fff; font-size: 18px;
  border: 1px solid rgba(255,255,255,.2); cursor: pointer; pointer-events: auto;
  backdrop-filter: blur(6px);
}
#pause-btn:active { transform: scale(.92); }

#toast {
  position: absolute; top: 18%; left: 50%; transform: translateX(-50%);
  background: rgba(10,14,40,.8); color: #fff; padding: 8px 18px;
  border-radius: 999px; font-size: 14px; border: 1px solid rgba(255,255,255,.25);
  animation: toast-in .25s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ===================== 触控区 ===================== */
#joystick-zone {
  position: absolute; left: 0; bottom: 0; width: 46%; height: 62%;
  display: none; align-items: center; justify-content: center;
  z-index: 12; pointer-events: auto; touch-action: none;
}
#joystick {
  width: 130px; height: 130px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.3);
  background: rgba(255,255,255,.08);
  position: relative; opacity: .85;
}
#joystick-knob {
  position: absolute; left: 50%; top: 50%; width: 54px; height: 54px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #7fd8ff, #3b7dff);
  box-shadow: 0 0 18px rgba(80,160,255,.6);
}
#boost-btn {
  position: absolute; right: calc(18px + env(safe-area-inset-right));
  bottom: calc(22px + env(safe-area-inset-bottom));
  width: 92px; height: 92px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.35);
  background: radial-gradient(circle at 35% 30%, #ffb35c, #ff7a1a);
  color: #fff; font-size: 30px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
  box-shadow: 0 0 24px rgba(255,140,40,.45);
  pointer-events: auto; touch-action: none;
}
#boost-btn span { font-size: 11px; }
#boost-btn.active { transform: scale(.94); background: radial-gradient(circle at 35% 30%, #ffd08a, #ff9d3d); }

/* 触控设备显示摇杆与加速键 */
@media (pointer: coarse) {
  #joystick-zone { display: flex; }
  #boost-btn { display: flex; }
}

/* ===================== 界面 ===================== */
.screen {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: rgba(6, 8, 30, 0.55);
  backdrop-filter: blur(3px);
  padding: 16px;
}
.card {
  width: min(460px, 94vw); max-height: 92vh; overflow-y: auto;
  background: linear-gradient(160deg, rgba(30,36,80,.94), rgba(14,16,45,.96));
  border: 1px solid rgba(140,150,255,.35);
  border-radius: 22px; padding: 26px 24px;
  text-align: center; color: #fff;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
  animation: card-in .35s ease;
}
@keyframes card-in { from { opacity: 0; transform: translateY(16px) scale(.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
.game-title {
  font-size: clamp(30px, 7vw, 44px); font-weight: 900;
  background: linear-gradient(90deg, #ffd93d, #ff7ac6, #7ad7ff);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  letter-spacing: 2px; text-shadow: 0 0 30px rgba(255,150,200,.25);
}
.game-title span { font-size: .72em; vertical-align: middle; }
.subtitle { color: #9aa3e8; margin: 4px 0 14px; font-size: 14px; letter-spacing: 3px; }
.howto { text-align: left; font-size: 13px; line-height: 1.65; color: #d4d8ff; }
.howto-item { padding: 4px 0; border-bottom: 1px dashed rgba(255,255,255,.09); }
.howto-item:last-child { border-bottom: none; }
.howto-item b { color: #fff; }

.controls { display: flex; gap: 12px; margin: 14px 0; }
.ctrl-col {
  flex: 1; background: rgba(255,255,255,.05); border-radius: 12px; padding: 10px;
  font-size: 12px; color: #c8cdf5; line-height: 1.6;
}
.ctrl-col h3 { color: #ffd93d; font-size: 13px; margin-bottom: 4px; }

.main-btn {
  display: block; width: 100%; margin-top: 8px;
  padding: 14px; font-size: 17px; font-weight: 700; color: #fff;
  border: none; border-radius: 14px; cursor: pointer;
  background: linear-gradient(90deg, #7a5cff, #ff5da2);
  box-shadow: 0 6px 20px rgba(140,80,255,.4);
  transition: transform .12s;
}
.main-btn:active { transform: scale(.97); }
.ghost-btn {
  display: block; width: 100%; margin-top: 10px;
  padding: 12px; font-size: 15px; color: #b9c0ff;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.18);
  border-radius: 14px; cursor: pointer;
}
.best-line { margin-top: 12px; font-size: 13px; color: #9aa3e8; }

.go-title { font-size: 30px; color: #ff7a9e; margin-bottom: 14px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stat { background: rgba(255,255,255,.06); border-radius: 12px; padding: 12px 6px; }
.stat-num { display: block; font-size: 26px; font-weight: 800; color: #ffd93d; }
.stat-label { font-size: 12px; color: #9aa3e8; }
.record-line { font-size: 14px; color: #d4d8ff; margin-bottom: 4px; }
#new-record-wrap { color: #ffd93d; font-weight: 700; }
#new-record-wrap.new-record { animation: pulse 1s infinite; }
@keyframes pulse { 50% { text-shadow: 0 0 14px #ffd93d; } }
