.battlefield {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background:
    radial-gradient(circle at 16% 10%, rgba(85, 161, 205, 0.15), transparent 24rem),
    radial-gradient(circle at 84% 92%, rgba(216, 86, 76, 0.13), transparent 24rem),
    linear-gradient(180deg, rgba(25, 28, 27, 0.96), rgba(17, 18, 17, 0.98));
  border-color: rgba(245, 223, 170, 0.18);
}

@media (min-width: 1521px) {
  .layout {
    align-items: stretch;
  }

  .battlefield {
    height: min(1040px, calc(100vh - 124px));
    max-height: none;
  }

  .side-column {
    height: min(1040px, calc(100vh - 124px));
    max-height: none;
  }
}

.battlefield .battle-header {
  padding: 11px 14px;
  border-bottom-color: rgba(245, 223, 170, 0.1);
  background: rgba(11, 13, 13, 0.28);
}

.battlefield .battle-header p {
  display: none;
}

.war-map {
  --battle-card-width: clamp(202px, 12vw, 246px);
  --battle-card-gap: 16px;
  display: grid;
  flex: 1;
  grid-template-rows: minmax(max-content, 1fr) minmax(42px, auto) minmax(max-content, 1fr);
  gap: 10px;
  min-height: auto;
  padding: 14px;
  background:
    radial-gradient(circle at 50% 48%, rgba(244, 207, 120, 0.12), transparent 17rem),
    linear-gradient(90deg, rgba(245, 223, 170, 0.028) 1px, transparent 1px),
    linear-gradient(rgba(245, 223, 170, 0.028) 1px, transparent 1px),
    linear-gradient(180deg, rgba(35, 58, 69, 0.28) 0%, rgba(18, 20, 20, 0.94) 48%, rgba(74, 27, 29, 0.28) 100%);
  background-size: auto, 32px 32px, 32px 32px, auto;
}

.army-block {
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 10px;
  border: 1px solid rgba(245, 223, 170, 0.09);
  border-radius: 8px;
  background: rgba(8, 11, 12, 0.28);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

.player-block {
  background:
    linear-gradient(90deg, rgba(59, 137, 183, 0.15), transparent 44%),
    rgba(8, 11, 12, 0.3);
}

.enemy-block {
  background:
    linear-gradient(90deg, rgba(183, 65, 58, 0.16), transparent 44%),
    rgba(11, 8, 8, 0.3);
}

.army-title {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, var(--battle-card-width)));
  justify-content: center;
  gap: var(--battle-card-gap);
  align-items: center;
  min-height: 32px;
  padding: 0;
  color: #f6edd5;
}

.player-block .army-title {
  background: transparent;
}

.enemy-block .army-title {
  background: transparent;
}

.army-title > span {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
}

.army-title span {
  display: inline-grid;
  min-width: 74px;
  min-height: 26px;
  place-items: center;
  border: 1px solid rgba(245, 223, 170, 0.15);
  border-radius: 999px;
  background: rgba(15, 16, 15, 0.56);
  font-size: 14px;
  font-weight: 900;
}

.player-block .army-title > span {
  color: #bfe9ff;
  border-color: rgba(93, 182, 233, 0.3);
  background: rgba(35, 94, 128, 0.3);
}

.enemy-block .army-title > span {
  color: #ffd2c7;
  border-color: rgba(235, 113, 100, 0.32);
  background: rgba(112, 38, 34, 0.3);
}

.army-title strong {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  width: 100%;
}

.army-title .troop-summary-text {
  min-width: 142px;
}

.position-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, var(--battle-card-width)));
  justify-content: center;
  gap: var(--battle-card-gap);
  padding: 0;
  color: rgba(239, 232, 212, 0.72);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.position-row span {
  display: grid;
  min-height: 21px;
  place-items: center;
  border-bottom: 1px solid rgba(245, 223, 170, 0.16);
  background: rgba(255, 255, 255, 0.025);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.64);
}

.line {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, var(--battle-card-width)));
  justify-content: center;
  gap: var(--battle-card-gap);
  align-items: stretch;
}

.unit-card {
  display: grid;
  position: relative;
  overflow: hidden;
  grid-template-rows: auto auto 1fr;
  min-height: 0;
  padding: 0;
  isolation: isolate;
  border: 1px solid rgba(245, 223, 170, 0.18);
  background:
    linear-gradient(180deg, rgba(30, 31, 28, 0.84), rgba(10, 11, 10, 0.92)),
    #0d100f;
  border-radius: 8px;
  box-shadow:
    0 12px 26px rgba(0, 0, 0, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.055);
  cursor: pointer;
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease;
}

.unit-card::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 36%, rgba(0, 0, 0, 0.28) 100%),
    radial-gradient(circle at 74% 22%, rgba(255, 226, 150, 0.12), transparent 34%);
  pointer-events: none;
  content: "";
}

