:root {
  --orange: #FF8A3D;
  --orange-hot: #F86A18;
  --orange-deep: #8C3708;
  --orange-soft: #FFC48F;
  --cream: #FFF5E6;
  --mint: #8FE6A8;
  --green: #35C97A;
  --deep: #04110F;
  --panel: #0C2A23;
  --line: rgba(255, 240, 220, 0.13);
  --muted: rgba(255, 244, 226, 0.62);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --dock-h: 204px;
}

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

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #020b09;
}

body {
  color: var(--cream);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

button {
  font-family: inherit;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

img {
  -webkit-user-drag: none;
}

.app {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  overflow: hidden;
  background: #061512;
  isolation: isolate;
  touch-action: none;
}

@media (min-width: 540px) {
  body {
    background:
      radial-gradient(900px 600px at 50% 18%, #0e3a30 0%, #020b09 68%),
      #020b09;
  }
  .app {
    box-shadow: 0 0 0 1px rgba(255, 138, 61, 0.16), 0 34px 90px rgba(0, 0, 0, 0.72);
  }
}

/* ═══════════ 主界面 ═══════════ */
.home {
  position: absolute;
  inset: 0;
  z-index: 20;
  overflow: hidden;
  background: #051411;
  transition: opacity 0.55s ease, transform 0.75s cubic-bezier(0.16, 0.8, 0.3, 1);
}

.home-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 42%;
  display: block;
  filter: saturate(1.04) contrast(1.02);
  animation: artDrift 24s ease-in-out infinite alternate;
}

.home-shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(3, 14, 12, 0.46) 0%, rgba(3, 14, 12, 0) 24%, rgba(3, 14, 12, 0) 48%, rgba(3, 14, 12, 0.72) 72%, #04110f 96%),
    radial-gradient(120% 60% at 50% 100%, rgba(255, 138, 61, 0.14), transparent 62%);
  pointer-events: none;
}

.home-top {
  position: absolute;
  z-index: 3;
  top: calc(var(--safe-top) + 13px);
  left: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.home-stamp,
.home-waves {
  height: 31px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid rgba(255, 196, 143, 0.26);
  background: rgba(4, 20, 16, 0.62);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.16em;
  color: #FFD9B6;
  white-space: nowrap;
}

.stamp-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(53, 201, 122, 0.15), 0 0 8px rgba(53, 201, 122, 0.9);
}

.home-waves {
  letter-spacing: 0.04em;
  font-size: 11px;
  color: #FFE2C5;
}

.home-waves .mp-icon {
  width: 14px;
  height: 14px;
  color: var(--orange);
}

.home-content {
  position: absolute;
  z-index: 4;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0 14px calc(13px + var(--safe-bottom));
}

.home-card {
  position: relative;
  padding: 15px 16px 13px;
  border-radius: 25px;
  border: 1px solid rgba(255, 196, 143, 0.2);
  background:
    radial-gradient(120% 100% at 50% 0%, rgba(255, 138, 61, 0.14), transparent 52%),
    linear-gradient(180deg, rgba(13, 43, 35, 0.88) 0%, rgba(4, 19, 15, 0.96) 62%, rgba(3, 15, 12, 0.99) 100%);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.58),
    inset 0 1px 0 rgba(255, 255, 255, 0.13);
  overflow: hidden;
  animation: cardRise 0.72s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.home-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 22%;
  right: 22%;
  height: 1.5px;
  background: linear-gradient(90deg, transparent, rgba(255, 207, 158, 0.95), transparent);
}

.home-eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.22em;
  color: rgba(255, 196, 143, 0.78);
}

.eyebrow-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(255, 138, 61, 0.42), transparent);
}

.home-title {
  margin: 5px 0 0;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 3px 10px;
  line-height: 1;
}

