@font-face {
  font-family: "Foundry Mono";
  src: local("SFMono-Regular"), local("Consolas"), local("Liberation Mono");
}

:root {
  color-scheme: dark;
  --bg: #07090c;
  --panel: rgba(14, 19, 24, 0.76);
  --panel-solid: #0e1318;
  --line: rgba(201, 233, 220, 0.12);
  --line-bright: rgba(255, 159, 67, 0.34);
  --text: #f1f6f2;
  --muted: #88928f;
  --faint: #596360;
  --acid: #ff9f43;
  --acid-soft: #e48835;
  --cyan: #66e8d0;
  --ocean: #1786a3;
  --land: #7fa56e;
  --danger: #ff755f;
  --radius: 18px;
  --mono: "Foundry Mono", "SFMono-Regular", Consolas, monospace;
  --sans: Inter, "Avenir Next", "Segoe UI", Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% 38%, rgba(31, 77, 72, 0.13), transparent 32rem),
    radial-gradient(circle at 10% 100%, rgba(115, 151, 42, 0.05), transparent 30rem),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid var(--acid);
  outline-offset: 3px;
}

.starfield {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 13% 22%, rgba(255, 255, 255, 0.72) 0 0.7px, transparent 1px),
    radial-gradient(circle at 72% 12%, rgba(183, 238, 220, 0.5) 0 0.8px, transparent 1px),
    radial-gradient(circle at 44% 82%, rgba(255, 255, 255, 0.5) 0 0.7px, transparent 1px),
    radial-gradient(circle at 89% 69%, rgba(180, 220, 210, 0.44) 0 0.9px, transparent 1px);
  background-size: 170px 170px, 230px 230px, 270px 270px, 340px 340px;
  opacity: 0.55;
  mask-image: linear-gradient(to bottom, black, transparent 96%);
}

.app-shell {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar,
.bottombar {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  border-color: var(--line);
  border-style: solid;
  backdrop-filter: blur(18px);
  background: rgba(7, 9, 12, 0.72);
}

.topbar {
  min-height: 74px;
  justify-content: space-between;
  padding: 0 28px;
  border-width: 0 0 1px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  position: relative;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
}

.brand-core {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--acid);
  box-shadow: 0 0 20px rgba(255, 159, 67, 0.55);
}

.brand-orbit {
  position: absolute;
  inset: 6px 1px;
  border: 1px solid var(--acid);
  border-radius: 50%;
  transform: rotate(-25deg);
}

.brand-orbit::after {
  content: "";
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  top: 1px;
  right: 5px;
  background: var(--acid);
}

.brand strong {
  display: block;
  font-size: 13px;
  letter-spacing: 0.18em;
}

.brand small {
  display: block;
  margin-top: 3px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.17em;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--acid);
  box-shadow: 0 0 11px var(--acid);
  animation: blink 1.8s ease-in-out infinite;
}

.header-divider {
  width: 1px;
  height: 17px;
  margin: 0 5px;
  background: var(--line);
}

.header-actions,
.view-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.library-button {
  position: relative;
}

.world-count {
  min-width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  margin-left: 2px;
  border-radius: 9px;
  background: rgba(255, 159, 67, 0.12);
  color: var(--acid);
  font-size: 8px;
}

.button,
.icon-button,
.view-button,
.copy-button,
.preset {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease;
}

.button:hover,
.icon-button:hover,
.view-button:hover,
.copy-button:hover,
.preset:hover {
  border-color: var(--line-bright);
  background: rgba(255, 159, 67, 0.07);
}

.button:active,
.icon-button:active,
.view-button:active,
.preset:active {
  transform: translateY(1px);
}

.button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 15px;
  border-radius: 10px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.button-primary {
  width: 100%;
  min-height: 48px;
  justify-content: flex-start;
  padding: 0 15px;
  border-color: var(--acid);
  background: var(--acid);
  color: #211207;
  font-weight: 700;
}

.button-primary:hover {
  background: #ffb565;
  border-color: #ffb565;
}

.button-primary .shortcut {
  margin-left: auto;
  min-width: 22px;
  padding: 4px;
  border: 1px solid rgba(10, 20, 8, 0.18);
  border-radius: 5px;
  text-align: center;
}

