/* Set to 1 to restore the previous ship size without changing slot geometry. */
.online-game {
  --battle-ship-scale: 1.1;
}

/* Wide boards need a separate spacing fix before their ships can grow safely. */
@media (min-width: 1281px), (min-width: 681px) and (min-height: 621px) {
  .online-game {
    --battle-ship-scale: 1;
  }
}

/* Ship artwork is the slot grid. Keep modules in the source-image coordinate space. */
.ship-visual {
  --ship-aspect: 1518 / 1036;
  position: absolute;
  z-index: 2;
  left: 50%;
  width: calc(min(620px, 94%, 52vh) * var(--battle-ship-scale, 1));
  height: auto;
  aspect-ratio: var(--ship-aspect);
  transform: translateX(-50%);
  pointer-events: none;
}

.ship-zone.enemy-zone .ship-visual {
  --ship-aspect: 1536 / 1024;
  top: 10px;
}

.ship-zone.player-zone .ship-visual {
  --ship-aspect: 1518 / 1036;
  bottom: 6px;
}

@media (min-width: 1281px) {
  .ship-zone.enemy-zone .ship-visual {
    top: calc(10px - clamp(78px, 10.5vh, 96px));
  }

  .ship-zone.player-zone .ship-visual {
    bottom: calc(6px - clamp(58px, 7.7vh, 72px));
  }

  .online-game .ship-engineering-bay,
  .online-game .ship-zone.enemy-zone .ship-engineering-bay,
  .online-game .ship-zone.player-zone .ship-engineering-bay {
    --engineering-desktop-width: clamp(64px, 4.2vw, 80px);
    --engineering-row-count: var(--engineering-capacity);
    --engineering-row-gap: 7px;
    position: absolute;
    z-index: 7;
    left: auto;
    right: clamp(18px, 1.6vw, 30px);
    width: var(--engineering-desktop-width);
    max-width: none;
    height: calc(var(--engineering-row-count) * var(--engineering-desktop-width) * 0.833 + (var(--engineering-row-count) - 1) * var(--engineering-row-gap));
    display: grid;
    grid-template-columns: var(--engineering-desktop-width);
    grid-auto-rows: calc(var(--engineering-desktop-width) * 0.833);
    align-items: initial;
    justify-content: initial;
    gap: var(--engineering-row-gap);
    transform: none;
  }

  .online-game .ship-zone.enemy-zone .ship-engineering-bay {
    top: 12px;
    bottom: auto;
    align-content: start;
  }

  .online-game .ship-zone.player-zone .ship-engineering-bay {
    top: auto;
    bottom: 12px;
    align-content: end;
  }

  .online-game .engineering-cell {
    width: var(--engineering-desktop-width);
    height: calc(var(--engineering-desktop-width) * 0.833);
    min-width: var(--engineering-desktop-width);
  }

  .online-game .player-zone .engineering-cell {
    order: calc(-1 * var(--engineering-order, 0));
  }
}

@media (min-width: 1281px) and (max-height: 840px) {
  .ship-zone.enemy-zone .ship-visual {
    top: calc(10px - clamp(98px, 12.7vh, 114px));
  }

  .ship-zone.player-zone .ship-visual {
    bottom: calc(6px - clamp(66px, 8.7vh, 80px));
  }
}

.ship-visual .ship-art,
.ship-zone.enemy-zone .ship-visual .ship-art,
.ship-zone.player-zone .ship-visual .ship-art {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  max-height: none;
  transform: none;
  object-fit: contain;
}

.ship-visual .slot-row {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  max-height: none;
  transform: none;
  pointer-events: none;
}

.ship-visual > .ship-normal-shield,
.ship-zone.enemy-zone .ship-visual > .ship-normal-shield,
.ship-zone.player-zone .ship-visual > .ship-normal-shield {
  position: absolute;
  z-index: 2;
  inset: -7% -6% -5%;
  width: auto;
  height: auto;
  transform: none;
  border: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
  pointer-events: none;
}

/* The field sits in front of the bow: above the player, below the enemy. */
.ship-zone.player-zone .ship-visual > .ship-normal-shield {
  inset: -45% -6% 2%;
}

.ship-zone.enemy-zone .ship-visual > .ship-normal-shield {
  --enemy-shield-offset: 20%;
  /* Move toward the bow without changing the field dimensions. Set to 0% to undo. */
  inset: calc(2% + var(--enemy-shield-offset)) -6% calc(-14% - var(--enemy-shield-offset));
}

.ship-visual > .ship-normal-shield::before,
.ship-visual > .ship-normal-shield::after {
  display: none;
}

.ship-visual .ship-normal-shield-field {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  opacity: var(--ship-shield-opacity, 0);
  filter: saturate(1.08) drop-shadow(0 0 12px rgba(38, 174, 255, 0.5));
  pointer-events: none;
}

.enemy-zone .ship-visual .ship-normal-shield-field {
  transform: rotate(180deg);
}

.ship-visual .slot-wrap {
  --module-width: 12.67%;
  --slot-rotation: 0deg;
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--slot-x);
  display: block;
  width: var(--module-width);
  min-width: 0;
  padding: 0;
  transform: translateX(-50%);
  overflow: visible;
  pointer-events: none;
}

/* Source-image anchors. Fractions scale with the ship and ignore viewport crops. */
.player-zone .ship-visual .slot-wrap { --module-width: 12.52%; }
.player-zone .ship-visual .slot-wrap:nth-child(1) { --slot-x: 37.09%; }
.player-zone .ship-visual .slot-wrap:nth-child(2) { --slot-x: 49.93%; }
.player-zone .ship-visual .slot-wrap:nth-child(3) { --slot-x: 62.78%; }

.enemy-zone .ship-visual .slot-wrap { --module-width: 12.37%; }
.enemy-zone .ship-visual .slot-wrap:nth-child(1) { --slot-x: 37.57%; }
.enemy-zone .ship-visual .slot-wrap:nth-child(2) { --slot-x: 50%; }
.enemy-zone .ship-visual .slot-wrap:nth-child(3) { --slot-x: 62.43%; }

.ship-visual .slot-button,
.ship-zone.enemy-zone .ship-visual .slot-button,
.ship-zone.player-zone .ship-visual .slot-button {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  clip-path: none;
  transform: none;
  overflow: visible;
  pointer-events: auto;
}

