/* ─── Space Station Hub — Deep Space Aesthetic ────────────────────────────────
   Mobile-first (ages 2–5). CSS 3D transforms. Calm, no flashing.              */

/* ─── Variables ─── */
:root {
  --bg-void: #040810;
  --bg-panel: #070d18;
  --bg-card: #0b1220;
  --bg-card-hover: #111828;
  --fg: #dce8f0;
  --fg-muted: #6a8090;
  --accent-dust: #c8a84b;      /* Star Dust gold */
  --accent-dust-glow: rgba(200,168,75,0.25);
  --accent-dust-soft: rgba(200,168,75,0.1);
  --accent-teal: #3d8f82;
  --accent-blue: #4a7ab5;
  --accent-cyan: #4ab5c8;
  --accent-violet: #8a6bbf;
  --border-subtle: rgba(220,232,240,0.07);
  --border-dust: rgba(200,168,75,0.15);
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
}

/* ─── Reset ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  background: var(--bg-void);
  color: var(--fg);
  font-family: var(--font-body);
  font-weight: 300;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
h1,h2,h3 { font-family: var(--font-display); font-weight: 600; }

/* ─── Starfield Background ─── */
.starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.star-dot {
  position: absolute;
  border-radius: 50%;
  background: #fff;
}
.star-dot.twinkle {
  animation: twinkle 4s ease-in-out infinite alternate;
}
@keyframes twinkle {
  0%   { opacity: 0.2; }
  100% { opacity: 0.8; }
}

/* ─── App Shell ─── */
.hub-app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── Top Bar ─── */
.hub-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: rgba(4,8,16,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
}
.hub-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--fg);
}
.hub-brand svg { width: 28px; height: 28px; }

.dust-counter {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(200,168,75,0.08);
  border: 1px solid var(--border-dust);
  border-radius: 999px;
  padding: 6px 16px 6px 10px;
  cursor: default;
  user-select: none;
}
.dust-icon { font-size: 1.2rem; }
.dust-amount {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-dust);
  min-width: 28px;
  text-align: right;
}
.dust-label {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
}
.hub-parent-link, .hub-signin-link {
  font-size: 0.82rem;
  color: var(--fg-muted);
  text-decoration: none;
  transition: color 0.2s;
  padding: 4px 8px;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
}
.hub-parent-link { color: var(--accent-dust); border-color: var(--border-dust); }
.hub-parent-link:hover { color: #dab85c; }
.hub-signin-link:hover { color: var(--fg); }

/* ─── Navigation Tabs ─── */
.hub-nav {
  display: flex;
  gap: 4px;
  padding: 8px 16px;
  overflow-x: auto;
  scrollbar-width: none;
}
.hub-nav::-webkit-scrollbar { display: none; }
.nav-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--fg-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  background: none;
  flex-shrink: 0;
}
.nav-tab:hover { color: var(--fg); border-color: var(--border-subtle); }
.nav-tab.active {
  background: var(--bg-card);
  border-color: var(--accent-dust);
  color: var(--accent-dust);
}
.nav-tab .tab-emoji { font-size: 1rem; }