.icon-button,
.copy-button,
.view-button {
  display: grid;
  place-items: center;
  border-radius: 9px;
}

.icon-button {
  width: 42px;
  height: 42px;
  color: var(--muted);
}

.workspace {
  flex: 1;
  min-height: calc(100vh - 112px);
  display: grid;
  grid-template-columns: 300px minmax(420px, 1fr) 300px;
}

.glass-panel {
  position: relative;
  z-index: 3;
  padding: 25px 24px;
  background: linear-gradient(180deg, rgba(14, 19, 24, 0.9), rgba(10, 14, 18, 0.82));
  backdrop-filter: blur(24px);
}

.control-panel {
  border-right: 1px solid var(--line);
}

.telemetry-panel {
  border-left: 1px solid var(--line);
}

.panel-intro {
  margin-bottom: 20px;
}

.eyebrow,
.section-label,
.telemetry-heading small,
.score-ring small,
.world-score > span small,
.telemetry-grid small,
.discovery-card small {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--acid);
}

.panel-intro h1 {
  margin: 0;
  max-width: 220px;
  font-size: 27px;
  line-height: 1.04;
  letter-spacing: -0.04em;
}

.panel-intro > p:last-child {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.seed-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 12px 0 22px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.18);
}

.world-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  margin: -11px 0 22px;
}

.mini-action {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease;
}

.mini-action span {
  color: var(--acid);
  font-size: 10px;
}

.mini-action:hover {
  border-color: var(--line-bright);
  background: rgba(255, 159, 67, 0.06);
  color: var(--text);
}

.seed-card small {
  display: block;
  margin-bottom: 4px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.12em;
}

.seed-card code {
  color: #c3ccc8;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
}

.copy-button {
  width: 30px;
  height: 30px;
  color: var(--muted);
}

.section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-label span:last-child {
  color: var(--faint);
}

.preset-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  max-height: 252px;
  padding-right: 5px;
  overflow-y: auto;
  scrollbar-color: var(--line-bright) transparent;
  scrollbar-width: thin;
}

.preset {
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 9px;
  border-radius: 8px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.04em;
}

.preset span {
  color: var(--acid);
  font-size: 13px;
}

.preset.active {
  border-color: var(--line-bright);
  background: rgba(255, 159, 67, 0.08);
  color: var(--text);
}

.parameter-list {
  display: grid;
  gap: 17px;
  margin: 23px 0 21px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.parameter {
  display: block;
}

.parameter-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 9px;
  color: #cbd2cf;
  font-size: 10px;
}

.parameter-heading > span {
  display: flex;
  align-items: center;
  gap: 9px;
}

.parameter output {
  color: var(--acid);
  font-family: var(--mono);
  font-size: 9px;
}

.parameter-icon {
  width: 14px;
  height: 14px;
  display: inline-block;
  position: relative;
  opacity: 0.8;
}

.terrain-icon {
  border-bottom: 1px solid var(--muted);
  clip-path: polygon(0 100%, 22% 45%, 42% 72%, 68% 13%, 100% 100%);
  background: var(--muted);
}

.ocean-icon::before,
.ocean-icon::after {
  content: "";
  position: absolute;
  left: 0;
  width: 13px;
  height: 3px;
  border-top: 1px solid var(--muted);
  border-radius: 50%;
}

.ocean-icon::before { top: 4px; }
.ocean-icon::after { top: 9px; }

.temp-icon {
  width: 6px;
  margin-left: 4px;
  border: 1px solid var(--muted);
  border-radius: 5px;
}

.temp-icon::after {
  content: "";
  position: absolute;
  width: 6px;
  height: 6px;
  left: -1px;
  bottom: -2px;
  border-radius: 50%;
  background: var(--muted);
}

.atmosphere-icon {
  border: 1px solid var(--muted);
  border-radius: 50%;
}

.atmosphere-icon::after {
  content: "";
  position: absolute;
  inset: 3px -3px;
  border: 1px solid var(--muted);
  border-radius: 50%;
  transform: rotate(-24deg);
}

