/* =========================================================
   攻防12 · 古代城池攻防 H5
   画面：gpt-image 生成的攻城实机场景 + 原生 CSS/JS
   竖屏铺满，移动端优先，无外链依赖
   ========================================================= */

:root {
  --orange: #FF8A3D;
  --orange-deep: #D9531E;
  --orange-soft: #FFB35C;
  --gold: #FFC94A;
  --gold-light: #FFE6A8;
  --cream: #FFF1D4;
  --ink: #2A160C;
  --ink-2: #1A0E07;
  --line: rgba(255, 205, 130, .38);
  --line-strong: rgba(255, 205, 130, .62);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font-title: "Kaiti SC", "STKaiti", "KaiTi", "Songti SC", "Noto Serif SC", serif;
  --font-body: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #0a0604;
  color: var(--cream);
  font-family: var(--font-body);
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  position: fixed;
  inset: 0;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

button {
  font-family: inherit;
  color: inherit;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}

button:focus-visible {
  outline: 2px solid #ffe6a8;
  outline-offset: 2px;
}

img, svg { display: block; }

/* ========================= 舞台 ========================= */

.app {
  position: fixed;
  inset: 0;
  left: 0;
  right: 0;
  margin: 0 auto;
  width: 100%;
  max-width: 560px;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #0b0704;
  isolation: isolate;
  box-shadow: 0 0 90px rgba(0, 0, 0, .85);
}

@media (min-width: 561px) {
  .app { border-left: 1px solid rgba(255, 190, 90, .12); border-right: 1px solid rgba(255, 190, 90, .12); }
}

.scene {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: linear-gradient(180deg, #6ba5e6 0%, #7bb4f2 100%);
  overflow: hidden;
}

.scene-bg {
  position: absolute;
  left: 0;
  right: 0;
  top: 20px;
  bottom: 0;
  background-image: url("images/gen/gptimg_1795365422_look_scene.png");
  background-repeat: no-repeat;
  background-position: 50% 0%;
  background-size: auto 128%;
  transform-origin: 50% 46%;
  transition: transform 1.4s cubic-bezier(.2, .7, .3, 1), filter 1.4s ease;
  will-change: transform;
}

/* 宽屏兜底：仍保持铺满，不出现空白 */
@media (min-aspect-ratio: 4/5) {
  .scene-bg {
    background-size: cover;
    background-position: 50% 30%;
  }
}

.scene-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 74% at 50% 48%, rgba(255, 140, 60, .08) 0%, rgba(10, 6, 3, 0) 58%),
    linear-gradient(180deg, rgba(10, 7, 4, .45) 0%, rgba(10, 7, 4, .08) 16%, rgba(10, 7, 4, 0) 46%,
      rgba(10, 7, 4, .12) 68%, rgba(9, 5, 3, .84) 92%, rgba(9, 5, 3, .96) 100%);
}

.scene-shade::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 48%, rgba(0, 0, 0, 0) 42%, rgba(0, 0, 0, .38) 100%);
}

