/* ========== 花雾 UI v2 · 全屏骨架（仅战斗页生效）========== */
/* 菜单/选关/结算仍走 main.css；这里所有规则都必须带 body.battle。 */

body.battle {
  overflow: hidden;
}

body.battle .masthead,
body.battle .page-footer {
  display: none !important;
}

body.battle #gameContainer {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  border: 0;
  padding: 0;
  background: #0a0d0b;
  overflow: hidden;
}

body.battle #stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  background: #0a0d0b;
}

/* 非 16:9 的留边用本关背景的模糊放大图填满，不露黑边。 */
body.battle #stage::before {
  content: "";
  position: absolute;
  inset: -24px;
  background-image: var(--stage-bg-image, none);
  background-position: center;
  background-size: cover;
  filter: blur(18px) brightness(0.55);
  transform: scale(1.04);
  pointer-events: none;
  z-index: 0;
}

/* 战场按 16:9 contain 居中；逻辑坐标仍是 1600×900。 */
body.battle #gameCanvas {
  position: relative;
  z-index: 1;
  width: min(100%, calc(100dvh * 16 / 9));
  height: min(100%, calc(100vw * 9 / 16));
  display: block;
}

/* ========== P1：四角悬浮 HUD + 法塔匣 ========== */

body.battle #hud {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0;
  background: none;
  border: 0;
  display: block;
  pointer-events: none;
  z-index: 100;
}

body.battle .scene-heading {
  position: fixed;
  top: 18px;
  left: 24px;
  min-width: 0;
  padding: 0 0 0 12px;
  border-left: 2px solid var(--gilt, #c8a96a);
  border-right: 0;
  text-shadow: 0 2px 10px #000;
  pointer-events: none;
}

body.battle .scene-heading small {
  color: #c8a96a;
  letter-spacing: 3px;
}

body.battle .scene-heading strong {
  font-size: 22px;
  color: var(--paper, #e8dcc0);
  letter-spacing: 3px;
}

body.battle .hud-resources {
  position: fixed;
  top: 66px;
  left: 24px;
  display: flex;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

body.battle .hud-item {
  gap: 8px;
  padding: 6px 10px;
  background: rgba(10, 13, 11, 0.62);
  border: 1px solid rgba(200, 169, 106, 0.32);
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
}

body.battle .hud-label {
  color: #b9c3ab;
  font-size: 11px;
  letter-spacing: 2px;
}

body.battle .hud-label.health-mark:before {
  color: #d0674a;
}

body.battle .hud-value {
  color: #f2e6c8;
  font-size: 17px;
}

body.battle .wave-status {
  position: fixed;
  top: 18px;
  right: 24px;
  margin: 0;
  min-width: 150px;
  padding: 8px 12px;
  text-align: right;
  color: #e8dcc0;
  background: rgba(10, 13, 11, 0.62);
  border: 1px solid rgba(200, 169, 106, 0.32);
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
}

body.battle .wave-track {
  margin-top: 7px;
  height: 4px;
  background: #5d6b54aa;
  border-radius: 3px;
  overflow: hidden;
}

body.battle .wave-fill {
  background: linear-gradient(90deg, #b8955a, #e6cf9c);
  border-radius: 3px;
}

body.battle .battle-meta {
  position: fixed;
  top: 86px;
  right: 24px;
  left: auto;
  font-size: 11px;
  color: #c9c9ad;
  pointer-events: none;
}

body.battle .battle-meta > span {
  display: none;
}

body.battle .battle-meta button {
  pointer-events: auto;
  padding: 8px 14px;
  color: #e0c58d;
  background: rgba(10, 13, 11, 0.72);
  border: 1px solid rgba(200, 169, 106, 0.5);
  border-radius: 12px;
}

body.battle .hud-buff {
  position: fixed;
  top: 134px;
  right: 24px;
  color: #e8c978;
  text-shadow: 0 2px 6px #000;
}

/* 法塔匣：底部居中悬浮，9 格定宽，锁定显示封印。 */
body.battle #towerPanel {
  position: fixed;
  left: 50%;
  right: auto;
  bottom: 18px;
  transform: translateX(-50%);
  width: auto;
  max-width: calc(100vw - 48px);
  min-height: 0;
  padding: 8px 10px;
  gap: 4px;
  align-items: stretch;
  background: rgba(14, 11, 8, 0.92);
  border: 1px solid rgba(200, 169, 106, 0.45);
  border-radius: 18px 18px 8px 8px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  z-index: 101;
}

body.battle #towerPanel::-webkit-scrollbar {
  display: none;
}

body.battle #towerPanel > .panel-title {
  writing-mode: horizontal-tb;
  align-self: center;
  position: sticky;
  left: 0;
  z-index: 1;
  padding: 0 8px 0 2px;
  color: #9daa8c;
  font-size: 11px;
  letter-spacing: 4px;
  background: rgba(14, 11, 8, 0.92);
  border-right: 1px solid rgba(200, 169, 106, 0.25);
}

body.battle .build-card {
  flex: 0 0 76px;
  min-width: 0;
  padding: 4px 2px 6px;
  border: 1px solid transparent;
  border-radius: 14px 14px 8px 8px;
  scroll-snap-align: start;
}

body.battle .build-card:hover {
  background: rgba(200, 169, 106, 0.08);
  border-color: rgba(200, 169, 106, 0.25);
}

body.battle .build-card.selected {
  background: rgba(200, 169, 106, 0.12);
  border-color: #c8a96a;
  box-shadow: inset 0 0 0 1px rgba(200, 169, 106, 0.35);
}

body.battle .build-card.locked {
  opacity: 0.62;
}

body.battle .build-card.locked::after {
  content: "封";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #c8a96a;
  font-size: 18px;
  letter-spacing: 2px;
  background: rgba(8, 10, 8, 0.5);
  border-radius: inherit;
}

body.battle .bc-image {
  width: 56px;
  height: 52px;
  object-fit: contain;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.55));
}

