/* 5v5 小小塔防 · 竖屏卡通塔防 */
:root {
  --orange: #FF8A3D;
  --orange-deep: #E4611C;
  --orange-dark: #B94712;
  --gold: #FFC94F;
  --gold-deep: #F0A21E;
  --cream: #FFF8EA;
  --cream-2: #FFEFD2;
  --ink: #4A2A16;
  --ink-2: #6D4528;
  --ink-3: #9A714F;
  --line: #5B3319;
  --green: #62C75C;
  --blue: #59C8F5;
  --shadow: 0 10px 26px rgba(76, 40, 14, 0.22);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #180F08;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior: none;
  -webkit-touch-callout: none;
}
button { font-family: inherit; border: 0; cursor: pointer; color: inherit; }
button:focus-visible { outline: 3px solid #FFE08A; outline-offset: 3px; }
b, strong { font-weight: 800; }

.app {
  position: fixed; inset: 0; margin: 0 auto; width: 100%; max-width: 520px;
  overflow: hidden; background: #2B1A0E;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.55);
}
.screen { position: absolute; inset: 0; display: none; overflow: hidden; }
.screen.active { display: block; }

/* ================= 开始页 ================= */
.home { background: #8CD9FA; }
.home.active { display: flex; flex-direction: column; }
.home-sky {
  position: absolute; inset: 0; z-index: 0;
  background: linear-gradient(180deg, #3FB1F2 0%, #9CDFFC 44%, #EAF9FF 68%, #FFE8B8 100%);
}
.home-sun {
  position: absolute; z-index: 1; top: -90px; right: -70px; width: 300px; height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 247, 190, 0.95) 0%, rgba(255, 230, 130, 0.5) 32%, rgba(255, 220, 120, 0) 70%);
  pointer-events: none;
}
.cloud {
  position: absolute; z-index: 1; border-radius: 999px;
  background: rgba(255, 255, 255, 0.8);
  filter: blur(0.5px);
  box-shadow: 24px 6px 0 -4px rgba(255,255,255,.8), -22px 8px 0 -6px rgba(255,255,255,.7);
  pointer-events: none;
  animation: cloudFloat 14s ease-in-out infinite alternate;
}
.cloud-1 { top: 14%; left: 9%; width: 66px; height: 24px; opacity: .9; }
.cloud-2 { top: 22%; right: 8%; width: 52px; height: 19px; opacity: .75; animation-delay: -4s; animation-duration: 18s; }
.cloud-3 { top: 8%; left: 46%; width: 38px; height: 14px; opacity: .55; animation-delay: -8s; animation-duration: 22s; }
@keyframes cloudFloat {
  from { transform: translate3d(-6px, 0, 0); }
  to { transform: translate3d(12px, 3px, 0); }
}
.home-art {
  position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%;
  pointer-events: none;
}
.svg-cloud-a { animation: cloudFloat 12s ease-in-out infinite alternate; }
.svg-cloud-b { animation: cloudFloat 16s ease-in-out infinite alternate-reverse; }
.svg-cloud-c { animation: cloudFloat 20s ease-in-out infinite alternate; }
.home-shade {
  position: absolute; inset: 0; z-index: 3; pointer-events: none;
  background:
    linear-gradient(180deg, rgba(20, 70, 120, 0.10) 0%, rgba(20, 70, 120, 0) 30%),
    linear-gradient(180deg, rgba(70, 34, 8, 0) 54%, rgba(70, 34, 8, 0.20) 78%, rgba(52, 24, 5, 0.48) 100%);
}

.home-hud {
  position: relative; z-index: 9; flex: 0 0 auto;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  padding: calc(var(--safe-top) + 12px) 14px 0;
}
.player {
  display: flex; align-items: center; gap: 9px; min-width: 0;
  padding: 6px 12px 6px 6px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 249, 236, 0.94), rgba(255, 232, 199, 0.88));
  border: 2px solid rgba(255, 255, 255, 0.72);
  box-shadow: 0 6px 16px rgba(45, 24, 8, 0.26), inset 0 1px 0 rgba(255,255,255,.8);
  backdrop-filter: blur(6px);
}
.avatar {
  flex: 0 0 auto; width: 46px; height: 46px; border-radius: 50%;
  padding: 2px;
  background: linear-gradient(145deg, #FFD264, #FF8A3D 58%, #D95012);
  box-shadow: 0 3px 8px rgba(115, 54, 10, 0.35), inset 0 1px 2px rgba(255,255,255,.6);
}
.avatar svg { display: block; width: 100%; height: 100%; border-radius: 50%; background: #FFE2B2; }
.player-meta { min-width: 0; }
.player-line { display: flex; align-items: center; gap: 6px; }
.player-line b { font-size: 12.5px; line-height: 1.1; color: #5A3017; white-space: nowrap; }
.lv {
  font-size: 9px; font-weight: 800; color: #8A3D0A;
  padding: 2px 6px; border-radius: 999px;
  background: #FFD97C; border: 1px solid rgba(139, 75, 20, 0.25);
  white-space: nowrap;
}
.xp {
  width: 96px; height: 6px; margin-top: 5px; border-radius: 999px; overflow: hidden;
  background: rgba(100, 55, 20, 0.17);
  box-shadow: inset 0 1px 2px rgba(70, 35, 10, 0.25);
}
.xp i {
  display: block; height: 100%; width: 0%; border-radius: inherit;
  background: linear-gradient(90deg, #FFB13F, #FFD95E);
  box-shadow: 0 0 8px rgba(255, 174, 55, 0.8);
  transition: width .5s cubic-bezier(.2, .8, .3, 1);
}
.player-best { margin-top: 3px; font-size: 9.5px; color: #91613C; white-space: nowrap; }

.sound-btn {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 15px;
  display: inline-flex; align-items: center; justify-content: center;
  color: #6B3D1D;
  background: linear-gradient(180deg, rgba(255, 250, 239, 0.95), rgba(255, 231, 195, 0.9));
  border: 2px solid rgba(255, 255, 255, 0.72);
  box-shadow: 0 5px 14px rgba(45, 24, 8, 0.22), inset 0 1px 0 rgba(255,255,255,.8);
  backdrop-filter: blur(6px);
  transition: transform .12s ease;
}
.sound-btn:active { transform: scale(.92); }
.sound-btn .mp-icon { width: 22px; height: 22px; }
.sound-off { display: none !important; }
body.muted .sound-on { display: none !important; }
body.muted .sound-off { display: inline-block !important; }

.home-body {
  position: relative; z-index: 8; flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column;
  padding: 8px 18px calc(var(--safe-bottom) + 16px);
}
.logo-wrap {
  position: relative; text-align: center; margin-top: clamp(0px, 1.4vh, 14px);
  filter: drop-shadow(0 10px 18px rgba(80, 38, 8, 0.20));
}
.logo-ribbon {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px 5px 9px; border-radius: 999px;
  background: rgba(85, 42, 14, 0.78);
  border: 1.5px solid rgba(255, 232, 177, 0.55);
  color: #FFE9B0; font-size: 10.5px; font-weight: 700; letter-spacing: .06em;
  box-shadow: 0 4px 10px rgba(50, 25, 8, 0.25);
  backdrop-filter: blur(3px);
}
.logo-ribbon .mp-icon { width: 14px; height: 14px; color: #FFD05E; }
.logo-vs {
  display: flex; align-items: baseline; justify-content: center; gap: 2px;
  margin: 3px 0 -4px; line-height: .92;
  font-family: "Arial Rounded MT Bold", "Trebuchet MS", "PingFang SC", sans-serif;
  font-weight: 900; font-size: clamp(52px, 16vw, 70px);
  color: #FFD35C;
  -webkit-text-stroke: 2px #5B3319;
  text-shadow:
    3px 3px 0 #5B3319, -3px 3px 0 #5B3319, 3px -3px 0 #5B3319, -3px -3px 0 #5B3319,
    0 4px 0 #5B3319, 0 7px 0 #8C4A13, 0 12px 16px rgba(60, 30, 8, 0.4);
  transform: rotate(-2deg);
}
.logo-vs span { display: inline-block; }
.logo-vs em {
  font-style: normal; font-size: .64em; color: #FFF1C6;
  transform: translateY(-.1em) rotate(6deg);
  text-shadow: 2px 2px 0 #5B3319, -2px 2px 0 #5B3319, 2px -2px 0 #5B3319, -2px -2px 0 #5B3319, 0 4px 0 #5B3319;
}
.logo-title {
  margin: 0; line-height: 1.02; letter-spacing: .02em;
  font-size: clamp(34px, 10.2vw, 44px); font-weight: 900; color: #FFF6DC;
  text-shadow:
    2.5px 2.5px 0 #5B3319, -2.5px 2.5px 0 #5B3319, 2.5px -2.5px 0 #5B3319, -2.5px -2.5px 0 #5B3319,
    0 3px 0 #5B3319, 3px 0 0 #5B3319, 0 -3px 0 #5B3319, -3px 0 0 #5B3319,
    0 7px 0 #A95418, 0 12px 16px rgba(60, 30, 8, 0.35);
}
.logo-sub {
  display: inline-block; margin: 8px 0 0;
  padding: 4px 11px; border-radius: 999px;
  font-size: 10.5px; font-weight: 600; color: #FFF3D6;
  background: rgba(75, 38, 12, 0.44);
  border: 1px solid rgba(255, 240, 202, 0.3);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
.home-spacer { flex: 1 1 auto; min-height: 12px; }
.home-cta { position: relative; width: 100%; display: flex; flex-direction: column; align-items: center; }
.best-pill {
  margin-bottom: 8px; padding: 4px 12px; border-radius: 999px;
  font-size: 10.5px; font-weight: 700; color: #FFEDC0;
  background: rgba(58, 29, 8, 0.42);
  border: 1px solid rgba(255, 228, 170, 0.38);
  text-shadow: 0 1px 2px rgba(0,0,0,.3);
  backdrop-filter: blur(3px);
}
.start-btn {
  position: relative; width: 100%; min-height: 72px; overflow: hidden;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px 12px 11px;
  border-radius: 999px;
  color: #FFFDF6;
  background: linear-gradient(180deg, #FFC24B 0%, #FF8A3D 46%, #F06A1C 100%);
  border: 2.5px solid #7D3B11;
  box-shadow:
    0 7px 0 #B94A0E,
    0 13px 22px rgba(91, 41, 7, 0.35),
    inset 0 2px 0 rgba(255, 255, 255, 0.55),
    inset 0 -3px 0 rgba(146, 56, 6, 0.24);
  transition: transform .1s ease, box-shadow .1s ease;
}
.start-btn::after {
  content: ""; position: absolute; top: -40%; left: -30%; width: 34%; height: 180%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  transform: rotate(20deg);
  animation: shine 3.8s ease-in-out infinite;
}
@keyframes shine {
  0%, 62% { left: -40%; }
  82%, 100% { left: 130%; }
}
.start-btn:active {
  transform: translateY(5px);
  box-shadow: 0 2px 0 #B94A0E, 0 5px 10px rgba(91, 41, 7, 0.28), inset 0 2px 0 rgba(255,255,255,.4);
}
.start-icon {
  flex: 0 0 auto; width: 50px; height: 50px; border-radius: 50%;
  display: grid; place-items: center; color: #E4611C;
  background: linear-gradient(180deg, #FFFDF4, #FFE9BC);
  border: 2px solid rgba(126, 60, 14, 0.35);
  box-shadow: inset 0 2px 0 #fff, 0 3px 7px rgba(120, 55, 8, 0.22);
}
.start-icon .mp-icon { width: 30px; height: 30px; margin-left: 3px; }
.start-text { flex: 1 1 auto; min-width: 0; text-align: left; display: flex; flex-direction: column; gap: 1px; }
.start-text b { font-size: clamp(21px, 6.2vw, 25px); font-weight: 900; letter-spacing: .04em; text-shadow: 0 2px 0 rgba(164, 64, 8, 0.5); }
.start-text small { font-size: 10px; font-weight: 600; color: #FFEAC6; letter-spacing: .03em; }
.start-chevron { flex: 0 0 auto; font-size: 30px; line-height: 1; opacity: .85; transform: translateY(-2px); }
.home-hints {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  margin-top: 11px; color: #FFF4D8; font-size: 10.5px; font-weight: 600;
  text-shadow: 0 1px 3px rgba(50, 24, 6, 0.55);
}
.home-hints span { display: inline-flex; align-items: center; gap: 4px; }
.home-hints .mp-icon { width: 14px; height: 14px; color: #FFD77C; }
.hint-dot { width: 3px; height: 3px; border-radius: 50%; background: rgba(255, 240, 200, 0.6); }

/* ================= 游戏中 ================= */
.game { background: #64B94E; }
.game canvas {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.game-hud {
  position: absolute; z-index: 20;
  top: calc(var(--safe-top) + 10px); left: 12px; right: 12px;
  display: flex; align-items: center; gap: 8px;
  pointer-events: none;
}
.game-hud > * { pointer-events: auto; }
.hud-grow { flex: 1 1 auto; min-width: 4px; }
.hud-btn {
  width: 42px; height: 42px; border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  color: #6B3D1D;
  background: linear-gradient(180deg, rgba(255, 250, 239, 0.94), rgba(255, 231, 195, 0.9));
  border: 2px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 5px 12px rgba(45, 24, 8, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  transition: transform .1s ease;
}
.hud-btn:active { transform: scale(.92); }
.hud-btn .mp-icon { width: 21px; height: 21px; }
.wave-chip {
  height: 42px; display: inline-flex; align-items: center; gap: 6px;
  padding: 0 12px; border-radius: 14px;
  color: #FFF0CE; font-size: 12px; font-weight: 600;
  background: linear-gradient(180deg, rgba(89, 48, 20, 0.94), rgba(62, 31, 11, 0.94));
  border: 2px solid rgba(255, 222, 163, 0.32);
  box-shadow: 0 5px 12px rgba(35, 18, 4, 0.28), inset 0 1px 0 rgba(255,255,255,.12);
  white-space: nowrap;
}
.wave-chip .mp-icon { width: 15px; height: 15px; color: #FFC24B; }
.wave-chip b { color: #FFD66E; font-size: 14px; }
.coin-chip {
  height: 42px; display: inline-flex; align-items: center; gap: 7px;
  padding: 0 13px 0 8px; border-radius: 14px;
  color: #6B3512; font-size: 15px; font-weight: 900;
  background: linear-gradient(180deg, rgba(255, 251, 240, 0.96), rgba(255, 231, 189, 0.94));
  border: 2px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 5px 12px rgba(45, 24, 8, 0.24), inset 0 1px 0 #fff;
}
.coin-dot {
  position: relative; width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, #FFF3B0, #FFC53F 55%, #E9920D 100%);
  border: 2px solid #A9620B;
  box-shadow: inset 0 1px 2px rgba(255,255,255,.8), 0 2px 3px rgba(91, 41, 7, 0.25);
}
.coin-dot::after {
  content: ""; position: absolute; inset: 6px; border-radius: 50%;
  border: 1.5px solid #D98A10;
}

.hp-row {
  position: absolute; z-index: 19;
  top: calc(var(--safe-top) + 60px); left: 14px; right: 14px;
  display: flex; align-items: center; gap: 7px;
  pointer-events: none;
}
.hp-shield {
  width: 22px; height: 22px; display: grid; place-items: center;
  color: #FFF1CC;
  filter: drop-shadow(0 2px 3px rgba(40, 20, 5, 0.45));
}
.hp-shield .mp-icon { width: 18px; height: 18px; }
.hp-track {
  flex: 1 1 auto; height: 14px; border-radius: 999px; overflow: hidden;
  background: rgba(51, 26, 8, 0.42);
  border: 2px solid rgba(255, 244, 218, 0.42);
  box-shadow: inset 0 2px 4px rgba(30, 15, 3, 0.38), 0 2px 5px rgba(30, 15, 3, 0.18);
}
.hp-track i {
  display: block; height: 100%; width: 100%; border-radius: inherit;
  background: linear-gradient(90deg, #FF7B54, #FFB23E 55%, #FFD866);
  box-shadow: 0 0 10px rgba(255, 174, 63, 0.55);
  transition: width .28s ease, background .3s ease;
}
.hp-track i.low { background: linear-gradient(90deg, #E93B2E, #FF6A3D); animation: hpPulse 1s infinite; }
@keyframes hpPulse { 50% { opacity: .66; } }
.hp-row > b {
  min-width: 26px; text-align: right; font-size: 13px; color: #FFF4D7;
  text-shadow: 0 2px 3px rgba(45, 20, 4, 0.6);
}

.wave-call {
  position: absolute; z-index: 18;
  top: calc(var(--safe-top) + 86px); left: 50%;
  display: flex; align-items: center; gap: 8px;
  padding: 7px 13px 7px 10px; border-radius: 999px;
  color: #5D2C0C; font-size: 11.5px; font-weight: 800; white-space: nowrap;
  background: linear-gradient(180deg, #FFF8E6, #FFE1A6);
  border: 2px solid #7D3B11;
  box-shadow: 0 4px 0 rgba(168, 72, 10, 0.8), 0 8px 16px rgba(50, 25, 5, 0.26);
  transform: translate(-50%, -8px); opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.wave-call.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.wave-call:active { transform: translate(-50%, 2px) scale(.98); }
.wave-call em {
  font-style: normal; font-size: 9.5px; color: #FFF8EA;
  padding: 2px 6px; border-radius: 999px;
  background: #E4611C;
}
.wc-pulse {
  width: 9px; height: 9px; border-radius: 50%; background: #FF8A3D;
  box-shadow: 0 0 0 0 rgba(255, 138, 61, 0.7);
  animation: wcPulse 1.5s infinite;
}
@keyframes wcPulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 138, 61, 0.7); }
  70% { box-shadow: 0 0 0 8px rgba(255, 138, 61, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 138, 61, 0); }
}

.wave-banner {
  position: absolute; z-index: 17; top: 29%; left: 50%;
  width: 86%; max-width: 340px; text-align: center;
  transform: translate(-50%, 10px) scale(.92); opacity: 0;
  pointer-events: none;
}
.wave-banner.show { animation: bannerIn 1.9s cubic-bezier(.2, .8, .3, 1) forwards; }
.wave-banner b {
  display: block; font-size: clamp(28px, 8.5vw, 38px); font-weight: 900; color: #FFF7DC;
  -webkit-text-stroke: 1.5px #5B3319;
  text-shadow: 0 3px 0 #5B3319, 0 8px 16px rgba(40, 20, 4, 0.5);
}
.wave-banner span {
  display: inline-block; margin-top: 5px; padding: 4px 12px; border-radius: 999px;
  font-size: 11px; font-weight: 700; color: #FFEDC4;
  background: rgba(60, 30, 9, 0.62);
  border: 1px solid rgba(255, 230, 172, 0.4);
}
@keyframes bannerIn {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(.9); }
  13% { opacity: 1; transform: translate(-50%, 0) scale(1.04); }
  22% { transform: translate(-50%, 0) scale(1); }
  78% { opacity: 1; transform: translate(-50%, -2px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -12px) scale(.98); }
}

.toast {
  position: absolute; z-index: 30; left: 50%; bottom: calc(var(--safe-bottom) + 142px);
  max-width: 82%; padding: 9px 15px; border-radius: 999px;
  color: #FFF5DA; font-size: 11.5px; font-weight: 700; text-align: center;
  background: rgba(57, 29, 8, 0.86);
  border: 1.5px solid rgba(255, 222, 162, 0.35);
  box-shadow: 0 7px 18px rgba(35, 18, 4, 0.3);
  transform: translate(-50%, 8px); opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 塔操作面板 */
.tower-panel {
  position: absolute; z-index: 35;
  left: 10px; right: 10px; bottom: calc(var(--safe-bottom) + 10px);
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; border-radius: 22px;
  background: linear-gradient(180deg, #FFFCF3 0%, #FFEFD0 100%);
  border: 2.5px solid #5B3319;
  box-shadow: 0 9px 0 rgba(111, 53, 13, 0.32), 0 16px 28px rgba(38, 20, 4, 0.35), inset 0 1px 0 #fff;
  transform: translateY(calc(100% + 30px)); opacity: 0; pointer-events: none;
  transition: transform .22s cubic-bezier(.2, .9, .3, 1.15), opacity .16s ease;
}
.tower-panel.open { transform: translateY(0); opacity: 1; pointer-events: auto; }
.tp-badge {
  flex: 0 0 auto; width: 48px; height: 48px; border-radius: 16px;
  display: grid; place-items: center;
  background: var(--tw-color, #62C75C);
  border: 2px solid #5B3319;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.45), 0 3px 0 rgba(91, 51, 25, 0.28);
}
.tp-badge span {
  width: 19px; height: 19px; border-radius: 50%;
  background: #FFF4D6; border: 2px solid #5B3319;
  box-shadow: inset 0 -3px 0 rgba(255, 170, 60, 0.45);
}
.tp-main { flex: 1 1 auto; min-width: 0; }
.tp-title { display: flex; align-items: center; gap: 6px; }
.tp-title b { font-size: 14px; color: #4A2A16; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tp-title span {
  flex: 0 0 auto; font-size: 9px; font-weight: 900; color: #8A3D0A;
  padding: 2px 6px; border-radius: 999px; background: #FFD97C;
}
.tp-desc { margin-top: 2px; font-size: 10px; color: #8C6041; }
.tp-stats { margin-top: 3px; font-size: 10px; font-weight: 700; color: #5B3A22; white-space: nowrap; }
.tp-up {
  flex: 0 0 auto; width: 80px; height: 54px; border-radius: 15px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  color: #FFFDF4; font-size: 12px; font-weight: 800;
  background: linear-gradient(180deg, #FFB23E, #F06A1C);
  border: 2px solid #7D3B11;
  box-shadow: 0 4px 0 #B94A0E, inset 0 1px 0 rgba(255,255,255,.45);
  transition: transform .1s ease, filter .2s ease;
}
.tp-up b { font-size: 15px; line-height: 1; }
.tp-up b::before {
  content: ""; display: inline-block; width: 11px; height: 11px; margin-right: 3px;
  border-radius: 50%; vertical-align: -1px;
  background: radial-gradient(circle at 35% 30%, #FFF3B0, #FFC53F 60%, #E9920D);
  border: 1.5px solid #8A4A08;
}
.tp-up:active { transform: translateY(2px); }
.tp-up.poor { filter: saturate(.55) brightness(.9); }
.tp-up.max { background: linear-gradient(180deg, #C9B79D, #A98F6D); box-shadow: 0 4px 0 #7C6448; font-size: 11px; color: #FFF8EA; }
.tp-up.max b, .tp-up.max b::before { display: none; }
.tp-close {
  position: absolute; top: -11px; right: -7px;
  width: 27px; height: 27px; border-radius: 50%;
  display: grid; place-items: center; color: #FFF4D5;
  background: #6D4528; border: 2px solid #FFF0CE;
  box-shadow: 0 2px 5px rgba(40, 20, 4, 0.3);
}
.tp-close .mp-icon { width: 15px; height: 15px; }

/* 弹层 */
.modal-overlay {
  position: absolute; inset: 0; z-index: 60;
  display: none; align-items: center; justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 40%, rgba(255, 150, 70, 0.16), transparent 55%), rgba(38, 20, 8, 0.72);
  backdrop-filter: blur(4px);
}
.modal-overlay.show { display: flex; animation: overlayIn .2s ease both; }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  width: 100%; max-width: 318px; padding: 24px 20px 20px;
  text-align: center; border-radius: 26px;
  background: linear-gradient(180deg, #FFFCF2, #FFEDCE);
  border: 3px solid #5B3319;
  box-shadow: 0 20px 40px rgba(30, 15, 3, 0.45), inset 0 1px 0 #fff;
  animation: cardIn .24s cubic-bezier(.2, .9, .3, 1.22) both;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
.modal-kicker {
  display: inline-block; padding: 4px 11px; border-radius: 999px;
  font-size: 9.5px; font-weight: 800; letter-spacing: .12em; color: #8A3D0A;
  background: #FFD97C; border: 1px solid rgba(128, 65, 14, 0.2);
}
.modal-card h2 { margin: 10px 0 4px; font-size: 22px; color: #4A2A16; }
.modal-card p { margin: 0 0 18px; font-size: 11.5px; color: #8C6041; }
.btn-primary {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 52px; border-radius: 16px;
  font-size: 16px; font-weight: 900; color: #FFFDF4; letter-spacing: .03em;
  background: linear-gradient(180deg, #FFB23E, #F06A1C);
  border: 2px solid #7D3B11;
  box-shadow: 0 5px 0 #B94A0E, 0 9px 16px rgba(120, 52, 8, 0.28), inset 0 1px 0 rgba(255,255,255,.45);
  transition: transform .1s ease;
}
.btn-primary:active { transform: translateY(4px); box-shadow: 0 1px 0 #B94A0E; }
.btn-soft {
  width: 100%; height: 46px; margin-top: 9px; border-radius: 14px;
  font-size: 13px; font-weight: 800; color: #6B4529;
  background: #FFF7E5; border: 2px solid rgba(107, 69, 41, 0.22);
  box-shadow: 0 3px 0 rgba(107, 69, 41, 0.14);
}
.btn-soft:active { transform: translateY(2px); }
.btn-text {
  width: 100%; height: 38px; margin-top: 4px; background: transparent;
  font-size: 11.5px; font-weight: 700; color: #9A714F;
}
.btn-ghost {
  width: 100%; height: 46px; margin-top: 9px; border-radius: 14px;
  font-size: 13px; font-weight: 800; color: #6B4529;
  background: rgba(255, 248, 232, 0.65);
  border: 2px solid rgba(107, 69, 41, 0.22);
}
.btn-ghost:active { transform: translateY(2px); }

/* 结算 */
.end-overlay {
  position: absolute; inset: 0; z-index: 55;
  display: none; align-items: center; justify-content: center;
  padding: calc(var(--safe-top) + 14px) 18px calc(var(--safe-bottom) + 14px);
  background:
    radial-gradient(circle at 50% 32%, rgba(255, 152, 63, 0.28), transparent 56%),
    rgba(34, 18, 8, 0.74);
  backdrop-filter: blur(4px);
}
.end-overlay.show { display: flex; animation: overlayIn .25s ease both; }
.end-card {
  position: relative; z-index: 2; width: 100%; max-width: 354px;
  padding: 20px 18px 16px; text-align: center;
  border-radius: 28px;
  background: linear-gradient(180deg, #FFFDF4 0%, #FFF4DC 48%, #FFE6BC 100%);
  border: 3px solid #5B3319;
  box-shadow: 0 10px 0 rgba(111, 53, 13, 0.28), 0 24px 48px rgba(20, 10, 2, 0.5), inset 0 1px 0 #fff;
  animation: cardIn .3s cubic-bezier(.2, .9, .3, 1.2) both;
}
.end-burst {
  position: absolute; z-index: -1; top: -120px; left: 50%; width: 340px; height: 340px;
  transform: translateX(-50%); border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 208, 96, 0.55), rgba(255, 180, 70, 0) 66%);
  pointer-events: none;
}
.end-kicker {
  display: inline-block; padding: 4px 12px; border-radius: 999px;
  font-size: 9.5px; font-weight: 800; letter-spacing: .14em; color: #8A3D0A;
  background: #FFD97C; border: 1px solid rgba(128, 65, 14, 0.22);
}
.end-crest { width: 64px; height: 64px; margin: 7px auto 2px; filter: drop-shadow(0 5px 8px rgba(100, 48, 8, 0.25)); }
.end-crest svg { display: block; width: 100%; height: 100%; }
.end-card h2 {
  margin: 3px 0 2px; font-size: 26px; line-height: 1.15; letter-spacing: .01em;
  color: #5B3319;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.9);
}
.end-sub { margin: 0; font-size: 11px; color: #91613C; }
.stars { display: flex; align-items: center; justify-content: center; gap: 8px; height: 38px; margin: 5px 0 2px; }
.star {
  width: 28px; height: 28px; display: inline-block;
  clip-path: polygon(50% 0%, 63% 35%, 100% 38%, 71% 60%, 82% 96%, 50% 74%, 18% 96%, 29% 60%, 0% 38%, 37% 35%);
  background: rgba(108, 72, 42, 0.18);
  transition: background .25s ease;
}
.star.on {
  background: linear-gradient(180deg, #FFE98B, #FFB62E 58%, #F08A14);
  filter: drop-shadow(0 2px 2px rgba(150, 75, 8, 0.32));
  animation: starPop .45s cubic-bezier(.2, .9, .3, 1.4) both;
}
.star.on:nth-child(2) { animation-delay: .1s; }
.star.on:nth-child(3) { animation-delay: .2s; }
@keyframes starPop { from { transform: scale(.2) rotate(-24deg); opacity: 0; } to { transform: none; opacity: 1; } }
.end-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  margin: 8px 0 0; padding: 9px 6px; border-radius: 16px;
  background: rgba(255, 255, 255, 0.5);
  border: 1.5px solid rgba(107, 69, 41, 0.14);
}
.end-stats div { display: flex; flex-direction: column; gap: 1px; }
.end-stats b { font-size: 20px; line-height: 1.1; color: #5B3319; }
.end-stats span { font-size: 9.5px; color: #91613C; }
.end-record {
  display: inline-block; margin: 8px 0 0; padding: 4px 11px; border-radius: 999px;
  font-size: 9.5px; font-weight: 800; color: #8A3D0A;
  background: #FFE3A1; border: 1px solid rgba(160, 90, 20, 0.18);
}
.btn-end { margin-top: 11px; height: 50px; }
.end-card .btn-ghost { margin-top: 8px; height: 42px; }
.end-overlay.lose .end-card { background: linear-gradient(180deg, #FBF5EC 0%, #EDE2D2 55%, #DCCBB4 100%); }
.end-overlay.lose .end-crest svg path:nth-child(1) { fill: #A8A19A; }
.end-overlay.lose .end-crest svg path:nth-child(2) { fill: #E4DDD2; }
.end-overlay.lose .end-crest svg path:nth-child(3) { fill: #8D7C69; }
.end-overlay.lose .end-burst { background: radial-gradient(circle, rgba(170, 165, 155, 0.3), transparent 66%); }
.confetti {
  position: absolute; z-index: 1; top: -24px; width: 8px; height: 13px;
  border-radius: 2px; opacity: 0; pointer-events: none;
  animation: confettiFall linear infinite;
}
@keyframes confettiFall {
  0% { transform: translate3d(0, -20px, 0) rotate(0deg); opacity: 0; }
  8% { opacity: 1; }
  100% { transform: translate3d(var(--drift, 30px), 110vh, 0) rotate(640deg); opacity: .85; }
}

/* 小屏适配 */
@media (max-height: 680px) {
  .home-body { padding-top: 2px; }
  .logo-vs { font-size: clamp(44px, 14vw, 58px); }
  .logo-title { font-size: clamp(28px, 8.6vw, 36px); }
  .logo-sub { margin-top: 5px; font-size: 9.5px; }
  .logo-ribbon { font-size: 9.5px; }
  .home-hints { margin-top: 7px; font-size: 9.5px; }
  .best-pill { margin-bottom: 5px; }
  .start-btn { min-height: 64px; padding-top: 7px; padding-bottom: 10px; }
  .start-icon { width: 44px; height: 44px; }
  .start-icon .mp-icon { width: 26px; height: 26px; }
  .end-card { padding: 16px 16px 13px; }
  .end-crest { width: 52px; height: 52px; }
  .end-card h2 { font-size: 23px; }
  .stars { height: 32px; }
  .star { width: 24px; height: 24px; }
}
@media (max-height: 590px) {
  .player-best, .logo-sub, .home-hints, .best-pill { display: none; }
  .logo-ribbon { display: none; }
  .logo-wrap { margin-top: -4px; }
  .home-spacer { min-height: 4px; }
  .start-btn { min-height: 58px; }
  .end-crest { display: none; }
  .end-card { max-width: 330px; }
  .end-card h2 { font-size: 21px; margin-top: 6px; }
  .end-stats b { font-size: 17px; }
}
@media (orientation: landscape) and (max-height: 540px) {
  .home-body { padding-left: 54px; padding-right: 54px; }
  .logo-vs { font-size: 42px; }
  .logo-title { font-size: 28px; }
  .logo-sub, .home-hints, .best-pill, .logo-ribbon { display: none; }
  .home-spacer { min-height: 2px; }
  .start-btn { min-height: 56px; max-width: 360px; margin: 0 auto; }
  .home-cta { align-items: center; }
  .tower-panel { left: 12%; right: 12%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
