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

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

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

/* ---------- HUD ---------- */
.hud {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) calc(14px + env(safe-area-inset-right)) 0 calc(14px + env(safe-area-inset-left));
  pointer-events: none;
  z-index: 5;
}
.hud-left, .hud-right { display: flex; align-items: center; gap: 8px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  border: 2px solid rgba(255, 138, 61, 0.55);
  box-shadow: 0 4px 0 rgba(196, 96, 30, 0.28), 0 6px 14px rgba(120, 60, 20, 0.16);
  font-size: 15px; font-weight: 800; letter-spacing: 0.02em;
  color: #B4520F;
  font-variant-numeric: tabular-nums;
}
.pill .mp-icon { font-size: 18px; color: #FF8A3D; }
.pill-ghost {
  background: rgba(255, 255, 255, 0.72);
  border-color: rgba(255, 255, 255, 0.9);
  color: #7A5A3C;
  box-shadow: 0 3px 0 rgba(120, 60, 20, 0.14);
}
.pill-ghost .mp-icon { color: #C79A6B; }
#playerPill { max-width: 42vw; }
#playerPill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  width: 22px; height: 22px; border-radius: 50%;
  object-fit: cover; display: block;
  border: 2px solid #FF8A3D;
}

.icon-btn, .pause-btn {
  width: 38px; height: 38px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.82);
  color: #B4520F;
  box-shadow: 0 3px 0 rgba(120, 60, 20, 0.16);
  pointer-events: auto;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.icon-btn .mp-icon, .pause-btn .mp-icon { font-size: 20px; }
.icon-btn:active, .pause-btn:active { transform: translateY(2px) scale(0.96); box-shadow: 0 1px 0 rgba(120, 60, 20, 0.16); }

.pause-btn {
  position: absolute; z-index: 6;
  right: calc(14px + env(safe-area-inset-right));
  bottom: calc(14px + env(safe-area-inset-bottom));
  width: 42px; height: 42px;
}

/* ---------- 面板 ---------- */
.overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: radial-gradient(120% 100% at 50% 0%, rgba(255, 176, 108, 0.42), rgba(58, 30, 12, 0.62));
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 8;
  animation: fadeIn 0.22s ease both;
}
.overlay[hidden] { display: none; }

.panel {
  position: relative;
  width: min(430px, 92vw);
  max-height: 92vh;
  overflow-y: auto;
  padding: 22px 22px 20px;
  border-radius: 26px;
  background: linear-gradient(180deg, #FFFDF8 0%, #FFF3E2 100%);
  border: 3px solid #FFFFFF;
  box-shadow: 0 10px 0 rgba(196, 96, 30, 0.35), 0 22px 44px rgba(60, 26, 6, 0.42);
  text-align: center;
  animation: popIn 0.28s cubic-bezier(0.2, 1.3, 0.4, 1) both;
}
.panel-sm { width: min(320px, 84vw); padding: 20px; }

.panel-badge {
  width: 62px; height: 62px; margin: -46px auto 10px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: linear-gradient(160deg, #FFB066, #FF8A3D 60%, #F06E1E);
  border: 3px solid #FFFFFF;
  box-shadow: 0 6px 0 rgba(196, 96, 30, 0.4), 0 10px 20px rgba(120, 50, 10, 0.3);
  color: #FFFFFF;
}
.panel-badge .mp-icon { font-size: 32px; }
.badge-fail { background: linear-gradient(160deg, #FF9C8A, #F2603F 60%, #D8431F); box-shadow: 0 6px 0 rgba(160, 50, 20, 0.4), 0 10px 20px rgba(120, 40, 10, 0.3); }

.panel-title {
  margin: 0;
  font-size: 24px; font-weight: 900; letter-spacing: 0.02em;
  color: #3A2412;
}
.panel-sub {
  margin: 8px 0 0;
  font-size: 13.5px; line-height: 1.55;
  color: #8A6A4C;
}

.tips {
  display: flex; gap: 8px;
  margin: 16px 0 18px;
}
.tip {
  flex: 1 1 0;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 6px;
  border-radius: 14px;
  background: #FFFFFF;
  border: 1.5px solid #F6DFC4;
  box-shadow: 0 3px 0 rgba(214, 160, 108, 0.22);
  font-size: 11.5px; font-weight: 700; color: #8A6A4C;
  line-height: 1.3;
}
.tip .mp-icon { font-size: 20px; color: #FF8A3D; }

.btn-primary {
  width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 54px;
  border: none; border-radius: 16px;
  background: linear-gradient(180deg, #FFA45C 0%, #FF8A3D 55%, #F2731F 100%);
  color: #FFFFFF;
  font-size: 17px; font-weight: 900; letter-spacing: 0.04em;
  box-shadow: 0 5px 0 #C9601A, 0 10px 20px rgba(240, 110, 30, 0.4);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.btn-primary .mp-icon { font-size: 22px; }
.btn-primary:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #C9601A, 0 4px 10px rgba(240, 110, 30, 0.32);
}

.panel-foot {
  margin: 14px 0 0;
  font-size: 12.5px; color: #A98A6C;
}
.panel-foot b { color: #E06A1C; font-size: 14px; }

.score-row { display: flex; gap: 10px; margin: 16px 0 4px; }
.score-box {
  flex: 1 1 0;
  display: flex; flex-direction: column; gap: 4px;
  padding: 12px 8px;
  border-radius: 16px;
  background: #FFFFFF;
  border: 1.5px solid #F6DFC4;
  box-shadow: 0 3px 0 rgba(214, 160, 108, 0.22);
}
.score-label { font-size: 11.5px; font-weight: 700; color: #A98A6C; }
.score-value {
  font-size: 26px; font-weight: 900; color: #E06A1C;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

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

/* 横屏窄高时压缩面板 */
@media (max-height: 420px) {
  .panel { padding: 16px 18px 14px; border-radius: 20px; }
  .panel-badge { width: 48px; height: 48px; margin: -34px auto 6px; }
  .panel-badge .mp-icon { font-size: 24px; }
  .panel-title { font-size: 19px; }
  .panel-sub { font-size: 12px; margin-top: 5px; }
  .tips { margin: 10px 0 12px; gap: 6px; }
  .tip { padding: 7px 4px; font-size: 10.5px; }
  .tip .mp-icon { font-size: 16px; }
  .btn-primary { height: 46px; font-size: 15px; }
  .score-value { font-size: 22px; }
  .panel-foot { margin-top: 10px; }
}
