:root {
  color-scheme: light;
  --ink: #171b22;
  --muted: #536072;
  --paper: rgba(255, 249, 232, 0.94);
  --paper-edge: rgba(93, 72, 49, 0.26);
  --line: rgba(36, 38, 42, 0.18);
  --gold: #d7942c;
  --orange: #e76f22;
  --wood: #9a6539;
  --wood-dark: #6d4528;
  --stone: #9a9a98;
  --river: #96c5cd;
  --grass: #a7a05e;
  --ground: #d7b474;
  --village: #e56d1d;
  --enemy: #5a3e36;
  --blue-aura: #6ed8ff;
  --green-aura: #8cf09a;
  --gold-aura: #ffd45f;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family:
    "Trebuchet MS", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont,
    sans-serif;
  color: var(--ink);
  background: #bcd0d6;
  touch-action: manipulation;
}

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

.game-root {
  min-height: 100svh;
  background:
    linear-gradient(180deg, rgba(239, 248, 250, 0.9), rgba(239, 248, 250, 0.24) 46%),
    linear-gradient(180deg, #c9dde1 0 54%, #b6ad69 54% 100%);
}

.screen {
  min-height: 100svh;
  position: relative;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: hidden;
}

.storybook-screen {
  background:
    radial-gradient(circle at 50% 15%, rgba(255, 255, 255, 0.8), transparent 28%),
    linear-gradient(180deg, #c7dde1 0 50%, #d4b579 50% 100%);
}

.storybook-scene {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.start-panel,
.story-panel,
.result-panel,
.repair-panel,
.help-panel {
  width: min(760px, 92vw);
  padding: 28px;
  border: 2px solid var(--paper-edge);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0)),
    var(--paper);
  box-shadow:
    0 24px 70px rgba(48, 43, 36, 0.22),
    inset 0 0 0 1px rgba(255, 255, 255, 0.66);
}

.illustrated-panel {
  position: relative;
  z-index: 3;
}

.illustrated-panel::before,
.illustrated-panel::after {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  height: 2px;
  border-radius: 999px;
  background: rgba(106, 76, 45, 0.22);
}

.illustrated-panel::before {
  top: 12px;
}

.illustrated-panel::after {
  bottom: 12px;
}

.eyebrow {
  margin: 0 0 10px;
  color: #8d4b1c;
  font-size: 14px;
  font-weight: 900;
}

h1,
h2 {
  margin: 0;
  line-height: 1.08;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(34px, 6vh, 56px);
}

h2 {
  font-size: clamp(26px, 5vh, 42px);
}

.lead,
.story-copy,
.result-copy {
  color: var(--muted);
  line-height: 1.75;
}

.lead {
  max-width: 600px;
  margin: 18px 0 24px;
  font-size: 17px;
}

.story-copy,
.result-copy {
  display: grid;
  gap: 8px;
  margin: 18px 0 22px;
  font-size: 16px;
}

.story-copy p,
.result-copy p {
  margin: 0;
}

.mission-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  margin: 0 0 22px;
  padding: 14px;
  border: 1px solid rgba(108, 76, 43, 0.24);
  border-radius: 8px;
  background: rgba(245, 226, 181, 0.55);
}

.mission-card strong {
  grid-column: 1 / -1;
  color: #6f421e;
}

.mission-card span {
  position: relative;
  padding-left: 16px;
  color: #43505f;
  font-weight: 800;
}

.mission-card span::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.7em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--orange);
}

.start-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.difficulty-panel {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid rgba(45, 75, 110, 0.24);
  border-radius: 8px;
  background: rgba(230, 240, 248, 0.62);
}

.difficulty-panel strong {
  display: block;
  margin-bottom: 8px;
  color: #2f506b;
  font-size: 13px;
}

.difficulty-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.difficulty-chip {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(45, 75, 110, 0.28);
  background: rgba(255, 255, 255, 0.76);
  color: #2f506b;
  font-size: 13px;
  font-weight: 900;
}

.difficulty-chip.active {
  background: #2f506b;
  color: #fff;
  border-color: #2f506b;
}

.difficulty-desc {
  display: block;
  margin-top: 8px;
  color: #4c6174;
  font-size: 12px;
  font-weight: 700;
}

.primary-action,
.secondary-action,
.train-button,
.command-button {
  min-height: 44px;
  border-radius: 8px;
  padding: 0 18px;
  font-weight: 900;
  transition:
    transform 0.15s ease,
    opacity 0.15s ease,
    background 0.15s ease;
}

.primary-action {
  background: #243447;
  color: #fff;
  box-shadow: 0 8px 0 rgba(22, 31, 43, 0.18);
}

.secondary-action,
.command-button {
  background: #edf2f4;
}

.primary-action:active,
.secondary-action:active,
.train-button:active,
.command-button:active {
  transform: translateY(2px) scale(0.99);
}