input[type="range"] {
  width: 100%;
  height: 4px;
  display: block;
  appearance: none;
  border-radius: 5px;
  background: linear-gradient(to right, var(--acid) 0 var(--range-progress, 50%), #25302d var(--range-progress, 50%) 100%);
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  width: 13px;
  height: 13px;
  appearance: none;
  border: 3px solid var(--panel-solid);
  border-radius: 50%;
  background: var(--acid);
  box-shadow: 0 0 0 1px var(--acid), 0 0 10px rgba(255, 159, 67, 0.22);
}

input[type="range"]::-moz-range-thumb {
  width: 8px;
  height: 8px;
  border: 3px solid var(--panel-solid);
  border-radius: 50%;
  background: var(--acid);
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  border-top: 1px solid var(--line);
}

.switch-row strong {
  display: block;
  color: #c7cfcc;
  font-size: 10px;
  font-weight: 500;
}

.switch-row small {
  display: block;
  margin-top: 3px;
  color: var(--faint);
  font-size: 8px;
}

.switch {
  width: 34px;
  height: 19px;
  position: relative;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #202725;
  cursor: pointer;
}

.switch span {
  position: absolute;
  width: 13px;
  height: 13px;
  top: 2px;
  left: 3px;
  border-radius: 50%;
  background: #77807d;
  transition: transform 180ms ease, background 180ms ease;
}

.switch[aria-checked="true"] {
  border-color: rgba(255, 159, 67, 0.45);
  background: rgba(255, 159, 67, 0.16);
}

.switch[aria-checked="true"] span {
  transform: translateX(14px);
  background: var(--acid);
}

.planet-stage {
  min-width: 0;
  min-height: 610px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(rgba(255, 255, 255, 0.016) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.016) 1px, transparent 1px);
  background-size: 64px 64px;
}

.planet-stage::before,
.planet-stage::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.planet-stage::before {
  width: 70%;
  height: 70%;
  left: 15%;
  top: 13%;
  background: radial-gradient(circle, rgba(55, 126, 113, 0.09), transparent 64%);
  filter: blur(20px);
}

.planet-stage::after {
  inset: 0;
  border: 1px solid transparent;
  background:
    linear-gradient(to right, rgba(255, 159, 67, 0.23), rgba(255, 159, 67, 0.23)) 22px 22px / 25px 1px no-repeat,
    linear-gradient(to bottom, rgba(255, 159, 67, 0.23), rgba(255, 159, 67, 0.23)) 22px 22px / 1px 25px no-repeat,
    linear-gradient(to left, rgba(255, 159, 67, 0.23), rgba(255, 159, 67, 0.23)) calc(100% - 22px) calc(100% - 22px) / 25px 1px no-repeat,
    linear-gradient(to top, rgba(255, 159, 67, 0.23), rgba(255, 159, 67, 0.23)) calc(100% - 22px) calc(100% - 22px) / 1px 25px no-repeat;
}

.stage-meta {
  position: relative;
  z-index: 4;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 24px 27px;
}

.coordinate-readout span {
  display: block;
  color: #b9c3bf;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.13em;
}

.coordinate-readout small {
  display: block;
  margin-top: 6px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.1em;
}

.coordinate-readout b {
  color: var(--acid);
  font-weight: 500;
}

.view-controls {
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(5, 8, 10, 0.5);
}

.view-button {
  width: 29px;
  height: 29px;
  border-color: transparent;
  color: var(--muted);
  font-size: 13px;
}

.view-button[title] {
  position: relative;
}

.view-button.active {
  background: rgba(255, 159, 67, 0.11);
  color: var(--acid);
}

.planet-wrap {
  width: min(72vh, 670px);
  height: min(72vh, 670px);
  min-width: 420px;
  min-height: 420px;
  position: absolute;
  left: 50%;
  top: 48%;
  transform: translate(-50%, -50%);
  cursor: grab;
  touch-action: none;
  transition: transform 180ms ease;
}

.map-legend {
  min-width: 300px;
  position: absolute;
  z-index: 6;
  left: 27px;
  bottom: 92px;
  padding: 12px;
  border: 1px solid rgba(255, 159, 67, 0.18);
  border-radius: 9px;
  background: rgba(8, 13, 15, 0.82);
  backdrop-filter: blur(14px);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.map-legend.visible {
  opacity: 1;
  transform: translateY(0);
}

.map-legend-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  color: var(--acid);
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.1em;
}

