* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  background: #0f0f0f;
  overflow: hidden;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #ede6d8;
}

#fit {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#wrap {
  position: relative;
  width: 1280px;
  height: 720px;
  transform-origin: center center;
  flex: 0 0 auto;
}

#stage {
  position: absolute;
  inset: 0;
  width: 1280px;
  height: 720px;
  display: block;
  border-radius: 6px;
  background: #141414;
  cursor: crosshair;
}

/* ===== HUD ===== */
.hud {
  position: absolute;
  left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  pointer-events: none;
  z-index: 5;
}
.hud.top {
  top: 0;
  padding: 14px 18px;
  background: linear-gradient(180deg, rgba(12, 10, 8, 0.72), rgba(12, 10, 8, 0));
}
.hud.bottom {
  bottom: 0;
  flex-direction: column;
  gap: 8px;
  padding: 12px 18px 14px;
  background: linear-gradient(0deg, rgba(12, 10, 8, 0.78), rgba(12, 10, 8, 0));
}

.stat {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(20, 16, 12, 0.7);
  border: 1px solid #3a332a;
  border-radius: 999px;
  padding: 5px 14px 5px 7px;
}
.stat img { width: 26px; height: 26px; display: block; }
.stat b {
  display: inline-block;
  font-family: Consolas, monospace;
  font-size: 17px;
  letter-spacing: 1px;
  color: #fff3d6;
}
.stat.hp b { color: #ff8a7a; }

.stat b.bump { animation: statBump .42s ease; }
.stat b.bump.up { color: #c9f58a; }
.stat b.bump.down { color: #ff7a66; }
@keyframes statBump {
  0% { transform: scale(1); }
  35% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

.stat.hp.low {
  border-color: #a83226;
  background: rgba(46, 16, 12, 0.78);
  animation: lowPulse 1s ease-in-out infinite;
}
.stat.hp.low b { color: #ff5a48; }
@keyframes lowPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(226, 87, 74, 0); }
  50% { box-shadow: 0 0 0 4px rgba(226, 87, 74, .22); }
}

.mechTag {
  max-width: 150px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 11px;
  letter-spacing: 1px;
  color: #8fe4ff;
  background: rgba(16, 34, 40, 0.55);
  border: 1px solid rgba(143, 228, 255, .35);
  border-radius: 999px;
  padding: 4px 11px;
}

.wave {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-left: auto;
  font-family: Consolas, monospace;
  font-size: 13px;
  letter-spacing: 2px;
  color: #d8cfc0;
  background: rgba(20, 16, 12, 0.7);
  border: 1px solid #3a332a;
  border-radius: 999px;
  padding: 7px 14px 7px 16px;
}

.wbar {
  width: 56px;
  height: 4px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .45);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08);
  overflow: hidden;
}
.wbar i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #c6802c, #ffd34e);
  transition: width .25s ease;
}

