:root {
  color-scheme: dark;
  font-family: 'Nunito', ui-rounded, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --bg: #050816;
  --panel: rgba(10, 17, 38, 0.78);
  --panel-strong: rgba(14, 24, 52, 0.92);
  --line: rgba(255, 255, 255, 0.16);
  --text: #f8fbff;
  --muted: #b9c5d9;
  --sun: #ffd86b;
  --blue: #69c7ff;
  --purple: #a78bfa;
  --green: #6ee7b7;
  --danger: #ff8a8a;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 10%, rgba(105,199,255,0.22), transparent 30%),
    radial-gradient(circle at 84% 12%, rgba(255,216,107,0.16), transparent 26%),
    linear-gradient(135deg, #030512 0%, #09112b 56%, #120a2e 100%);
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle, rgba(255,255,255,0.9) 0 1px, transparent 1.5px),
    radial-gradient(circle, rgba(255,255,255,0.5) 0 1px, transparent 1.5px);
  background-size: 70px 70px, 118px 118px;
  background-position: 0 0, 27px 33px;
  opacity: 0.22;
}

#app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(330px, 430px);
  gap: 18px;
  height: 100dvh;
  padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}

.scene-card, .info-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 22px 80px rgba(0,0,0,0.42), inset 0 1px 0 rgba(255,255,255,0.08);
  backdrop-filter: blur(18px);
  border-radius: 34px;
  overflow: hidden;
}

.scene-card {
  position: relative;
  min-height: 360px;
}

#space {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}
#space:active { cursor: grabbing; }

.topbar {
  position: absolute;
  top: 20px;
  left: 20px;
  right: 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }

.eyebrow {
  margin: 0 0 6px;
  color: var(--sun);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 12px;
  font-weight: 900;
}
h1, h2, h3 { margin: 0; line-height: 1.05; }
h1 { font-size: clamp(26px, 4vw, 54px); max-width: 720px; text-shadow: 0 2px 20px rgba(0,0,0,0.5); }
h2 { font-size: clamp(30px, 4vw, 52px); }
h3 { font-size: 18px; }

.pill-button, button {
  border: 0;
  border-radius: 999px;
  color: var(--text);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.pill-button {
  padding: 12px 16px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.16);
  box-shadow: 0 10px 30px rgba(0,0,0,0.22);
}
.pill-button:hover, button:hover { transform: translateY(-1px); }
button:active { transform: translateY(1px) scale(0.99); }

.hint-card {
  position: absolute;
  left: 20px;
  bottom: 88px;
  max-width: min(520px, calc(100% - 40px));
  padding: 14px 16px;
  color: #eaf4ff;
  background: rgba(4, 10, 25, 0.66);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 22px;
  line-height: 1.45;
}

.planet-strip {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 18px;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}
.planet-button {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 13px;
  background: rgba(255,255,255,0.11);
  border: 1px solid rgba(255,255,255,0.16);
}
.planet-button[aria-pressed="true"] {
  background: linear-gradient(135deg, rgba(255,216,107,0.42), rgba(105,199,255,0.26));
  border-color: rgba(255,216,107,0.65);
}
.swatch { width: 14px; height: 14px; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(255,255,255,0.22); }

.info-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: clamp(20px, 3vw, 32px);
  overflow-y: auto;
}
.mascot {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  font-size: 34px;
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(255,216,107,0.35), rgba(255,255,255,0.08));
  border: 1px solid rgba(255,216,107,0.32);
}
.story, #dayNightText {
  margin: 0;
  color: #dbe7fb;
  line-height: 1.56;
  font-size: 17px;
}
.day-night-box {
  padding: 16px;
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(255,216,107,0.16), rgba(105,199,255,0.12));
  border: 1px solid rgba(255,255,255,0.14);
}
.day-night-box h3 { margin-bottom: 8px; color: #fff8dc; }

.facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0;
}
.fact {
  min-height: 88px;
  padding: 14px;
  border-radius: 20px;
  background: rgba(255,255,255,0.075);
  border: 1px solid rgba(255,255,255,0.11);
}
.fact dt {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 900;
}
.fact dd {
  margin: 6px 0 0;
  font-size: 18px;
  font-weight: 900;
}
.control-row { display: flex; gap: 10px; flex-wrap: wrap; }
.primary, .secondary {
  padding: 13px 16px;
  border: 1px solid rgba(255,255,255,0.14);
}
.primary { background: linear-gradient(135deg, #ffcf6b, #ff8e6b); color: #211303; }
.secondary { background: rgba(255,255,255,0.1); }
.legend {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.sun-dot { background: var(--sun); box-shadow: 0 0 14px var(--sun); }
.day-dot { background: #8ddcff; }
.night-dot { background: #241a68; }

@media (max-width: 980px) {
  body { overflow: auto; }
  #app-shell {
    height: auto;
    min-height: 100dvh;
    grid-template-columns: 1fr;
  }
  .scene-card { height: 64dvh; min-height: 460px; }
  .info-panel { min-height: auto; }
}

@media (max-width: 640px) {
  #app-shell { padding: 8px; gap: 10px; }
  .scene-card, .info-panel { border-radius: 26px; }
  .scene-card { height: 62dvh; min-height: 430px; }
  .topbar { top: 14px; left: 14px; right: 14px; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .hint-card { left: 14px; right: 14px; bottom: 86px; max-width: none; font-size: 14px; }
  .planet-strip { left: 14px; right: 14px; bottom: 14px; }
  .facts { grid-template-columns: 1fr; }
  .planet-button { padding: 9px 11px; }
}