.game-hud {
  position: relative;
  height: 100svh;
  min-width: 760px;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.top-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  background: rgba(255, 249, 232, 0.88);
  border-bottom: 2px solid rgba(88, 64, 42, 0.2);
  box-shadow: 0 6px 18px rgba(80, 63, 44, 0.12);
  backdrop-filter: blur(10px);
}

.stat-sub {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  font-weight: 700;
  opacity: 0.72;
}

.wave-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(231, 111, 34, 0.18);
  color: #9a4a12;
  font-size: 11px;
  font-weight: 900;
}

.coin-stat {
  position: relative;
}

.gold-pop {
  position: absolute;
  right: 8px;
  top: -4px;
  color: var(--gold);
  font-size: 13px;
  font-weight: 900;
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
}

.gold-pop.show {
  animation: gold-float 0.55s ease forwards;
}

.coin-stat.gold-pulse .stat-sub,
.coin-stat.gold-bump {
  color: #9a4a12;
}

.coin-stat.gold-bump {
  animation: gold-bump 0.35s ease;
}

.wave-banner {
  position: absolute;
  left: 50%;
  top: 42%;
  z-index: 8;
  transform: translate(-50%, -12px);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(255, 249, 232, 0.95);
  border: 2px solid rgba(231, 111, 34, 0.45);
  color: #8d4b1c;
  font-weight: 900;
  font-size: 15px;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 10px 28px rgba(48, 43, 36, 0.18);
}

.wave-banner.show {
  animation: wave-banner-pop 1.5s ease forwards;
}

.units-layer {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
}

