.space-station-level {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #080c0f;
  color: #f7fbff;
  touch-action: none;
}

.space-station-level::before,
.space-station-level::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.space-station-level::before {
  background:
    radial-gradient(circle at 50% 42%, transparent 52%, rgba(0, 0, 0, 0.16) 100%),
    linear-gradient(180deg, rgba(2, 5, 7, 0.08), transparent 32%, rgba(1, 3, 5, 0.08));
}

.space-station-level::after {
  opacity: 0.12;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.24'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

body:has(.space-station-level) .zephy-buddy,
body:has(.space-station-level) #data-garden-button,
body:has(.space-station-hallways-level) .zephy-buddy,
body:has(.space-station-hallways-level) #data-garden-button {
  display: none !important;
}

.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(260px, 1fr) auto auto;
  gap: 6px;
  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: 48px;
  padding: 0 16px;
  border: 1px solid rgba(194, 218, 224, 0.34);
  border-radius: 7px;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0;
  background: rgba(8, 14, 18, 0.76);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.24);
}

.space-station-brief {
  min-height: 56px;
  padding: 8px 12px;
  border: 1px solid rgba(134, 177, 187, 0.34);
  border-radius: 7px;
  background: rgba(7, 14, 18, 0.72);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(12px);
}

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

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

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

.space-station-stars {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  min-width: 84px;
  padding: 5px 12px;
  border: 1px solid rgba(219, 172, 93, 0.46);
  border-radius: 7px;
  background: rgba(30, 25, 17, 0.76);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.2);
}

.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: 2px;
  align-items: center;
}

.space-station-progress span {
  display: grid;
  place-items: center;
  min-width: 62px;
  min-height: 56px;
  padding: 4px 7px;
  border: 1px solid rgba(188, 211, 216, 0.22);
  border-radius: 4px;
  background: rgba(7, 13, 17, 0.68);
  box-shadow: none;
}

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

.space-station-progress small {
  margin-top: 3px;
  color: #d8e3e4;
  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: 200px;
  min-height: 62px;
  padding: 0 24px;
  border: 1px solid rgba(203, 224, 228, 0.44);
  border-radius: 8px;
  color: #fff;
  font-size: 1.2rem;
  font-weight: 900;
  letter-spacing: 0.01em;
  background: rgba(9, 17, 22, 0.84);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.3);
  pointer-events: auto;
  touch-action: manipulation;
}

.space-station-action.ready {
  border-color: #e6b76e;
  background: rgba(70, 55, 31, 0.92);
  animation: none;
}

.space-station-action:disabled {
  opacity: 0;
  pointer-events: none;
}

@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: 52px;
  height: 52px;
  border: 1px solid rgba(255, 255, 255, 0.46);
  border-radius: 8px;
  font-size: 1.35rem;
  line-height: 1;
  color: #fff;
  background: rgba(8, 15, 19, 0.76);
  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-view-links {
  position: absolute;
  left: max(18px, env(safe-area-inset-left));
  bottom: max(82px, calc(env(safe-area-inset-bottom) + 82px));
  z-index: 4;
  display: flex;
  gap: 8px;
}

.space-station-exterior-link,
.space-station-hallways-link {
  min-height: 48px;
  padding: 0 15px;
  border: 1px solid rgba(140, 225, 238, 0.58);
  border-radius: 7px;
  color: #effcff;
  background: rgba(7, 20, 27, 0.82);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
  font-weight: 900;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.space-station-exterior-link:hover,
.space-station-exterior-link:focus-visible,
.space-station-hallways-link:hover,
.space-station-hallways-link:focus-visible {
  border-color: #b9f7ff;
  outline: 3px solid rgba(185, 247, 255, 0.35);
  outline-offset: 2px;
  background: rgba(20, 67, 78, 0.9);
}

.space-station-hallways-link {
  border-color: rgba(198, 218, 255, 0.62);
  background: rgba(22, 31, 55, 0.86);
}

.space-station-hallways-level {
  position: fixed;
  inset: 0;
  z-index: 250;
  overflow: hidden;
  color: #eff7ff;
  background: #05070d;
}

.space-station-hallways-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #05070d;
}

.space-station-hallways-header {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  z-index: 5;
  display: flex;
  align-items: stretch;
  gap: 10px;
  pointer-events: none;
}

.space-station-hallways-header button,
.space-station-hallways-header div {
  border: 1px solid rgba(190, 218, 255, 0.44);
  border-radius: 8px;
  color: #eff7ff;
  background: rgba(5, 12, 24, 0.82);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(12px);
}

