* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  overflow: hidden; background: #0E1B2A;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  color: #1C1915;
  user-select: none; -webkit-user-select: none;
  touch-action: none;
}

#stage {
  position: fixed; inset: 0;
  overflow: hidden;
  background: #0E1B2A;
}

#game {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
}

/* ---------- HUD ---------- */
.hud {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 10px 14px;
  pointer-events: none;
  z-index: 5;
}
.hud-left { display: flex; gap: 8px; }
.hud-right { display: flex; gap: 8px; }

.hud-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 11px 6px 9px;
  border-radius: 999px;
  background: rgba(12, 26, 42, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #F4FAFF;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
}
.hud-chip .mp-icon { font-size: 15px; color: #9FD8FF; }
.hud-chip.accent {
  background: rgba(255, 138, 61, 0.92);
  border-color: rgba(255, 255, 255, 0.34);
  color: #2A1405;
}
.hud-chip.accent .mp-icon { color: #2A1405; }

/* ---------- 面板 ---------- */
.panel {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  z-index: 10;
  background: radial-gradient(120% 90% at 50% 40%, rgba(8, 20, 34, 0.42) 0%, rgba(6, 14, 24, 0.78) 100%);
  animation: fadeIn 0.22s ease-out;
}
.panel.hidden { display: none; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.panel-card {
  width: 100%;
  max-width: 430px;
  max-height: 100%;
  overflow-y: auto;
  padding: 18px 20px 20px;
  border-radius: 22px;
  background: linear-gradient(180deg, #FFFDF9 0%, #FFF4E8 100%);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 18px 44px rgba(4, 12, 22, 0.45), 0 2px 0 rgba(255, 255, 255, 0.6) inset;
  animation: popIn 0.26s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.panel-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 138, 61, 0.16);
  color: #C25A16;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
}
.panel-badge.fail {
  background: rgba(226, 74, 74, 0.14);
  color: #C23A3A;
}

.panel-title {
  margin: 8px 0 4px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #241A10;
}
.panel-desc {
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.55;
  color: #8A7A68;
}

.panel-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.panel-stats.wide { grid-template-columns: repeat(3, 1fr); }

.stat {
  padding: 9px 11px;
  border-radius: 13px;
  background: #FFFFFF;
  border: 1px solid #F0E2D2;
  box-shadow: 0 2px 6px rgba(180, 140, 100, 0.1);
}
.stat-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #A89684;
  margin-bottom: 3px;
}
.stat-value {
  display: block;
  font-size: 16px;
  font-weight: 800;
  color: #2A1D10;
  font-variant-numeric: tabular-nums;
}

.panel-new {
  margin: 0 0 12px;
  padding: 7px 12px;
  border-radius: 11px;
  background: linear-gradient(90deg, #FF8A3D, #FFB066);
  color: #3A1A02;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  letter-spacing: 0.04em;
}
.panel-new.hidden { display: none; }

.panel-actions { display: flex; gap: 10px; }

.btn-primary {
  flex: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 48px;
  padding: 0 18px;
  border: none;
  border-radius: 15px;
  background: linear-gradient(180deg, #FFA05C 0%, #FF8A3D 55%, #F0741F 100%);
  color: #2A1405;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: 0 6px 16px rgba(255, 138, 61, 0.42), 0 1px 0 rgba(255, 255, 255, 0.55) inset;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  cursor: pointer;
}
.btn-primary .mp-icon { font-size: 20px; }
.btn-primary:active {
  transform: translateY(2px) scale(0.985);
  box-shadow: 0 2px 8px rgba(255, 138, 61, 0.34);
}

.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px;
  padding: 0 16px;
  border-radius: 15px;
  background: #FFFFFF;
  border: 1px solid #EBDCCB;
  color: #6B5A48;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(180, 140, 100, 0.12);
  transition: transform 0.1s ease;
  cursor: pointer;
}
.btn-ghost .mp-icon { font-size: 18px; }
.btn-ghost:active { transform: translateY(2px) scale(0.985); }

.panel-tip {
  margin: 12px 0 0;
  font-size: 11px;
  line-height: 1.5;
  color: #A89684;
  text-align: center;
}

/* ---------- 倒计时 ---------- */
.countdown {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 9;
  pointer-events: none;
  font-size: 76px;
  font-weight: 900;
  color: #FFFFFF;
  text-shadow: 0 6px 22px rgba(0, 0, 0, 0.55), 0 0 0 3px rgba(255, 138, 61, 0.5);
  animation: cdPulse 0.9s ease-out;
}
.countdown.hidden { display: none; }
@keyframes cdPulse {
  0% { opacity: 0; transform: scale(1.7); }
  35% { opacity: 1; transform: scale(1); }
  100% { opacity: 0.85; transform: scale(0.94); }
}

/* 横屏窄高时压缩面板 */
@media (max-height: 420px) {
  .panel-card { padding: 14px 16px 16px; border-radius: 18px; max-width: 520px; }
  .panel-title { font-size: 20px; margin: 6px 0 2px; }
  .panel-desc { margin-bottom: 10px; font-size: 12px; }
  .panel-stats { margin-bottom: 12px; gap: 8px; }
  .stat { padding: 7px 9px; }
  .stat-value { font-size: 14px; }
  .btn-primary, .btn-ghost { min-height: 42px; }
  .panel-tip { margin-top: 8px; }
  .countdown { font-size: 60px; }
}
