/* ── Shared (all viewports) ─────────────────────────────────────── */
* {
  margin: 0; padding: 0; box-sizing: border-box;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
}
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  background: #000; overflow: hidden; font-family: monospace;
  min-height: 100%;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
body.walk-touch-look-active {
  touch-action: none;
  overscroll-behavior: none;
}
canvas:not(#start-starfield) {
  display: block;
  touch-action: none;
  opacity: 0;
  transition: opacity 1.95s cubic-bezier(0.16, 1, 0.3, 1);
}
body.scene-visible canvas:not(#start-starfield) { opacity: 1; }
::selection { background: transparent; color: inherit; }

/* First screen: remind about volume, then tap unlocks audio → astra gate */
#tap-primer-screen {
  position: fixed;
  inset: 0;
  z-index: 1002;
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(1.25rem, 5vw, 2.5rem);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  text-align: center;
}
#tap-primer-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(1rem, 3.5vh, 1.85rem);
  max-width: min(22rem, 92vw);
}
#tap-primer-speaker {
  width: clamp(76px, 22vw, 118px);
  height: clamp(76px, 22vw, 118px);
  color: #c8f8ff;
  filter: drop-shadow(0 0 22px rgba(94, 232, 255, 0.5)) drop-shadow(0 0 40px rgba(255, 255, 255, 0.12));
}
#tap-primer-speaker svg {
  width: 100%;
  height: 100%;
  display: block;
}
#tap-primer-headline {
  margin: 0;
  font-family: "Exo 2", system-ui, sans-serif;
  font-weight: 700;
  font-size: clamp(1.2rem, 4.8vw, 1.75rem);
  line-height: 1.35;
  letter-spacing: 0.03em;
  color: #f2fbff;
  text-shadow: 0 0 28px rgba(120, 220, 255, 0.35);
}
#tap-primer-cta {
  margin: 0;
  font-family: "Exo 2", system-ui, sans-serif;
  font-weight: 600;
  font-size: clamp(0.78rem, 2.8vw, 0.95rem);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(190, 236, 255, 0.72);
}

/* Pre-splash start gate (Astra + tap / key to continue) */
#start-screen {
  position: fixed; inset: 0; z-index: 1000;
  /* Black comes from the starfield canvas so stars are never painted under this layer */
  background: transparent;
  isolation: isolate;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: clamp(1rem, 4vh, 2.5rem);
  pointer-events: auto;
  cursor: default;
  transition: opacity 0.5s ease;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
}
#start-starfield {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
  pointer-events: none;
  opacity: 1;
}
@media (pointer: coarse) {
  #start-screen { cursor: pointer; }
}
#start-screen.gate-behind-primer {
  visibility: hidden;
  pointer-events: none;
}
#start-title {
  position: relative;
  z-index: 2;
  font-family: "Exo 2", system-ui, sans-serif;
  font-weight: 900;
  font-size: clamp(64px, 19vw, 260px);
  line-height: 0.95;
  color: #fff;
  letter-spacing: 0.06em;
  text-transform: lowercase;
  text-shadow:
    0 0 80px rgba(255, 255, 255, 0.45),
    0 0 28px rgba(180, 230, 255, 0.35);
  opacity: 0;
}
#start-screen:not(.gate-behind-primer) #start-title {
  animation: start-title-fadein 1.15s ease 0.12s forwards;
}
#start-screen.gate-behind-primer #start-title {
  animation: none;
}
@keyframes start-title-fadein {
  from { opacity: 0; }
  to { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  #start-screen:not(.gate-behind-primer) #start-title {
    opacity: 1;
    animation: none;
  }
}
#start-hint {
  position: relative;
  z-index: 2;
  font-family: "Exo 2", system-ui, sans-serif;
  font-weight: 700;
  font-style: italic;
  font-size: clamp(17px, 4.2vw, 30px);
  color: rgba(255, 255, 255, 0.78);
  letter-spacing: 0.14em;
  text-align: center;
  padding: 0 1.5rem;
  max-width: 92vw;
  line-height: 1.45;
  margin: 0;
  transform-origin: 50% 50%;
  will-change: transform, letter-spacing, opacity;
  opacity: 0;
}
#start-hint.start-hint-visible {
  animation: start-hint-breathe 3.4s ease-in-out infinite;
}
@keyframes start-hint-breathe {
  0%, 100% {
    transform: scale(1);
    letter-spacing: 0.12em;
  }
  50% {
    transform: scale(1.045);
    letter-spacing: 0.2em;
  }
}
@media (prefers-reduced-motion: reduce) {
  #start-hint {
    opacity: 1;
  }
  #start-hint.start-hint-visible {
    animation: none;
  }
}

