:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #f5f7fb;
  background: #050814;

  --hud-blue-950: #030814;
  --hud-blue-900: #071427;
  --hud-blue-800: #0b213c;
  --hud-blue-700: #12355f;
  --hud-blue-500: #1e7fd8;
  --hud-cyan: #31c9ff;
  --hud-cyan-soft: rgba(49, 201, 255, 0.34);
  --hud-gold: #f5c84e;
  --hud-gold-soft: rgba(245, 200, 78, 0.44);
  --hud-red: #ff674f;
  --hud-orange: #ff9d3f;
  --hud-green: #61df7a;
  --hud-violet: #b46cff;
  --hud-text: #f5f7fb;
  --hud-muted: #a9bad4;
  --hud-dim: #6f84a3;
  --hud-panel: rgba(5, 17, 36, 0.88);
  --hud-panel-strong: rgba(8, 25, 50, 0.96);
  --hud-line: rgba(149, 200, 255, 0.26);
  --hud-line-strong: rgba(149, 200, 255, 0.48);
  --hud-radius: 8px;
  --hud-cut: 12px;
  --hud-gap: clamp(6px, 1.8vw, 12px);
  --hud-shadow: 0 16px 42px rgba(0, 0, 0, 0.42);
  --hud-inner: inset 0 1px 0 rgba(255, 255, 255, 0.13), inset 0 -10px 20px rgba(0, 0, 0, 0.18);
  --hud-transition: 150ms ease;
  --hud-kit: url("/assets/hud/hud-kit-reference.jpg");
  --hud-top: url("/assets/hud/top-bar-reference.jpg");
  --hud-z-model: 1;
  --hud-z-canvas: 2;
  --hud-z-panel: 3;
  --hud-z-rail: 4;
  --hud-z-top: 5;
  --hud-z-bottom: 6;
  --hud-z-toast: 9;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #050814;
  touch-action: none;
}

button {
  min-height: 44px;
  border: 1px solid var(--hud-line);
  border-radius: 7px;
  background:
    linear-gradient(180deg, rgba(36, 100, 160, 0.92), rgba(7, 30, 61, 0.96)),
    var(--hud-blue-800);
  box-shadow: var(--hud-inner), 0 8px 20px rgba(0, 0, 0, 0.24);
  color: var(--hud-text);
  font: inherit;
  font-weight: 900;
  letter-spacing: 0;
  cursor: pointer;
}

button:disabled {
  cursor: default;
  border-color: rgba(149, 200, 255, 0.18);
  background:
    linear-gradient(180deg, rgba(74, 42, 120, 0.7), rgba(34, 18, 67, 0.82)),
    #2a1749;
  color: rgba(245, 247, 251, 0.62);
  box-shadow: var(--hud-inner);
}

[hidden] {
  display: none !important;
}

.game-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(circle at 30% 18%, rgba(40, 93, 174, 0.22), transparent 28%),
    linear-gradient(180deg, #071327, #030814 68%);
}

#gameCanvas {
  position: absolute;
  inset: 0;
  z-index: var(--hud-z-canvas);
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.flagship-model-stage {
  position: absolute;
  inset: 0;
  z-index: calc(var(--hud-z-canvas) + 1);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 260ms ease;
}

.flagship-model-stage::before {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 44%, rgba(49, 201, 255, 0.16), transparent 31%),
    radial-gradient(circle at 50% 54%, rgba(245, 200, 78, 0.09), transparent 42%),
    linear-gradient(180deg, rgba(2, 8, 18, 0), rgba(2, 8, 18, 0.24));
  content: "";
  opacity: 0.78;
}

.flagship-model-stage::before,
.pirate-flagship-model-stage::before {
  display: none;
}

.flagship-model-stage.is-visible {
  opacity: 1;
  visibility: visible;
}

.pirate-flagship-model-stage::before {
  z-index: calc(var(--hud-z-canvas) + 1);
  background:
    radial-gradient(circle at 50% 44%, rgba(255, 74, 47, 0.16), transparent 31%),
    radial-gradient(circle at 50% 54%, rgba(255, 157, 63, 0.1), transparent 42%),
    linear-gradient(180deg, rgba(2, 8, 18, 0), rgba(18, 5, 4, 0.24));
}

.pirate-flagship-model-stage {
  z-index: calc(var(--hud-z-canvas) + 1);
}

.flagship-overview-model-stage {
  z-index: calc(var(--hud-z-canvas) + 1);
}

.flagship-overview-model-stage::before {
  z-index: 0;
  display: block;
  background:
    radial-gradient(ellipse at 38% 48%, rgba(49, 201, 255, 0.15), transparent 27%),
    radial-gradient(ellipse at 35% 51%, rgba(245, 200, 78, 0.08), transparent 42%);
}

.flagship-overview {
  --selected-compartment-accent: #34d7ff;
  position: absolute;
  top: calc(max(8px, env(safe-area-inset-top)) + 60px);
  right: min(464px, 38vw);
  bottom: max(14px, env(safe-area-inset-bottom));
  left: max(16px, env(safe-area-inset-left));
  z-index: var(--hud-z-rail);
  pointer-events: none;
}

.flagship-overview-header {
  position: absolute;
  top: 8px;
  left: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  width: min(100%, 330px);
  min-height: 52px;
  padding: 8px 10px 8px 13px;
  gap: 12px;
  border: 1px solid rgba(149, 200, 255, 0.28);
  border-left: 3px solid var(--selected-compartment-accent);
  border-radius: 7px;
  background: linear-gradient(90deg, rgba(5, 20, 42, 0.92), rgba(5, 17, 36, 0.54));
  box-shadow: var(--hud-inner), 0 10px 28px rgba(0, 0, 0, 0.22);
}

.flagship-overview-header div {
  display: grid;
  min-width: 0;
}

