* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: #0B1020; color: #FFF6EC;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  user-select: none; -webkit-user-select: none;
  touch-action: none;
}
.stage {
  position: fixed; inset: 0; overflow: hidden;
  background: radial-gradient(120% 80% at 50% 0%, #1B2A55 0%, #0E1530 45%, #070A18 100%);
}
.game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------- HUD ---------- */
.hud {
  position: absolute; top: 0; left: 0; right: 0;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 0;
  display: flex; align-items: flex-start; justify-content: space-between;
  pointer-events: none; z-index: 5;
}
.hud-left, .hud-right { display: flex; flex-direction: column; gap: 6px; }
.hud-right { align-items: flex-end; }
.hud-score {
  display: flex; align-items: baseline; gap: 8px;
  background: rgba(12, 20, 44, 0.55);
  border: 1px solid rgba(255, 138, 61, 0.45);
  border-radius: 14px; padding: 6px 12px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
}
.hud-label { font-size: 11px; letter-spacing: 0.12em; color: #FFC79E; }
.hud-value { font-size: 22px; font-weight: 800; color: #FFFFFF; font-variant-numeric: tabular-nums; }
.hud-best { font-size: 11px; color: rgba(255, 246, 236, 0.62); padding-left: 4px; }
.hud-best b { color: #FFD9B8; }
.hud-lives { display: flex; gap: 4px; }
.hud-lives .mp-icon { width: 18px; height: 18px; color: #FF5E6C; filter: drop-shadow(0 2px 6px rgba(255, 94, 108, 0.5)); transition: opacity .2s, transform .2s; }
.hud-lives .mp-icon.off { opacity: 0.22; transform: scale(0.85); filter: none; }
.hud-wave {
  font-size: 11px; color: rgba(255, 246, 236, 0.7);
  background: rgba(12, 20, 44, 0.5); border-radius: 10px; padding: 3px 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.hud-wave b { color: #FFB27A; }

.combo {
  position: absolute; left: 50%; top: 22%; transform: translate(-50%, 0) scale(0.8);
  font-size: 20px; font-weight: 800; color: #FFD166; opacity: 0;
  text-shadow: 0 3px 12px rgba(255, 138, 61, 0.7);
  pointer-events: none; z-index: 6; transition: opacity .18s, transform .18s;
}
.combo.show { opacity: 1; transform: translate(-50%, -8px) scale(1); }

/* ---------- 面板 ---------- */
.overlay {
  position: absolute; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 20px calc(env(safe-area-inset-bottom, 0px) + 24px);
  background: radial-gradient(90% 60% at 50% 40%, rgba(10, 16, 36, 0.55), rgba(6, 9, 20, 0.88));
  backdrop-filter: blur(3px);
  transition: opacity .25s ease;
}
.overlay.hidden { opacity: 0; pointer-events: none; }
.panel {
  width: 100%; max-width: 360px;
  background: linear-gradient(180deg, #1E2A52 0%, #141C3A 100%);
  border: 1px solid rgba(255, 138, 61, 0.35);
  border-radius: 24px;
  padding: 26px 22px 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  text-align: center;
  animation: pop .3s cubic-bezier(.2, 1.2, .4, 1) both;
}
@keyframes pop { from { transform: translateY(14px) scale(.94); opacity: 0; } to { transform: none; opacity: 1; } }
.panel-badge {
  width: 62px; height: 62px; margin: -52px auto 12px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #FFA45C, #FF6B2C);
  box-shadow: 0 10px 26px rgba(255, 122, 44, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  border: 2px solid rgba(255, 255, 255, 0.22);
}
.panel-badge .mp-icon { width: 30px; height: 30px; color: #FFF; }
.panel-badge.fail { background: linear-gradient(160deg, #FF7A85, #E23B4E); box-shadow: 0 10px 26px rgba(226, 59, 78, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.35); }
.panel-title { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: 0.02em; color: #FFFFFF; }
.panel-desc { margin: 10px 0 0; font-size: 13px; line-height: 1.65; color: rgba(255, 246, 236, 0.66); }
.panel-tips { display: flex; flex-direction: column; gap: 8px; margin: 18px 0 22px; }
.tip {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px; padding: 10px 12px;
  font-size: 12.5px; color: rgba(255, 246, 236, 0.82); text-align: left;
}
.tip .mp-icon { width: 18px; height: 18px; color: #FFA45C; flex: 0 0 auto; }
.btn {
  width: 100%; min-height: 52px; border: 0; border-radius: 16px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 16px; font-weight: 700; font-family: inherit; color: #FFF;
  cursor: pointer; transition: transform .12s ease, box-shadow .12s ease, filter .12s;
}
.btn .mp-icon { width: 20px; height: 20px; }
.btn-primary {
  background: linear-gradient(160deg, #FFA45C 0%, #FF7A2C 55%, #F2601A 100%);
  box-shadow: 0 12px 26px rgba(255, 122, 44, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.btn-primary:active { transform: translateY(2px) scale(0.985); box-shadow: 0 6px 14px rgba(255, 122, 44, 0.35); filter: brightness(0.97); }
.panel-foot { margin: 14px 0 0; font-size: 12px; color: rgba(255, 246, 236, 0.5); }
.panel-foot b { color: #FFD9B8; }

.result-row { display: flex; gap: 10px; margin: 18px 0 6px; }
.result-cell {
  flex: 1; background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 14px; padding: 12px 8px;
  display: flex; flex-direction: column; gap: 4px;
}
.result-label { font-size: 11px; color: rgba(255, 246, 236, 0.55); }
.result-value { font-size: 22px; font-weight: 800; color: #FFD166; font-variant-numeric: tabular-nums; }
.result-extra { font-size: 12px; color: rgba(255, 246, 236, 0.6); margin: 8px 0 18px; min-height: 16px; }
.result-extra.newbest { color: #FFB27A; font-weight: 700; }