/* Splash: same structure on all viewports; font sizes tuned per breakpoint */
#splash {
  position: fixed; inset: 0; z-index: 999;
  background: #000;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  transition: opacity 1s ease;
}
#s-hello {
  position: absolute;
  font-family: monospace;
  font-size: clamp(32px, 9vw, 130px);
  color: #fff;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity 0.7s ease;
  white-space: nowrap;
  text-shadow: 0 0 60px rgba(255,255,255,0.4);
}
#s-face {
  position: absolute;
  font-family: monospace;
  font-size: clamp(72px, 18vw, 220px);
  color: #fff;
  letter-spacing: -0.05em;
  opacity: 1;
  transform-origin: 50% 42%;
  will-change: transform, filter;
  text-shadow: 0 0 40px rgba(255,255,255,0.5);
}

/* Hide gameplay HUD until intro zoom settles, and during flights between solar systems */
/* Keep a transition so reveal fades in instead of popping */
#ui,
#cam-buttons,
#cam-settings,
#planet-panel,
#planet-radial-editor,
#sun-radial-editor,
#galaxy-menu,
#walk-controls,
#walk-cam-badge {
  transition: opacity 0.55s ease;
}
body.hud-hidden #ui,
body.hud-hidden #cam-buttons,
body.hud-hidden #cam-settings,
body.hud-hidden #planet-panel,
body.hud-hidden #planet-radial-editor,
body.hud-hidden #sun-radial-editor,
body.hud-hidden #galaxy-menu,
body.hud-hidden #walk-controls,
body.hud-hidden #walk-cam-badge {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* Legacy panel retired: top-left picker now handles planets/moons */
#planet-panel {
  display: none !important;
}

/* Planet radial editor — shared across viewports (JS sets left/top on the root).
   Must not live only inside the desktop media query, or narrow screens never get
   position:fixed and knob offsets anchor incorrectly. */
