* { box-sizing: border-box; }
html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  background: #0a0a0a;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: "PingFang SC", "Noto Sans SC", sans-serif;
  user-select: none;
  touch-action: none;
}

.viewport {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.stage {
  position: relative;
  width: 640px;
  height: 1386px;
  transform-origin: top left;
  overflow: hidden;
  color: #fff;
}

.bg {
  position: absolute;
  left: 0;
  top: 0;
  width: 640px;
  height: 1386px;
  background-size: 640px 1386px;
  background-repeat: no-repeat;
  image-rendering: auto;
}

.btn-pause {
  position: absolute;
  left: 12px;
  top: 18px;
  width: 64px;
  height: 62px;
  border: 0;
  padding: 0;
  background: none;
  background-size: 100% 100%;
  cursor: pointer;
  z-index: 8;
}
.btn-pause.paused { filter: brightness(0.6); }

.gold-bg {
  position: absolute;
  left: 88px;
  top: 24px;
  width: 150px;
  height: 50px;
  z-index: 8;
}
.gold-icon {
  position: absolute;
  left: -8px;
  top: 0;
  width: 52px;
  height: 44px;
  display: block;
  pointer-events: none;
}
.gold-bg strong {
  position: absolute;
  left: 50px;
  top: 7px;
  width: 90px;
  height: 36px;
  line-height: 36px;
  font-size: 32px;
  color: #f1d57a;
  font-weight: 700;
}

.wave {
  position: absolute;
  left: 248px;
  top: 20px;
  width: 162px;
  height: 62px;
  line-height: 62px;
  text-align: center;
  font-size: 40px;
  font-weight: 700;
  color: #fff;
  -webkit-text-stroke: 8px #3a2410;
  paint-order: stroke fill;
  text-shadow: 0 2px 0 #3a2410;
  z-index: 8;
}

.map {
  position: absolute;
  left: 0;
  top: 200px;
  width: 640px;
  height: 800px;
  z-index: 2;
  overflow: visible;
}

.divide {
  position: absolute;
  left: 0;
  top: 304px;
  width: 640px;
  height: 184px;
  pointer-events: none;
  z-index: 1;
  opacity: 0.95;
}

.cell {
  position: absolute;
  width: 80px;
  height: 80px;
  z-index: 0;
  background-size: 80px 80px;
  image-rendering: auto;
}
.cell.drop-ok { outline: 3px solid #8fd18a; outline-offset: -3px; z-index: 1; }
.cell.drop-bad { outline: 3px solid #d96a6a; outline-offset: -3px; z-index: 1; }

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

.hearts {
  position: absolute;
  display: flex;
  gap: 1px;
  z-index: 6;
  pointer-events: none;
}
.hearts-player { left: 567px; top: 680px; }
.hearts-enemy { left: 5px; top: -50px; }
.hearts .heart-extra {
  color: #ff8a8a;
  font-size: 16px;
  font-weight: 700;
  text-shadow: 0 1px 0 #3a0000;
  line-height: 22px;
  margin-left: 2px;
}

.unit {
  position: absolute;
  width: 80px;
  height: 80px;
  pointer-events: auto;
  cursor: grab;
  z-index: 5;
  overflow: visible;
  touch-action: none;
}
.unit img.skel {
  position: absolute;
  left: 0;
  top: 0;
  max-width: none;
  max-height: none;
  object-fit: fill;
  pointer-events: none;
  image-rendering: auto;
}
.unit .skel-stage {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  transform-origin: center center;
  pointer-events: none;
  overflow: visible;
}
.unit.on-bench .skel-stage {
  width: 80px;
  height: 80px;
  transform: none;
}
.unit.on-map.attacking .skel-stage {
  z-index: 8;
}
.pike-shaft {
  position: absolute;
  width: 30px;
  height: 71px;
  pointer-events: none;
  z-index: 9;
  transform-origin: center center;
}
.pike-shaft > img:first-child {
  display: block;
  width: 30px;
  height: 71px;
}
.pike-eff {
  position: absolute;
  left: 1px;
  top: -36px;
  width: 30px;
  height: 76px;
  display: none;
}
.pike-shaft.show-eff .pike-eff { display: block; }
.unit.on-bench .pike-shaft { display: none; }
.fx.arrow {
  width: 44px;
  height: 144px;
  z-index: 12;
}
.fx.arrow.spear {
  width: 30px;
  height: 71px;
}
.unit.on-map.farmer img.skel {
  width: 80px;
  height: 80px;
}
.unit .shadow {
  position: absolute;
  left: 18px;
  bottom: 6px;
  width: 44px;
  height: 22px;
  background: url("assets/cut/units/shadow2.png") center / 100% 100% no-repeat;
  opacity: 0.5;
  pointer-events: none;
}
.unit.on-bench .shadow,
.unit.on-bench .crops,
.unit.on-bench .hoe { display: none; }
.unit .crops {
  position: absolute;
  inset: 0;
  width: 80px;
  height: 80px;
  object-fit: contain;
  pointer-events: none;
  z-index: 0;
}
.unit .hoe {
  position: absolute;
  left: 0;
  top: 0;
  width: 80px;
  height: 80px;
  object-fit: fill;
  pointer-events: none;
  transform-origin: 50% 45%;
  animation: hoe-swing 1.1s ease-in-out infinite;
  z-index: 3;
}
.unit.on-bench .shadow,
.unit.on-bench .crops,
.unit.on-bench .hoe { display: none; }
.unit .lv[hidden],
.unit .glyph-wrap[hidden],
.unit .glyph[hidden] { display: none !important; }
.unit .glyph-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  pointer-events: none;
}
.unit .lv {
  position: absolute;
  right: 4px;
  bottom: 2px;
  min-width: 16px;
  padding: 0 3px;
  border-radius: 8px;
  background: #2a1a08;
  color: #f5d48a;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  line-height: 16px;
}
.unit .glyph {
  position: relative;
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
  line-height: 1;
  transform-origin: 50% 100%;
}
.unit .glyph-img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  flex: none;
}
.unit .glyph-img.tint {
  filter: sepia(0.85) saturate(2.6) hue-rotate(-18deg) brightness(0.9);
}
.unit.part .glyph {
  position: absolute;
  inset: 0;
  flex: none;
}
.unit.part .glyph-img {
  position: absolute;
  left: 0;
  bottom: 0;
}
.unit.shovel .skel-stage img.skel {
  margin: 1px auto 0;
}
.unit.enemy { filter: hue-rotate(160deg); pointer-events: none; }

.ghost {
  position: fixed;
  z-index: 99;
  opacity: 0.9;
  pointer-events: none;
}

.creep {
  position: absolute;
  width: 80px;
  height: 80px;
  margin: -40px 0 0 -40px;
  z-index: 6;
  pointer-events: none;
}
.creep .shadow {
  position: absolute;
  left: 15px;
  top: 58px;
  width: 50px;
  height: 22px;
  background: url("assets/cut/units/shadow2.png") center / 100% 100% no-repeat;
  opacity: 0.5;
}
.creep .hp {
  position: absolute;
  left: 12px;
  top: 3px;
  width: 62px;
  height: 11px;
  background: url("assets/cut/units/hpBg.png") center / 100% 100% no-repeat;
}
.creep .hp > b {
  display: none;
}
.creep .hp > i {
  display: block;
  margin: 3px 0 0 4px;
  height: 5px;
  background: #e07070;
}
@keyframes hoe-swing {
  0%, 100% { transform: rotate(-16deg); }
  50% { transform: rotate(20deg); }
}

.bench {
  position: absolute;
  left: 95px;
  top: 1045px;
  width: 450px;
  height: 90px;
  display: flex;
  z-index: 8;
}
.slot {
  position: relative;
  width: 90px;
  height: 90px;
  flex: none;
  touch-action: none;
}
.slot.drop-ok { outline: 3px solid #8fd18a; outline-offset: -3px; z-index: 1; }
.slot.drop-bad { outline: 3px solid #d96a6a; outline-offset: -3px; z-index: 1; }
.slot .unit {
  left: 5px;
  top: 5px;
}
.slot .unit img.skel {
  width: 80px;
  height: 80px;
}
.hearts img {
  display: block;
  width: 25px;
  height: 19px;
}

.btn-recruit {
  position: absolute;
  left: 190px;
  top: 1152px;
  width: 260px;
  height: 131px;
  border: 0;
  padding: 0;
  background: none;
  background-size: 100% 100%;
  color: #fff;
  cursor: pointer;
  z-index: 8;
  font-weight: 700;
  touch-action: none;
}
.recruit-gold {
  width: 40px;
  height: 33px;
  display: block;
}
.btn-recruit span {
  position: absolute;
  left: 69px;
  top: 18px;
  width: 121px;
  height: 51px;
  line-height: 51px;
  font-size: 47px;
  letter-spacing: 2px;
  text-shadow: 0 3px 0 #6a2a10;
  -webkit-text-stroke: 5px #6a2a10;
  paint-order: stroke fill;
}
.btn-recruit .recruit-gold {
  position: absolute;
  left: 91px;
  top: 70px;
  pointer-events: none;
}
.btn-recruit small {
  position: absolute;
  left: 132px;
  top: 68px;
  font-size: 30px;
  line-height: 35px;
  text-shadow: 0 2px 0 #5a3a10;
}
.btn-recruit span,
.btn-recruit small,
.btn-recruit .recruit-gold {
  pointer-events: none;
}

.hint {
  position: absolute;
  left: 24px;
  right: 24px;
  top: 1310px;
  margin: 0;
  font-size: 16px;
  color: #f4ead7;
  text-align: center;
  text-shadow: 0 1px 2px #000;
  z-index: 8;
}

.dev-tools {
  position: absolute;
  right: 12px;
  top: 18px;
  z-index: 8;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dev-tools button {
  border: 0;
  background: rgba(0,0,0,.45);
  color: #fff;
  border-radius: 8px;
  padding: 6px 10px;
}

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.62);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 20;
  gap: 16px;
}
.overlay[hidden] { display: none; }
.overlay h2 { margin: 0; font-size: 56px; }
.overlay p { margin: 0; font-size: 22px; }
.overlay button {
  border: 0;
  background: #c45c2a;
  color: #fff;
  font-size: 24px;
  padding: 12px 28px;
  border-radius: 12px;
}

.deco {
  position: absolute;
  left: 0;
  top: 0;
  width: 640px;
  height: 240px;
  pointer-events: none;
  z-index: 1;
}
.deco i { position: absolute; display: block; }
.deco .mountains { left: -77px; top: 33px; width: 761px; height: 145px; }
.deco .bird0 { left: 102px; top: 54px; width: 61px; height: 29px; animation: bird-fly 6s linear infinite; }
.deco .bird1 { left: 25px; top: 9px; width: 61px; height: 29px; animation: bird-fly 8s linear infinite reverse; }
.deco .deer0 { left: 569px; top: 105px; width: 76px; height: 85px; opacity: 0.6; }
.deco .deer1 { left: 212px; top: 61px; width: 76px; height: 85px; transform: scale(0.35); opacity: 0.2; }
.deco .deer2 { left: 418px; top: 140px; width: 77px; height: 85px; transform: scaleX(-0.5) scaleY(0.5); opacity: 0.5; }
.deco .deer3 { left: 172px; top: 133px; width: 76px; height: 85px; transform: scaleX(-0.7) scaleY(0.7); opacity: 0.5; }
@keyframes bird-fly {
  0% { transform: translateX(0); }
  50% { transform: translateX(40px); }
  100% { transform: translateX(0); }
}

.spine-layer {
  position: absolute;
  left: 0;
  top: 0;
  width: 640px;
  height: 800px;
  pointer-events: none;
  z-index: 7;
}

.path-tip {
  position: absolute;
  width: 80px;
  height: 150px;
  pointer-events: none;
  z-index: 3;
}
.path-tip i {
  position: absolute;
  left: 5px;
  width: 70px;
  height: 40px;
  animation: dir-blink 1.4s ease-in-out infinite;
}
.path-tip i:nth-child(1) { top: 97px; }
.path-tip i:nth-child(2) { top: 49px; animation-delay: 0.15s; }
.path-tip i:nth-child(3) { top: 0; animation-delay: 0.3s; }
.path-tip-0 { left: 0; top: 570px; }
.path-tip-1 { left: 560px; top: 80px; transform: scaleY(-1); }
@keyframes dir-blink {
  0%, 100% { opacity: 0.15; }
  50% { opacity: 0.9; }
}

.deck {
  position: absolute;
  left: -10px;
  top: 1027px;
  width: 100px;
  height: 103px;
  transform: scale(0.8);
  transform-origin: 50% 100%;
  z-index: 8;
  pointer-events: none;
}
.deck i { position: absolute; display: block; }
.deck-base { left: 0; top: 74px; width: 103px; height: 40px; }
.deck-body { left: 6px; top: 35px; width: 88px; height: 66px; }
.deck-roof { left: 12px; top: 42px; width: 109px; height: 57px; transform-origin: 13% 80%; }
.deck-ying { left: 32px; top: 35px; width: 44px; height: 57px; }
.deck-light { left: -15px; top: -31px; width: 134px; height: 72px; transform: scale(0); transform-origin: 50% 100%; }
.deck.open .deck-roof { animation: roof-open 0.55s ease; }
.deck.open .deck-light { animation: light-pop 0.55s ease; }
@keyframes roof-open {
  0% { transform: rotate(0); }
  40% { transform: rotate(-28deg); }
  100% { transform: rotate(0); }
}
@keyframes light-pop {
  0% { transform: scale(0); opacity: 0; }
  40% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0); opacity: 0; }
}

