/* stylelint-disable */
/* 桥头保卫战 · 卡通塔防 H5 */
:root {
  --orange: #FF8A3D;
  --orange-deep: #E96D1F;
  --orange-dark: #C9560F;
  --cream: #FFF7E9;
  --cream-2: #FFEFD7;
  --ink: #33251A;
  --ink-soft: #8B7358;
  --teal: #062B36;
  --gold: #FFC24B;
  --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; }
[hidden] { display: none !important; }

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

body {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
  -webkit-touch-callout: none;
}

#app {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #0B6076;
}

#stage {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

img { -webkit-user-drag: none; }
button { font-family: inherit; }

/* ---------------- HUD ---------------- */
#hud {
  position: absolute;
  z-index: 5;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  padding: calc(10px + var(--safe-top)) 12px 0;
  pointer-events: none;
}
#hud > * { pointer-events: auto; }

.player {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 3px 9px 3px 3px;
  border-radius: 999px;
  background: rgba(8, 44, 54, 0.52);
  border: 1px solid rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  max-width: 112px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18);
}

.avatar {
  position: relative;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.88);
  background-size: cover;
  background-position: center;
  background-color: #FFB25E;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.22);
}
.avatar img {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.player-name {
  min-width: 0;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: none;
}

.stat {
  height: 32px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 3px 0 rgba(6, 40, 50, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.stat.coin {
  background: rgba(255, 247, 233, 0.96);
  color: #7A4A16;
  min-width: 62px;
  justify-content: center;
}
.stat.coin .mp-icon { width: 15px; height: 15px; color: #F5A623; }
.stat.coin b {
  font-size: 14px;
  color: #B85E12;
  font-variant-numeric: tabular-nums;
}
.stat.wave {
  background: linear-gradient(180deg, #FFA15A, #FF7A2D);
  color: #fff;
  text-shadow: 0 1px 0 rgba(160, 60, 10, 0.4);
  padding: 0 8px;
}
.stat.wave b { font-size: 14px; margin: 0 1px; }

.round-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 0;
  padding: 0;
  background: rgba(255, 247, 233, 0.95);
  color: #7A4A16;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 0 rgba(6, 40, 50, 0.28);
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.round-btn .mp-icon { width: 18px; height: 18px; }
.round-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(6, 40, 50, 0.28); }

/* ---------------- 波次横幅 / toast ---------------- */
.wave-banner {
  position: absolute;
  z-index: 7;
  top: calc(58px + var(--safe-top));
  left: 50%;
  transform: translate(-50%, -8px) scale(0.96);
  opacity: 0;
  pointer-events: none;
  max-width: 88vw;
  padding: 8px 17px;
  border-radius: 999px;
  background: rgba(255, 248, 235, 0.97);
  border: 1px solid rgba(255, 138, 61, 0.45);
  color: #7A4214;
  font-size: 12.5px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 6px 16px rgba(4, 35, 44, 0.3), inset 0 1px 0 #fff;
  transition: opacity 0.24s ease, transform 0.24s ease;
}
.wave-banner.show { opacity: 1; transform: translate(-50%, 0) scale(1); }

.toast {
  position: absolute;
  z-index: 16;
  left: 50%;
  bottom: calc(148px + var(--safe-bottom));
  transform: translate(-50%, 10px);
  opacity: 0;
  pointer-events: none;
  max-width: 82vw;
  padding: 8px 15px;
  border-radius: 999px;
  background: rgba(8, 38, 48, 0.9);
  color: #FFF3DC;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 196, 120, 0.25);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- 守卫操作浮层 ---------------- */
.unit-pop {
  position: fixed;
  z-index: 15;
  width: 198px;
  padding: 10px;
  border-radius: 16px;
  background: linear-gradient(180deg, #FFFDF7, #FFF1DA);
  border: 2px solid #FFD9AC;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.38);
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.unit-pop.show { opacity: 1; transform: none; pointer-events: auto; }

.unit-pop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding: 0 2px;
}
.unit-pop-head > span:first-child {
  font-size: 13px;
  font-weight: 800;
  color: #4B3322;
}
.unit-pop-lv {
  font-size: 10px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(180deg, #FFA65C, #FF7A2D);
  padding: 2px 7px;
  border-radius: 999px;
  box-shadow: 0 1px 0 #C9560F;
}

.unit-pop-actions { display: flex; gap: 6px; }

.pop-btn {
  height: 40px;
  border-radius: 11px;
  font-size: 11.5px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.pop-btn .mp-icon { width: 13px; height: 13px; }
.pop-btn.up {
  flex: 1.25;
  border: 0;
  color: #fff;
  background: linear-gradient(180deg, #FFA65C, #FF7A2D);
  box-shadow: 0 3px 0 #C9560F;
}
.pop-btn.sell {
  flex: 1;
  color: #8A5A2A;
  background: #F4E5CE;
  border: 1px solid #E3CBA7;
  box-shadow: 0 3px 0 #D9BE97;
}
.pop-btn:active { transform: translateY(2px); box-shadow: none; }
.pop-btn[disabled] { opacity: 0.45; pointer-events: none; }

/* ---------------- 底部部署栏 ---------------- */
#shop {
  position: absolute;
  z-index: 6;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 14px calc(10px + var(--safe-bottom));
  background: linear-gradient(180deg, rgba(8, 45, 56, 0) 0%, rgba(7, 40, 50, 0.72) 26%, rgba(7, 36, 46, 0.94) 58%, #062B36 100%);
  pointer-events: auto;
}

.shop-top {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 560px;
  margin: 0 auto 7px;
}
.shop-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.62);
  white-space: nowrap;
}
.wave-track {
  flex: 1;
  min-width: 20px;
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}
.wave-track i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #FFC24B, #FF8A3D);
  transition: width 0.2s linear;
}
.shop-tip {
  font-size: 10.5px;
  font-weight: 700;
  color: rgba(255, 220, 180, 0.85);
  white-space: nowrap;
}

.unit-row {
  display: flex;
  gap: 8px;
  max-width: 560px;
  margin: 0 auto;
}

.unit-card {
  position: relative;
  flex: 1;
  min-width: 0;
  border: 2px solid transparent;
  border-radius: 15px;
  background: linear-gradient(180deg, #FFFCF4, #FFEFD8);
  padding: 6px 4px 7px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.22), inset 0 1px 0 #fff;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
  cursor: pointer;
}
.unit-card:active {
  transform: translateY(3px) scale(0.985);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.22);
}
.unit-card.selected {
  border-color: #FF8A3D;
  transform: translateY(-4px);
  background: linear-gradient(180deg, #FFFDF6, #FFF4E2);
  box-shadow: 0 6px 0 rgba(233, 109, 31, 0.45), 0 10px 18px rgba(0, 0, 0, 0.22), inset 0 1px 0 #fff;
}
.unit-card.poor { opacity: 0.5; filter: saturate(0.55); }

.unit-ico {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  margin-bottom: 1px;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.4), inset 0 -2px 0 rgba(0, 0, 0, 0.18), 0 2px 3px rgba(0, 0, 0, 0.15);
}
.unit-ico .mp-icon { width: 18px; height: 18px; }
.unit-ico.archer, .roster-ico.archer { background: linear-gradient(180deg, #FFB468, #EF8534); }
.unit-ico.gunner, .roster-ico.gunner { background: linear-gradient(180deg, #5FA8B6, #2F7080); }
.unit-ico.frost, .roster-ico.frost { background: linear-gradient(180deg, #8BDCF2, #3E9BC2); }

.unit-name {
  font-size: 10.5px;
  font-weight: 800;
  color: #4B3322;
  line-height: 1.1;
  white-space: nowrap;
}
.unit-cost {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 10.5px;
  font-weight: 800;
  color: #B4711F;
}
.unit-cost .mp-icon { width: 11px; height: 11px; color: #F5A623; }

/* ---------------- 通用弹层 ---------------- */
.overlay {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(18px + var(--safe-top)) 18px calc(18px + var(--safe-bottom));
  background: radial-gradient(circle at 50% 18%, rgba(22, 90, 100, 0.58), rgba(4, 26, 34, 0.84));
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.22s ease, visibility 0.22s ease;
}
.overlay.show { opacity: 1; visibility: visible; pointer-events: auto; }

.panel {
  position: relative;
  width: min(346px, 88vw);
  max-height: calc(100vh - 80px);
  max-height: calc(100dvh - 80px);
  overflow-y: auto;
  padding: 22px 20px 20px;
  border-radius: 26px;
  background: linear-gradient(180deg, #FFFDF6 0%, #FFF3DE 100%);
  border: 2px solid rgba(255, 255, 255, 0.75);
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.4), 0 5px 0 rgba(120, 60, 20, 0.3), inset 0 1px 0 #fff;
  text-align: center;
  transform: translateY(10px) scale(0.97);
  transition: transform 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  scrollbar-width: none;
}
.panel::-webkit-scrollbar { display: none; }
.overlay.show .panel { transform: none; }

.panel h2 {
  margin: 10px 0 2px;
  font-size: 25px;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #33251A;
}
.panel-sub {
  margin: 0 0 16px;
  font-size: 12px;
  color: #97795A;
  font-weight: 600;
}

.panel-badge {
  width: 60px;
  height: 60px;
  margin: 0 auto;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: linear-gradient(180deg, #FFB25E, #FF7A2D);
  border: 3px solid #fff;
  box-shadow: 0 5px 0 rgba(201, 86, 15, 0.4), 0 10px 20px rgba(233, 109, 31, 0.3);
}
.panel-badge .mp-icon { width: 30px; height: 30px; }
.panel-badge.danger { background: linear-gradient(180deg, #FF8C6B, #E24A2F); box-shadow: 0 5px 0 rgba(160, 45, 20, 0.4), 0 10px 20px rgba(226, 74, 47, 0.3); }

/* ---------------- 开始页 ---------------- */
.splash-panel { padding-top: 20px; }
.splash-panel::before {
  content: "";
  position: absolute;
  top: -70px;
  left: 50%;
  width: 270px;
  height: 200px;
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(255, 170, 90, 0.4), rgba(255, 170, 90, 0) 68%);
  pointer-events: none;
}

.crest {
  position: relative;
  width: 76px;
  height: 76px;
  margin: 2px auto 10px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: linear-gradient(180deg, #FFB25E, #FF7A2D);
  border: 4px solid #fff;
  box-shadow: 0 6px 0 rgba(201, 86, 15, 0.35), 0 12px 24px rgba(233, 109, 31, 0.35);
}
.crest .mp-icon { width: 38px; height: 38px; filter: drop-shadow(0 2px 0 rgba(150, 60, 10, 0.3)); }
.crest-star {
  position: absolute;
  right: -5px;
  bottom: -2px;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: linear-gradient(180deg, #FFD86E, #FFB020);
  border: 2px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #8A5410;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
.crest-star .mp-icon { width: 14px; height: 14px; filter: none; }

.game-title {
  margin: 0;
  font-size: 29px;
  line-height: 1.1;
  font-weight: 900;
  letter-spacing: 0.1em;
  color: #33251A;
  text-shadow: 0 2px 0 #fff;
}
.game-sub {
  margin: 7px 0 0;
  font-size: 12px;
  font-weight: 600;
  color: #97795A;
}
.splash-player {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  margin-top: 10px;
  padding: 3px 10px 3px 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid #F0DCC0;
  font-size: 11px;
  font-weight: 700;
  color: #8A6A48;
}
.splash-player > span:last-child {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.splash-player b { color: #4B3322; font-weight: 900; }
.splash-avatar {
  position: relative;
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 50%;
  overflow: hidden;
  background-color: #FFB25E;
  background-size: cover;
  background-position: center;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}
.splash-avatar img {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.best-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  margin: 12px auto 14px;
  padding: 5px 14px;
  border-radius: 999px;
  background: #FFE9C9;
  border: 1px solid #F5D4A6;
  color: #8A5A22;
  font-size: 11px;
  font-weight: 700;
}
.best-chip b { font-size: 17px; color: #E96D1F; line-height: 1; }

.roster {
  display: flex;
  gap: 7px;
  margin-bottom: 16px;
}
.roster-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 3px 7px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid #F0DCC0;
  font-size: 10px;
  font-weight: 800;
  color: #6B4A2E;
}
.roster-ico {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.4), 0 2px 3px rgba(0, 0, 0, 0.14);
}
.roster-ico .mp-icon { width: 17px; height: 17px; }

.btn-primary {
  width: 100%;
  height: 52px;
  border: 0;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: linear-gradient(180deg, #FFA352, #FF7A2D);
  color: #fff;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-shadow: 0 1px 0 rgba(160, 60, 10, 0.35);
  box-shadow: 0 5px 0 #C95C16, 0 12px 22px rgba(233, 109, 31, 0.32);
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.btn-primary .mp-icon { width: 22px; height: 22px; }
.btn-primary:active { transform: translateY(4px); box-shadow: 0 1px 0 #C95C16; }

.howto {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 3px;
  margin: 13px 0 0;
  font-size: 10.5px;
  font-weight: 600;
  color: #A28562;
}
.howto .mp-icon { width: 11px; height: 11px; color: #D9A05B; }

/* ---------------- 暂停 / 结束 ---------------- */
.small-panel { width: min(310px, 84vw); }
.row-btns { display: flex; gap: 8px; margin-top: 10px; }
.btn-ghost {
  flex: 1;
  height: 42px;
  border-radius: 12px;
  border: 1px solid #E8D2B0;
  background: #FFF7E8;
  color: #7A5A38;
  font-size: 12px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  box-shadow: 0 3px 0 rgba(210, 180, 140, 0.55);
  cursor: pointer;
}
.btn-ghost .mp-icon { width: 16px; height: 16px; }
.btn-ghost:active { transform: translateY(2px); box-shadow: none; }

.score-row { display: flex; gap: 9px; margin-bottom: 16px; }
.score-box {
  flex: 1;
  padding: 10px 4px 9px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid #F0DCC0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}
.score-box span { font-size: 10px; font-weight: 700; color: #A28562; }
.score-box b {
  font-size: 28px;
  line-height: 1.15;
  font-weight: 900;
  color: #E96D1F;
  font-variant-numeric: tabular-nums;
}

.btn-ad {
  width: 100%;
  height: 44px;
  margin-top: 9px;
  border-radius: 13px;
  border: 1.5px solid #E8D2B0;
  background: linear-gradient(180deg, #FFF9EC, #FFEFD8);
  color: #7A5A38;
  font-size: 12.5px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  box-shadow: 0 3px 0 rgba(210, 180, 140, 0.5);
  cursor: pointer;
}
.btn-ad .mp-icon { width: 17px; height: 17px; color: #E96D1F; }
.btn-ad em {
  font-style: normal;
  font-size: 9.5px;
  font-weight: 700;
  color: #B99A70;
  background: #F5E3C8;
  border-radius: 99px;
  padding: 2px 6px;
}
.btn-ad:active { transform: translateY(2px); box-shadow: none; }
.btn-ad[hidden] { display: none; }

/* ---------------- 小屏适配 ---------------- */
@media (max-height: 720px) {
  .splash-panel { padding: 16px 18px 15px; }
  .crest { width: 62px; height: 62px; margin-bottom: 7px; }
  .crest .mp-icon { width: 31px; height: 31px; }
  .game-title { font-size: 25px; }
  .best-chip { margin: 9px auto 10px; }
  .roster { margin-bottom: 12px; }
  .btn-primary { height: 48px; }
  .howto { margin-top: 10px; }
  .panel h2 { font-size: 22px; }
  .panel-badge { width: 52px; height: 52px; border-radius: 17px; }
  .score-box b { font-size: 24px; }
}

@media (max-width: 350px) {
  .player { max-width: 96px; }
  .player-name { font-size: 10px; }
  .stat { padding: 0 7px; }
  .stat.coin { min-width: 56px; }
  .unit-name, .unit-cost { font-size: 10px; }
  #shop { padding-left: 9px; padding-right: 9px; }
  .unit-row { gap: 6px; }
}