#planet-radial-editor,
#sun-radial-editor {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 88;
  display: none;
  pointer-events: none;
  --pre-size: 220px;
}
#planet-radial-ring,
#sun-radial-ring {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--pre-size);
  height: var(--pre-size);
  margin-left: calc(var(--pre-size) * -0.5);
  margin-top: calc(var(--pre-size) * -0.5);
  border-radius: 50%;
  border: 1px solid rgba(122, 233, 255, 0.35);
  box-shadow: 0 0 22px rgba(56, 201, 255, 0.32), inset 0 0 32px rgba(16, 140, 205, 0.2);
  background:
    radial-gradient(circle at 50% 50%, rgba(74, 232, 255, 0.03) 0 46%, rgba(65, 194, 255, 0.11) 58%, rgba(14, 39, 59, 0.18) 100%);
}
#planet-radial-guide,
#sun-radial-guide {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--pre-size);
  height: var(--pre-size);
  margin-left: calc(var(--pre-size) * -0.5);
  margin-top: calc(var(--pre-size) * -0.5);
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.16s ease;
  background: conic-gradient(
    from var(--guide-start, 0deg),
    rgba(129, 235, 255, 0.92) 0deg var(--guide-span, 90deg),
    rgba(129, 235, 255, 0) var(--guide-span, 90deg) 360deg
  );
  -webkit-mask: radial-gradient(farthest-side, transparent calc(50% - 7px), #000 calc(50% - 7px) calc(50% - 1px), transparent calc(50% - 1px));
  mask: radial-gradient(farthest-side, transparent calc(50% - 7px), #000 calc(50% - 7px) calc(50% - 1px), transparent calc(50% - 1px));
}
#planet-radial-guide.visible,
#sun-radial-guide.visible { opacity: 1; }
.planet-radial-close {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, -50%);
  width: 38px;
  height: 38px;
  margin: 0;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(162, 236, 255, 0.38);
  background: rgba(1, 15, 28, 0.78);
  box-shadow: 0 0 14px rgba(44, 184, 255, 0.28);
  color: rgba(219, 247, 255, 0.95);
  font-family: monospace;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.98;
  transition: opacity 0.16s ease, transform 0.16s ease, border-color 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.planet-radial-close:hover {
  border-color: rgba(210, 247, 255, 0.75);
  box-shadow: 0 0 18px rgba(84, 206, 255, 0.45);
}
.planet-radial-close:active {
  transform: translate(-50%, -50%) scale(0.96);
}
.planet-radial-close.dim {
  opacity: 0.22;
  pointer-events: none;
}
.planet-radial-knob {
  position: absolute;
  transform: translate(-50%, -50%);
  min-width: 72px;
  padding: 6px 8px;
  border-radius: 11px;
  border: 1px solid rgba(162, 236, 255, 0.38);
  background: rgba(1, 15, 28, 0.72);
  box-shadow: 0 0 14px rgba(44, 184, 255, 0.28);
  color: rgba(219, 247, 255, 0.95);
  font-family: monospace;
  text-transform: uppercase;
  text-align: center;
  pointer-events: auto;
  cursor: grab;
  opacity: 0.98;
  transition: opacity 0.16s ease, transform 0.16s ease;
}
.planet-radial-knob:active { cursor: grabbing; }
.planet-radial-knob.active {
  border-color: rgba(210, 247, 255, 0.9);
  box-shadow: 0 0 22px rgba(84, 206, 255, 0.55);
  transform: translate(-50%, -50%) scale(1.05);
}
.planet-radial-knob.dim {
  opacity: 0.18;
  transform: translate(-50%, -50%) scale(0.94);
}
.planet-radial-knob .prk-name {
  display: block;
  font-size: 9px;
  letter-spacing: 0.12em;
  color: rgba(181, 238, 255, 0.85);
}
.planet-radial-knob .prk-value {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.92);
}
body.radial-edit-active #planet-panel {
  display: none !important;
}
#galaxy-menu.galaxy-await-sun-tap {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}
body.sun-radial-edit-active #ui {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}
body.mode-planet-view #ui {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* ══════════════════════════════════════════════════════════════════
   PC / DESKTOP — wide layouts, original spacing (769px and wider)
   ══════════════════════════════════════════════════════════════════ */
@media (min-width: 769px) {

#hint {
  position: fixed; top: 24px; left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,0.14); font-size: 10px;
  letter-spacing: 2px; text-transform: uppercase; pointer-events: none;
}
.hint-touch { display: none; }
#ui {
  position: fixed; bottom: 30px; left: 50%;
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  pointer-events: none;
}
.row-label {
  color: rgba(255,255,255,0.38);
  font-size: 10px; letter-spacing: 3px; text-transform: uppercase;
}
.gap { height: 4px; }
input[type=range] {
  pointer-events: all; -webkit-appearance: none;
  width: 240px; height: 1px; background: rgba(255,255,255,0.20);
  outline: none; cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; cursor: pointer;
  box-shadow: 0 0 8px rgba(255,255,255,.9), 0 0 18px rgba(255,255,255,.3);
}
#cam-buttons {
  position: fixed; top: 24px; right: 24px;
  display: flex; gap: 8px;
}
.cam-btn {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.18);
  color: rgba(255,255,255,0.45);
  font-family: monospace; font-size: 10px;
  letter-spacing: 2px; text-transform: uppercase;
  padding: 7px 14px; cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.cam-btn:hover { background: rgba(255,255,255,0.10); color: rgba(255,255,255,0.75); }
