/* ==========================================================================
   Weltraum-Entdecker – Warmer Bilderbuch-Gouache-Stil
   ========================================================================== */

:root {
  --bg-deep: #0b132b;
  --bg-indigo: #162147;
  --bg-nebula-1: rgba(88, 60, 148, 0.35);
  --bg-nebula-2: rgba(33, 128, 160, 0.25);

  --cream-card: #fbf3df;
  --cream-card-dark: #f2e4c4;
  --cream-border: #e5cfa3;
  --ink-brown: #3e2a1e;
  --ink-soft: #6b4e3a;

  --accent-orange: #e86b3a;
  --accent-orange-hover: #d45828;
  --accent-gold: #f7c948;
  --accent-cyan: #57e2e5;
  --accent-mint: #6be5a0;

  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-pill: 999px;

  --shadow-soft: 0 12px 32px rgba(5, 10, 28, 0.45);
  --shadow-glow: 0 0 22px rgba(247, 201, 72, 0.35);

  --story-font-size: 1.03rem;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  min-height: 100%;
  font-family: "Nunito", "Quicksand", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: radial-gradient(ellipse at 25% 20%, #1d2b5b 0%, var(--bg-indigo) 45%, var(--bg-deep) 100%);
  color: #f7f4eb;
  overflow-x: hidden;
}

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

.starfield-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

/* ==========================================================================
   Top Bar
   ========================================================================== */

.top-bar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  gap: 12px;
}

.top-bar-left,
.top-bar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.game-title {
  font-size: clamp(1.2rem, 2.2vw, 1.75rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #fff6df;
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.45);
  text-align: center;
}

.star-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--cream-card);
  color: var(--ink-brown);
  border: 3px solid var(--accent-gold);
  border-radius: var(--radius-pill);
  padding: 6px 16px;
  font-weight: 800;
  font-size: 1.05rem;
  box-shadow: var(--shadow-soft);
}

.star-icon {
  font-size: 1.2rem;
}

.pill-btn,
.action-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-pill);
  padding: 9px 18px;
  font-weight: 800;
  font-size: 0.96rem;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
  font-family: inherit;
}

.home-btn {
  background: var(--cream-card);
  color: var(--ink-brown);
  border: 2px solid var(--cream-border);
  box-shadow: var(--shadow-soft);
}

.home-btn:hover {
  transform: translateY(-2px);
  background: #fff9eb;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 2px solid var(--cream-border);
  background: var(--cream-card);
  color: var(--ink-brown);
  font-size: 1.3rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: transform 0.15s ease, background 0.15s ease;
}

.icon-btn:hover {
  transform: translateY(-2px) scale(1.04);
  background: #fff9ec;
}

.primary-pill {
  background: var(--accent-orange);
  color: #fff;
  box-shadow: 0 6px 18px rgba(232, 107, 58, 0.4);
}

.primary-pill:hover {
  background: var(--accent-orange-hover);
  transform: translateY(-2px);
}

.secondary-pill {
  background: var(--cream-card);
  color: var(--ink-brown);
  border: 2px solid var(--cream-border);
  box-shadow: var(--shadow-soft);
}

.secondary-pill:hover {
  background: #fff9eb;
  transform: translateY(-2px);
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   Views
   ========================================================================== */

.view {
  position: relative;
  z-index: 5;
  display: none;
  flex: 1;
  padding: 4px 24px 24px;
  max-width: 1360px;
  width: 100%;
  margin: 0 auto;
}

.view.active {
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   View 1: Solar System Map
   ========================================================================== */

.map-intro-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(22, 33, 71, 0.72);
  border: 1.5px solid rgba(251, 243, 223, 0.2);
  backdrop-filter: blur(8px);
  border-radius: var(--radius-lg);
  padding: 10px 20px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-soft);
}

.map-crew-mini {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.map-crew-mini svg {
  width: 44px;
  height: 44px;
}

.map-intro-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.96rem;
  color: #e9e4d7;
}

.map-intro-text strong {
  color: var(--accent-gold);
  font-size: 1.05rem;
}