.ship-visual .slot-button:hover,
.ship-visual .slot-button.is-legal,
.ship-visual .slot-button.is-selected-target,
.ship-visual .slot-button.has-focus-memory,
.ship-visual .slot-button.has-target-lock,
.ship-visual .slot-button.has-delayed-threat,
.ship-visual .slot-button.has-cutter-threat,
.ship-visual .slot-button.has-missile-threat,
.ship-visual .slot-button.has-missile-splash,
.ship-visual .slot-button.is-breached,
.ship-visual .slot-button.seal-armor-over-breach,
.ship-visual .slot-button.seal-open-breach,
.ship-visual .slot-button.seal-closed-empty,
.ship-visual .slot-button.is-recently-sealed {
  border: 0;
  background: transparent;
  box-shadow: none;
  transform: none;
}

.ship-visual .slot-layers {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.ship-visual .layer {
  position: absolute;
  left: 48%;
  display: grid;
  width: 82%;
  height: auto;
  aspect-ratio: 1;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  clip-path: none;
  overflow: visible;
  isolation: isolate;
  transform: translate(-50%, -50%);
  transform-origin: center;
  pointer-events: none;
}

.ship-zone.enemy-zone .ship-visual .layer {left: 50%;}

/* Old hex-cell skins must never leak behind the artwork modules. */
.ship-visual .layer.armor,
.ship-visual .layer.shield-bay,
.ship-visual .layer.shield-bay.normal-shield,
.ship-visual .layer.shield-bay.military {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  clip-path: none;
}

.player-zone .ship-visual .layer.armor { top: 44%; }
.player-zone .ship-visual .layer.shield-bay { top: 59.1%; }
.enemy-zone .ship-visual .layer.shield-bay { top: 36%; }
.enemy-zone .ship-visual .layer.armor { top: 51%; }

@media (max-width: 420px)  {
  .enemy-zone .ship-visual .layer.armor { top: 54%; }
  .enemy-zone .ship-visual .layer.shield-bay { top: 38.4%; }
}

.ship-visual .layer.empty {
  opacity: 0;
  filter: none;
}

.ship-visual .layer.armor.empty.open-breach {
  opacity: 1;
}

.ship-visual .layer.armor.empty.open-breach::before {
  content: "";
  position: absolute;
  z-index: 1;
  inset: -3%;
  pointer-events: none;
  opacity: 0.98;
  background: url("../../assets/ui/slot-module-breach-20260825.png") center / contain no-repeat;
  transform: rotate(var(--slot-rotation));
  transform-origin: center;
  filter: drop-shadow(0 0 5px rgba(255, 57, 31, 0.42));
  animation: openBreachPulse 2.8s ease-in-out infinite;
}

.ship-visual .layer.armor.empty.open-breach::after {
  content: "";
  position: absolute;
  z-index: 2;
  left: 68%;
  top: 24%;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #fff1ba;
  box-shadow: 0 0 5px #ff6a32;
  opacity: 0;
  pointer-events: none;
  animation: openBreachSpark 5.4s steps(1, end) infinite;
}

.ship-visual .layer.is-layer-candidate {
  opacity: 1;
  border: 2px solid rgba(180, 239, 255, 0.92);
  background: rgba(64, 208, 255, 0.14);
  box-shadow: 0 0 18px rgba(80, 220, 255, 0.82), inset 0 0 14px rgba(80, 220, 255, 0.24);
  clip-path: polygon(31% 3%, 69% 3%, 93% 25%, 93% 75%, 69% 97%, 31% 97%, 7% 75%, 7% 25%);
}

.ship-visual .layer.armor.is-layer-candidate {
  border-color: rgba(255, 201, 91, 0.96);
  background: rgba(255, 165, 45, 0.16);
  box-shadow: 0 0 18px rgba(255, 180, 58, 0.86), inset 0 0 14px rgba(255, 205, 105, 0.24);
}

.ship-visual .layer.armor:not(.empty)::before,
.ship-visual .layer.shield-bay:not(.empty)::before {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 0;
  width: 99%;
  height: 93%;
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  transform: rotate(var(--slot-rotation));
  transform-origin: center;
  pointer-events: none;
  top: 5%;
  left: 3%;
}

.ship-visual .layer.armor:not(.empty)::before {
  background-image: var(--ship-module-art, url("../../assets/ui/slot-module-armor-20260824.png"));
  transform: rotate(var(--slot-rotation)) scale(0.9474);
}

.ship-visual .layer.shield-bay.normal-shield:not(.empty)::before {
  background-image: var(--ship-module-art, url("../../assets/ui/slot-module-normal-20260824.png"));
}

.ship-visual .layer.shield-bay.military:not(.empty)::before {
  background-image: var(--ship-module-art, url("../../assets/ui/slot-module-military-20260824.png"));
}

.ship-visual .layer-icon,
.ship-visual .layer.empty .layer-value {
  display: none;
}

.ship-visual .slot-layers .layer-value,
.ship-visual .slot-layers .layer-value-stacked,
.ship-visual .slot-layers .layer-value-primary,
.ship-visual .slot-layers .layer-value-secondary {
  display: none !important;
}

.ship-visual .slot-status-row {
  position: absolute;
  z-index: 9;
  left: 50%;
  top: var(--status-y);
  display: flex;
  width: max-content;
  max-width: 170%;
  height: 18px;
  min-height: 18px;
  transform: translateX(-50%);
  pointer-events: auto;
}

.player-zone .ship-visual .slot-status-row { --status-y: 18%; }
.enemy-zone .ship-visual .slot-status-row { --status-y: 72%; }

.ship-visual .slot-fx-stack {
  inset: 28% -24% auto;
  min-height: 44%;
}

.ship-defense-bay {
  position: absolute;
  z-index: 12;
  right: 6px;
  top: 50%;
  width: 58px;
  display: block;
  transform: translateY(-50%);
  pointer-events: auto;
}

.defense-slot-list {
  box-sizing: border-box;
  width: 100%;
  display: grid;
  grid-template-rows: repeat(3, 50px);
  gap: 2px;
  overflow: visible;
  color: #dff8ff;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.defense-slot-position {
  width: 100%;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.defense-value-row strong {
  min-width: 0;
  color: currentColor;
  font-family: Roboto, "Arial Narrow", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
  font-weight: 900;
  text-align: right;
  letter-spacing: 0;
}

.defense-slot-card {
  box-sizing: border-box;
  position: relative;
  width: 54px;
  min-width: 44px;
  min-height: 36px;
  padding: 6px 5px 6px 18px;
  display: flex;
  align-items: center;
  overflow: visible;
  color: #dff8ff;
  border: 1px solid rgba(87, 174, 204, 0.22);
  border-radius: 3px;
  background: rgba(2, 13, 22, 0.38);
  box-shadow: inset 2px 0 0 rgba(112, 191, 218, 0.18);
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.defense-slot-card.is-entering {
  animation: defenseSlotEnter 200ms ease-out both;
}

.defense-slot-card.is-leaving {
  animation: defenseSlotExit 200ms ease-in both;
  pointer-events: none;
}

.defense-slot-card.has-2-value {
  min-height: 46px;
}

.defense-slot-card:hover,
.defense-slot-card:focus-visible,
.defense-slot-card.is-selected {
  border-color: rgba(123, 226, 255, 0.74);
  background: rgba(38, 136, 171, 0.13);
  box-shadow: 0 0 10px rgba(73, 197, 239, 0.24), inset 2px 0 0 rgba(123, 226, 255, 0.92);
  outline: none;
}

.defense-slot-card.has-open-breach {
  width: 54px;
  height: 38px;
  min-height: 38px;
  padding: 3px 4px 3px 18px;
  overflow: hidden;
}

.defense-slot-card.is-breached::before {
  content: "";
  position: absolute;
  z-index: 1;
  top: 0;
  bottom: 0;
  left: 0;
  width: 3px;
  background: #e15a3f;
  box-shadow: 0 0 5px rgba(225, 90, 63, 0.48);
  opacity: 0.55;
  animation: defenseBreachEdgePulse 2s ease-in-out infinite;
  pointer-events: none;
}

.defense-slot-number {
  position: absolute;
  left: 5px;
  top: 50%;
  transform: translateY(-50%);
  color: #8eb8c7;
  font-size: 9px;
  line-height: 1;
  font-weight: 900;
}

.defense-slot-card.is-breached .defense-slot-number {
  color: #ff7655;
}

.defense-generator-warning {
  position: absolute;
  right: 2px;
  top: 2px;
  width: 11px;
  height: 11px;
  display: grid;
  place-items: center;
  color: #ff746f;
  border: 1px solid rgba(255, 88, 81, 0.72);
  border-radius: 50%;
  background: rgba(44, 4, 6, 0.92);
  font-size: 8px;
  line-height: 1;
  font-weight: 1000;
  box-shadow: 0 0 6px rgba(255, 70, 64, 0.32);
}

.defense-slot-values {
  min-width: 0;
  width: 100%;
  display: grid;
  gap: 2px;
}

.defense-value-row {
  position: relative;
  min-width: 0;
  min-height: 15px;
  display: grid;
  grid-template-columns: 11px minmax(0, 1fr);
  gap: 3px;
  align-items: center;
  color: #efb75e;
}

.defense-value-row.shield.is-normal {
  color: #70dcff;
}

.defense-value-row.shield.is-military {
  color: #d88cff;
}

.defense-value-row.shield.is-empty {
  color: #57717c;
}

.defense-value-row.breach {
  display: block;
  min-height: 30px;
  color: #ff6d5d;
}

.defense-value-icon {
  position: relative;
  width: 12px;
  height: 12px;
  display: block;
  border: 0;
  background: url("../../assets/ui/defense-armor-hud.svg") center / contain no-repeat;
  transform: none;
  filter: drop-shadow(0 0 3px color-mix(in srgb, currentColor 48%, transparent));
}

.defense-value-row.shield .defense-value-icon {
  background-image: url("../../assets/ui/defense-normal-shield-hud.svg");
}

.defense-value-row.shield.is-military .defense-value-icon {
  background-image: url("../../assets/ui/defense-military-shield-hud.svg");
}

.defense-value-row.breach .defense-value-icon {
  position: absolute;
  top: 50%;
  right: 0;
  width: 28px;
  height: 30px;
  background-image: url("../../assets/ui/slot-module-breach-20260825.png");
  transform: translateY(-50%);
  filter: brightness(1.08) drop-shadow(0 0 3px rgba(255, 70, 43, 0.5));
}

.defense-value-row strong {
  font-size: 14px;
  line-height: 1;
}

.ship-visual .slot-button.is-defense-inspected .layer:not(.empty)::before {
  filter: brightness(1.22) drop-shadow(0 0 7px rgba(119, 224, 255, 0.82));
}

.ship-visual .slot-button.is-defense-inspected .layer.armor.empty.open-breach::before {
  filter: brightness(1.28) drop-shadow(0 0 8px rgba(255, 82, 52, 0.92));
}

.defense-detail-modal {
  position: fixed;
  z-index: 190;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  animation: defenseDetailBackdropIn 190ms ease-out both;
}

body.page-match #app > main.game.online-game > .defense-detail-modal {
  position: fixed;
  z-index: 190;
  inset: 0;
}

.defense-detail-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: rgba(0, 6, 12, 0.72);
  backdrop-filter: blur(3px);
  cursor: default;
}

.defense-detail-sheet {
  position: relative;
  z-index: 1;
  width: min(380px, calc(100vw - 28px));
  max-height: min(45dvh, 320px);
  padding: 14px 16px 16px;
  overflow-y: auto;
  color: #eaf9ff;
  border: 1px solid rgba(74, 202, 242, 0.68);
  border-radius: 4px;
  background: linear-gradient(155deg, rgba(5, 28, 42, 0.98), rgba(2, 10, 18, 0.99));
  box-shadow: 0 0 34px rgba(45, 178, 232, 0.28), 0 20px 54px rgba(0, 0, 0, 0.72);
  clip-path: polygon(12px 0, calc(100% - 20px) 0, 100% 20px, 100% calc(100% - 12px), calc(100% - 12px) 100%, 20px 100%, 0 calc(100% - 20px), 0 12px);
  animation: defenseDetailSheetIn 210ms ease-out both;
}

.defense-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.defense-detail-head h2 {
  margin: 0;
  color: #dcf8ff;
  font-size: 1.05rem;
  line-height: 1;
  text-transform: uppercase;
}

.defense-detail-head h2 span {
  color: #5fc8e9;
}

.defense-detail-close {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  display: grid;
  place-items: center;
  padding: 0;
  color: #bdefff;
  border: 1px solid rgba(82, 200, 239, 0.52);
  border-radius: 3px;
  background: rgba(7, 31, 45, 0.92);
  font: inherit;
  font-size: 1.45rem;
  cursor: pointer;
}

.defense-detail-values {
  margin: 12px 0 0;
  display: grid;
  gap: 8px;
}

.defense-detail-section {
  min-height: 48px;
  padding: 9px 10px;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  border-left: 2px solid #e6a635;
  background: rgba(25, 20, 9, 0.42);
}

.defense-detail-section.defense-detail-shield {
  border-left-color: #45cfff;
  background: rgba(4, 30, 46, 0.5);
}

.defense-detail-section.defense-detail-shield.is-military {
  border-left-color: #d568ff;
  background: rgba(35, 7, 50, 0.48);
}

.defense-detail-icon {
  width: 28px;
  height: 28px;
  background: url("../../assets/ui/defense-armor-hud.svg") center / contain no-repeat;
}

.defense-detail-shield .defense-detail-icon {
  background-image: url("../../assets/ui/defense-normal-shield-hud.svg");
}

.defense-detail-shield.is-military .defense-detail-icon {
  background-image: url("../../assets/ui/defense-military-shield-hud.svg");
}

.defense-detail-section-body {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.defense-detail-line {
  min-width: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  color: #a9c7d2;
  font-size: 0.75rem;
  line-height: 1.15;
}

.defense-detail-line strong {
  min-width: 0;
  overflow: hidden;
  color: #e9f9ff;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.defense-detail-line b {
  flex: none;
  color: #fff1c2;
  font-variant-numeric: tabular-nums;
}

.defense-detail-section-title {
  margin-bottom: 2px;
}

.defense-detail-meter {
  height: 3px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
}

.defense-detail-meter i {
  display: block;
  height: 100%;
  background: #e0a33d;
}

.defense-detail-shield .defense-detail-meter i {
  background: #48d1ff;
}

.defense-detail-shield.is-military .defense-detail-meter i {
  background: #d36cff;
}

.defense-detail-generator-meter {
  opacity: 0.72;
}

.defense-detail-breach {
  min-height: 42px;
  padding: 7px 10px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  color: #ffb1a7;
  border-left: 2px solid #ff584b;
  background: rgba(50, 5, 8, 0.28);
}

.defense-detail-breach-icon {
  width: 21px;
  height: 28px;
  background: url("../../assets/ui/slot-module-breach-20260825.png") center / contain no-repeat;
  filter: drop-shadow(0 0 4px rgba(255, 65, 42, 0.55));
}

.defense-detail-breach div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.defense-detail-breach strong {
  color: #ff8f83;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.defense-detail-breach span:last-child {
  color: #cfa5a0;
  font-size: 0.7rem;
  line-height: 1.2;
}

.defense-detail-effects h3 {
  margin: 4px 0 8px;
  color: #dcf8ff;
  font-size: 0.8rem;
  line-height: 1.2;
  text-transform: uppercase;
}

.defense-detail-status-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.defense-detail-status {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 10px 0;
  border-top: 1px solid rgba(113, 186, 210, 0.2);
}

.online-game .defense-detail-status .defense-status {
  width: 30px;
  height: 30px;
  min-width: 30px;
  pointer-events: none;
  cursor: default;
}

.defense-detail-status > div {
  min-width: 0;
  overflow-wrap: anywhere;
}

.defense-detail-status strong {
  color: #e9f9ff;
  font-size: 0.8rem;
  line-height: 1.3;
}

.defense-detail-status p {
  margin: 4px 0 0;
  color: #a9c7d2;
  font-size: 0.8rem;
  line-height: 1.4;
}

@keyframes defenseSlotEnter {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes defenseSlotExit {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(12px); }
}

@keyframes defenseBreachEdgePulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

@keyframes openBreachPulse {
  0%, 100% { opacity: 0.94; filter: brightness(0.96) drop-shadow(0 0 4px rgba(255, 57, 31, 0.34)); }
  50% { opacity: 1; filter: brightness(1.06) drop-shadow(0 0 6px rgba(255, 57, 31, 0.48)); }
}

@keyframes openBreachSpark {
  0%, 88%, 100% { opacity: 0; }
  90% { opacity: 0.9; }
  93% { opacity: 0; }
}

@keyframes defenseDetailBackdropIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes defenseDetailSheetIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .defense-slot-card,
  .defense-slot-card.is-breached::before,
  .defense-detail-modal,
  .defense-detail-sheet,
  .ship-visual .layer.armor.empty.open-breach::before,
  .ship-visual .layer.armor.empty.open-breach::after {
    animation: none;
  }
}

@media (max-width: 1280px) and (max-height: 620px) and (orientation: landscape) {
  .ship-visual,
  .ship-zone.enemy-zone .ship-visual,
  .ship-zone.player-zone .ship-visual {
    left: 50%;
    top: 50%;
    bottom: auto;
    width: calc(min(250px, 68vh) * var(--battle-ship-scale, 1));
    height: auto;
    aspect-ratio: var(--ship-aspect);
    transform: translate(-50%, -50%) rotate(-90deg);
    transform-origin: center;
  }

  .ship-visual .ship-art {
    opacity: 0.84;
  }

  .ship-visual .slot-status-badge,
  .ship-visual .slot-fx-label {
    transform: rotate(90deg);
  }

  .ship-defense-bay {
    right: 2px;
    width: 48px;
  }

  .defense-slot-card {
    min-height: 34px;
    padding: 5px 4px 5px 15px;
  }

  .defense-slot-card.has-2-value {
    min-height: 42px;
  }

  .defense-slot-number {
    font-size: 7px;
  }

  .defense-value-row {
    min-height: 11px;
    grid-template-columns: 8px minmax(0, 1fr);
    gap: 2px;
  }

  .defense-value-icon {
    width: 7px;
    height: 7px;
  }

  .defense-value-row strong {
    font-size: 11px;
  }
}

@media (max-width: 680px) and (orientation: portrait) {
  .ship-zone {
    --defense-rail-width: clamp(52px, 15.5vw, 60px);
  }

  .ship-visual,
  .ship-zone.enemy-zone .ship-visual,
  .ship-zone.player-zone .ship-visual {
    width: calc(min(
      360px,
      calc(100% - var(--defense-rail-width) - var(--defense-rail-width))
    ) * var(--battle-ship-scale, 1));
    height: auto;
    aspect-ratio: var(--ship-aspect);
    max-height: none;
    transform: translateX(-50%);
  }

  .ship-zone.enemy-zone .ship-visual {
    /*top: var(--ship-zone-edge-offset);*/
    bottom: auto;
  }

  .ship-zone.player-zone .ship-visual {
    top: auto;
    /*bottom: var(--ship-zone-edge-offset);*/
  }

  .ship-defense-bay {
    right: 1px;
    width: var(--defense-rail-width);
  }

  .ship-zone.enemy-zone .ship-defense-bay {
    transform: translateY(calc(-50% - 5px));
  }

  .ship-zone.player-zone .ship-defense-bay {
    transform: translateY(calc(-50% + 5px));
  }

  .defense-slot-card {
    min-height: 36px;
    padding: 5px 5px 5px 17px;
  }

  .defense-slot-card.has-2-value {
    min-height: 46px;
  }

  .defense-value-row {
    min-height: 13px;
    grid-template-columns: 10px minmax(0, 1fr);
    gap: 3px;
  }

  .defense-value-icon {
    width: 9px;
    height: 9px;
  }

  .defense-value-row strong {
    font-size: 15px;
  }

  .defense-detail-modal {
    place-items: end center;
    padding: 8px;
  }

  .defense-detail-sheet {
    width: calc(100% - 16px);
    max-height: min(45dvh, 320px);
    padding: 14px 12px max(14px, env(safe-area-inset-bottom));
    clip-path: polygon(12px 0, calc(100% - 20px) 0, 100% 20px, 100% calc(100% - 10px), calc(100% - 10px) 100%, 12px 100%, 0 calc(100% - 12px), 0 12px);
  }

  .ship-visual .slot-status-row {
    height: 16px;
    min-height: 16px;
  }

}

/* Unified slot telemetry. The rail owns all persistent slot text and numbers. */
.online-game {
  --defense-rail-width: clamp(82px, 23vw, 100px);
  --engineering-rail-width: clamp(34px, 9vw, 40px);
  --engineering-display-width: calc(var(--engineering-rail-width) * 1.4);
  --battle-rail-gap: 4px;
}

.online-game .ship-defense-bay {
  position: absolute;
  left: 4px;
  right: auto;
  top: 50%;
  bottom: auto;
  width: var(--defense-rail-width);
  margin: 0;
  transform: translateY(-50%);
}

.online-game .engineering-cell {
  width: calc(var(--engineering-cell-size) * 1.4);
}

.online-game .defense-slot-list {
  height: auto;
  grid-template-rows: none;
  grid-auto-rows: minmax(38px, auto);
  gap: 4px;
}

.online-game .defense-slot-position {
  height: auto;
  min-height: 38px;
  justify-content: flex-start;
  align-items: center;
}

.online-game .player-zone .defense-slot-position:nth-child(1) { grid-row: 3; }
.online-game .player-zone .defense-slot-position:nth-child(2) { grid-row: 2; }
.online-game .player-zone .defense-slot-position:nth-child(3) { grid-row: 1; }

.online-game .defense-slot-card {
  --defense-card-border: rgba(75, 155, 184, 0.34);
  --defense-card-surface: rgba(1, 12, 21, 0.78);
  position: relative;
  isolation: isolate;
  box-sizing: border-box;
  width: 100%;
  height: auto;
  min-width: 0;
  min-height: 38px;
  padding: 3px 4px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 18px;
  grid-template-rows: auto;
  align-items: center;
  align-content: center;
  gap: 4px;
  overflow: visible;
  color: #dff8ff;
  border: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  cursor: default;
  transition: min-height 140ms ease, width 140ms ease, padding 140ms ease;
}

/* Clip only the shell, keeping status indicators and focus targets intact. */
.online-game .defense-slot-card::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -1px;
  border: 1px solid var(--defense-card-border);
  background: var(--defense-card-surface);
  clip-path: polygon(0 0, calc(100% - 6px) 0, 100% 6px, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%);
  pointer-events: none;
}