.map-legend-heading small {
  color: var(--faint);
  font-size: 6px;
}

.legend-set {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px 13px;
  margin-top: 10px;
}

.biome-legend {
  grid-template-columns: repeat(3, 1fr);
}

.legend-set span {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 7px;
}

.legend-set i {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--key);
  box-shadow: 0 0 6px color-mix(in srgb, var(--key) 45%, transparent);
}

.climate-legend {
  display: none;
}

.map-legend.climate .biome-legend {
  display: none;
}

.map-legend.climate .climate-legend {
  display: grid;
}

.surface-marker {
  width: 18px;
  height: 18px;
  display: none;
  position: absolute;
  z-index: 8;
  padding: 0;
  border: 1px solid var(--acid);
  border-radius: 50%;
  background: rgba(255, 159, 67, 0.12);
  box-shadow: 0 0 0 4px rgba(255, 159, 67, 0.08), 0 0 18px rgba(255, 159, 67, 0.42);
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.surface-marker::before,
.surface-marker::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  background: var(--acid);
  transform: translate(-50%, -50%);
}

.surface-marker::before {
  width: 4px;
  height: 4px;
  border-radius: 50%;
}

.surface-marker::after {
  width: 26px;
  height: 1px;
  opacity: 0.45;
}

.surface-marker.visible {
  display: block;
}

.surface-inspector {
  width: 260px;
  position: absolute;
  z-index: 8;
  right: 27px;
  bottom: 91px;
  padding: 14px;
  border: 1px solid rgba(255, 159, 67, 0.21);
  border-radius: 10px;
  background: rgba(8, 13, 15, 0.9);
  backdrop-filter: blur(16px);
  opacity: 0;
  visibility: hidden;
  transform: translateY(9px);
  transition: opacity 160ms ease, visibility 160ms ease, transform 160ms ease;
}

.surface-inspector.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.surface-inspector header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.surface-inspector header small,
.surface-inspector header strong {
  display: block;
}

.surface-inspector header small,
.inspect-grid small,
.inspect-coordinates small {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 6px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.surface-inspector header strong {
  margin-top: 4px;
  color: var(--acid);
  font-size: 11px;
  letter-spacing: 0.02em;
}

.surface-inspector header button {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.surface-inspector header button:hover {
  border-color: var(--line-bright);
  color: var(--acid);
}

.inspect-coordinates {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 0;
  color: #c6ceca;
  font-family: var(--mono);
  font-size: 8px;
}

.inspect-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.inspect-grid > span {
  padding: 9px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.inspect-grid strong {
  display: block;
  margin-top: 5px;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 500;
}

.surface-inspector p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.5;
}

.planet-wrap.dragging {
  cursor: grabbing;
}

.planet-wrap.inspect-mode:not(.dragging) {
  cursor: crosshair;
}

#planetCanvas {
  width: 100%;
  height: 100%;
  display: block;
  position: relative;
  z-index: 2;
  filter: saturate(1.05) contrast(1.03);
}

.moon-system {
  position: absolute;
  z-index: 5;
  inset: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.moon-orbit-path {
  position: absolute;
  left: 50%;
  top: 50%;
  border: 1px solid rgba(160, 184, 177, 0.08);
  border-radius: 50%;
  transform: translate(-50%, -50%) rotate(var(--orbit-tilt));
}

.generated-moon {
  position: absolute;
  overflow: hidden;
  border: 1px solid rgba(225, 236, 230, 0.26);
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 38%, rgba(12, 16, 17, 0.28) 0 7%, transparent 8%),
    radial-gradient(circle at 67% 63%, rgba(10, 14, 15, 0.22) 0 10%, transparent 11%),
    radial-gradient(circle at 70% 26%, rgba(255, 255, 255, 0.12) 0 5%, transparent 6%),
    radial-gradient(circle at 33% 28%, var(--moon-light) 0, var(--moon-color) 45%, var(--moon-dark) 100%);
  box-shadow:
    inset -7px -5px 10px rgba(0, 0, 0, 0.45),
    0 0 12px rgba(161, 198, 191, 0.2);
  will-change: left, top, transform, opacity;
}

.generated-moon::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: linear-gradient(115deg, rgba(255,255,255,0.12), transparent 42%, rgba(0,0,0,0.28));
}