.cam-btn.active {
  background: rgba(255,255,255,0.14);
  color: #fff;
  border-color: rgba(255,255,255,0.55);
}

/* ── Planet panel (minimal card — system UI, not monospace) ──────── */
#planet-panel {
  position: fixed;
  bottom: 30px;
  right: 24px;
  width: min(268px, 30vw);
  max-height: min(74vh, 520px);
  display: flex;
  flex-direction: column;
  background: rgba(10, 12, 18, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.065);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  overflow: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
#planet-panel-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px 8px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.pp-toggle { display: none; }
.pp-head-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
#planet-panel-title {
  color: rgba(255, 255, 255, 0.48);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.pp-count {
  font-size: 9px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.28);
}
#add-planet-btn,
#add-twin-btn {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.7);
  font-size: 18px;
  line-height: 1;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
#add-planet-btn:hover,
#add-twin-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.28);
}
#add-twin-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
#planet-panel-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
#planet-list {
  max-height: 168px;
  overflow-y: auto;
  padding: 6px 8px 8px;
}
.planet-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  margin: 2px 0;
  border-radius: 9px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s;
}
.planet-item:hover { background: rgba(255, 255, 255, 0.05); }
.planet-item.selected {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.11);
}
.planet-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.planet-name {
  color: rgba(255, 255, 255, 0.52);
  font-size: 12px;
  font-weight: 450;
  letter-spacing: 0.02em;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.planet-item.selected .planet-name { color: rgba(255, 255, 255, 0.95); }
#planet-edit-panel {
  padding: 8px 10px 11px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: none !important;
  flex-direction: column;
  gap: 8px;
  background: rgba(0, 0, 0, 0.22);
  pointer-events: none !important;
}
.pe-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pe-lbl {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.34);
  pointer-events: none;
}
#planet-edit-panel input[type=range] { width: 100%; }

#sun-orbit-sliders {
  display: none;
  flex-direction: column;
  gap: 8px;
  padding: 8px 10px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.18);
}
#sun-orbit-sliders input[type=range] { width: 100%; }

/* ── Galaxy navigation menu ─────────────────────────────────────── */
#galaxy-menu {
  position: fixed; top: 24px; left: 24px;
  z-index: 50;
}
#galaxy-btn {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.18);
  color: rgba(255,255,255,0.55);
  font-family: monospace; font-size: 10px;
  letter-spacing: 2px; text-transform: uppercase;
  padding: 7px 14px; cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