.online-game .defense-slot-card.is-status-only {
  width: max-content;
  max-width: 100%;
  min-width: 36px;
  min-height: 38px;
}

.online-game .defense-slot-card.has-one-layer {
  min-height: 48px;
}

.online-game .defense-slot-card.has-two-layers {
  min-height: 62px;
}

.online-game .defense-slot-open {
  position: absolute;
  z-index: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: inherit;
  background: transparent;
  cursor: pointer;
}

.online-game .defense-slot-open:focus-visible {
  outline: 2px solid rgba(123, 226, 255, 0.92);
  outline-offset: -2px;
}

.online-game .defense-slot-number,
.online-game .defense-slot-values {
  pointer-events: none;
}

.online-game .defense-slot-card:hover,
.online-game .defense-slot-card:has(.defense-slot-open:focus-visible),
.online-game .defense-slot-card.is-selected {
  --defense-card-border: rgba(123, 226, 255, 0.74);
  --defense-card-surface: rgba(7, 32, 46, 0.88);
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.online-game .defense-slot-card.is-breached::before {
  z-index: 4;
  left: auto;
  right: -1px;
  top: -1px;
  bottom: -1px;
  width: 9px;
  clip-path: polygon(0 0, 3px 0, 100% 6px, 100% calc(100% - 6px), 3px 100%, 0 100%, 6px calc(100% - 7.25px), 6px 7.25px);
}

.online-game .defense-slot-number {
  position: relative;
  z-index: 3;
  grid-column: 2;
  grid-row: 1;
  left: auto;
  top: auto;
  transform: none;
  justify-self: center;
  align-self: center;
  color: #b7deec;
  font-size: 14px;
  line-height: 1;
  font-weight: 1000;
}

.online-game .defense-slot-values {
  position: relative;
  z-index: 2;
  box-sizing: border-box;
  grid-column: 1;
  grid-row: 1;
  width: 100%;
  min-height: 27px;
  padding-left: 0;
  display: grid;
  align-content: center;
  gap: 3px;
}

.online-game .defense-value-row {
  min-height: 12px;
  display: block;
  color: #d7a23c;
}

.online-game .defense-value-row.shield.is-normal {
  color: #41c9f4;
}

.online-game .defense-value-row.shield.is-military {
  color: #bd66ed;
}

.online-game .defense-value-row.shield-module {
  color: #9cdeb9;
}

.online-game .defense-value-label {
  display: block;
  color: #dff8ff;
  font-size: 10px;
  line-height: 12px;
  font-weight: 600;
  font-family: Roboto, "Arial Narrow", Arial, sans-serif;
  white-space: nowrap;
}

.online-game .ship-zone:is(.enemy-zone, .player-zone) .ship-defense-bay:has(.shield-module) {
  width: 128px;
}

.online-game .defense-value-row:has(.defense-value-label) {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 2px;
  align-items: center;
}

@media (max-width: 600px) {
  .online-game .ship-zone:is(.enemy-zone, .player-zone) .ship-defense-bay:has(.shield-module) {
    width: 120px;
  }
  .online-game .ship-zone .defense-slot-card:has(.shield-module) {
    padding-block: 1px;
    grid-template-columns: minmax(0, 1fr) 18px;
  }
  .online-game .ship-zone .defense-slot-card.status-count-1:has(.shield-module) .defense-status-grid {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    align-self: end;
  }
  .online-game .ship-zone .defense-slot-card.status-count-1:has(.shield-module) .defense-slot-number {
    grid-row: 1;
    align-self: start;
  }
}

.online-game .defense-value-row.is-hit .defense-value-meter {
  animation: defense-meter-hit 450ms ease-out both;
  animation-delay: var(--defense-hit-delay, 0ms);
}

@keyframes defense-meter-hit {
  from { outline: 2px solid #ff786a; filter: brightness(1.7); }
  to { outline: 2px solid transparent; filter: brightness(1); }
}

@media (prefers-reduced-motion: reduce) {
  .online-game .defense-value-row.is-hit .defense-value-meter {
    animation: none;
    outline: 1px solid #ff786a;
  }
}

.online-game .defense-value-meter {
  position: relative;
  box-sizing: border-box;
  width: 100%;
  height: 13px;
  display: grid;
  place-items: center end;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, currentColor 58%, transparent);
  background: rgba(0, 0, 0, 0.6);
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.78);
}