/* ─── Main Content ─── */
.hub-main {
  flex: 1;
  padding: 16px 16px 120px;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

/* ─── 3D Station View ─── */
.station-canvas {
  perspective: 900px;
  perspective-origin: 50% 40%;
  margin: 0 auto 32px;
  height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
}
.station-canvas:active { cursor: grabbing; }

.station-scene {
  transform-style: preserve-3d;
  transform: rotateX(-8deg) rotateY(-15deg);
  transition: transform 0.6s cubic-bezier(0.23,1,0.32,1);
  position: relative;
  width: 260px;
  height: 260px;
}
.station-scene.rot-1 { transform: rotateX(-8deg)  rotateY(15deg);  }
.station-scene.rot-2 { transform: rotateX(-8deg)  rotateY(45deg);  }
.station-scene.rot-3 { transform: rotateX(-8deg)  rotateY(75deg);  }
.station-scene.rot-4 { transform: rotateX(-8deg)  rotateY(105deg); }
.station-scene.rot-5 { transform: rotateX(-8deg)  rotateY(135deg); }

.core-body {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 100px; height: 100px;
  background: linear-gradient(145deg, #1a2a40, #0d1a2c);
  border: 1px solid rgba(74,180,200,0.3);
  border-radius: 12px;
  box-shadow:
    0 0 30px rgba(74,180,200,0.1),
    inset 0 0 20px rgba(74,180,200,0.05);
  display: flex;
  align-items: center;
  justify-content: center;
}
.core-window {
  width: 60px; height: 60px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, rgba(74,180,200,0.2) 0%, rgba(10,30,50,0.9) 70%);
  border: 2px solid rgba(74,180,200,0.5);
  box-shadow: 0 0 12px rgba(74,180,200,0.3);
}

/* Station Modules */
.station-module {
  position: absolute;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: box-shadow 0.3s ease, transform 0.3s ease;
  cursor: pointer;
  user-select: none;
}
.station-module:hover {
  box-shadow: 0 0 20px rgba(74,180,200,0.2);
  transform: translateZ(8px);
}
.station-module.owned {
  border: 1px solid rgba(74,180,200,0.35);
  background: rgba(10,30,50,0.8);
}
.station-module.locked {
  border: 1px solid rgba(100,120,140,0.2);
  background: rgba(10,20,35,0.6);
  opacity: 0.7;
}
.module-emoji { font-size: 1.2rem; }
.module-name  { font-size: 0.6rem; color: var(--fg-muted); text-align: center; max-width: 48px; line-height: 1.2; }

/* Module positions (positioned around the core) */
.mod-l-1 { left: -55px; top: 0; width: 50px; height: 50px; }
.mod-r-1 { right: -55px; top: 0; width: 50px; height: 50px; }
.mod-l-2 { left: -65px; top: 80px; width: 60px; height: 45px; }
.mod-r-2 { right: -65px; top: 80px; width: 60px; height: 45px; }
.mod-t    { top: -65px; left: 50%; transform: translateX(-50%); width: 50px; height: 50px; }
.mod-b    { bottom: -65px; left: 50%; transform: translateX(-50%); width: 50px; height: 50px; }
.mod-tl   { top: 30px; left: -20px; width: 45px; height: 45px; }
.mod-tr   { top: 30px; right: -20px; width: 45px; height: 45px; }

/* Connector struts */
.strut {
  position: absolute;
  background: linear-gradient(90deg, rgba(74,180,200,0.2), rgba(74,180,200,0.4), rgba(74,180,200,0.2));
  height: 2px;
  border-radius: 1px;
  transform-origin: left center;
}
.strut-1 { top: 50px; left: 80px; width: 60px; transform: rotate(0deg); }
.strut-2 { top: 50px; right: 80px; width: 60px; transform: rotate(0deg); }
.strut-3 { top: 100px; left: 80px; width: 70px; transform: rotate(0deg); }
.strut-4 { top: 100px; right: 80px; width: 70px; transform: rotate(0deg); }

/* ─── Station Info Bar ─── */
.station-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  margin-bottom: 20px;
}
.station-stat { display: flex; flex-direction: column; gap: 2px; }
.station-stat-val {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent-dust);
}
.station-stat-label { font-size: 0.7rem; color: var(--fg-muted); letter-spacing: 0.06em; text-transform: uppercase; }

/* ─── Module Catalog ─── */
.modules-section { margin-top: 8px; }
.section-title {
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: 12px;
  padding-left: 4px;
}
.modules-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.module-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.25s;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.module-card:hover { border-color: rgba(200,168,75,0.3); }
.module-card.owned {
  border-color: rgba(74,180,200,0.25);
  background: rgba(74,180,200,0.05);
}
.module-card.owned::after {
  content: '✓ Owned';
  position: absolute;
  top: 8px; right: 8px;
  font-size: 0.65rem;
  color: var(--accent-teal);
  letter-spacing: 0.05em;
}
.module-card.locked-preview {
  opacity: 0.55;
}
.module-card-header { display: flex; align-items: center; gap: 8px; }
.module-card-icon { font-size: 1.6rem; line-height: 1; }
.module-card-name { font-size: 0.85rem; font-weight: 500; color: var(--fg); }
.module-card-name.locked-label { color: var(--fg-muted); }
.module-card-desc { font-size: 0.75rem; color: var(--fg-muted); line-height: 1.4; }
.module-card-cost {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: auto;
  padding-top: 4px;
  border-top: 1px solid var(--border-subtle);
}
.cost-dust { font-size: 0.95rem; }
.cost-amount {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent-dust);
}
.cost-label { font-size: 0.7rem; color: var(--fg-muted); }
.module-card.locked-preview .cost-amount { color: var(--fg-muted); }