.webgl-error {
  width: 280px;
  position: absolute;
  left: 50%;
  top: 50%;
  padding: 20px;
  border: 1px solid rgba(255, 117, 95, 0.35);
  border-radius: 10px;
  background: rgba(18, 11, 12, 0.9);
  text-align: center;
  transform: translate(-50%, -50%);
}

.webgl-error strong,
.webgl-error span {
  display: block;
}

.webgl-error strong {
  color: var(--danger);
}

.webgl-error span {
  margin-top: 7px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.orbit {
  position: absolute;
  pointer-events: none;
  border: 1px solid rgba(126, 160, 151, 0.1);
  border-radius: 50%;
}

.orbit-one {
  inset: 13%;
  transform: rotate(-18deg) scaleY(0.38);
}

.orbit-two {
  inset: 5%;
  border-style: dashed;
  transform: rotate(35deg) scaleY(0.55);
  opacity: 0.5;
}

.planet-label {
  position: absolute;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.1em;
  pointer-events: none;
}

.planet-label i {
  display: block;
  width: 70px;
  height: 1px;
  margin-top: 5px;
  background: linear-gradient(90deg, rgba(136, 146, 143, 0.5), transparent);
}

.label-a {
  top: 22%;
  right: -2%;
}

.label-b {
  bottom: 25%;
  left: -2%;
}

.label-b i {
  transform: scaleX(-1);
}

.evolution-event {
  width: min(440px, calc(100% - 54px));
  min-height: 62px;
  position: absolute;
  z-index: 6;
  left: 27px;
  top: 78px;
  display: grid;
  grid-template-columns: 32px 1fr 88px;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(102, 232, 208, 0.13);
  border-radius: 9px;
  background: rgba(7, 12, 14, 0.76);
  backdrop-filter: blur(14px);
  pointer-events: none;
  transition: border-color 180ms ease, background 180ms ease;
}

.evolution-event.major {
  border-color: rgba(255, 117, 95, 0.36);
  background: rgba(25, 12, 12, 0.82);
}

.event-symbol {
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(102, 232, 208, 0.24);
  border-radius: 50%;
  background: rgba(102, 232, 208, 0.07);
  color: var(--cyan);
  font-size: 12px;
}

.evolution-event.major .event-symbol {
  border-color: rgba(255, 117, 95, 0.32);
  background: rgba(255, 117, 95, 0.08);
  color: var(--danger);
}

.evolution-event small,
.evolution-event strong,
.evolution-event p {
  display: block;
}

.evolution-event small {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 6px;
  letter-spacing: 0.12em;
}

.evolution-event > span > strong {
  margin-top: 4px;
  font-size: 10px;
  font-weight: 500;
}

.evolution-event p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 8px;
  line-height: 1.35;
}

.biosphere-meter {
  padding-left: 10px;
  border-left: 1px solid var(--line);
}

.biosphere-meter i {
  height: 3px;
  display: block;
  margin: 7px 0 5px;
  background: #202927;
}

.biosphere-meter i b {
  width: 68%;
  height: 100%;
  display: block;
  background: var(--cyan);
  box-shadow: 0 0 7px rgba(102, 232, 208, 0.35);
  transition: width 250ms ease, background 250ms ease;
}

.biosphere-meter strong {
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 500;
}

.stage-footer {
  position: relative;
  z-index: 4;
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 20px 27px 25px;
}

.evolve-button {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.evolve-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--acid);
  border-radius: 50%;
  background: rgba(255, 159, 67, 0.08);
  color: var(--acid);
  font-size: 9px;
  box-shadow: inset 0 0 15px rgba(255, 159, 67, 0.05);
}

.evolve-button:hover .evolve-icon {
  background: rgba(255, 159, 67, 0.17);
}

.evolve-button strong,
.evolve-button small {
  display: block;
  text-align: left;
  font-family: var(--mono);
}

.evolve-button strong {
  font-size: 9px;
  letter-spacing: 0.11em;
}

.evolve-button small {
  margin-top: 4px;
  color: var(--faint);
  font-size: 7px;
  letter-spacing: 0.06em;
}