.online-game .defense-value-meter i {
  position: absolute;
  z-index: 0;
  inset: 0 auto 0 0;
  max-width: 100%;
  background: color-mix(in srgb, currentColor 62%, transparent);
  box-shadow: 0 0 7px currentColor;
}

.online-game .defense-value-meter strong {
  position: relative;
  z-index: 1;
  min-width: 0;
  padding: 0 3px;
  color: #fff;
  font-family: Roboto, "Arial Narrow", Arial, sans-serif;
  font-size: 11px;
  line-height: 11px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  text-align: right;
  text-shadow: 0 1px 2px #000, 0 0 3px #000;
}

.online-game .defense-status-grid {
  position: relative;
  z-index: 5;
  grid-column: 1 / -1;
  grid-row: 2;
  width: max-content;
  min-height: 22px;
  margin-left: 0;
  display: grid;
  grid-template-columns: repeat(3, 22px);
  grid-auto-rows: 22px;
  justify-content: end;
  align-content: end;
  gap: 4px;
}

.online-game .slot-statuses:empty {
  display: none;
}

.online-game .defense-slot-card.is-status-only .defense-status-grid {
  grid-column: 1;
  grid-row: 1;
  margin-left: 0;
  justify-self: start;
}

.online-game .defense-slot-card.status-count-1 .defense-status-grid {
  grid-template-columns: repeat(1, 22px);
}

