.space-station-level {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(
      circle at 12% 18%,
      rgba(120, 238, 255, 0.24),
      transparent 28%
    ),
    radial-gradient(
      circle at 82% 8%,
      rgba(255, 190, 111, 0.22),
      transparent 25%
    ),
    #071225;
  color: #f7fbff;
  touch-action: none;
}

.space-station-stage,
.space-station-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.space-station-stage {
  outline: none;
}

.space-station-canvas {
  display: block;
}

.space-station-hud {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  right: max(14px, env(safe-area-inset-right));
  z-index: 3;
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr) auto auto;
  gap: 10px;
  align-items: stretch;
  pointer-events: none;
}

.space-station-hud button,
.space-station-progress,
.space-station-stars,
.space-station-brief {
  pointer-events: auto;
}

.space-station-exit {
  min-height: 52px;
  padding: 0 18px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 12px;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0;
  background: rgba(8, 18, 38, 0.84);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
}

.space-station-brief {
  min-height: 72px;
  padding: 10px 14px;
  border: 1px solid rgba(139, 232, 255, 0.5);
  border-radius: 12px;
  background: rgba(6, 17, 37, 0.78);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(8px);
}

.space-station-kicker {
  display: block;
  margin: 0 0 2px;
  color: #9ef5ff;
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.space-station-brief h1 {
  margin: 0;
  font-size: clamp(1.05rem, 2.2vw, 1.6rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.space-station-brief p {
  margin: 4px 0 0;
  max-width: 56ch;
  color: #dff9ff;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.25;
}

.space-station-stars {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  min-width: 96px;
  padding: 6px 14px;
  border: 1px solid rgba(255, 215, 94, 0.6);
  border-radius: 14px;
  background: rgba(57, 41, 7, 0.78);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.22);
}

.space-station-stars b {
  font-size: 1.5rem;
  line-height: 1;
}

.space-station-stars span {
  color: #ffe9a3;
  font-size: 1.25rem;
  font-weight: 900;
  line-height: 1;
}

.space-station-progress {
  display: flex;
  gap: 8px;
  align-items: center;
}

.space-station-progress span {
  display: grid;
  place-items: center;
  min-width: 70px;
  min-height: 70px;
  padding: 6px 8px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 12px;
  background: rgba(7, 16, 35, 0.78);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.22);
}

.space-station-progress b {
  font-size: 1.45rem;
  line-height: 1;
}

.space-station-progress small {
  margin-top: 3px;
  color: #d8f8ff;
  font-size: 0.74rem;
  font-weight: 900;
  line-height: 1;
}

.space-station-dots {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  font-style: normal;
}

.space-station-dots em {
  width: 9px;
  height: 9px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}

/* Each pill is tinted with its own zone brand colour (passed in as --zone)
   so the HUD reads as the same teal / orange / purple identity the player
   sees on the matching station in 3D. Falls back to gold if unset. */
.space-station-dots em.on {
  border-color: var(--zone, #ffd166);
  background: var(--zone, #ffd166);
  box-shadow: 0 0 6px color-mix(in srgb, var(--zone, #ffd166) 80%, transparent);
}

.space-station-progress span.near {
  border-color: var(--zone, #ffd166);
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--zone, #ffd166) 32%, transparent),
    0 12px 24px rgba(0, 0, 0, 0.22);
  transform: scale(1.06);
}

.space-station-progress span.found {
  border-color: var(--zone, #68f7b0);
  background: color-mix(in srgb, var(--zone, #68f7b0) 24%, rgba(7, 16, 35, 0.82));
}

.space-station-progress span.found .space-station-dots em {
  border-color: var(--zone, #68f7b0);
  background: var(--zone, #68f7b0);
  box-shadow: none;
}

.space-station-action {
  position: absolute;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 4;
  transform: translateX(-50%);
  min-width: 220px;
  min-height: 76px;
  padding: 0 28px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 22px;
  color: #fff;
  font-size: 1.55rem;
  font-weight: 900;
  letter-spacing: 0.01em;
  background: rgba(18, 31, 53, 0.86);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.32);
  pointer-events: auto;
  touch-action: manipulation;
}

.space-station-action.ready {
  border-color: #ffe9a3;
  background: linear-gradient(
    135deg,
    rgba(21, 117, 94, 0.95),
    rgba(236, 129, 62, 0.95)
  );
  animation: space-station-action-pulse 1.1s ease-in-out infinite;
}

.space-station-action:disabled {
  opacity: 0.78;
}

@keyframes space-station-action-pulse {
  0%,
  100% {
    transform: translateX(-50%) scale(1);
    box-shadow: 0 16px 34px rgba(0, 0, 0, 0.32);
  }
  50% {
    transform: translateX(-50%) scale(1.05);
    box-shadow: 0 18px 40px rgba(255, 209, 102, 0.3);
  }
}

@media (prefers-reduced-motion: reduce) {
  .space-station-action.ready {
    animation: none;
  }
}

.space-station-recenter {
  position: absolute;
  left: max(18px, env(safe-area-inset-left));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 4;
  width: 60px;
  height: 60px;
  border: 1px solid rgba(255, 255, 255, 0.46);
  border-radius: 16px;
  font-size: 1.7rem;
  line-height: 1;
  color: #fff;
  background: rgba(9, 23, 47, 0.82);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.24);
  pointer-events: auto;
  touch-action: manipulation;
}

.space-station-recenter:active {
  background: rgba(43, 84, 134, 0.92);
  transform: scale(0.94);
}

.space-station-recenter:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.space-station-pad {
  position: absolute;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 4;
  display: grid;
  grid-template-columns: 64px 64px 64px;
  grid-template-rows: 64px 64px;
  gap: 10px;
  pointer-events: auto;
}

.space-station-pad button {
  width: 64px;
  height: 64px;
  border: 1px solid rgba(255, 255, 255, 0.46);
  border-radius: 14px;
  color: #fff;
  font-size: 1.7rem;
  font-weight: 900;
  background: rgba(9, 23, 47, 0.82);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.24);
  touch-action: none;
}

.space-station-pad button:active {
  background: rgba(43, 84, 134, 0.92);
  transform: scale(0.94);
}

.space-station-pad button:first-child {
  grid-column: 2;
}

.space-station-pad button:nth-child(2) {
  grid-column: 1;
  grid-row: 2;
}

.space-station-pad button:nth-child(3) {
  grid-column: 2;
  grid-row: 2;
}

.space-station-pad button:nth-child(4) {
  grid-column: 3;
  grid-row: 2;
}

.space-station-exit:focus-visible,
.space-station-action:focus-visible,
.space-station-pad button:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

@media (max-width: 820px) {
  .space-station-hud {
    grid-template-columns: 1fr auto;
  }

  .space-station-exit {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
  }

  .space-station-stars {
    grid-column: 2;
    grid-row: 1;
  }

  .space-station-brief {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .space-station-progress {
    grid-column: 1 / -1;
    grid-row: 3;
    justify-content: start;
  }

  .space-station-progress span {
    min-width: 62px;
    min-height: 62px;
  }

  .space-station-action {
    left: max(18px, env(safe-area-inset-left));
    transform: none;
    min-width: 170px;
  }

  .space-station-action.ready {
    animation: none;
  }
}

@media (max-width: 560px) {
  .space-station-hud {
    gap: 8px;
  }

  .space-station-brief {
    min-height: 66px;
    padding: 9px 10px;
  }

  .space-station-brief h1 {
    font-size: 1.05rem;
  }

  .space-station-brief p {
    font-size: 0.9rem;
  }

  .space-station-progress span {
    min-width: 56px;
    min-height: 56px;
    padding: 4px 5px;
  }

  .space-station-progress small {
    font-size: 0.64rem;
  }

  .space-station-action {
    min-width: 150px;
    min-height: 66px;
    font-size: 1.3rem;
  }

  .space-station-pad {
    grid-template-columns: 56px 56px 56px;
    grid-template-rows: 56px 56px;
    gap: 8px;
  }

  .space-station-pad button {
    width: 56px;
    height: 56px;
    font-size: 1.5rem;
  }
}

.ship-boarding-cutscene {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #050812;
  color: #f6fbff;
}

.ship-boarding-stage,
.ship-boarding-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.ship-boarding-hud {
  position: absolute;
  left: max(22px, env(safe-area-inset-left));
  top: max(22px, env(safe-area-inset-top));
  max-width: min(460px, calc(100vw - 44px));
  padding: 14px 16px;
  border: 1px solid rgba(147, 219, 255, 0.42);
  border-radius: 8px;
  background: rgba(4, 10, 20, 0.64);
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(12px);
}

.ship-boarding-hud span {
  display: block;
  color: #93dbff;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ship-boarding-hud h1 {
  margin: 4px 0 0;
  font-size: clamp(1.45rem, 2.4vw, 2.15rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.ship-boarding-skip,
.ship-boarding-exit {
  position: absolute;
  z-index: 2;
  min-height: 46px;
  border: 1px solid rgba(147, 219, 255, 0.5);
  border-radius: 8px;
  color: #f7fcff;
  background: rgba(8, 18, 31, 0.72);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
  font-weight: 900;
  cursor: pointer;
  backdrop-filter: blur(12px);
}

.ship-boarding-skip {
  right: max(22px, env(safe-area-inset-right));
  bottom: max(22px, env(safe-area-inset-bottom));
  padding: 0 18px;
}

.ship-boarding-exit {
  left: max(22px, env(safe-area-inset-left));
  bottom: max(22px, env(safe-area-inset-bottom));
  padding: 0 16px;
}

.ship-boarding-skip:hover,
.ship-boarding-exit:hover {
  border-color: rgba(255, 215, 121, 0.8);
  background: rgba(19, 31, 48, 0.86);
}

@media (max-width: 560px) {
  .ship-boarding-hud {
    left: 14px;
    right: 14px;
    top: max(14px, env(safe-area-inset-top));
    max-width: none;
    padding: 12px 13px;
  }

  .ship-boarding-hud h1 {
    font-size: 1.35rem;
  }

  .ship-boarding-skip,
  .ship-boarding-exit {
    bottom: max(14px, env(safe-area-inset-bottom));
  }
}