.solar-system-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  background: radial-gradient(circle at 12% 50%, rgba(255, 183, 77, 0.16) 0%, rgba(88, 60, 148, 0.18) 45%, rgba(11, 19, 43, 0.3) 100%);
  border-radius: var(--radius-lg);
  border: 1.5px solid rgba(251, 243, 223, 0.14);
  overflow: hidden;
  position: relative;
  box-shadow: var(--shadow-soft);
}

.solar-svg {
  width: 100%;
  height: 100%;
  max-height: 560px;
}

.planet-node {
  cursor: pointer;
  transition: transform 0.22s ease;
  transform-box: fill-box;
  transform-origin: center;
}

.planet-node:hover {
  transform: scale(1.12);
}

.planet-label {
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  fill: #fff6df;
  text-anchor: middle;
  paint-order: stroke;
  stroke: rgba(11, 19, 43, 0.85);
  stroke-width: 4px;
  stroke-linejoin: round;
  pointer-events: none;
}

.orbit-ring {
  fill: none;
  stroke: rgba(247, 201, 72, 0.38);
  stroke-width: 1.6;
  stroke-dasharray: 5 6;
  pointer-events: none;
}

.discovery-pin {
  animation: floatPin 2.4s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}

@keyframes floatPin {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.map-bottom-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}

/* ==========================================================================
   View 2: Planet Exploration & Read-Aloud Card
   ========================================================================== */

.planet-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.95fr);
  gap: 20px;
  flex: 1;
  align-items: stretch;
}

.exploration-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.scene-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.planet-badge {
  display: inline-block;
  background: rgba(251, 243, 223, 0.14);
  border: 1.5px solid rgba(251, 243, 223, 0.28);
  color: #fff5d6;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 0.95rem;
}

.planet-progress-stars {
  display: flex;
  gap: 6px;
  font-size: 1.3rem;
}

.planet-scene-container {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 2px solid rgba(251, 243, 223, 0.22);
  box-shadow: var(--shadow-soft);
  background: #141c3c;
  aspect-ratio: 16 / 9.5;
  width: 100%;
}

.planet-scene-container svg {
  width: 100%;
  height: 100%;
  display: block;
}

.hotspot-group {
  cursor: pointer;
}

.hotspot-ring-outer {
  fill: none;
  stroke-width: 3;
  animation: pulseRing 2.1s ease-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}

.hotspot-ring-inner {
  fill: rgba(255, 255, 255, 0.14);
  stroke-width: 3;
  transition: fill 0.2s ease;
}

.hotspot-group:hover .hotspot-ring-inner {
  fill: rgba(255, 255, 255, 0.3);
}

.hotspot-group.discovered .hotspot-ring-outer {
  animation: none;
  opacity: 0.45;
}

@keyframes pulseRing {
  0% { transform: scale(0.95); opacity: 0.95; }
  70% { transform: scale(1.25); opacity: 0.15; }
  100% { transform: scale(1.3); opacity: 0; }
}

/* Discovery Speech Bubble */
.discovery-bubble {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(251, 243, 223, 0.96);
  color: var(--ink-brown);
  border: 3px solid var(--accent-gold);
  border-radius: var(--radius-lg);
  padding: 12px 18px;
  box-shadow: var(--shadow-soft);
}

