:root {
  color-scheme: dark;
  --black: #000000;
  --red: #db0814;
  --white: #ffffff;
  --cursor-default: url("./assets/icon/mouse.png") 0 0, auto;
  --font-display: "UnifrakturCook", "UnifrakturMaguntia", "Old English Text MT", "Lucida Blackletter", Georgia, serif;
  --font-ui: "Noto Serif JP", "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", Georgia, serif;
  font-family: var(--font-ui);
  cursor: var(--cursor-default);
}

* {
  box-sizing: border-box;
  cursor: var(--cursor-default);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

html, body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--black);
  color: var(--white);
}

body {
  position: fixed;
  inset: 0;
}

button { font: inherit; }

.game-shell {
  display: grid;
  grid-template-rows: 76px minmax(0, 1fr);
  width: 100%;
  height: var(--app-height, 100dvh);
  min-height: 0;
  overflow: hidden;
  background: var(--black);
}

.top-bar {
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  padding: 0 22px;
  border-bottom: 4px solid var(--white);
  background: var(--black);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--red);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .22em;
}

h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 31px;
  line-height: .9;
  letter-spacing: .02em;
}

.battle-status {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 148px minmax(0, 1fr);
  width: 372px;
  min-width: 372px;
  max-width: 372px;
  align-items: center;
  gap: 0;
  min-height: 42px;
  border: 3px solid var(--white);
  background: var(--black);
  color: var(--white);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .08em;
  font-family: var(--font-ui);
}

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

.team-count {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 6px;
  width: 100%;
  min-width: 0;
  padding: 5px 13px;
  white-space: nowrap;
}

.team-count b {
  font-size: 24px;
  line-height: 1;
  font-family: Georgia, "Times New Roman", var(--font-ui);
  font-variant-numeric: lining-nums tabular-nums;
}

.team-count.ally { color: var(--white); }
.team-count.enemy {
  background: var(--red);
  color: var(--white);
}

#battle-message {
  align-self: stretch;
  display: grid;
  place-items: center;
  width: 100%;
  min-width: 0;
  max-width: 148px;
  padding: 0 14px;
  border-right: 3px solid var(--white);
  border-left: 3px solid var(--white);
  text-align: center;
  white-space: nowrap;
  font-size: 11px;
}

.controls {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

button {
  min-height: 38px;
  padding: 0 15px;
  border: 3px solid var(--white);
  border-radius: 0;
  background: var(--black);
  color: var(--white);
  font-weight: 900;
  letter-spacing: .06em;
}

button:hover {
  background: var(--white);
  color: var(--black);
}

button.is-active {
  background: var(--white);
  color: var(--black);
}

button:active {
  background: var(--red);
  color: var(--white);
}

button:disabled {
  color: var(--white);
  opacity: .45;
}

button:disabled:hover {
  background: var(--black);
  color: var(--white);
}

.battlefield-wrap {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: var(--black);
}

.front-screen {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: clamp(28px, 4vw, 64px);
  color: var(--white);
}

.front-screen[hidden] { display: none; }

.title-screen {
  overflow: hidden;
  padding: 16px;
  background: var(--black);
}

.title-stage {
  position: relative;
  width: min(calc(100vw - 32px), calc((100vh - 32px) * 1184 / 667));
  aspect-ratio: 1184 / 667;
  overflow: hidden;
  background: var(--black) url("./assets/title/title.webp") center / 100% 100% no-repeat;
}

.title-menu {
  position: absolute;
  top: 42%;
  left: 9.9%;
  display: grid;
  grid-template-rows: repeat(5, 1fr);
  width: 40.54%;
  height: 52.48%;
}

.title-menu button {
  display: block;
  width: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  background: var(--black);
  transition: filter 120ms ease, transform 120ms ease;
}

.title-menu button:hover,
.title-menu button:focus-visible {
  z-index: 1;
  background: var(--black);
  filter: brightness(1.35) contrast(1.08);
  outline: 0;
  transform: translateX(2.5%);
}

.title-menu button:disabled {
  opacity: .74;
}

.title-menu button:disabled:hover {
  filter: none;
  transform: none;
}

.title-menu img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
}

.scenario-screen {
  padding: 0;
  background: var(--black);
  overflow: hidden;
}

.scenario-screen button {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
}

