:root {
  color-scheme: dark;
  font-family: Inter, "Noto Sans JP", system-ui, sans-serif;
  --tile-size: 48px;
  --panel: #111922;
  --line: #293642;
  --text: #edf6f2;
  --muted: #91a89e;
  --accent: #8ce3ad;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #091015;
  color: var(--text);
}

body {
  display: grid;
  grid-template-rows: 68px 1fr 34px;
}

.battle-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: clamp(240px, 20vw, 310px) minmax(280px, 1fr) clamp(240px, 20vw, 310px);
}

body.is-alpha-perspective .roster--left {
  grid-column: 3;
  grid-row: 1;
  border-right: 0;
  border-left: 1px solid var(--line);
}

body.is-alpha-perspective .viewport {
  grid-column: 2;
  grid-row: 1;
}

body.is-alpha-perspective .roster--right {
  grid-column: 1;
  grid-row: 1;
  border-right: 1px solid var(--line);
  border-left: 0;
}

body.is-alpha-perspective .roster--left .roster__heading {
  gap: 7px;
  padding: 7px 10px;
}

body.is-alpha-perspective .roster--left .team-mark {
  height: 28px;
  background: #57c9e8;
  box-shadow: 0 0 16px #57c9e866;
}

body.is-alpha-perspective .roster--right .team-mark {
  background: #e76e91;
  box-shadow: 0 0 16px #e76e9166;
}

body.is-alpha-perspective .roster--left .roster__pairs {
  gap: 5px;
  padding: 6px;
}

body.is-alpha-perspective .roster--left .pair-card h2 {
  padding: 3px 7px;
  font-size: 8px;
}

.toolbar,
.statusbar {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-color: var(--line);
  background: color-mix(in srgb, var(--panel) 94%, transparent);
}

.toolbar {
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
}

.toolbar h1 {
  margin: 0;
  color: var(--accent);
  font-size: 15px;
  letter-spacing: 0.16em;
}

.toolbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

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

.turn-state {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  column-gap: 10px;
  min-width: 190px;
  margin-right: 10px;
  padding-right: 16px;
  border-right: 1px solid var(--line);
}

.turn-state span {
  grid-row: 1 / 3;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .08em;
}

.turn-state strong,
.turn-state small {
  display: block;
}

.turn-state strong {
  font-size: 11px;
}

.turn-state small {
  color: var(--muted);
  font-size: 9px;
}

.is-processing .turn-state strong {
  color: #f1c66f;
}

button,
output {
  min-width: 40px;
  height: 34px;
  border: 1px solid #344653;
  border-radius: 7px;
  background: #18242d;
  color: var(--text);
}