.speaker-avatar {
  width: 58px;
  height: 58px;
  flex-shrink: 0;
  border-radius: 50%;
  background: #efe2c1;
  border: 2px solid var(--cream-border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.speaker-avatar svg {
  width: 54px;
  height: 54px;
}

.speaker-name {
  font-weight: 900;
  font-size: 0.92rem;
  color: var(--accent-orange);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}

.discovery-text {
  font-size: 1rem;
  line-height: 1.45;
  font-weight: 600;
}

/* Quiz Box */
.quiz-box {
  background: rgba(27, 42, 86, 0.88);
  border: 2px solid rgba(247, 201, 72, 0.45);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  box-shadow: var(--shadow-soft);
}

.quiz-header {
  font-weight: 800;
  color: var(--accent-gold);
  margin-bottom: 6px;
  font-size: 0.95rem;
}

.quiz-question {
  font-weight: 700;
  margin-bottom: 10px;
  font-size: 1rem;
}

.quiz-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quiz-option-btn {
  background: var(--cream-card);
  color: var(--ink-brown);
  border: 2px solid var(--cream-border);
  border-radius: var(--radius-pill);
  padding: 8px 16px;
  font-weight: 700;
  font-family: inherit;
  font-size: 0.93rem;
  cursor: pointer;
  transition: transform 0.14s ease, background 0.14s ease;
}

.quiz-option-btn:hover {
  transform: translateY(-2px);
  background: #fff9eb;
}

.quiz-option-btn.correct {
  background: #6be5a0;
  border-color: #2f9d60;
  color: #123c25;
}

.quiz-option-btn.wrong {
  background: #f6b2a6;
  border-color: #c95642;
  color: #531b12;
}

.quiz-feedback {
  margin-top: 8px;
  font-weight: 700;
  font-size: 0.94rem;
  color: #ffe8a3;
}

/* ==========================================================================
   Parent Read-Aloud Storybook Card
   ========================================================================== */

.readaloud-card {
  background: linear-gradient(180deg, var(--cream-card) 0%, #f6ead0 100%);
  color: var(--ink-brown);
  border: 3px solid var(--cream-border);
  border-radius: 28px;
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 14px 36px rgba(5, 10, 28, 0.5), 0 0 24px rgba(251, 243, 223, 0.14);
}

.readaloud-card.large-text {
  --story-font-size: 1.24rem;
}

.card-top-icons {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-badge-icons {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--accent-orange);
  font-weight: 800;
  font-size: 0.9rem;
}

.font-size-btn {
  border: 2px solid var(--cream-border);
  background: #fff8e7;
  color: var(--ink-brown);
  border-radius: 10px;
  padding: 4px 10px;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
}

.font-size-btn:hover {
  background: #ffefc8;
}

.card-planet-name {
  text-align: center;
  font-size: 1.9rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: var(--ink-brown);
  line-height: 1.1;
}

.card-mini-illustration {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 92px;
}

.card-mini-illustration svg {
  height: 90px;
  width: 140px;
}

.card-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: var(--cream-card-dark);
  padding: 4px;
  border-radius: var(--radius-pill);
}

.card-tab {
  border: none;
  background: transparent;
  color: var(--ink-soft);
  padding: 8px 10px;
  border-radius: var(--radius-pill);
  font-weight: 800;
  font-size: 0.88rem;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease, color 0.15s ease;
}

.card-tab.active {
  background: #fffaf0;
  color: var(--ink-brown);
  box-shadow: 0 2px 6px rgba(62, 42, 30, 0.12);
}

.card-tab-content {
  display: none;
  flex: 1;
  overflow-y: auto;
}

.card-tab-content.active {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.story-text {
  font-size: var(--story-font-size);
  line-height: 1.65;
  color: var(--ink-brown);
  font-weight: 600;
}

.parent-prompt-box {
  background: rgba(232, 107, 58, 0.1);
  border-left: 4px solid var(--accent-orange);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.93rem;
  line-height: 1.45;
  color: var(--ink-brown);
}

.parent-prompt-box strong {
  display: block;
  margin-bottom: 3px;
  color: var(--accent-orange-hover);
}

.facts-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.facts-list li {
  background: #fffaf0;
  border: 1.5px solid var(--cream-border);
  border-radius: 14px;
  padding: 10px 12px;
  font-size: calc(var(--story-font-size) * 0.95);
  line-height: 1.45;
  font-weight: 600;
}

.card-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding-top: 6px;
}

.readaloud-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent-orange);
  color: #fff;
  border: none;
  border-radius: var(--radius-pill);
  padding: 13px 18px;
  font-size: 1.08rem;
  font-weight: 900;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 6px 16px rgba(232, 107, 58, 0.35);
  transition: transform 0.15s ease, background 0.15s ease;
}

.readaloud-btn:hover {
  background: var(--accent-orange-hover);
  transform: translateY(-2px);
}

.readaloud-btn.speaking {
  background: #2f9d60;
}

.planet-nav-arrows {
  display: flex;
  gap: 6px;
}

