:root {
  color-scheme: dark;
  --page: #07090d;
  --ink: #fff5d9;
  --gold: #f4d896;
  --teal: #62d2c5;
  --coral: #dc7465;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 18%, rgba(98, 210, 197, 0.18), transparent 28rem),
    radial-gradient(circle at 84% 78%, rgba(220, 116, 101, 0.18), transparent 28rem),
    linear-gradient(135deg, #08090d, #14110e 54%, #07090d);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.battle-shell {
  position: relative;
  width: 100vw;
  height: 100dvh;
  display: grid;
  place-items: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#battlefield {
  display: block;
  width: min(100vw, 1180px);
  height: min(100dvh, 720px);
  aspect-ratio: 16 / 9;
  max-height: 100dvh;
  background: #111820;
  border: 1px solid rgba(244, 226, 184, 0.18);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.05),
    0 28px 90px rgba(0, 0, 0, 0.6);
  cursor: crosshair;
  touch-action: none;
}

#battlefield.is-panning-ready {
  cursor: grab;
}

#battlefield.is-unit-pickable {
  cursor: grab;
}

#battlefield.is-unit-dragging {
  cursor: grabbing;
}

.splash-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  cursor: pointer;
  background:
    radial-gradient(circle at 50% 40%, rgba(255, 229, 164, 0.16), transparent 28rem),
    radial-gradient(ellipse at 50% 44%, rgba(4, 5, 8, 0.38), rgba(4, 5, 8, 0.1) 28%, transparent 48%),
    linear-gradient(90deg, rgba(4, 5, 8, 0.38), rgba(7, 9, 13, 0.08) 43%, rgba(4, 5, 8, 0.34)),
    linear-gradient(180deg, rgba(4, 5, 8, 0.06), rgba(4, 5, 8, 0.48)),
    url("./assets/splash-impressionist-battle-tiny.jpg");
  background-position: center;
  background-size: cover;
}

.splash-copy {
  display: grid;
  justify-items: center;
  gap: 18px;
  width: min(86vw, 780px);
  color: var(--ink);
  text-align: center;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.88);
}

.splash-kicker {
  margin: 0;
  color: rgba(255, 247, 224, 0.78);
  font-size: clamp(0.68rem, 1.5vw, 0.82rem);
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.splash-copy h1 {
  position: relative;
  display: inline-block;
  isolation: isolate;
  margin: 0;
  padding: 0 14px 16px;
  font-family: Papyrus, Copperplate, Georgia, "Times New Roman", serif;
  font-size: clamp(3.4rem, 10vw, 7.8rem);
  font-variant-caps: small-caps;
  font-weight: 900;
  line-height: 0.78;
  letter-spacing: 0;
  text-transform: uppercase;
  color: transparent;
  background:
    linear-gradient(180deg, #ffffdf 0%, #ffd965 27%, #9d4d28 52%, #fff0b6 67%, #52200f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-stroke: 1.2px rgba(49, 22, 19, 0.98);
  paint-order: stroke fill;
  transform: perspective(620px) rotateX(8deg) skewX(-4deg);
  text-shadow:
    0 1px 0 #fff1b8,
    0 4px 0 #7b351f,
    0 7px 0 rgba(30, 10, 14, 0.98),
    0 16px 30px rgba(0, 0, 0, 0.86),
    0 0 24px rgba(98, 210, 197, 0.5),
    0 0 36px rgba(220, 116, 101, 0.28);
}

.splash-copy h1::before,
.splash-copy h1::after {
  content: attr(data-title);
  position: absolute;
  inset: 0;
  z-index: -1;
  box-sizing: border-box;
  padding: inherit;
  color: rgba(18, 8, 9, 0.96);
  -webkit-text-stroke: 7px rgba(15, 8, 11, 0.98);
}

.splash-copy h1::after {
  z-index: -2;
  filter: blur(12px);
  opacity: 0.5;
}

.splash-line {
  margin: 0 auto;
  max-width: 34rem;
  color: rgba(255, 247, 224, 0.84);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1rem, 2vw, 1.35rem);
  line-height: 1.32;
}

.table-width-arrow {
  position: fixed;
  top: 50%;
  z-index: 12;
  display: grid;
  place-items: center;
  width: 66px;
  height: 94px;
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(190, 200, 203, 0.86));
  color: #11151a;
  box-shadow:
    0 0 0 3px rgba(5, 8, 12, 0.24),
    0 14px 34px rgba(0, 0, 0, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  font: inherit;
  font-size: 2.8rem;
  font-weight: 950;
  line-height: 1;
  cursor: pointer;
  transform: translateY(-50%);
  touch-action: manipulation;
}

.table-width-arrow::after {
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  min-width: 58px;
  padding: 4px 7px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: rgba(8, 10, 14, 0.72);
  color: rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.28);
  font-size: 0.56rem;
  font-weight: 950;
  letter-spacing: 0.06em;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
  transform: translateX(-50%);
  backdrop-filter: blur(8px);
}