.battlefield [data-bind="miner"] {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.stat {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid rgba(113, 80, 50, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.54);
  font-size: 13px;
  font-weight: 900;
}

.coin-stat {
  color: #86551c;
}

.stat span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.health-track {
  width: 100%;
  height: 8px;
  margin-top: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(35, 42, 54, 0.15);
}

.health-fill {
  width: var(--value);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #65b877, #9de28b);
}

.health-fill.enemy {
  background: linear-gradient(90deg, #915150, #d2694b);
}

.battlefield {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 42% 14%, rgba(255, 255, 255, 0.55), transparent 22%),
    linear-gradient(180deg, #d4e4e8 0 50%, #c8af73 50% 100%);
}

.battlefield::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: url("../assets/reference-scene.png") center 42% / cover no-repeat;
  opacity: 0.34;
  pointer-events: none;
}

.battlefield > * {
  position: absolute;
  z-index: 1;
}

.painted-sky {
  position: absolute;
  inset: 0 0 48%;
  background:
    linear-gradient(180deg, rgba(238, 249, 250, 0.88), rgba(210, 225, 226, 0.2)),
    radial-gradient(circle at 60% 30%, rgba(255, 255, 255, 0.8), transparent 24%);
}

.painted-mountain {
  position: absolute;
  bottom: 43%;
  width: 34%;
  height: 35%;
  opacity: 0.95;
  filter: drop-shadow(0 8px 0 rgba(72, 70, 67, 0.12));
}

.painted-mountain::before,
.painted-mountain::after {
  content: "";
  position: absolute;
  bottom: 0;
  border-style: solid;
}

.painted-mountain::before {
  left: 0;
  border-width: 0 150px 190px 80px;
  border-color: transparent transparent #8d8d8a transparent;
}

.painted-mountain::after {
  left: 68px;
  border-width: 0 120px 168px 120px;
  border-color: transparent transparent #b7b4ad transparent;
}

.painted-mountain.left {
  left: -4%;
}

.painted-mountain.right {
  right: -5%;
  transform: scaleX(-1);
}

.painted-mountain.far {
  left: 28%;
  bottom: 47%;
  width: 44%;
  height: 27%;
  opacity: 0.38;
  transform: scale(0.9);
}

.painted-river {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 30%;
  height: 25%;
  z-index: 1;
  background:
    linear-gradient(100deg, transparent 0 25%, rgba(137, 190, 199, 0.82) 25% 74%, transparent 74%),
    linear-gradient(180deg, rgba(184, 224, 226, 0.68), rgba(99, 156, 170, 0.76));
  clip-path: polygon(0 68%, 18% 56%, 34% 72%, 51% 52%, 68% 64%, 84% 44%, 100% 58%, 100% 100%, 0 100%);
}

.river-shimmer {
  left: 0;
  right: 0;
  bottom: 31%;
  height: 18%;
  z-index: 2;
  background: linear-gradient(
    105deg,
    transparent 0 40%,
    rgba(255, 255, 255, 0.45) 48%,
    transparent 56%
  );
  clip-path: polygon(0 68%, 18% 56%, 34% 72%, 51% 52%, 68% 64%, 84% 44%, 100% 58%, 100% 100%, 0 100%);
  animation: river-shimmer 4s linear infinite;
  opacity: 0.55;
  pointer-events: none;
}

.bridge {
  position: absolute;
  left: 27%;
  bottom: 46%;
  width: 32%;
  height: 12%;
  border-bottom: 16px solid var(--wood-dark);
  border-radius: 0 0 50% 50%;
  background:
    repeating-linear-gradient(90deg, transparent 0 36px, rgba(75, 43, 24, 0.45) 36px 41px),
    linear-gradient(180deg, #ba7d42, #8f5a32);
  box-shadow:
    inset 0 -8px 0 rgba(61, 36, 22, 0.24),
    0 10px 0 rgba(86, 62, 42, 0.1);
}

.bridge::before {
  content: "";
  position: absolute;
  left: -3%;
  right: -3%;
  top: -18px;
  height: 20px;
  border-top: 5px solid var(--wood-dark);
  border-radius: 50% 50% 0 0;
  background:
    repeating-linear-gradient(90deg, var(--wood-dark) 0 5px, transparent 5px 54px),
    transparent;
}

.bridge::after {
  content: "";
  position: absolute;
  left: 16%;
  right: 16%;
  bottom: -15px;
  height: 60px;
  border-left: 10px solid rgba(77, 47, 29, 0.82);
  border-right: 10px solid rgba(77, 47, 29, 0.82);
}

.preview-bridge {
  left: 23%;
  bottom: 40%;
  opacity: 0.72;
}

.windmill {
  position: absolute;
  left: 13%;
  bottom: 61%;
  width: 70px;
  height: 96px;
  z-index: 1;
}

.windmill::before {
  content: "";
  position: absolute;
  left: 18px;
  bottom: 0;
  width: 34px;
  height: 70px;
  border: 3px solid rgba(62, 51, 42, 0.55);
  border-radius: 16px 16px 4px 4px;
  background: #e8dac1;
  transform: perspective(80px) rotateX(6deg);
}

.windmill::after {
  content: "";
  position: absolute;
  left: 25px;
  top: 19px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #c46824;
  box-shadow: 0 0 0 3px rgba(78, 54, 35, 0.44);
}

.windmill i {
  position: absolute;
  left: 33px;
  top: 28px;
  width: 8px;
  height: 80px;
  background: rgba(83, 67, 48, 0.74);
  transform-origin: center 12px;
  transform: rotate(45deg);
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.18),
    0 -30px 0 1px rgba(83, 67, 48, 0.74);
}

.windmill i::before {
  content: "";
  position: absolute;
  left: -36px;
  top: 34px;
  width: 80px;
  height: 8px;
  background: rgba(83, 67, 48, 0.74);
  box-shadow:
    30px 0 0 1px rgba(83, 67, 48, 0.74),
    -30px 0 0 1px rgba(83, 67, 48, 0.74);
}

.preview-windmill {
  left: 8%;
  bottom: 54%;
}

.camp-tents {
  position: absolute;
  right: 8%;
  bottom: 46%;
  width: 220px;
  height: 100px;
  z-index: 2;
}

.camp-tents::before,
.camp-tents::after {
  content: "";
  position: absolute;
  bottom: 0;
  border-style: solid;
  filter: drop-shadow(0 8px 0 rgba(80, 58, 38, 0.13));
}

.camp-tents::before {
  left: 0;
  border-width: 0 62px 86px 62px;
  border-color: transparent transparent #d8c29a transparent;
}

.camp-tents::after {
  right: 0;
  border-width: 0 76px 104px 76px;
  border-color: transparent transparent #ecd8ad transparent;
}

.preview-tents {
  right: 6%;
  bottom: 33%;
}

.war-banner {
  position: absolute;
  right: 25%;
  bottom: 50%;
  width: 120px;
  height: 136px;
  z-index: 2;
}

.war-banner::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 0;
  bottom: 0;
  width: 5px;
  border-radius: 999px;
  background: #704522;
}

.war-banner::after {
  content: "";
  position: absolute;
  left: 13px;
  top: 10px;
  width: 96px;
  height: 48px;
  border: 3px solid rgba(105, 58, 22, 0.46);
  border-left: 0;
  border-radius: 0 8px 8px 0;
  background: var(--orange);
  clip-path: polygon(0 0, 100% 7%, 88% 50%, 100% 93%, 0 100%);
}

.war-banner i {
  position: absolute;
  left: 44px;
  top: 18px;
  z-index: 2;
  width: 22px;
  height: 26px;
  border: 2.5px solid rgba(86, 44, 24, 0.65);
  border-radius: 4px 4px 8px 8px;
  background: linear-gradient(180deg, #fff8dc, #f0e0a8);
  box-shadow: inset 0 -4px 0 rgba(180, 140, 80, 0.35);
}

.war-banner i::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 4px;
  width: 3px;
  height: 16px;
  transform: translateX(-50%);
  border-radius: 1px;
  background: #6a4028;
  box-shadow: -5px 2px 0 -1px #6a4028, 5px 2px 0 -1px #6a4028;
}