body.battle .bc-body {
  gap: 3px;
}

body.battle .bc-name {
  color: #e8dcc0;
  font-size: 11px;
}

body.battle .bc-cost {
  color: #c8a96a;
  font-size: 10px;
}

body.battle .bc-key {
  top: 2px;
  right: 4px;
  color: #88987a;
  font-size: 10px;
}

/* 技能 / 道具 / 剧情条 */
body.battle #skillPanel {
  position: fixed;
  left: 24px;
  bottom: 142px;
  flex-direction: row;
  gap: 8px;
  z-index: 101;
}

body.battle .skill-btn {
  width: 68px;
  height: 70px;
  border: 1px solid rgba(200, 169, 106, 0.45);
  border-radius: 14px 14px 8px 8px;
  background: rgba(14, 11, 8, 0.86);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
}

body.battle #itemPanel {
  position: fixed;
  right: 24px;
  bottom: 142px;
  gap: 6px;
  z-index: 101;
}

body.battle .item-card {
  width: 56px;
  height: 66px;
  background: rgba(14, 11, 8, 0.86);
  border: 1px solid rgba(200, 169, 106, 0.4);
  border-radius: 12px 12px 8px 8px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
}

body.battle #storyBar {
  position: fixed;
  left: 50%;
  bottom: 142px;
  transform: translateX(-50%);
  max-width: min(58vw, 620px);
  padding: 7px 14px;
  text-align: center;
  color: #d9d2b8;
  background: rgba(10, 13, 11, 0.66);
  border: 1px solid rgba(200, 169, 106, 0.25);
  border-left: 1px solid rgba(200, 169, 106, 0.25);
  border-radius: 12px;
  z-index: 99;
  pointer-events: none;
}

body.battle #towerCard {
  position: fixed;
  z-index: 120;
}