.online-game .defense-slot-card.status-count-2 .defense-status-grid {
  grid-template-columns: repeat(2, 22px);
}

.online-game .defense-slot-card.status-count-3 .defense-status-grid,
.online-game .defense-slot-card.status-count-4 .defense-status-grid,
.online-game .defense-slot-card.status-count-5 .defense-status-grid {
  grid-template-columns: repeat(3, 22px);
}

.online-game .defense-status {
  position: relative;
  box-sizing: border-box;
  width: 22px;
  height: 22px;
  min-width: 22px;
  display: grid;
  place-items: center;
  color: #dff8ff;
  border: 1px solid rgba(113, 186, 210, 0.42);
  border-radius: 50%;
  background: rgba(2, 13, 22, 0.92);
  font-family: Roboto, Arial, sans-serif;
  font-size: 7px;
  line-height: 1;
  font-weight: 1000;
  letter-spacing: 0;
  cursor: help;
}

.online-game .defense-status-grid .defense-status {
  margin: 0;
  padding: 0;
  cursor: pointer;
}

.online-game .defense-status:focus-visible {
  outline: 2px solid #dff8ff;
  outline-offset: 1px;
}

.online-game .defense-status.is-focus {
  color: #e19aff;
  border: 2px solid #be62e8;
  background: rgba(32, 5, 45, 0.76);
  font-size: 8px;
}