.recruit-mask {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.layer-fx { z-index: 9; overflow: visible; }
.fx {
  position: absolute;
  pointer-events: none;
  transform: translate(-50%, -50%);
}
.fx.place { width: 95px; height: 90px; animation: fx-pop 0.42s ease-out forwards; }
.fx.merge { width: 81px; height: 100px; animation: fx-up 0.65s ease-out forwards; }
.gold-pop {
  position: absolute;
  color: #f1d57a;
  font-size: 22px;
  font-weight: 700;
  text-shadow: 0 2px 0 #5a3a10;
  animation: gold-up 0.7s ease-out forwards;
  pointer-events: none;
}
@keyframes fx-pop {
  0% { transform: translate(-50%, -50%) scale(0.4); opacity: 1; }
  70% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.15); opacity: 0; }
}
@keyframes fx-up {
  0% { transform: translate(-50%, -20%) scale(0.6); opacity: 1; }
  100% { transform: translate(-50%, -90%) scale(1); opacity: 0; }
}
@keyframes gold-up {
  0% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(-28px); opacity: 0; }
}

.weapon-shop {
  position: absolute;
  left: 40px;
  right: 40px;
  top: 220px;
  height: 640px;
  z-index: 22;
  background: rgba(18, 12, 8, 0.94);
  border: 2px solid #c4a36a;
  border-radius: 12px;
  color: #f4ead7;
  display: flex;
  flex-direction: column;
  padding: 12px 16px 16px;
}
.weapon-shop[hidden] { display: none; }
.weapon-shop header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.weapon-shop h3 { margin: 0; font-size: 28px; color: #f1d57a; }
.weapon-shop header button {
  border: 0;
  background: #7a3a18;
  color: #fff;
  border-radius: 8px;
  padding: 6px 12px;
}
.weapon-tabs {
  display: flex;
  gap: 8px;
  margin: 12px 0;
}
.weapon-tab {
  flex: 1;
  border: 0;
  background: #3a2a18;
  color: #f4ead7;
  border-radius: 8px;
  padding: 8px 0;
  font-size: 20px;
}
.weapon-tab.on { background: #c45c2a; }
.weapon-list {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.weapon-row {
  display: grid;
  grid-template-columns: 52px 90px 1fr auto;
  gap: 8px;
  align-items: center;
  border: 1px solid #5a4030;
  background: #2a1c10;
  color: #f4ead7;
  border-radius: 8px;
  padding: 6px 10px;
  text-align: left;
}
.weapon-row img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}
.weapon-row .nm { font-size: 18px; font-weight: 700; }
.weapon-row small {
  grid-column: 3;
  font-size: 13px;
  color: #d8c7a4;
  line-height: 1.3;
}
.weapon-row b { color: #f1d57a; font-size: 16px; }
.weapon-row.equipped { border-color: #f1d57a; }
.weapon-equipped {
  margin: 8px 0 0;
  font-size: 15px;
  color: #f1d57a;
  line-height: 1.45;
}
.weapon-note {
  margin: 10px 0 0;
  font-size: 13px;
  color: #cbb896;
  line-height: 1.4;
}

.layer-props { z-index: 4; pointer-events: none; }
.field-prop {
  position: absolute;
  width: 80px;
  height: 80px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.field-prop img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  display: block;
  margin: 8px auto 0;
}

/* 原作 BattleScene.propsBox：征兵左右两侧，不进地图 */
.prop-bar {
  position: absolute;
  top: 1170px;
  z-index: 9;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  width: 172px;
  pointer-events: none;
}
.prop-bar-active { left: 12px; }
.prop-bar-passive { left: 456px; }
.prop-slot {
  width: 54px;
  height: 54px;
  border: 0;
  padding: 0;
  position: relative;
  background: transparent;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  cursor: pointer;
  pointer-events: auto;
}
.prop-slot img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  position: absolute;
  left: 7px;
  top: 7px;
  pointer-events: none;
}
.prop-slot .cd {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.prop-slot.aiming { box-shadow: 0 0 0 2px #f1d57a; }
.prop-owned {
  margin-top: 10px;
  border-top: 1px solid #5a4030;
  padding-top: 8px;
}
.prop-owned p {
  margin: 6px 0 4px;
  font-size: 14px;
  color: #f1d57a;
}
.prop-owned-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 40px;
}
.prop-owned-row img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  background: rgba(0,0,0,.35);
  border-radius: 6px;
}
.stage.prop-aiming { cursor: crosshair; }
#btn-prop-refresh {
  margin-left: auto;
}
