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

/* ---------- HUD ---------- */
.hud {
  position: absolute; left: 0; right: 0; top: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  pointer-events: none;
}
.hud-chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 30px; padding: 0 11px 0 8px;
  border-radius: 15px;
  background: rgba(255, 246, 232, .92);
  border: 1.5px solid rgba(120, 74, 38, .28);
  box-shadow: 0 3px 0 rgba(120, 74, 38, .18), 0 6px 14px rgba(60, 30, 10, .18);
  font-size: 13px; font-weight: 800; letter-spacing: .2px;
  color: #4A2E17;
  backdrop-filter: blur(4px);
}
.hud-chip i { font-size: 16px; }
.hud-chip.gold i { color: #F2A417; }
.hud-chip.wave i { color: #FF8A3D; }
.hud-chip.life i { color: #E4573D; }
.hud-spacer { flex: 1; }
.hud-btn {
  pointer-events: auto;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  height: 30px; min-width: 34px; padding: 0 10px;
  border-radius: 15px; border: 1.5px solid rgba(120, 74, 38, .28);
  background: rgba(255, 246, 232, .92);
  color: #4A2E17; font-size: 13px; font-weight: 800;
  box-shadow: 0 3px 0 rgba(120, 74, 38, .18), 0 6px 14px rgba(60, 30, 10, .18);
  transition: transform .08s ease, box-shadow .08s ease;
}
.hud-btn i { font-size: 16px; }
.hud-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(120, 74, 38, .18); }
.hud-btn.on { background: #FF8A3D; color: #FFF6E8; border-color: #D96A22; }

/* ---------- 下一波预告 ---------- */
.nextwave {
  position: absolute; left: 12px; top: 46px;
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 12px;
  background: rgba(43, 27, 16, .55);
  color: #FFE9C9; font-size: 11px; font-weight: 700;
  border: 1px solid rgba(255, 200, 140, .28);
  pointer-events: none;
  max-width: 62vw;
}
.nw-label { color: #FFB877; }
.nw-body { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- 建造栏 ---------- */
.dock {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(43, 27, 16, 0) 0%, rgba(43, 27, 16, .55) 40%, rgba(30, 18, 10, .82) 100%);
}
.dock-title {
  font-size: 11px; font-weight: 800; color: #FFD9AE;
  writing-mode: vertical-rl; letter-spacing: 2px;
  opacity: .85;
}
.towers { display: flex; gap: 8px; flex: 1; }
.tcard {
  position: relative;
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px;
  padding: 6px 4px 5px;
  border-radius: 14px;
  background: linear-gradient(180deg, #FFF7EA 0%, #F6E3C8 100%);
  border: 2px solid #C98A4E;
  box-shadow: 0 4px 0 #A96C33, 0 8px 16px rgba(30, 15, 5, .35);
  transition: transform .08s ease, box-shadow .08s ease, filter .15s ease;
  overflow: hidden;
}
.tcard:active { transform: translateY(3px); box-shadow: 0 1px 0 #A96C33, 0 4px 10px rgba(30, 15, 5, .3); }
.tcard.sel { border-color: #FF8A3D; box-shadow: 0 4px 0 #D96A22, 0 0 0 3px rgba(255, 138, 61, .45), 0 8px 16px rgba(30, 15, 5, .35); }
.tcard.poor { filter: grayscale(.55) brightness(.86); }
.tcard .ti { font-size: 22px; line-height: 1; color: #7A4A22; }
.tcard .tn { font-size: 11px; font-weight: 800; color: #4A2E17; white-space: nowrap; }
.tcard .tc { font-size: 10px; font-weight: 800; color: #B4762F; display: flex; align-items: center; gap: 2px; }
.tcard .tc i { font-size: 11px; color: #F2A417; }
.tcard .tc.no { color: #C0392B; }

.dock-right { display: flex; align-items: center; }
.go-btn {
  display: inline-flex; align-items: center; gap: 4px;
  height: 46px; padding: 0 14px;
  border-radius: 14px; border: 2px solid #D96A22;
  background: linear-gradient(180deg, #FFA45C 0%, #FF8A3D 55%, #F0741F 100%);
  color: #FFF6E8; font-size: 13px; font-weight: 900; letter-spacing: .5px;
  box-shadow: 0 4px 0 #B9540F, 0 8px 18px rgba(30, 15, 5, .4);
  transition: transform .08s ease, box-shadow .08s ease;
}
.go-btn i { font-size: 18px; }
.go-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #B9540F; }
.go-btn.ready { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 4px 0 #B9540F, 0 0 0 0 rgba(255, 138, 61, .55); }
  50% { box-shadow: 0 4px 0 #B9540F, 0 0 0 8px rgba(255, 138, 61, 0); }
}

/* ---------- 选中塔卡片 ---------- */
.selcard {
  position: absolute; right: 12px; bottom: 74px;
  width: 186px;
  padding: 9px 10px 10px;
  border-radius: 16px;
  background: linear-gradient(180deg, #FFF9EF 0%, #F7E7CE 100%);
  border: 2px solid #C98A4E;
  box-shadow: 0 5px 0 #A96C33, 0 12px 24px rgba(30, 15, 5, .4);
  animation: pop .16s ease-out;
}
@keyframes pop { from { transform: scale(.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.sel-head { display: flex; align-items: center; gap: 6px; }
.sel-head i { font-size: 18px; color: #7A4A22; }
.sel-name { font-size: 13px; font-weight: 900; color: #3A2312; }
.sel-lv {
  font-size: 10px; font-weight: 900; color: #FFF6E8;
  background: #FF8A3D; border-radius: 8px; padding: 1px 6px;
}
.sel-x {
  margin-left: auto; width: 22px; height: 22px; border-radius: 50%;
  border: none; background: rgba(120, 74, 38, .14); color: #7A4A22;
  display: inline-flex; align-items: center; justify-content: center;
}
.sel-x i { font-size: 14px; }
.sel-stats { margin: 6px 0 8px; font-size: 11px; font-weight: 700; color: #7A5A3A; line-height: 1.5; }
.sel-actions { display: flex; gap: 6px; }
.sel-btn {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 3px;
  height: 32px; border-radius: 10px; border: 2px solid transparent;
  font-size: 11px; font-weight: 900;
  transition: transform .08s ease;
}
.sel-btn i { font-size: 14px; }
.sel-btn:active { transform: translateY(2px); }
.sel-btn.up { background: linear-gradient(180deg, #FFB067, #FF8A3D); color: #FFF6E8; border-color: #D96A22; box-shadow: 0 3px 0 #B9540F; }
.sel-btn.up:disabled { background: #E3D6C4; color: #A08B72; border-color: #C9B79E; box-shadow: 0 3px 0 #C9B79E; }
.sel-btn.sell { background: #F3E4CC; color: #8A5A2A; border-color: #C9A87C; box-shadow: 0 3px 0 #C9A87C; }

/* ---------- 遮罩层 ---------- */
.overlay {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: rgba(28, 16, 8, .62);
  backdrop-filter: blur(3px);
  animation: fade .18s ease-out;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.ov-card {
  width: min(78vw, 340px);
  padding: 18px 18px 16px;
  border-radius: 22px;
  background: linear-gradient(180deg, #FFF9EF 0%, #F6E4C8 100%);
  border: 2px solid #C98A4E;
  box-shadow: 0 8px 0 #A96C33, 0 20px 40px rgba(20, 10, 4, .5);
  text-align: center;
  animation: pop .2s ease-out;
}
.ov-badge {
  width: 46px; height: 46px; margin: 0 auto 8px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #FFB067, #FF8A3D);
  color: #FFF6E8; box-shadow: 0 4px 0 #B9540F;
}
.ov-badge i { font-size: 24px; }
.ov-badge.big { width: 62px; height: 62px; }
.ov-badge.big i { font-size: 32px; }
.ov-title { font-size: 19px; font-weight: 900; color: #3A2312; letter-spacing: .5px; }
.ov-sub { margin-top: 4px; font-size: 12px; font-weight: 700; color: #8A6A48; line-height: 1.5; }
.ov-stats { display: flex; gap: 8px; margin: 12px 0 4px; }
.ov-stat {
  flex: 1; padding: 7px 4px; border-radius: 12px;
  background: rgba(255, 255, 255, .6);
  border: 1.5px solid rgba(160, 110, 60, .28);
}
.ov-stat b { display: block; font-size: 17px; font-weight: 900; color: #FF8A3D; }
.ov-stat span { font-size: 10px; font-weight: 700; color: #8A6A48; }
.ov-btn {
  width: 100%; margin-top: 10px;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  height: 44px; border-radius: 14px; border: 2px solid #D96A22;
  background: linear-gradient(180deg, #FFA45C 0%, #FF8A3D 55%, #F0741F 100%);
  color: #FFF6E8; font-size: 14px; font-weight: 900; letter-spacing: .5px;
  box-shadow: 0 4px 0 #B9540F;
  transition: transform .08s ease, box-shadow .08s ease;
}
.ov-btn i { font-size: 18px; }
.ov-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #B9540F; }
.ov-btn.ghost {
  background: #F3E4CC; color: #8A5A2A; border-color: #C9A87C; box-shadow: 0 4px 0 #C9A87C;
}
.ov-btn.ghost:active { box-shadow: 0 1px 0 #C9A87C; }

@media (max-height: 380px) {
  .hud-chip, .hud-btn { height: 26px; font-size: 12px; }
  .nextwave { top: 40px; }
  .tcard .ti { font-size: 18px; }
  .go-btn { height: 40px; }
  .selcard { bottom: 66px; width: 168px; }
}