.online-game .defense-status.is-targetLock,
.online-game .defense-status.is-target-lock {
  color: #ffd15c;
  border-color: #d8a52d;
  background:
    linear-gradient(#d8a52d, #d8a52d) center / 2px 100% no-repeat,
    linear-gradient(90deg, #d8a52d, #d8a52d) center / 100% 2px no-repeat,
    radial-gradient(circle, transparent 35%, #d8a52d 38% 47%, transparent 50%);
  font-size: 0;
}

.online-game .defense-status.is-cutter {
  color: #ffb26d;
  border-radius: 2px 8px 2px 8px;
  border-color: #e36b43;
  background: rgba(48, 12, 5, 0.9);
  box-shadow: inset 0 0 5px rgba(227, 107, 67, 0.34);
  font-size: 9px;
}

.online-game .defense-status.is-delayedDoomsday,
.online-game .defense-status.is-doomsday {
  color: #ffdb80;
  border-radius: 3px;
  border-color: #e56446;
  background: rgba(52, 9, 8, 0.92);
  font-size: 6px;
}

.online-game .defense-status.is-delayedMissile,
.online-game .defense-status.is-missile,
.online-game .defense-status.is-missileSplash,
.online-game .defense-status.is-missile-splash {
  color: #ffc46b;
  border-color: #cc7d38;
  border-radius: 3px;
  font-size: 6px;
}

.online-game .defense-generator-warning {
  z-index: 7;
  left: auto;
  right: -3px;
  top: -4px;
}

.online-game .defense-sealed-confirmation {
  position: absolute;
  z-index: 8;
  right: -4px;
  bottom: -4px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  color: #bffcff;
  border: 1px solid rgba(75, 224, 238, 0.84);
  border-radius: 50%;
  background: rgba(1, 45, 48, 0.96);
  font-size: 12px;
  line-height: 1;
  font-weight: 1000;
  pointer-events: auto;
}

.online-game .defense-transient-event {
  position: absolute;
  z-index: 8;
  left: 4px;
  right: 4px;
  top: 50%;
  min-height: 24px;
  display: grid;
  place-items: center;
  padding: 2px 3px;
  transform: translateY(-50%);
  color: #fff;
  border: 1px solid rgba(255, 114, 75, 0.88);
  border-radius: 2px;
  background: rgba(44, 8, 5, 0.94);
  font-size: 9px;
  line-height: 1.05;
  font-weight: 1000;
  text-align: center;
  pointer-events: none;
  animation: defenseTransientEvent 500ms ease-out both;
}

@keyframes defenseTransientEvent {
  from { opacity: 0; transform: translateY(-42%) scale(0.96); }
  to { opacity: 1; transform: translateY(-50%) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .online-game .defense-transient-event {
    animation: none;
  }
}

@media (max-width: 680px) and (orientation: portrait) {
  .online-game {
    --battle-action-top: calc(50dvh - 81px);
    --battle-action-height: 77px;
    --battle-action-clearance: 8px;
  }

  .online-game .ship-zone {
    --defense-rail-width: 64px;
    --engineering-rail-width: clamp(34px, 9vw, 40px);
    --ship-previous-width: min(360px, calc(100% - clamp(82px, 23vw, 100px) - var(--engineering-rail-width) - var(--battle-rail-gap) * 2));
  }

  .online-game .ship-visual,
  .online-game .ship-zone.enemy-zone .ship-visual,
  .online-game .ship-zone.player-zone .ship-visual {
    left: 50%;
    width: calc(var(--ship-previous-width) * 1.1 * var(--battle-ship-scale, 1));
  }

  /* Preserve the calibrated pixel offset in the scaled source-image space. */
  .online-game .ship-zone.enemy-zone .ship-visual .slot-row {
    top: calc(var(--ship-zone-edge-offset) * var(--battle-ship-scale, 1));
  }

  .online-game .ship-defense-bay,
  .online-game .ship-zone.enemy-zone .ship-defense-bay,
  .online-game .ship-zone.player-zone .ship-defense-bay {
    left: 2px;
    right: auto;
    top: 50%;
    width: var(--defense-rail-width);
    transform: translateY(-50%);
  }

  .online-game .ship-zone.enemy-zone .defense-slots-rail {
    top: 4px;
    bottom: auto;
    transform: none;
  }

  .online-game .ship-zone.player-zone .defense-slots-rail {
    top: auto;
    bottom: 5px;
    transform: none;
  }

  /* Keep the full three-slot stack inside the menu-to-hand interval at 360x660. */
  .online-game .defense-slot-list {
    grid-auto-rows: minmax(52px, auto);
    gap: 4px;
  }

  .online-game .defense-slot-card,
  .online-game .defense-slot-card.has-one-layer,
  .online-game .defense-slot-card.has-two-layers {
    min-height: 44px;
    padding: 3px;
    grid-template-columns: minmax(0, 1fr) 10px;
    gap: 2px;
  }

  .online-game .defense-slot-number {
    grid-row: 1 / 3;
    font-size: 12px;
  }

.online-game .defense-slot-card.status-count-0 .defense-slot-number {
  grid-row: 1;
}

  .online-game .defense-slot-values {
    min-height: 0;
    gap: 2px;
  }

  .online-game .defense-value-meter {
    height: 12px;
  }

  .online-game .defense-value-meter strong {
    padding: 0 1px;
    font-size: 10px;
    line-height: 10px;
  }

  .online-game .defense-status-grid,
  .online-game .defense-slot-card[class*="status-count-"] .defense-status-grid {
    grid-column: 1;
    min-height: 16px;
    grid-template-columns: repeat(3, 16px);
    grid-auto-rows: 16px;
    justify-content: start;
    gap: 2px;
  }

  .online-game .defense-slot-card.status-count-1 .defense-status-grid {
    grid-template-columns: 16px;
  }

  .online-game .defense-slot-card.status-count-2 .defense-status-grid {
    grid-template-columns: repeat(2, 16px);
  }

  .online-game .defense-status {
    width: 16px;
    height: 16px;
    min-width: 16px;
  }

  .online-game .defense-status.is-focus {
    border-width: 1px;
    font-size: 7px;
  }

  .online-game .ship-engineering-bay,
  .online-game .ship-zone.enemy-zone .ship-engineering-bay,
  .online-game .ship-zone.player-zone .ship-engineering-bay {
    --engineering-row-count: var(--engineering-capacity);
    --engineering-row-gap: 2px;
    height: calc(var(--engineering-row-count) * var(--engineering-display-width) * 0.833 + (var(--engineering-row-count) - 1) * var(--engineering-row-gap));
    position: absolute;
    left: auto;
    right: 12px;
    top: auto;
    bottom: auto;
    width: var(--engineering-display-width);
    grid-template-columns: var(--engineering-display-width);
    grid-auto-rows: calc(var(--engineering-display-width) * 0.833);
    gap: 2px;
    transform: none;
  }

  /* The action and both rails share viewport anchors; content cannot shift them. */
  .online-game .primary-action-slot:has(> .battle-action-button) {
    top: var(--battle-action-top);
    height: var(--battle-action-height);
  }

  .online-game .ship-zone.enemy-zone .ship-engineering-bay {
    top: 4px;
    bottom: auto;
  }

  .online-game .ship-zone.player-zone .ship-engineering-bay {
    top: auto;
    bottom: 5px;
  }

  body:has(.online-game .ship-engineering-bay :is(:hover, :focus)) > .floating-card-tooltip {
    /* Override the pointer-based inline position only for engineering tooltips. */
    left: auto !important;
    right: calc(16px + 64px + 8px);
    width: min(220px, calc(100vw - 102px));
    transform: translateY(calc(-100% - 12px));
    animation: none;
  }

  .online-game .engineering-cell {
    width: var(--engineering-display-width);
    height: calc(var(--engineering-display-width) * 0.833);
    min-width: var(--engineering-display-width);
    background-size: 100% 100%;
  }

  .online-game .engineering-cell.is-empty .engineering-cell-icon {
    width: 12.6px;
    height: 11.2px;
    background-size: 100% 100%;
  }

  .online-game .engineering-cell:not(.is-empty):not(.engineering-reactor) .engineering-cell-icon {
    font-size: 14px;
  }

  .online-game .engineering-cell:not(.is-empty):not(.engineering-reactor) .engineering-cell-value {
    min-width: 20px;
    max-width: 39px;
    padding: 1px 4px;
    font-size: 10px;
  }

  .online-game .engineering-cell.is-doomsday .engineering-cell-icon {
    top: 4px;
    font-size: 10px;
    line-height: 10px;
  }
}

@media (max-width: 1280px) and (max-height: 620px) and (orientation: landscape) {
  .online-game .ship-defense-bay,
  .online-game .ship-zone.enemy-zone .ship-defense-bay,
  .online-game .ship-zone.player-zone .ship-defense-bay {
    left: 2px;
    right: auto;
    top: 50%;
    width: clamp(76px, 11vw, 94px);
    transform: translateY(-50%);
  }

  .online-game .defense-slot-list {
    grid-template-rows: repeat(3, clamp(62px, 19vh, 74px));
  }

  .online-game .ship-engineering-bay,
  .online-game .ship-zone.enemy-zone .ship-engineering-bay,
  .online-game .ship-zone.player-zone .ship-engineering-bay {
    --engineering-row-count: var(--engineering-capacity);
    --engineering-row-gap: 4px;
    height: calc(var(--engineering-row-count) * var(--engineering-display-width) * 0.833 + (var(--engineering-row-count) - 1) * var(--engineering-row-gap));
    position: absolute;
    left: auto;
    right: 2px;
    top: 50%;
    bottom: auto;
    width: var(--engineering-display-width);
    max-width: var(--engineering-display-width);
    display: grid;
    grid-template-columns: var(--engineering-display-width);
    grid-auto-rows: calc(var(--engineering-display-width) * 0.833);
    gap: 4px;
    transform: translateY(-50%);
  }

  .online-game .engineering-cell {
    width: var(--engineering-display-width);
    height: calc(var(--engineering-display-width) * 0.833);
    min-width: var(--engineering-display-width);
  }
}

.online-game .hud-reactor-bar {
  --reactor-color: #41c9f4;
  position: relative;
  box-sizing: border-box;
  width: 86%;
  height: 14px;
  min-height: 0;
  margin: 4px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  gap: 0;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--reactor-color) 58%, transparent);
  background: rgba(0, 0, 0, 0.75);
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.78);
  clip-path: polygon(0 0, 100% 0, calc(100% - 12px) 100%, 12px 100%);
}

@media (max-width: 1280px) and (max-height: 420px) and (orientation: landscape) {
  .online-game .ship-engineering-bay,
  .online-game .ship-zone.enemy-zone .ship-engineering-bay,
  .online-game .ship-zone.player-zone .ship-engineering-bay {
    --engineering-row-count: var(--engineering-paired-rows);
    width: calc(var(--engineering-display-width) * 2 + 4px);
    max-width: none;
    grid-template-columns: repeat(2, var(--engineering-display-width));
  }
}

@media (min-width: 681px) and (max-width: 1280px) and (min-height: 621px) {
  .online-game .ship-zone.enemy-zone .ship-engineering-bay {
    top: 12px;
  }

  .online-game .ship-zone.player-zone .ship-engineering-bay {
    top: auto;
    bottom: 5px;
  }
}

.online-game .hud-reactor-bar.is-impaired { --reactor-color: #ed795e; }

/* Empty rail space must not intercept ship targets. Only mounted cells can. */
.online-game .ship-engineering-bay { pointer-events: none; }
.online-game .engineering-cell { pointer-events: auto; }

@media (max-width: 1280px) {
  .online-game .ship-zone.player-zone .ship-engineering-bay {
    align-content: end;
  }

  .online-game .player-zone .engineering-cell {
    order: calc(-1 * var(--engineering-order, 0));
  }
}

.online-game .hud-reactor-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--reactor-fill);
  max-width: 100%;
  background: color-mix(in srgb, var(--reactor-color) 62%, transparent);
}