/* 手机横屏：HUD 压缩，法塔匣横向滑动。 */
@media (max-width: 900px), (max-height: 500px) {
  body.cinematic .scene-content {
    padding-top: 56px;
  }

  body.battle .scene-heading {
    top: 10px;
    left: 12px;
    padding-left: 8px;
  }

  body.battle .scene-heading small {
    display: none;
  }

  body.battle .scene-heading strong {
    font-size: 15px;
    letter-spacing: 2px;
  }

  body.battle .hud-resources {
    top: 8px;
    left: 112px;
    gap: 4px;
  }

  body.battle .hud-item {
    gap: 4px;
    padding: 4px 6px;
    border-radius: 9px;
  }

  body.battle .hud-label {
    display: none;
  }

  body.battle .hud-value {
    font-size: 14px;
  }

  body.battle .hud-icon {
    width: 17px;
    height: 17px;
  }

  body.battle .wave-status {
    top: 8px;
    right: 12px;
    min-width: 112px;
    padding: 6px 8px;
    font-size: 10px;
    border-radius: 9px;
  }

  body.battle .battle-meta {
    top: 60px;
    right: 12px;
  }

  body.battle .battle-meta button {
    padding: 6px 10px;
    font-size: 10px;
    border-radius: 9px;
  }

  body.battle .hud-buff {
    top: 96px;
    right: 12px;
  }

  body.battle #towerPanel {
    bottom: 8px;
    max-width: calc(100vw - 16px);
    padding: 6px;
    gap: 2px;
    border-radius: 14px 14px 6px 6px;
  }

  body.battle #towerPanel > .panel-title {
    font-size: 10px;
    letter-spacing: 2px;
    padding-right: 5px;
  }

  body.battle .build-card {
    flex: 0 0 72px;
    padding: 3px 1px 4px;
  }

  body.battle .bc-image {
    width: 44px;
    height: 42px;
  }

  body.battle .bc-name {
    font-size: 10px;
  }

  body.battle .bc-cost {
    font-size: 9px;
  }

  body.battle #skillPanel {
    left: 8px;
    bottom: 116px;
    gap: 5px;
  }

  body.battle .skill-btn {
    width: 48px;
    height: 54px;
  }

  body.battle #itemPanel {
    right: 8px;
    bottom: 116px;
    gap: 4px;
  }

  body.battle .item-card {
    width: 40px;
    height: 48px;
  }

  body.battle .ic-name {
    font-size: 9px;
  }

  body.battle .ic-cost {
    font-size: 9px;
  }

  body.battle #storyBar {
    bottom: 116px;
    max-width: 40vw;
    font-size: 10px;
    padding: 5px 8px;
  }
}

/* ========== P2：全屏菜单 / 选关 / 结果 + 横幅 + 动画 ========== */

body.cinematic {
  overflow: hidden;
}

body.cinematic .masthead {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  max-width: none;
  height: 72px;
  padding: 0 4.2%;
  margin: 0;
  background: linear-gradient(180deg, rgba(6, 9, 7, 0.94), rgba(6, 9, 7, 0));
  border-bottom: 0;
  z-index: 80;
}

body.cinematic .page-footer {
  display: none;
}

body.cinematic #gameContainer {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  border: 0;
  background: #080b09;
  overflow: hidden;
}

body.cinematic #stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background-color: #080b09;
}

body.cinematic #stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("../assets/bg/bg_l01_2x.png") center / cover no-repeat;
  filter: saturate(0.82) brightness(0.62);
  transform: scale(1.03);
}

body.cinematic #stage::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 62% 42%, transparent 18%, rgba(5, 8, 6, 0.55) 78%),
    linear-gradient(90deg, rgba(5, 8, 6, 0.94) 0%, rgba(5, 8, 6, 0.68) 38%, rgba(5, 8, 6, 0.16) 72%);
}

body.cinematic #gameCanvas {
  display: none;
}

body.cinematic .screen {
  z-index: 60;
}

body.cinematic .menu-screen {
  background: transparent;
}

body.cinematic .menu-content {
  animation: menuIn 0.8s var(--ease-out, ease-out) both;
}

body.cinematic .game-title {
  animation: inkIn 1.1s 0.1s var(--ease-out, ease-out) both;
}

body.cinematic .menu-eyebrow,
body.cinematic .menu-poem,
body.cinematic .menu-buttons,
body.cinematic .menu-desc {
  animation: menuIn 0.7s 0.18s var(--ease-out, ease-out) both;
}