#galaxy-btn:hover, #galaxy-btn.open {
  background: rgba(255,255,255,0.12); color: #fff;
  border-color: rgba(255,255,255,0.45);
}
#galaxy-list {
  position: absolute; top: calc(100% + 6px); left: 0;
  background: rgba(0,0,0,0.88);
  border: 1px solid rgba(255,255,255,0.12);
  min-width: 210px;
  display: none; flex-direction: column;
  backdrop-filter: blur(8px);
}
#galaxy-list.open { display: flex; }
.gx-item {
  padding: 9px 16px;
  color: rgba(255,255,255,0.45);
  font-family: monospace; font-size: 10px;
  letter-spacing: 2px; text-transform: uppercase;
  cursor: pointer; display: flex; justify-content: space-between; gap: 12px;
  transition: background 0.1s, color 0.1s;
  border-left: 2px solid transparent;
}
.gx-item:hover { background: rgba(255,255,255,0.07); color: rgba(255,255,255,0.8); }
.gx-item.current {
  color: #fff; border-left-color: rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.05);
}
.gx-item.navigating { opacity: 0.4; pointer-events: none; }
.gx-dist { color: rgba(255,255,255,0.25); font-size: 9px; align-self: center; }
.gx-item.planet-picker-item {
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}
.gx-item-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.gx-item-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.gx-item-title .planet-dot {
  width: 8px;
  height: 8px;
}
.gx-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gx-item-meta {
  color: rgba(255,255,255,0.28);
  font-size: 9px;
}
.gx-inline-actions {
  padding: 0 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.gx-list-footer {
  padding: 10px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.gx-action-btn {
  width: 100%;
  min-height: 34px;
  border-radius: 9px;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.92);
  font-family: monospace;
  font-size: 10px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  cursor: pointer;
}
.gx-action-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#cam-settings {
  position: fixed; top: 60px; right: 24px;
  background: rgba(0,0,0,0.72);
  border: 1px solid rgba(255,255,255,0.12);
  padding: 16px 20px;
  display: none; flex-direction: column; gap: 10px;
  min-width: 220px;
  backdrop-filter: blur(6px);
}
#cam-settings.open { display: flex; }
.cs-row {
  display: flex; flex-direction: column; gap: 5px;
}
.cs-label {
  color: rgba(255,255,255,0.38);
  font-size: 10px; letter-spacing: 3px; text-transform: uppercase;
}
.cs-toggle {
  display: flex; gap: 0;
}
.cs-toggle button {
  flex: 1;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.40);
  font-family: monospace; font-size: 10px;
  letter-spacing: 2px; text-transform: uppercase;
  padding: 5px 0; cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.cs-toggle button:first-child { border-right: none; }
.cs-toggle button.on {
  background: rgba(255,255,255,0.14);
  color: #fff; border-color: rgba(255,255,255,0.45);
}
.cs-toggle button:hover { background: rgba(255,255,255,0.09); }
#cam-settings input[type=range] {
  width: 100%; pointer-events: all;
}

} /* end desktop */