.timeline {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.08em;
}

.timeline-step {
  width: 27px;
  height: 27px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255,255,255,0.02);
  color: var(--muted);
  cursor: pointer;
}

.timeline-step:hover:not(:disabled) {
  border-color: var(--line-bright);
  color: var(--acid);
}

.timeline-step:disabled {
  opacity: 0.3;
  cursor: default;
}

.timeline-scrubber {
  flex: 1;
  height: 20px;
  position: relative;
  display: flex;
  align-items: center;
}

.timeline-track {
  width: 100%;
  height: 2px;
  position: absolute;
  left: 0;
  top: 9px;
  overflow: hidden;
  background: #252b2a;
}

.timeline-track i {
  width: 0;
  height: 100%;
  display: block;
  background: var(--acid);
  box-shadow: 0 0 8px var(--acid);
}

.timeline-scrubber input[type="range"] {
  width: 100%;
  height: 20px;
  position: relative;
  z-index: 2;
  margin: 0;
  appearance: none;
  background: transparent;
}

.timeline-scrubber input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  background: transparent;
}

.timeline-scrubber input[type="range"]::-webkit-slider-thumb {
  width: 11px;
  height: 11px;
  margin-top: -4px;
  border: 2px solid #101612;
  border-radius: 50%;
  background: var(--acid);
  box-shadow: 0 0 0 1px var(--acid), 0 0 9px rgba(255,159,67,0.3);
}

.timeline-scrubber input[type="range"]::-moz-range-track {
  height: 2px;
  background: transparent;
}

.timeline-readout {
  min-width: 77px;
  text-align: right;
}

.timeline-readout strong,
.timeline-readout small {
  display: block;
}

.timeline-readout strong {
  color: var(--muted);
  font-size: 7px;
}

.timeline-readout small {
  margin-top: 3px;
  color: var(--faint);
  font-size: 6px;
}

.telemetry-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.telemetry-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.telemetry-heading small,
.telemetry-heading strong {
  display: block;
}

.telemetry-heading strong {
  margin-top: 5px;
  font-size: 11px;
  letter-spacing: 0.08em;
}

.analysis-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 16px var(--cyan);
}

.world-score {
  display: flex;
  align-items: center;
  gap: 15px;
}

.score-ring {
  --score: 82;
  width: 74px;
  height: 74px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  position: relative;
  border-radius: 50%;
  background: conic-gradient(var(--acid) calc(var(--score) * 1%), rgba(255, 255, 255, 0.07) 0);
}

.score-ring::before {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: var(--panel-solid);
}

.score-ring > span {
  position: relative;
  text-align: center;
}

.score-ring strong {
  display: block;
  font-size: 19px;
}

.score-ring small {
  display: block;
  margin-top: 1px;
  font-size: 6px;
}

.world-score > span > * {
  display: block;
}

.world-score > span strong {
  margin-top: 6px;
  color: var(--acid);
  font-size: 12px;
  letter-spacing: 0.06em;
}

.world-score em {
  margin-top: 6px;
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 8px;
  font-style: normal;
}