/* ─── Purchase Modal ─── */
.purchase-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(4,8,16,0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 0 40px;
  animation: fade-in 0.2s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.purchase-sheet {
  background: var(--bg-card);
  border: 1px solid var(--accent-dust);
  border-radius: 20px 20px 0 0;
  padding: 28px 24px 40px;
  width: 100%;
  max-width: 480px;
  text-align: center;
  animation: slide-up 0.3s cubic-bezier(0.23,1,0.32,1);
}
@keyframes slide-up {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.purchase-icon { font-size: 3rem; margin-bottom: 12px; }
.purchase-name {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 8px;
}
.purchase-desc { font-size: 0.9rem; color: var(--fg-muted); margin-bottom: 24px; line-height: 1.5; }
.purchase-cost-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 20px;
  padding: 12px;
  background: rgba(200,168,75,0.08);
  border: 1px solid var(--border-dust);
  border-radius: 10px;
}
.purchase-cost-amount {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-dust);
}
.purchase-balance {
  font-size: 0.8rem;
  color: var(--fg-muted);
  margin-top: 4px;
}
.purchase-actions { display: flex; gap: 12px; }
.btn {
  flex: 1;
  padding: 14px 20px;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: transform 0.15s, opacity 0.15s;
  font-family: var(--font-body);
}
.btn:active { transform: scale(0.96); }
.btn-cancel {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  color: var(--fg-muted);
}
.btn-confirm {
  background: var(--accent-dust);
  color: #040810;
}
.btn-confirm:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-confirm:disabled:active { transform: none; }
.btn-confirm.loading::after {
  content: '...';
  animation: pulse 0.8s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 0.4; } 50% { opacity: 1; } }

.purchase-error {
  margin-top: 12px;
  padding: 10px 16px;
  background: rgba(220,80,80,0.1);
  border: 1px solid rgba(220,80,80,0.2);
  border-radius: 8px;
  font-size: 0.82rem;
  color: #e07070;
  display: none;
}
.purchase-error.visible { display: block; }

/* ─── Success Toast ─── */
.success-toast {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  background: var(--bg-card);
  border: 1px solid var(--accent-teal);
  border-radius: 12px;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--accent-teal);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  animation: toast-in 0.3s cubic-bezier(0.23,1,0.32,1);
}
@keyframes toast-in {
  from { transform: translateX(-50%) translateY(-16px); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0);      opacity: 1; }
}
.success-toast .toast-icon { font-size: 1.3rem; }
.success-toast .toast-msg { font-weight: 400; }
.success-toast .toast-amount { font-family: var(--font-display); font-weight: 700; }

/* ─── Rotate hint ─── */
.rotate-hint {
  text-align: center;
  font-size: 0.75rem;
  color: var(--fg-muted);
  margin-bottom: 20px;
  letter-spacing: 0.05em;
}

/* ─── Mission Complete Banner ─── */
.mission-banner {
  background: linear-gradient(135deg, rgba(200,168,75,0.1) 0%, rgba(74,180,200,0.08) 100%);
  border: 1px solid var(--border-dust);
  border-radius: 14px;
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.mission-banner-icon { font-size: 2rem; }
.mission-banner-text { flex: 1; }
.mission-banner-title { font-family: var(--font-display); font-size: 1rem; font-weight: 600; color: var(--accent-dust); margin-bottom: 2px; }
.mission-banner-sub { font-size: 0.78rem; color: var(--fg-muted); }
.mission-banner-cta {
  padding: 8px 16px;
  background: var(--accent-dust);
  color: #040810;
  border: none;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-body);
  white-space: nowrap;
}

/* ─── Empty State ─── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--fg-muted);
}
.empty-state-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state-title { font-size: 1rem; font-weight: 500; color: var(--fg); margin-bottom: 6px; }
.empty-state-sub { font-size: 0.82rem; line-height: 1.5; }

/* ─── Loading skeleton ─── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 0%, rgba(255,255,255,0.03) 50%, var(--bg-card) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 6px;
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ─── Bottom Mission Button ─── */
.hub-bottom {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px 20px 24px;
  background: linear-gradient(0deg, rgba(4,8,16,0.95) 0%, transparent 100%);
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.btn-mission {
  width: 100%;
  max-width: 480px;
  padding: 16px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-teal));
  color: #040810;
  border: none;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font-display);
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 20px rgba(74,180,200,0.25);
}
.btn-mission:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(74,180,200,0.35); }
.btn-mission:active { transform: scale(0.97); }
.mission-sub { font-size: 0.72rem; color: rgba(220,232,240,0.5); }

/* ─── Responsive ─── */
@media (min-width: 480px) {
  .modules-grid { grid-template-columns: repeat(3, 1fr); }
  .station-canvas { height: 380px; }
  .station-scene { width: 300px; height: 300px; }
}
@media (min-width: 768px) {
  .hub-main { max-width: 900px; padding: 24px 32px 120px; }
  .modules-grid { grid-template-columns: repeat(4, 1fr); }
  .station-canvas { height: 440px; }
  .station-scene { width: 340px; height: 340px; }
  .hub-nav { padding: 8px 32px; }
}