.embers {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.ember {
  position: absolute;
  bottom: 26%;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #ffc06a;
  box-shadow: 0 0 7px rgba(255, 140, 50, .95);
  opacity: 0;
  animation: emberRise var(--dur, 7s) linear infinite;
  animation-delay: var(--delay, 0s);
}

/* ========================= 通用层 ========================= */

.screen {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  transition: opacity .34s ease, visibility .34s;
}

.home.hide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.battle {
  z-index: 12;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .34s ease, visibility .34s;
}

.battle.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.app.in-battle .scene-bg {
  transform: scale(1.035);
  filter: saturate(1.06) brightness(.94);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: rgba(24, 13, 7, .68);
  border: 1px solid var(--line);
  color: #ffe4b3;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08), 0 4px 12px rgba(0, 0, 0, .28);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  transition: transform .12s ease, filter .12s ease;
}

.icon-btn:active { transform: scale(.92); filter: brightness(.9); }
.icon-btn .mp-icon { width: 20px; height: 20px; }

/* ========================= 首页 HUD ========================= */

.hud {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  padding: calc(8px + var(--safe-t)) 14px 0;
}

.hud-left {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}

.avatar {
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid #f6c661;
  background: #3a180d;
  box-shadow: 0 0 0 2px rgba(40, 20, 8, .86), 0 0 18px rgba(255, 168, 68, .45),
    inset 0 0 12px rgba(0, 0, 0, .5);
}

.avatar svg { width: 100%; height: 100%; }

.player { min-width: 0; padding-top: 1px; }

.player-line {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.lv {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: baseline;
  gap: 1px;
  padding: 1px 5px;
  border-radius: 5px;
  border: 1px solid #bd8a45;
  background: linear-gradient(180deg, #3c2514, #1f120a);
  color: #f2d3a0;
  font-size: 9px;
  line-height: 1.35;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12);
  letter-spacing: .02em;
}

.lv b { font-size: 11px; color: #ffd47a; font-weight: 800; }

.nick {
  min-width: 0;
  max-width: 70px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 11px;
  color: #fff6e4;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .95);
}

.xp {
  width: 104px;
  height: 8px;
  margin-top: 4px;
  padding: 1px;
  border-radius: 5px;
  background: rgba(18, 10, 5, .9);
  border: 1px solid #6b4a24;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .8);
}

.xp i {
  display: block;
  width: 62%;
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #ff8a3d 0%, #ffbf51 55%, #ffe69a 100%);
  box-shadow: 0 0 8px rgba(255, 168, 68, .8);
}

.power {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-top: 5px;
  padding: 2px 9px 2px 6px;
  border-radius: 4px;
  border: 1px solid #e0a14d;
  background: linear-gradient(90deg, #7e2015, #b63a25 70%, #8e2418);
  color: #ffe3b8;
  font-size: 9px;
  line-height: 1.3;
  clip-path: polygon(0 0, 100% 0, 94% 100%, 0 100%);
  white-space: nowrap;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .28), inset 0 1px 0 rgba(255, 220, 150, .28);
}

.power .mp-icon { width: 11px; height: 11px; color: #ffd37a; }
.power b { font-size: 11px; color: #ffe08a; letter-spacing: .02em; }

.hud-right {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  flex: 0 0 auto;
}

.res-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.res {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 80px;
  min-height: 23px;
  padding: 2px 7px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(34, 19, 10, .84), rgba(20, 11, 6, .8));
  border: 1px solid rgba(255, 205, 130, .42);
  color: #ffe9bf;
  font-size: 10px;
  line-height: 1.2;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08), 0 3px 9px rgba(0, 0, 0, .24);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  transition: transform .12s ease;
}

.res:active { transform: scale(.96); }
.res .mp-icon { width: 13px; height: 13px; flex: 0 0 13px; color: #ffd05f; }
.res.wood .mp-icon { color: #b7d99b; }
.res b { font-weight: 800; font-size: 10.5px; letter-spacing: .01em; }
.res .plus {
  margin-left: auto;
  color: #ff9c40;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  transform: translateY(-.5px);
}

.gear {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  margin-top: 1px;
}

.gear .mp-icon { width: 18px; height: 18px; }

/* ========================= 首页中部 / 底部 ========================= */

.home-bottom {
  position: relative;
  z-index: 20;
  flex: 0 0 auto;
  margin-top: auto;
  padding: 0 14px 0;
}

.start-shell {
  position: relative;
  width: 100%;
  max-width: 316px;
  margin: 0 auto;
  padding: 2px;
  clip-path: polygon(15px 0, calc(100% - 15px) 0, 100% 50%, calc(100% - 15px) 100%, 15px 100%, 0 50%);
  background: linear-gradient(180deg, #fff0b9 0%, #ffd275 22%, #c97b2d 62%, #ffe4a0 100%);
  filter: drop-shadow(0 10px 16px rgba(0, 0, 0, .46));
}

.start-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 66px;
  padding: 0 12px;
  overflow: hidden;
  clip-path: polygon(14px 0, calc(100% - 14px) 0, 100% 50%, calc(100% - 14px) 100%, 14px 100%, 0 50%);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .38) 0%, rgba(255, 255, 255, 0) 32%),
    linear-gradient(180deg, #ffc552 0%, #ff9a3f 44%, #f5762c 70%, #d1551c 100%);
  box-shadow: inset 0 -4px 0 rgba(126, 45, 9, .45), inset 0 2px 0 rgba(255, 248, 214, .6);
  transition: transform .12s ease, filter .12s ease;
}

.start-btn:active {
  transform: translateY(2px) scale(.985);
  filter: brightness(.95);
}

.start-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(80% 120% at 50% 0%, rgba(255, 255, 255, .22), transparent 58%);
  pointer-events: none;
}

.start-shine {
  position: absolute;
  top: -30%;
  left: -55%;
  width: 34%;
  height: 160%;
  background: linear-gradient(100deg, transparent 0%, rgba(255, 255, 255, .45) 50%, transparent 100%);
  transform: skewX(-22deg);
  animation: sheen 3.6s ease-in-out infinite;
  pointer-events: none;
}

.start-icon { position: relative; z-index: 1; flex: 0 0 auto; }
.start-icon svg {
  width: 34px;
  height: 34px;
  filter: drop-shadow(0 2px 2px rgba(112, 41, 8, .55));
}

.start-txt {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.05;
}

.start-txt b {
  font-family: var(--font-title);
  font-size: 24px;
  font-weight: 900;
  letter-spacing: .12em;
  color: #fffaf0;
  text-shadow: 0 2px 0 #9d3b10, 0 4px 10px rgba(80, 24, 4, .55);
}

.start-txt small {
  margin-top: 4px;
  font-size: 9.5px;
  letter-spacing: .1em;
  color: rgba(255, 244, 218, .88);
  text-shadow: 0 1px 2px rgba(107, 38, 6, .5);
}

.best {
  margin: 7px 0 7px;
  text-align: center;
  font-size: 10px;
  line-height: 1.3;
  letter-spacing: .05em;
  color: #f1d0a0;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .8);
  opacity: .86;
}

.dock {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  margin: 0 -14px;
  padding: 7px 5px calc(6px + var(--safe-b));
  border-top: 1px solid rgba(255, 196, 100, .36);
  border-radius: 17px 17px 0 0;
  background:
    linear-gradient(180deg, rgba(255, 190, 100, .08), transparent 28%),
    linear-gradient(180deg, rgba(48, 27, 14, .93) 0%, rgba(27, 15, 8, .97) 48%, rgba(16, 9, 5, .99) 100%);
  box-shadow: 0 -12px 30px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 226, 170, .15);
}

.dock-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 46px;
  color: #b39672;
  font-size: 9.5px;
  letter-spacing: .04em;
  transition: color .16s ease, transform .12s ease;
}

.dock-item .mp-icon {
  width: 22px;
  height: 22px;
  transition: transform .16s ease, filter .16s ease;
}

.dock-item span { line-height: 1; }
.dock-item:active { transform: translateY(1px); }

.dock-item.active {
  color: #ffb45c;
  text-shadow: 0 0 10px rgba(255, 138, 61, .55);
}

.dock-item.active .mp-icon {
  color: #ffb45c;
  filter: drop-shadow(0 0 7px rgba(255, 138, 61, .8));
  transform: translateY(-1px);
}

.dock-item.active::before {
  content: "";
  position: absolute;
  top: -7px;
  left: 50%;
  width: 24px;
  height: 3px;
  border-radius: 0 0 3px 3px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, transparent, #ffd06a, transparent);
  box-shadow: 0 0 10px rgba(255, 180, 80, .9);
}

/* ========================= 投石机 ========================= */

.treb {
  position: absolute;
  right: -10px;
  bottom: 150px;
  z-index: 6;
  width: 192px;
  pointer-events: none;
  opacity: .94;
  filter: drop-shadow(0 12px 22px rgba(0, 0, 0, .48));
  transform-origin: 58% 88%;
  transition: opacity .4s ease, bottom .4s ease, transform .12s ease-out;
}

.treb svg { width: 100%; height: auto; }
.treb.fire { animation: trebRecoil .42s cubic-bezier(.2, .8, .3, 1); }

.app.in-battle .treb {
  bottom: 172px;
  opacity: .78;
}

@media (max-height: 720px) {
  .treb { width: 158px; bottom: 138px; }
  .app.in-battle .treb { bottom: 158px; }
}

/* ========================= 战斗 HUD ========================= */

.battle-hud {
  position: relative;
  z-index: 30;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: calc(8px + var(--safe-t)) 12px 0;
}

.back { flex: 0 0 38px; margin-top: 2px; }

.gate-meter {
  flex: 1 1 auto;
  min-width: 0;
  padding: 5px 10px 7px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(32, 18, 10, .78), rgba(18, 10, 5, .8));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07), 0 4px 14px rgba(0, 0, 0, .3);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.meter-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 9.5px;
  color: #f7ddb2;
  line-height: 1.2;
}