.telemetry-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.telemetry-grid article {
  min-height: 86px;
  padding: 13px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.metric-icon {
  float: right;
  color: var(--faint);
}

.telemetry-grid small,
.telemetry-grid strong {
  display: block;
}

.telemetry-grid strong {
  margin-top: 8px;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.03em;
}

.telemetry-grid strong i {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8px;
  font-style: normal;
}

.composition-block,
.atmosphere-block {
  padding-top: 2px;
}

.composition-bar {
  height: 7px;
  display: flex;
  gap: 2px;
  overflow: hidden;
  border-radius: 8px;
  background: #252b2a;
}

.composition-bar span {
  height: 100%;
  transition: width 350ms ease;
}

.comp-ocean { width: 58%; background: #2488a8; }
.comp-land { width: 35%; background: var(--land); }
.comp-ice { width: 7%; background: #dbeeed; }

.composition-legend {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  margin-top: 10px;
}

.composition-legend span {
  display: grid;
  grid-template-columns: 6px 1fr;
  gap: 4px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 7px;
}

.composition-legend i {
  width: 5px;
  height: 5px;
  margin-top: 2px;
  border-radius: 50%;
}

.legend-ocean { background: #2488a8; }
.legend-land { background: var(--land); }
.legend-ice { background: #dbeeed; }

.composition-legend strong {
  grid-column: 2;
  color: #c2cac6;
  font-size: 8px;
}

.gas-row {
  display: grid;
  grid-template-columns: 27px 1fr 28px;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8px;
}

.gas-row div {
  height: 2px;
  background: #252c2a;
}

.gas-row div i {
  width: var(--gas-width);
  height: 100%;
  display: block;
  background: var(--cyan);
}

.gas-row strong {
  text-align: right;
  color: #bfc6c3;
  font-weight: 400;
}

.discovery-card {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-top: auto;
  padding: 12px;
  border: 1px solid rgba(102, 232, 208, 0.14);
  border-radius: 9px;
  background: rgba(102, 232, 208, 0.045);
}

.discovery-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(102, 232, 208, 0.1);
  color: var(--cyan);
}

.discovery-card strong {
  display: block;
  margin-top: 4px;
  font-size: 9px;
  font-weight: 500;
}

.bottombar {
  min-height: 38px;
  justify-content: space-between;
  padding: 0 28px;
  border-width: 1px 0 0;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.1em;
}

.bottombar strong {
  color: var(--muted);
}

.design-credit {
  font-size: 9px;
  letter-spacing: 0.12em;
}

.design-credit a {
  color: var(--muted);
  text-decoration: none;
  transition: color 160ms ease;
}

.design-credit a:hover {
  color: var(--acid);
}

.footer-center {
  display: flex;
  align-items: center;
  gap: 8px;
}

.footer-center i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--acid);
  box-shadow: 0 0 8px var(--acid);
}

.toast {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: 54px;
  padding: 10px 14px;
  border: 1px solid var(--line-bright);
  border-radius: 8px;
  background: rgba(13, 18, 18, 0.95);
  color: var(--acid);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.06em;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

body.modal-open {
  overflow: hidden;
}

.modal-backdrop {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(2, 4, 6, 0.78);
  backdrop-filter: blur(13px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 180ms ease, visibility 180ms ease;
}

.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.world-library {
  width: min(820px, 100%);
  max-height: min(720px, 88vh);
  overflow: auto;
  border: 1px solid var(--line-bright);
  border-radius: 16px;
  background:
    radial-gradient(circle at 90% 10%, rgba(102, 232, 208, 0.07), transparent 25rem),
    #0c1115;
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.55);
}

.library-header,
.library-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.library-header {
  padding: 24px 26px 18px;
  border-bottom: 1px solid var(--line);
}

.library-header small {
  color: var(--acid);
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.15em;
}

.library-header h2 {
  margin: 5px 0 0;
  font-size: 25px;
  letter-spacing: -0.04em;
}

.modal-close {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted);
  font-size: 21px;
  cursor: pointer;
}

.modal-close:hover {
  border-color: var(--line-bright);
  color: var(--acid);
}

.library-toolbar {
  padding: 13px 26px;
  border-bottom: 1px solid var(--line);
}

.library-toolbar p {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
}

.world-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 20px 26px 26px;
}

.world-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
}

.world-preview {
  height: 112px;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 52% 44%, var(--preview-glow), transparent 40%),
    #070a0d;
}

.world-preview::before {
  content: "";
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, rgba(255,255,255,0.28), transparent 12%),
    radial-gradient(circle at 62% 58%, var(--preview-land), transparent 18%),
    radial-gradient(circle at 31% 66%, var(--preview-land), transparent 22%),
    var(--preview-ocean);
  box-shadow: inset -18px -12px 22px rgba(0,0,0,0.62), 0 0 22px var(--preview-glow);
}

.world-preview.ringed::after {
  content: "";
  width: 115px;
  height: 28px;
  position: absolute;
  border: 2px solid rgba(255, 159, 67, 0.31);
  border-radius: 50%;
  transform: rotate(-13deg);
}

.world-card-body {
  padding: 12px;
}

.world-card-body small,
.world-card-body strong {
  display: block;
}

.world-card-body small {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.08em;
}

.world-card-body strong {
  margin-top: 5px;
  font-size: 11px;
}