/* ══════════════════════════════════════════════════════════════════
   MOBILE / TABLET PORTRAIT — fits UI to small viewports + touch
   (768px and below)
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

.row-label {
  color: rgba(255,255,255,0.38);
  font-size: clamp(8px, 2.5vw, 10px);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.gap { height: 4px; }

#hint {
  position: fixed;
  top: max(8px, env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,0.16);
  font-size: clamp(8px, 2.6vw, 10px);
  letter-spacing: 0.12em;
  max-width: calc(100vw - 20px);
  white-space: normal;
  text-align: center;
  line-height: 1.35;
  pointer-events: none;
}
.hint-desktop { display: none; }
.hint-touch { display: inline; }

#galaxy-menu {
  position: fixed;
  top: max(8px, env(safe-area-inset-top, 0px));
  left: max(8px, env(safe-area-inset-left, 0px));
  z-index: 60;
  max-width: calc(100vw - min(148px, 38vw) - 28px);
}
#galaxy-btn {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.18);
  color: rgba(255,255,255,0.55);
  font-family: monospace;
  font-size: clamp(9px, 2.8vw, 11px);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 10px 12px;
  min-height: 44px;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
#galaxy-btn.open {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border-color: rgba(255,255,255,0.45);
}
#galaxy-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  display: none;
  flex-direction: column;
  background: rgba(0,0,0,0.88);
  border: 1px solid rgba(255,255,255,0.12);
  backdrop-filter: blur(8px);
  min-width: min(300px, calc(100vw - 20px));
  max-width: calc(100vw - 16px);
  max-height: min(48vh, 320px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
#galaxy-list.open { display: flex; }
.gx-item {
  padding: 12px 14px;
  min-height: 48px;
  font-size: clamp(9px, 2.6vw, 11px);
  color: rgba(255,255,255,0.45);
  font-family: monospace;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  transition: background 0.1s, color 0.1s;
  border-left: 2px solid transparent;
}
.gx-item.current {
  color: #fff;
  border-left-color: rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.05);
}
.gx-item.navigating { opacity: 0.4; pointer-events: none; }
.gx-dist { font-size: clamp(8px, 2.2vw, 10px); color: rgba(255,255,255,0.28); }
.gx-item-meta { font-size: clamp(8px, 2.2vw, 10px); }
.gx-inline-actions { padding: 0 8px 10px; }
.gx-list-footer {
  padding: 10px 8px;
  border-top: 1px solid rgba(255,255,255,0.12);
}
.gx-action-btn {
  min-height: 44px;
  font-size: clamp(9px, 2.4vw, 10px);
}

#cam-buttons {
  position: fixed;
  top: max(8px, env(safe-area-inset-top, 0px));
  right: max(8px, env(safe-area-inset-right, 0px));
  left: auto;
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 6px;
  width: min(176px, 46vw);
  z-index: 55;
}
.cam-btn {
  background: linear-gradient(180deg, rgba(24,40,66,0.78), rgba(13,22,38,0.72));
  border: 1px solid rgba(112,205,255,0.34);
  color: rgba(188, 236, 255, 0.86);
  font-family: monospace;
  font-size: clamp(8px, 2.35vw, 10px);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 10px 8px;
  min-height: 44px;
  text-align: center;
  cursor: pointer;
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.28), inset 0 0 10px rgba(102,206,255,0.08);
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.12s;
}
.cam-btn.active {
  background: linear-gradient(180deg, rgba(43,95,145,0.9), rgba(26,62,102,0.86));
  color: #f0fbff;
  border-color: rgba(152, 233, 255, 0.9);
}
.cam-btn:active {
  transform: translateY(1px);
}

#cam-settings {
  position: fixed;
  z-index: 70;
  top: auto;
  left: max(10px, env(safe-area-inset-left, 0px));
  right: max(10px, env(safe-area-inset-right, 0px));
  /* Sit above the scale / time-warp strip so sliders stay reachable */
  bottom: calc(max(10px, env(safe-area-inset-bottom, 0px)) + 112px);
  width: auto;
  min-width: unset;
  max-height: min(48vh, 340px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 16px;
  gap: 12px;
  display: none;
  flex-direction: column;
  background: linear-gradient(165deg, rgba(13,18,31,0.94), rgba(8,12,23,0.9));
  border: 1px solid rgba(126, 218, 255, 0.24);
  border-radius: 14px;
  box-shadow: 0 14px 36px rgba(0,0,0,0.46);
  backdrop-filter: blur(8px);
}
#cam-settings.open { display: flex; }
.cs-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cs-label {
  font-size: clamp(9px, 2.5vw, 11px);
  color: rgba(255,255,255,0.38);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.cs-toggle {
  display: flex;
  gap: 0;
}
.cs-toggle button {
  flex: 1;
  min-height: 44px;
  padding: 10px 6px;
  font-size: clamp(9px, 2.4vw, 10px);
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.40);
  font-family: monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.cs-toggle button:first-child { border-right: none; }
.cs-toggle button.on {
  background: rgba(255,255,255,0.14);
  color: #fff;
  border-color: rgba(255,255,255,0.45);
}
#cam-settings input[type=range] {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  background: rgba(255,255,255,0.20);
  outline: none;
  cursor: pointer;
}

#ui {
  position: fixed;
  bottom: max(10px, env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  width: min(calc(100vw - 16px), 420px);
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  pointer-events: none;
  z-index: 30;
}
#ui .row-label {
  font-size: clamp(8px, 2.5vw, 10px);
  letter-spacing: 0.15em;
  text-align: center;
}
#ui input[type=range] {
  pointer-events: all;
  width: 100%;
  max-width: 100%;
  height: 6px;
  -webkit-appearance: none;
  background: rgba(255,255,255,0.20);
  outline: none;
  cursor: pointer;
}
#ui .gap { height: 2px; }