.online-game .defense-status.has-custom-image {
  background: transparent;
  border-color: transparent;
  border-radius: 0;
  box-shadow: none;
}
.online-game .defense-status-image {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}
.online-game .has-custom-image .defense-status-count {
  z-index: 1;
  align-self: end;
  justify-self: end;
  color: #fff;
  text-shadow: 0 1px 2px #000, 0 0 3px #000;
}
.online-game .engineering-cell.has-custom-image,
.online-game .engineering-cell.engineering-trap.is-hidden {
  box-sizing: border-box;
  padding: 3px 5px;
  border: 0;
  color: #d8f4ff;
  background: transparent url("../../assets/ui/engineering-cell-frame.svg") center / 100% 100% no-repeat;
  clip-path: none;
  box-shadow: none;
}
.online-game .engineering-cell.has-custom-image::before,
.online-game .engineering-cell.engineering-trap.is-hidden::before {
  display: none;
}
.online-game .engineering-cell.engineering-trap.is-hidden .engineering-cell-icon {
  display: none;
}
.online-game .engineering-cell.engineering-trap.is-hidden .engineering-cell-value {
  min-width: 0;
  max-width: none;
  margin: 0;
  padding: 0;
  align-self: center;
  justify-self: center;
  overflow: visible;
  color: #d8f4ff;
  background: transparent;
  clip-path: none;
  font-size: clamp(16px, 1.3vw, 22px);
  line-height: 1;
  text-shadow: 0 1px 2px #000, 0 0 8px rgba(102, 220, 255, 0.58);
}
.online-game .engineering-cell-art {
  position: absolute;
  inset: 4px 5px;
  width: calc(100% - 10px);
  height: calc(100% - 8px);
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.78));
  pointer-events: none;
}
.online-game .engineering-cell.has-custom-image .engineering-cell-value {
  position: relative;
  z-index: 1;
  align-self: end;
  margin-bottom: 3px;
  color: #fff;
  text-shadow: 0 1px 2px #000, 0 0 3px #000;
}

.online-game .hud-reactor-value {
  position: relative;
  z-index: 1;
  padding: 0 3px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: #fff;
  font-family: "Roboto Condensed", Roboto, "Arial Narrow", Arial, sans-serif;
  font-size: 10px;
  line-height: 10px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  text-shadow: 0 1px 2px #000, 0 0 3px #000;
}

.online-game .hud-reactor-icon {
  color: #ffd24f;
  font-size: 9px;
  line-height: 1;
  filter: drop-shadow(0 0 3px rgba(255, 210, 79, 0.72));
}

@media (max-width: 1280px) {
  .online-game .left-rail > .hud-panel { overflow: visible; }

  .online-game .left-rail .hud-reactor-bar {
    position: absolute;
    top: 100%;
    left: 6.714286%;
    right: 6.714286%;
    width: auto;
    height: 12px;
    margin: 0;
    transform: translateX(-0.5px);
  }
}
