/* Battle Mode screens. */
#battle-orders {
  position: fixed;
  z-index: 29;
  left: 50%;
  top: calc(118px + var(--frame-y) + env(safe-area-inset-top));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: min(880px, calc(100vw - 24px - var(--frame-x)));
  max-height: none;
  overflow: visible;
  pointer-events: none;
}

.battle-shell {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
}

.battle-rail {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.battle-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0;
  border: 1px solid rgba(120, 196, 214, 0.35);
  background: rgba(10, 14, 28, 0.82);
  color: #e7eef6;
  font: 10px "Segoe UI", sans-serif;
}

.battle-icon i {
  font-style: normal;
  color: #c6f56a;
  font-size: 14px;
  line-height: 1;
}

.battle-icon strong {
  font: 12px "IBM Plex Mono", monospace;
  color: #fff;
}

#boot:not(.is-opening) ~ #battle-orders { visibility: hidden; }

#battle-orders[hidden] { display: none; }

#battle-exit {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid rgba(255, 140, 112, 0.9);
  border-radius: 16px;
  background: rgba(28, 10, 10, 0.9);
  color: #ffe4dc;
  cursor: pointer;
  pointer-events: auto;
}

#battle-exit i {
  font-style: normal;
  font-size: 18px;
  line-height: 1;
}

#battle-exit span {
  font: 700 11px "Segoe UI", sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#battle-exit[hidden] { display: none; }

#battle-focus {
  position: fixed;
  z-index: 34;
  top: calc(54px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  max-width: min(640px, calc(100vw - 48px));
  text-align: center;
  pointer-events: none;
}

#battle-focus[hidden] { display: none; }

#battle-focus-name {
  display: block;
  font: 700 20px/1.2 "Sora", "Segoe UI", sans-serif;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.65);
}

#battle-focus-hull {
  display: block;
  margin-top: 2px;
  font: 700 13px/1.2 "IBM Plex Mono", ui-monospace, monospace;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.65);
}

#battle-focus-hull[hidden] { display: none; }

#battle-remain {
  position: fixed;
  z-index: 34;
  left: calc(16px + var(--frame-x) + env(safe-area-inset-left));
  margin: 0;
  color: #e7eef6;
  font: 700 18px/1 "IBM Plex Mono", ui-monospace, monospace;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.7);
  pointer-events: none;
}

#battle-remain[hidden] { display: none; }
.battle-tabs {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-start;
  gap: 4px;
  overflow-x: auto;
  pointer-events: auto;
}

.battle-tab {
  position: relative;
  flex: 1 0 88px;
  min-width: 88px;
  max-width: 148px;
  padding: 5px 6px 7px;
  border: 1px solid rgba(120, 196, 214, 0.35);
  border-radius: 2px;
  background: rgba(10, 14, 28, 0.82);
  color: #e7eef6;
  font: 10px "IBM Plex Mono", monospace;
  text-align: left;
  cursor: pointer;
}

.battle-tab.is-current { border-color: rgba(198, 245, 106, 0.7); }

.battle-tab-pips { display: flex; gap: 3px; height: 6px; }

.battle-tab-pips i { width: 6px; height: 6px; border-radius: 50%; }

.battle-tab-name,
.battle-tab-status {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.battle-tab-name { margin-top: 3px; color: #fff; }

.battle-tab-status { color: rgba(231, 238, 246, 0.62); }

.battle-tab-track {
  display: block;
  height: 2px;
  margin-top: 4px;
  background: rgba(255, 255, 255, 0.12);
}

.battle-tab-track i {
  display: block;
  height: 100%;
  width: 0;
  background: #e6c03c;
}

.battle-tab.is-done .battle-tab-track i { background: #5fd35f; }

.battle-tab-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #e6c03c;
}

#battle-victor {
  position: fixed;
  left: 0;
  right: 0;
  top: 18%;
  z-index: 32;
  pointer-events: none;
  margin: 0;
  padding: 22px 28px 18px;
  background: rgba(5, 8, 18, 0.42);
  text-align: center;
}

#battle-victor strong {
  display: block;
  color: #c6f56a;
  font: 700 clamp(34px, 4.6vw, 58px) "Segoe UI", sans-serif;
  letter-spacing: 0.12em;
  line-height: 1;
  text-transform: uppercase;
}

#battle-victor em,
#battle-victor span {
  display: block;
  margin-top: 8px;
  color: rgba(255, 255, 255, 0.88);
  font: 500 15px "Segoe UI", sans-serif;
  font-style: normal;
  letter-spacing: 0.02em;
}

#battle-victor[hidden] { display: none; }

.battle-note {
  margin: 0;
  padding: 6px 8px;
  border: 1px solid rgba(230, 192, 60, 0.7);
  background: rgba(10, 14, 28, 0.88);
  color: #fff;
  font: 11px "IBM Plex Mono", monospace;
}

.battle-order {
  padding: 8px 10px 10px;
  border: 1px solid rgba(120, 196, 214, 0.35);
  border-radius: 2px;
  background: rgba(10, 14, 28, 0.82);
  color: #e7eef6;
  font-family: "IBM Plex Mono", monospace;
}