.meter-top span { display: inline-flex; align-items: center; gap: 3px; letter-spacing: .05em; }
.meter-top .mp-icon { width: 12px; height: 12px; color: #ffce6a; }
.meter-top b { font-size: 10px; color: #ffe8b8; letter-spacing: .02em; }

.meter-bar {
  height: 8px;
  margin-top: 4px;
  padding: 1px;
  border-radius: 5px;
  background: #160c06;
  border: 1px solid rgba(255, 190, 100, .28);
  overflow: hidden;
}

.meter-bar i {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #b82d1f 0%, #ef6a2b 45%, #ffb445 78%, #ffe08a 100%);
  box-shadow: 0 0 9px rgba(255, 150, 60, .7);
  transition: width .22s ease-out;
}

.timer {
  flex: 0 0 auto;
  display: flex;
  align-items: baseline;
  gap: 1px;
  min-width: 62px;
  height: 38px;
  padding: 0 9px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(32, 18, 10, .8), rgba(18, 10, 5, .84));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07), 0 4px 14px rgba(0, 0, 0, .3);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.timer .mp-icon { width: 13px; height: 13px; color: #ffce6a; align-self: center; margin-right: 1px; }
.timer b { font-size: 20px; line-height: 1; color: #fff3d3; font-variant-numeric: tabular-nums; }
.timer small { font-size: 9px; color: #e6c691; margin-left: 1px; }
.timer.low { border-color: rgba(255, 90, 60, .7); box-shadow: 0 0 18px rgba(220, 50, 20, .35); }
.timer.low b { color: #ff7a5a; animation: blink 1s steps(2, start) infinite; }

/* ========================= 城门靶区 ========================= */

.gate-tag {
  position: absolute;
  left: 50%;
  top: 36.5%;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 11px;
  transform: translate(-50%, -50%);
  border-radius: 7px;
  border: 1px solid #e0a34d;
  background: linear-gradient(180deg, rgba(104, 27, 16, .94), rgba(52, 13, 8, .94));
  color: #ffe2ae;
  font-size: 10px;
  letter-spacing: .08em;
  box-shadow: 0 5px 12px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 220, 160, .2);
  pointer-events: none;
}

.gate-tag b { color: #ffd06a; font-size: 11px; }
.gate-tag.low { border-color: #ff7d4f; box-shadow: 0 0 18px rgba(230, 60, 30, .45); animation: tagPulse 1.1s ease-in-out infinite; }
.gate-tag::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -5px;
  width: 8px;
  height: 8px;
  transform: translateX(-50%) rotate(45deg);
  background: #38110a;
  border-right: 1px solid #e0a34d;
  border-bottom: 1px solid #e0a34d;
}

.gate-hit {
  position: absolute;
  left: 50%;
  top: 47.5%;
  z-index: 14;
  width: 44vw;
  max-width: 250px;
  height: 24vh;
  max-height: 230px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.gate-glow {
  position: absolute;
  inset: 0;
  border-radius: 46%;
  opacity: 0;
  background: radial-gradient(ellipse at center, rgba(255, 218, 130, .95) 0%,
    rgba(255, 140, 45, .55) 32%, rgba(255, 80, 20, .12) 62%, transparent 74%);
  mix-blend-mode: screen;
}

.gate-hit.hit .gate-glow { animation: gateFlash .36s ease-out; }

.cracks {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.cr {
  opacity: 0;
  transition: opacity .28s ease;
}

.cr path {
  fill: none;
  stroke: #2a1209;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 2px rgba(255, 190, 90, .75));
}

.gate-hit.cr1 .cr1 { opacity: .9; }
.gate-hit.cr2 .cr1, .gate-hit.cr2 .cr2 { opacity: .95; }
.gate-hit.cr3 .cr1, .gate-hit.cr3 .cr2, .gate-hit.cr3 .cr3 { opacity: 1; }

.gate-hit.broken .gate-glow {
  opacity: 1;
  animation: gateBreak .8s ease-out;
}

/* ========================= 箭雨 / 格挡 ========================= */

.raid-flash {
  position: absolute;
  inset: 0;
  z-index: 22;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at 50% 52%, rgba(160, 20, 8, 0) 32%, rgba(170, 22, 10, .7) 100%);
}

.raid-flash.hit { animation: raidHit .6s ease-out; }
.raid-flash.block {
  background: radial-gradient(circle at 50% 72%, rgba(96, 198, 255, .4) 0%, rgba(40, 130, 220, .16) 36%, transparent 66%);
  animation: blockFlash .55s ease-out;
}

.raid-banner {
  position: absolute;
  left: 50%;
  top: 21%;
  z-index: 36;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 9px 22px 10px;
  border-radius: 12px;
  border: 1px solid #ffb35c;
  background: linear-gradient(180deg, rgba(122, 25, 15, .96), rgba(58, 10, 6, .97));
  box-shadow: 0 12px 34px rgba(0, 0, 0, .55), 0 0 26px rgba(255, 70, 25, .38),
    inset 0 1px 0 rgba(255, 210, 150, .25);
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, -8px) scale(.94);
  transition: opacity .18s ease, transform .2s ease, visibility .18s;
  pointer-events: none;
}

.raid-banner.show {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0) scale(1);
  animation: raidPop .34s cubic-bezier(.2, .9, .3, 1.35);
}

.raid-banner .mp-icon { width: 22px; height: 22px; color: #ffcf6a; margin-bottom: 2px; }
.raid-banner b { font-family: var(--font-title); font-size: 16px; letter-spacing: .12em; color: #fff0c9; }
.raid-banner span { font-size: 10px; letter-spacing: .08em; color: #ffc9a0; }

/* ========================= 投石 / 粒子 ========================= */

.fx-layer, .float-layer, .arrow-layer {
  position: absolute;
  inset: 0;
  z-index: 26;
  pointer-events: none;
  overflow: hidden;
}

.float-layer { z-index: 27; }
.arrow-layer { z-index: 24; }

.boulder {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 26;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #c9c4ba 0%, #7b766f 34%, #46423e 66%, #211e1c 100%);
  box-shadow: 0 0 18px rgba(255, 130, 45, .7), inset -4px -4px 8px rgba(0, 0, 0, .55);
  will-change: transform;
}

.boulder::after {
  content: "";
  position: absolute;
  inset: -9px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 160, 70, .5) 0%, rgba(255, 110, 30, .12) 48%, transparent 68%);
}

.spark {
  position: absolute;
  width: 5px;
  height: 5px;
  margin: -2px 0 0 -2px;
  border-radius: 50%;
  background: #ffd37a;
  box-shadow: 0 0 8px rgba(255, 140, 50, .95);
  animation: sparkFly .68s ease-out forwards;
}

.spark.gold { background: #fff2c0; box-shadow: 0 0 10px #ffd37a; }

.float-text {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: var(--font-title);
  font-weight: 900;
  font-size: 28px;
  color: #ffd76a;
  text-shadow: 0 2px 0 #6b1d12, 0 0 16px rgba(255, 140, 50, .85);
  animation: floatUp .95s ease-out forwards;
  pointer-events: none;
  white-space: nowrap;
}

.float-text.crit { font-size: 36px; color: #fff2bd; }
.float-text.bad { font-size: 20px; color: #ff8060; text-shadow: 0 2px 0 #4d0c06, 0 0 12px rgba(255, 70, 40, .8); }
.float-text.good { font-size: 19px; color: #9fe6ff; text-shadow: 0 2px 0 #0c3a52, 0 0 12px rgba(90, 190, 255, .8); }

.volley-arrow {
  position: absolute;
  width: 20px;
  height: 20px;
  color: #ffd27a;
  filter: drop-shadow(0 0 7px rgba(255, 110, 30, .9));
  animation: volleyFly .72s ease-in forwards;
}

.shield-ring {
  position: absolute;
  z-index: 27;
  width: 78px;
  height: 78px;
  margin: -39px 0 0 -39px;
  border-radius: 50%;
  border: 3px solid rgba(130, 214, 255, .95);
  box-shadow: 0 0 26px rgba(90, 190, 255, .8), inset 0 0 20px rgba(90, 190, 255, .45);
  animation: shieldRing .55s ease-out forwards;
}

/* ========================= 战斗底栏 ========================= */

.battle-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  padding: 26px 16px calc(12px + var(--safe-b));
  background: linear-gradient(180deg, rgba(14, 8, 4, 0) 0%, rgba(14, 8, 4, .68) 26%,
    rgba(13, 7, 4, .95) 62%, rgba(11, 6, 3, .99) 100%);
}

.morale-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 9.5px;
  color: #f0d4a7;
}

.morale-label {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex: 0 0 auto;
  letter-spacing: .06em;
}

.morale-label .mp-icon { width: 13px; height: 13px; color: #ffb35c; }

.morale-bar {
  flex: 1 1 auto;
  height: 7px;
  padding: 1px;
  border-radius: 4px;
  background: #170c06;
  border: 1px solid rgba(255, 190, 100, .3);
  overflow: hidden;
}

.morale-bar i {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #6ea9d8, #9fe6ff 70%, #e2f9ff);
  box-shadow: 0 0 8px rgba(110, 190, 255, .55);
  transition: width .25s ease-out;
}

.morale-bar i.low { background: linear-gradient(90deg, #b83422, #ff7a4e); box-shadow: 0 0 9px rgba(255, 90, 40, .6); }

.morale-num {
  flex: 0 0 auto;
  min-width: 22px;
  text-align: right;
  font-size: 10px;
  font-weight: 800;
  color: #bfe8ff;
  font-variant-numeric: tabular-nums;
}

.power-row {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  margin-top: 9px;
}

.power-box { flex: 1 1 auto; min-width: 0; }

.power-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
  font-size: 9.5px;
  color: #e9c997;
  letter-spacing: .05em;
}

.power-top b {
  min-height: 12px;
  color: #ffd06a;
  font-size: 10px;
  letter-spacing: .03em;
}

.power-track {
  position: relative;
  height: 21px;
  border-radius: 11px;
  border: 1px solid #8a5a2b;
  background: linear-gradient(180deg, #180d07, #301b0c 60%, #1c1008);
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, .65), 0 1px 0 rgba(255, 210, 150, .12);
  overflow: hidden;
}

.power-track::after {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: 9px;
  background: repeating-linear-gradient(90deg, transparent 0 13px, rgba(255, 210, 150, .07) 13px 14px);
  pointer-events: none;
  z-index: 0;
}

.sweet {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 56%;
  width: 24%;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 236, 160, .98), rgba(255, 186, 70, .92) 54%, rgba(255, 120, 45, .92));
  box-shadow: 0 0 14px rgba(255, 180, 70, .8), inset 0 1px 0 rgba(255, 255, 255, .7);
  transition: left .18s ease, width .18s ease;
  z-index: 1;
}

.sweet::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 50%;
  width: 2px;
  height: calc(100% - 4px);
  transform: translateX(-50%);
  border-radius: 2px;
  background: rgba(255, 255, 255, .85);
  box-shadow: 0 0 8px #fff;
}

.needle {
  position: absolute;
  top: -2px;
  bottom: -2px;
  left: 8%;
  width: 4px;
  margin-left: -2px;
  border-radius: 3px;
  background: #fff;
  box-shadow: 0 0 8px #fff, 0 0 18px rgba(255, 180, 90, .95);
  transition: left .03s linear;
  z-index: 2;
}

.fire-btn {
  flex: 0 0 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 48px;
  border-radius: 14px;
  border: 1px solid #ffe3a2;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .35), transparent 34%),
    linear-gradient(180deg, #ffd05f 0%, #ff9c3e 48%, #ee6a24 100%);
  color: #3c1707;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .08em;
  box-shadow: 0 6px 0 #8a3410, 0 12px 20px rgba(0, 0, 0, .4), inset 0 1px 0 rgba(255, 252, 220, .7);
  transition: transform .1s ease, box-shadow .1s ease, background .2s ease;
}

.fire-btn .mp-icon { width: 19px; height: 19px; }
.fire-btn .shield-ico { display: none; }
.fire-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #8a3410, 0 5px 10px rgba(0, 0, 0, .35); }

.fire-btn.shield-mode {
  border-color: #d8f4ff;
  color: #082334;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .45), transparent 38%),
    linear-gradient(180deg, #b9efff 0%, #58b8e9 48%, #2b7fbc 100%);
  box-shadow: 0 6px 0 #16466d, 0 0 24px rgba(90, 190, 255, .55), inset 0 1px 0 rgba(255, 255, 255, .8);
  animation: shieldPulse .65s ease-in-out infinite alternate;
}

.fire-btn.shield-mode .fire-ico { display: none; }
.fire-btn.shield-mode .shield-ico { display: inline-block; }

.battle-tip {
  margin: 7px 0 0;
  text-align: center;
  font-size: 9.5px;
  line-height: 1.35;
  letter-spacing: .02em;
  color: rgba(255, 218, 170, .64);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .7);
}

/* ========================= 结算弹层 ========================= */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(7, 4, 2, .7);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .28s ease, visibility .28s;
}

.overlay.show { opacity: 1; visibility: visible; }

.result-card {
  position: relative;
  width: 100%;
  max-width: 342px;
  margin-top: 22px;
  padding: 34px 20px 20px;
  border-radius: 22px;
  border: 1px solid rgba(255, 205, 120, .58);
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(255, 150, 66, .16), transparent 52%),
    linear-gradient(180deg, #3b2413 0%, #241309 52%, #170c06 100%);
  box-shadow: 0 26px 60px rgba(0, 0, 0, .7), inset 0 1px 0 rgba(255, 235, 190, .16),
    inset 0 0 40px rgba(255, 120, 40, .06);
  transform: translateY(20px) scale(.955);
  transition: transform .34s cubic-bezier(.2, .9, .3, 1.2);
}

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

.result-card::before,
.result-card::after {
  content: "";
  position: absolute;
  width: 38px;
  height: 38px;
  border-color: rgba(255, 210, 135, .55);
  border-style: solid;
  pointer-events: none;
}

.result-card::before { top: 8px; left: 8px; border-width: 1px 0 0 1px; border-radius: 7px 0 0 0; }
.result-card::after { right: 8px; bottom: 8px; border-width: 0 1px 1px 0; border-radius: 0 0 7px 0; }

.result-seal {
  position: absolute;
  top: -27px;
  left: 50%;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  transform: translateX(-50%) rotate(-4deg);
  border-radius: 14px;
  border: 2px solid #ffd88f;
  background: radial-gradient(circle at 35% 30%, #d9512f, #8c2317 62%, #60140c);
  color: #fff0c4;
  font-family: var(--font-title);
  font-size: 30px;
  font-weight: 900;
  box-shadow: 0 10px 22px rgba(0, 0, 0, .55), inset 0 0 14px rgba(255, 210, 150, .25);
}

.result-card h2 {
  margin: 0;
  text-align: center;
  font-family: var(--font-title);
  font-size: 29px;
  letter-spacing: .16em;
  color: #ffd677;
  text-shadow: 0 2px 0 #6b250c, 0 0 20px rgba(255, 170, 70, .35);
}

.result-card p { margin: 7px 0 0; text-align: center; font-size: 11px; letter-spacing: .04em; color: #eccfa2; }

.result-card.lose .result-seal {
  border-color: #d9b88c;
  background: radial-gradient(circle at 35% 30%, #6a5a4b, #3a3028 62%, #211a15);
  color: #e2ceb2;
}

.result-card.lose h2 { color: #ffb193; text-shadow: 0 2px 0 #5b1b0c; }

.result-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin: 16px 0 0;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 200, 120, .18);
  background: rgba(255, 200, 120, .16);
}

.result-stats div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 5px;
  padding: 9px 11px;
  background: rgba(22, 12, 7, .72);
}

.result-stats span { font-size: 9.5px; color: #d8b98e; letter-spacing: .02em; }
.result-stats b { font-size: 14px; color: #ffe0a0; font-variant-numeric: tabular-nums; }

.reward {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
  padding: 7px 10px;
  border-radius: 9px;
  border: 1px dashed rgba(255, 200, 120, .38);
  background: rgba(255, 160, 60, .08);
  font-size: 10px;
  color: #ffdca4;
  letter-spacing: .03em;
}

.reward .mp-icon { width: 15px; height: 15px; color: #ffd05f; }
.reward.hidden { display: none; }

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.btn-primary, .btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 46px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .09em;
  transition: transform .12s ease, filter .12s ease;
}

.btn-primary {
  border: 1px solid #ffe3a2;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .35), transparent 38%),
    linear-gradient(180deg, #ffcd5c, #ff9139 52%, #e2601f);
  color: #3b1607;
  box-shadow: 0 5px 0 #8c3410, 0 10px 20px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 250, 215, .7);
}

.btn-ghost {
  height: 42px;
  border: 1px solid rgba(255, 205, 130, .38);
  background: rgba(255, 255, 255, .04);
  color: #f0d6ab;
  font-size: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05);
}

.btn-primary:active, .btn-ghost:active { transform: translateY(2px); filter: brightness(.95); }
.btn-primary.wide { margin-top: 4px; }

/* ========================= 设置面板 ========================= */

.sheet-overlay {
  align-items: flex-end;
  padding: 0;
  background: rgba(5, 3, 2, .55);
}

.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 88dvh;
  overflow-y: auto;
  padding: 16px 18px calc(18px + var(--safe-b));
  border-radius: 22px 22px 0 0;
  border-top: 1px solid rgba(255, 210, 140, .55);
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(255, 150, 70, .14), transparent 52%),
    linear-gradient(180deg, #34200f 0%, #201209 52%, #150b05 100%);
  box-shadow: 0 -18px 50px rgba(0, 0, 0, .65), inset 0 1px 0 rgba(255, 235, 190, .16);
  transform: translateY(24px);
  transition: transform .3s cubic-bezier(.2, .9, .3, 1.1);
}

.sheet-overlay.show .sheet { transform: translateY(0); }

.sheet::before {
  content: "";
  display: block;
  width: 40px;
  height: 4px;
  margin: -4px auto 12px;
  border-radius: 3px;
  background: rgba(255, 215, 160, .38);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sheet-head h3 {
  margin: 0;
  font-family: var(--font-title);
  font-size: 20px;
  letter-spacing: .14em;
  color: #ffd47e;
}

.sheet-head .icon-btn { width: 32px; height: 32px; }

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding: 12px 13px;
  border-radius: 12px;
  border: 1px solid rgba(255, 200, 120, .22);
  background: rgba(255, 255, 255, .035);
  font-size: 12px;
  color: #f2dcb8;
}

.switch-label { display: inline-flex; align-items: center; gap: 7px; }
.switch-label .mp-icon { width: 17px; height: 17px; color: #ffcd6b; }

.switch-ctl { position: relative; display: inline-block; width: 50px; height: 28px; flex: 0 0 auto; }
.switch-ctl input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; z-index: 2; cursor: pointer; }

.switch {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  border: 1px solid #7a4b25;
  background: #2a1a10;
  transition: background .2s ease, border-color .2s ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #e8cba0;
  box-shadow: 0 2px 5px rgba(0, 0, 0, .4);
  transition: transform .2s ease, background .2s ease;
}

.switch-ctl input:checked + .switch {
  border-color: #ffd58a;
  background: linear-gradient(90deg, #ff8a3d, #ffc24d);
}

.switch-ctl input:checked + .switch::after {
  transform: translateX(22px);
  background: #fff8e8;
}

.help {
  margin: 14px 0 14px;
  padding: 12px 13px;
  border-radius: 12px;
  border: 1px solid rgba(255, 200, 120, .18);
  background: rgba(10, 6, 3, .28);
}

.help h4 {
  margin: 0 0 7px;
  font-size: 11px;
  letter-spacing: .12em;
  color: #ffce6b;
}

.help p {
  margin: 5px 0 0;
  font-size: 10.5px;
  line-height: 1.6;
  color: #dec4a2;
}

/* ========================= 提示 Toast ========================= */

.toast {
  position: absolute;
  left: 50%;
  bottom: 24%;
  z-index: 80;
  max-width: 82%;
  padding: 8px 15px;
  border-radius: 999px;
  border: 1px solid rgba(255, 205, 130, .4);
  background: rgba(24, 13, 7, .92);
  color: #ffe5bb;
  font-size: 11px;
  line-height: 1.4;
  letter-spacing: .02em;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .08);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 10px);
  transition: opacity .2s ease, transform .2s ease, visibility .2s;
  pointer-events: none;
}

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

/* ========================= 动效 ========================= */

@keyframes sheen {
  0%, 55% { left: -55%; }
  85%, 100% { left: 135%; }
}

@keyframes emberRise {
  0% { transform: translate(0, 0) scale(.6); opacity: 0; }
  14% { opacity: .85; }
  70% { opacity: .55; }
  100% { transform: translate(var(--ex, 12px), -38vh) scale(1.15); opacity: 0; }
}

@keyframes tagPulse {
  50% { filter: brightness(1.25); }
}

@keyframes blink {
  50% { opacity: .45; }
}

@keyframes gateFlash {
  0% { opacity: 0; transform: scale(.7); }
  25% { opacity: 1; transform: scale(1.02); }
  100% { opacity: 0; transform: scale(1.16); }
}

@keyframes gateBreak {
  0% { opacity: 0; transform: scale(.8); }
  20% { opacity: 1; transform: scale(1.05); }
  100% { opacity: 0; transform: scale(1.5); }
}

@keyframes raidHit {
  0% { opacity: 0; }
  18% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes blockFlash {
  0% { opacity: 0; }
  20% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes raidPop {
  0% { transform: translate(-50%, -12px) scale(.9); }
  100% { transform: translate(-50%, 0) scale(1); }
}

@keyframes sparkFly {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx, 20px), var(--dy, -30px)) scale(.2); opacity: 0; }
}

@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, -46%) scale(.7); }
  18% { opacity: 1; transform: translate(-50%, -62%) scale(1.12); }
  100% { opacity: 0; transform: translate(-50%, -128%) scale(1); }
}

@keyframes volleyFly {
  0% { opacity: 0; transform: translate(0, -26px) rotate(78deg) scale(.85); }
  16% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--tx, 0), 56vh) rotate(104deg) scale(1); }
}