.war-banner i::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 10px;
  height: 3px;
  transform: translateX(-50%);
  border-radius: 1px;
  background: #8a5030;
}

.preview-banner {
  right: 18%;
  bottom: 35%;
}

.story-tower {
  position: absolute;
  right: 34%;
  bottom: 36%;
  width: 64px;
  height: 116px;
  z-index: 2;
}

.story-tower::before {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 0;
  height: 88px;
  border: 3px solid rgba(65, 59, 54, 0.58);
  border-radius: 12px 12px 4px 4px;
  background:
    repeating-linear-gradient(180deg, transparent 0 18px, rgba(71, 66, 60, 0.32) 18px 21px),
    repeating-linear-gradient(90deg, transparent 0 20px, rgba(71, 66, 60, 0.24) 20px 23px),
    #b6aea4;
}

.story-tower::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 38px;
  border-radius: 50% 50% 16px 16px;
  background: #c4beb4;
}

.story-tower i {
  position: absolute;
  z-index: 2;
  left: 22px;
  top: -35px;
  width: 24px;
  height: 45px;
  border-radius: 50% 50% 42% 42%;
  background:
    radial-gradient(circle at 50% 75%, #fff6a5 0 18%, transparent 19%),
    linear-gradient(180deg, #ff8f26, #ffd44d 55%, #ff7424);
  filter: drop-shadow(0 0 16px rgba(255, 126, 34, 0.85));
  animation: fire-flicker 0.8s infinite alternate ease-in-out;
}

.tower-glow {
  position: absolute;
  left: 26px;
  bottom: 28px;
  width: 12px;
  height: 36px;
  border-radius: 4px;
  background: linear-gradient(180deg, rgba(120, 255, 140, 0.15), rgba(80, 240, 100, 0.85));
  box-shadow: 0 0 18px rgba(90, 255, 120, 0.75);
  animation: glow-pulse 2.2s ease-in-out infinite;
}

.camp-pot {
  position: absolute;
  left: 10px;
  bottom: 28px;
  width: 34px;
  height: 22px;
  border: 3px solid #2a2a2a;
  border-radius: 0 0 14px 14px;
  background: linear-gradient(180deg, #3a3a3a, #1a1a1a);
  z-index: 3;
}

.camp-pot::before {
  content: "";
  position: absolute;
  left: -6px;
  right: -6px;
  top: -4px;
  height: 6px;
  border-radius: 3px;
  background: #2a2a2a;
}

.ground-decor {
  inset: auto 0 0;
  height: 44%;
  z-index: 2;
  pointer-events: none;
}

.ground-decor .rock {
  position: absolute;
  bottom: 18%;
  border-radius: 40% 50% 45% 55%;
  background: linear-gradient(145deg, #a89888, #7a7068);
  box-shadow: inset -2px -3px 0 rgba(0, 0, 0, 0.12);
}

.ground-decor .r1 {
  left: 22%;
  width: 18px;
  height: 12px;
}

.ground-decor .r2 {
  left: 58%;
  width: 14px;
  height: 10px;
}

.ground-decor .r3 {
  right: 28%;
  width: 16px;
  height: 11px;
}

.ground-decor .grass {
  position: absolute;
  bottom: 16%;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 14px solid #7a9a48;
  filter: drop-shadow(2px 0 0 #6a8840) drop-shadow(-2px 0 0 #6a8840);
}

.ground-decor .g1 {
  left: 15%;
}

.ground-decor .g2 {
  left: 38%;
}

.ground-decor .g3 {
  left: 72%;
}

.ground-decor .g4 {
  right: 18%;
}

.bridge-rope {
  position: absolute;
  top: -28px;
  width: 2px;
  height: 32px;
  background: rgba(70, 45, 25, 0.65);
  transform-origin: top center;
}

.bridge-rope.left {
  left: 8%;
  transform: rotate(8deg);
}

.bridge-rope.right {
  right: 8%;
  transform: rotate(-8deg);
}

.tent-rope {
  position: absolute;
  right: 18%;
  bottom: 8%;
  width: 48px;
  height: 24px;
  border-top: 2px solid rgba(90, 60, 35, 0.5);
  border-left: 2px solid rgba(90, 60, 35, 0.35);
  transform: skewX(-12deg);
}

.preview-tower {
  right: 31%;
  bottom: 28%;
}

.campfire {
  position: absolute;
  bottom: 37%;
  width: 54px;
  height: 42px;
  z-index: 2;
}

.campfire::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 18px;
  border: 4px solid rgba(64, 45, 31, 0.7);
  border-radius: 50%;
  background: #5d4c3e;
}

.campfire::after {
  content: "";
  position: absolute;
  left: 17px;
  bottom: 15px;
  width: 20px;
  height: 34px;
  border-radius: 50% 50% 40% 40%;
  background: linear-gradient(180deg, #ff7d22, #ffd75f 62%, #ff6b1f);
  filter: drop-shadow(0 0 12px rgba(255, 127, 34, 0.8));
  animation: fire-flicker 0.9s infinite alternate ease-in-out;
}

.village-fire {
  left: 18%;
}

.enemy-fire {
  right: 4%;
}

.ground {
  position: absolute;
  inset: auto 0 0;
  height: 43%;
  background:
    radial-gradient(ellipse at 18% 78%, rgba(75, 58, 42, 0.3) 0 1%, transparent 12%),
    radial-gradient(ellipse at 72% 68%, rgba(75, 58, 42, 0.22) 0 1%, transparent 10%),
    linear-gradient(180deg, var(--ground), #c79658);
  border-top: 5px solid rgba(88, 69, 47, 0.28);
}

.road {
  position: absolute;
  left: 5%;
  right: 5%;
  bottom: 11%;
  height: 30%;
  border-radius: 52% 48% 0 0;
  background:
    radial-gradient(circle at 20% 60%, rgba(74, 55, 35, 0.2) 0 4px, transparent 5px),
    radial-gradient(circle at 68% 45%, rgba(74, 55, 35, 0.18) 0 5px, transparent 6px),
    rgba(196, 151, 95, 0.62);
  box-shadow: inset 0 8px 12px rgba(92, 67, 42, 0.12);
}

.base {
  position: absolute;
  bottom: 27%;
  width: 118px;
  height: 104px;
  z-index: 4;
  display: grid;
  place-items: end center;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.base::before {
  content: "";
  position: absolute;
  bottom: 0;
  width: 92px;
  height: 72px;
  border: 4px solid rgba(70, 48, 31, 0.42);
  border-radius: 8px 8px 0 0;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.26), transparent 34%),
    #d8c19b;
}

.base span {
  position: relative;
  margin-bottom: 11px;
  padding: 4px 7px;
  border-radius: 6px;
  background: rgba(23, 31, 42, 0.68);
}

.base.player {
  left: 8%;
}

.base.player::before {
  background-color: #d7be92;
}

.base.enemy {
  right: 8%;
}

.base.enemy::before {
  background-color: #bca58c;
}

.mine {
  position: absolute;
  left: 3%;
  bottom: 25%;
  z-index: 3;
  width: 82px;
  height: 72px;
  border: 4px solid rgba(45, 42, 38, 0.4);
  border-radius: 50% 50% 8px 8px;
  background:
    radial-gradient(circle at 52% 75%, #111 0 22%, transparent 23%),
    linear-gradient(135deg, #746c63, #34312f);
  box-shadow: inset 0 12px 0 rgba(255, 255, 255, 0.08);
}

.mine::after {
  content: "矿洞";
  position: absolute;
  left: 50%;
  bottom: -24px;
  transform: translateX(-50%);
  color: rgba(29, 36, 51, 0.78);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.chapter-log {
  position: absolute;
  z-index: 7;
  left: 14px;
  top: 14px;
  width: min(330px, 34vw);
  padding: 12px 14px;
  border: 1px solid rgba(105, 72, 43, 0.26);
  border-radius: 8px;
  background: rgba(255, 249, 232, 0.84);
  box-shadow: 0 10px 24px rgba(60, 46, 32, 0.15);
}

.chapter-log strong,
.chapter-log span {
  display: block;
}

.chapter-log strong {
  margin-bottom: 4px;
  color: #7a451b;
  font-size: 12px;
}

.chapter-log span {
  color: #445161;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
}

.unit-wrap,
.miner-wrap {
  position: absolute;
  bottom: 20%;
  z-index: 6;
  width: 52px;
  height: 78px;
  transform: translateX(-50%);
  transition: left 0.12s linear;
  filter: drop-shadow(0 4px 6px rgba(20, 24, 30, 0.28));
}

.miner-wrap {
  bottom: 21%;
  z-index: 5;
  animation: miner-bob 0.8s ease-in-out infinite alternate;
}

.stick-svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.stick-svg .hex-shield-aura {
  animation: hex-pulse 1.6s ease-in-out infinite;
  transform-origin: 32px 36px;
}

.stick-svg .speed-aura {
  animation: aura-spin 2.4s linear infinite;
  transform-origin: 32px 52px;
}

.stick-svg .nature-aura,
.stick-svg .enemy-aura,
.stick-svg .mine-sparkle {
  animation: aura-breathe 1.8s ease-in-out infinite;
  transform-origin: center;
}

.unit-wrap.type-sword:not(.fallen) .stick-svg {
  animation: sword-run 0.45s ease-in-out infinite alternate;
}

.unit-wrap.type-shield:not(.fallen) .stick-svg,
.unit-wrap.type-enemyShield:not(.fallen) .stick-svg {
  animation: shield-brace 1.2s ease-in-out infinite alternate;
}

.unit-wrap.type-archer:not(.fallen) .stick-svg {
  animation: archer-idle 1.4s ease-in-out infinite alternate;
}

.unit-wrap.enemy:not(.fallen) {
  filter: drop-shadow(0 3px 5px rgba(80, 50, 30, 0.35));
}

.hp-chip {
  position: absolute;
  left: 50%;
  bottom: -4px;
  width: 40px;
  height: 5px;
  transform: translateX(-50%);
  overflow: hidden;
  border-radius: 999px;
  background: rgba(20, 26, 36, 0.28);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

.hp-chip i {
  display: block;
  width: var(--hp);
  height: 100%;
  background: linear-gradient(90deg, #3d9a62, #7ed99a);
}

.unit-wrap.enemy .hp-chip i {
  background: linear-gradient(90deg, #9a3d48, #d46a5a);
}

.control-bar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 10px 14px max(12px, env(safe-area-inset-bottom));
  background: rgba(255, 249, 232, 0.9);
  border-top: 2px solid rgba(88, 64, 42, 0.2);
  box-shadow: 0 -8px 20px rgba(80, 63, 44, 0.13);
  backdrop-filter: blur(10px);
}

.train-group,
.command-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.train-button {
  min-width: 116px;
  background: #27394b;
  color: #fff;
  box-shadow: 0 5px 0 rgba(23, 32, 42, 0.16);
}

.train-button span {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  font-weight: 800;
  opacity: 0.78;
}

.train-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.command-button {
  color: #29313c;
  background: #f3e4c1;
}

.command-button.active {
  background: var(--orange);
  color: #fff;
}

.hint-line {
  grid-column: 1 / -1;
  min-height: 22px;
  color: #506071;
  font-size: 13px;
  font-weight: 800;
}

.orientation-tip {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: none;
  place-items: center;
  gap: 16px;
  padding: 20px;
  text-align: center;
  background: rgba(236, 243, 246, 0.96);
}

.orientation-tip strong,
.orientation-tip span {
  display: block;
}

.orientation-tip strong {
  margin-bottom: 8px;
  font-size: 24px;
}

.orientation-tip span {
  color: var(--muted);
}

.orientation-tip button {
  margin-top: 16px;
  border-radius: 8px;
  padding: 12px 18px;
  background: #26384f;
  color: #fff;
  font-weight: 900;
}

.parent-panel {
  margin: 0 0 18px;
  padding: 12px 14px;
  border: 1px dashed rgba(108, 76, 43, 0.35);
  border-radius: 8px;
  background: rgba(245, 226, 181, 0.4);
}

.guide-panel {
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid rgba(36, 84, 120, 0.28);
  border-radius: 8px;
  background: rgba(232, 244, 252, 0.72);
}

.guide-teaser {
  margin: 0 0 14px;
  padding: 14px;
  border: 1px solid rgba(36, 84, 120, 0.28);
  border-radius: 8px;
  background: rgba(232, 244, 252, 0.72);
}

.guide-teaser strong {
  display: block;
  margin-bottom: 8px;
  color: #2a5570;
  font-size: 16px;
}

.guide-teaser p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.guide-teaser .secondary-action {
  width: 100%;
}

.guide-panel.compact .guide-body {
  max-height: 200px;
  overflow: auto;
}

.how-to-panel[open] .guide-body {
  max-height: min(36vh, 300px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-right: 4px;
}

.guide-panel summary,
.parent-panel summary {
  cursor: pointer;
  font-weight: 900;
  list-style: none;
}

.guide-panel summary {
  color: #2a5570;
}

.parent-panel summary {
  color: #6f421e;
}

.guide-panel summary::-webkit-details-marker,
.parent-panel summary::-webkit-details-marker {
  display: none;
}

.guide-body {
  margin-top: 12px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.65;
}

.guide-goal {
  margin: 0 0 12px;
  color: #2f3b49;
}

.guide-intro {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 6px;
  background: rgba(255, 252, 240, 0.85);
  color: #3a4a5c;
  line-height: 1.65;
}

.guide-steps {
  margin: 0 0 14px;
  padding-left: 1.25em;
}

.guide-steps li {
  margin-bottom: 12px;
}

.guide-steps li p {
  margin: 4px 0 6px;
}

.guide-steps strong {
  display: block;
  color: #2a5570;
  margin-bottom: 2px;
}

.guide-tip {
  display: block;
  margin-top: 4px;
  padding: 6px 10px;
  border-left: 3px solid var(--orange);
  border-radius: 0 4px 4px 0;
  background: rgba(231, 111, 34, 0.1);
  color: #6a4a2a;
  font-size: 13px;
  line-height: 1.5;
}

.audio-toggle {
  border-radius: 999px;
  padding: 8px 14px;
  background: rgba(38, 56, 79, 0.92);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(30, 40, 55, 0.2);
}

.audio-toggle[aria-pressed="false"] {
  background: rgba(120, 130, 140, 0.85);
}

.audio-toggle-floating {
  position: absolute;
  z-index: 12;
  top: max(8px, env(safe-area-inset-top));
  right: 10px;
  padding: 6px 12px;
  font-size: 11px;
}

.start-actions .audio-toggle {
  flex: 0 0 auto;
}

/* 战场新手指引 */
.game-hud.tutorial-active {
  isolation: isolate;
}

.tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  pointer-events: auto;
}

.tutorial-spotlight {
  position: fixed;
  z-index: 10001;
  border-radius: 10px;
  box-shadow: 0 0 0 9999px rgba(18, 24, 32, 0.62);
  pointer-events: none;
  transition:
    top 0.2s ease,
    left 0.2s ease,
    width 0.2s ease,
    height 0.2s ease;
}

.tutorial-target {
  position: relative;
  z-index: 10002 !important;
  pointer-events: auto !important;
  box-shadow:
    0 0 0 3px rgba(255, 210, 90, 0.95),
    0 0 24px rgba(255, 200, 80, 0.45);
  animation: tutorial-pulse 1.2s ease-in-out infinite;
}

.tutorial-card {
  position: fixed;
  z-index: 10003;
  width: min(400px, calc(100vw - 24px));
  padding: 18px 20px;
  border: 2px solid rgba(108, 76, 43, 0.3);
  border-radius: 10px;
  background: rgba(255, 249, 232, 0.98);
  box-shadow: 0 18px 50px rgba(30, 36, 48, 0.28);
  pointer-events: auto;
}

.tutorial-progress {
  margin: 0 0 6px;
  color: #8d4b1c;
  font-size: 12px;
  font-weight: 900;
}

.tutorial-card h3 {
  margin: 0 0 10px;
  color: #2a5570;
  font-size: 20px;
  line-height: 1.25;
}

.tutorial-body {
  margin: 0 0 14px;
  color: #4a5a6a;
  font-size: 15px;
  line-height: 1.65;
}

.tutorial-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.tutorial-actions .primary-action:disabled {
  opacity: 0.72;
  cursor: wait;
}

.tutorial-actions .ghost-action {
  padding: 10px 14px;
}

@keyframes tutorial-pulse {
  0%,
  100% {
    box-shadow:
      0 0 0 3px rgba(255, 210, 90, 0.95),
      0 0 16px rgba(255, 200, 80, 0.35);
  }

  50% {
    box-shadow:
      0 0 0 5px rgba(255, 210, 90, 1),
      0 0 28px rgba(255, 200, 80, 0.55);
  }
}

.guide-block {
  margin-bottom: 12px;
}

.guide-block strong {
  display: block;
  margin-bottom: 6px;
  color: #2a5570;
}

.guide-block ul {
  margin: 0;
  padding-left: 1.2em;
}

.guide-more {
  margin-top: 10px;
  width: 100%;
}

.storybook-screen.help-screen {
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  align-items: flex-start;
  padding: max(12px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}

.help-panel {
  display: flex;
  flex-direction: column;
  max-height: min(96svh, 900px);
  margin: 0 auto;
}

.help-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.help-header h2 {
  margin: 0;
}

.help-close {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: rgba(42, 85, 112, 0.12);
  color: #2a5570;
  font-size: 28px;
  line-height: 1;
  font-weight: 400;
}

.help-close:hover {
  background: rgba(42, 85, 112, 0.22);
}

.help-panel .how-to-body {
  flex: 1 1 auto;
  min-height: 0;
  max-height: min(58vh, 520px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 0;
  padding-right: 6px;
  scrollbar-gutter: stable;
}

.guide-scroll-hint {
  margin: 12px 0 0;
  padding-top: 10px;
  border-top: 1px dashed rgba(42, 85, 112, 0.25);
  color: #6a7f92;
  font-size: 13px;
  text-align: center;
}

.help-footer {
  flex-shrink: 0;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 2px solid rgba(108, 76, 43, 0.18);
  background: linear-gradient(180deg, rgba(255, 249, 232, 0.72), rgba(255, 249, 232, 0.98));
}

.parent-panel .parent-body {
  max-height: min(28vh, 220px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.command-button.help-toggle {
  min-width: 44px;
  padding: 0 12px;
  font-size: 18px;
  font-weight: 900;
  color: #2a5570;
  background: #e8f4fa;
  border: 2px solid rgba(42, 85, 112, 0.22);
}

.parent-body {
  margin-top: 12px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.65;
}

.parent-body ul,
.parent-body ol {
  margin: 8px 0 0;
  padding-left: 1.2em;
}

.repair-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 18px;
}

.repair-card {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 2px solid rgba(108, 76, 43, 0.28);
  border-radius: 8px;
  background: rgba(255, 252, 240, 0.9);
  text-align: left;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.repair-card:hover:not(:disabled),
.repair-card:focus-visible:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(48, 43, 36, 0.15);
}

.repair-card strong {
  color: #6f421e;
  font-size: 16px;
}

.repair-card span {
  color: var(--gold);
  font-weight: 800;
  font-size: 13px;
}

.repair-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.repair-card:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.ghost-action {
  border-radius: 8px;
  padding: 12px 18px;
  background: transparent;
  border: 2px solid rgba(108, 76, 43, 0.35);
  color: #6f421e;
  font-weight: 800;
}

.codex-panel {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.codex-card {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 252, 240, 0.92);
  border: 1px solid rgba(108, 76, 43, 0.22);
}

.codex-icon {
  font-size: 22px;
  line-height: 1;
}

.codex-card strong {
  display: block;
  color: #2f3b49;
}

.codex-card em {
  display: block;
  color: #8d4b1c;
  font-style: normal;
  font-size: 12px;
  font-weight: 900;
}

.codex-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.command-button.codex-toggle.active {
  background: #4a6f8c;
  color: #fff;
}

.unit-wrap.hit-flash .stick-svg {
  animation: hit-flash 0.18s ease;
  filter: brightness(1.25);
}

.train-button.train-pulse {
  animation: train-pulse 0.32s ease;
}

.unit-wrap.fallen {
  pointer-events: none;
}

.unit-wrap.fallen .stick-svg {
  animation: unit-retreat 0.9s ease forwards;
  filter: grayscale(0.25);
}

.unit-wrap.fallen::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -8px;
  width: 18px;
  height: 18px;
  transform: translateX(-50%);
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.4),
    0 0 0 2px rgba(255, 255, 255, 0.15);
  animation: confusion-spin 0.9s linear infinite;
  opacity: 0.85;
}

.unit-wrap.fallen .hp-chip {
  display: none;
}

@keyframes gold-float {
  0% {
    opacity: 0;
    transform: translateY(8px);
  }

  30% {
    opacity: 1;
    transform: translateY(-4px);
  }

  100% {
    opacity: 0;
    transform: translateY(-18px);
  }
}

@keyframes gold-bump {
  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.04);
  }
}

@keyframes wave-banner-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, 8px) scale(0.92);
  }

  18% {
    opacity: 1;
    transform: translate(-50%, -12px) scale(1);
  }

  80% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -20px) scale(0.98);
  }
}

@keyframes hit-flash {
  0% {
    transform: scale(1);
    opacity: 1;
  }

  40% {
    transform: scale(1.35);
    opacity: 0.35;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes train-pulse {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-3px);
  }
}

@keyframes unit-retreat {
  0% {
    transform: rotate(0deg) translateY(0);
    opacity: 1;
  }

  100% {
    transform: rotate(-72deg) translateY(12px);
    opacity: 0.15;
  }
}

@keyframes hex-pulse {
  0%,
  100% {
    opacity: 0.75;
    transform: scale(1);
  }

  50% {
    opacity: 1;
    transform: scale(1.06);
  }
}

@keyframes aura-spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

@keyframes aura-breathe {
  0%,
  100% {
    opacity: 0.65;
    transform: scale(1);
  }

  50% {
    opacity: 1;
    transform: scale(1.08);
  }
}

@keyframes sword-run {
  from {
    transform: translateY(0);
  }

  to {
    transform: translateY(-3px);
  }
}

@keyframes shield-brace {
  from {
    transform: scale(1);
  }

  to {
    transform: scale(1.04);
  }
}

@keyframes archer-idle {
  from {
    transform: translateY(0);
  }

  to {
    transform: translateY(-2px);
  }
}

@keyframes miner-bob {
  from {
    transform: translateX(-50%) translateY(0);
  }

  to {
    transform: translateX(-50%) translateY(-4px);
  }
}

@keyframes river-shimmer {
  from {
    transform: translateX(-8%);
  }

  to {
    transform: translateX(8%);
  }
}

@keyframes glow-pulse {
  0%,
  100% {
    opacity: 0.7;
  }

  50% {
    opacity: 1;
  }
}

@keyframes confusion-spin {
  from {
    transform: translateX(-50%) rotate(0deg);
  }

  to {
    transform: translateX(-50%) rotate(360deg);
  }
}

@media (max-width: 720px) {
  .repair-grid,
  .codex-panel {
    grid-template-columns: 1fr;
  }
}

@keyframes fire-flicker {
  from {
    transform: scaleY(0.92) translateY(2px);
  }

  to {
    transform: scaleY(1.08) translateY(-1px);
  }
}

@media (orientation: portrait) and (max-width: 760px) {
  .orientation-tip:not(.dismissed) {
    display: grid;
  }
}

@media (max-height: 520px) {
  .top-bar {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .stat {
    padding: 6px 8px;
  }

  .chapter-log {
    top: 8px;
    width: min(300px, 35vw);
    padding: 9px 11px;
  }

  .chapter-log span {
    font-size: 12px;
  }

  .control-bar {
    grid-template-columns: 1fr auto;
    padding-top: 8px;
  }

  .train-button,
  .command-button {
    min-height: 40px;
  }

  .camp-tents {
    transform: scale(0.82);
    transform-origin: bottom right;
  }
}
