body:has(#combat-screen[open]) { overflow: hidden; }
body:has(#combat-screen[open]) > :is(.masthead, main) { visibility: hidden; }
.tile, #end { -webkit-tap-highlight-color: transparent; }
#combat-screen {
  position: fixed; inset: 0; margin: 0; width: 100%; height: 100%; height: 100dvh;
  max-width: none; max-height: none; border: 0; border-radius: 0; overflow: auto;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  color: #fbf0db;
  background: radial-gradient(ellipse at 50% 30%, #453c54, #121824 76%);
}
#combat-screen[open] { display: flex; }
#combat-screen button:focus-visible { outline-color: #ffeeae; }
.combat-frame {
  width: min(100%, 930px); margin: auto; overflow: hidden;
  background: #1a2030; border: 1px solid #9f8c75; border-radius: 10px;
  box-shadow: 0 26px 76px #0a0b16cc, 0 0 0 4px #1d2231;
}
.combat-heading, .combat-teams, .combat-controls { display: flex; align-items: center; justify-content: space-between; }
.combat-heading { padding: 10px clamp(12px,3vw,24px); border-bottom: 1px solid #81715f; background: linear-gradient(110deg, #2c2b3c, #1d2432); }
.combat-heading h2 { flex: none; margin: 0; color: #ffe09b; font-size: clamp(20px,3vw,28px); letter-spacing: .12em; white-space: nowrap; }
.combat-heading h2:focus { outline: none; }
.combat-heading-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: clamp(4px,2vw,16px); }
.combat-heading .sound-switch { background: #243b44; border-color: #65827f; color: #fbf0db; }
.combat-heading .sound-switch b { color: #c2d2cd; }
.combat-heading .sound-toggle[aria-pressed="true"] .sound-switch { background: #284d49; border-color: #85cbb9; }
.combat-heading .sound-toggle[aria-pressed="true"] b { color: #a5e7ce; }
#combat-turn, .combat-hp { font-family: Consolas, monospace; font-size: 14px; font-weight: 700; }
.combat-teams { align-items: stretch; background: #17262e; }
.combat-team {
  --side: #85e1d4; --panel: #253d45; min-width: 0; flex: 1;
  padding: 8px clamp(8px,2vw,20px) 11px; display: grid; grid-template-columns: 1fr auto;
  gap: 3px 8px; align-items: baseline; border-top: 3px solid var(--side);
  background: linear-gradient(130deg, var(--panel), #1a2831);
}
.combat-team small { color: #e8d8be; font-weight: bold; font-size: 12px; }
.combat-team.foe { --side: #ffac92; --panel: #563a39; border-left: 1px solid #856d58; }
[data-attacker="player"] .combat-team.ally, [data-attacker="enemy"] .combat-team.foe {
  box-shadow: inset 0 1px 0 var(--side), inset 0 11px 22px -17px var(--side);
}
.combat-team strong { font-size: clamp(13px,2vw,18px); }
.combat-hp { white-space: nowrap; color: var(--side); }
.combat-hp b { font-size: 1.15em; }
.force-health { position: relative; align-self: center; height: 6px; width: clamp(52px,12vw,140px); background: #111c24; border-radius: 2px; }
.force-health::before { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--hp-fill, 0%); background: var(--side); border-radius: inherit; transition: width 240ms ease; }
.force-health::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), #0f202e95 calc(10% - 1px) 10%); }
.combat-field {
  --shot: #bff8ff; --shot-edge: #68bddd; --pan: 1; --stage-ink: #b9f7f3;
  position: relative; overflow: hidden; isolation: isolate; height: clamp(220px,44dvh,460px);
  background: #82715c; border-block: 1px solid #938269;
}
.combat-camera {
  position: absolute; inset: 0; isolation: isolate;
  transition: transform .36s ease-out;
}
[data-phase="aim"] .combat-camera, [data-phase="attack"] .combat-camera {
  transform: scale(1.045) translateX(calc(var(--pan) * 1.1%));
}
[data-phase="impact"] .combat-camera {
  transform: scale(1.025) translateX(calc(var(--pan) * -.8%));
}
.combat-backdrop {
  position: absolute; inset: 0; z-index: -2;
  background: url("./assets/combat-field.png?v=graphics-bgm") center 65% / cover no-repeat;
}
.combat-backdrop img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center 61%; opacity: 0; transition: opacity .2s ease-out; }
.combat-backdrop img.is-ready { opacity: 1; }
[data-coastal] .combat-backdrop {
  background: url("./assets/combat-sea.png?v=coastal") center / cover no-repeat,
    radial-gradient(ellipse at 57% 24%, #ffe2a6 0 5%, #efaa8b 5.5%, transparent 23%),
    linear-gradient(#525d87, #d68c8e 49%, #e7b09d 55%, #578698 55.5%, #21506c);
}
[data-coastal] .combat-backdrop img { visibility: hidden; }
[data-coastal] .combat-backdrop::after {
  content: ""; position: absolute; inset: 55% 0 0;
  background: repeating-linear-gradient(174deg, transparent 0 9px, #e9f5df38 10px 11px, transparent 12px 21px),
    radial-gradient(ellipse at 57% 0%, #ffe1aa8f, transparent 54%);
}
[data-coastal] .combat-atmosphere { opacity: .33; }
[data-coastal] .formation[data-domain="land"]::after {
  content: ""; position: absolute; z-index: -2; inset: 58% 12% 0 0;
  background: repeating-linear-gradient(173deg, #efd4a0 0 2px, #c4ab86 3px 10px);
  clip-path: polygon(0 6%, 43% 17%, 68% 42%, 88% 50%, 76% 68%, 100% 84%, 82% 100%, 0 100%);
}
[data-phase="entry"] .combat-backdrop { animation: reveal-field .42s cubic-bezier(.16,.82,.35,1) both; }
@keyframes reveal-field { from { transform: scale(1.075); filter: brightness(.77); } to { transform: none; filter: none; } }
.combat-atmosphere {
  position: absolute; inset: 35% -12% 0; z-index: 1; pointer-events: none;
  background: radial-gradient(ellipse at 38% 31%, #ffe5a64f, transparent 45%),
    radial-gradient(ellipse at 69% 57%, #fbc28843, transparent 52%);
  animation: valley-haze 8s ease-in-out infinite alternate;
}
@keyframes valley-haze { from { opacity: .25; transform: translateX(-6%); } to { opacity: .66; transform: translateX(6%); } }
.combat-field::after { content: ""; position: absolute; inset: 0; z-index: 12; pointer-events: none; box-shadow: inset 0 0 58px #18203375; }
[data-attacker="enemy"] .combat-field { --shot: #ffdcaa; --shot-edge: #ec8c65; --pan: -1; --stage-ink: #ffd7ad; }
.combat-stage {
  position: absolute; top: clamp(7px, 2dvh, 18px); left: 12px; z-index: 13;
  padding: 6px 12px; border: 1px solid #dbc9a971; border-left: 3px solid var(--stage-ink);
  border-radius: 3px; background: #141c2ee8; color: #fff6df;
  font-size: clamp(11px, 1.8vw, 14px); font-weight: 850; line-height: 1.2; letter-spacing: .14em;
  box-shadow: 0 3px 12px #12151e55;
}
[data-attacker="enemy"] .combat-stage { left: auto; right: 12px; border-left: 1px solid #dbc9a971; border-right: 3px solid var(--stage-ink); }
:is([data-phase="entry"], [data-phase="result"]) .combat-stage { display: none; }
.formation { position: absolute; inset: 0 50% 0 0; z-index: 2; image-rendering: pixelated; }
.formation.foe { inset: 0 0 0 50%; transform: scaleX(-1); }
.formation::before {
  content: ""; position: absolute; z-index: -1; left: 0; bottom: 26%; width: 64%; height: 42%;
  background: var(--cover-image, none) left bottom / min(100%, 168px) auto no-repeat;
  filter: brightness(.82) saturate(.82) drop-shadow(4px 3px 0 #302d3d49);
}
.formation[data-terrain="forest"] { --cover-image: url("./assets/volley-cover-forest.png"); }
.formation[data-terrain="mountain"] { --cover-image: url("./assets/volley-cover-mountain.png"); }
.formation[data-terrain="marsh"] { --cover-image: url("./assets/volley-cover-marsh.png"); }
.formation {
  --fire-motion: infantry-fire; --hit-motion: infantry-hit; --loss-motion: infantry-down;
  --hit-frames: infantry-hit-frames;
  --fire-time: .28s; --muzzle-x: 85%; --muzzle-y: 45%; --muzzle-size: 29%;
}
.formation[data-profile="scout"] {
  --fire-motion: scout-fire; --hit-motion: scout-hit; --loss-motion: scout-down;
  --fire-time: .41s; --muzzle-x: 84%; --muzzle-y: 30%; --muzzle-size: 29%;
}
.formation:not([data-kind="infantry"]) { --hit-frames: vehicle-hit-frames; }
.formation[data-profile="support"] {
  --fire-motion: support-fire; --hit-motion: support-hit; --loss-motion: support-down;
  --fire-time: .56s; --muzzle-x: 63%; --muzzle-y: 5%; --muzzle-size: 39%;
}
.formation[data-profile="tank"] {
  --fire-motion: tank-fire; --hit-motion: tank-hit; --loss-motion: tank-down;
  --fire-time: .40s; --muzzle-x: 93%; --muzzle-y: 30%; --muzzle-size: 49%;
}
.fighter {
  --pose-aim: 16.6667%; --pose-fire: 33.3333%; --pose-recoil: 50%; --pose-hit: 66.6667%; --pose-duck: 83.3333%;
  position: absolute; left: 37%; bottom: 11%; width: 58%; max-width: 164px; aspect-ratio: 8/7;
  background: url("./assets/volley-ally.png?v=unit-combat") 50% 0 / 100% 700% no-repeat;
  filter: drop-shadow(1px 2px 0 #241e2e9e);
}
.fighter::before { content: ""; position: absolute; inset: 87% 10% 2% 6%; background: #291f32a6; border-radius: 50%; filter: blur(2px); z-index: -1; }
.foe .fighter { background-image: url("./assets/volley-foe.png?v=unit-combat"); }
.formation[data-unit="scout"] .fighter { background-image: url("./assets/volley-scout.png?v=unit-combat"); }
.formation[data-unit="enemy-scout"] .fighter { background-image: url("./assets/volley-enemy-scout.png?v=unit-combat"); }
.formation[data-unit="support"] .fighter { background-image: url("./assets/volley-support.png?v=unit-combat"); }
.formation[data-unit="friendly-support"] .fighter { background-image: url("./assets/volley-friendly-support.png?v=unit-combat"); }
.formation[data-unit="tank"] .fighter { background-image: url("./assets/volley-tank.png?v=unit-combat"); }
.formation[data-unit="enemy-tank"] .fighter { background-image: url("./assets/volley-enemy-tank.png?v=unit-combat"); }
.formation[data-kind="tank"] .fighter { left: 30%; width: 65%; max-width: 176px; }
.formation[data-static] .fighter {
  left: 31%; width: 63%; aspect-ratio: 8/7; background: none;
}
.fighter-sprite {
  position: absolute; inset: 0;
  background: var(--unit-static) center / 100% 100% no-repeat;
}
.foe .fighter-sprite { transform: scaleX(-1); }
.formation[data-domain="air"] .fighter { bottom: 38%; }
.formation[data-domain="air"]::before, .formation[data-domain="air"] .fighter::before { display: none; }
.formation[data-domain="sea"] .fighter { left: 23%; bottom: 9%; width: 73%; max-width: 182px; }
.formation[data-domain="sea"] .fighter::before {
  inset: 70% 1% 17%; background: repeating-linear-gradient(175deg, #d8f1f9a0 0 2px, transparent 2px 7px);
  filter: none;
}
.formation[data-static][data-domain="air"] {
  --fire-motion: air-fire; --hit-motion: air-hit; --loss-motion: air-down;
}
.formation[data-static][data-domain="sea"] { --hit-motion: sea-hit; --loss-motion: sea-down; }
.platoon .formation[data-kind="infantry"] .fighter {
  left: calc(72% - var(--column) * 16% + var(--rank) * 3%);
  bottom: calc(10% + var(--rank) * min(7vw, 48px) + var(--column) * 0.35%);
  width: 25%; max-width: min(86px, 16dvh); z-index: calc(2 - var(--rank));
}
[data-phase="entry"] .fighter { animation: take-position .42s steps(5, end) both; animation-delay: calc(var(--column) * 12ms); }
@keyframes take-position { from { opacity: .25; transform: translateX(-24%); } to { opacity: 1; transform: none; } }
[data-phase="aim"] .formation[data-role="attacking"] .fighter { animation: raise-sights .25s steps(1, end) both; }
@keyframes raise-sights { from { background-position-y: 0%; } 65%, to { background-position-y: var(--pose-aim); } }
[data-phase="attack"] .formation[data-role="attacking"] .fighter {
  animation: var(--fire-motion) var(--fire-time) var(--fire-delay) steps(1, end) both;
}
:is([data-phase="aim"], [data-phase="attack"]) .formation[data-role="defending"][data-kind="infantry"] .fighter { background-position-y: var(--pose-duck); }
@keyframes infantry-fire {
  from { background-position-y: var(--pose-fire); transform: translate(6%, 1%); }
  24% { background-position-y: var(--pose-recoil); transform: translate(-7%, -2%); }
  53%, to { background-position-y: var(--pose-aim); transform: translate(3%, 2%); }
}
@keyframes scout-fire {
  0%, 20%, 40% { background-position-y: var(--pose-fire); transform: translateX(5%) rotate(-1deg); }
  12%, 32%, 52% { background-position-y: var(--pose-recoil); transform: translateX(-2%) rotate(1deg); }
  70%, to { background-position-y: var(--pose-aim); transform: translateX(4%); }
}
@keyframes support-fire {
  0%, 22% { background-position-y: var(--pose-fire); transform: translateY(2%); }
  12%, 34% { background-position-y: var(--pose-recoil); transform: translate(-2%, 4%); }
  55%, to { background-position-y: var(--pose-aim); }
}
@keyframes tank-fire {
  from { background-position-y: var(--pose-fire); transform: translateX(2%); }
  13% { background-position-y: var(--pose-recoil); transform: translateX(-14%) rotate(-2.5deg); }
  45% { background-position-y: var(--pose-aim); transform: translateX(-4%); }
  70%, to { background-position-y: var(--pose-aim); transform: none; }
}
@keyframes air-fire {
  from { transform: translate(5%, -4%) rotate(-4deg); }
  35% { transform: translate(10%, 3%) rotate(3deg); }
  to { transform: none; }
}
@keyframes air-hit {
  from { transform: translate(-14%, -4%) rotate(-12deg); }
  53% { transform: translate(-5%, 6%) rotate(8deg); }
  to { transform: none; }
}
@keyframes air-down {
  from { transform: translate(-5%, -3%) rotate(-8deg); }
  to { opacity: 0; transform: translate(-27%, 63%) rotate(-30deg); filter: saturate(.45); }
}
@keyframes sea-hit {
  from { transform: translateX(-9%) rotate(5deg); }
  53% { transform: translateY(4%) rotate(-3deg); }
  to { transform: none; }
}
@keyframes sea-down {
  from { transform: rotate(5deg); }
  to { opacity: .15; transform: translateY(40%) rotate(17deg); filter: saturate(.55); }
}
.fighter::after {
  content: ""; position: absolute; left: var(--muzzle-x); top: var(--muzzle-y); width: var(--muzzle-size); aspect-ratio: 1; opacity: 0;
  background: radial-gradient(circle at 18% 51%, #fffbe2 20%, var(--shot) 44%, var(--shot-edge) 78%);
  clip-path: polygon(0 45%, 44% 35%, 75% 0, 72% 32%, 100% 46%, 76% 58%, 94% 91%, 45% 67%, 0 63%);
}
[data-phase="attack"] .formation[data-role="attacking"] .fighter::after { animation: muzzle .105s var(--fire-delay) ease-out both; }
[data-phase="attack"] .formation[data-role="attacking"][data-profile="scout"] .fighter::after { animation: muzzle 82ms ease-out 3; }
[data-phase="attack"] .formation[data-role="attacking"][data-profile="support"] .fighter::after {
  animation: muzzle 120ms ease-out 2; background: radial-gradient(circle at 24% 62%, #fffbd5 20%, #ff9a65 49%, transparent 76%);
}
@keyframes muzzle { from { opacity: .85; transform: scale(.44); } 24% { opacity: 1; } to { opacity: 0; transform: scale(1.45); } }
[data-attack-profile="tank"][data-phase="attack"] .combat-camera { animation: cannon-kick .31s ease-out; }
@keyframes cannon-kick { 12% { translate: calc(var(--pan) * -5px) 2px; } 35% { translate: calc(var(--pan) * 3px) -1px; } }

.combat-volley { position: absolute; z-index: 6; inset: 0; pointer-events: none; }
.combat-volley i {
  position: absolute; left: var(--from-x); top: var(--from-y); width: clamp(12px, 5%, 48px); height: 2px; opacity: 0;
  transform: rotate(var(--angle)) translateX(-100%); transform-origin: left center;
}
.combat-volley i::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, var(--shot-edge) 51%, var(--shot) 83%, #fff9db);
  box-shadow: 0 0 8px var(--shot-edge); border-radius: 2px;
}
.combat-volley i::after {
  content: ""; position: absolute; right: -5px; top: -5px; width: 12px; height: 12px;
  background: radial-gradient(circle, #fff6c9 12%, var(--shot) 30%, transparent 68%);
}
[data-phase="attack"] .combat-volley i { animation: shot-trail var(--flight) var(--shot-delay) linear both; }
[data-attack-profile="scout"] .combat-volley i { width: clamp(22px, 9%, 63px); height: 2px; }
[data-attack-profile="scout"] .combat-volley i::before {
  background: linear-gradient(90deg, transparent, var(--shot-edge) 36%, transparent 51% 62%, #ffcf85 74%, #fff4c2);
}
[data-attack-profile="tank"] .combat-volley i { height: 5px; width: clamp(22px, 10%, 78px); }
[data-attack-profile="tank"] .combat-volley i::before { box-shadow: 0 0 12px var(--shot-edge), -12px 1px 7px #efae6885; }
[data-attack-profile="support"] .combat-volley i { width: clamp(26px, 11%, 78px); height: 5px; }
[data-attack-profile="support"] .combat-volley i::before {
  background: linear-gradient(90deg, transparent, #d5c7bbc7 35%, #f0b381 69%, #fff4bb 94%);
  box-shadow: 1px 2px 5px #48364399, 0 0 9px #fedeb880;
}
[data-attack-profile="support"] .combat-volley i::after { background: radial-gradient(circle, #ffffff 12%, #ffd68e 33%, transparent 68%); }
[data-attack-profile="support"][data-phase="attack"] .combat-volley i { animation-name: rocket-trail; }
@keyframes shot-trail {
  from { opacity: 0; }
  10%, 84% { opacity: 1; }
  to { left: var(--to-x); top: var(--to-y); opacity: 0; }
}
@keyframes rocket-trail {
  from { opacity: 0; transform: rotate(var(--launch)) translateX(-100%); }
  12%, 88% { opacity: 1; }
  50% {
    left: calc((var(--from-x) + var(--to-x)) / 2);
    top: calc((var(--from-y) + var(--to-y)) / 2 - var(--arc-rise));
    transform: rotate(var(--angle)) translateX(-100%);
  }
  to { left: var(--to-x); top: var(--to-y); transform: rotate(var(--fall)) translateX(-100%); opacity: 0; }
}

.combat-hit { position: absolute; z-index: 7; inset: 0; pointer-events: none; }
.combat-impact, .combat-smoke, .combat-sparks, .combat-wreck, .combat-damage {
  position: absolute; left: var(--hit-x); top: var(--hit-y); opacity: 0;
}
.combat-impact {
  --impact-size: clamp(27px, 9%, 70px);
  width: var(--impact-size); aspect-ratio: 1; border: 1px solid #ffd4a5;
  translate: -50% -50%; border-radius: 50%; background: radial-gradient(circle, #fff5cde9, #f8a9606e 55%, transparent 71%);
  box-shadow: 0 0 23px #fba560a6;
}
.combat-impact::after {
  content: ""; position: absolute; inset: 10%; background: #fff2cf;
  clip-path: polygon(50% 0,61% 31%,92% 15%,76% 43%,100% 48%,76% 62%,92% 89%,61% 73%,50% 100%,41% 72%,8% 90%,22% 60%,0 49%,23% 40%,9% 13%,41% 32%);
}
.combat-smoke {
  translate: -68% 36%; width: clamp(26px, 9%, 68px); height: 16px; border-radius: 50%;
  background: #e0b894; box-shadow: 16px -8px #ae8b8d, -16px 4px #ccb096, 28px 3px #d4a489; filter: blur(2px);
}
.combat-sparks {
  width: 4px; height: 2px; background: #ffe9bf; color: #eca05e;
  box-shadow: 7px -7px #ffe9b6, 15px 2px currentColor, -6px 0 #ffd3a5, -13px -4px currentColor, 4px 8px currentColor, 12px -9px currentColor, -15px 5px #ffddad;
}
.combat-wreck {
  width: clamp(28px, 13%, 96px); aspect-ratio: 1; translate: -50% -75%; border-radius: 50%;
  background: radial-gradient(circle at 52% 64%, #f7e3a8 0 12%, #f6a55d 17% 28%, #bb6e63c7 38%, transparent 64%);
}
.combat-wreck::before {
  content: ""; position: absolute; inset: 18% 26% 44%; border-radius: 50%;
  background: #524653c7; box-shadow: -10px 4px #655361a8, 11px -5px #383d4cae, 3px -11px #594c5299;
  filter: blur(3px);
}
[data-defense-profile="scout"] .combat-wreck::before { inset: 37% 15% 31%; background: #a78c779e; }
[data-defense-profile="tank"] .combat-wreck::before { inset: 1% 21% 49%; background: #39333bcf; }
.combat-damage {
  translate: -50% calc(-100% - 19px); display: grid; justify-items: center; gap: 2px; color: #fff0bb; white-space: nowrap;
  text-shadow: -2px -1px #1c222b, 2px 2px #1c222b, -1px 2px #1c222b, 1px -1px #1c222b;
}
.combat-damage b { font: 900 clamp(30px, 7vw, 64px)/1 Consolas, monospace; }
.combat-damage small { padding: 2px 5px; font-size: 11px; font-weight: bold; background: #24303be8; border: 1px solid #a7bda6; border-radius: 4px; }
[data-phase="impact"] .combat-impact { animation: burst .42s ease-out both; }
[data-phase="impact"] .combat-smoke { animation: dust .78s ease-out both; }
[data-phase="impact"] .combat-sparks { animation: scattering .45s ease-out both; }
[data-phase="impact"] .combat-damage { opacity: 1; animation: damage-rise .8s ease-out both; }
[data-phase="impact"] .formation[data-role="defending"] .fighter:not(.retreating) {
  animation: var(--hit-motion) .55s ease-out both, var(--hit-frames) .55s steps(1, end) both;
}
[data-phase="impact"] .fighter.retreating { animation: var(--loss-motion) .89s ease-out both, defeated-frames .89s steps(1, end) both; }
[data-defense-profile="infantry"] .combat-impact { --impact-size: clamp(15px, 6%, 48px); }
[data-defense-profile="scout"] .combat-smoke { height: 9px; translate: -45% 115%; }
[data-defense-profile="support"] .combat-smoke { background: #8d7881; box-shadow: 14px -17px #ae8b8d, -14px -9px #767480; }
[data-defense-profile="tank"] .combat-impact { --impact-size: clamp(32px, 12%, 98px); }
[data-defense-profile="tank"] .combat-sparks { height: 4px; color: #ffe0a3; }
[data-defense-domain="sea"] .combat-smoke {
  height: 20px; background: #bdddea; box-shadow: 11px -12px #d4edf5, -21px 2px #88b6cc;
}
.combat-impact::before {
  content: ""; position: absolute; inset: 10%; border: 2px solid #ffebba; border-radius: 50%; opacity: 0;
  box-shadow: inset 0 0 13px #ee916c, 0 0 15px #ffd59788;
}
[data-phase="impact"][data-attack-profile="tank"] .combat-impact::before { animation: impact-ring .47s ease-out both; }
[data-phase="impact"][data-defense-profile="scout"] .combat-smoke { animation-name: skid-dust; }
[data-phase="impact"][data-defense-profile="support"] .combat-smoke { animation-name: equipment-smoke; }
[data-phase="impact"][data-defense-profile="tank"] .combat-sparks { animation-name: armor-sparks; }
[data-phase="impact"][data-lethal="true"][data-defense-profile="scout"] .combat-wreck { animation: scout-wreck .79s ease-out both; }
[data-phase="impact"][data-lethal="true"][data-defense-profile="support"] .combat-wreck { animation: support-wreck .91s ease-out both; }
[data-phase="impact"][data-lethal="true"][data-defense-profile="tank"] .combat-wreck { animation: tank-wreck .95s ease-out both; }
@keyframes burst { from { opacity: .96; transform: scale(.42); } 36% { opacity: .87; transform: scale(1); } to { opacity: 0; transform: scale(1.62); } }
@keyframes dust { from { opacity: .8; transform: scale(.5); } to { opacity: 0; transform: translate(calc(var(--pan) * 28px), -19px) scale(1.8); } }
@keyframes skid-dust { from { opacity: .7; transform: scale(.45); } to { opacity: 0; transform: translateX(calc(var(--pan) * 38px)) scale(2.1, 1.3); } }
@keyframes equipment-smoke { from { opacity: .9; transform: scale(.48); } to { opacity: 0; transform: translateY(-45px) scale(2.1); } }
@keyframes scattering { from { opacity: 1; transform: scale(.65); } to { opacity: 0; transform: translate(calc(var(--pan) * 19px), -28px) scale(2.7) rotate(18deg); } }
@keyframes armor-sparks { from { opacity: 1; transform: scale(.62); } to { opacity: 0; transform: translate(calc(var(--pan) * 14px), -32px) scale(2.9, 1.5) rotate(32deg); } }
@keyframes damage-rise { from { opacity: .85; transform: translateY(5px) scale(.75); } 33%, to { opacity: 1; transform: translateY(-12px); } }
@keyframes impact-ring { from { opacity: .9; transform: scale(.55); } to { opacity: 0; transform: scale(2.4); } }
@keyframes infantry-hit-frames { from { background-position-y: var(--pose-hit); } 30% { background-position-y: var(--pose-duck); } 82%, to { background-position-y: 0%; } }
@keyframes vehicle-hit-frames { from { background-position-y: var(--pose-hit); } 50%, to { background-position-y: 0%; } }
@keyframes defeated-frames { from { background-position-y: var(--pose-hit); } 24%, to { background-position-y: 100%; } }
@keyframes infantry-hit { from { transform: translate(-11%, -3%); } 74%, to { transform: none; } }
@keyframes scout-hit { from { transform: translateX(-17%) rotate(8deg); } 56% { transform: translateX(-9%) rotate(-3deg); } to { transform: none; } }
@keyframes support-hit { from { transform: translate(-6%, -5%) rotate(-5deg); } 47% { transform: translateY(5%) rotate(3deg); } to { transform: none; } }
@keyframes tank-hit { from { transform: translateX(-7%) rotate(2deg); } 43% { transform: translateX(-2%); } to { transform: none; } }
@keyframes infantry-down { from { transform: translate(-9%, -2%); } 59% { opacity: .94; } to { opacity: .44; transform: translate(-34%, 9%); } }
@keyframes scout-down { from { transform: translateX(-6%); } 30% { transform: translateX(-32%) rotate(15deg); } to { transform: translateX(-38%) rotate(7deg); filter: saturate(.57); } }
@keyframes support-down { from { transform: translateY(-5%); } 25% { transform: translate(-9%, -9%) rotate(-9deg); } to { transform: translate(-10%, 4%) rotate(4deg); filter: saturate(.54); } }
@keyframes tank-down { from { transform: translateX(-8%); } 19% { transform: translateX(-6%) rotate(-3deg); } to { transform: translate(-7%, 5%); filter: saturate(.38); } }
@keyframes scout-wreck { from { opacity: .95; transform: scale(.43); } to { opacity: 0; transform: translate(calc(var(--pan) * 31px), 12px) scale(1.42, .83); } }
@keyframes support-wreck { from { opacity: .9; transform: scale(.37); } 26% { opacity: .71; transform: translateY(-10px) scale(1.3); } to { opacity: 0; transform: translateY(-43px) scale(1.84, 2.14); } }
@keyframes tank-wreck { from { opacity: .96; transform: scale(.29); } 23% { opacity: .82; transform: scale(1.24); } to { opacity: 0; transform: translateY(-17px) scale(2.3, 1.85); } }
.combat-outcome {
  --verdict-light: #ffe7a7; --verdict-rim: #edbc6c; --verdict-bg: #2a1c17ec;
  position: absolute; inset: 0; z-index: 13; display: grid; align-content: center; justify-items: center;
  gap: clamp(5px, 1.5dvh, 12px); color: var(--verdict-light);
  background: radial-gradient(ellipse at 50% 25%, #ffc98052, transparent 58%), linear-gradient(#2618112c, #251a183d 36%, #1d192c76);
  animation: outcome-arrive .55s ease-out both;
}
[data-outcome="defeat"] .combat-outcome {
  --verdict-light: #deebff; --verdict-rim: #8ea5c1; --verdict-bg: #101b2cee;
  background: radial-gradient(ellipse at 50% 34%, #9bb7d322, #101a30bf 78%), linear-gradient(135deg, #13213637, #0e1d31a3);
  animation: outcome-arrive .85s ease-out both;
}
[data-outcome="defeat"] .combat-backdrop { filter: saturate(.48) contrast(.94); }
.outcome-emblem {
  width: clamp(20px, 8dvh, 76px); aspect-ratio: 1; background: var(--verdict-rim);
  clip-path: polygon(20% 11%, 86% 11%, 70% 32%, 86% 53%, 30% 53%, 30% 87%, 20% 87%);
  animation: outcome-standard .62s cubic-bezier(.2,.77,.29,1) both;
}
[data-outcome="defeat"] .outcome-emblem {
  transform: rotate(-24deg); clip-path: polygon(20% 11%, 86% 11%, 64% 34%, 74% 52%, 30% 51%, 30% 87%, 20% 87%);
  animation: none;
}
.combat-outcome h3 {
  min-width: 52%; max-width: 85%; padding: .12em .58em .2em; text-align: center;
  background: var(--verdict-bg); border-block: 2px solid var(--verdict-rim);
  box-shadow: 0 7px 20px #0d142588, inset 0 0 20px #d9a85923;
  font-size: clamp(28px, 10vw, 78px); letter-spacing: .22em; text-indent: .22em; line-height: 1.3;
  text-shadow: 0 2px 0 #091122aa, 0 0 18px #d8ad6250;
}
[data-outcome="defeat"] .combat-outcome h3 { box-shadow: 0 7px 22px #0d1425ba, inset 0 0 20px #819db52d; text-shadow: 0 2px 0 #10233c; }
@keyframes outcome-arrive { from { opacity: 0; } to { opacity: 1; } }
@keyframes outcome-standard { from { transform: translateY(12px) scale(.86); } to { transform: none; } }
.combat-controls { min-height: 76px; gap: 16px; padding: 12px clamp(12px,3vw,24px); }
#combat-status { margin: 0; color: #fff1ce; font-size: clamp(15px,2vw,20px); font-weight: 700; }
#combat-advance { width: auto; flex-shrink: 0; min-height: 48px; justify-content: center; }
@media (max-width: 550px) {
  .combat-controls { align-items: stretch; flex-direction: column; gap: 8px; }
  .combat-team { gap: 2px 4px; }
}
@media (max-width: 360px) {
  #combat-turn { font-size: 12px; }
  .combat-heading { padding-inline: 8px; gap: 5px; }
  .combat-team { grid-template-columns: auto 1fr; gap: 2px 6px; }
  .combat-team strong { grid-column: 1 / -1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .combat-team small { grid-row: 3; }
  .combat-team .force-health { grid-row: 3; }
}
@media (max-height: 640px) {
  .combat-field { height: clamp(180px,40dvh,460px); }
}
@media (max-height: 460px) {
  .combat-field { height: clamp(99px,43dvh,180px); }
  .combat-heading, .combat-controls { min-height: 0; padding-block: 5px; }
  .combat-team { padding-block: 4px; }
  .fighter { max-width: 82px; }
  .combat-damage { translate: -50% calc(-100% - 6px); }
  .combat-outcome h3 { font-size: clamp(25px, 9dvh, 46px); }
}
@media (prefers-reduced-motion: reduce) {
  #combat-screen *, #combat-screen *::before, #combat-screen *::after { animation: none !important; transition: none !important; }
  .combat-camera { transform: none !important; }
}