button, .mini {
  pointer-events: auto;
  font-family: Consolas, monospace;
  font-size: 12px;
  letter-spacing: 1px;
  color: #e8dfcd;
  background: rgba(28, 23, 18, 0.9);
  border: 1px solid #4a3f31;
  border-radius: 999px;
  padding: 7px 16px;
  cursor: pointer;
  text-decoration: none;
}
button:hover, .mini:hover { border-color: #c6802c; color: #ffd98a; }

/* ===== 塔栏 ===== */
.towers { display: flex; gap: 10px; pointer-events: auto; }

.tcard {
  width: 150px;
  display: flex;
  align-items: center;
  gap: 9px;
  background: rgba(24, 19, 15, 0.92);
  border: 2px solid #3d3428;
  border-radius: 12px;
  padding: 7px 10px;
  cursor: pointer;
  transition: border-color .15s ease, transform .12s ease, box-shadow .15s ease, background .15s ease;
}
.tcard:hover {
  border-color: #6d5b41;
  background: rgba(33, 26, 20, 0.95);
  transform: translateY(-2px);
}
.tcard:active { transform: translateY(0); }
.tcard.active {
  border-color: #c6802c;
  background: rgba(43, 32, 20, 0.95);
  box-shadow: 0 0 0 2px rgba(198, 128, 44, .25), 0 4px 14px rgba(0, 0, 0, .35);
}
.tcard.active img { animation: cardBob 2.2s ease-in-out infinite; }
@keyframes cardBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}
.tcard.poor img { filter: grayscale(.6) brightness(.8); }
.tcard.poor .tcost { color: #ff8a7a; }
.tcard img { width: 38px; height: 38px; display: block; flex: 0 0 auto; }
.tcard .meta { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.tcard .tname { font-size: 12.5px; color: #f0e6d3; white-space: nowrap; }
.tcard .tcost {
  font-family: Consolas, monospace;
  font-size: 12px;
  color: #ffd34e;
}
.tcard.poor { opacity: .45; }

.hint {
  font-family: Consolas, monospace;
  font-size: 11px;
  letter-spacing: .4px;
  color: #8b8272;
}

/* ===== 波次横幅 ===== */
.waveBanner {
  position: absolute;
  left: 50%;
  top: 86px;
  z-index: 7;
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 9px 26px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(24, 19, 15, .95), rgba(24, 19, 15, .78));
  border: 2px solid #c6802c;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45), inset 0 0 24px rgba(198, 128, 44, .15);
  opacity: 0;
  transform: translate(-50%, -10px);
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: none;
}
.waveBanner.show { opacity: 1; transform: translate(-50%, 0); }
.waveBanner b {
  font-family: Consolas, monospace;
  font-size: 20px;
  letter-spacing: 4px;
  color: #ffd34e;
}
.waveBanner span {
  font-size: 12px;
  letter-spacing: 3px;
  color: #f0e6d3;
}
.waveBanner.counting { border-color: #6b5b41; }
.waveBanner.counting b { font-size: 17px; color: #ffe9b8; }
.waveBanner.counting span { color: #a49a89; }

/* ===== 结算 / 开始浮层 ===== */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 8, 7, 0.62);
  backdrop-filter: blur(2px);
}
.overlay.hidden { display: none; }
.overlay:not(.hidden) { animation: fadeIn .2s ease both; }
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.overlay:not(.hidden) .panel { animation: panelIn .36s cubic-bezier(.2, .9, .3, 1.25) both; }
@keyframes panelIn {
  from { opacity: 0; transform: translateY(28px) scale(.94); }
  to { opacity: 1; transform: none; }
}

.panel {
  width: 460px;
  background: #fbf8f1;
  border: 3px solid #2b2724;
  border-radius: 18px;
  padding: 30px 34px 28px;
  text-align: center;
  color: #241f1b;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .45);
}
.panel .kicker {
  font-family: Consolas, monospace;
  font-size: 11px;
  letter-spacing: 3px;
  color: #a1978a;
  margin-bottom: 8px;
}
.panel h1 {
  font-size: 27px;
  letter-spacing: 3px;
  color: #8c5a2b;
  margin-bottom: 10px;
}
.panel .desc {
  font-size: 13.5px;
  line-height: 1.9;
  color: #5a534a;
  margin-bottom: 20px;
}
.panel .stars {
  display: block;
  font-size: 30px;
  letter-spacing: 8px;
  color: #ffd34e;
  text-shadow: 0 2px 0 #2b2724;
  margin: 4px 0 12px;
}
.panel .bestLine {
  display: inline-block;
  margin-top: 6px;
  font-family: Consolas, monospace;
  font-size: 12px;
  letter-spacing: 1px;
  color: #9a7b3f;
}
.panel .primary {
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #fff8e8;
  background: #c6802c;
  border: 3px solid #2b2724;
  border-radius: 999px;
  padding: 11px 34px;
  cursor: pointer;
  box-shadow: 0 4px 0 #2b2724;
}
.panel .primary:active { transform: translateY(2px); box-shadow: 0 2px 0 #2b2724; }

.panel .actions {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}
.panel .secondary {
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #5a534a;
  background: #ece5d6;
  border: 3px solid #2b2724;
  border-radius: 999px;
  padding: 10px 22px;
  cursor: pointer;
  box-shadow: 0 4px 0 #2b2724;
}
.panel .secondary:active { transform: translateY(2px); box-shadow: 0 2px 0 #2b2724; }
.panel .secondary.hidden { display: none; }

/* ===== 已建塔面板 ===== */
.towerPanel {
  position: absolute;
  right: 20px;
  bottom: 118px;
  width: 252px;
  z-index: 8;
  background: rgba(24, 19, 15, 0.95);
  border: 2px solid #4a3f31;
  border-radius: 14px;
  padding: 14px 16px 12px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, .45);
}
.towerPanel.hidden { display: none; }
.towerPanel:not(.hidden) { animation: popIn .22s ease both; }
@keyframes popIn {
  from { opacity: 0; transform: translateY(10px) scale(.97); }
  to { opacity: 1; transform: none; }
}

.tp-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 6px;
}
.tp-head b { font-size: 15px; color: #f3eada; letter-spacing: 1px; }
.tp-head span {
  font-family: Consolas, monospace;
  font-size: 12px;
  color: #ffd34e;
}

.tp-stats {
  font-family: Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.7;
  color: #a49a89;
  margin-bottom: 10px;
}

.tp-actions { display: flex; gap: 8px; }
.tp-actions button {
  flex: 1;
  padding: 8px 0;
  font-size: 12px;
  border-radius: 8px;
}
.tp-actions button:disabled {
  opacity: .4;
  cursor: not-allowed;
  border-color: #3a332a;
  color: #8b8272;
}

/* ===== 技能按钮 ===== */
.skillBtn {
  position: absolute;
  right: 20px;
  bottom: 22px;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: radial-gradient(circle at 50% 35%, #6b4a22, #2c2118 70%);
  border: 2px solid #c6802c;
  box-shadow: 0 0 0 3px rgba(43, 39, 36, .8), 0 6px 16px rgba(0, 0, 0, .4);
  cursor: pointer;
}
.skillBtn:hover { border-color: #ffd34e; }
.skillBtn:not(.cooling) { animation: skillReady 2.6s ease-in-out infinite; }
@keyframes skillReady {
  0%, 100% { box-shadow: 0 0 0 3px rgba(43, 39, 36, .8), 0 6px 16px rgba(0, 0, 0, .4); }
  50% { box-shadow: 0 0 0 3px rgba(43, 39, 36, .8), 0 0 20px rgba(255, 211, 78, .5), 0 6px 16px rgba(0, 0, 0, .4); }
}
.skillBtn .skillName {
  font-size: 13px;
  letter-spacing: 1px;
  color: #ffe9b8;
}
.skillBtn .skillCd {
  font-family: Consolas, monospace;
  font-size: 11px;
  color: #ffb84d;
  min-height: 13px;
}
.skillBtn.cooling {
  filter: grayscale(.7) brightness(.75);
  cursor: not-allowed;
}
.skillBtn.cooling:hover { border-color: #6b5b41; }