.title-turtle {
  font-size: clamp(38px, 11.4vw, 46px);
  font-weight: 900;
  letter-spacing: 0.03em;
  color: #FFF8EC;
  text-shadow:
    0 2px 0 #A3400D,
    0 5px 0 rgba(103, 40, 6, 0.5),
    0 12px 28px rgba(0, 0, 0, 0.55);
  -webkit-text-stroke: 1px rgba(255, 210, 165, 0.14);
}

.title-sub {
  font-size: clamp(17px, 5vw, 21px);
  font-weight: 900;
  letter-spacing: 0.08em;
  color: var(--orange);
  text-shadow: 0 2px 10px rgba(255, 110, 26, 0.32);
}

.home-desc {
  margin: 8px 0 0;
  font-size: 11.5px;
  line-height: 1.62;
  color: rgba(255, 241, 224, 0.7);
  letter-spacing: 0.01em;
}

.home-turtles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin: 11px 0 12px;
}

.mascot {
  position: relative;
  height: 55px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
  border-radius: 13px;
  background:
    radial-gradient(90% 72% at 50% 24%, rgba(255, 255, 255, 0.07), transparent 72%),
    rgba(255, 255, 255, 0.04);
  background:
    radial-gradient(90% 72% at 50% 24%, color-mix(in srgb, var(--c) 26%, transparent), transparent 72%),
    rgba(255, 255, 255, 0.04);
  border: 1px solid color-mix(in srgb, var(--c) 34%, transparent);
  overflow: hidden;
}

.mascot img {
  width: 42px;
  height: 42px;
  margin-top: -2px;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.4));
}

.mascot span {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 2px;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: rgba(255, 245, 230, 0.82);
  text-align: center;
}

.start-btn {
  position: relative;
  width: 100%;
  height: 56px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #3F1602;
  background: linear-gradient(180deg, #FFC47E 0%, #FF8A3D 46%, #F16E1B 100%);
  border: 2px solid #6B2802;
  box-shadow:
    0 6px 0 #8C3708,
    0 14px 26px rgba(255, 106, 26, 0.4),
    inset 0 2px 0 rgba(255, 255, 255, 0.58);
  overflow: hidden;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.start-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: 8%;
  right: 8%;
  height: 1px;
  background: rgba(255, 255, 255, 0.8);
}

.start-btn .mp-icon {
  position: relative;
  z-index: 1;
  width: 26px;
  height: 26px;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.35));
}

.start-btn b {
  position: relative;
  z-index: 1;
  font-size: 19px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.32);
}

.start-sub {
  position: relative;
  z-index: 1;
  align-self: flex-end;
  margin: 0 0 13px 2px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(76, 29, 2, 0.16);
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #5B2203;
}

.start-shine {
  position: absolute;
  top: -40%;
  left: -60%;
  width: 38%;
  height: 180%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  transform: rotate(18deg);
  animation: startShine 3.6s ease-in-out infinite;
}

.start-btn:active {
  transform: translateY(5px);
  box-shadow:
    0 1px 0 #8C3708,
    0 6px 12px rgba(255, 106, 26, 0.26),
    inset 0 2px 0 rgba(255, 255, 255, 0.42);
}

.home-note {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: rgba(255, 240, 220, 0.48);
}

.home-note .mp-icon {
  width: 13px;
  height: 13px;
  color: rgba(255, 196, 143, 0.7);
}

/* ═══════════ 游戏场景 ═══════════ */
.game {
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease;
  background:
    radial-gradient(120% 80% at 50% 10%, #123f34 0%, #071d18 46%, #04110f 100%);
}

.app.playing .home {
  opacity: 0;
  transform: scale(1.04) translateY(-10px);
  pointer-events: none;
}

.app.playing .game {
  opacity: 1;
  visibility: visible;
}

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

#bg { z-index: 0; }
#stage { z-index: 1; }

.game::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0.12;
  background-image:
    radial-gradient(rgba(255, 255, 255, 0.5) 0.6px, transparent 0.8px),
    radial-gradient(rgba(0, 0, 0, 0.55) 0.6px, transparent 0.8px);
  background-size: 5px 5px, 7px 7px;
  background-position: 0 0, 3px 4px;
  mix-blend-mode: overlay;
}