.scenario-layout {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 36%) minmax(0, 64%);
  grid-template-rows: 18% minmax(0, 1fr) 8%;
  width: min(calc(100vw - 24px), calc((100vh - 24px) * 1184 / 667));
  aspect-ratio: 1184 / 667;
  padding: 7% 7.5% 5.7%;
  overflow: hidden;
  background: var(--black) url("./assets/pre/pre1.webp") center / 100% 100% no-repeat;
}

.scenario-heading {
  grid-column: 1 / -1;
  align-self: center;
  display: flex;
  align-items: baseline;
  gap: clamp(14px, 2vw, 32px);
  min-width: 0;
  padding-bottom: 1.5%;
  border-bottom: 2px solid rgba(219, 8, 20, .72);
  text-transform: uppercase;
}

.scenario-heading p,
.scenario-heading strong {
  margin: 0;
}

.scenario-heading p {
  color: var(--red);
  font-size: clamp(8px, .75vw, 12px);
  font-weight: 900;
  letter-spacing: .32em;
}

.scenario-heading strong {
  font-family: var(--font-display);
  font-size: clamp(24px, 3vw, 50px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: .025em;
}

#scenario-list {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: clamp(5px, .7vh, 10px);
  min-width: 0;
  padding: 6% 8% 4% 0;
  border-right: 2px solid rgba(219, 8, 20, .72);
}

#scenario-list button {
  display: grid;
  grid-template-columns: clamp(52px, 5.2vw, 78px) minmax(0, 1fr);
  align-items: center;
  width: 100%;
  min-height: clamp(52px, 7.2vh, 82px);
  padding: 0 clamp(8px, 1.2vw, 18px) 0 0;
  border-left: clamp(3px, .35vw, 6px) solid transparent;
  text-align: left;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}

#scenario-list button:hover,
#scenario-list button:focus-visible,
#scenario-list button.is-selected {
  background: var(--red);
  border-left-color: var(--white);
  color: var(--white);
  outline: 0;
  transform: translateX(1.8%);
}

#scenario-list button:disabled {
  opacity: .28;
}

#scenario-list button:disabled:hover {
  background: transparent;
  border-left-color: transparent;
  transform: none;
}

.scenario-number {
  align-self: stretch;
  display: grid;
  place-items: center;
  padding-right: clamp(5px, .7vw, 11px);
  border-right: 1px solid rgba(219, 8, 20, .62);
  color: var(--red);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(25px, 2.8vw, 45px);
  font-weight: 700;
  line-height: 1;
  text-align: center;
}

#scenario-list button.is-selected .scenario-number,
#scenario-list button:hover .scenario-number,
#scenario-list button:focus-visible .scenario-number {
  border-right-color: rgba(255, 255, 255, .72);
  color: var(--white);
}

#scenario-list button > span:last-child {
  min-width: 0;
  padding-left: clamp(12px, 1.2vw, 18px);
}

#scenario-list b,
#scenario-list small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#scenario-list b {
  font-size: clamp(10px, 1.1vw, 17px);
  letter-spacing: .05em;
}

#scenario-list small {
  margin-top: 3px;
  font-size: clamp(7px, .72vw, 11px);
  font-weight: 700;
  letter-spacing: .15em;
}

#scenario-detail {
  align-self: stretch;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  min-width: 0;
  padding: 6% 2% 3% 8%;
}

.scenario-kicker {
  margin: 0 0 1%;
  color: var(--red);
  font-size: clamp(8px, .72vw, 11px);
  font-weight: 900;
  letter-spacing: .28em;
}

#scenario-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(27px, 4vw, 64px);
  line-height: 1;
  letter-spacing: .025em;
}

#scenario-description {
  align-self: start;
  max-width: 42em;
  margin: 4% 0 2%;
  color: rgba(255, 255, 255, .82);
  font-size: clamp(9px, 1vw, 15px);
  font-weight: 700;
  line-height: 1.9;
  letter-spacing: .06em;
}

.scenario-data {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 2px solid var(--white);
  border-bottom: 2px solid var(--white);
}