button {
  padding: 0 12px;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

button:disabled {
  cursor: not-allowed;
  opacity: .42;
}

.confirm-actions {
  min-width: 88px;
  border-color: #8ce3ad;
  background: linear-gradient(180deg, #27533b, #173426);
  color: #dffff0;
  font-size: 12px;
  font-weight: 900;
}

.confirm-actions:not(:disabled):hover {
  border-color: #dffff0;
  background: linear-gradient(180deg, #34704f, #1d4731);
  box-shadow: 0 0 9px #8ce3ad55;
}

.navigation-link {
  display: grid;
  place-items: center;
  height: 34px;
  padding: 0 12px;
  border: 1px solid #6e613e;
  border-radius: 7px;
  background: #3d341f;
  color: #f5d993;
  font-size: 11px;
  text-decoration: none;
}

.navigation-link:hover {
  border-color: #f1c66f;
}

.local-battle-button {
  min-width: 94px;
  border-color: #5d91b5;
  background: linear-gradient(180deg, #244d68, #162f42);
  color: #d8f2ff;
  font-size: 11px;
  font-weight: 800;
}

.local-battle-button.is-connected {
  border-color: #8ce3ad;
  background: linear-gradient(180deg, #27533b, #173426);
  color: #dffff0;
}

.random-match-button {
  min-width: 166px;
  border-color: #5d91b5;
  background: linear-gradient(180deg, #244d68, #162f42);
  color: #d8f2ff;
  font-size: 11px;
  font-weight: 800;
}

.random-match-button.is-matching {
  border-color: #e5bd62;
  background: linear-gradient(180deg, #5a4821, #342a18);
  color: #ffe6a9;
}

.matchmaking-status {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 126px;
  color: #ffe6a9;
  font-size: 11px;
  white-space: nowrap;
}

.matchmaking-status[hidden] {
  display: none;
}

.matchmaking-status span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #e5bd62;
  box-shadow: 0 0 10px #e5bd62cc;
  animation: matchmaking-pulse 1.1s ease-in-out infinite alternate;
}

.matchmaking-status.is-matched {
  color: #bfffd7;
}

.matchmaking-status.is-matched span {
  background: #8ce3ad;
  box-shadow: 0 0 10px #8ce3adcc;
  animation: none;
}

@keyframes matchmaking-pulse {
  from { opacity: .4; }
  to { opacity: 1; }
}

.battle-result {
  position: fixed;
  inset: 0;
  z-index: 220;
  display: grid;
  place-items: center;
  background: #02080dd9;
  backdrop-filter: blur(5px);
}

.battle-result[hidden] {
  display: none;
}

.battle-result__panel {
  display: grid;
  justify-items: center;
  width: min(560px, calc(100vw - 40px));
  padding: 42px 28px;
  border: 1px solid #79dca1;
  border-radius: 16px;
  background: radial-gradient(circle at 50% 0%, #275844 0%, #101c24 60%);
  box-shadow: 0 24px 90px #000d, 0 0 32px #62d69a45;
  text-align: center;
}

.battle-result.is-defeat .battle-result__panel {
  border-color: #e76e79;
  background: radial-gradient(circle at 50% 0%, #612d35 0%, #1f151c 60%);
  box-shadow: 0 24px 90px #000d, 0 0 32px #e76e7945;
}

.battle-result__panel small {
  color: #9eb6c3;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .2em;
}

.battle-result__panel strong {
  margin-top: 10px;
  color: #bfffd7;
  font-size: clamp(44px, 8vw, 76px);
  line-height: 1;
  letter-spacing: .12em;
  text-shadow: 0 0 28px #62d69a88;
}

.battle-result.is-defeat .battle-result__panel strong {
  color: #ffb9c0;
  text-shadow: 0 0 28px #e76e7988;
}

.battle-result__panel p {
  margin: 18px 0 0;
  color: #edf6f2;
  font-size: 15px;
  font-weight: 700;
}

.battle-result__panel span {
  margin-top: 14px;
  color: #91a89e;
  font-size: 11px;
}

output {
  display: grid;
  place-items: center;
  width: 62px;
  font-size: 12px;
}

.local-battle-modal {
  position: fixed;
  inset: 0;
  z-index: 160;
  display: grid;
  place-items: center;
}

.local-battle-modal[hidden] {
  display: none;
}

.local-battle-modal__backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  background: #02070bd1;
}

.local-battle-modal__dialog {
  position: relative;
  width: min(520px, calc(100vw - 32px));
  padding: 18px;
  border: 1px solid #506879;
  border-radius: 12px;
  background: #111c25;
  box-shadow: 0 22px 70px #000c;
}

.local-battle-modal__dialog > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.local-battle-modal__dialog h2,
.local-battle-modal__dialog p {
  margin: 0;
}

.local-battle-modal__dialog header small,
.local-battle-modal__dialog p,
.local-battle-modal__setup > span {
  color: var(--muted);
  font-size: 11px;
}

.local-battle-modal__dialog h2 {
  margin-top: 3px;
  color: #bfeaff;
  font-size: 19px;
}

.local-battle-modal__dialog > p {
  margin-top: 14px;
  line-height: 1.7;
}

.local-battle-modal__dialog > p strong {
  color: #dff6ff;
}

.local-battle-modal__setup {
  display: grid;
  grid-template-columns: auto auto minmax(120px, 1fr) auto;
  align-items: end;
  gap: 9px;
  margin-top: 18px;
}

.local-battle-modal__setup[hidden] {
  display: none;
}

.local-battle-modal__setup label {
  display: grid;
  gap: 4px;
}

.local-battle-modal__setup input {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid #415767;
  border-radius: 7px;
  background: #091117;
  color: #f2fbff;
  font: 800 14px/1 monospace;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.local-battle-modal__primary {
  border-color: #8ce3ad;
  background: #1c4832;
  color: #dffff0;
  font-weight: 800;
}

.local-battle-modal__connected {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 3px 12px;
  margin-top: 18px;
  padding: 13px 15px;
  border: 1px solid #42687e;
  border-radius: 9px;
  background: #0c171f;
}

.local-battle-modal__connected[hidden] {
  display: none;
}

.local-battle-modal__connected > span {
  grid-row: 1 / 3;
  color: #7f9bab;
  font-size: 10px;
}

.local-battle-modal__connected strong {
  color: #c7f0ff;
  font: 900 22px/1 monospace;
  letter-spacing: .16em;
}

.local-battle-modal__connected small {
  color: #a9c0cd;
}

.local-battle-modal__formation-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 10px;
}

.local-battle-modal__formation-actions[hidden] {
  display: none;
}

.local-battle-modal__status {
  display: block;
  width: 100%;
  min-height: 0;
  height: auto;
  margin-top: 12px;
  padding: 8px 10px;
  border-color: #344653;
  color: #bad0dc;
  font-size: 11px;
  text-align: left;
}

.local-battle-modal__status.is-error {
  border-color: #a7505d;
  color: #ffb8c0;
}

@media (max-width: 900px) {
  .local-battle-modal__setup {
    grid-template-columns: 1fr auto;
  }

  .local-battle-modal__setup > span {
    display: none;
  }
}

.viewport {
  position: relative;
  overflow: hidden;
  cursor: grab;
  background:
    radial-gradient(circle at 50% 50%, #17232a 0, #091015 75%);
  touch-action: none;
  user-select: none;
}

.destination-action-menu {
  position: absolute;
  z-index: 20;
  width: 284px;
  height: 260px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.destination-action-menu[hidden] {
  display: none;
}

.destination-action-menu__center {
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  place-items: center;
  width: 44px;
  min-width: 44px;
  height: 44px;
  padding: 0;
  transform: translate(-50%, -50%);
  border: 2px solid #f1c66f;
  border-radius: 50%;
  background: #0c171ee8;
  color: #f6df9f;
  font-size: 9px;
  font-weight: 800;
  box-shadow: 0 0 0 5px #0a1118b8, 0 5px 18px #000c;
  pointer-events: auto;
}

.destination-action-menu__center:hover,
.destination-action-menu__center:focus-visible {
  border-color: #fff0b8;
  background: #263139f2;
  color: #fff8dc;
  transform: translate(-50%, -50%) scale(1.08);
}

.destination-action-menu__center.is-sub {
  border-color: #caa2ff;
  color: #efdfff;
}

.destination-action-menu__center.is-sub:hover,
.destination-action-menu__center.is-sub:focus-visible {
  border-color: #f1e3ff;
  color: #f8efff;
}

.destination-action-button {
  --action-x: 0px;
  --action-y: 0px;
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  place-items: center;
  width: 56px;
  min-width: 56px;
  height: 56px;
  padding: 4px;
  transform: translate(calc(-50% + var(--action-x)), calc(-50% + var(--action-y)));
  border: 2px solid #85d8ef;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, #28495a, #10232e 70%);
  color: #eafaff;
  font-size: 9px;
  font-weight: 900;
  line-height: 1.05;
  text-align: center;
  overflow-wrap: anywhere;
  box-shadow: 0 5px 13px #000b, inset 0 0 9px #7addf033;
  pointer-events: auto;
}

.destination-action-button:hover {
  border-color: #e8fbff;
  background: radial-gradient(circle at 35% 28%, #3c687c, #17313e 72%);
  transform: translate(calc(-50% + var(--action-x)), calc(-50% + var(--action-y))) scale(1.08);
}

.destination-action-button.is-placeholder {
  border-style: dashed;
  color: #8aa4ae;
  filter: saturate(.55);
}

.destination-action-button--chip2 {
  border-color: #caa2ff;
  background: radial-gradient(circle at 35% 28%, #574574, #281f3a 72%);
  box-shadow: 0 5px 13px #000b, inset 0 0 9px #caa2ff33;
}

.destination-action-button--chip2:hover {
  border-color: #f1e3ff;
  background: radial-gradient(circle at 35% 28%, #745b99, #392a50 72%);
}

.destination-action-button--na {
  --action-y: -112px;
  border-color: #f1c66f;
  background: radial-gradient(circle at 35% 28%, #66512b, #2e2514 72%);
  color: #fff0bb;
  font-size: 13px;
}

.destination-action-button--separate {
  --action-y: 112px;
  border-color: #caa2ff;
  background: radial-gradient(circle at 35% 28%, #554073, #281d39 72%);
  color: #f1e3ff;
  font-size: 11px;
}

.destination-action-button--left-top {
  --action-x: -70px;
  --action-y: -68px;
}

.destination-action-button--left-middle {
  --action-x: -112px;
}

.destination-action-button--left-bottom {
  --action-x: -70px;
  --action-y: 68px;
}

.destination-action-button--right-top {
  --action-x: 70px;
  --action-y: -68px;
}

.destination-action-button--right-middle {
  --action-x: 112px;
}

.destination-action-button--right-bottom {
  --action-x: 70px;
  --action-y: 68px;
}

.roster {
  position: relative;
  z-index: 4;
  min-width: 0;
  overflow: auto;
  scrollbar-width: thin;
  background: #0d151b;
}

.roster--left {
  border-right: 1px solid var(--line);
}

.roster--right {
  border-left: 1px solid var(--line);
}

.roster--right .roster__heading {
  gap: 7px;
  padding: 7px 10px;
}

.roster--right .team-mark {
  height: 28px;
}

.roster__heading {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #101a21f2;
  backdrop-filter: blur(8px);
}

.roster__heading strong,
.roster__heading small {
  display: block;
}

.roster__heading strong {
  font-size: 13px;
  letter-spacing: .12em;
}

.roster__heading small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.team-mark {
  width: 10px;
  height: 34px;
  border-radius: 3px;
}

.team-mark--alpha {
  background: #e76e91;
  box-shadow: 0 0 16px #e76e9166;
}

.team-mark--bravo {
  background: #57c9e8;
  box-shadow: 0 0 16px #57c9e866;
}

.roster__pairs {
  display: grid;
  gap: 9px;
  padding: 10px;
}

.roster--right .roster__pairs {
  gap: 5px;
  padding: 6px;
}

.pair-card {
  overflow: hidden;
  border: 1px solid #263640;
  border-radius: 8px;
  background: #111c23;
}

.pair-card--solo {
  border-color: #476675;
}

.pair-card--solo h2 span {
  color: #77d5ed;
}

.pair-card h2 {
  display: flex;
  justify-content: space-between;
  margin: 0;
  padding: 6px 9px;
  border-bottom: 1px solid #263640;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: .1em;
}

.pair-card h2 small {
  font-weight: 400;
  letter-spacing: 0;
}

.roster--right .pair-card h2 {
  padding: 3px 7px;
  font-size: 8px;
}

.unit-card {
  padding: 8px;
  cursor: pointer;
  transition: background .15s ease, box-shadow .15s ease;
}

.unit-card + .unit-card {
  border-top: 1px solid #213039;
}

.unit-card:hover,
.unit-card.is-selected {
  background: #1b2a32;
  box-shadow: inset 3px 0 var(--accent);
}

.unit-card.has-order:not(.is-selected) {
  background: #14251f;
  box-shadow: inset 3px 0 #4ea474;
}

.unit-card.is-recovering {
  background: #20191b;
  box-shadow: inset 3px 0 #c05867;
}

.unit-card.is-recovering .unit-card__portrait {
  filter: grayscale(1) brightness(.58);
}

.unit-card.is-recovering .unit-card__identity span,
.unit-card.is-recovering .unit-card__identity-row em {
  color: #f18b99;
  font-weight: 800;
}

.unit-card--concealed {
  border: 1px solid #263640;
  border-radius: 8px;
  background: #111c23;
}

.unit-card--enemy-visible {
  border-color: #58d58a;
  background: #12261b;
  box-shadow: inset 3px 0 #58d58a;
}

.unit-card--enemy-hidden {
  border-color: #596167;
  background: #171b1e;
  box-shadow: inset 3px 0 #6c7479;
}

.unit-card--concealed + .unit-card--concealed {
  border-top: 1px solid #263640;
}

.unit-card--concealed .unit-card__top {
  grid-template-columns: 38px minmax(0, 1fr);
}

.unit-card--concealed .unit-card__portrait {
  width: 38px;
  height: 38px;
  border-color: #815064;
}

.unit-card--concealed .unit-card__identity strong {
  font-size: 12px;
}

.unit-card__top {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: center;
  gap: 7px;
}

.unit-card__portrait {
  display: block;
  width: 30px;
  height: 30px;
  border: 1px solid #587164;
  border-radius: 5px;
  background-image: url("../assets/characters/formation-portraits.png");
  background-position: var(--portrait-position, 0% 0%);
  background-repeat: no-repeat;
  background-size: 300% 200%;
}

.unit-card__portrait.is-additional-portrait {
  background-image: url("../assets/characters/formation-portraits-additional.png");
}

.unit-card__identity strong,
.unit-card__identity span {
  display: block;
}

.unit-card__identity strong {
  font-size: 12px;
}

.unit-card__identity span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
}

.unit-card__top em {
  color: #b9c9c1;
  font-size: 8px;
  font-style: normal;
  letter-spacing: .1em;
}

.unit-card--detailed {
  padding: 4px 6px;
}

.unit-card__identity-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: baseline;
  gap: 5px;
  min-width: 0;
  white-space: nowrap;
}

.unit-card__identity-row strong {
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
}

.unit-card__identity-row span {
  overflow: hidden;
  color: var(--muted);
  font-size: 8px;
  text-overflow: ellipsis;
}

.unit-card__identity-row small {
  color: #80958b;
  font-size: 7px;
}

.unit-card__identity-row em {
  color: #b9c9c1;
  font-size: 7px;
  font-style: normal;
  letter-spacing: .08em;
}

.unit-card__status-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  margin-top: 3px;
}

.unit-card--detailed .unit-card__portrait {
  width: 40px;
  height: 40px;
}

.unit-card__status-body {
  min-width: 0;
}

.unit-card--detailed .hp {
  height: 10px;
  margin-top: 0;
}

.unit-card--detailed .hp span {
  font-size: 7px;
  line-height: 10px;
}

.unit-card--detailed .unit-card__stats {
  gap: 1px;
  margin-top: 3px;
}

.unit-card--detailed .unit-card__stats small {
  font-size: 6px;
}

.unit-card--detailed .unit-card__stats b {
  margin-top: 0;
  font-size: 8px;
}

.unit-card--detailed .chips {
  gap: 3px;
  margin-top: 3px;
}

.unit-card--detailed .chip-button {
  padding: 2px 4px;
  font-size: 7px;
}

.hp {
  position: relative;
  height: 12px;
  margin-top: 7px;
  overflow: hidden;
  border-radius: 3px;
  background: #2b3031;
}

.hp i {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, #318c5d, #69c98c);
}

.hp span {
  position: absolute;
  inset: 0;
  text-align: center;
  color: #f2fff7;
  font-size: 8px;
  line-height: 12px;
  text-shadow: 0 1px 2px #000;
}

.unit-card__stats {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-top: 6px;
}

.unit-card__stats span {
  min-width: 0;
  text-align: center;
}

.unit-card__stats small,
.unit-card__stats b {
  display: block;
}

.unit-card__stats small {
  overflow: hidden;
  color: #718a80;
  font-size: 7px;
  white-space: nowrap;
}

.unit-card__stats b {
  margin-top: 1px;
  font-size: 9px;
}

.chips {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-top: 6px;
}

.chip-button {
  display: block;
  width: 100%;
  min-width: 0;
  height: auto;
  min-height: 0;
  overflow: hidden;
  padding: 3px 5px;
  border: 1px solid #2c424d;
  border-radius: 3px;
  background: #17242d;
  color: #afc4ba;
  font-size: 8px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip-button:hover {
  border-color: var(--accent);
  color: #e7fff2;
}

.chip-button:disabled {
  color: #687c73;
  cursor: default;
  opacity: .65;
}

.chip-button--concealed {
  border-color: #513b46;
  background: #21171d;
  color: #d6b9c4;
  text-align: center;
  letter-spacing: .08em;
}

.chip-button--concealed:hover {
  border-color: #b2788e;
  color: #f4dce5;
}

.chip-skill-modal[hidden] {
  display: none;
}

.chip-skill-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
}

.chip-skill-modal__backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #020609d1;
  backdrop-filter: blur(5px);
}

.chip-skill-modal__dialog {
  position: relative;
  z-index: 1;
  width: min(620px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  overflow: hidden;
  border: 1px solid #49616b;
  border-radius: 11px;
  background: #101a21;
  box-shadow: 0 24px 80px #000c;
}

.chip-skill-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 15px;
  border-bottom: 1px solid var(--line);
  background: #142129;
}

.chip-skill-modal__header span {
  color: var(--accent);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .1em;
}

.chip-skill-modal__header h2 {
  margin: 3px 0 0;
  font-size: 17px;
}

.chip-skill-modal__close {
  width: 34px;
  min-width: 34px;
  height: 34px;
  padding: 0;
  font-size: 18px;
}

.chip-skill-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 150px);
  overflow-y: auto;
  padding: 14px;
}

.chip-skill-item {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 12px;
  padding: 11px 12px;
  border: 1px solid #30434d;
  border-radius: 7px;
  background: #111c23;
}

.chip-skill-item__meta {
  display: grid;
  align-content: start;
  gap: 4px;
}

.chip-skill-item__meta span {
  color: var(--gold, #e7bd69);
  font-size: 11px;
  font-weight: 800;
}

.chip-skill-item__meta small {
  color: var(--accent);
  font-size: 8px;
}

.chip-skill-item strong {
  font-size: 12px;
}

.chip-skill-item p,
.chip-skill-list__empty p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.55;
}

.chip-skill-list__empty {
  padding: 30px 16px;
  border: 1px dashed #354852;
  border-radius: 8px;
  color: #c2d4cc;
  text-align: center;
}

.chip-skill-list__empty strong {
  font-size: 12px;
}

.viewport.dragging {
  cursor: grabbing;
}

.field-corner-label {
  position: absolute;
  z-index: 4;
  padding: 5px 8px;
  border: 1px solid;
  border-radius: 4px;
  background: #0c1419d9;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .12em;
  pointer-events: none;
}

.field-corner-label--enemy {
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  border-color: #e76e916b;
  color: #f1a7bc;
}

.field-corner-label--player {
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  border-color: #57c9e86b;
  color: #9be5f8;
}

.field {
  position: absolute;
  left: 0;
  top: 0;
  overflow: hidden;
  background: #15251c;
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
  filter: drop-shadow(0 24px 40px #000c);
  transform-origin: 0 0;
  will-change: transform;
}

.field.is-camera-following {
  transition: transform .28s ease;
}

.unit-layer,
.order-layer,
.movement-arrow-layer,
.vision-edge-layer,
.tower-heal-zone-layer,
.terrain-structure-layer,
.mob-hp-layer,
.mob-spawn-countdown-layer,
.generated-wall-countdown-layer,
.damage-number-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.terrain-structure-layer {
  z-index: 2;
}

.mob-hp-layer {
  z-index: 3;
}

.vision-edge-layer {
  z-index: 3;
  overflow: visible;
}

.vision-edge-layer line {
  stroke: #75d9f6e6;
  stroke-width: 3px;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 3px #77dcf58f);
}

.tower-heal-zone-layer {
  z-index: 2;
  overflow: visible;
}

.tower-heal-zone-fill {
  fill: #3fd78020;
  stroke: none;
}

.tower-heal-zone-edge {
  stroke: #47e88bd9;
  stroke-width: 3px;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 3px #2ede777d);
}

.mob-spawn-countdown-layer {
  z-index: 7;
}

.generated-wall-countdown-layer {
  z-index: 8;
}

.generated-wall-countdown {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ff334d;
  font-size: 18px;
  font-weight: 1000;
  line-height: 1;
  text-align: center;
  text-shadow: 0 2px 2px #000, 0 0 5px #000;
}

.damage-number-layer {
  z-index: 9;
  overflow: visible;
}

.damage-number {
  position: absolute;
  min-width: 28px;
  color: #ff7281;
  font-size: 18px;
  font-weight: 1000;
  line-height: 1;
  text-align: center;
  text-shadow: 0 2px 2px #000, 0 0 5px #5c0000;
  transform: translate(-50%, -50%);
  animation: damage-number-pop .48s ease-out both;
}

.damage-number--shield {
  color: #fff;
  text-shadow: 0 2px 2px #000, 0 0 5px #dff8ff;
}

.damage-number--critical {
  color: #ffe05e;
  font-size: 22px;
  text-shadow: 0 2px 2px #000, 0 0 6px #ff5722;
}

.healing-number {
  color: #62f59a;
  text-shadow: 0 2px 2px #00130a, 0 0 7px #24d76d;
  animation: healing-number-pop .9s ease-out both;
}

@keyframes damage-number-pop {
  0% { opacity: 0; transform: translate(-50%, -20%) scale(.68); }
  22% { opacity: 1; transform: translate(-50%, -72%) scale(1.18); }
  100% { opacity: .96; transform: translate(-50%, -115%) scale(1); }
}

@keyframes healing-number-pop {
  0% { opacity: 0; transform: translate(-50%, -10%) scale(.7); }
  20% { opacity: 1; transform: translate(-50%, -65%) scale(1.2); }
  70% { opacity: 1; transform: translate(-50%, -105%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -145%) scale(.95); }
}

.mob-spawn-countdown[hidden] {
  display: none;
}

.mob-spawn-countdown {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #d7f3ff;
  line-height: 1;
  text-align: center;
  text-shadow: 0 1px 3px #000, 0 0 5px #00151f;
}

.mob-spawn-countdown strong {
  color: #7edcff;
  font-size: 16px;
  font-weight: 900;
}

.terrain-structure {
  position: absolute;
  object-fit: cover;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  filter: drop-shadow(0 4px 5px #000a);
}

.terrain-structure.is-destroyed {
  opacity: .28;
  filter: grayscale(1) brightness(.55) drop-shadow(0 2px 3px #0008);
}

.tower-recovery-countdown[hidden] {
  display: none;
}

.tower-recovery-countdown {
  position: absolute;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffd7dc;
  font-size: 17px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  text-shadow: 0 2px 3px #000, 0 0 7px #000;
  pointer-events: none;
}

.order-layer {
  z-index: 6;
}

.na-more-marker {
  position: absolute;
  z-index: 4;
  transform: translate(-50%, -50%);
  padding: 3px 7px;
  border: 2px solid #e8fbff;
  border-radius: 999px;
  background: #147faee8;
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: .04em;
  text-shadow: 0 1px 2px #00131d;
  box-shadow: 0 0 0 2px #0a314bc7, 0 0 12px #60d9ff;
}

.unit-layer {
  z-index: 4;
}

.movement-arrow-layer {
  z-index: 5;
  overflow: visible;
}

.movement-arrow-line {
  fill: none;
  stroke-width: 5px;
  stroke-linecap: round;
  opacity: .92;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 2px 2px #000c);
}

.movement-arrow-line--alpha {
  stroke: #e76e91;
}

.movement-arrow-line--bravo {
  stroke: #57c9e8;
}

body.is-alpha-perspective .movement-arrow-line--alpha {
  stroke: #57c9e8;
}

body.is-alpha-perspective .movement-arrow-line--bravo {
  stroke: #e76e91;
}

.movement-arrow-origin {
  stroke: #f5fff9;
  stroke-width: 2px;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 1px 2px #000d);
}

.movement-arrow-origin--alpha {
  fill: #e76e91;
}

.movement-arrow-origin--bravo {
  fill: #57c9e8;
}

body.is-alpha-perspective .movement-arrow-origin--alpha {
  fill: #57c9e8;
}

body.is-alpha-perspective .movement-arrow-origin--bravo {
  fill: #e76e91;
}

.action-arrow-line {
  fill: none;
  stroke: #ffd86b;
  stroke-width: 5px;
  stroke-linecap: round;
  stroke-dasharray: 12 7;
  opacity: .98;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 2px 3px #000e) drop-shadow(0 0 3px #ffbd38);
}

.action-arrow-line--sub {
  stroke: #d7a4ff;
  stroke-dasharray: 7 6;
  filter: drop-shadow(0 2px 3px #000e) drop-shadow(0 0 3px #ad63ed);
}

.action-arrow-origin {
  fill: #ffd86b;
  stroke: #fff8d6;
  stroke-width: 2px;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 1px 2px #000e);
}

.action-arrow-origin--sub {
  fill: #d7a4ff;
  stroke: #f7eaff;
}

.action-arrow-target {
  fill: #ffd86b1f;
  stroke: #ffe69c;
  stroke-width: 3px;
  stroke-dasharray: 5 4;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 4px #ffbd38);
}

.action-arrow-target--sub {
  fill: #d7a4ff14;
  stroke: #e8c9ff;
  filter: drop-shadow(0 0 4px #ad63ed);
}

.attack-range-outline {
  fill: #ffd84f2e;
  stroke: #ffd84f;
  stroke-width: 4px;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 4px #ffbd38e0);
}

.attack-range-outline-content--preview .attack-range-outline {
  fill: #ffe78340;
  stroke: #ffe783;
}

.unit-marker {
  position: absolute;
  display: block;
  width: var(--hex-width);
  min-width: 0;
  height: var(--hex-height);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  pointer-events: auto;
  overflow: visible;
  box-shadow: none;
  transition: left .7s ease, top .7s ease, outline .15s ease;
}

.unit-marker.is-hidden-by-vision {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.unit-marker.is-separated-sub-inactive {
  display: none;
}

.unit-marker.unit-marker--separated-sub::before {
  filter: drop-shadow(0 0 6px #d7a4ff) drop-shadow(0 3px 5px #000c);
}

.unit-marker.unit-marker--separated-sub.is-virtual-separation {
  opacity: .72;
  pointer-events: none;
}

.unit-marker.unit-marker--separated-sub.is-virtual-separation::before {
  background: #7e8791;
  filter: drop-shadow(0 0 5px #d5d9de) drop-shadow(0 3px 5px #000c);
}

.unit-marker.unit-marker--separated-sub.is-virtual-separation .unit-marker__main-face {
  filter: grayscale(1) brightness(.72);
}

.unit-marker.unit-marker--separated-sub.is-virtual-separation .hex-hp-bar {
  display: none;
}

.unit-marker.is-main-recovering .unit-marker__main-face {
  filter: grayscale(1) brightness(.42);
}

.unit-marker__recovery {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 7;
  min-width: 25px;
  padding: 2px 4px;
  transform: translate(-50%, -50%);
  border: 1px solid #ff8292;
  border-radius: 10px;
  background: #2a0e14e8;
  color: #ffd7dc;
  font-size: 7px;
  font-weight: 900;
  text-align: center;
  pointer-events: none;
}

.hex-hp-bar {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.hex-hp-bar--mob {
  inset: auto;
}

.hex-hp-bar--tower {
  inset: auto;
}

.hex-hp-bar--mob[data-hp-percent="0"],
.hex-hp-bar--tower[data-hp-percent="0"][data-shield="0"] {
  opacity: 0;
}

.hex-hp-bar__track,
.hex-hp-bar__value,
.hex-hp-bar__shield {
  fill: none;
  vector-effect: non-scaling-stroke;
}

.hex-hp-bar__track line,
.hex-hp-bar__value line,
.hex-hp-bar__shield line {
  vector-effect: non-scaling-stroke;
  stroke-linecap: butt;
}

.hex-hp-bar__track {
  stroke: #2a1115e8;
  stroke-width: 6px;
}

.hex-hp-bar__value {
  stroke: #ef334d;
  stroke-width: 4px;
  filter: drop-shadow(0 0 2px #ff263f) drop-shadow(0 1px 2px #000d);
}

.hex-hp-bar.is-friendly .hex-hp-bar__value {
  stroke: #1854b4;
  filter: drop-shadow(0 0 2px #0b3b91) drop-shadow(0 1px 2px #000d);
}

.hex-hp-bar--mob .hex-hp-bar__value {
  stroke: #f2cf31;
  filter: drop-shadow(0 0 2px #ffd91f) drop-shadow(0 1px 2px #000d);
}

.hex-hp-bar__shield {
  stroke: #fff;
  stroke-width: 5px;
  filter: drop-shadow(0 0 2px #fff) drop-shadow(0 1px 2px #000d);
}

.hex-hp-bar[data-shield="0"] .hex-hp-bar__shield {
  opacity: 0;
}

.hex-hp-bar--mob.is-stale .hex-hp-bar__value {
  opacity: .62;
}

.hex-hp-bar--mob.is-unknown .hex-hp-bar__value {
  opacity: .24;
  stroke-dasharray: 4 3 !important;
}

.unit-marker::before {
  content: "";
  position: absolute;
  inset: 0;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  filter: drop-shadow(0 3px 5px #000c);
}

.unit-marker--alpha::before {
  background: #e76e91;
}

.unit-marker--bravo::before {
  background: #57c9e8;
}

body.is-alpha-perspective .unit-marker--alpha::before {
  background: #57c9e8;
}

body.is-alpha-perspective .unit-marker--bravo::before {
  background: #e76e91;
}

.unit-marker__main-face,
.unit-marker__sub-face {
  position: absolute;
  display: block;
  background-image: url("../assets/characters/formation-portraits.png");
  background-position: var(--portrait-position, 0% 0%);
  background-repeat: no-repeat;
  background-size: 300% 200%;
  pointer-events: none;
}

.unit-marker__main-face {
  inset: 2px;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}

.unit-marker__sub-face {
  right: -4px;
  bottom: -4px;
  width: 45px;
  height: 45px;
  border: 0;
  border-radius: 0;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  filter: drop-shadow(0 0 2px #e7f5ed) drop-shadow(0 2px 4px #000c);
}

.unit-marker__main-face.is-additional-portrait,
.unit-marker__sub-face.is-additional-portrait {
  background-image: url("../assets/characters/formation-portraits-additional.png");
}

.unit-marker.has-order:not(.is-selected) {
  filter: drop-shadow(0 0 4px #8ce3ad);
}

.unit-marker:hover::before,
.unit-marker.is-selected::before {
  filter: drop-shadow(0 0 5px #eeff9d) drop-shadow(0 3px 5px #000c);
}

.unit-marker.is-action-target {
  cursor: crosshair;
  animation: action-target-pulse 1s ease-in-out infinite alternate;
}

.unit-marker.is-action-target::before {
  filter: drop-shadow(0 0 6px #fff0a4) drop-shadow(0 0 12px #ffbd38) drop-shadow(0 3px 5px #000c);
}

.order-marker {
  position: absolute;
  display: grid;
  place-items: center;
  width: 12px;
  height: 12px;
  border: 1px solid;
  border-radius: 50%;
  color: #fff;
  font-size: 5px;
  font-weight: 900;
  box-shadow: 0 1px 4px #000;
}

.order-marker--alpha {
  border-color: #ffb2c7;
  background: #c64d70;
}

.order-marker--bravo {
  border-color: #b7efff;
  background: #2589a5;
}

body.is-alpha-perspective .order-marker--alpha {
  border-color: #b7efff;
  background: #2589a5;
}

body.is-alpha-perspective .order-marker--bravo {
  border-color: #ffb2c7;
  background: #c64d70;
}

.tile {
  position: absolute;
  display: block;
  width: var(--hex-width);
  height: var(--hex-height);
  border: 0;
  outline: 1px solid #0c17103d;
  outline-offset: -1px;
  object-fit: cover;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  pointer-events: auto;
}

.tile[data-field-side="player"] {
  outline-color: #57c9e824;
}

.tile[data-field-side="enemy"] {
  outline-color: #e76e9124;
}

body.is-alpha-perspective .tile[data-field-side="enemy"] {
  outline-color: #57c9e824;
}

body.is-alpha-perspective .tile[data-field-side="player"] {
  outline-color: #e76e9124;
}

.tile[data-field-side="boundary"] {
  position: absolute;
  z-index: 1;
  outline: 2px solid #f1c66f70;
  outline-offset: -2px;
}

.tile[data-field-zone="top_lane"],
.tile[data-field-zone="bottom_lane"] {
  filter: brightness(1.08) sepia(.12);
}

.tile[data-field-zone="jungle"] {
  filter: brightness(.84) saturate(1.18);
}

.tile[data-tile-type="mob_origin"] {
  position: absolute;
  z-index: 1;
  outline: 0;
  box-shadow: none;
}

.tile[data-tile-type="mob_origin"][data-mob-state="unknown"] {
  filter: brightness(.68) grayscale(.55);
}

.tile[data-tile-type="mob_origin"][data-mob-state="not-spawned"] {
  filter: brightness(.62) grayscale(.8);
}

.tile[data-tile-type="mob_origin"][data-mob-state="defeated"],
.tile[data-tile-type="mob_origin"][data-mob-state="last-known-defeated"] {
  filter: brightness(.48) grayscale(1);
}

.tile[data-tile-type="mob_origin"][data-mob-state="last-known-alive"] {
  filter: brightness(.82) saturate(.72);
}

.tile.is-in-player-vision {
  filter: brightness(1.16) saturate(1.08) !important;
}

.tile.is-outside-player-vision {
  filter: brightness(.68) saturate(.72) !important;
}

.tile:hover {
  position: absolute;
  z-index: 2;
  outline: 2px solid #d8ff96;
}

.tile.is-reachable {
  filter: brightness(1.5) saturate(1.15) !important;
  outline: 2px solid #8ce3ad99;
  outline-offset: -2px;
}

.tile.is-action-range {
  z-index: 2;
  filter: brightness(1.28) saturate(1.25) sepia(.18) !important;
  outline: 2px solid #ffd86b99;
  outline-offset: -2px;
  box-shadow: inset 0 0 9px #ffd86b45;
}

.tile.is-action-target {
  z-index: 3;
  cursor: crosshair;
  filter: brightness(1.55) saturate(1.4) !important;
  outline: 3px solid #fff0a4;
  outline-offset: -3px;
  box-shadow: inset 0 0 12px #ffbd387d;
  animation: action-target-pulse 1s ease-in-out infinite alternate;
}

.tile.is-na-impact-preview,
.tile.is-na-impact-planned {
  z-index: 4;
  filter: brightness(1.12) saturate(1.08) sepia(.12) !important;
  outline: 0 !important;
  box-shadow: none !important;
}

.tile.is-na-impact-preview {
  cursor: crosshair;
}

.is-action-targeting .viewport {
  cursor: crosshair;
}

@keyframes action-target-pulse {
  from { opacity: .76; }
  to { opacity: 1; }
}

.is-processing .unit-marker,
.is-processing .unit-card {
  pointer-events: none;
}

.is-processing .unit-marker {
  transition-duration: .42s, .42s, .15s;
}

.unit-marker.is-position-jump {
  transition: none;
}

.processing-order {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 40;
  width: min(330px, calc(100% - 24px));
  padding: 8px;
  border: 1px solid #6d8194;
  border-radius: 9px;
  background: #0b131ce8;
  box-shadow: 0 8px 22px #0009;
  color: #e9f3fb;
  pointer-events: auto;
}

.processing-order[hidden] {
  display: none;
}

.processing-order header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
}

.processing-order header > div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.processing-order header strong {
  font-size: 13px;
  letter-spacing: .08em;
}

.processing-order header small {
  color: #9eb0c0;
  font-size: 10px;
}

.processing-order__toggle {
  width: 42px;
  min-width: 42px;
  height: 26px;
  padding: 0;
  border-color: #4e7589;
  border-radius: 999px;
  background: #173848;
  color: #bceeff;
  font-size: 9px;
  font-weight: 900;
}

.processing-order.is-collapsed ol {
  display: none;
}

.processing-order ol {
  display: grid;
  gap: 4px;
  max-height: min(316px, 72vh);
  margin: 0;
  padding: 0;
  overflow: hidden auto;
  list-style: none;
}

.processing-order li {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 4px 6px;
  border: 1px solid #304253;
  border-radius: 6px;
  background: #15212c;
  color: #c7d4df;
  font-size: 11px;
}

.processing-order li.is-active {
  border-color: #62d5f4;
  background: #183848;
  box-shadow: inset 3px 0 #62d5f4, 0 0 9px #40bfe25c;
  color: #fff;
}

.processing-order li.is-complete {
  opacity: .52;
}

.processing-order.is-history li.is-complete {
  opacity: 1;
}

.processing-order__rank {
  color: #89a0b3;
  font-weight: 800;
  text-align: center;
}

.processing-order__unit {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.processing-order__stat {
  color: #9eb0c0;
  font-size: 9px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.processing-order li.is-active .processing-order__stat {
  color: #bceeff;
}

.loading {
  position: absolute;
  left: 50%;
  top: 50%;
  padding: 12px 18px;
  transform: translate(-50%, -50%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111922e8;
  color: var(--muted);
}

.statusbar {
  justify-content: flex-start;
  gap: 24px;
  padding: 0 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

#tile-info {
  margin-left: auto;
  color: var(--accent);
}

@media (max-width: 980px) {
  .battle-layout {
    grid-template-columns: 190px minmax(250px, 1fr) 190px;
  }

  .unit-card__stats {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 700px) {
  body {
    grid-template-rows: 60px 1fr 30px;
  }

  .battle-layout {
    grid-template-columns: 1fr;
  }

  .roster {
    display: none;
  }

  .toolbar {
    padding: 8px 10px;
  }

  .toolbar p,
  .statusbar span:not(#tile-info),
  #reset-view {
    display: none;
  }
}