.table-width-arrow-left {
  left: max(12px, calc(env(safe-area-inset-left) + 10px));
}

.table-width-arrow-left::after {
  content: "narrow";
}

.table-width-arrow-right {
  right: max(12px, calc(env(safe-area-inset-right) + 10px));
}

.table-width-arrow-right::after {
  content: "widen";
}

.table-width-arrow:disabled {
  cursor: default;
  opacity: 0.42;
  filter: saturate(0.65);
}

.table-width-arrow:focus-visible {
  outline: 2px solid #dfffd9;
  outline-offset: 4px;
}

.table-width-label {
  position: fixed;
  left: 50%;
  bottom: max(56px, calc(env(safe-area-inset-bottom) + 54px));
  z-index: 12;
  padding: 8px 16px;
  border: 1px solid rgba(252, 226, 175, 0.42);
  border-radius: 999px;
  background: rgba(8, 10, 14, 0.76);
  color: rgba(255, 247, 224, 0.95);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.32);
  font-size: 0.72rem;
  font-weight: 950;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transform: translateX(-50%);
  backdrop-filter: blur(8px);
}

.coin-flip-overlay {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 14;
  display: grid;
  justify-items: center;
  gap: 12px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.coin-flip-shadow {
  position: absolute;
  left: 50%;
  top: 116px;
  width: 104px;
  height: 24px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.42), rgba(0, 0, 0, 0));
  filter: blur(2px);
  opacity: 0.44;
  transform: translateX(-50%);
  transform-origin: 50% 50%;
}

.coin-flip-coin {
  position: relative;
  z-index: 1;
  width: 112px;
  height: 112px;
  border: 3px solid rgba(44, 24, 10, 0.88);
  border-radius: 50%;
  background:
    radial-gradient(circle at 36% 28%, #fff6b8 0 12%, #f1bd49 31%, #9b5b21 68%, #3b1b0b 100%);
  box-shadow:
    0 24px 42px rgba(0, 0, 0, 0.44),
    inset 0 4px 10px rgba(255, 255, 220, 0.48),
    inset 0 -9px 16px rgba(64, 25, 8, 0.58);
  transform-style: preserve-3d;
}

.coin-flip-coin.is-flipping {
  will-change: transform;
}

.coin-face {
  position: absolute;
  inset: 12px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(65, 33, 12, 0.36);
  border-radius: 50%;
  color: #281306;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 3rem;
  font-weight: 900;
  text-shadow: 0 1px 0 rgba(255, 244, 177, 0.75);
  backface-visibility: hidden;
}

.coin-face-high {
  transform: rotateY(180deg);
}

.coin-flip-coin.is-high {
  transform: rotateY(180deg);
}

.coin-flip-label {
  margin: 0;
  padding: 7px 14px;
  border: 1px solid rgba(252, 226, 175, 0.28);
  border-radius: 999px;
  background: rgba(8, 10, 14, 0.68);
  color: rgba(255, 247, 224, 0.92);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.32);
  font-size: 0.72rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
}

.splash-mode {
  position: fixed;
  left: 50%;
  bottom: max(12px, calc(env(safe-area-inset-bottom) + 10px));
  z-index: 11;
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  padding: 3px;
  border: 1px solid rgba(252, 226, 175, 0.2);
  border-radius: 999px;
  background: rgba(8, 10, 14, 0.54);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
  transform: translateX(-50%);
  backdrop-filter: blur(8px);
}

.mode-button {
  min-height: 28px;
  padding: 5px 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 247, 224, 0.58);
  font: inherit;
  font-size: 0.58rem;
  font-weight: 950;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
}

.mode-button.is-active {
  border-color: rgba(252, 226, 175, 0.42);
  background: rgba(248, 221, 165, 0.84);
  color: #19110c;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.24);
}

.mode-button:focus-visible {
  outline: 2px solid #dfffd9;
  outline-offset: 3px;
}

.splash-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  width: min(78vw, 420px);
  margin-top: 0;
  flex-wrap: wrap;
}

.battle-pill,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 9px 20px;
  border: 1px solid rgba(252, 226, 175, 0.58);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(248, 221, 165, 0.95), rgba(188, 130, 72, 0.95));
  color: #19110c;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.38);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}