/* HUD */
.hud {
  position: absolute;
  z-index: 12;
  top: calc(var(--safe-top) + 9px);
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  pointer-events: none;
}

.hud-pill {
  height: 37px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 11px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(16, 49, 40, 0.94), rgba(5, 24, 20, 0.94));
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--cream);
  font-size: 14.5px;
  font-weight: 800;
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition: border-color 0.2s ease;
}

.hud-gold {
  border-color: rgba(255, 138, 61, 0.44);
}

.hud-gold b { color: #FFD8B2; }

.coin {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #FFC06F, #FF8A3D 58%, #E76412);
  border: 1.5px solid #873400;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.55);
  color: #6E2800;
  flex: 0 0 auto;
}

.coin .mp-icon {
  width: 14px;
  height: 14px;
}

.hud-wave {
  gap: 6px;
  padding: 0 10px;
  font-size: 12.5px;
  color: #EAF8F0;
  background: linear-gradient(180deg, rgba(21, 58, 47, 0.92), rgba(6, 27, 22, 0.94));
}

.hud-dim {
  font-size: 10px;
  font-weight: 700;
  color: rgba(234, 248, 240, 0.48);
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #64E39A;
  box-shadow: 0 0 0 3px rgba(100, 227, 154, 0.14), 0 0 8px rgba(100, 227, 154, 0.9);
  animation: dotPulse 1.8s ease-in-out infinite;
}

.hud-hp {
  color: #FFD7D0;
  border-color: rgba(255, 110, 86, 0.2);
}

.hud-hp .mp-icon {
  width: 17px;
  height: 17px;
  color: #FF7A66;
  filter: drop-shadow(0 0 5px rgba(255, 80, 60, 0.55));
}

.hud-hp.low {
  animation: hpWarn 0.9s ease-in-out infinite;
  border-color: rgba(255, 90, 74, 0.7);
}

.hud-pill.bump {
  animation: bump 0.34s ease;
}

/* Wave banner */
.wave-banner {
  position: absolute;
  z-index: 9;
  left: 50%;
  top: 26%;
  transform: translate(-50%, -6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  pointer-events: none;
  opacity: 0;
  text-align: center;
  width: max-content;
  max-width: 86%;
}

.wave-banner.show {
  animation: bannerShow 2.35s cubic-bezier(0.16, 0.8, 0.24, 1) forwards;
}

.wb-kicker {
  font-size: 9.5px;
  font-weight: 900;
  letter-spacing: 0.38em;
  color: #FFC48F;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.85);
}

.wave-banner b {
  font-size: 29px;
  line-height: 1.16;
  font-weight: 900;
  letter-spacing: 0.02em;
  color: #FFF8EC;
  text-shadow:
    0 2px 0 #7E2F06,
    0 5px 0 rgba(90, 32, 5, 0.55),
    0 12px 28px rgba(0, 0, 0, 0.68);
}

.wb-sub {
  font-size: 11.5px;
  font-weight: 700;
  color: #FFE1C4;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
}

/* Toast */
.toast {
  position: absolute;
  z-index: 18;
  left: 50%;
  bottom: calc(var(--dock-h) + 152px);
  transform: translate(-50%, 8px);
  max-width: 84%;
  padding: 9px 15px;
  border-radius: 999px;
  background: rgba(5, 22, 18, 0.94);
  border: 1px solid rgba(255, 138, 61, 0.48);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  color: #FFE6CC;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.warn {
  border-color: rgba(255, 100, 78, 0.7);
  color: #FFD3C9;
}

.toast.good {
  border-color: rgba(100, 227, 154, 0.62);
  color: #D5FFE7;
}

/* Build pads */
.pads {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
}

.pad {
  position: absolute;
  width: 46px;
  height: 46px;
  padding: 0;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  pointer-events: auto;
  border: 2px dashed rgba(255, 196, 143, 0.44);
  background:
    radial-gradient(circle at 50% 32%, #234b3e 0%, #0d2a22 62%, #071a15 100%);
  box-shadow:
    0 4px 10px rgba(0, 0, 0, 0.44),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  color: rgba(255, 196, 143, 0.8);
  transition: transform 0.14s ease, border-color 0.16s ease, box-shadow 0.16s ease;
  overflow: visible;
  animation: padIn 0.4s cubic-bezier(0.16, 1.2, 0.3, 1) both;
  animation-delay: var(--d, 0s);
}

.pad::before {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background-image: repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.035) 0 2px, transparent 2px 5px);
  pointer-events: none;
}

.pad::after {
  content: "+";
  position: relative;
  z-index: 1;
  font-size: 23px;
  font-weight: 500;
  line-height: 1;
  color: rgba(255, 196, 143, 0.75);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.pad.ready {
  border-style: solid;
  border-color: rgba(255, 138, 61, 0.92);
  box-shadow:
    0 0 0 4px rgba(255, 138, 61, 0.12),
    0 0 22px rgba(255, 138, 61, 0.4),
    0 4px 10px rgba(0, 0, 0, 0.4);
  animation: padReady 1.5s ease-in-out infinite;
}

.pad.ready::after {
  color: #FFC48F;
}

.pad.occupied {
  border: 2px solid var(--pc, var(--orange));
  background:
    radial-gradient(circle at 50% 38%, rgba(255, 255, 255, 0.14), #0a241d 70%, #061713 100%);
  background:
    radial-gradient(circle at 50% 38%, color-mix(in srgb, var(--pc) 34%, #12352b), #0a241d 70%, #061713 100%);
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--pc) 16%, transparent),
    0 6px 14px rgba(0, 0, 0, 0.48),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
  animation: none;
}

.pad.occupied::before {
  inset: 4px;
  border-color: color-mix(in srgb, var(--pc) 30%, transparent);
  background: none;
}

.pad.occupied::after {
  content: none;
}

.pad img {
  position: relative;
  z-index: 1;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: block;
  object-fit: cover;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.45));
}

.pad.selected {
  box-shadow:
    0 0 0 4px rgba(255, 196, 143, 0.18),
    0 0 24px rgba(255, 196, 143, 0.34),
    0 6px 14px rgba(0, 0, 0, 0.48);
  box-shadow:
    0 0 0 4px color-mix(in srgb, var(--pc) 22%, transparent),
    0 0 26px color-mix(in srgb, var(--pc) 55%, transparent),
    0 6px 14px rgba(0, 0, 0, 0.48);
}

.pad:active {
  transform: translate(-50%, -50%) scale(0.92);
}

.pad-lv {
  position: absolute;
  z-index: 2;
  right: -3px;
  bottom: -3px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #FFC078, #FF8A3D);
  border: 1.5px solid #5B2203;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
  color: #481900;
  font-size: 8.5px;
  font-weight: 900;
  line-height: 1;
}

/* Tower inspect panel */
.tower-panel {
  position: absolute;
  z-index: 14;
  left: 12px;
  right: 12px;
  bottom: calc(var(--dock-h) + 82px);
  min-height: 62px;
  padding: 8px 9px 8px 10px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  background:
    radial-gradient(120% 100% at 0% 0%, rgba(255, 138, 61, 0.12), transparent 52%),
    linear-gradient(180deg, rgba(15, 47, 39, 0.97), rgba(5, 23, 19, 0.98));
  border: 1px solid rgba(255, 196, 143, 0.28);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: panelIn 0.24s cubic-bezier(0.16, 1.1, 0.3, 1) both;
}

.tower-panel[hidden] {
  display: none;
}

.tp-img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex: 0 0 auto;
  border: 2px solid var(--pc, var(--orange));
  background: radial-gradient(circle at 50% 35%, #1e4a3c, #0a241d);
  object-fit: cover;
}

.tp-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.tp-line {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tp-line b {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.02em;
  color: #FFF3E2;
  white-space: nowrap;
}

.tp-lv {
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(255, 138, 61, 0.16);
  border: 1px solid rgba(255, 138, 61, 0.3);
  font-size: 8px;
  font-weight: 900;
  color: #FFC48F;
}

.tp-stats {
  font-size: 9.5px;
  font-weight: 600;
  color: rgba(255, 241, 224, 0.56);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upgrade-btn {
  flex: 0 0 auto;
  min-width: 76px;
  height: 44px;
  padding: 4px 8px;
  border-radius: 12px;
  display: grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  align-content: center;
  justify-content: center;
  column-gap: 4px;
  color: #431701;
  background: linear-gradient(180deg, #FFC07A, #FF8A3D 52%, #EE6A17);
  border: 1.5px solid #6B2802;
  box-shadow: 0 3px 0 #8C3708, inset 0 1px 0 rgba(255, 255, 255, 0.5);
  transition: transform 0.12s ease, filter 0.15s ease;
}

.upgrade-btn .mp-icon {
  grid-row: 1 / 3;
  align-self: center;
  width: 17px;
  height: 17px;
}

.upgrade-btn span {
  font-size: 11.5px;
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.upgrade-btn em {
  font-size: 9px;
  font-style: normal;
  font-weight: 900;
  line-height: 1.15;
  color: #572104;
  opacity: 0.85;
  white-space: nowrap;
}

.upgrade-btn:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 #8C3708, inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.upgrade-btn[disabled] {
  filter: saturate(0.2) brightness(0.8);
  box-shadow: none;
}

.tp-close {
  flex: 0 0 auto;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: rgba(255, 241, 224, 0.55);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.tp-close .mp-icon {
  width: 15px;
  height: 15px;
}

.tp-close:active {
  background: rgba(255, 255, 255, 0.12);
}

/* Wave button */
.wave-btn {
  position: absolute;
  z-index: 11;
  right: 13px;
  bottom: calc(var(--dock-h) + 12px);
  width: 96px;
  height: 59px;
  border-radius: 18px;
  padding: 4px 6px 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #3F1602;
  background: linear-gradient(180deg, #FFC076 0%, #FF8A3D 46%, #F56D1A 100%);
  border: 2px solid #6B2802;
  box-shadow:
    0 6px 0 #8C3708,
    0 14px 26px rgba(255, 106, 26, 0.42),
    inset 0 2px 0 rgba(255, 255, 255, 0.55);
  overflow: hidden;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.2s ease;
  animation: waveBreathe 2.6s ease-in-out infinite;
}

.wave-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: 8%;
  right: 8%;
  height: 1px;
  background: rgba(255, 255, 255, 0.75);
}

.wave-shine {
  position: absolute;
  top: -30%;
  left: -60%;
  width: 40%;
  height: 160%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  transform: rotate(18deg);
  animation: waveShine 3.4s ease-in-out infinite;
}

.wave-label {
  position: relative;
  z-index: 1;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1.1;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

.wave-sub {
  position: relative;
  z-index: 1;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #552003;
  opacity: 0.82;
}

.wave-btn:active:not([disabled]) {
  transform: translateY(5px);
  box-shadow:
    0 1px 0 #8C3708,
    0 6px 12px rgba(255, 106, 26, 0.28),
    inset 0 2px 0 rgba(255, 255, 255, 0.4);
}

.wave-btn[disabled] {
  animation: none;
  filter: saturate(0.55) brightness(0.76);
  border-color: #163a30;
  color: #9FC7B8;
  background: linear-gradient(180deg, #2A5A4B, #1A4137);
  box-shadow: 0 5px 0 #0c2a22, 0 10px 18px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.wave-btn[disabled] .wave-sub { color: #9FC7B8; }
.wave-btn[disabled] .wave-shine { display: none; }
.wave-btn.won { filter: saturate(0.4) brightness(0.72); animation: none; }

/* Dock */
.dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  padding: 11px 12px calc(9px + var(--safe-bottom));
  background:
    radial-gradient(120% 120% at 50% 0%, rgba(43, 96, 78, 0.56) 0%, rgba(14, 43, 36, 0.95) 44%, #071c17 100%),
    #0a241f;
  border-top: 1px solid rgba(255, 138, 61, 0.34);
  border-radius: 22px 22px 0 0;
  box-shadow:
    0 -1px 0 rgba(255, 204, 157, 0.16),
    0 -18px 42px rgba(0, 0, 0, 0.52);
}

.dock::before {
  content: "";
  position: absolute;
  top: 5px;
  left: 22%;
  right: 22%;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, rgba(255, 138, 61, 0.55), transparent);
  opacity: 0.8;
}

.dock-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 18px;
  margin-bottom: 7px;
}

.dock-brand {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.06em;
  color: #FFE3C8;
  white-space: nowrap;
}

.brand-tick {
  width: 3px;
  height: 12px;
  border-radius: 2px;
  background: linear-gradient(180deg, #FFC48F, var(--orange));
  box-shadow: 0 0 8px rgba(255, 138, 61, 0.65);
}

.brand-en {
  font-size: 6.5px;
  letter-spacing: 0.15em;
  color: rgba(255, 196, 143, 0.52);
  transform: translateY(1px);
}

.next-wave {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: rgba(255, 241, 224, 0.56);
}

.next-wave .mp-icon {
  width: 12px;
  height: 12px;
  color: rgba(255, 138, 61, 0.8);
  flex: 0 0 auto;
}

.next-wave span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.roster {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.hero-card {
  position: relative;
  height: 104px;
  padding: 3px 2px 6px;
  border-radius: 15px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 0;
  background:
    radial-gradient(80% 55% at 50% 13%, color-mix(in srgb, var(--c) 30%, transparent), transparent 72%),
    linear-gradient(180deg, #1b473a 0%, #123128 72%, #0d271f 100%);
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 3px 8px rgba(0, 0, 0, 0.24);
  color: var(--cream);
  transition: transform 0.16s cubic-bezier(0.3, 1.5, 0.5, 1), border-color 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
  overflow: hidden;
}

.hero-card::after {
  content: "";
  position: absolute;
  left: 13%;
  right: 13%;
  bottom: 0;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: transparent;
  transition: background 0.16s ease;
}

.hero-card.selected {
  transform: translateY(-5px);
  border-color: var(--c);
  box-shadow:
    0 0 0 1px var(--c),
    0 10px 20px rgba(0, 0, 0, 0.4),
    0 0 26px rgba(255, 196, 143, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--c) 55%, transparent),
    0 10px 20px rgba(0, 0, 0, 0.4),
    0 0 26px color-mix(in srgb, var(--c) 38%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.hero-card.selected::after {
  background: linear-gradient(90deg, transparent, var(--c), transparent);
  box-shadow: 0 0 10px var(--c);
}

.hero-card:active {
  transform: scale(0.955);
}

.hero-card.poor {
  filter: saturate(0.6) brightness(0.82);
}

.hero-card.poor.selected {
  filter: saturate(0.72) brightness(0.9);
}

.hero-portrait {
  position: relative;
  width: 54px;
  height: 52px;
  margin-top: 1px;
  flex: 0 0 auto;
  display: block;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, #174034, #0a241d 74%);
  background: radial-gradient(circle at 50% 38%, color-mix(in srgb, var(--c) 32%, #173c30), #0a241d 74%);
  border: 1.5px solid color-mix(in srgb, var(--c) 55%, transparent);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.32);
  overflow: hidden;
}

.hero-portrait img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.hero-name {
  margin-top: 3px;
  font-size: 10.5px;
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: -0.02em;
  white-space: nowrap;
  color: #F4FFF7;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.hero-role {
  font-size: 8px;
  font-weight: 700;
  line-height: 1.2;
  color: rgba(255, 241, 224, 0.46);
  white-space: nowrap;
}

.hero-cost {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-top: 1px;
  font-size: 9.5px;
  font-weight: 900;
  color: #FFD2A4;
  line-height: 1.2;
}

.hero-cost .mp-icon {
  width: 10px;
  height: 10px;
  color: var(--orange);
}

.hero-card.poor .hero-cost { color: #FF9282; }

/* Result */
.result {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(2, 11, 9, 0.68);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  opacity: 0;
  transition: opacity 0.32s ease;
}

.result.show { opacity: 1; }
.result[hidden] { display: none; }

.result-card {
  position: relative;
  width: 100%;
  max-width: 338px;
  padding: 22px 20px 18px;
  border-radius: 26px;
  text-align: center;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(255, 138, 61, 0.2), transparent 55%),
    linear-gradient(180deg, #184338 0%, #0c2a23 55%, #081f1a 100%);
  border: 1.5px solid rgba(255, 138, 61, 0.45);
  box-shadow:
    0 34px 80px rgba(0, 0, 0, 0.66),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
  transform: translateY(18px) scale(0.95);
  transition: transform 0.42s cubic-bezier(0.16, 1.2, 0.3, 1);
  overflow: hidden;
}

.result.show .result-card { transform: translateY(0) scale(1); }

.result-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 18%;
  right: 18%;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, rgba(255, 190, 130, 0.9), transparent);
}

.result-badge {
  width: 58px;
  height: 58px;
  margin: 0 auto 10px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 38% 30%, #FFC48F, #FF8A3D 52%, #D9580E);
  border: 2px solid #7A2F06;
  box-shadow: 0 6px 0 #7A2F06, 0 12px 26px rgba(255, 120, 40, 0.38), inset 0 2px 2px rgba(255, 255, 255, 0.55);
  color: #5B1E02;
}

.result-badge .mp-icon {
  width: 30px;
  height: 30px;
}

.result-badge.lose {
  background: radial-gradient(circle at 38% 30%, #FFB2A5, #E85C48 52%, #A72D1E);
  border-color: #55150D;
  box-shadow: 0 6px 0 #55150D, 0 12px 26px rgba(220, 70, 50, 0.32), inset 0 2px 2px rgba(255, 255, 255, 0.4);
  color: #4A1009;
}

.result-title {
  margin: 0;
  font-size: 25px;
  font-weight: 900;
  letter-spacing: 0.01em;
  color: #FFF3E2;
  text-shadow: 0 3px 0 rgba(120, 45, 8, 0.45), 0 8px 20px rgba(0, 0, 0, 0.4);
}

.result-desc {
  margin: 7px 0 0;
  font-size: 12px;
  line-height: 1.55;
  color: rgba(255, 240, 220, 0.66);
}

.result-turtles {
  display: flex;
  justify-content: center;
  gap: 7px;
  margin: 13px 0 14px;
}

.result-turtles img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: block;
  border: 2px solid var(--c, var(--orange));
  background: radial-gradient(circle at 50% 35%, #1e4a3c, #0a241d);
  filter: drop-shadow(0 5px 8px rgba(0, 0, 0, 0.35));
}

.result-turtles.dim img {
  filter: grayscale(0.65) brightness(0.66) drop-shadow(0 5px 8px rgba(0, 0, 0, 0.3));
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin-bottom: 15px;
}

.stat {
  padding: 9px 4px 8px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.09);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-v {
  font-size: 19px;
  font-weight: 900;
  color: #FFD8B2;
  line-height: 1.1;
}

.stat-k {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: rgba(255, 244, 226, 0.55);
}

.restart-btn {
  width: 100%;
  height: 52px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.06em;
  color: #431701;
  background: linear-gradient(180deg, #FFC07A, #FF8A3D 48%, #F06B18);
  border: 2px solid #6B2802;
  box-shadow: 0 5px 0 #8C3708, 0 12px 22px rgba(255, 106, 26, 0.3), inset 0 2px 0 rgba(255, 255, 255, 0.5);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.restart-btn .mp-icon {
  width: 20px;
  height: 20px;
}

.restart-btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #8C3708, 0 4px 10px rgba(255, 106, 26, 0.25), inset 0 2px 0 rgba(255, 255, 255, 0.4);
}

/* ═══════════ 小屏适配 ═══════════ */
@media (max-height: 720px) {
  .home-card { padding: 12px 14px 11px; }
  .home-desc { margin-top: 6px; font-size: 11px; }
  .home-turtles { margin: 8px 0 9px; }
  .mascot { height: 50px; }
  .mascot img { width: 38px; height: 38px; }
  .start-btn { height: 50px; }
  .start-btn b { font-size: 17px; }
  .home-note { margin-top: 6px; }
  .hero-card { height: 94px; }
  .hero-portrait { width: 48px; height: 46px; }
  .dock { padding-top: 9px; }
  .dock-top { height: 15px; margin-bottom: 5px; }
  .result-card { padding: 18px 18px 15px; }
  .result-badge { width: 50px; height: 50px; margin-bottom: 8px; }
  .result-title { font-size: 22px; }
  .result-turtles { margin: 10px 0 11px; }
}

@media (max-width: 355px) {
  .hud { left: 8px; right: 8px; gap: 4px; }
  .hud-pill { padding: 0 8px; font-size: 12.5px; height: 34px; }
  .hud-wave { font-size: 11px; padding: 0 7px; }
  .brand-en { display: none; }
  .dock { padding-left: 8px; padding-right: 8px; }
  .roster { gap: 4px; }
  .hero-card { height: 99px; }
  .hero-name { font-size: 9.5px; }
  .hero-role { font-size: 7.5px; }
  .home-stamp { font-size: 8px; padding: 0 9px; }
  .home-waves { font-size: 10px; padding: 0 9px; }
  .title-turtle { font-size: 34px; }
  .title-sub { font-size: 16px; }
  .home-card { padding: 13px 13px 11px; }
  .tp-stats { font-size: 8.5px; }
  .upgrade-btn { min-width: 68px; padding: 4px 6px; }
  .tower-panel { gap: 6px; }
  .wave-btn { width: 88px; }
}

@keyframes dotPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.82); }
}

@keyframes hpWarn {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

@keyframes waveBreathe {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

@keyframes waveShine {
  0%, 55% { left: -70%; opacity: 0; }
  68% { opacity: 1; }
  88%, 100% { left: 135%; opacity: 0; }
}

@keyframes startShine {
  0%, 48% { left: -70%; opacity: 0; }
  60% { opacity: 1; }
  82%, 100% { left: 140%; opacity: 0; }
}

@keyframes bannerShow {
  0% { opacity: 0; transform: translate(-50%, 16px) scale(0.92); }
  14% { opacity: 1; transform: translate(-50%, 0) scale(1.03); }
  22% { transform: translate(-50%, 0) scale(1); }
  78% { opacity: 1; transform: translate(-50%, -4px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -20px) scale(0.98); }
}

@keyframes padIn {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@keyframes padReady {
  0%, 100% { box-shadow: 0 0 0 4px rgba(255, 138, 61, 0.10), 0 0 18px rgba(255, 138, 61, 0.32), 0 4px 10px rgba(0, 0, 0, 0.4); }
  50% { box-shadow: 0 0 0 7px rgba(255, 138, 61, 0.05), 0 0 28px rgba(255, 138, 61, 0.6), 0 4px 10px rgba(0, 0, 0, 0.4); }
}

@keyframes panelIn {
  0% { opacity: 0; transform: translateY(10px) scale(0.97); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes artDrift {
  0% { transform: scale(1.01) translateY(0); }
  100% { transform: scale(1.045) translateY(-7px); }
}

@keyframes cardRise {
  0% { opacity: 0; transform: translateY(26px); }
  100% { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .home-art,
  .start-shine,
  .wave-shine,
  .wave-btn,
  .live-dot,
  .pad.ready {
    animation: none !important;
  }
}