@keyframes shieldRing {
  0% { opacity: 0; transform: scale(.4); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.9); }
}

@keyframes shieldPulse {
  from { filter: brightness(.95); }
  to { filter: brightness(1.14); }
}

@keyframes trebRecoil {
  0% { transform: translate(0, 0) rotate(0); }
  28% { transform: translate(3px, 2px) rotate(2.2deg); }
  100% { transform: translate(0, 0) rotate(0); }
}

@keyframes shakeSm {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-3px, 2px); }
  40% { transform: translate(3px, -2px); }
  60% { transform: translate(-2px, -2px); }
  80% { transform: translate(2px, 1px); }
}

@keyframes shakeLg {
  0%, 100% { transform: translate(0, 0); }
  15% { transform: translate(-6px, 4px) rotate(-.3deg); }
  30% { transform: translate(6px, -5px) rotate(.3deg); }
  45% { transform: translate(-5px, -3px); }
  60% { transform: translate(4px, 4px); }
  80% { transform: translate(-2px, 1px); }
}

.shake-sm { animation: shakeSm .3s ease-out; }
.shake-lg { animation: shakeLg .42s ease-out; }

/* 低性能 / 减少动态偏好 */
@media (prefers-reduced-motion: reduce) {
  .start-shine, .ember, .fire-btn.shield-mode { animation: none; }
  .scene-bg, .screen, .result-card, .sheet, .toast { transition: none; }
  .shake-sm, .shake-lg, .treb.fire { animation: none; }
}

/* 极矮屏适配 */
@media (max-height: 640px) {
  .hud { padding-top: calc(4px + var(--safe-t)); }
  .avatar { width: 42px; height: 42px; flex-basis: 42px; }
  .start-btn { height: 58px; }
  .start-txt b { font-size: 21px; }
  .dock-item { min-height: 42px; }
  .treb { width: 150px; bottom: 125px; }
  .app.in-battle .treb { bottom: 150px; }
  .gate-tag { top: 34%; }
  .battle-bottom { padding-top: 18px; }
  .result-card { padding-top: 30px; }
}