.unit-card:hover {
  transform: translateY(-2px);
  border-color: rgba(245, 223, 170, 0.34);
  box-shadow:
    0 16px 32px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

.unit-content {
  position: relative;
  z-index: 1;
}

.unit-card.camp {
  border-color: rgba(198, 121, 210, 0.38);
  box-shadow:
    0 12px 26px rgba(0, 0, 0, 0.22),
    0 0 18px rgba(188, 60, 165, 0.13),
    inset 0 1px 0 rgba(255, 255, 255, 0.055);
}

.unit-card.front {
  border-color: rgba(104, 188, 150, 0.34);
}

.unit-card.fallen {
  filter: grayscale(0.85);
  opacity: 0.62;
}

.unit-portrait {
  position: relative;
  aspect-ratio: 1 / 1.16;
  height: auto;
  min-height: 0;
  overflow: hidden;
  border-bottom: 1px solid rgba(245, 223, 170, 0.12);
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 237, 190, 0.1), transparent 46%),
    #121614;
}

.unit-portrait::before,
.unit-portrait::after {
  position: absolute;
  inset: 0;
  pointer-events: none;
  content: "";
}

.unit-portrait::before {
  z-index: 0;
  background:
    var(--unit-portrait, linear-gradient(135deg, rgba(244, 236, 216, 0.08), transparent 45%));
  background-position: center 18%;
  background-repeat: no-repeat;
  background-size: cover;
  transform: scale(1.02);
  transform-origin: center 18%;
  filter: saturate(1.08) contrast(1.03);
}

.unit-portrait::after {
  z-index: 1;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), transparent 18%),
    linear-gradient(180deg, rgba(0, 0, 0, 0) 0 50%, rgba(0, 0, 0, 0.18) 75%, rgba(0, 0, 0, 0.48) 100%),
    radial-gradient(circle at 52% 22%, transparent 0 50%, rgba(0, 0, 0, 0.18) 100%);
  background-position: center;
  background-repeat: no-repeat;
  background-size: auto;
}

.unit-stars {
  position: absolute;
  top: 6px;
  left: 8px;
  z-index: 3;
  color: #ffe08a;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  text-shadow:
    0 1px 1px #301507,
    0 0 5px rgba(245, 184, 68, 0.72),
    0 0 8px rgba(0, 0, 0, 0.72);
}

.unit-nameplate {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  justify-self: stretch;
  gap: 4px;
  align-items: center;
  width: 100%;
  min-height: 24px;
  padding: 3px 6px;
  border-block: 0;
  border-inline: 0;
  border-radius: 0;
  background:
    linear-gradient(90deg, rgba(14, 16, 15, 0.84), rgba(20, 22, 20, 0.64)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), transparent 58%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.045);
}

.unit-card.player .unit-nameplate {
  background:
    linear-gradient(90deg, rgba(13, 73, 109, 0.7), rgba(14, 36, 47, 0.5)),
    linear-gradient(180deg, rgba(172, 222, 255, 0.13), transparent 58%);
}

.unit-card.enemy .unit-nameplate {
  background:
    linear-gradient(90deg, rgba(103, 31, 28, 0.66), rgba(47, 21, 18, 0.48)),
    linear-gradient(180deg, rgba(255, 194, 160, 0.12), transparent 58%);
}

.unit-faction {
  display: grid;
  width: 19px;
  height: 19px;
  place-items: center;
  border: 1px solid rgba(245, 223, 170, 0.22);
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.22);
  color: #ffe7b4;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
}

.unit-range {
  display: inline-grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border: 1px solid rgba(245, 223, 170, 0.16);
  border-radius: 50%;
  color: #fff2d2;
  font-size: 10px;
  font-weight: 900;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.88);
  white-space: nowrap;
}

.unit-arm {
  color: #fff2d2;
  font-size: 10px;
  font-weight: 900;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.88);
  white-space: nowrap;
}

.unit-troops {
  align-self: stretch;
  padding: 4px 6px 6px;
  background:
    linear-gradient(180deg, rgba(22, 24, 22, 0.82), rgba(8, 9, 8, 0.94)),
    radial-gradient(circle at 50% 0, rgba(245, 223, 170, 0.07), transparent 56%);
}

.role-tag {
  padding: 3px 7px;
  border: 1px solid rgba(245, 223, 170, 0.2);
  border-radius: 999px;
  color: var(--paper);
  font-size: 11px;
  white-space: nowrap;
}

.troop-bar {
  position: relative;
  height: 6px;
  margin-top: 4px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.64);
  --wounded-separator: rgba(255, 255, 255, 0.82);
  --wounded-separator-core: rgba(255, 255, 255, 0.96);
  --wounded-separator-glow: rgba(255, 255, 255, 0.42);
  --wounded-separator-aura: rgba(255, 255, 255, 0.18);
}

.troop-fill,
.wounded-fill {
  position: absolute;
  inset-block: 0;
  display: block;
  height: 100%;
  transition: width 0.2s ease, left 0.2s ease;
}

.troop-fill {
  left: 0;
  width: var(--active-pct, 100%);
  background: linear-gradient(90deg, var(--red), var(--gold));
}