.scenario-data > div {
  min-width: 0;
  padding: clamp(7px, 1vw, 14px);
  overflow: hidden;
  font-size: clamp(8px, .84vw, 13px);
  font-weight: 900;
  letter-spacing: .08em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scenario-data > div + div {
  border-left: 2px solid var(--white);
}

.scenario-data > div::before {
  content: attr(data-label);
  display: block;
  margin-bottom: 4px;
  color: var(--red);
  font-size: .7em;
  letter-spacing: .16em;
}

.scenario-screen .operation-launch {
  justify-self: end;
  width: min(38%, 210px);
  min-height: clamp(42px, 6vh, 68px);
  margin-top: 4%;
  border: 3px solid var(--white);
  background: var(--red);
  font-family: var(--font-display);
  font-size: clamp(19px, 2.2vw, 35px);
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

.scenario-screen .operation-launch::before { content: "START"; }

.scenario-screen .operation-launch:hover,
.scenario-screen .operation-launch:focus-visible {
  background: var(--white);
  color: var(--black);
  outline: 0;
}

.scenario-help {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-self: end;
  margin: 0;
  padding-top: 1.5%;
  color: rgba(255, 255, 255, .52);
  font-size: clamp(7px, .65vw, 10px);
  font-weight: 900;
  letter-spacing: .18em;
}

@media (max-aspect-ratio: 4 / 5) {
  .scenario-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    width: min(calc(100vw - 16px), calc((100vh - 16px) * 1184 / 667));
    padding: 7% 8% 5.5%;
  }

  .scenario-heading strong { font-size: clamp(18px, 4vw, 32px); }

  #scenario-list {
    grid-column: 1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 2% 0;
    border-right: 0;
    border-bottom: 2px solid rgba(219, 8, 20, .72);
  }

  #scenario-list button {
    grid-template-columns: auto minmax(0, 1fr);
    min-height: 38px;
  }

  .scenario-number { font-size: clamp(18px, 5vw, 32px); }

  #scenario-detail {
    padding: 3% 0 1%;
  }

  #scenario-description { line-height: 1.5; }
}
#battlefield {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  overscroll-behavior: none;
  touch-action: none;
}

.loading {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: var(--black);
  color: var(--white);
}

.loading-card {
  display: grid;
  justify-items: center;
  gap: 12px;
  width: min(520px, calc(100vw - 40px));
  padding: 34px 28px 28px;
  border: 4px solid var(--white);
  background: var(--black);
  text-align: center;
}

.loading-kicker {
  margin: 0;
  color: var(--red);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .24em;
}

.loading strong {
  font-family: var(--font-display);
  font-size: clamp(42px, 8vw, 74px);
  line-height: .85;
  letter-spacing: .03em;
}

.loading span {
  color: var(--white);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .12em;
}

.loading i {
  display: block;
  width: min(240px, 60vw);
  height: 6px;
  margin-top: 6px;
  background: var(--red);
}

.loading.error .loading-card { border-color: var(--red); }
.loading.error .loading-kicker,
.loading.error span { color: var(--red); }
.loading.error i { background: var(--white); }
.loading[hidden] { display: none; }

.scenario-loading {
  position: fixed;
  inset: 0;
  z-index: 28;
  overflow: hidden;
  background: var(--black);
}

.scenario-loading img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--loading-art-position, center);
}

.scenario-loading[hidden] { display: none; }

.start-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 24px;
  background: var(--black);
  color: var(--white);
  text-align: center;
}

.start-screen[hidden] { display: none; }

.screen-transition {
  position: fixed;
  inset: 0;
  z-index: 29;
  background: var(--black);
  opacity: 0;
  pointer-events: auto;
  transition: opacity 220ms ease;
}

.screen-transition.is-visible {
  opacity: 1;
}

.screen-transition[hidden] { display: none; }

.start-kicker,
.start-edition {
  margin: 0;
  color: var(--red);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .24em;
}

.start-screen h2 {
  margin: 8px 0 2px;
  font-family: var(--font-display);
  font-size: clamp(54px, 10vw, 108px);
  line-height: .82;
  letter-spacing: .02em;
}

.start-edition {
  color: var(--white);
  font-size: 13px;
}

.start-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: min(440px, calc(100vw - 40px));
  margin-top: 34px;
}

#start-battle {
  background: var(--red);
}

#start-battle:hover {
  background: var(--white);
  color: var(--black);
}

.controls-dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 11;
  width: min(500px, calc(100vw - 32px));
  padding: 24px;
  border: 4px solid var(--white);
  background: var(--black);
  color: var(--white);
  text-align: left;
  transform: translate(-50%, -50%);
}

.controls-dialog[hidden] { display: none; }

