:root {
  --theme: #FF8A3D;
  --theme-deep: #E86A1C;
  --ink: #1B2333;
  --ink-2: #4A5568;
  --ink-3: #8A94A6;
  --card: #FFFFFF;
  --line: rgba(27, 35, 51, 0.08);
  --shadow: 0 10px 30px rgba(20, 30, 60, 0.12);
  --space: #071127;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #050a18;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Segoe UI", sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.hidden { display: none !important; }

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

/* 首页实机画面：铺满整个竖屏，从屏幕顶端开始 */
.bg-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
  z-index: 0;
  pointer-events: none;
  filter: saturate(1.05) brightness(0.95);
  transition: opacity .25s ease;
}
.stage.battle .bg-art { opacity: 0; }

.game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 2;
  background: transparent;
  touch-action: none;
}

/* ---------- 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: 3;
  transition: opacity .25s ease;
}
.hud.dim { opacity: 0; }

.hud-left { display: flex; flex-direction: column; gap: 4px; }
.hud-score { display: flex; align-items: baseline; gap: 6px; }
.hud-label {
  font-size: 11px;
  letter-spacing: .12em;
  color: rgba(255, 255, 255, .72);
  text-transform: uppercase;
  text-shadow: 0 1px 6px rgba(0,0,0,.5);
}
.hud-value {
  font-size: 28px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -.02em;
  text-shadow: 0 2px 10px rgba(0, 0, 0, .55);
  font-variant-numeric: tabular-nums;
}
.hud-best {
  font-size: 11px;
  color: rgba(255, 255, 255, .65);
  text-shadow: 0 1px 6px rgba(0,0,0,.5);
}
.hud-best b { color: #FFD9A8; font-weight: 700; }

.hud-right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.hud-lives { display: flex; gap: 3px; }
.hud-lives .mp-icon {
  width: 19px;
  height: 19px;
  font-size: 19px;
  color: #FF5C6C;
  filter: drop-shadow(0 0 6px rgba(255, 92, 108, .55));
  transition: opacity .15s ease;
}
.hud-lives .mp-icon.off {
  opacity: .24;
  filter: none;
}
.hud-bomb {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  background: rgba(8, 16, 36, .55);
  border: 1px solid rgba(255, 255, 255, .2);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  backdrop-filter: blur(6px);
}
.hud-bomb .mp-icon { width: 16px; height: 16px; font-size: 16px; color: #FFD9A8; }

.revive-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px 4px 7px;
  border-radius: 999px;
  background: rgba(255, 138, 61, .22);
  border: 1px solid rgba(255, 186, 130, .65);
  color: #FFD9A8;
  font-size: 11px;
  font-weight: 700;
  backdrop-filter: blur(6px);
}
.revive-chip .mp-icon { width: 14px; height: 14px; font-size: 14px; color: #FF9D5C; }

.round-btn {
  position: absolute;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .22);
  background: rgba(8, 16, 36, .55);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4;
  backdrop-filter: blur(8px);
  transition: transform .12s ease, background .12s ease;
}
.round-btn .mp-icon { width: 22px; height: 22px; font-size: 22px; }
.round-btn:active { transform: scale(.92); background: rgba(255, 255, 255, .22); }

.pause-btn {
  right: 16px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
}
.bomb-btn {
  left: 16px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  color: #FFD9A8;
  border-color: rgba(255, 196, 140, .45);
  background: rgba(255, 138, 61, .2);
}

/* ---------- 遮罩面板 ---------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 20px calc(env(safe-area-inset-bottom, 0px) + 20px);
  background: radial-gradient(120% 80% at 50% 0%, rgba(4, 8, 20, .22), rgba(4, 8, 20, .74));
  backdrop-filter: blur(2px);
  animation: fadeIn .22s ease both;
}
.overlay.start {
  align-items: flex-end;
  background: linear-gradient(180deg, rgba(4, 8, 20, 0) 0%, rgba(4, 8, 20, .32) 46%, rgba(4, 8, 20, .86) 100%);
}
.overlay.hidden { display: none; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes riseIn { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }

.panel {
  width: 100%;
  max-width: 360px;
  padding: 22px 20px 18px;
  border-radius: 26px;
  background: linear-gradient(180deg, rgba(20, 32, 62, .94) 0%, rgba(8, 15, 34, .97) 100%);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .14);
  border: 1px solid rgba(140, 175, 255, .2);
  text-align: center;
  color: #fff;
  animation: riseIn .28s cubic-bezier(.2, .9, .3, 1.1) both;
}

.panel-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  color: #FFD9A8;
  background: rgba(255, 138, 61, .16);
  border: 1px solid rgba(255, 166, 100, .3);
}
.panel-badge .mp-icon { width: 13px; height: 13px; font-size: 13px; color: #FFB45C; }
.panel-badge.danger { color: #FF9A9A; background: rgba(214, 69, 69, .2); border-color: rgba(255, 120, 120, .34); }

.panel-title {
  margin: 10px 0 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -.02em;
  color: #fff;
  text-shadow: 0 3px 16px rgba(255, 138, 61, .28);
}
.panel-desc {
  margin: 9px 0 0;
  font-size: 13px;
  line-height: 1.6;
  color: rgba(220, 232, 255, .72);
}

.panel-stats {
  display: flex;
  gap: 10px;
  margin: 16px 0 0;
}
.stat {
  flex: 1;
  padding: 10px 8px;
  border-radius: 15px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(150, 180, 255, .14);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat-num {
  font-size: 21px;
  font-weight: 800;
  color: #fff;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.stat-label { font-size: 11px; color: rgba(200, 215, 245, .6); }

.result-score {
  margin: 14px 0 0;
  padding: 12px;
  border-radius: 16px;
  background: linear-gradient(130deg, rgba(255, 138, 61, .24), rgba(255, 138, 61, .05));
  border: 1px solid rgba(255, 166, 100, .4);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.result-num {
  font-size: 36px;
  font-weight: 800;
  color: #FFC38C;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.result-label { font-size: 11px; color: rgba(200, 215, 245, .62); letter-spacing: .08em; }

.btn-primary {
  width: 100%;
  margin-top: 14px;
  height: 52px;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(180deg, #FFA05C, var(--theme) 55%, var(--theme-deep));
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: .02em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 10px 22px rgba(232, 106, 28, .38), inset 0 1px 0 rgba(255, 255, 255, .5);
  transition: transform .12s ease, box-shadow .12s ease;
  font-family: inherit;
}
.btn-primary .mp-icon { width: 21px; height: 21px; font-size: 21px; }
.btn-primary:active {
  transform: translateY(2px) scale(.985);
  box-shadow: 0 4px 12px rgba(232, 106, 28, .32), inset 0 1px 0 rgba(255, 255, 255, .4);
}

.btn-ad {
  width: 100%;
  margin-top: 12px;
  height: 48px;
  border-radius: 15px;
  border: 1px solid rgba(255, 166, 100, .55);
  background: linear-gradient(180deg, rgba(255, 138, 61, .2), rgba(255, 138, 61, .1));
  color: #FFD9A8;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: transform .12s ease, background .15s ease, border-color .15s ease;
}
.btn-ad .mp-icon { width: 20px; height: 20px; font-size: 20px; color: #FFB45C; }
.btn-ad:active { transform: scale(.985); background: rgba(255, 138, 61, .28); }
.btn-ad:disabled {
  border-color: rgba(160, 180, 215, .22);
  background: rgba(255, 255, 255, .05);
  color: rgba(220, 232, 255, .48);
  transform: none;
}
.btn-ad:disabled .mp-icon { color: rgba(220, 232, 255, .4); }
.btn-ad.is-done { border-color: rgba(255, 186, 130, .3); color: rgba(255, 217, 168, .7); }

.ad-tip {
  margin: 7px 0 0;
  font-size: 11px;
  line-height: 1.4;
  color: rgba(200, 215, 245, .55);
}

.btn-ghost {
  width: 100%;
  margin-top: 10px;
  height: 46px;
  border-radius: 14px;
  border: 1px solid rgba(160, 185, 235, .2);
  background: rgba(255, 255, 255, .05);
  color: rgba(225, 235, 255, .78);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform .12s ease, background .12s ease;
}
.btn-ghost .mp-icon { width: 18px; height: 18px; font-size: 18px; color: rgba(200, 215, 245, .65); }
.btn-ghost:active { transform: scale(.985); background: rgba(255, 255, 255, .12); }

.panel-tip {
  margin: 10px 0 0;
  font-size: 11px;
  color: rgba(200, 215, 245, .45);
}

/* ---------- 提示 ---------- */
.toast {
  position: absolute;
  left: 50%;
  top: 17%;
  z-index: 30;
  max-width: 82%;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(8, 15, 34, .9);
  border: 1px solid rgba(255, 166, 100, .45);
  color: #FFE1BE;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -8px);
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-height: 700px) {
  .overlay { padding: 14px 16px calc(env(safe-area-inset-bottom, 0px) + 14px); }
  .panel { padding: 18px 16px 15px; border-radius: 22px; }
  .panel-title { font-size: 24px; margin-top: 8px; }
  .panel-desc { margin-top: 7px; font-size: 12px; }
  .panel-stats { margin-top: 12px; }
  .stat { padding: 8px 6px; }
  .btn-primary { margin-top: 12px; height: 48px; }
  .btn-ad { height: 44px; margin-top: 10px; }
  .result-num { font-size: 30px; }
  .result-score { margin-top: 10px; padding: 10px; }
  .panel-tip { margin-top: 8px; }
}

@media (max-width: 340px) {
  .panel { padding: 18px 14px 15px; }
  .panel-title { font-size: 23px; }
  .hud-value { font-size: 23px; }
  .overlay { padding-left: 14px; padding-right: 14px; }
}