.wounded-fill {
  left: var(--active-pct, 100%);
  width: var(--wounded-pct, 0%);
  background:
    linear-gradient(90deg, rgba(40, 134, 198, 0.88), rgba(124, 198, 232, 0.9)),
    rgba(52, 146, 204, 0.8);
  box-shadow: inset 0 0 8px rgba(190, 232, 255, 0.28);
}

.has-wounded-separator .wounded-fill::before {
  content: "";
  position: absolute;
  inset-block: -1px;
  left: -1px;
  z-index: 2;
  width: 3px;
  border-radius: 999px;
  background:
    linear-gradient(180deg, transparent 0%, var(--wounded-separator) 18%, var(--wounded-separator-core) 50%, var(--wounded-separator) 82%, transparent 100%),
    linear-gradient(90deg, transparent 0%, var(--wounded-separator-core) 52%, transparent 100%);
  box-shadow:
    0 0 6px var(--wounded-separator-glow),
    0 0 14px var(--wounded-separator-glow),
    2px 0 12px var(--wounded-separator-aura),
    -2px 0 10px var(--wounded-separator-aura);
}

.has-wounded-separator .wounded-fill::after {
  content: "";
  position: absolute;
  inset-block: 0;
  left: -10px;
  z-index: 1;
  width: 24px;
  background:
    radial-gradient(ellipse at 45% 50%, var(--wounded-separator-glow) 0%, var(--wounded-separator-aura) 36%, transparent 72%),
    linear-gradient(90deg, transparent 0%, var(--wounded-separator-aura) 45%, transparent 100%);
  opacity: 0.92;
  pointer-events: none;
}

.unit-card.player .troop-fill,
.player-block .team-troop-bar .troop-fill {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.28), transparent 48%),
    linear-gradient(90deg, #2f86c4, #5dc7f2);
}

.unit-card.player .wounded-fill,
.player-block .team-troop-bar .wounded-fill {
  background: linear-gradient(90deg, rgba(78, 173, 224, 0.88), rgba(155, 219, 248, 0.94));
  box-shadow: inset 0 0 8px rgba(194, 237, 255, 0.3);
}

.unit-card.player .troop-bar,
.player-block .team-troop-bar {
  --wounded-separator: #65f1ff;
  --wounded-separator-core: #f1feff;
  --wounded-separator-glow: rgba(93, 235, 255, 0.96);
  --wounded-separator-aura: rgba(54, 203, 255, 0.42);
}

.unit-card.enemy .troop-fill,
.enemy-block .team-troop-bar .troop-fill {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.22), transparent 48%),
    linear-gradient(90deg, #8b2a29 0%, #c64941 100%);
  box-shadow: inset 0 1px 0 rgba(255, 224, 199, 0.16);
}

.unit-card.enemy .wounded-fill,
.enemy-block .team-troop-bar .wounded-fill {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.34), transparent 48%),
    linear-gradient(90deg, rgba(234, 111, 98, 0.96), rgba(255, 187, 171, 0.98));
  box-shadow:
    inset 0 0 8px rgba(255, 219, 200, 0.34);
}

.unit-card.enemy .troop-bar,
.enemy-block .team-troop-bar {
  --wounded-separator: #ff4b3f;
  --wounded-separator-core: #fff5ef;
  --wounded-separator-glow: rgba(255, 70, 56, 0.98);
  --wounded-separator-aura: rgba(255, 92, 72, 0.5);
}

.unit-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 5px 7px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.unit-stats span {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
}

.skill-list {
  display: grid;
  gap: 3px;
  margin-top: 4px;
}

.unit-card .skill-list {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.unit-portrait .skill-list {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 3;
  grid-template-columns: 1fr;
  gap: 4px;
  margin: 0;
  padding: 10px 8px 8px;
  background:
    linear-gradient(180deg, transparent 0%, rgba(8, 9, 8, 0.2) 32%, rgba(8, 9, 8, 0.52) 100%),
    linear-gradient(90deg, rgba(255, 224, 156, 0.06), transparent 22%, transparent 78%, rgba(255, 224, 156, 0.05));
}

.skill-chip {
  overflow: hidden;
  padding: 1px 5px;
  border: 1px solid rgba(215, 170, 71, 0.16);
  border-radius: 6px;
  background: rgba(20, 19, 15, 0.34);
  color: #e8d5a8;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.unit-portrait .skill-chip {
  min-height: 22px;
  padding: 4px 8px;
  border-color: rgba(255, 226, 170, 0.18);
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(38, 35, 28, 0.48), rgba(8, 9, 8, 0.36));
  -webkit-backdrop-filter: blur(1.5px);
  backdrop-filter: blur(1.5px);
  color: #ffe4a8;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.15;
  box-shadow:
    inset 0 1px 0 rgba(255, 243, 206, 0.07),
    0 1px 4px rgba(0, 0, 0, 0.14);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.72);
}

.unit-card.enemy .unit-portrait .skill-chip {
  border-color: rgba(255, 190, 160, 0.18);
  background:
    linear-gradient(180deg, rgba(71, 30, 23, 0.42), rgba(16, 9, 8, 0.34));
  color: #ffd2b7;
}

.skill-chip:hover,
.text-link:hover {
  color: #fff2c9;
}