.controls-kicker {
  margin: 0 0 5px;
  color: var(--red);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .2em;
}

.controls-dialog h3 {
  margin: 0 0 18px;
  font-family: var(--font-display);
  font-size: 34px;
  line-height: 1;
}

.controls-dialog dl { margin: 0 0 20px; }

.controls-dialog dl div {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 14px;
  padding: 10px 0;
  border-top: 2px solid var(--white);
}

.controls-dialog dl div:last-child {
  border-bottom: 2px solid var(--white);
}

.controls-dialog dt {
  color: var(--red);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .1em;
}

.controls-dialog dd {
  margin: 0;
  font-size: 11px;
}

#close-controls { width: 100%; }

.hud-panel {
  touch-action: none;
}

.commander-panel {
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 2;
  width: min(360px, calc(100vw - 28px));
  border: 3px solid var(--white);
  background: var(--black);
  color: var(--white);
}

.commander-summary {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  min-height: 96px;
  border-bottom: 3px solid var(--white);
}

.commander-portrait {
  display: block;
  width: 96px;
  height: 96px;
  aspect-ratio: 1 / 1;
  border-right: 3px solid var(--white);
  object-fit: cover;
}

.commander-info {
  display: grid;
  align-content: center;
  gap: 7px;
  min-width: 0;
  padding: 12px 14px;
}

.panel-kicker,
.panel-status {
  margin: 0;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .16em;
}

.panel-kicker { color: var(--red); }

.commander-name {
  overflow: hidden;
  font-family: var(--font-display);
  font-size: 34px;
  line-height: 1;
  letter-spacing: .03em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.force-status {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 0;
  padding: 6px;
  border-bottom: 3px solid var(--white);
}

.force-status div {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 4px 6px;
  border: 2px solid var(--white);
}

.force-status dt {
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .08em;
  white-space: nowrap;
}

.force-status dd {
  margin: 0;
  font-family: Georgia, "Times New Roman", var(--font-ui);
  font-size: 16px;
  font-weight: 900;
  font-variant-numeric: lining-nums tabular-nums;
}

.panel-status {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: baseline;
  gap: 8px;
  padding: 7px 10px;
  border-bottom: 3px solid var(--white);
}

.panel-status b {
  overflow: hidden;
  color: var(--red);
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.command-mode,
.formation-mode {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border-bottom: 3px solid var(--white);
}

.command-mode span,
.formation-mode span {
  color: var(--red);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .16em;
}

.command-mode-buttons,
.formation-mode-buttons {
  display: grid;
  gap: 4px;
}

.command-mode-buttons {
  grid-template-columns: 1fr 1fr;
}

.formation-mode-buttons {
  grid-template-columns: repeat(3, 1fr);
}

.command-mode button,
.formation-mode button {
  min-height: 30px;
  padding: 0 8px;
  font-size: 9px;
}

.command-mode button.is-active,
.formation-mode button.is-active {
  background: var(--white);
  color: var(--black);
}

.selection-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 6px;
}

.selection-actions button,
.formation-select {
  min-height: 30px;
  padding: 0 8px;
  font-size: 9px;
}

.selection-actions button.is-selected,
.formation-select.is-selected {
  background: var(--red);
  color: var(--white);
}

.unit-status-panel {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(390px, calc(100vw - 28px));
  max-height: min(330px, calc(100% - 28px));
  overflow: hidden;
  border: 3px solid var(--white);
  background: var(--black);
  color: var(--white);
  user-select: none;
}

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

.strategy-panel {
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 2;
  width: min(360px, calc(100vw - 28px));
  border: 3px solid var(--white);
  background: var(--black);
  color: var(--white);
}

.strategy-panel[hidden] { display: none; }

.faction-panel {
  position: absolute;
  right: 22px;
  top: 22px;
  z-index: 3;
  width: min(390px, calc(100vw - 44px));
  border: 3px solid var(--white);
  background: rgba(0, 0, 0, .96);
  color: var(--white);
}

.faction-panel[hidden],
#faction-detail[hidden],
#faction-empty[hidden] { display: none; }

.faction-panel > .panel-kicker {
  margin: 0;
  padding: 9px 12px;
  border-bottom: 3px solid var(--white);
  background: var(--red);
  color: var(--white);
}

.faction-empty { padding: 24px; }
.faction-empty h2 { margin: 0 0 8px; font-size: 28px; }
.faction-empty p { margin: 0; color: #c9c9c9; font-size: 13px; }

.faction-heading {
  display: grid;
  grid-template-columns: 106px minmax(0, 1fr);
  min-height: 106px;
}

.faction-heading img {
  display: block;
  width: 106px;
  height: 106px;
  aspect-ratio: 1 / 1;
  border-right: 3px solid var(--white);
  border-bottom: 3px solid var(--white);
  object-fit: cover;
}

.faction-heading > div {
  align-self: stretch;
  display: grid;
  align-content: center;
  min-width: 0;
  padding: 12px 15px;
  border-bottom: 3px solid var(--white);
}
.faction-heading span { color: var(--red); font-size: 9px; font-weight: 900; letter-spacing: .18em; }
.faction-heading h2 { overflow: hidden; margin: 3px 0; font-size: 30px; text-overflow: ellipsis; }
.faction-heading p { margin: 0; font-size: 10px; font-weight: 900; letter-spacing: .08em; }

.faction-description { min-height: 64px; margin: 0; padding: 14px 16px; border-bottom: 3px solid var(--white); font-size: 13px; line-height: 1.7; }
.faction-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 0; padding: 7px; }
.faction-stats div { padding: 7px 9px; border: 2px solid var(--white); }
.faction-stats dt { color: var(--red); font-size: 8px; font-weight: 900; letter-spacing: .13em; }
.faction-stats dd { margin: 2px 0 0; font-size: 18px; font-weight: 900; }
.faction-choose { width: calc(100% - 14px); margin: 0 7px 7px; background: var(--red); }
.faction-choose:hover { background: var(--white); color: var(--black); }

.strategy-spot-panels {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.strategy-spot-panels[hidden] { display: none; }

.strategy-spot-panel {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  width: min(390px, calc(100vw - 28px));
  max-height: min(440px, calc(100% - 28px));
  overflow: hidden;
  border: 3px solid var(--white);
  background: var(--black);
  color: var(--white);
  user-select: none;
  pointer-events: auto;
}

.strategy-spot-panel[hidden] { display: none; }

.strategy-spot-panel .unit-status-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 30px;
}

.strategy-spot-panel .unit-status-heading h2 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.strategy-panel-close {
  min-width: 0;
  min-height: 28px;
  width: 28px;
  padding: 0;
  font-size: 11px;
  line-height: 1;
}

.strategy-spot-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 0;
  padding: 6px;
  border-bottom: 3px solid var(--white);
}