.splash-actions #startButton {
  width: 100%;
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: rgba(255, 247, 224, 0.92);
  font-size: clamp(1.02rem, 2.4vw, 1.38rem);
  letter-spacing: 0.12em;
  text-shadow:
    0 2px 12px rgba(0, 0, 0, 0.82),
    0 0 18px rgba(255, 239, 184, 0.22);
  box-shadow: none;
}

.splash-links-label {
  position: fixed;
  left: 50%;
  bottom: max(98px, calc(env(safe-area-inset-bottom) + 94px));
  z-index: 11;
  margin: 0;
  color: rgba(255, 247, 224, 0.72);
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transform: translateX(-50%);
  white-space: nowrap;
}

.splash-links {
  position: fixed;
  left: 50%;
  bottom: max(62px, calc(env(safe-area-inset-bottom) + 58px));
  z-index: 11;
  display: flex;
  gap: 12px;
  justify-content: center;
  transform: translateX(-50%);
}

.splash-links a {
  padding: 7px 11px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  background: rgba(8, 10, 14, 0.56);
  color: rgba(255, 247, 224, 0.8);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
  font-size: 0.62rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-decoration: none;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
}

.splash-links a:focus-visible {
  outline: 2px solid #dfffd9;
  outline-offset: 3px;
}

.battle-pill-secondary,
.icon-button {
  border-color: rgba(174, 238, 255, 0.34);
  background: rgba(17, 20, 29, 0.76);
  color: rgba(226, 249, 255, 0.92);
}

.battle-pill:focus-visible,
.icon-button:focus-visible {
  outline: 2px solid #dfffd9;
  outline-offset: 3px;
}

.battle-pill:disabled,
.icon-button:disabled {
  cursor: default;
  opacity: 0.56;
}

.battle-hud {
  position: fixed;
  left: 0;
  right: 0;
  bottom: max(14px, calc(env(safe-area-inset-bottom) + 12px));
  z-index: 8;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: min(94vw, 760px);
  margin-inline: auto;
  padding: 8px 9px 8px 15px;
  border: 1px solid rgba(255, 238, 194, 0.24);
  border-radius: 999px;
  background: rgba(8, 10, 14, 0.76);
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.46);
  color: var(--ink);
  backdrop-filter: blur(10px);
}

.battle-hud.is-coin-flip-hud {
  left: 50%;
  right: auto;
  top: 50%;
  bottom: auto;
  display: block;
  width: auto;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  transform: translate(-50%, -50%);
  backdrop-filter: none;
}

.battle-hud.is-coin-flip-hud .battle-status,
.battle-hud.is-coin-flip-hud #resetOrdersButton,
.battle-hud.is-coin-flip-hud #musicToggle {
  display: none;
}

.battle-hud.is-coin-flip-hud .battle-actions {
  display: block;
}