.battle-order.is-focus { border-color: rgba(198, 245, 106, 0.7); }

.battle-order header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(231, 238, 246, 0.62);
}

.battle-order header strong {
  color: #fff;
  font-weight: 500;
  letter-spacing: 0;
}

.battle-order-clock {
  margin: 6px 0 0;
  font-size: 12px;
  color: #fff;
}

.battle-order-track {
  display: block;
  height: 3px;
  margin-top: 6px;
  background: rgba(255, 255, 255, 0.12);
}

.battle-order-track i {
  display: block;
  height: 100%;
  width: 0;
  background: #e6c03c;
}

.battle-order.is-done .battle-order-track i { background: #5fd35f; }

.battle-order ul {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

.battle-order li {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) 28px 46px 46px;
  gap: 6px;
  align-items: center;
  font-size: 11px;
  line-height: 1.7;
}

.battle-order-key {
  color: rgba(231, 238, 246, 0.45);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 9px;
}

.battle-order li i {
  width: 4px;
  height: 10px;
  background: #e7eef8;
}

.battle-order li span:nth-child(n + 3) {
  text-align: right;
  color: rgba(231, 238, 246, 0.7);
}

.battle-order-more {
  margin: 8px 0 0;
  font-size: 11px;
  color: rgba(231, 238, 246, 0.62);
}

.battle-order-result {
  margin: 8px 0 0;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fff;
}

.battle-order-feed li {
  display: block;
  color: rgba(231, 238, 246, 0.78);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 800px) {
  #battle-orders {
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    top: calc(108px + env(safe-area-inset-top));
    bottom: auto;
    transform: none;
    width: auto;
    max-height: none;
  }

  .battle-tabs { max-width: 100%; justify-content: flex-start; }
}

#battle-board {
  position: fixed;
  z-index: 32;
  left: calc(8px + var(--frame-x) + env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  width: min(268px, calc(100vw - 84px - var(--frame-x) - env(safe-area-inset-left)));
  color: #e7eef6;
  font: 12px/1.35 "IBM Plex Mono", ui-monospace, monospace;
  pointer-events: auto;
}

#battle-board[hidden] { display: none; }

#battle-board-toggle {
  align-self: flex-start;
  margin: 0;
  padding: 4px 8px;
  border: 1px solid rgba(231, 238, 246, 0.22);
  border-radius: 8px 8px 0 0;
  background: rgba(10, 14, 28, 0.42);
  color: inherit;
  font: inherit;
  cursor: pointer;
}

#battle-board.is-shut #battle-board-toggle { border-radius: 8px; }

#battle-board-body {
  overflow: auto;
  min-height: 0;
  padding: 8px;
  border: 1px solid rgba(231, 238, 246, 0.16);
  border-radius: 0 10px 10px 10px;
  background: rgba(10, 14, 28, 0.42);
}

#battle-board-rows {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.battle-roster-fleet,
.battle-roster-ship {
  display: block;
  width: 100%;
  margin: 0;
  padding: 3px 6px 4px;
  border: 0;
  border-left: 2px solid transparent;
  border-radius: 3px;
  background: transparent;
  color: #7ec8ff;
  font: inherit;
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
  user-select: none;
}

.battle-roster-fleet {
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.battle-roster-fleet.is-on,
.battle-roster-ship.is-on {
  border-left-color: currentColor;
  background: rgba(231, 238, 246, 0.1);
}

.battle-roster-fleet:hover,
.battle-roster-ship:hover {
  background: rgba(231, 238, 246, 0.08);
}

.battle-roster-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.battle-roster-hull {
  display: block;
  height: 2px;
  margin-top: 3px;
  background: rgba(231, 238, 246, 0.16);
  overflow: hidden;
}

.battle-roster-hull b {
  display: block;
  height: 100%;
  width: 0;
  background: currentColor;
}

#battle-board-clock {
  margin: 0 0 6px;
  color: rgba(231, 238, 246, 0.8);
}

#battle-board-feed p {
  margin: 4px 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#battle-board-feed .battle-kill b {
  font-weight: 600;
}

#battle-board-feed .battle-kill i {
  margin: 0 6px;
  font-style: normal;
  color: rgba(231, 238, 246, 0.6);
}

#battle-board-feed .battle-kill.is-new {
  animation: battle-kill-in 0.6s ease-out;
}

@keyframes battle-kill-in {
  from { background: rgba(255, 190, 110, 0.28); }
  to { background: transparent; }
}

#battle-flash {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(ellipse at center, rgba(255, 244, 228, 0) 46%, rgba(255, 196, 120, 0.22) 78%, rgba(255, 150, 70, 0.36) 100%);
}

#battle-flash.on {
  animation: battle-flash 180ms ease-out;
}

@keyframes battle-flash {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  #battle-board-feed .battle-kill.is-new,
  #battle-flash.on { animation: none; }
}

@media (max-width: 520px) {
  #battle-board {
    width: min(240px, calc(100vw - 72px - env(safe-area-inset-left)));
    font-size: 11px;
  }
}
