* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%; width: 100%;
  overflow: hidden;
  background: #1A1026;
  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% 70% at 50% -10%, #4A2A6B 0%, rgba(74,42,107,0) 60%),
    radial-gradient(90% 60% at 50% 110%, #6B2E4E 0%, rgba(107,46,78,0) 65%),
    linear-gradient(180deg, #241436 0%, #1A1026 55%, #140C1E 100%);
}

.game-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
}

/* ---------- HUD ---------- */
.hud {
  position: absolute; top: 0; left: 0; right: 0;
  padding: max(10px, env(safe-area-inset-top)) 16px 0;
  display: flex; align-items: flex-start; justify-content: space-between;
  pointer-events: none;
  z-index: 5;
}
.hud-left { display: flex; align-items: center; gap: 10px; }
.hud-score {
  display: flex; flex-direction: column;
  background: rgba(255, 138, 61, 0.16);
  border: 1px solid rgba(255, 138, 61, 0.42);
  border-radius: 14px;
  padding: 6px 14px 7px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
}
.hud-label { font-size: 10px; letter-spacing: 0.16em; color: #FFC79B; }
.hud-value {
  font-size: 22px; font-weight: 800; line-height: 1.1;
  color: #FFFFFF; font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 10px rgba(255, 138, 61, 0.55);
}
.hud-combo {
  display: flex; align-items: baseline; gap: 4px;
  padding: 5px 12px 6px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  opacity: 0.55;
  transition: opacity 0.18s ease, transform 0.18s ease, background 0.18s ease;
}
.hud-combo.on {
  opacity: 1;
  background: rgba(255, 138, 61, 0.24);
  border-color: rgba(255, 190, 130, 0.6);
  transform: scale(1.04);
}
.hud-combo-x { font-size: 17px; font-weight: 800; color: #FFD9B8; font-variant-numeric: tabular-nums; }
.hud-combo-t { font-size: 10px; color: #FFC79B; letter-spacing: 0.1em; }

.hud-right { display: flex; align-items: center; gap: 10px; }
.hud-best {
  display: flex; align-items: center; gap: 5px;
  font-size: 13px; font-weight: 700; color: #FFD9B8;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 6px 11px;
  font-variant-numeric: tabular-nums;
}
.hud-best .mp-icon { font-size: 15px; color: #FFC24B; }
.hud-lives { display: flex; gap: 4px; }
.hud-lives .mp-icon { font-size: 19px; color: #FF5E7A; transition: transform 0.2s ease, opacity 0.2s ease; }
.hud-lives .mp-icon.off { color: rgba(255, 255, 255, 0.22); transform: scale(0.86); }

/* ---------- 节拍闪光 ---------- */
.beat-flash {
  position: absolute; inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(80% 50% at 50% 100%, rgba(255, 138, 61, 0.35) 0%, rgba(255, 138, 61, 0) 70%);
  z-index: 3;
}
.beat-flash.on { animation: beatPulse 0.34s ease-out; }
@keyframes beatPulse {
  0% { opacity: 0.9; }
  100% { opacity: 0; }
}

/* ---------- 遮罩面板 ---------- */
.overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: radial-gradient(120% 90% at 50% 40%, rgba(26, 16, 38, 0.72) 0%, rgba(14, 8, 22, 0.92) 100%);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 10;
  transition: opacity 0.24s ease;
}
.overlay.hidden { opacity: 0; pointer-events: none; }

.panel {
  width: 100%; max-width: 420px;
  max-height: 100%;
  overflow-y: auto;
  background: linear-gradient(180deg, #2E1B44 0%, #241436 100%);
  border: 1px solid rgba(255, 138, 61, 0.34);
  border-radius: 22px;
  padding: 18px 18px 16px;
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  animation: panelIn 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes panelIn {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

.panel-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px 6px;
  border-radius: 999px;
  background: rgba(255, 138, 61, 0.18);
  border: 1px solid rgba(255, 138, 61, 0.5);
  color: #FFC79B;
  font-size: 11px; font-weight: 700; letter-spacing: 0.12em;
}
.panel-badge .mp-icon { font-size: 14px; color: #FF8A3D; }
.panel-badge--fail {
  background: rgba(255, 94, 122, 0.16);
  border-color: rgba(255, 94, 122, 0.5);
  color: #FFB3C1;
}
.panel-badge--fail .mp-icon { color: #FF5E7A; }

.panel-title {
  margin: 12px 0 0;
  font-size: 24px; font-weight: 800; letter-spacing: -0.01em;
  color: #FFFFFF;
  text-shadow: 0 3px 16px rgba(255, 138, 61, 0.4);
}
.panel-title--sm { font-size: 19px; }
.panel-desc {
  margin: 8px 0 0;
  font-size: 13px; line-height: 1.6;
  color: #C9B8DA;
}

.panel-tips { margin: 14px 0 0; display: flex; flex-direction: column; gap: 8px; }
.tip-row {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 12px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.09);
  font-size: 12.5px; color: #E4D8F0;
}
.tip-row .mp-icon { font-size: 17px; color: #FF8A3D; flex: 0 0 auto; }

.btn-primary {
  margin-top: 16px;
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 15px 18px;
  border: 0; border-radius: 16px;
  background: linear-gradient(180deg, #FFA05C 0%, #FF8A3D 55%, #F0701F 100%);
  color: #2A1408;
  font-size: 16px; font-weight: 800; letter-spacing: 0.04em;
  font-family: inherit;
  box-shadow: 0 10px 24px rgba(255, 138, 61, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
  cursor: pointer;
}
.btn-primary .mp-icon { font-size: 20px; color: #2A1408; }
.btn-primary:active {
  transform: translateY(2px) scale(0.985);
  box-shadow: 0 4px 12px rgba(255, 138, 61, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  filter: brightness(0.96);
}

.panel-foot {
  margin-top: 10px;
  text-align: center;
  font-size: 11.5px; color: #9C8AB0;
  letter-spacing: 0.06em;
}

.result-grid {
  margin-top: 14px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 9px;
}
.result-cell {
  display: flex; flex-direction: column; gap: 3px;
  padding: 11px 13px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.result-label { font-size: 10.5px; color: #A995BE; letter-spacing: 0.1em; }
.result-value {
  font-size: 19px; font-weight: 800; color: #FFD9B8;
  font-variant-numeric: tabular-nums;
}

@media (max-height: 420px) {
  .panel { padding: 14px 16px 13px; border-radius: 18px; }
  .panel-title { font-size: 20px; margin-top: 9px; }
  .panel-desc { font-size: 12px; margin-top: 6px; }
  .panel-tips { margin-top: 10px; gap: 6px; }
  .tip-row { padding: 7px 10px; font-size: 11.5px; }
  .btn-primary { margin-top: 12px; padding: 12px 16px; font-size: 15px; }
  .result-grid { margin-top: 10px; gap: 7px; }
  .result-cell { padding: 8px 11px; }
  .result-value { font-size: 16px; }
  .hud-value { font-size: 18px; }
}