.strategy-spot-summary div {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 6px 8px;
  border: 2px solid var(--white);
}

.strategy-spot-summary dt {
  color: var(--red);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .14em;
}

.strategy-spot-summary dd {
  overflow: hidden;
  margin: 0;
  font-family: Georgia, "Times New Roman", var(--font-ui);
  font-size: 18px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.strategy-hire-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 6px;
  border-bottom: 3px solid var(--white);
}

.strategy-hire-actions[hidden] { display: none; }

.strategy-hire-actions button {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  min-height: 48px;
  padding: 4px 8px 4px 4px;
  text-align: left;
}

.strategy-hire-actions img {
  display: block;
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.strategy-hire-actions span {
  overflow: hidden;
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.strategy-hire-actions b {
  color: var(--red);
  font-family: Georgia, "Times New Roman", var(--font-ui);
  font-size: 16px;
  font-variant-numeric: lining-nums tabular-nums;
}

.strategy-formation-label {
  display: grid;
  align-items: center;
  min-height: 30px;
  padding: 0 8px;
  border-right: 2px solid var(--white);
  color: var(--white);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .06em;
}

.strategy-unit-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border-bottom: 3px solid var(--white);
}

.strategy-unit-actions button {
  min-height: 30px;
  padding: 0 8px;
  font-size: 9px;
}

.strategy-unit-actions button.is-selected {
  background: var(--red);
  color: var(--white);
}

.strategy-unit-actions b {
  min-width: 38px;
  padding: 4px 6px;
  border: 2px solid var(--white);
  font-family: Georgia, "Times New Roman", var(--font-ui);
  font-size: 16px;
  font-variant-numeric: lining-nums tabular-nums;
  text-align: center;
}

.strategy-unit-card:not(button) {
  pointer-events: none;
}

.strategy-unit-card.is-selected {
  border-color: var(--red);
  background: var(--red);
}

.strategy-unit-card.is-dragging {
  background: var(--white);
  border-color: var(--white);
}

.strategy-drag-ghost {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 60;
  width: 82px;
  height: 66px;
  border: 3px solid var(--red);
  background: var(--black);
  pointer-events: none;
  transition: border-color 80ms linear, background 80ms linear;
  will-change: transform;
}

.strategy-drag-ghost img {
  position: absolute;
  top: 7px;
  left: 7px;
  display: block;
  width: 42px;
  height: 42px;
  border: 2px solid var(--white);
  background: var(--black);
  object-fit: contain;
}

.strategy-drag-ghost img:nth-child(2) {
  transform: translate(8px, 5px);
}

.strategy-drag-ghost img:nth-child(3) {
  transform: translate(16px, 10px);
}

.strategy-drag-ghost b {
  position: absolute;
  right: -3px;
  bottom: -3px;
  min-width: 35px;
  padding: 3px 5px;
  border: 3px solid var(--red);
  background: var(--red);
  color: var(--white);
  font-family: Georgia, "Times New Roman", var(--font-ui);
  font-size: 15px;
  line-height: 1;
  text-align: center;
}

.strategy-drag-ghost.is-valid {
  border-color: var(--white);
  background: var(--red);
}

.strategy-drag-ghost.is-valid b {
  border-color: var(--white);
  background: var(--white);
  color: var(--black);
}

.strategy-panel-selection-box {
  position: absolute;
}

.strategy-spot-panel.is-drop-hover {
  background: var(--white);
  color: var(--black);
}

.strategy-spot-panel.is-drop-hover .panel-kicker,
.strategy-spot-panel.is-drop-hover .unit-status-heading p,
.strategy-spot-panel.is-drop-hover dt,
.strategy-spot-panel.is-drop-hover .role-heading,
.strategy-spot-panel.is-drop-hover .strategy-empty-units {
  color: var(--black);
}

.strategy-spot-panel.is-drop-hover,
.strategy-spot-panel.is-drop-hover *,
.strategy-spot-panel.is-drop-hover .unit-card,
.strategy-spot-panel.is-drop-hover .unit-card-hp {
  border-color: var(--black);
}

.strategy-spot-panel.is-drop-hover .unit-card,
.strategy-spot-panel.is-drop-hover .unit-card-hp {
  background: var(--white);
}

.strategy-spot-panel.is-drop-hover .unit-card-hp i {
  background: var(--black);
}

.strategy-empty-units {
  margin: 0;
  padding: 16px 10px;
  color: var(--red);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .16em;
  text-align: center;
}

.strategy-heading {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  min-height: 88px;
  border-bottom: 3px solid var(--white);
}

.strategy-master-portrait {
  display: block;
  width: 88px;
  height: 88px;
  aspect-ratio: 1 / 1;
  border-right: 3px solid var(--white);
  object-fit: cover;
}

.strategy-master-info {
  display: grid;
  align-content: center;
  gap: 6px;
  min-width: 0;
  padding: 10px 12px;
}

.strategy-heading h2 {
  overflow: hidden;
  margin: 0;
  font-family: var(--font-display);
  font-size: 30px;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.strategy-status {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 0;
  padding: 6px;
  border-bottom: 3px solid var(--white);
}

.strategy-status div {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 6px 8px;
  border: 2px solid var(--white);
}

.strategy-status dt,
.strategy-selection span {
  color: var(--red);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .14em;
}

.strategy-status dd {
  margin: 0;
  font-family: Georgia, "Times New Roman", var(--font-ui);
  font-size: 19px;
  font-weight: 900;
}

.strategy-selection {
  display: grid;
  gap: 0;
  border-bottom: 3px solid var(--white);
}

.strategy-selection p {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 9px 10px;
}

.strategy-selection p + p {
  border-top: 2px solid var(--white);
}

.strategy-selection b {
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.strategy-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  padding: 6px;
  border-bottom: 3px solid var(--white);
}

#strategy-invade {
  background: var(--red);
}

#strategy-invade:disabled {
  background: var(--black);
}