.flagship-overview-header small {
  color: var(--selected-compartment-accent);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.flagship-overview-header strong {
  color: #f5f7fb;
  font-size: clamp(16px, 2vw, 23px);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.flagship-overview-header > span {
  margin-left: auto;
  color: #a9bad4;
  font-size: 10px;
  font-weight: 900;
  white-space: nowrap;
}

.flagship-compartment-hotspots {
  position: absolute;
  inset: 68px 0 44px;
  pointer-events: none;
}

.flagship-compartment-hotspot {
  position: absolute;
  top: var(--hotspot-y);
  left: var(--hotspot-x);
  display: grid;
  place-items: center;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  border: 1px solid var(--compartment-accent);
  border-radius: 50%;
  background:
    radial-gradient(circle, color-mix(in srgb, var(--compartment-accent) 34%, #071427) 0 44%, rgba(3, 8, 20, 0.96) 47%),
    #071427;
  box-shadow:
    0 0 0 4px rgba(3, 8, 20, 0.66),
    0 0 18px color-mix(in srgb, var(--compartment-accent) 42%, transparent),
    inset 0 0 12px rgba(255, 255, 255, 0.09);
  color: #f5f7fb;
  transition: transform 160ms ease, filter 160ms ease, box-shadow 160ms ease;
}

.flagship-compartment-hotspot span {
  font-size: 10px;
  font-weight: 950;
  letter-spacing: 0.04em;
}

.flagship-compartment-hotspot::before {
  position: absolute;
  inset: -7px;
  border: 1px solid color-mix(in srgb, var(--compartment-accent) 46%, transparent);
  border-radius: 50%;
  content: "";
  opacity: 0.42;
}

.flagship-compartment-hotspot::after {
  position: absolute;
  top: calc(100% + 7px);
  left: 50%;
  max-width: 126px;
  padding: 3px 6px;
  transform: translateX(-50%);
  border: 1px solid rgba(149, 200, 255, 0.2);
  border-radius: 4px;
  background: rgba(3, 8, 20, 0.82);
  color: #cfe6fb;
  content: attr(data-label);
  font-size: 8px;
  font-weight: 900;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.flagship-compartment-hotspot:hover,
.flagship-compartment-hotspot:focus-visible,
.flagship-compartment-hotspot.is-selected {
  z-index: 3;
  transform: translate(-50%, -50%) scale(1.13);
  filter: brightness(1.2);
  box-shadow:
    0 0 0 5px rgba(3, 8, 20, 0.76),
    0 0 27px color-mix(in srgb, var(--compartment-accent) 72%, transparent),
    inset 0 0 14px rgba(255, 255, 255, 0.16);
}

.flagship-compartment-hotspot.is-selected::before {
  animation: flagship-hotspot-pulse 1.8s ease-out infinite;
  opacity: 0.9;
}

.flagship-compartment-hotspot.is-selected::after {
  border-color: var(--compartment-accent);
  color: #fff;
}

.flagship-overview-footer {
  position: absolute;
  bottom: 0;
  left: 50%;
  display: grid;
  grid-template-columns: auto minmax(0, auto);
  align-items: center;
  max-width: min(92%, 390px);
  min-width: 260px;
  padding: 7px 14px;
  column-gap: 9px;
  transform: translateX(-50%);
  border: 1px solid rgba(149, 200, 255, 0.24);
  border-radius: 999px;
  background: rgba(3, 8, 20, 0.82);
  box-shadow: var(--hud-inner), 0 8px 24px rgba(0, 0, 0, 0.28);
}

.flagship-overview-footer strong {
  min-width: 0;
  color: var(--selected-compartment-accent);
  font-size: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.flagship-overview-footer small {
  grid-column: 2;
  color: #8099b5;
  font-size: 8px;
}

.flagship-overview-pulse {
  grid-row: 1 / 3;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--selected-compartment-accent);
  box-shadow: 0 0 12px var(--selected-compartment-accent);
}

@keyframes flagship-hotspot-pulse {
  0% {
    transform: scale(0.82);
    opacity: 0.9;
  }
  100% {
    transform: scale(1.45);
    opacity: 0;
  }
}

.flagship-interior-nav {
  position: absolute;
  inset: 0;
  z-index: var(--hud-z-rail);
  display: none;
  pointer-events: none;
}

body.is-flagship-view .flagship-interior-nav {
  display: block;
}

.flagship-nav-button {
  position: absolute;
  top: 37%;
  width: clamp(42px, 10vw, 58px);
  height: clamp(58px, 13vw, 72px);
  min-height: clamp(58px, 13vw, 72px);
  padding: 0 0 5px;
  transform: translateY(-50%);
  pointer-events: auto;
  border-color: rgba(149, 200, 255, 0.52);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(35, 112, 184, 0.94), rgba(5, 19, 42, 0.97)),
    var(--hud-blue-900);
  box-shadow: var(--hud-shadow), var(--hud-inner), 0 0 20px rgba(49, 201, 255, 0.16);
  color: #f5f7fb;
  font-size: clamp(34px, 8vw, 46px);
  line-height: 1;
}

.flagship-nav-button--prev {
  left: max(10px, env(safe-area-inset-left));
}

.flagship-nav-button--next {
  right: max(10px, env(safe-area-inset-right));
}

.flagship-interior-counter {
  position: absolute;
  top: calc(max(8px, env(safe-area-inset-top)) + 86px);
  left: 50%;
  max-width: min(72vw, 440px);
  padding: 7px 14px;
  transform: translateX(-50%);
  pointer-events: none;
  border: 1px solid rgba(149, 200, 255, 0.34);
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(8, 25, 50, 0.86), rgba(3, 8, 20, 0.9)),
    var(--hud-panel);
  box-shadow: var(--hud-inner), 0 0 18px rgba(49, 201, 255, 0.12);
  color: var(--hud-text);
  font-size: clamp(10px, 2.6vw, 13px);
  font-weight: 900;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.flagship-model-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.flagship-model-status {
  position: absolute;
  left: 50%;
  top: 46%;
  z-index: 1;
  min-width: 160px;
  padding: 9px 12px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(149, 200, 255, 0.32);
  border-radius: 7px;
  background: rgba(5, 17, 36, 0.82);
  color: var(--hud-muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.hud-panel {
  position: absolute;
  z-index: var(--hud-z-panel);
  border: 1px solid var(--hud-line);
  border-radius: var(--hud-radius);
  background:
    linear-gradient(180deg, rgba(20, 52, 91, 0.88), rgba(4, 13, 31, 0.93)),
    var(--hud-panel);
  box-shadow: var(--hud-shadow), var(--hud-inner);
  backdrop-filter: blur(10px);
}

.hud-panel::before {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  background:
    linear-gradient(135deg, rgba(49, 201, 255, 0.14), transparent 35%, rgba(245, 200, 78, 0.06)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 22%);
  content: "";
  opacity: 0.88;
  pointer-events: none;
}

.hud-panel > * {
  position: relative;
  z-index: 1;
}

.hud-panel-cut,
.hud-sector-status-panel,
.bottom-navigation,
.fleet-quick-list,
.contextual-bottom-sheet,
.drawer-panel,
.flagship-context-panel,
.power-toast {
  clip-path: polygon(var(--hud-cut) 0, 100% 0, 100% calc(100% - var(--hud-cut)), calc(100% - var(--hud-cut)) 100%, 0 100%, 0 var(--hud-cut));
}

.hud-art-icon {
  position: relative;
  display: block;
  flex: 0 0 auto;
  overflow: hidden;
  background-image: none;
}

.hud-button,
.hud-icon-button {
  display: grid;
  place-items: center;
  border-color: var(--hud-line-strong);
  background:
    linear-gradient(180deg, rgba(52, 138, 214, 0.94), rgba(8, 41, 83, 0.98)),
    #0d3768;
  color: #f5fbff;
}

.hud-icon-button {
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  font-size: 18px;
}

.secondary-resources-button {
  background:
    url("/assets/hud/topbar/plus_button.png") center / contain no-repeat,
    linear-gradient(180deg, rgba(52, 138, 214, 0.94), rgba(8, 41, 83, 0.98));
  border: 0;
  box-shadow: none;
  color: transparent;
}

.hud-progress-bar {
  display: block;
  width: 100%;
  height: 6px;
  overflow: hidden;
  border: 1px solid rgba(149, 200, 255, 0.25);
  border-radius: 999px;
  background: rgba(2, 7, 16, 0.72);
}

.hud-progress-bar > span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--hud-cyan), var(--hud-green));
  box-shadow: 0 0 10px rgba(97, 223, 122, 0.45);
}

/* TopStatusBar */
.top-bar {
  top: max(8px, env(safe-area-inset-top));
  left: max(8px, env(safe-area-inset-left));
  right: max(8px, env(safe-area-inset-right));
  z-index: var(--hud-z-top);
}

.hud-top-status-bar {
  display: grid;
  grid-template-columns: minmax(146px, 0.38fr) minmax(0, 0.62fr);
  align-items: center;
  min-height: 58px;
  padding: 7px;
  gap: 7px;
  overflow: hidden;
  border: 1px solid rgba(149, 200, 255, 0.36);
  background:
    linear-gradient(180deg, rgba(16, 45, 78, 0.94), rgba(4, 13, 31, 0.96)),
    var(--hud-blue-900);
  box-shadow: var(--hud-shadow), var(--hud-inner);
  clip-path: polygon(12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 12px);
}

.hud-top-status-bar::before {
  inset: 0;
  background:
    linear-gradient(90deg, rgba(245, 200, 78, 0.12), transparent 34%),
    radial-gradient(circle at 92% 50%, rgba(49, 201, 255, 0.12), transparent 34%);
  opacity: 0.82;
}

.commander-chip {
  position: relative;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  align-items: center;
  min-width: 0;
  min-height: 44px;
  padding: 4px 7px 4px 4px;
  gap: 5px;
  border: 1px solid rgba(245, 200, 78, 0.42);
  background:
    linear-gradient(180deg, rgba(12, 29, 52, 0.98), rgba(3, 9, 22, 0.94)),
    var(--hud-blue-900);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 0 18px rgba(245, 200, 78, 0.1);
  text-align: left;
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}

.commander-chip::before {
  display: none;
}

.commander-chip::after {
  display: none;
}

.commander-chip > * {
  position: relative;
  z-index: 2;
}

.commander-portrait {
  position: relative;
  width: 52px;
  height: 52px;
  border: 2px solid rgba(245, 200, 78, 0.62);
  border-radius: 12px;
  background: url("/assets/hud/crops/commander.png") center / 82% 82% no-repeat;
  box-shadow: 0 0 14px rgba(245, 200, 78, 0.2);
  clip-path: none;
}

.commander-portrait::before {
  display: none;
}

.commander-portrait::after {
  display: none;
}

.commander-copy {
  min-width: 0;
}

.commander-copy strong,
.commander-copy small {
  display: block;
  overflow: hidden;
  line-height: 1.08;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.commander-copy strong {
  color: #f7fbff;
  font-size: 13px;
}

.commander-copy small {
  margin-top: 3px;
  color: var(--hud-gold);
  font-size: 10px;
  font-weight: 800;
}

.resource-list,
.hud-resource-strip {
  display: grid;
  grid-template-columns: minmax(88px, 1fr);
  align-items: center;
  justify-content: stretch;
  gap: 5px;
  min-width: 0;
}

.hud-resource-counter,
.power-button {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  min-width: 0;
  min-height: 40px;
  padding: 4px 8px 4px 4px;
  gap: 6px;
  border: 1px solid rgba(149, 200, 255, 0.32);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(11, 37, 68, 0.96), rgba(4, 13, 31, 0.98)),
    var(--hud-blue-900);
  box-shadow: var(--hud-inner);
  color: var(--hud-text);
  text-align: left;
}

.commander-chip.commander-power-card {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  min-height: 60px;
  padding: 4px 9px 4px 5px;
  gap: 9px;
  min-width: 178px;
}

.commander-power-card .hud-resource-copy strong {
  color: #ffe373;
}

.commander-power-copy {
  align-self: center;
  display: flex;
  min-width: 0;
  padding: 0;
  flex-direction: column;
  justify-content: center;
}

.commander-power-copy small {
  color: #f5f7fb;
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
}

.commander-power-copy strong {
  color: #fff073;
  overflow: hidden;
  font-size: 15px;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.commander-power-copy em {
  display: inline-block;
  margin-top: 4px;
  padding: 1px 8px;
  border: 1px solid rgba(245, 200, 78, 0.42);
  border-radius: 999px;
  background: rgba(6, 12, 24, 0.74);
  color: #ffd65f;
  font-size: 10px;
  font-style: normal;
  font-weight: 900;
  line-height: 1.1;
}

.power-button.is-active,
.hud-icon-button.is-active,
.hud-icon-button[aria-expanded="true"] {
  border-color: rgba(245, 200, 78, 0.82);
  color: #ffeaa5;
  box-shadow: var(--hud-inner), 0 0 18px rgba(245, 200, 78, 0.2);
}

.hud-resource-icon {
  position: relative;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: center / contain no-repeat;
  box-shadow: 0 0 12px rgba(49, 201, 255, 0.18);
}

.hud-top-status-bar .hud-resource-strip .hud-resource-counter {
  grid-template-columns: 26px minmax(0, 1fr);
  min-height: 42px;
  padding: 4px 10px 4px 6px;
  border: 1px solid rgba(149, 200, 255, 0.28);
  border-radius: 8px;
  background-image: linear-gradient(180deg, rgba(12, 36, 68, 0.94), rgba(3, 10, 24, 0.96));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.11);
  gap: 10px;
}

.hud-top-status-bar .hud-resource-strip .hud-resource-icon {
  display: block;
  width: 28px;
  height: 28px;
}

.hud-top-status-bar .hud-resource-counter--ore {
  background-image: linear-gradient(180deg, rgba(12, 40, 78, 0.95), rgba(3, 11, 25, 0.96));
}

.hud-top-status-bar .hud-resource-counter--credits {
  background-image: linear-gradient(180deg, rgba(62, 42, 9, 0.95), rgba(18, 12, 4, 0.96));
}

.hud-top-status-bar .hud-resource-counter--credits strong {
  padding-left: 4px;
}

.hud-top-status-bar .hud-resource-counter--rare {
  background-image: linear-gradient(180deg, rgba(50, 24, 78, 0.95), rgba(15, 7, 29, 0.96));
}

.hud-resource-icon::before,
.hud-resource-icon::after {
  display: none;
}

.hud-resource-icon::before {
  inset: 7px;
  background: var(--hud-cyan);
  clip-path: polygon(50% 0, 88% 25%, 78% 78%, 50% 100%, 22% 78%, 12% 25%);
}

.hud-resource-icon::after {
  inset: 10px 12px;
  background: rgba(255, 255, 255, 0.45);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.hud-art-icon--power::before {
  display: none;
}

.hud-art-icon--power::after {
  display: none;
}

.hud-art-icon--power {
  background-image: url("/assets/hud/crops/power_commander.png");
}

.hud-art-icon--credits {
  background-image: url("/assets/hud/resources/designed/credits.png");
}

.hud-art-icon--ore {
  background-image: url("/assets/hud/crops/resource_blue.png");
}

.hud-art-icon--rare {
  background-image: url("/assets/hud/crops/resource_purple.png");
}

.hud-art-icon--energy {
  background-image: url("/assets/hud/crops/resource_red.png");
}

.hud-resource-copy {
  min-width: 0;
}

.hud-resource-copy small,
.hud-resource-copy strong {
  display: block;
  overflow: hidden;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud-resource-copy small {
  color: var(--hud-muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.hud-resource-copy strong {
  color: #fff;
  font-size: 14px;
  font-weight: 900;
}

.hud-resource-counter--power .hud-resource-copy strong {
  color: #ffe373;
}

#creditsValue::before,
#oreValue::before,
#rareOreValue::before {
  content: none;
}

.secondary-resources-panel {
  top: calc(100% + 8px);
  right: 0;
  z-index: var(--hud-z-top);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: min(330px, calc(100vw - 16px));
  padding: 8px;
  gap: 8px;
}

.mineral-resource-counter {
  border-color: color-mix(in srgb, var(--mineral-color) 42%, rgba(67, 115, 160, 0.38));
}

.mineral-resource-icon {
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.8), transparent 22%),
    linear-gradient(145deg, color-mix(in srgb, var(--mineral-color) 82%, white), color-mix(in srgb, var(--mineral-color) 64%, black));
  background-position: center, center;
  background-repeat: no-repeat, no-repeat;
  background-size: cover, cover;
  color: transparent;
  font-size: 0.62rem;
  font-weight: 950;
  border: 1px solid color-mix(in srgb, var(--mineral-color) 74%, white);
  box-shadow: 0 0 14px color-mix(in srgb, var(--mineral-color) 42%, transparent);
}

/* SectorStatusPanel */
.sector-panel {
  display: none !important;
  top: calc(max(8px, env(safe-area-inset-top)) + 76px);
  left: max(8px, env(safe-area-inset-left));
  width: min(430px, calc(100vw - 88px));
}

.hud-sector-status-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 76px;
  padding: 10px;
  gap: 10px;
  border-color: rgba(97, 223, 122, 0.3);
}

.sector-copy {
  min-width: 0;
}

.sector-copy strong {
  display: block;
  color: var(--hud-text);
  font-size: 20px;
  line-height: 1;
  text-transform: uppercase;
}

.sector-copy p {
  margin: 5px 0 8px;
  overflow: hidden;
  color: #d6e4f5;
  font-size: 12px;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sector-actions {
  display: grid;
  grid-template-columns: 1fr;
  align-content: center;
  min-width: 92px;
  gap: 6px;
}

.sector-actions small {
  display: none;
  color: #e1f4ff;
  font-size: 11px;
  font-weight: 900;
  text-align: center;
  white-space: nowrap;
}

.sector-actions small span {
  color: #ffe373;
}

.sector-actions .hud-button {
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  min-height: 38px;
  padding: 0 10px;
  border-color: rgba(180, 108, 255, 0.56);
  background:
    linear-gradient(180deg, rgba(119, 63, 195, 0.96), rgba(39, 16, 78, 0.98)),
    #3b1e70;
  font-size: 12px;
  line-height: 1.05;
  text-transform: uppercase;
}

.sector-actions .hud-button span,
.sector-actions .hud-button strong {
  display: block;
}

.sector-actions .hud-button strong {
  color: #fff;
  font-size: 13px;
}

.reset-button {
  display: none;
}

/* FleetQuickList */
.admiral-rail,
.fleet-quick-list {
  top: calc(max(8px, env(safe-area-inset-top)) + 164px);
  right: max(8px, env(safe-area-inset-right));
  bottom: calc(max(8px, env(safe-area-inset-bottom)) + 112px);
  z-index: var(--hud-z-rail);
  width: 72px;
  padding: 6px;
}

.admiral-quick-list {
  display: grid;
  gap: 7px;
}

.admiral-quick-button,
.fleet-quick-card {
  position: relative;
  display: grid;
  grid-template-rows: 14px 30px 13px 5px 10px;
  place-items: center;
  width: 100%;
  min-height: 78px;
  padding: 5px 4px;
  border-color: rgba(149, 200, 255, 0.32);
  background:
    linear-gradient(180deg, rgba(13, 43, 78, 0.98), rgba(4, 13, 31, 0.98)),
    #071427;
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
  line-height: 1;
}

.admiral-quick-button::after {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--hud-green);
  content: "";
  box-shadow: 0 0 8px currentColor;
}

.admiral-quick-button.is-selected {
  border-color: rgba(245, 200, 78, 0.86);
  box-shadow: var(--hud-inner), 0 0 18px rgba(245, 200, 78, 0.18);
}

.admiral-quick-button.is-moving::after,
.admiral-quick-button.is-returning::after {
  background: var(--hud-gold);
}

.admiral-quick-button.is-resolving::after {
  background: var(--hud-red);
}

.admiral-quick-button.is-empty {
  opacity: 0.52;
}

.fleet-quick-number,
.admiral-ship-code,
.fleet-quick-state {
  overflow: hidden;
  width: 100%;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fleet-quick-number {
  color: #fff;
  font-size: 11px;
  font-weight: 900;
}

.admiral-avatar,
.ship-badge,
.inline-unit-shape {
  display: grid;
  place-items: center;
  border: 1px solid rgba(49, 201, 255, 0.46);
  background:
    radial-gradient(circle at 50% 38%, rgba(49, 201, 255, 0.26), transparent 44%),
    rgba(9, 32, 61, 0.9);
  color: var(--hud-text);
  font-weight: 900;
}

.admiral-avatar {
  width: 30px;
  height: 30px;
  font-size: 10px;
}

.admiral-ship-code {
  color: #f5fbff;
  font-size: 9px;
  font-weight: 900;
}

.fleet-quick-health {
  height: 5px;
}

.fleet-quick-state {
  color: var(--hud-muted);
  font-size: 8px;
  font-weight: 900;
}

.unit-shape.shape-triangle {
  clip-path: polygon(50% 4%, 96% 94%, 50% 72%, 4% 94%);
}

.unit-shape.shape-square {
  border-radius: 5px;
  clip-path: none;
}

.unit-shape.shape-circle {
  border-radius: 50%;
  clip-path: none;
}

/* BottomNavigation */
.fleet-panel,
.bottom-navigation {
  left: max(8px, env(safe-area-inset-left));
  right: max(8px, env(safe-area-inset-right));
  bottom: calc(env(safe-area-inset-bottom) + 20px);
  z-index: var(--hud-z-bottom);
}

.bottom-navigation {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  min-height: 74px;
  padding: 2px 8px 0;
  gap: 7px;
  border: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.fleet-summary {
  position: absolute;
  left: 0;
  right: 74px;
  bottom: calc(100% + 7px);
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid rgba(149, 200, 255, 0.24);
  border-radius: 8px;
  background: rgba(5, 17, 36, 0.82);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.26);
  backdrop-filter: none;
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}

.fleet-summary strong {
  display: none;
}

.fleet-summary p,
.fleet-summary small {
  display: block;
  margin: 0;
  overflow: hidden;
  color: #d7e8fb;
  font-size: 11px;
  line-height: 1.18;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fleet-summary small {
  color: var(--hud-gold);
}

.hud-action,
.bottom-navigation-item {
  display: grid;
  grid-template-rows: 38px 14px;
  place-items: center;
  min-width: 0;
  min-height: 58px;
  padding: 0 2px;
  gap: 3px;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: #e6f4ff;
  font-size: 10px;
  line-height: 1;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
}

.bottom-navigation-item::before {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 0;
  background: center / contain no-repeat;
  filter: drop-shadow(0 0 8px rgba(49, 201, 255, 0.2));
  color: transparent;
  content: attr(data-icon);
  font-size: 14px;
  font-weight: 900;
}

#shipyardButton::before {
  background-image: url("/assets/hud/nav/optimized/nav_fleets_new.png");
}

#governorButton::before {
  background-image: url("/assets/hud/nav/optimized/nav_commanders_new.png");
}

#flagshipButton::before {
  background-image: url("/assets/hud/nav/optimized/nav_flagship_new.png");
}

#centerButton::before {
  background-image: url("/assets/hud/nav/optimized/nav_map_new.png");
}

.bottom-navigation-item.is-active {
  border-color: transparent;
  box-shadow: none;
}

.bottom-navigation-item.is-active::after {
  position: absolute;
  bottom: 3px;
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--hud-gold);
  content: "";
  transform: rotate(45deg);
}

