#moon-surface {
  overflow: clip;
  scroll-margin-block-start: 112px;
}

.moon-surface__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: clamp(10px, 2vw, 18px);
  border-bottom: 1px solid var(--line);
}
.moon-surface__toolbar h2 { margin: 0; font: 660 clamp(1.05rem, 2vw, 1.45rem) var(--heading); }
.moon-surface__toolbar p, .moon-facility-card p, .moon-construction p { margin: 4px 0 0; color: var(--muted); font-size: .84rem; }
.moon-surface__landscape {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  aspect-ratio: 2.45;
  --lunar-terrain: url('assets/moon-surface.jpg') center bottom / 100% 83% no-repeat;
  background: #090a0d;
}
.moon-surface__landscape::before {
  content: '';
  position: absolute;
  z-index: -1;
  inset: 0;
  background: var(--lunar-terrain);
  -webkit-mask-image: linear-gradient(transparent 17%, #000 25%);
  mask-image: linear-gradient(transparent 17%, #000 25%);
  pointer-events: none;
}
.moon-surface__landscape::after {
  content: '';
  position: absolute;
  z-index: 1;
  inset: 0;
  background: var(--lunar-terrain);
  /* The matching foreground ridge hides the bottom limb of the actual parent planet. */
  clip-path: polygon(71% 32.4%, 75% 32.2%, 77% 32.2%, 80% 30.5%, 82% 29.3%, 86% 29.5%,
    89% 28.6%, 91% 28.7%, 94% 28%, 97% 29%, 97% 100%, 71% 100%);
  pointer-events: none;
}
.moon-surface__planet {
  position: absolute;
  z-index: 0;
  inset: 3% auto auto 75%;
  inline-size: 15%;
  filter: drop-shadow(0 0 10px #9fb3d444);
  pointer-events: none;
}
.moon-surface__planet[data-climate='arid'] { inline-size: 13%; inset-inline-start: 76%; }
.moon-surface__planet[data-climate='cold'] { inline-size: 17%; inset-inline-start: 74%; }
.moon-surface__landscape .site-roads { z-index: 2; opacity: .8; }
.moon-surface__site {
  position: absolute;
  z-index: var(--site-depth);
  left: var(--site-x);
  top: var(--site-y);
  inline-size: var(--site-width);
  transform: translate(-50%, -91%);
}
.moon-surface__site::before {
  content: '';
  position: absolute;
  inset: 80% -12% -12%;
  border-radius: 50%;
  background:
    radial-gradient(ellipse at 42% 42%, #0c0d1180, transparent 70%),
    radial-gradient(ellipse at 51% 58%, #b8b2a955, #43454a80 48%, transparent 75%);
  pointer-events: none;
}
.moon-surface__site button {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
}
.moon-surface__site button:focus-visible { outline: 2px solid #cae7ff; }
.moon-surface__site .moon-facility-art {
  width: 100%;
  aspect-ratio: 1.45;
  background: transparent;
  overflow: visible;
  filter: saturate(.66) contrast(1.02) drop-shadow(4px 5px 3px #020308a8);
}
.moon-surface__site img.moon-facility-art {
  display: block;
  block-size: auto;
  aspect-ratio: auto;
  filter: none;
}
.moon-surface__site[data-moon-site='moon-dock']::before,
.moon-surface__site[data-moon-site='lunar-rescue']::before { display: none; }
.moon-harbor-lighting {
  position: absolute;
  z-index: 90;
  inset: 0;
  pointer-events: none;
}
.moon-harbor-lighting::before {
  content: '';
  position: absolute;
  inset: 0;
  mix-blend-mode: screen;
  background:
    radial-gradient(ellipse, #fff5cd 0 9%, #ffb264 16%, #f4943b61 34%, transparent 69%) 28.5% 58.5% / 2.4% 5.5% no-repeat,
    radial-gradient(ellipse, #fff5cd 0 9%, #ffb264 16%, #f4943b61 34%, transparent 69%) 35.8% 60% / 2.4% 5.5% no-repeat,
    radial-gradient(ellipse, #ffcf8d91 1%, #ffae474d 28%, transparent 72%) 32.8% 69.5% / 19% 22% no-repeat,
    radial-gradient(ellipse, #f8a45037 0%, transparent 72%) 33.6% 82% / 27% 14% no-repeat;
}
.moon-harbor-lighting[data-approach-active]::after {
  content: '';
  position: absolute;
  inset: 0;
  clip-path: polygon(25% 81%, 37% 81%, 49.7% 100%, 34.8% 100%);
  background: linear-gradient(180deg, transparent 80%, #ffcd7d38 97%, #ffbc694a);
  mix-blend-mode: screen;
  animation: moon-approach-lights .65s ease-out both;
}
.moon-harbor-lighting > i { display: none; }
.moon-harbor-lighting[data-approach-active] > i {
  display: block;
  position: absolute;
  z-index: 1;
  top: 82%;
  height: 3%;
  transform-origin: left center;
  background: radial-gradient(ellipse, #fff9dc 0 11%, #ffdc80 17% 24%, #ff8d306b 38%, transparent 68%)
    left center / 16.6667% 100% repeat-x;
  -webkit-mask-image: linear-gradient(90deg, #0009, #000 65%);
  mask-image: linear-gradient(90deg, #0009, #000 65%);
  animation: moon-approach-lights .65s ease-out both;
}
/* Perspective along the existing drydock apron, from its door to the foreground. */
.moon-harbor-lighting > i:first-child {
  left: 26.1%;
  width: 12.2%;
  transform: translateY(-50%) rotate(42deg);
}
.moon-harbor-lighting > i:last-child {
  left: 36.8%;
  width: 15.1%;
  transform: translateY(-50%) rotate(29deg);
}
@keyframes moon-approach-lights {
  from { opacity: 0; }
  to { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .moon-harbor-lighting[data-approach-active]::after,
  .moon-harbor-lighting[data-approach-active] > i { animation: none; }
}
.moon-facility-art > .colony-architecture {
  width: 100%;
  max-height: 100%;
}
.moon-surface__badge {
  position: absolute;
  right: 12%;
  bottom: 1%;
  padding: .05em .35em;
  background: #101823ed;
  color: #d3e1ef;
  border: 1px solid #9bbad577;
  border-radius: 4px;
  font-size: clamp(.52rem, 1.45vw, .77rem);
  font-weight: 650;
  line-height: 1.4;
  pointer-events: none;
}

.moon-facilities {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  align-items: start;
  gap: 10px;
  padding: clamp(10px, 2vw, 18px);
}
.moon-facility-card, .moon-construction__option {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #121e30;
  min-inline-size: 0;
}
.moon-facility-card { scroll-margin-block-start: 110px; }
.moon-facility-card h3, .moon-construction h3 {
  margin: 0;
  font: 650 .97rem var(--heading);
  overflow-wrap: anywhere;
}
.moon-facility-card button, .moon-construction button { display: block; margin-top: 8px; max-inline-size: 100%; }
.moon-facility-card [data-action='toggle-moon-harbor-lighting'][aria-pressed='true'] {
  border-color: #b3834d;
  background: #31281f;
  color: #ffdfa9;
}
.moon-research-link { margin: 0 clamp(10px, 2vw, 18px) clamp(10px, 2vw, 18px); }
.moon-construction { display: grid; gap: 8px; }
.moon-construction__option strong { color: #e4ebf3; font-size: .9rem; }
.moon-construction__progress progress { display: block; width: 100%; block-size: 8px; accent-color: #dfab66; }
.moon-construction__progress > div { display: flex; justify-content: space-between; gap: 8px; margin-top: 5px; font-size: .82rem; }
.moon-construction__progress time { color: var(--muted); font-variant-numeric: tabular-nums; }

.moon-checklist {
  min-inline-size: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #101b2c;
}
.moon-checklist h3 { margin: 0 0 8px; font: 650 .97rem var(--heading); }
.moon-checklist h4 { margin: 0 0 6px; color: var(--muted); font: 610 .83rem var(--heading); }
.moon-checklist__groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr));
  gap: 10px;
}
.moon-checklist__groups > div { min-inline-size: 0; overflow-wrap: anywhere; }
.moon-checklist .catalog-requirements { display: grid; gap: 4px; }
.moon-checklist .catalog-requirements button {
  inline-size: 100%;
  margin: 0;
  padding-block: 4px;
  color: #e4ebf3;
}
.moon-checklist .catalog-requirements button[data-pending] { border-color: #775e36; background: #2b251e; color: #f0d2a3; }
.moon-checklist .catalog-requirements button small { display: block; font-size: .73rem; font-variant-numeric: tabular-nums; }

@media (max-width: 860px) and (orientation: landscape) {
  .moon-surface__toolbar { padding: 8px 10px; }
  .moon-surface__toolbar p { font-size: .74rem; }
  .moon-facilities { grid-template-columns: repeat(auto-fit, minmax(min(100%, 166px), 1fr)); gap: 7px; }
  .moon-facility-card { scroll-margin-block-start: 64px; }
}
