:root {
  --ink: #140d08;
  --brown: #2a180d;
  --brown-2: #3e2514;
  --brown-3: #56331b;
  --gold: #ffd15c;
  --gold-2: #f3a934;
  --gold-3: #a9651f;
  --cream: #fff1cf;
  --muted: #d8b990;
  --blue: #2b8cff;
  --blue-2: #1161db;
  --red: #ff5b45;
  --theme: #FF8A3D;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #0c0806;
}

body {
  color: var(--cream);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  padding: 0;
  background: none;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

[hidden] { display: none !important; }

.game {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background:
    radial-gradient(110% 60% at 50% 0%, #2b1b10 0%, #150e09 55%, #080504 100%);
}

/* ---------------------------------------------------------------- field */
.field {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background: #9ccfe8;
  isolation: isolate;
}

.field-bg {
  position: absolute;
  inset: 0;
  background-image: url("images/gen/bg-field.jpg");
  background-repeat: no-repeat;
  background-size: cover;
  background-position: 50% 46%;
  transform: scale(1.015);
  filter: saturate(1.07) contrast(1.02);
}

.field::before {
  content: "";
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  top: 0;
  height: 118px;
  background: linear-gradient(180deg, rgba(20, 14, 9, .45) 0%, rgba(20, 14, 9, .12) 58%, transparent 100%);
  pointer-events: none;
}

.field-vignette {
  position: absolute;
  inset: 0;
  z-index: 2;
  background:
    radial-gradient(120% 95% at 50% 42%, transparent 55%, rgba(28, 15, 6, .15) 82%, rgba(13, 8, 4, .42) 100%),
    linear-gradient(180deg, transparent 74%, rgba(20, 11, 6, .48) 100%);
  pointer-events: none;
}

#battle {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.portrait-hero,
.portrait-keep {
  display: none;
  pointer-events: none;
  position: absolute;
  z-index: 1;
  height: auto;
  user-select: none;
}

/* ----------------------------------------------------------------- hud */
.hud {
  position: absolute;
  z-index: 8;
  top: max(8px, var(--safe-top));
  left: 12px;
  right: 12px;
  display: flex;
  align-items: flex-start;
  gap: 7px;
  pointer-events: none;
}

.resource-pill {
  height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 11px 0 6px;
  border-radius: 18px;
  border: 1px solid rgba(255, 201, 101, .7);
  background:
    linear-gradient(180deg, rgba(82, 49, 25, .97) 0%, rgba(39, 22, 11, .97) 68%, rgba(24, 13, 7, .98) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 226, 157, .34),
    inset 0 -2px 0 rgba(0, 0, 0, .35),
    0 2px 7px rgba(0, 0, 0, .42);
  color: #fff6df;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: .2px;
  line-height: 1;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.res-ico {
  width: 25px;
  height: 25px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 32% 28%, #fff6c9 0%, #ffd35c 36%, #df8d21 72%, #8b4b10 100%);
  box-shadow: inset 0 0 0 1.5px rgba(255, 248, 203, .68), 0 1px 2px rgba(0, 0, 0, .5);
  color: #7a3f08;
}

.res-ico .mp-icon { width: 16px; height: 16px; }

.troop-pill .res-ico {
  background: radial-gradient(circle at 32% 28%, #d9efff 0%, #8bc4ff 34%, #2d76db 74%, #133f84 100%);
  color: #eaf6ff;
}

.troop-pill b { color: #9fd2ff; font-size: 16px; }
.troop-pill .slash { color: #a98e6d; padding: 0 1px; }

.gold-pill { color: #ffe9a7; }
.gold-pill #goldValue { min-width: 40px; }
.gold-rate {
  font-size: 9px;
  font-weight: 700;
  color: #9edc83;
  margin-left: 1px;
  letter-spacing: 0;
}

.enemy-hud {
  margin-left: auto;
  width: 168px;
  padding: 6px 9px 7px;
  border-radius: 11px;
  border: 1px solid rgba(255, 177, 99, .72);
  background: linear-gradient(180deg, rgba(66, 34, 19, .96), rgba(28, 14, 8, .97));
  box-shadow:
    inset 0 1px 0 rgba(255, 213, 139, .3),
    0 2px 8px rgba(0, 0, 0, .45);
}

.enemy-top,
.player-top {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #ffddb2;
  font-size: 10.5px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.enemy-top .mp-icon,
.player-top .mp-icon { width: 13px; height: 13px; color: #ff9d52; }

.enemy-top b,
.player-top b {
  margin-left: auto;
  font-size: 10.5px;
  color: #ffd26f;
  font-variant-numeric: tabular-nums;
}

.hp-track {
  width: 100%;
  height: 6px;
  margin-top: 5px;
  border-radius: 4px;
  background: rgba(0, 0, 0, .62);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .7);
  overflow: hidden;
}

.hp-fill {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  transition: width .16s linear;
}

.enemy-fill { background: linear-gradient(90deg, #ff442b, #ff7a3a 55%, #ffb14a); box-shadow: 0 0 7px rgba(255, 92, 53, .65); }
.player-fill { background: linear-gradient(90deg, #2d8bff, #54bdff 55%, #b5ebff); box-shadow: 0 0 7px rgba(63, 171, 255, .62); }

.player-hud {
  position: absolute;
  z-index: 7;
  left: 12px;
  bottom: 11px;
  width: 132px;
  padding: 5px 8px 6px;
  border-radius: 9px;
  border: 1px solid rgba(111, 180, 255, .5);
  background: linear-gradient(180deg, rgba(21, 47, 81, .86), rgba(11, 25, 45, .9));
  box-shadow: 0 2px 7px rgba(0, 0, 0, .34);
  pointer-events: none;
}

.player-top { color: #cbe9ff; }
.player-top .mp-icon { color: #83c8ff; }
.player-top b { color: #a8ddff; }
.player-hud .hp-track { height: 5px; margin-top: 4px; }

/* --------------------------------------------------------------- effects */
.battle-hint {
  position: absolute;
  z-index: 7;
  left: 50%;
  top: 54px;
  transform: translateX(-50%);
  padding: 7px 15px;
  border-radius: 999px;
  border: 1px solid rgba(255, 214, 128, .45);
  background: rgba(32, 18, 9, .68);
  color: #ffe7b5;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .6px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .28);
  pointer-events: none;
  transition: opacity .55s ease, transform .55s ease;
  backdrop-filter: blur(3px);
  white-space: nowrap;
}

.battle-hint.gone { opacity: 0; transform: translate(-50%, -6px); }

.toast {
  position: absolute;
  z-index: 30;
  left: 50%;
  bottom: 18px;
  transform: translate(-50%, 10px);
  max-width: 82%;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 205, 113, .62);
  background: rgba(31, 17, 8, .94);
  color: #ffe8ba;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 5px 18px rgba(0, 0, 0, .45);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  white-space: nowrap;
}

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

.announce {
  position: absolute;
  z-index: 18;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s ease;
}

.announce.show { opacity: 1; }

.announce span {
  color: #ffe071;
  font-size: clamp(32px, 8vw, 64px);
  font-weight: 900;
  letter-spacing: .18em;
  text-shadow:
    0 2px 0 #8e4d12,
    0 4px 0 #4c2609,
    0 0 24px rgba(255, 158, 45, .8),
    0 6px 20px rgba(0, 0, 0, .55);
  transform: scale(.7);
  transition: transform .34s cubic-bezier(.2, 1.6, .4, 1);
}

.announce.show span { transform: scale(1); }

/* ------------------------------------------------------------ end screen */
.end-screen {
  position: absolute;
  z-index: 40;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background:
    radial-gradient(circle at 50% 42%, rgba(62, 31, 12, .5), rgba(8, 5, 3, .86) 74%),
    rgba(7, 4, 2, .55);
  backdrop-filter: blur(2px);
}

.end-card {
  width: min(420px, 92vw);
  padding: 20px 22px 18px;
  text-align: center;
  border-radius: 18px;
  border: 2px solid #d69a42;
  background:
    linear-gradient(155deg, rgba(92, 54, 25, .98), rgba(38, 21, 11, .99) 45%, rgba(22, 12, 7, 1));
  box-shadow:
    inset 0 1px 0 rgba(255, 234, 174, .42),
    inset 0 0 40px rgba(255, 141, 45, .09),
    0 16px 48px rgba(0, 0, 0, .72);
  animation: endIn .34s cubic-bezier(.2, 1.2, .4, 1) both;
}

@keyframes endIn {
  from { opacity: 0; transform: translateY(14px) scale(.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.end-crest {
  width: 54px;
  height: 54px;
  margin: -46px auto 2px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 2px solid #ffe29a;
  background: radial-gradient(circle at 34% 26%, #fff5bb, #ffc543 44%, #b9661a 100%);
  color: #703b08;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .5), inset 0 0 0 3px rgba(107, 54, 10, .2);
}

.end-crest .mp-icon { width: 30px; height: 30px; }

.end-screen.lose .end-card h2 { color: #ff9a7e; text-shadow: 0 2px 0 #6b1d10, 0 0 18px rgba(255, 92, 62, .38); }
.end-screen.lose .end-crest { border-color: #ffb6a3; background: radial-gradient(circle at 34% 26%, #ffe0bd, #ff8e6a 44%, #912c19 100%); color: #5b160b; }

.end-card h2 {
  margin: 7px 0 3px;
  color: #ffe071;
  font-size: 29px;
  line-height: 1.15;
  letter-spacing: .1em;
  text-shadow: 0 2px 0 #83420e, 0 0 18px rgba(255, 165, 55, .4);
}

.end-card p {
  margin: 0;
  color: #e2c9a1;
  font-size: 12.5px;
  line-height: 1.55;
}

.end-stats {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 16px 0 15px;
}

.end-stats > div {
  flex: 1;
  min-width: 0;
  padding: 8px 4px 7px;
  border-radius: 9px;
  border: 1px solid rgba(255, 202, 111, .26);
  background: rgba(0, 0, 0, .24);
}

.end-stats span { display: block; color: #b99a72; font-size: 10px; }
.end-stats b { display: block; margin-top: 3px; color: #ffdf91; font-size: 16px; font-variant-numeric: tabular-nums; }

.again-btn {
  width: 100%;
  height: 47px;
  border-radius: 10px;
  border: 2px solid #ffe49a;
  background: linear-gradient(180deg, #ffcc55 0%, #f09a25 48%, #cf6b12 100%);
  box-shadow: inset 0 2px 0 rgba(255, 249, 200, .65), inset 0 -3px 0 rgba(128, 57, 4, .5), 0 4px 0 #71340a, 0 7px 14px rgba(0, 0, 0, .38);
  color: #51270a;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: .08em;
  text-shadow: 0 1px 0 rgba(255, 245, 185, .65);
}

.again-btn:active { transform: translateY(3px); box-shadow: inset 0 2px 0 rgba(255, 249, 200, .55), inset 0 -1px 0 rgba(128, 57, 4, .5), 0 1px 0 #71340a, 0 3px 6px rgba(0, 0, 0, .4); }

/* ---------------------------------------------------------------- deck */
.deck {
  position: relative;
  z-index: 12;
  flex: 0 0 auto;
  height: clamp(150px, 43vh, 214px);
  display: flex;
  gap: 9px;
  padding: 8px 12px calc(8px + var(--safe-bottom));
  background:
    linear-gradient(180deg, #5b381d 0%, #3a2212 7%, #25160c 28%, #1b0f08 100%);
  border-top: 2px solid #d99a42;
  box-shadow:
    inset 0 1px 0 rgba(255, 229, 158, .38),
    inset 0 12px 24px rgba(255, 136, 47, .06),
    0 -9px 26px rgba(0, 0, 0, .62);
}

.deck::before {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  top: 3px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 235, 177, .62), transparent);
  pointer-events: none;
}

.deck::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .18;
  background-image:
    repeating-linear-gradient(90deg, rgba(255, 226, 170, .2) 0 1px, transparent 1px 48px),
    repeating-linear-gradient(0deg, rgba(0, 0, 0, .28) 0 1px, transparent 1px 31px);
  mix-blend-mode: overlay;
}

.deck-body {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.tabs {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  min-height: 25px;
  padding-left: 1px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 0 0 auto;
  height: 25px;
  padding: 0 15px;
  border-radius: 6px 6px 2px 2px;
  border: 1px solid rgba(0, 0, 0, .45);
  border-bottom: 0;
  background: linear-gradient(180deg, #59452f, #332419);
  color: #bda98f;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .04em;
  box-shadow: inset 0 1px 0 rgba(255, 238, 196, .13);
  transition: transform .12s ease, filter .12s ease;
}

.tab:active { transform: translateY(1px); }

.tab.active {
  color: #fff;
  border-color: #6bb6ff;
  background: linear-gradient(180deg, #3e9cff 0%, #1c6ee0 55%, #0e4ead 100%);
  box-shadow:
    inset 0 1px 0 rgba(215, 241, 255, .55),
    inset 0 -2px 0 rgba(0, 30, 91, .36),
    0 0 10px rgba(62, 156, 255, .34);
  text-shadow: 0 1px 1px rgba(0, 26, 76, .6);
}

.units {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 5px;
}

.unit-card {
  position: relative;
  min-width: 0;
  min-height: 0;
  border-radius: 6px;
  background-color: #0c2460;
  background-size: cover;
  background-position: center 46%;
  background-repeat: no-repeat;
  border: 1px solid rgba(238, 181, 84, .46);
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, .28),
    0 2px 4px rgba(0, 0, 0, .36);
  transition: transform .1s ease, filter .16s ease, opacity .16s ease, box-shadow .14s ease;
  touch-action: manipulation;
  overflow: hidden;
}

.unit-card:active { transform: translateY(2px) scale(.98); filter: brightness(1.14); }

.unit-card.selected {
  border-color: #fff0ba;
  transform: translateY(-2px);
  box-shadow:
    0 0 0 2px #ffd261,
    0 0 0 4px rgba(28, 112, 238, .7),
    0 0 16px 3px rgba(76, 167, 255, .62),
    inset 0 0 12px rgba(93, 183, 255, .5);
  z-index: 2;
}

.unit-card.selected:active { transform: translateY(0) scale(.99); }

.unit-card.dim {
  opacity: .2;
  filter: saturate(.3) brightness(.72);
  pointer-events: none;
}

.card-cost {
  position: absolute;
  right: 3px;
  bottom: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 15px;
  padding: 0 5px;
  border-radius: 999px;
  border: 1px solid rgba(255, 225, 143, .7);
  background: rgba(28, 13, 4, .84);
  color: #ffe6a1;
  font-size: 9.5px;
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 1px #000;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .6);
}

.card-cost::before {
  content: "";
  width: 5px;
  height: 5px;
  margin-right: 2px;
  border-radius: 50%;
  background: #ffd05a;
  box-shadow: 0 0 3px rgba(255, 195, 57, .8);
}

.card-live {
  position: absolute;
  left: 3px;
  top: 3px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid rgba(204, 238, 255, .9);
  background: linear-gradient(180deg, #4ea8ff, #1458c8);
  color: #fff;
  font-size: 9px;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .6);
}

.card-live.on { display: inline-flex; }

/* -------------------------------------------------------------- action */
.action {
  position: relative;
  z-index: 1;
  flex: 0 0 172px;
  width: 172px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 7px 8px 7px;
  border-radius: 10px;
  border: 1px solid rgba(225, 166, 72, .55);
  background:
    linear-gradient(155deg, rgba(92, 57, 29, .9), rgba(50, 29, 14, .94) 50%, rgba(29, 16, 9, .96));
  box-shadow:
    inset 0 1px 0 rgba(255, 227, 168, .2),
    inset 0 0 22px rgba(255, 139, 47, .06),
    0 2px 8px rgba(0, 0, 0, .34);
}

.selected-info { min-width: 0; }

.selected-name {
  color: #ffe284;
  font-size: 14px;
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: .04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 0 #4a2508;
}

.selected-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
  color: #c9ac84;
  font-size: 9.5px;
  font-weight: 700;
  white-space: nowrap;
}

.meta-dot {
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: #8f7151;
}

.meta-cost { display: inline-flex; align-items: center; gap: 2px; color: #ffd368; }
.meta-cost .mp-icon { width: 11px; height: 11px; }
.meta-cost b { font-size: 10px; }

.supply-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  color: #bca07b;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.supply-line b { color: #9ed8ff; font-size: 10.5px; font-variant-numeric: tabular-nums; }

.deploy-btn {
  position: relative;
  flex: 1 1 auto;
  min-height: 48px;
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 9px;
  border: 2px solid #ffe49a;
  background:
    linear-gradient(180deg, #ffe07a 0%, #ffc447 22%, #ff8a3d 58%, #cf6810 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 252, 209, .8),
    inset 0 -3px 0 rgba(132, 55, 3, .52),
    0 4px 0 #743508,
    0 7px 14px rgba(0, 0, 0, .4),
    0 0 18px rgba(255, 143, 41, .22);
  color: #5b2c08;
  text-shadow: 0 1px 0 rgba(255, 248, 201, .7);
  overflow: hidden;
  transition: filter .12s ease, transform .1s ease, box-shadow .1s ease;
  touch-action: manipulation;
}

.deploy-btn::before {
  content: "";
  position: absolute;
  top: -30%;
  left: -24%;
  width: 58%;
  height: 170%;
  background: linear-gradient(100deg, transparent 0%, rgba(255, 255, 255, .34) 48%, transparent 100%);
  transform: rotate(14deg);
  pointer-events: none;
}

.deploy-btn::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 5px;
  border: 1px solid rgba(255, 241, 171, .3);
  pointer-events: none;
}

.deploy-btn:active,
.deploy-btn.pressed {
  transform: translateY(3px);
  filter: brightness(1.08);
  box-shadow:
    inset 0 2px 0 rgba(255, 252, 209, .7),
    inset 0 -1px 0 rgba(132, 55, 3, .5),
    0 1px 0 #743508,
    0 3px 7px rgba(0, 0, 0, .4);
}

.deploy-btn.is-short { filter: grayscale(.44) brightness(.78); }
.deploy-btn.is-short:active { filter: grayscale(.3) brightness(.9); }

.deploy-swords {
  width: 27px;
  height: 27px;
  display: block;
  color: #fff7d8;
  filter: drop-shadow(0 2px 0 rgba(103, 48, 4, .55));
}

.deploy-swords svg { width: 100%; height: 100%; display: block; }

.deploy-label {
  position: relative;
  z-index: 1;
  font-size: 22px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: .08em;
}

/* ----------------------------------------------------------- portrait */
@media (orientation: portrait) {
  .field { flex: 1 1 auto; min-height: 0; }

  .field-bg {
    background-position: 56% 48%;
    transform: scale(1.03);
  }

  .portrait-hero {
    display: block;
    left: -6%;
    bottom: -4%;
    width: 56%;
    max-width: 270px;
    opacity: .93;
    -webkit-mask-image: radial-gradient(ellipse 68% 66% at 44% 48%, #000 0%, #000 44%, rgba(0, 0, 0, .72) 65%, transparent 92%);
    mask-image: radial-gradient(ellipse 68% 66% at 44% 48%, #000 0%, #000 44%, rgba(0, 0, 0, .72) 65%, transparent 92%);
    filter: saturate(1.04) drop-shadow(0 5px 10px rgba(0, 0, 0, .22));
  }

  .portrait-keep {
    display: block;
    right: -7%;
    bottom: -2%;
    width: 27%;
    max-width: 124px;
    opacity: .94;
    -webkit-mask-image: radial-gradient(ellipse 68% 65% at 55% 48%, #000 0%, #000 44%, rgba(0, 0, 0, .68) 66%, transparent 93%);
    mask-image: radial-gradient(ellipse 68% 65% at 55% 48%, #000 0%, #000 44%, rgba(0, 0, 0, .68) 66%, transparent 93%);
    filter: drop-shadow(0 5px 10px rgba(0, 0, 0, .24));
  }

  .hud { gap: 5px; left: 9px; right: 9px; }
  .resource-pill { height: 34px; padding-right: 8px; font-size: 14px; }
  .res-ico { width: 23px; height: 23px; }
  .gold-rate { display: none; }
  .enemy-hud { width: 133px; padding: 5px 7px 6px; }
  .enemy-top, .enemy-top b { font-size: 10px; }

  .player-hud { left: 10px; bottom: 9px; width: 116px; }
  .battle-hint { top: 49px; font-size: 11.5px; }

  .deck {
    height: clamp(304px, 47vh, 426px);
    flex-direction: column;
    gap: 5px;
    padding: 8px 10px calc(8px + var(--safe-bottom));
  }

  .deck-body { flex: 1 1 auto; gap: 5px; }
  .tabs { min-height: 27px; gap: 5px; }
  .tab { height: 27px; flex: 1 1 0; padding: 0 4px; font-size: 11.5px; }

  .units {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: repeat(4, minmax(0, 1fr));
    gap: 5px;
  }

  .unit-card { background-position: center 43%; }

  .action {
    flex: 0 0 55px;
    width: auto;
    height: 55px;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 6px 7px;
  }

  .selected-info { flex: 1 1 auto; min-width: 0; padding-left: 2px; }
  .selected-name { font-size: 14px; }
  .selected-meta { margin-top: 1px; font-size: 9px; }
  .supply-line { flex: 0 0 auto; display: block; text-align: right; font-size: 8.5px; line-height: 1.25; }
  .supply-line span { display: block; }
  .supply-line b { display: block; font-size: 11px; }

  .deploy-btn {
    flex: 0 0 132px;
    width: 132px;
    height: 43px;
    min-height: 43px;
    margin: 0;
    border-radius: 8px;
    gap: 5px;
  }

  .deploy-swords { width: 23px; height: 23px; }
  .deploy-label { font-size: 20px; }

  .toast { bottom: 12px; }
  .end-card { padding: 18px 18px 16px; }
  .end-card h2 { font-size: 26px; }
}

@media (orientation: portrait) and (max-height: 700px) {
  .deck { height: 42vh; min-height: 270px; }
  .unit-card { background-position: center 40%; }
  .battle-hint { display: none; }
  .player-hud { width: 104px; }
}

@media (orientation: landscape) and (max-height: 440px) {
  .deck { height: 154px; padding: 6px 10px 6px; gap: 7px; }
  .deck-body { gap: 4px; }
  .tab { height: 22px; padding: 0 13px; font-size: 11px; }
  .units { gap: 4px; }
  .action { flex-basis: 154px; width: 154px; padding: 5px 7px; }
  .selected-name { font-size: 12.5px; }
  .selected-meta, .supply-line { font-size: 9px; }
  .deploy-btn { min-height: 43px; }
  .deploy-swords { width: 23px; height: 23px; }
  .deploy-label { font-size: 19px; }
  .battle-hint { top: 48px; font-size: 11px; }
  .player-hud { width: 116px; bottom: 8px; }
}

@media (orientation: landscape) and (max-height: 370px) {
  .deck { height: 142px; }
  .hud { top: 6px; }
  .enemy-hud { width: 138px; }
  .battle-hint { display: none; }
}

@media (max-width: 360px) and (orientation: portrait) {
  .gold-pill { padding-right: 7px; }
  .resource-pill { font-size: 13px; }
  .enemy-hud { width: 122px; }
  .tab { font-size: 10.5px; }
  .deploy-btn { flex-basis: 118px; width: 118px; }
}