.world-card-metrics {
  display: flex;
  justify-content: space-between;
  margin: 9px 0 11px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 7px;
}

.world-card-actions {
  display: grid;
  grid-template-columns: 1fr 32px;
  gap: 6px;
}

.world-load,
.world-delete {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255,255,255,0.02);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 7px;
  text-transform: uppercase;
  cursor: pointer;
}

.world-load:hover {
  border-color: var(--line-bright);
  color: var(--acid);
}

.world-delete:hover {
  border-color: rgba(255, 117, 95, 0.38);
  color: var(--danger);
}

.library-empty {
  display: none;
  min-height: 310px;
  padding: 60px 20px;
  text-align: center;
}

.library-empty.visible {
  display: block;
}

.empty-orbit {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  position: relative;
  margin: 0 auto 16px;
  border: 1px solid var(--line-bright);
  border-radius: 50%;
}

.empty-orbit::before {
  content: "";
  position: absolute;
  width: 84px;
  height: 22px;
  border: 1px solid var(--line-bright);
  border-radius: 50%;
  transform: rotate(-18deg);
}

.empty-orbit i {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--acid);
  box-shadow: 0 0 18px rgba(255,159,67,0.5);
}

.library-empty strong {
  display: block;
  font-size: 14px;
}

.library-empty p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 10px;
}

body.scan-mode #planetCanvas {
  filter: grayscale(0.72) sepia(0.55) hue-rotate(75deg) saturate(1.7) contrast(1.2);
}

body.scan-mode .planet-stage {
  background-size: 32px 32px;
}

body.scan-mode .planet-stage::before {
  background: radial-gradient(circle, rgba(255, 159, 67, 0.11), transparent 64%);
}

body.evolving .evolve-icon {
  animation: evolve-spin 1.2s linear infinite;
}

@keyframes blink {
  50% { opacity: 0.35; }
}

@keyframes evolve-spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 270px minmax(390px, 1fr);
  }

  .telemetry-panel {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1.1fr 1fr 1fr;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .telemetry-heading {
    grid-column: 1 / -1;
  }

  .world-score,
  .telemetry-grid,
  .composition-block,
  .atmosphere-block,
  .discovery-card {
    margin: 0;
  }
}

@media (max-width: 760px) {
  .topbar {
    min-height: 66px;
    padding: 0 16px;
  }

  .header-status,
  #exportButton {
    display: none;
  }

  .workspace {
    display: flex;
    flex-direction: column;
  }

  .planet-stage {
    order: 1;
    min-height: 560px;
  }

  .control-panel {
    order: 2;
    border-top: 1px solid var(--line);
    border-right: 0;
  }

  .telemetry-panel {
    order: 3;
    display: flex;
    border-top: 1px solid var(--line);
  }

  .glass-panel {
    padding: 24px 20px;
  }

  .planet-wrap {
    width: min(118vw, 600px);
    height: min(118vw, 600px);
    min-width: 360px;
    min-height: 360px;
    top: 49%;
  }

  .planet-label {
    display: none;
  }

  .map-legend {
    left: 18px;
    right: 18px;
    bottom: 84px;
    min-width: 0;
  }

  .surface-inspector {
    width: auto;
    left: 18px;
    right: 18px;
    bottom: 84px;
  }

  .map-legend.visible:has(+ .surface-marker.visible) {
    opacity: 0;
  }

  .stage-meta {
    padding: 18px;
  }

  .stage-footer {
    flex-direction: column;
    align-items: stretch;
    padding: 18px;
  }

  .timeline {
    width: 100%;
  }

  .evolution-event {
    width: auto;
    left: 18px;
    right: 18px;
    top: 70px;
    grid-template-columns: 28px 1fr 68px;
  }

  .evolution-event p {
    display: none;
  }

  .bottombar {
    justify-content: center;
    padding: 0 10px;
  }

  .bottombar > span:not(.footer-center) {
    display: none;
  }

  .world-grid {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .library-header,
  .library-toolbar {
    padding-left: 18px;
    padding-right: 18px;
  }

  .library-toolbar p {
    display: none;
  }

  .library-toolbar {
    justify-content: flex-end;
  }

  .modal-backdrop {
    padding: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