/* ContextualBottomSheet */
.selection-panel,
.contextual-bottom-sheet {
  left: max(8px, env(safe-area-inset-left));
  right: calc(max(8px, env(safe-area-inset-right)) + 82px);
  bottom: calc(max(8px, env(safe-area-inset-bottom)) + 122px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(88px, 132px);
  align-items: center;
  min-height: 96px;
  max-height: 136px;
  padding: 10px;
  gap: 10px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity var(--hud-transition), transform var(--hud-transition);
  pointer-events: none;
}

body.has-selection .selection-panel {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.selection-copy {
  min-width: 0;
}

.selection-copy strong,
.selection-copy p,
.selection-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.selection-copy strong {
  margin-bottom: 4px;
  color: #fff;
  font-size: 15px;
  line-height: 1.08;
  text-transform: uppercase;
  white-space: nowrap;
}

.selection-copy p {
  display: -webkit-box;
  margin: 0 0 6px;
  color: #d7e8fb;
  font-size: 12px;
  line-height: 1.25;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.selection-copy small {
  color: var(--hud-gold);
  font-size: 11px;
  white-space: nowrap;
}

.selection-panel button {
  min-height: 58px;
  padding: 7px;
  border-color: rgba(49, 201, 255, 0.5);
  background:
    linear-gradient(180deg, rgba(46, 139, 218, 0.96), rgba(9, 45, 89, 0.98)),
    #0c3b73;
  font-size: 12px;
}

/* Drawers and detailed panels */
.flagship-panel,
.shipyard-panel,
.governor-panel,
.power-panel,
.drawer-panel {
  right: calc(max(8px, env(safe-area-inset-right)) + 82px);
  bottom: calc(max(8px, env(safe-area-inset-bottom)) + 112px);
  width: min(520px, calc(100vw - 106px));
  max-height: min(58dvh, 520px);
  overflow: auto;
  padding: 12px;
  overscroll-behavior: contain;
}

.flagship-context-panel {
  right: max(8px, env(safe-area-inset-right));
  bottom: max(8px, env(safe-area-inset-bottom));
  width: min(440px, calc(100vw - 16px));
  max-height: min(42dvh, 420px);
  overflow: auto;
  padding: 12px;
  overscroll-behavior: contain;
}

body.is-flagship-view .flagship-context-panel {
  bottom: max(8px, env(safe-area-inset-bottom));
  max-height: min(52dvh, 520px);
  padding: 10px;
  border-color: rgba(149, 200, 255, 0.3);
  background:
    linear-gradient(180deg, rgba(7, 22, 43, 0.97), rgba(2, 8, 18, 0.98)),
    var(--hud-panel);
  box-shadow: var(--hud-shadow), var(--hud-inner), 0 0 26px rgba(49, 201, 255, 0.08);
}

body.is-flagship-view .flagship-context-panel.is-compartment-updated {
  animation: flagship-panel-refresh 220ms ease-out;
}

@keyframes flagship-panel-refresh {
  from {
    opacity: 0.72;
    transform: translateY(7px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

body.is-flagship-view .flagship-context-panel .panel-header {
  margin: -10px -10px 8px;
  padding: 9px 10px;
  border-bottom-color: rgba(245, 200, 78, 0.3);
  background:
    linear-gradient(90deg, rgba(120, 82, 15, 0.36), rgba(5, 17, 36, 0.96) 36%, rgba(5, 17, 36, 0.96)),
    rgba(5, 17, 36, 0.96);
}

body.is-flagship-view .flagship-context-panel .panel-header strong {
  font-size: 15px;
}

body.is-flagship-view .flagship-context-panel .panel-header p {
  font-size: 11px;
}

body.is-flagship-view .flagship-context-panel .panel-header button {
  width: 72px;
  min-height: 34px;
}

.compartment-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: -2px 0 10px;
  border: 1px solid rgba(149, 200, 255, 0.17);
  border-radius: 7px;
  overflow: hidden;
  background: rgba(3, 8, 20, 0.42);
}

.compartment-tabs span {
  min-width: 0;
  padding: 8px 6px;
  border-right: 1px solid rgba(149, 200, 255, 0.14);
  color: var(--hud-muted);
  font-size: 10px;
  font-weight: 900;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.compartment-tabs span:last-child {
  border-right: 0;
}

.compartment-tabs span.is-active {
  color: var(--hud-gold);
  background:
    linear-gradient(180deg, rgba(245, 200, 78, 0.16), rgba(245, 200, 78, 0.04)),
    rgba(3, 8, 20, 0.48);
  box-shadow: inset 0 -2px 0 rgba(245, 200, 78, 0.72);
}

.compartment-effects,
.compartment-modules {
  margin-top: 8px;
  padding: 8px;
  border: 1px solid rgba(149, 200, 255, 0.14);
  border-radius: 7px;
  background: rgba(3, 8, 20, 0.32);
}

.compartment-effects > strong,
.compartment-modules > strong {
  display: block;
  margin-bottom: 7px;
  color: var(--hud-muted);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.compartment-effect-grid,
.compartment-module-grid {
  display: grid;
  gap: 7px;
}

.compartment-effect-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.compartment-module-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.compartment-effect-grid span,
.compartment-module-grid span {
  display: grid;
  align-items: center;
  min-width: 0;
  gap: 6px;
  padding: 7px;
  border: 1px solid rgba(149, 200, 255, 0.11);
  border-radius: 6px;
  background: rgba(7, 24, 47, 0.56);
}

.compartment-effect-grid span {
  grid-template-columns: 22px minmax(0, 1fr);
}

.compartment-module-grid span {
  grid-template-columns: 28px minmax(0, 1fr);
}

.compartment-effect-grid i,
.compartment-module-grid i {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid rgba(149, 200, 255, 0.18);
  border-radius: 6px;
  color: #95c8ff;
  font-style: normal;
  font-size: 10px;
  font-weight: 900;
}

.compartment-effect-grid i.resource-art-badge,
.inline-resource-flow i.resource-art-badge {
  color: transparent;
  background:
    center / contain no-repeat var(--resource-art),
    rgba(7, 24, 47, 0.72);
  box-shadow: 0 0 10px rgba(49, 201, 255, 0.12);
}

.compartment-module-grid i {
  width: 28px;
  height: 28px;
  color: var(--hud-gold);
}

.compartment-effect-grid em,
.compartment-module-grid em {
  min-width: 0;
  color: #d7e8fb;
  font-style: normal;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compartment-module-grid small {
  display: block;
  margin-top: 2px;
  color: var(--hud-muted);
  font-size: 9px;
}

.compartment-effect-grid b,
.compartment-module-grid b {
  grid-column: 2;
  color: var(--hud-green);
  font-size: 10px;
  font-weight: 900;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compartment-module-grid b {
  grid-column: 2;
  color: var(--hud-cyan);
}

body.is-flagship-view .sector-panel,
body.is-flagship-view .admiral-rail,
body.is-flagship-view .fleet-panel,
body.is-flagship-view .bottom-navigation,
body.is-flagship-view .selection-panel {
  display: none;
}

.panel-header {
  position: sticky;
  top: -12px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: -12px -12px 12px;
  padding: 12px;
  gap: 10px;
  border-bottom: 1px solid rgba(149, 200, 255, 0.18);
  background: rgba(5, 17, 36, 0.96);
}

.panel-header div {
  min-width: 0;
}

.panel-header strong {
  display: block;
  overflow: hidden;
  color: #fff;
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-header p {
  margin: 4px 0 0;
  overflow: hidden;
  color: var(--hud-muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-header button {
  flex: 0 0 auto;
  width: 78px;
  min-height: 38px;
  padding-inline: 6px;
  font-size: 11px;
}

.wing-list,
.ship-list,
.fleet-formation-list,
.governor-list,
.power-breakdown-list,
.upgrade-tree,
.compartment-production,
.production-queue-list,
.production-orders {
  display: grid;
  gap: 10px;
}

.fleet-formation-list {
  margin-bottom: 12px;
}

.compartment-production {
  margin-top: 12px;
}

.refinery-recipe-grid {
  display: grid;
  gap: 10px;
}

.refinery-stock-card .compartment-effect-grid {
  margin: 10px 0;
}

.refinery-stock-card small {
  display: block;
  color: var(--hud-muted);
  font-size: 11px;
}

.inline-resource-flow {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.inline-resource-flow span {
  display: grid;
  grid-template-columns: 22px auto;
  align-items: center;
  gap: 5px;
  padding: 4px 6px;
  border: 1px solid rgba(149, 200, 255, 0.1);
  border-radius: 6px;
  background: rgba(5, 18, 36, 0.46);
}

.inline-resource-flow em,
.inline-resource-flow b {
  display: inline;
  margin: 0;
  font-style: normal;
  font-size: 10px;
  white-space: nowrap;
}

.inline-resource-flow em {
  color: #d7e8fb;
}

.inline-resource-flow b {
  color: var(--hud-gold);
  font-weight: 800;
}

.inline-resource-flow i {
  display: block;
  width: 22px;
  height: 22px;
  border: 1px solid rgba(149, 200, 255, 0.14);
  border-radius: 6px;
}

.inline-resource-flow--mastery b {
  color: var(--hud-green);
}

.wing-card,
.ship-card,
.governor-card,
.formation-card,
.upgrade-node,
.production-model,
.production-queue-card,
.production-order,
.power-breakdown-card {
  display: grid;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(149, 200, 255, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(12, 37, 69, 0.82), rgba(4, 13, 31, 0.86)),
    rgba(255, 255, 255, 0.035);
}

.wing-card {
  grid-template-columns: minmax(0, 1fr) 110px;
}

.ship-card {
  grid-template-columns: 46px minmax(0, 1fr) 116px;
}

.governor-card {
  grid-template-columns: 46px minmax(0, 1fr) 98px;
}

.formation-card {
  grid-template-columns: 46px minmax(0, 1fr);
}

.upgrade-node,
.production-model,
.production-order {
  grid-template-columns: minmax(0, 1fr) 98px;
}

.production-queue-card,
.power-breakdown-card {
  grid-template-columns: 1fr;
}

.wing-card-copy,
.ship-card-copy,
.governor-card-copy,
.formation-card-copy {
  min-width: 0;
}

.wing-card strong,
.ship-card strong,
.governor-card strong,
.formation-card strong,
.upgrade-node strong,
.production-model strong,
.production-queue-card strong,
.production-order strong,
.power-breakdown-card strong {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
  min-width: 0;
  color: #fff;
  font-size: 13px;
}

.wing-card strong span,
.ship-card strong span,
.governor-card strong span,
.formation-card strong span,
.upgrade-node strong span,
.production-model strong span,
.production-order span,
.power-breakdown-card strong span {
  flex: 0 0 auto;
  color: #95c8ff;
  font-size: 11px;
  white-space: nowrap;
}

.wing-card p,
.ship-card p,
.governor-card p,
.formation-card p,
.upgrade-node p,
.production-model p,
.production-queue-card p,
.power-breakdown-card p,
.compartment-details p {
  margin: 0 0 6px;
  color: #c8d8ea;
  font-size: 12px;
  line-height: 1.3;
}

.wing-card small,
.ship-card small,
.governor-card small,
.formation-card small,
.upgrade-node small,
.production-model small,
.power-breakdown-card small,
.compartment-details small {
  color: var(--hud-gold);
  font-size: 11px;
}

.wing-card button,
.ship-card button,
.governor-card button,
.formation-card button,
.upgrade-node button,
.production-model button,
.production-order button {
  min-height: 40px;
  padding: 6px;
  font-size: 11px;
}

.ship-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.formation-actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
}

.formation-actions [data-action="role"] {
  border-color: rgba(87, 240, 196, 0.42);
  color: #8ff5d6;
}

.hangar-mineral-stock {
  margin-top: 10px;
  padding: 9px;
  border: 1px solid rgba(87, 240, 196, 0.24);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(14, 55, 66, 0.44), rgba(4, 13, 31, 0.72)),
    rgba(3, 8, 20, 0.42);
}

.hangar-mineral-stock > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.hangar-mineral-stock > header div {
  display: grid;
  gap: 2px;
}

.hangar-mineral-stock > header strong {
  color: #dffef5;
  font-size: 11px;
  text-transform: uppercase;
}

.hangar-mineral-stock > header small {
  color: #7ee5c4;
  font-size: 9px;
}

.hangar-mineral-stock > header > b {
  color: #dffef5;
  font-size: 11px;
  text-align: right;
}

.hangar-mineral-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 8px;
}

.hangar-mineral-summary span {
  display: grid;
  min-width: 0;
  padding: 6px 7px;
  border: 1px solid rgba(87, 240, 196, 0.16);
  border-radius: 6px;
  background: rgba(3, 8, 20, 0.46);
}

.hangar-mineral-summary small {
  color: #7ee5c4;
  font-size: 8px;
  text-transform: uppercase;
}

.hangar-mineral-summary strong {
  color: #e8fff8;
  font-size: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hangar-mineral-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.hangar-mineral-card {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  min-width: 0;
  gap: 6px;
  padding: 7px;
  border: 1px solid rgba(87, 240, 196, 0.22);
  border: 1px solid color-mix(in srgb, var(--mineral-accent) 38%, transparent);
  border-radius: 7px;
  background: rgba(5, 20, 38, 0.76);
}

.hangar-mineral-card > i {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  color: transparent;
  background:
    center / contain no-repeat var(--resource-art),
    rgba(7, 24, 47, 0.9);
}

.hangar-mineral-card em {
  min-width: 0;
  color: #e9f8ff;
  font-style: normal;
  font-size: 10px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hangar-mineral-card em small {
  display: block;
  margin-top: 2px;
  color: var(--mineral-accent);
  font-size: 8px;
}

.hangar-mineral-card b {
  color: var(--mineral-accent);
  font-size: 10px;
  white-space: nowrap;
}

.hangar-mineral-balance {
  grid-column: 2 / -1;
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(149, 200, 255, 0.13);
}

.hangar-mineral-balance i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--mineral-accent);
  box-shadow: 0 0 8px var(--mineral-accent);
}

.hangar-mineral-card > small {
  grid-column: 2 / -1;
  color: #8ea9bf;
  font-size: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 760px) {
  .flagship-overview {
    top: calc(max(8px, env(safe-area-inset-top)) + 54px);
    right: max(8px, env(safe-area-inset-right));
    bottom: calc(min(46dvh, 420px) + max(14px, env(safe-area-inset-bottom)));
    left: max(8px, env(safe-area-inset-left));
  }

  .flagship-overview-header {
    top: 4px;
    left: 4px;
    width: 98px;
    min-height: 44px;
    padding: 6px 8px 6px 10px;
  }

  .flagship-overview-header small,
  .flagship-overview-header > span {
    display: none;
  }

  .flagship-overview-header strong {
    font-size: 10px;
    line-height: 1.05;
  }

  .flagship-compartment-hotspots {
    inset: 52px 0 39px;
  }

  .flagship-compartment-hotspot {
    width: 36px;
    min-width: 36px;
    height: 36px;
    min-height: 36px;
  }

  .flagship-compartment-hotspot span {
    font-size: 8px;
  }

  .flagship-compartment-hotspot::after {
    display: none;
  }

  .flagship-compartment-hotspot.is-selected::after {
    display: block;
    max-width: 110px;
    font-size: 7px;
  }

  .flagship-overview-footer {
    display: none;
  }

  body.is-flagship-view .flagship-context-panel {
    max-height: min(46dvh, 420px);
  }

  .hangar-mineral-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hangar-mineral-card {
    grid-template-columns: 26px minmax(0, 1fr);
  }

  .hangar-mineral-card > i {
    width: 26px;
    height: 26px;
  }

  .hangar-mineral-card b {
    grid-column: 2;
  }
}

.formation-actions button {
  min-width: 0;
  min-height: 38px;
  padding: 4px 2px;
  overflow: hidden;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ship-badge,
.governor-badge {
  width: 42px;
  height: 42px;
  font-size: 11px;
}

.governor-badge {
  border-color: var(--hud-gold-soft);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 38%, rgba(245, 200, 78, 0.26), transparent 44%),
    rgba(47, 31, 8, 0.8);
  color: #ffeaa5;
  font-size: 16px;
}

.inline-unit-shape {
  display: inline-grid;
  width: 22px;
  height: 22px;
  margin-right: 6px;
  font-size: 8px;
  vertical-align: middle;
}

.ship-card.is-locked,
.production-model.is-locked,
.upgrade-node.is-locked,
.admiral-quick-button.is-empty {
  opacity: 0.58;
}

.wing-card.is-selected,
.formation-card.is-selected,
.admiral-quick-button.is-selected {
  border-color: rgba(245, 200, 78, 0.72);
}

.formation-card.is-active,
.governor-card.is-assigned {
  border-color: rgba(49, 201, 255, 0.5);
  background:
    linear-gradient(180deg, rgba(15, 54, 92, 0.9), rgba(4, 13, 31, 0.88)),
    rgba(49, 201, 255, 0.08);
}

/* Admiral collection */
.governor-panel {
  width: min(980px, calc(100vw - 106px));
  max-height: min(78dvh, 760px);
  overflow: hidden;
}

.admiral-filters {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  padding-bottom: 4px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.admiral-filters button,
.admiral-tabs button {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 7px 11px;
  border-color: rgba(149, 200, 255, 0.2);
  background: rgba(5, 18, 36, 0.78);
  color: var(--hud-muted);
  font-size: 10px;
}

.admiral-filters button.is-active,
.admiral-tabs button.is-active {
  border-color: rgba(245, 200, 78, 0.7);
  background: linear-gradient(180deg, rgba(90, 67, 16, 0.82), rgba(20, 31, 50, 0.9));
  color: #fff3bd;
}

.admiral-collection-layout {
  display: grid;
  grid-template-columns: minmax(245px, 0.72fr) minmax(420px, 1.45fr);
  gap: 12px;
  min-height: 0;
  max-height: calc(min(78dvh, 760px) - 112px);
}

.admiral-collection-list,
.admiral-detail {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.governor-card.admiral-collection-card {
  grid-template-columns: 50px minmax(0, 1fr) 82px;
  gap: 8px;
  padding: 8px;
  border-color: color-mix(in srgb, var(--admiral-accent) 34%, transparent);
  cursor: default;
}

.governor-card.admiral-collection-card.is-selected {
  border-color: var(--admiral-accent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--admiral-accent) 30%, transparent), 0 0 16px color-mix(in srgb, var(--admiral-accent) 14%, transparent);
}

.governor-card.admiral-collection-card.is-locked {
  filter: saturate(0.25);
  opacity: 0.72;
}

.admiral-portrait-button {
  position: relative;
  width: 46px;
  height: 46px;
  min-height: 46px;
  padding: 0;
  overflow: hidden;
  border-color: var(--admiral-accent);
  background:
    linear-gradient(rgba(4, 14, 30, 0.2), rgba(4, 14, 30, 0.66)),
    var(--admiral-portrait) center / cover no-repeat,
    #071427;
  color: transparent;
  box-shadow: inset 0 0 10px color-mix(in srgb, var(--admiral-accent) 28%, transparent);
}

.admiral-collection-card.is-locked .admiral-portrait-button::after {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(2, 7, 16, 0.5);
  color: #d7e3ed;
  content: "?";
  font-size: 20px;
}

.admiral-empty-state {
  margin: 0;
  padding: 24px 12px;
  border: 1px dashed rgba(149, 200, 255, 0.2);
  color: var(--hud-muted);
  text-align: center;
}

.admiral-detail {
  display: grid;
  grid-template-columns: minmax(190px, 0.72fr) minmax(280px, 1.25fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(149, 200, 255, 0.2);
  border-radius: 10px;
  background:
    radial-gradient(circle at 22% 24%, color-mix(in srgb, var(--admiral-accent, #31c9ff) 14%, transparent), transparent 34%),
    linear-gradient(155deg, rgba(12, 38, 70, 0.92), rgba(3, 10, 25, 0.96));
}

.admiral-model-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 250px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--admiral-accent) 34%, transparent);
  border-radius: 9px;
  background:
    repeating-linear-gradient(0deg, transparent 0 7px, rgba(120, 220, 255, 0.025) 8px 9px),
    radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--admiral-accent) 18%, transparent), rgba(3, 12, 29, 0.9) 62%);
  perspective: 520px;
}

.admiral-model-stage > small {
  position: absolute;
  right: 8px;
  bottom: 7px;
  left: 8px;
  color: color-mix(in srgb, var(--admiral-accent) 72%, white);
  font-size: 8px;
  text-align: center;
  text-transform: uppercase;
}

.admiral-model-stage.is-locked {
  filter: grayscale(0.85);
}

.admiral-hologram-ring {
  position: absolute;
  bottom: 28px;
  width: 72%;
  height: 23%;
  border: 2px solid color-mix(in srgb, var(--admiral-accent) 64%, transparent);
  border-radius: 50%;
  box-shadow: 0 0 24px color-mix(in srgb, var(--admiral-accent) 26%, transparent), inset 0 0 18px color-mix(in srgb, var(--admiral-accent) 18%, transparent);
  animation: admiral-ring-pulse 2.8s ease-in-out infinite;
}

.admiral-hologram-figure {
  position: absolute;
  top: 19px;
  width: 126px;
  height: 174px;
  border: 1px solid color-mix(in srgb, var(--admiral-accent) 46%, transparent);
  border-radius: 46% 46% 24% 24%;
  background:
    linear-gradient(180deg, transparent 40%, color-mix(in srgb, var(--admiral-accent) 36%, #081326) 100%),
    var(--admiral-portrait) center 18% / 84px 84px no-repeat,
    linear-gradient(150deg, rgba(15, 42, 72, 0.9), rgba(4, 13, 31, 0.96));
  box-shadow: inset 0 -20px 30px color-mix(in srgb, var(--admiral-accent) 20%, transparent), 0 0 28px color-mix(in srgb, var(--admiral-accent) 15%, transparent);
  transform: rotateY(-8deg);
  animation: admiral-idle 5.2s ease-in-out infinite;
}

.admiral-hologram-figure span {
  position: absolute;
  right: 0;
  bottom: 13px;
  left: 0;
  color: #fff;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-align: center;
  text-shadow: 0 0 12px var(--admiral-accent);
}

.admiral-hologram-figure.has-detail-art {
  top: 12px;
  width: 150px;
  height: 202px;
  border-radius: 12px;
  background:
    linear-gradient(180deg, transparent 54%, color-mix(in srgb, var(--admiral-accent) 26%, #081326) 100%),
    var(--admiral-portrait) center 24% / cover no-repeat,
    #081326;
  box-shadow:
    inset 0 -26px 34px rgba(3, 8, 20, 0.72),
    0 0 30px color-mix(in srgb, var(--admiral-accent) 24%, transparent);
}

.admiral-hologram-figure.has-detail-art span {
  display: none;
}

.admiral-detail[data-admiral-id="napoleon-bonaparte"] {
  background:
    radial-gradient(circle at 20% 22%, rgba(184, 77, 255, 0.2), transparent 35%),
    radial-gradient(circle at 72% 8%, rgba(171, 52, 38, 0.15), transparent 30%),
    linear-gradient(155deg, rgba(28, 13, 50, 0.96), rgba(4, 9, 24, 0.98));
}

.admiral-command-ship-preview {
  position: absolute;
  right: 14px;
  bottom: 42px;
  display: grid;
  place-items: center;
  width: 62px;
  height: 36px;
  border: 1px solid var(--admiral-accent);
  background: color-mix(in srgb, var(--admiral-accent) 36%, #061226);
  clip-path: polygon(50% 0, 100% 80%, 62% 64%, 50% 100%, 38% 64%, 0 80%);
  color: #06101e;
  filter: drop-shadow(0 0 8px color-mix(in srgb, var(--admiral-accent) 50%, transparent));
}

.admiral-command-ship-preview i,
.admiral-ship-silhouette i {
  font-size: 9px;
  font-style: normal;
  font-weight: 1000;
}

.admiral-detail-content {
  min-width: 0;
}

.admiral-identity-line {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.admiral-identity-line h2 {
  margin: 2px 0 0;
  color: #fff;
  font-size: clamp(21px, 3vw, 32px);
  line-height: 1;
}

.admiral-identity-line p,
.admiral-description {
  margin: 5px 0 0;
  color: #c8d8ea;
  font-size: 11px;
  line-height: 1.4;
}

.admiral-identity-line > strong {
  color: var(--hud-gold);
  font-size: 14px;
  white-space: nowrap;
}

.admiral-rarity {
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.admiral-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 12px;
}

.admiral-meta-grid span,
.admiral-stat-list span {
  display: grid;
  gap: 2px;
  padding: 7px 8px;
  border: 1px solid rgba(149, 200, 255, 0.13);
  border-radius: 6px;
  background: rgba(3, 11, 26, 0.5);
}

.admiral-meta-grid small,
.admiral-stat-list em {
  color: var(--hud-muted);
  font-size: 8px;
  font-style: normal;
  text-transform: uppercase;
}

.admiral-meta-grid b,
.admiral-stat-list b {
  color: #fff;
  font-size: 10px;
}

.admiral-xp {
  height: 7px;
  margin-top: 10px;
  overflow: hidden;
  border: 1px solid rgba(149, 200, 255, 0.22);
  border-radius: 999px;
  background: rgba(2, 7, 16, 0.8);
}

.admiral-xp span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--admiral-accent), var(--hud-gold));
}

.admiral-xp-label {
  display: block;
  margin-top: 4px;
  color: var(--hud-muted);
  font-size: 9px;
}

.admiral-comparison {
  margin: 8px 0 0;
  font-size: 10px;
  font-weight: 800;
}

.admiral-comparison.is-positive {
  color: var(--hud-green);
}

.admiral-comparison.is-negative {
  color: var(--hud-red);
}

.admiral-detail-actions {
  display: grid;
  grid-template-columns: 1fr 0.72fr;
  gap: 7px;
  margin-top: 10px;
}

.admiral-detail-actions button {
  min-height: 42px;
  padding: 7px;
  font-size: 10px;
}

.admiral-tabs {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
}

.admiral-tabs button {
  width: 100%;
}

.admiral-tab-content {
  grid-column: 1 / -1;
  min-height: 130px;
}

.admiral-tab-heading {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  color: #fff;
  font-size: 11px;
}

.admiral-tab-heading span {
  color: var(--hud-gold);
}

.admiral-ability-card,
.admiral-command-ship-card {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid rgba(245, 200, 78, 0.3);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(85, 59, 10, 0.32), rgba(4, 14, 31, 0.76));
}

.admiral-command-ship-card.has-command-ship-art {
  grid-template-columns: 134px minmax(0, 1fr);
  border-color: color-mix(in srgb, var(--admiral-accent) 55%, rgba(245, 200, 78, 0.3));
}

.admiral-command-ship-art {
  display: block;
  width: 132px;
  height: 78px;
  object-fit: cover;
  object-position: center 48%;
  border: 1px solid color-mix(in srgb, var(--admiral-accent) 55%, #f5c84e);
  border-radius: 7px;
  background: #f3f1ec;
  filter: saturate(1.1) contrast(1.08);
  box-shadow: 0 0 14px color-mix(in srgb, var(--admiral-accent) 22%, transparent);
}

.admiral-ability-card > span {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border: 1px solid var(--hud-gold);
  border-radius: 50%;
  color: var(--hud-gold);
  font-size: 8px;
  font-weight: 900;
  text-transform: uppercase;
}

.admiral-ability-card strong,
.admiral-command-ship-card strong,
.admiral-secondary-skills strong {
  color: #fff;
  font-size: 11px;
}

.admiral-ability-card p,
.admiral-command-ship-card p,
.admiral-secondary-skills p {
  margin: 3px 0;
  color: #c8d8ea;
  font-size: 10px;
}

.admiral-ability-card small,
.admiral-command-ship-card small,
.admiral-secondary-skills small {
  color: var(--hud-gold);
  font-size: 9px;
}

.admiral-secondary-skills,
.admiral-stat-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-top: 8px;
}

.admiral-secondary-skills article {
  padding: 8px;
  border: 1px solid rgba(149, 200, 255, 0.16);
  border-radius: 7px;
  background: rgba(4, 14, 31, 0.62);
}

.admiral-secondary-skills article.is-locked {
  filter: grayscale(1);
  opacity: 0.55;
}

.admiral-talent-tree {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.admiral-talent-tree section {
  display: grid;
  gap: 6px;
  padding: 7px;
  border: 1px solid rgba(149, 200, 255, 0.13);
  border-radius: 7px;
  background: rgba(3, 11, 26, 0.5);
}

.admiral-talent-tree h3 {
  margin: 0;
  color: var(--admiral-accent);
  font-size: 10px;
  text-align: center;
}

.admiral-talent-tree button {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 2px 6px;
  min-height: 48px;
  padding: 6px;
  text-align: left;
}

.admiral-talent-tree button span {
  grid-row: 1 / 3;
  align-self: center;
  color: var(--hud-gold);
  font-size: 9px;
}

.admiral-talent-tree button strong {
  color: #fff;
  font-size: 9px;
}

.admiral-talent-tree button small {
  color: var(--hud-muted);
  font-size: 8px;
}

.admiral-ship-silhouette {
  display: grid;
  place-items: center;
  width: 54px;
  height: 46px;
  background: var(--admiral-accent);
  clip-path: polygon(50% 0, 100% 76%, 64% 62%, 50% 100%, 36% 62%, 0 76%);
  color: #06101e;
  filter: drop-shadow(0 0 8px color-mix(in srgb, var(--admiral-accent) 48%, transparent));
}

.admiral-avatar.admiral-portrait {
  position: relative;
  overflow: visible;
  border-color: var(--admiral-accent, var(--hud-cyan));
  border-radius: 50%;
  background:
    linear-gradient(rgba(4, 14, 30, 0.06), rgba(4, 14, 30, 0.35)),
    var(--admiral-portrait) center / cover no-repeat,
    #071427;
  box-shadow: 0 0 9px color-mix(in srgb, var(--admiral-accent) 40%, transparent);
}

.admiral-avatar.admiral-portrait i {
  position: absolute;
  right: -5px;
  bottom: -4px;
  display: grid;
  place-items: center;
  min-width: 14px;
  height: 14px;
  padding: 0 2px;
  border: 1px solid var(--admiral-accent, var(--hud-cyan));
  border-radius: 999px;
  background: #061326;
  color: #fff;
  font-size: 7px;
  font-style: normal;
}

@keyframes admiral-idle {
  0%, 100% { transform: rotateY(-8deg) translateY(0); }
  50% { transform: rotateY(8deg) translateY(-4px); }
}

@keyframes admiral-ring-pulse {
  0%, 100% { opacity: 0.55; transform: scale(0.96); }
  50% { opacity: 1; transform: scale(1.04); }
}

@media (max-width: 760px) {
  .governor-panel {
    max-height: min(72dvh, 650px);
    overflow: hidden;
  }

  .admiral-collection-layout {
    grid-template-columns: minmax(116px, 0.54fr) minmax(0, 1.46fr);
    gap: 7px;
    max-height: calc(min(72dvh, 650px) - 108px);
  }

  .governor-card.admiral-collection-card {
    grid-template-columns: 1fr;
    padding: 7px;
  }

  .governor-card.admiral-collection-card .governor-card-copy p,
  .governor-card.admiral-collection-card .governor-card-copy small,
  .governor-card.admiral-collection-card > [data-action="assign"] {
    display: none;
  }

  .admiral-portrait-button {
    display: block;
  }

  .admiral-detail {
    grid-template-columns: 1fr;
    padding: 8px;
  }

  .admiral-model-stage {
    min-height: 150px;
  }

  .admiral-hologram-figure {
    top: 10px;
    width: 86px;
    height: 112px;
    background-size: auto, 58px 58px, auto;
  }

  .admiral-hologram-figure span {
    bottom: 7px;
    font-size: 13px;
  }

  .admiral-hologram-figure.has-detail-art {
    top: 6px;
    width: 96px;
    height: 132px;
    background-size: auto, cover, auto;
  }

  .admiral-command-ship-preview {
    right: 7px;
    bottom: 29px;
    width: 42px;
    height: 26px;
  }

  .admiral-tabs,
  .admiral-tab-content {
    grid-column: 1;
  }

  .admiral-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admiral-tabs button {
    min-height: 34px;
    padding: 5px;
    font-size: 8px;
  }

  .admiral-secondary-skills,
  .admiral-talent-tree,
  .admiral-stat-list {
    grid-template-columns: 1fr;
  }

  .admiral-command-ship-card.has-command-ship-art {
    grid-template-columns: 86px minmax(0, 1fr);
  }

  .admiral-command-ship-art {
    width: 84px;
    height: 62px;
  }

  .admiral-identity-line h2 {
    font-size: 19px;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .governor-panel {
    top: 58px;
    bottom: 88px;
    max-height: none;
  }

  .admiral-collection-layout {
    max-height: calc(100dvh - 194px);
  }

  .admiral-model-stage {
    min-height: 164px;
  }
}

.upgrade-node.is-maxed {
  border-color: rgba(97, 223, 122, 0.48);
}

.production-progress,
.power-breakdown-bar {
  grid-column: 1 / -1;
  height: 7px;
  overflow: hidden;
  border: 1px solid rgba(149, 200, 255, 0.2);
  border-radius: 999px;
  background: rgba(2, 7, 16, 0.72);
}

.production-progress span,
.power-breakdown-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--hud-cyan), var(--hud-gold));
}

.power-breakdown-card strong span {
  color: #ffe373;
}

.compartment-details {
  margin-bottom: 12px;
}

.power-toast {
  position: absolute;
  top: calc(max(8px, env(safe-area-inset-top)) + 72px);
  right: max(8px, env(safe-area-inset-right));
  z-index: var(--hud-z-toast);
  padding: 9px 12px;
  border: 1px solid rgba(97, 223, 122, 0.52);
  background: rgba(5, 17, 36, 0.94);
  color: var(--hud-green);
  font-size: 13px;
  font-weight: 900;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity var(--hud-transition), transform var(--hud-transition);
  pointer-events: none;
}

.power-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.power-toast.is-loss {
  border-color: rgba(255, 103, 79, 0.55);
  color: var(--hud-red);
}

body::after {
  position: fixed;
  right: max(8px, env(safe-area-inset-right));
  bottom: calc(max(8px, env(safe-area-inset-bottom)) + 216px);
  z-index: var(--hud-z-toast);
  padding: 7px 9px;
  border: 1px solid rgba(149, 200, 255, 0.22);
  border-radius: 7px;
  background: rgba(5, 17, 36, 0.9);
  color: #c9f2ff;
  content: "Sauvegarde locale";
  font-size: 11px;
  font-weight: 800;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity var(--hud-transition), transform var(--hud-transition);
  pointer-events: none;
}

body.is-saving::after {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 760px) {
  .flagship-nav-button {
    top: 35%;
    width: 42px;
    height: 58px;
    min-height: 58px;
  }

  .flagship-interior-counter {
    top: calc(max(8px, env(safe-area-inset-top)) + 78px);
    max-width: 68vw;
  }

  body.is-flagship-view .flagship-context-panel {
    bottom: max(8px, env(safe-area-inset-bottom));
    max-height: min(46dvh, 420px);
  }

  body.is-flagship-view .compartment-details > p {
    display: -webkit-box;
    margin-bottom: 8px;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  body.is-flagship-view .compartment-tabs {
    display: none;
  }

  body.is-flagship-view .compartment-effect-grid,
  body.is-flagship-view .compartment-module-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.is-flagship-view .compartment-effect-grid span:nth-child(n + 5) {
    display: none;
  }

  body.is-flagship-view .compartment-module-grid span:nth-child(n + 3) {
    display: none;
  }

  .hud-top-status-bar {
    grid-template-columns: minmax(122px, 0.4fr) minmax(0, 0.6fr);
    min-height: 54px;
    padding: 5px;
    gap: 5px;
  }

  .hud-top-status-bar::before {
    inset: 0;
  }

  .commander-chip {
    grid-template-columns: 30px minmax(0, 1fr);
    justify-self: start;
    width: 100%;
    gap: 4px;
  }

  .commander-copy {
    display: none;
  }

  .commander-portrait {
    width: 30px;
    height: 30px;
    border-radius: 7px;
  }

  .commander-copy strong {
    font-size: 11px;
  }

  .commander-copy small {
    font-size: 9px;
  }

  .resource-list,
  .hud-resource-strip {
    grid-template-columns: minmax(88px, 1fr);
    align-items: stretch;
    gap: 4px;
  }

  .hud-resource-counter,
  .power-button {
    grid-template-columns: 24px minmax(0, 1fr);
    min-height: 34px;
    overflow: hidden;
    padding: 3px 5px 3px 3px;
    gap: 4px;
  }

  .hud-top-status-bar .hud-resource-strip .hud-resource-counter {
    grid-template-columns: 22px minmax(0, 1fr);
    min-height: 34px;
    padding: 3px 5px 3px 4px;
  }

  .commander-chip.commander-power-card {
    grid-template-columns: 30px minmax(0, 1fr);
    min-height: 38px;
    padding: 3px 5px 3px 3px;
    gap: 4px;
    min-width: 122px;
  }

  .commander-chip::before {
    display: none;
  }

  .commander-chip::after {
    display: none;
  }

  .hud-resource-icon {
    width: 22px;
    height: 22px;
    background-size: contain;
  }

  .hud-resource-copy small {
    display: none;
  }

  .commander-power-copy small {
    display: block;
    font-size: 7px;
    line-height: 1;
  }

  .commander-power-copy strong {
    font-size: clamp(13px, 3.75vw, 16px);
  }

  .commander-power-copy em {
    display: none;
  }

  .hud-resource-copy strong {
    font-size: clamp(11px, 3.45vw, 14px);
    letter-spacing: 0;
  }

  .secondary-resources-button {
    min-width: 34px;
    min-height: 34px;
  }

  .secondary-resources-panel {
    width: min(246px, calc(100vw - 16px));
  }

  .sector-panel {
    top: calc(max(8px, env(safe-area-inset-top)) + 72px);
    right: calc(max(8px, env(safe-area-inset-right)) + 78px);
    width: auto;
  }

  .hud-sector-status-panel {
    grid-template-columns: minmax(0, 1fr);
    min-height: 78px;
    padding: 8px;
    gap: 7px;
  }

  .sector-copy strong {
    font-size: 15px;
  }

  .sector-copy p {
    margin: 4px 0 7px;
    font-size: 11px;
  }

  .sector-actions {
    grid-template-columns: 82px;
    justify-content: end;
    align-items: center;
  }

  .sector-actions small {
    overflow: hidden;
    text-align: left;
    text-overflow: ellipsis;
  }

  .sector-actions .hud-button {
    min-height: 34px;
    font-size: 11px;
  }

  .admiral-rail,
  .fleet-quick-list {
    top: calc(max(8px, env(safe-area-inset-top)) + 72px);
    right: max(8px, env(safe-area-inset-right));
    bottom: calc(max(8px, env(safe-area-inset-bottom)) + 104px);
    width: 62px;
    padding: 5px;
  }

  .admiral-quick-list {
    gap: 6px;
  }

  .admiral-quick-button,
  .fleet-quick-card {
    grid-template-rows: 12px 25px 12px 5px 9px;
    min-height: 68px;
    padding: 4px 3px;
  }

  .admiral-avatar {
    width: 25px;
    height: 25px;
    font-size: 9px;
  }

  .admiral-ship-code {
    font-size: 8px;
  }

  .fleet-quick-state {
    font-size: 7px;
  }

.bottom-navigation {
  min-height: 74px;
  padding: 2px 8px 0;
  gap: 6px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

  .fleet-summary {
    right: 70px;
    min-height: 36px;
    padding: 6px 9px;
  }

.hud-action,
.bottom-navigation-item {
  grid-template-rows: 38px 14px;
  min-height: 58px;
  padding: 0 2px;
  border: 0;
  background: transparent;
  box-shadow: none;
    font-size: 9px;
}

.bottom-navigation-item::before {
  width: 40px;
  height: 40px;
  filter: drop-shadow(0 0 10px rgba(49, 201, 255, 0.3));
}

.bottom-navigation-item.is-active {
  border-color: transparent;
  box-shadow: none;
}

.bottom-navigation-item span,
.bottom-navigation-item {
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
}

  .selection-panel,
  .contextual-bottom-sheet {
    right: calc(max(8px, env(safe-area-inset-right)) + 70px);
    bottom: calc(env(safe-area-inset-bottom) + 118px);
    grid-template-columns: minmax(0, 1fr) 84px;
    min-height: 88px;
    padding: 9px;
  }

  .selection-copy strong {
    font-size: 13px;
  }

  .selection-copy p {
    font-size: 11px;
  }

  .selection-copy small {
    font-size: 10px;
  }

  .selection-panel button {
    min-height: 52px;
    font-size: 10px;
  }

  .flagship-panel,
  .shipyard-panel,
  .governor-panel,
  .power-panel,
  .drawer-panel {
    left: max(8px, env(safe-area-inset-left));
    right: calc(max(8px, env(safe-area-inset-right)) + 70px);
    bottom: calc(max(8px, env(safe-area-inset-bottom)) + 104px);
    width: auto;
    max-height: min(58dvh, 480px);
    padding: 10px;
  }

  .flagship-context-panel {
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    max-height: min(36dvh, 330px);
    padding: 10px;
  }

  .panel-header {
    top: -10px;
    margin: -10px -10px 10px;
    padding: 10px;
  }

  .panel-header strong {
    font-size: 14px;
  }

  .panel-header p {
    font-size: 11px;
  }

  .panel-header button {
    width: 68px;
    min-height: 36px;
    font-size: 10px;
  }

  .ship-card,
  .governor-card,
  .wing-card,
  .formation-card,
  .upgrade-node,
  .production-model,
  .production-order {
    grid-template-columns: 1fr;
  }

  .ship-card .ship-badge,
  .formation-card .ship-badge,
  .governor-badge {
    display: none;
  }

  .formation-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@supports (-webkit-touch-callout: none) {
  @media (max-width: 760px) and (orientation: portrait) {
    .fleet-panel,
    .bottom-navigation {
      bottom: calc(env(safe-area-inset-bottom) + 12px);
    }

    .selection-panel,
    .contextual-bottom-sheet {
      bottom: calc(env(safe-area-inset-bottom) + 118px);
    }

    .flagship-panel,
    .shipyard-panel,
    .governor-panel,
    .power-panel,
    .drawer-panel {
      bottom: calc(env(safe-area-inset-bottom) + 146px);
    }
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .hud-top-status-bar {
    grid-template-columns: 160px minmax(360px, 1fr);
    min-height: 48px;
  }

  .commander-portrait {
    width: 38px;
    height: 38px;
  }

  .hud-resource-counter,
  .power-button {
    min-height: 34px;
  }

  .sector-panel {
    top: 62px;
    width: min(360px, calc(50vw - 16px));
  }

  .admiral-rail {
    top: 62px;
    bottom: 92px;
  }

  .selection-panel {
    min-height: 76px;
    max-height: 104px;
  }

  .drawer-panel,
  .power-panel,
  .flagship-context-panel {
    top: 118px;
    bottom: 96px;
    max-height: none;
  }
}

body.has-drawer-open .selection-panel,
body.has-drawer-open .contextual-bottom-sheet {
  visibility: hidden;
  pointer-events: none;
}

@media (max-width: 760px) {
  .governor-panel {
    max-height: min(72dvh, 650px);
  }

  .admiral-collection-layout {
    max-height: calc(min(72dvh, 650px) - 108px);
  }

  .governor-card.admiral-collection-card .admiral-portrait-button {
    display: block;
  }
}

/* HUD layout, navigation scale and scrollable commander collection */
.top-bar.hud-top-status-bar {
  position: absolute;
  display: flex;
  grid-template-columns: none;
  align-items: flex-start;
  justify-content: space-between;
  min-height: 0;
  padding: 0;
  gap: 12px;
  overflow: visible;
  border: 0;
  background: transparent;
  box-shadow: none;
  clip-path: none;
  backdrop-filter: none;
  pointer-events: none;
}

.top-bar.hud-top-status-bar::before {
  display: none;
}

.hud-top-block {
  min-width: 0;
  pointer-events: auto;
}

.hud-top-power-block {
  width: min(370px, 38vw);
}

.hud-top-credits-block {
  width: min(520px, 42vw);
  margin-left: auto;
}

.hud-top-power-block .commander-power-card,
.hud-top-credits-block .hud-resource-strip,
.hud-top-credits-block .hud-resource-counter {
  width: 100%;
}

#creditsValue {
  overflow: visible;
  font-variant-numeric: tabular-nums;
  text-overflow: clip;
}

.bottom-navigation {
  min-height: 88px;
  padding-top: 0;
  gap: 10px;
}

.hud-action,
.bottom-navigation-item {
  grid-template-rows: 56px 16px;
  min-height: 76px;
  font-size: 11px;
}

.bottom-navigation-item::before {
  width: 56px;
  height: 56px;
  filter: drop-shadow(0 0 12px rgba(49, 201, 255, 0.34));
}

.governor-panel {
  top: calc(max(8px, env(safe-area-inset-top)) + 66px);
  bottom: calc(max(8px, env(safe-area-inset-bottom)) + 96px);
  display: flex;
  max-height: none;
  flex-direction: column;
  overflow: hidden;
}

.governor-panel > .panel-header,
.governor-panel > .admiral-filters {
  flex: 0 0 auto;
}

.admiral-collection-layout {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
  max-height: none;
  overflow: hidden;
}

.admiral-collection-list,
.admiral-detail {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  scrollbar-gutter: stable;
  touch-action: pan-y;
}

@media (max-width: 760px) {
  .top-bar.hud-top-status-bar {
    gap: 8px;
  }

  .hud-top-power-block {
    width: 38vw;
  }

  .hud-top-credits-block {
    width: 54vw;
  }

  .hud-top-credits-block .hud-resource-counter {
    grid-template-columns: 26px minmax(0, 1fr);
  }

  .hud-top-credits-block .hud-resource-copy strong {
    font-size: clamp(12px, 3.45vw, 14px);
  }

  .bottom-navigation {
    min-height: 86px;
    gap: 7px;
  }

  .hud-action,
  .bottom-navigation-item {
    grid-template-rows: 52px 15px;
    min-height: 72px;
    font-size: 10px;
  }

  .bottom-navigation-item::before {
    width: 52px;
    height: 52px;
  }

  .governor-panel {
    top: calc(max(8px, env(safe-area-inset-top)) + 62px);
    bottom: calc(max(8px, env(safe-area-inset-bottom)) + 96px);
    max-height: none;
  }

  .admiral-collection-layout {
    max-height: none;
  }

  .admiral-rail,
  .fleet-quick-list {
    bottom: auto;
    height: auto;
    max-height: min(
      470px,
      calc(100dvh - max(8px, env(safe-area-inset-top)) - 150px)
    );
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .governor-panel {
    top: 58px;
    bottom: 94px;
    max-height: none;
  }
}