.small-nav-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid var(--cream-border);
  background: #fff9eb;
  color: var(--ink-brown);
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.small-nav-btn:hover {
  background: #ffefc8;
  transform: scale(1.06);
}

/* ==========================================================================
   View 3: Constellations Mini-Game
   ========================================================================== */

.constellation-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.95fr);
  gap: 20px;
  flex: 1;
}

.constellation-stage-card {
  background: rgba(16, 26, 58, 0.85);
  border: 2px solid rgba(251, 243, 223, 0.22);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-soft);
}

.constellation-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.constellation-hint {
  color: #d8d4c8;
  font-size: 0.95rem;
  margin-top: 4px;
}

.constellation-selector {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.constellation-pill {
  background: rgba(251, 243, 223, 0.14);
  color: #fff6df;
  border: 1.5px solid rgba(251, 243, 223, 0.3);
  border-radius: var(--radius-pill);
  padding: 7px 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

.constellation-pill.active {
  background: var(--accent-gold);
  color: var(--ink-brown);
  border-color: var(--accent-gold);
}

.constellation-canvas-wrap {
  flex: 1;
  background: radial-gradient(circle at 50% 45%, #1d2d66 0%, #0d1636 100%);
  border-radius: var(--radius-md);
  border: 1.5px solid rgba(87, 226, 229, 0.25);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.constellation-svg {
  width: 100%;
  height: 100%;
  max-height: 430px;
}

.const-star {
  cursor: pointer;
  transition: transform 0.16s ease;
  transform-box: fill-box;
  transform-origin: center;
}

.const-star:hover {
  transform: scale(1.22);
}

/* ==========================================================================
   Modals (Crew & Logbook)
   ========================================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 10, 26, 0.72);
  backdrop-filter: blur(5px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-card {
  position: relative;
  background: var(--cream-card);
  color: var(--ink-brown);
  border: 3px solid var(--cream-border);
  border-radius: 28px;
  padding: 26px;
  max-width: 780px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
}

.modal-card-wide {
  max-width: 860px;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid var(--cream-border);
  background: #fff9eb;
  color: var(--ink-brown);
  font-size: 1.1rem;
  font-weight: 900;
  cursor: pointer;
}

.modal-title {
  font-size: 1.65rem;
  font-weight: 900;
  margin-bottom: 4px;
}

.modal-subtitle {
  color: var(--ink-soft);
  margin-bottom: 18px;
  font-weight: 600;
}

.crew-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
}

.crew-member-card {
  background: #fffaf0;
  border: 2px solid var(--cream-border);
  border-radius: 20px;
  padding: 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.crew-member-card svg {
  width: 110px;
  height: 110px;
}

.crew-member-name {
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--accent-orange);
}

.crew-member-role {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--ink-brown);
}

.crew-member-desc {
  font-size: 0.86rem;
  line-height: 1.4;
  color: var(--ink-soft);
}

.logbook-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.logbook-item {
  background: #fffaf0;
  border: 2px solid var(--cream-border);
  border-radius: 18px;
  padding: 14px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
  text-align: left;
  font-family: inherit;
}

.logbook-item:hover {
  transform: translateY(-2px);
  border-color: var(--accent-orange);
}

.logbook-item-title {
  font-weight: 900;
  font-size: 1.05rem;
  color: var(--ink-brown);
  margin-bottom: 4px;
}

.logbook-item-sub {
  font-size: 0.86rem;
  color: var(--ink-soft);
}

/* ==========================================================================
   Toast
   ========================================================================== */

.star-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  background: var(--accent-gold);
  color: var(--ink-brown);
  border: 3px solid #fff8df;
  border-radius: var(--radius-pill);
  padding: 10px 22px;
  font-weight: 900;
  font-size: 1.05rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  animation: toastPop 0.25s ease;
}

@keyframes toastPop {
  from { transform: translate(-50%, 16px) scale(0.92); opacity: 0; }
  to { transform: translate(-50%, 0) scale(1); opacity: 1; }
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 960px) {
  .planet-layout,
  .constellation-layout {
    grid-template-columns: 1fr;
  }

  .top-bar {
    padding: 10px 14px;
  }

  .view {
    padding: 4px 14px 20px;
  }
}