#strategy-invade:hover {
  background: var(--white);
  color: var(--black);
}

.strategy-selected-forces {
  display: grid;
  grid-template-columns: auto repeat(8, 28px) minmax(28px, auto);
  align-items: center;
  gap: 5px;
  min-height: 44px;
  padding: 7px 8px;
  border-bottom: 3px solid var(--white);
  background: var(--black);
  color: var(--white);
  user-select: none;
}

.strategy-selected-forces[hidden] { display: none; }

.strategy-selected-forces span {
  color: var(--red);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .14em;
}

.strategy-selected-forces img {
  display: block;
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.strategy-selected-forces b {
  justify-self: end;
  font-family: Georgia, "Times New Roman", var(--font-ui);
  font-size: 18px;
  font-variant-numeric: lining-nums tabular-nums;
}

.strategy-selected-forces.is-dragging {
  background: var(--red);
}

.strategy-message {
  min-height: 42px;
  margin: 0;
  padding: 9px 10px;
  color: var(--white);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .05em;
}

.unit-status-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 10px;
  border-bottom: 3px solid var(--white);
}

.unit-status-heading h2,
.unit-status-heading p {
  margin: 0;
}

.unit-status-heading h2 {
  font-family: var(--font-display);
  font-size: 20px;
  line-height: 1;
}