body.cinematic .scene-select-screen {
  background: transparent;
}

body.cinematic .scene-content {
  width: min(1180px, 92vw);
  padding-top: 92px;
}

body.cinematic #pauseBtn {
  display: none;
}

body.cinematic .scene-card {
  animation: cardIn 0.55s var(--ease-out, ease-out) both;
  animation-delay: calc(var(--i, 0) * 55ms);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

body.cinematic .scene-card:hover {
  transform: translateY(-3px);
  border-color: rgba(200, 169, 106, 0.55);
}

body.cinematic .menu-foot {
  z-index: 61;
}

body.battle .result-screen {
  background: rgba(8, 11, 9, 0.86);
}

body.battle .result-screen .result-content {
  background: rgba(8, 11, 9, 0.68);
  border: 1px solid rgba(200, 169, 106, 0.25);
  border-radius: 18px;
  padding: 26px 30px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.6);
  animation: cardIn 0.7s var(--ease-out, ease-out) both;
}

body.battle .result-seal {
  animation: sealStamp 0.6s var(--ease-out, ease-out) both;
}

/* 波次 / Boss 横幅 */
body.battle .wave-banner {
  position: fixed;
  top: 20%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 130;
  padding: 10px 30px;
  color: #f0e2bd;
  font-size: clamp(22px, 3.2vw, 40px);
  letter-spacing: 8px;
  text-shadow: 0 4px 22px #000, 0 0 30px rgba(200, 169, 106, 0.25);
  background: none;
  border: 0;
  pointer-events: none;
  opacity: 0;
}

body.battle .wave-banner.show {
  animation: bannerIn 1.8s ease-out both;
}

body.battle .wave-banner.boss {
  color: #e08063;
  border-color: rgba(163, 58, 44, 0.65);
  text-shadow: 0 4px 22px #000, 0 0 34px rgba(163, 58, 44, 0.45);
}

@keyframes menuIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes inkIn {
  from { opacity: 0; filter: blur(12px); letter-spacing: 14px; }
  to { opacity: 1; filter: blur(0); letter-spacing: 2px; }
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes sealStamp {
  0% { transform: scale(1.65); opacity: 0; }
  60% { transform: scale(0.96); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes bannerIn {
  0% { opacity: 0; letter-spacing: 18px; filter: blur(8px); }
  18% { opacity: 1; letter-spacing: 8px; filter: blur(0); }
  72% { opacity: 1; letter-spacing: 8px; filter: blur(0); }
  100% { opacity: 0; letter-spacing: 6px; filter: blur(2px); }
}

/* 暂停面板 / 波次预览 / 音量 */
.pause-panel {
  position: fixed;
  inset: 0;
  z-index: 210;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 9, 7, 0.78);
  backdrop-filter: blur(6px);
}

.pause-card {
  width: min(420px, 86vw);
  padding: 32px 30px;
  text-align: center;
  background: rgba(14, 11, 8, 0.96);
  border: 1px solid rgba(200, 169, 106, 0.45);
  border-radius: 20px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.7);
}

.pause-card h2 {
  margin: 10px 0 0;
  color: #f0e2bd;
  font-size: 32px;
  font-weight: 500;
  letter-spacing: 5px;
}

.pause-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 24px;
}

.pause-actions button {
  min-height: 44px;
  border-radius: 12px;
}

.wave-preview {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 190px;
  padding: 10px 12px;
  text-align: left;
  background: rgba(10, 13, 11, 0.95);
  border: 1px solid rgba(200, 169, 106, 0.4);
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  z-index: 110;
}

.wave-preview > b {
  display: block;
  margin-bottom: 6px;
  color: #c8a96a;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 2px;
}

.wp-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
  color: #d9d2b8;
  font-size: 11px;
}

.wp-item img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.wp-item i {
  margin-left: auto;
  color: #c8a96a;
  font-style: normal;
}

.help-volume {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  color: #d9d2b8;
  font-size: 12px;
}

.help-volume input {
  flex: 1;
  accent-color: #c8a96a;
}