input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 0 8px rgba(255,255,255,.9), 0 0 18px rgba(255,255,255,.3);
}
input[type=range]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 8px rgba(255,255,255,.9);
}

/* Mobile: small floating card above scale sliders; tap header to expand */
#planet-panel {
  position: fixed;
  left: max(8px, env(safe-area-inset-left, 0px));
  right: max(8px, env(safe-area-inset-right, 0px));
  bottom: calc(max(10px, env(safe-area-inset-bottom, 0px)) + 96px);
  width: auto;
  max-width: none;
  max-height: min(52vh, 380px);
  overflow: hidden;
  z-index: 32;
  display: flex;
  flex-direction: column;
  background: linear-gradient(165deg, rgba(14,18,30,0.94), rgba(8,10,18,0.9));
  border: 1px solid rgba(98, 200, 255, 0.24);
  border-radius: 16px;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.56), inset 0 0 24px rgba(84, 188, 255, 0.08);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
#planet-panel:not(.pp-open) #planet-panel-body {
  display: none !important;
}
#planet-panel.pp-open #planet-panel-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
#planet-panel-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 10px 8px 4px;
  border-bottom: 1px solid rgba(120, 214, 255, 0.2);
  min-height: 44px;
}
.pp-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: rgba(255, 255, 255, 0.42);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s, transform 0.2s ease, background 0.15s;
}
.pp-toggle:active { background: rgba(255, 255, 255, 0.06); }
#planet-panel.pp-open .pp-toggle {
  transform: rotate(180deg);
  color: rgba(255, 255, 255, 0.65);
}
.pp-head-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
#planet-panel-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(146, 224, 255, 0.9);
}
.pp-count {
  font-size: 9px;
  font-weight: 500;
  color: rgba(146, 224, 255, 0.62);
}
#add-planet-btn,
#add-twin-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid rgba(104, 205, 255, 0.34);
  background: linear-gradient(180deg, rgba(45,77,118,0.36), rgba(18,34,58,0.34));
  color: rgba(208, 242, 255, 0.95);
  font-size: 20px;
  line-height: 1;
  font-family: inherit;
  cursor: pointer;
}
#add-twin-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
#planet-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 10px 8px;
  max-height: 180px;
  -webkit-overflow-scrolling: touch;
}
.planet-item {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 10px 10px;
  min-height: 42px;
  border-radius: 12px;
  cursor: pointer;
  border: 1px solid rgba(100, 189, 255, 0.18);
  background: rgba(20, 35, 58, 0.5);
  transition: background 0.12s, border-color 0.12s;
}
.planet-item.selected {
  border-color: rgba(126, 217, 255, 0.65);
  background: linear-gradient(180deg, rgba(40, 78, 120, 0.66), rgba(28, 56, 90, 0.58));
  box-shadow: inset 0 0 12px rgba(127, 216, 255, 0.22);
}
.planet-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.planet-name {
  font-size: 11px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.55);
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.planet-item.selected .planet-name { color: rgba(255, 255, 255, 0.95); }
#planet-edit-panel {
  padding: 10px 12px 12px;
  border-top: 1px solid rgba(120, 214, 255, 0.18);
  gap: 8px;
  display: none !important;
  flex-direction: column;
  flex-shrink: 0;
  background: rgba(8, 14, 24, 0.66);
  pointer-events: none !important;
}
.pe-lbl {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(160, 231, 255, 0.8);
}
.pe-row { display: flex; flex-direction: column; gap: 3px; }
#planet-edit-panel input[type=range] {
  width: 100%;
  height: 5px;
  -webkit-appearance: none;
  background: rgba(255, 255, 255, 0.18);
  outline: none;
  cursor: pointer;
}

#splash #s-hello {
  font-size: clamp(22px, 10vw, 90px);
  white-space: normal;
  text-align: center;
  max-width: 92vw;
}
#splash #s-face {
  font-size: clamp(48px, 20vw, 160px);
}
} /* end mobile */