.unit-status-heading p {
  color: var(--red);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .12em;
  white-space: nowrap;
}

.formation-panel {
  display: grid;
  min-height: 0;
  overflow: auto;
}

.role-group + .role-group {
  border-top: 3px solid var(--white);
}

.role-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0;
  padding: 7px 9px;
  color: var(--red);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .16em;
}

.formation-row {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  border-top: 2px solid var(--white);
}

.formation-select {
  align-self: stretch;
  border: 0;
  border-right: 2px solid var(--white);
}

.formation-units {
  display: flex;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
  padding: 7px;
}

.unit-card {
  position: relative;
  flex: 0 0 58px;
  width: 58px;
  min-height: 70px;
  padding: 3px;
  border: 2px solid var(--white);
  background: var(--black);
}

.unit-card.is-selected {
  border-color: var(--red);
  background: var(--red);
}

.unit-card.is-destroyed::after {
  position: absolute;
  inset: 3px;
  display: grid;
  place-items: center;
  background: var(--black);
  color: var(--red);
  content: "X";
  font-family: Georgia, serif;
  font-size: 28px;
  font-weight: 900;
}

.unit-card img {
  display: block;
  width: 48px;
  height: 48px;
  margin: 0 auto 3px;
  object-fit: contain;
}

.unit-card-hp {
  display: block;
  height: 6px;
  border: 1px solid var(--white);
  background: var(--black);
}

.unit-card-hp i {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--white);
}

.panel-selection-box {
  position: absolute;
  z-index: 4;
  border: 2px solid var(--red);
  background: transparent;
  pointer-events: none;
}

.panel-selection-box[hidden] { display: none; }

.selection-box {
  position: absolute;
  z-index: 4;
  border: 2px solid var(--white);
  background: transparent;
  pointer-events: none;
}

.selection-box[hidden] { display: none; }

.battle-result,
.invasion-dialog,
.battle-briefing {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 20;
  width: min(440px, calc(100vw - 32px));
  padding: 24px;
  border: 4px solid var(--white);
  background: var(--black);
  color: var(--white);
  text-align: center;
  transform: translate(-50%, -50%);
}

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

.result-kicker {
  margin: 0 0 8px;
  color: var(--red);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .22em;
}

.battle-result h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(36px, 6vw, 58px);
  line-height: .95;
  letter-spacing: .02em;
}

.battle-result h2.is-defeat { color: var(--red); }

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 22px 0 18px;
  border-top: 3px solid var(--white);
  border-bottom: 3px solid var(--white);
}

.result-stats p {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 12px 8px;
}

.result-stats p + p { border-left: 3px solid var(--white); }

.result-stats span {
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .12em;
}

.result-stats b {
  font-family: Georgia, "Times New Roman", var(--font-ui);
  font-size: 25px;
  font-variant-numeric: lining-nums tabular-nums;
}

#result-restart {
  width: 100%;
  background: var(--red);
}

#result-restart:hover {
  background: var(--white);
  color: var(--black);
}

.invasion-dialog h2,
.battle-briefing h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(30px, 5vw, 48px);
  line-height: 1;
  letter-spacing: .02em;
}

.battle-briefing-header {
  touch-action: none;
  user-select: none;
}