.battle-status {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.battle-status strong {
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 950;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.battle-status span {
  min-width: 0;
  overflow: hidden;
  color: rgba(255, 247, 224, 0.78);
  font-size: 0.86rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.battle-hud .battle-pill,
.battle-hud .icon-button {
  min-height: 40px;
  margin: 0;
  padding-inline: 17px;
}

.battle-hud .battle-pill.is-coin-flip-action {
  position: static;
  z-index: 13;
  min-width: 172px;
  min-height: 62px;
  padding-inline: 28px;
  border-color: rgba(255, 238, 194, 0.72);
  background:
    linear-gradient(180deg, rgba(255, 239, 188, 0.98), rgba(204, 148, 72, 0.94));
  color: #1e1208;
  box-shadow:
    0 0 0 4px rgba(8, 10, 14, 0.22),
    0 18px 48px rgba(0, 0, 0, 0.48),
    inset 0 1px 0 rgba(255, 255, 255, 0.78);
  font-size: 0.95rem;
}

.music-toggle {
  min-width: 94px;
  border-color: rgba(174, 238, 255, 0.34);
}

.music-toggle.is-muted {
  border-color: rgba(255, 146, 119, 0.34);
  color: rgba(255, 202, 189, 0.84);
}

.end-screen {
  position: fixed;
  inset: 0;
  z-index: 12;
  display: grid;
  place-items: start center;
  padding: max(18px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  overflow-y: auto;
  overscroll-behavior: contain;
  background:
    radial-gradient(circle at 50% 30%, rgba(244, 211, 150, 0.12), transparent 18rem),
    linear-gradient(180deg, rgba(6, 7, 10, 0.42), rgba(6, 7, 10, 0.82));
  backdrop-filter: blur(7px);
  -webkit-overflow-scrolling: touch;
}

.end-panel {
  display: grid;
  justify-items: center;
  width: min(94vw, 620px);
  min-height: min-content;
  margin-block: auto;
  color: var(--ink);
  text-align: center;
}

.result-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  isolation: isolate;
  min-width: clamp(224px, 64vw, 342px);
  min-height: 64px;
  padding: 13px 34px 17px;
  border: 1px solid rgba(249, 223, 166, 0.62);
  border-radius: 999px;
  background: rgba(13, 14, 18, 0.82);
  box-shadow:
    0 0 30px rgba(104, 232, 137, 0.2),
    0 16px 46px rgba(0, 0, 0, 0.52);
  color: transparent;
  font-family: Papyrus, Copperplate, Georgia, "Times New Roman", serif;
  font-size: clamp(1.75rem, 7vw, 3.05rem);
  font-variant-caps: small-caps;
  font-weight: 900;
  line-height: 0.82;
  text-transform: uppercase;
  white-space: nowrap;
  animation: result-summon 720ms cubic-bezier(0.2, 1.05, 0.2, 1) both;
}

.result-pill::before,
.result-pill::after {
  content: attr(data-result);
  position: absolute;
  left: 50%;
  top: 50%;
  letter-spacing: 0;
  line-height: 0.82;
  text-transform: uppercase;
  transform: translate(-50%, -49%) perspective(380px) rotateX(8deg) skewX(-5deg);
  white-space: nowrap;
  pointer-events: none;
}

.result-pill::before {
  z-index: 0;
  color: rgba(19, 11, 12, 0.98);
  -webkit-text-stroke: 7px rgba(15, 8, 11, 0.98);
  text-shadow:
    0 2px 0 rgba(255, 239, 184, 0.28),
    0 0 26px rgba(116, 246, 146, 0.36),
    0 13px 24px rgba(0, 0, 0, 0.84);
}

.result-pill::after {
  z-index: 1;
  color: transparent;
  background:
    linear-gradient(180deg, #ffffdf 0%, #ffd965 27%, #9d4d28 52%, #fff0b6 67%, #52200f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-stroke: 1px rgba(49, 22, 19, 0.98);
  paint-order: stroke fill;
  text-shadow:
    0 1px 0 #fff1b8,
    0 3px 0 #7b351f,
    0 5px 0 rgba(30, 10, 14, 0.98),
    0 10px 19px rgba(0, 0, 0, 0.82),
    0 0 20px rgba(148, 236, 122, 0.46),
    0 0 31px rgba(217, 101, 232, 0.24);
  animation: result-letter-glow 1.9s ease-in-out infinite;
}

.result-pill.is-vanquished {
  border-color: rgba(244, 154, 131, 0.58);
  box-shadow:
    0 0 30px rgba(213, 103, 91, 0.26),
    0 16px 46px rgba(0, 0, 0, 0.52);
}

.result-pill.is-vanquished::before {
  -webkit-text-stroke-color: rgba(23, 6, 9, 0.98);
  text-shadow:
    0 2px 0 rgba(255, 202, 166, 0.22),
    0 0 24px rgba(213, 82, 91, 0.38),
    0 13px 24px rgba(0, 0, 0, 0.84);
}

.result-pill.is-vanquished::after {
  background:
    linear-gradient(180deg, #ffe8c9 0%, #ff956a 26%, #8d242a 54%, #ffd1a5 70%, #31070c 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-stroke-color: rgba(54, 10, 14, 0.98);
  text-shadow:
    0 1px 0 rgba(255, 218, 176, 0.88),
    0 3px 0 #78201f,
    0 5px 0 rgba(25, 5, 8, 0.98),
    0 10px 19px rgba(0, 0, 0, 0.82),
    0 0 20px rgba(226, 87, 82, 0.44),
    0 0 31px rgba(232, 142, 92, 0.24);
}

.result-pill + .end-summary::before {
  content: "";
  position: fixed;
  left: 50%;
  top: 26%;
  width: min(72vw, 360px);
  height: 92px;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 58%, rgba(255, 238, 194, 0.76) 0 2px, transparent 3px),
    radial-gradient(circle at 82% 42%, rgba(122, 255, 180, 0.62) 0 2px, transparent 3px),
    radial-gradient(circle at 36% 18%, rgba(255, 181, 106, 0.66) 0 1.5px, transparent 3px),
    radial-gradient(circle at 64% 82%, rgba(218, 180, 255, 0.58) 0 1.5px, transparent 3px);
  filter: drop-shadow(0 0 8px rgba(255, 238, 194, 0.5));
  transform: translateX(-50%);
  animation: result-sparks 2.8s ease-in-out infinite;
}

.end-summary {
  margin: 16px 0 0;
  color: rgba(255, 247, 224, 0.9);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.02rem, 2.4vw, 1.34rem);
  font-weight: 700;
  line-height: 1.28;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.86);
}

.end-detail {
  margin: 6px 0 0;
  color: rgba(255, 247, 224, 0.68);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.82);
}

.end-report {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  margin-top: 14px;
}

.end-report-summary {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(8, 10, 14, 0.58);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.24);
  text-align: left;
  backdrop-filter: blur(8px);
}