.space-station-hallways-header button {
  min-width: 96px;
  min-height: 52px;
  padding: 0 16px;
  font-weight: 900;
  cursor: pointer;
  pointer-events: auto;
}

.space-station-hallways-header div {
  padding: 9px 14px;
  pointer-events: none;
}

.space-station-hallways-header span {
  display: block;
  color: #8fcfff;
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.15em;
}

.space-station-hallways-header h1 {
  margin: 2px 0 0;
  font-size: clamp(1rem, 2vw, 1.32rem);
}

.space-station-hallways-header p {
  margin: 2px 0 0;
  color: #cbd8e8;
  font-size: 0.72rem;
}

.space-station-exterior-fallback {
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
}

.space-station-exterior-fallback section {
  max-width: 520px;
  padding: 24px;
  border: 1px solid rgba(140, 225, 238, 0.44);
  border-radius: 10px;
  background: rgba(5, 15, 23, 0.88);
}

.space-station-exterior-fallback button {
  min-height: 48px;
  padding: 0 16px;
}

.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: 58px 58px 58px;
  grid-template-rows: 58px 58px;
  gap: 2px;
  padding: 6px;
  border: 1px solid rgba(197, 218, 222, 0.22);
  border-radius: 10px;
  background: rgba(7, 13, 17, 0.56);
  pointer-events: auto;
}

.space-station-pad button {
  width: 58px;
  height: 58px;
  border: 1px solid rgba(203, 223, 226, 0.3);
  border-radius: 5px;
  color: #fff;
  font-size: 1.7rem;
  font-weight: 900;
  background: rgba(10, 18, 22, 0.68);
  box-shadow: none;
  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 {
    grid-template-columns: 1fr auto;
    grid-template-rows: 48px 62px;
    gap: 6px;
  }

  .space-station-brief {
    grid-column: 1 / -1;
    grid-row: 2;
    min-height: 62px;
    padding: 7px 146px 7px 10px;
    overflow: hidden;
  }

  .space-station-brief h1 {
    font-size: 0.96rem;
    white-space: nowrap;
  }

  .space-station-brief p {
    max-width: 25ch;
    font-size: 0.76rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .space-station-kicker {
    font-size: 0.6rem;
  }

  .space-station-progress {
    position: fixed;
    top: calc(max(14px, env(safe-area-inset-top)) + 54px);
    right: calc(max(14px, env(safe-area-inset-right)) + 6px);
    z-index: 1;
    grid-column: initial;
    grid-row: initial;
    gap: 2px;
  }

  .space-station-progress span {
    min-width: 40px;
    min-height: 48px;
    padding: 3px;
  }

  .space-station-progress small {
    display: none;
  }

  .space-station-progress b {
    font-size: 0.98rem;
  }

  .space-station-dots {
    gap: 2px;
    margin-top: 3px;
  }

  .space-station-dots em {
    width: 6px;
    height: 6px;
  }

  .space-station-action {
    left: 50%;
    bottom: max(146px, calc(env(safe-area-inset-bottom) + 146px));
    transform: translateX(-50%);
    min-width: 174px;
    min-height: 60px;
    font-size: 1.08rem;
  }

  .space-station-pad {
    grid-template-columns: 56px 56px 56px;
    grid-template-rows: 56px 56px;
    gap: 2px;
    right: max(10px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
  }

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

  .space-station-recenter {
    left: max(12px, env(safe-area-inset-left));
    bottom: max(12px, env(safe-area-inset-bottom));
  }

  .space-station-view-links {
    left: max(12px, env(safe-area-inset-left));
    bottom: max(76px, calc(env(safe-area-inset-bottom) + 76px));
    width: 176px;
    flex-direction: column;
    align-items: stretch;
    gap: 5px;
  }

  .space-station-exterior-link,
  .space-station-hallways-link {
    min-height: 46px;
    padding: 0 8px;
    font-size: 0.68rem;
    text-align: left;
  }

  .space-station-hallways-header {
    right: max(12px, env(safe-area-inset-right));
  }

  .space-station-hallways-header button {
    min-width: 84px;
    min-height: 48px;
    padding: 0 10px;
  }

  .space-station-hallways-header div {
    flex: 1;
    min-width: 0;
    padding: 7px 10px;
  }

  .space-station-hallways-header h1 {
    font-size: 0.94rem;
  }

  .space-station-hallways-header p {
    overflow: hidden;
    max-width: 30ch;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
}

.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));
  }
}