.invasion-summary,
.battle-briefing-summary {
  margin: 18px 0;
  padding: 12px 10px;
  border-top: 3px solid var(--white);
  border-bottom: 3px solid var(--white);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .05em;
}

#begin-battle {
  width: 100%;
  background: var(--red);
}

.invasion-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

#confirm-invasion {
  background: var(--red);
}

#confirm-invasion:hover {
  background: var(--white);
  color: var(--black);
}

#begin-battle:hover {
  background: var(--white);
  color: var(--black);
}

.legend {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: flex;
  gap: 14px;
  padding: 9px 12px;
  border: 3px solid var(--white);
  border-radius: 0;
  background: var(--black);
  color: var(--white);
  font-size: 10px;
  font-weight: 800;
}

.legend span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend i {
  width: 10px;
  height: 10px;
  border: 2px solid var(--white);
}

.ally-dot { background: var(--white); }
.enemy-dot { background: var(--red); }

#zoom-level {
  min-width: 34px;
  justify-content: flex-end;
  color: var(--white);
  font-variant-numeric: tabular-nums;
  font-family: Georgia, "Times New Roman", var(--font-ui);
}

@media (max-width: 720px) {
  .game-shell { grid-template-rows: 104px minmax(0, 1fr); }
  .top-bar {
    grid-template-columns: 1fr auto;
    gap: 8px;
    padding: 8px 12px;
  }
  h1 { font-size: 28px; }
  .battle-status {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: center;
    min-height: 36px;
    grid-template-columns: minmax(0, 1fr) 116px minmax(0, 1fr);
    width: 292px;
    min-width: 292px;
    max-width: 292px;
  }
  .team-count { padding: 3px 6px; font-size: 10px; }
  .team-count b { font-size: 20px; }
  #battle-message { width: 100%; max-width: 116px; padding: 0 5px; font-size: 9px; }
  .controls { grid-column: 2; grid-row: 1; }
  .start-screen { padding: 16px; }
  .start-screen h2 { font-size: 52px; }
  .start-actions {
    grid-template-columns: 1fr;
    width: min(360px, calc(100vw - 32px));
    margin-top: 26px;
  }
  .controls-dialog { padding: 18px; }
  .controls-dialog dl div { grid-template-columns: 90px 1fr; }
  .commander-panel {
    left: 8px;
    bottom: 8px;
    width: min(320px, calc(100vw - 16px));
  }
  .commander-summary { grid-template-columns: 72px 1fr; min-height: 72px; }
  .commander-portrait { width: 72px; height: 72px; }
  .commander-info { gap: 3px; padding: 7px 9px; }
  .commander-name { font-size: 24px; }
  .force-status { padding: 5px; }
  .force-status dd { font-size: 14px; }
  .selection-actions { gap: 4px; padding: 6px; }
  .selection-actions button { padding: 0 4px; font-size: 8px; }
  .unit-status-panel {
    top: 8px;
    right: 8px;
    width: min(340px, calc(100vw - 16px));
    max-height: min(280px, calc(100% - 16px));
  }
  .strategy-panel {
    left: 8px;
    bottom: 8px;
    width: min(320px, calc(100vw - 16px));
  }
  .faction-panel {
    top: 8px;
    right: 8px;
    width: min(340px, calc(100vw - 16px));
  }
  .strategy-spot-panel {
    top: 8px;
    right: 8px;
    width: min(340px, calc(100vw - 16px));
    max-height: min(360px, calc(100% - 16px));
  }
  .strategy-heading { grid-template-columns: 72px minmax(0, 1fr); min-height: 72px; }
  .strategy-master-portrait { width: 72px; height: 72px; }
  .strategy-master-info { gap: 3px; padding: 7px 9px; }
  .strategy-heading h2 { font-size: 25px; }
  .unit-status-heading { padding: 7px 8px; }
  .unit-status-heading h2 { font-size: 18px; }
  .formation-row { grid-template-columns: 82px minmax(0, 1fr); }
  .battle-result { padding: 18px; }
  .battle-result h2 { font-size: 36px; }
  .result-stats { margin: 18px 0 14px; }
  .legend span:last-child { display: none; }
  .title-screen { display: grid; overflow: hidden; padding: 8px; }
  .title-screen[hidden] { display: none; }
}

@media (max-height: 680px) and (min-width: 721px) {
  .title-screen { padding: 8px; }
}