.end-report-summary-player {
  border-color: rgba(116, 246, 207, 0.28);
}

.end-report-summary-enemy {
  border-color: rgba(255, 146, 119, 0.26);
}

.end-report-summary strong {
  color: rgba(255, 247, 224, 0.94);
  font-size: 0.7rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.end-report-summary span {
  color: rgba(255, 247, 224, 0.72);
  font-size: 0.74rem;
  font-weight: 800;
  line-height: 1.24;
}

.end-report-table {
  grid-column: 1 / -1;
  display: grid;
  min-height: 0;
  max-height: min(34dvh, 286px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(8, 10, 14, 0.5);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(8px);
  -webkit-overflow-scrolling: touch;
}

.end-report-row {
  display: grid;
  grid-template-columns: 0.72fr 1.22fr 0.56fr 0.72fr 0.78fr;
  gap: 8px;
  align-items: center;
  min-height: 30px;
  padding: 6px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 247, 224, 0.78);
  font-size: 0.68rem;
  font-weight: 800;
  text-align: left;
}

.end-report-row:first-child {
  border-top: 0;
}

.end-report-head {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(15, 17, 22, 0.92);
  color: rgba(255, 247, 224, 0.56);
  font-size: 0.58rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.end-report-row.is-lost {
  color: rgba(255, 202, 189, 0.82);
}

.end-cross-promo {
  display: grid;
  justify-items: center;
  gap: 8px;
  width: 100%;
  margin-top: 14px;
}

.end-cross-promo p {
  margin: 0;
  color: rgba(255, 247, 224, 0.68);
  font-size: 0.64rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.end-links {
  display: flex;
  justify-content: center;
  gap: 8px;
  width: 100%;
  flex-wrap: wrap;
}

.end-links a {
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(8, 10, 14, 0.52);
  color: rgba(255, 247, 224, 0.82);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22);
  font-size: 0.62rem;
  font-weight: 950;
  letter-spacing: 0.06em;
  text-decoration: none;
  text-transform: uppercase;
}

.end-links a:focus-visible {
  outline: 2px solid #dfffd9;
  outline-offset: 3px;
}

.end-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.86fr);
  gap: 8px;
  width: min(82vw, 350px);
  margin-top: 18px;
}

.end-actions .battle-pill {
  width: 100%;
  min-width: 0;
}

@keyframes result-summon {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.92);
    filter: blur(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

@keyframes result-sparks {
  0%,
  100% {
    opacity: 0.48;
    transform: translateX(-50%) translateY(8px) scale(0.98);
  }

  50% {
    opacity: 0.96;
    transform: translateX(-50%) translateY(-8px) scale(1.02);
  }
}

@keyframes result-letter-glow {
  0%,
  100% {
    filter: drop-shadow(0 0 2px rgba(255, 238, 194, 0.18));
  }

  50% {
    filter: drop-shadow(0 0 10px rgba(255, 238, 194, 0.64));
  }
}

@media (max-width: 680px) {
  #battlefield {
    width: 100vw;
    height: 100dvh;
    border: 0;
  }

  .battle-hud {
    grid-template-columns: 1fr;
    border-radius: 18px;
    width: min(94vw, 420px);
    padding: 10px;
  }

  .battle-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .battle-actions > * {
    width: 100%;
    padding-inline: 10px;
    font-size: 0.7rem;
  }

  .end-report {
    grid-template-columns: 1fr;
  }

  .end-report-table {
    grid-column: auto;
    max-height: 30vh;
  }

  .end-report-row {
    grid-template-columns: 0.62fr 1fr 0.48fr 0.64fr 0.68fr;
    gap: 6px;
    padding: 6px 8px;
    font-size: 0.62rem;
  }

  .end-actions {
    grid-template-columns: 1fr;
    width: min(82vw, 260px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .result-pill,
  .result-pill::after,
  .result-pill + .end-summary::before {
    animation: none;
  }
}