/* ── Mobile landscape: shorter vertical space ───────────────────── */
@media (max-width: 768px) and (max-height: 460px) {

#hint { display: none; }

#galaxy-menu {
  max-width: 42vw;
}
#galaxy-btn {
  min-height: 40px;
  padding: 8px 10px;
  font-size: 8px;
}

#cam-buttons {
  width: min(128px, 34vw);
  gap: 4px;
}
.cam-btn {
  min-height: 38px;
  padding: 6px 4px;
  font-size: 7px;
  letter-spacing: 0.06em;
}

#planet-panel {
  bottom: calc(max(6px, env(safe-area-inset-bottom, 0px)) + 96px);
  max-height: min(40vh, 200px);
  max-width: min(280px, 88vw);
}

#ui {
  bottom: max(6px, env(safe-area-inset-bottom, 0px));
  width: min(calc(100vw - 12px), 360px);
  gap: 4px;
}
#ui .row-label { font-size: 7px; }

#cam-settings {
  max-height: min(58vh, 260px);
  padding: 10px 12px;
}

}

#walk-controls {
  position: fixed;
  left: max(10px, env(safe-area-inset-left, 0px));
  bottom: calc(max(10px, env(safe-area-inset-bottom, 0px)) + 112px);
  z-index: 85;
  display: none;
  grid-template-columns: auto auto;
  align-items: end;
  gap: 10px;
}
#walk-dpad {
  display: none;
  grid-template-columns: repeat(3, 54px);
  grid-template-rows: repeat(2, 44px);
  gap: 6px;
}
#walk-dpad button[data-walk="left"] { grid-column: 1; grid-row: 2; }
#walk-dpad button[data-walk="forward"] { grid-column: 2; grid-row: 1; }
#walk-dpad button[data-walk="right"] { grid-column: 3; grid-row: 2; }
#walk-dpad button[data-walk="back"] { grid-column: 2; grid-row: 2; }
#walk-action-buttons {
  display: grid;
  grid-template-columns: 54px;
  grid-auto-rows: 44px;
  gap: 6px;
}
#walk-controls button {
  width: 54px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(0,0,0,0.55);
  color: rgba(255,255,255,0.88);
  font-family: monospace;
  font-size: 16px;
  cursor: pointer;
}
#walk-controls button[data-walk="jump"],
#walk-controls button[data-walk="sprint"] {
  font-size: 10px;
  letter-spacing: 0.08em;
}
#walk-controls button[data-walk="view"] {
  font-size: 11px;
  letter-spacing: 0.08em;
}
#walk-joystick {
  position: relative;
  width: 126px;
  height: 126px;
  border-radius: 50%;
  display: block;
  border: 1px solid rgba(255,255,255,0.2);
  background:
    radial-gradient(circle at 50% 50%, rgba(255,255,255,0.09) 0 36%, rgba(0,0,0,0.48) 72%, rgba(0,0,0,0.62) 100%);
  touch-action: none;
}
#walk-joystick::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 68px;
  height: 68px;
  margin-left: -34px;
  margin-top: -34px;
  border-radius: 50%;
  border: 1px dashed rgba(255,255,255,0.16);
}
#walk-joystick-thumb {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 50px;
  height: 50px;
  margin-left: -25px;
  margin-top: -25px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.28);
  background: rgba(255,255,255,0.18);
  transform: translate(0px, 0px);
}
#walk-cam-badge {
  position: fixed;
  left: max(10px, env(safe-area-inset-left, 0px));
  bottom: calc(max(10px, env(safe-area-inset-bottom, 0px)) + 78px);
  z-index: 86;
  display: none;
  min-width: 58px;
  padding: 4px 8px;
  border-radius: 9px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(0,0,0,0.58);
  color: rgba(255,255,255,0.92);
  font-family: monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
}

