:root {
  --arcade-bg: #030712;
  --arcade-panel: rgba(6, 12, 24, 0.68);
  --arcade-panel-strong: rgba(5, 10, 22, 0.86);
  --arcade-border: rgba(148, 163, 184, 0.18);
  --arcade-text: #e2e8f0;
  --arcade-muted: #94a3b8;
  --arcade-cyan: #67e8f9;
  --arcade-blue: #60a5fa;
  --arcade-violet: #a78bfa;
  --arcade-pink: #f472b6;
  --arcade-green: #4ade80;
  --arcade-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

body.arcade-page {
  background: var(--arcade-bg);
}

#sim-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 20%, rgba(59, 130, 246, 0.18), transparent 28%),
    radial-gradient(circle at 78% 18%, rgba(168, 85, 247, 0.16), transparent 24%),
    radial-gradient(circle at center, #081223 0%, #02050d 50%, #000 100%);
  touch-action: none;
}

#loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  gap: 18px;
  background:
    radial-gradient(circle at center, rgba(15, 23, 42, 0.92), rgba(2, 6, 23, 0.98));
  transition: opacity 0.5s ease;
}

#loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-spinner {
  width: 56px;
  height: 56px;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--arcade-cyan);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.loading-text {
  color: var(--arcade-text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.92rem;
  letter-spacing: 0.28em;
}

#arcade-hub-ui {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 32px;
  background: linear-gradient(180deg, rgba(2, 6, 23, 0.3), rgba(2, 6, 23, 0.84));
  backdrop-filter: blur(18px);
}

#arcade-hub-ui.hidden {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.hub-shell {
  width: min(1240px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(340px, 0.95fr);
  gap: 28px;
  align-items: stretch;
}

.hub-copy,
.hub-grid,
.hub-card,
.metric-pill,
.hud-panel,
.sim-top-bar {
  border: 1px solid var(--arcade-border);
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.52), rgba(2, 6, 23, 0.72));
  box-shadow: var(--arcade-shadow);
  backdrop-filter: blur(16px);
}

.hub-copy {
  padding: clamp(28px, 4vw, 48px);
  border-radius: 28px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
}

.hub-eyebrow,
.card-kicker,
.sim-label,
.panel-kicker,
.data-label,
.control-label,
.carousel-label {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: var(--arcade-muted);
}

.hub-title {
  margin: 0;
  font-size: clamp(2.5rem, 5vw, 4.9rem);
  line-height: 0.95;
  letter-spacing: -0.05em;
  color: white;
}

.hub-subtitle,
#sim-subtitle,
.panel-description,
.card-content p,
.data-note {
  color: var(--arcade-muted);
  line-height: 1.75;
}

.hub-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.metric-pill {
  min-width: 180px;
  padding: 16px 18px;
  border-radius: 18px;
}

.metric-label {
  display: block;
  margin-bottom: 8px;
  color: var(--arcade-muted);
  font-size: 0.76rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.system-online {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--arcade-green);
  box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.5);
  animation: pulse 2s infinite;
}

.hub-grid {
  border-radius: 28px;
  padding: 20px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

.hub-card {
  border-radius: 24px;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(190px, 240px) 1fr;
  min-height: 270px;
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
  cursor: pointer;
}

.hub-card:hover,
.hub-card:focus-visible {
  transform: translateY(-6px);
  border-color: rgba(103, 232, 249, 0.45);
  box-shadow: 0 28px 90px rgba(5, 15, 35, 0.7);
  outline: none;
}

.hub-card.featured {
  border-color: rgba(96, 165, 250, 0.32);
}

.card-preview {
  position: relative;
  min-height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at center, rgba(15, 23, 42, 0.4), rgba(2, 6, 23, 0.9));
}

.card-content {
  padding: 26px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
}

.card-content h3 {
  margin: 0;
  font-size: 1.65rem;
  color: white;
}

.btn-launch,
.btn-control,
.btn-back {
  appearance: none;
  border: 1px solid rgba(103, 232, 249, 0.36);
  background: rgba(8, 15, 28, 0.72);
  color: #ecfeff;
  padding: 12px 18px;
  border-radius: 14px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.btn-launch:hover,
.btn-control:hover,
.btn-back:hover,
.btn-launch:focus-visible,
.btn-control:focus-visible,
.btn-back:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(103, 232, 249, 0.75);
  background: rgba(10, 20, 36, 0.95);
  box-shadow: 0 12px 30px rgba(14, 165, 233, 0.18);
  outline: none;
}

.btn-launch {
  margin-top: 4px;
  width: fit-content;
}

.btn-control.ghost,
.btn-back.secondary {
  border-color: rgba(148, 163, 184, 0.28);
  color: var(--arcade-muted);
}

.btn-control.is-active {
  border-color: rgba(96, 165, 250, 0.8);
  box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.4), 0 0 28px rgba(96, 165, 250, 0.18);
}

.hub-footer {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding-inline: 8px;
}

.preview-core,
.preview-ring,
.planet-dot {
  position: absolute;
  border-radius: 50%;
}

.preview-earth {
  inset: 50% auto auto 50%;
  width: 112px;
  height: 112px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 30% 30%, #8be0ff, #2563eb 45%, #0b1120 75%);
  box-shadow: 0 0 60px rgba(96, 165, 250, 0.35);
}

.preview-ring {
  inset: 50% auto auto 50%;
  border: 1px solid rgba(103, 232, 249, 0.28);
  transform: translate(-50%, -50%);
}

.preview-ring-1 {
  width: 170px;
  height: 170px;
}

.preview-ring-2 {
  width: 220px;
  height: 220px;
  opacity: 0.45;
}

.preview-sun {
  top: 50%;
  left: 32%;
  width: 94px;
  height: 94px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, #fde68a, #f59e0b 52%, rgba(245, 158, 11, 0.18) 80%);
  box-shadow: 0 0 70px rgba(251, 191, 36, 0.35);
}

.planet-dot {
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0 0 16px rgba(255, 255, 255, 0.12);
}

.planet-dot.mercury { width: 8px; height: 8px; top: 36%; right: 28%; }
.planet-dot.venus { width: 12px; height: 12px; top: 52%; right: 20%; background: #fde68a; }
.planet-dot.mars { width: 10px; height: 10px; bottom: 28%; right: 33%; background: #fb7185; }

#simulation-ui {
  position: fixed;
  inset: 0;
  z-index: 30;
  pointer-events: none;
}

#simulation-ui.hidden {
  display: none !important;
}

.sim-top-bar {
  position: fixed;
  top: 20px;
  left: 20px;
  right: 20px;
  z-index: 35;
  border-radius: 24px;
  padding: 18px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  pointer-events: auto;
  box-sizing: border-box;
}

.sim-overview {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#sim-title {
  color: white;
  font-size: 1.24rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

#sim-subtitle {
  margin: 0;
  font-size: 0.95rem;
}

.sim-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

#sim-content-layer {
  position: fixed;
  inset: 0;
  z-index: 34;
  pointer-events: none;
}

.hud-panel {
  position: absolute;
  border-radius: 22px;
  padding: 18px;
  color: var(--arcade-text);
  pointer-events: auto;
  box-sizing: border-box;
}

.hud-top-left { top: 112px; left: 20px; width: min(380px, calc(100vw - 40px)); }
.hud-top-right { top: 112px; right: 20px; width: min(320px, calc(100vw - 40px)); }
.hud-bottom-left { left: 20px; bottom: 20px; width: min(420px, calc(100vw - 40px)); }
.hud-bottom-right { right: 20px; bottom: 20px; width: min(360px, calc(100vw - 40px)); }

.hud-stack {
  display: grid;
  gap: 16px;
}

.data-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.data-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
}

.data-value {
  color: white;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95rem;
}

.data-card {
  padding: 14px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.48);
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.data-card strong {
  display: block;
  margin-top: 6px;
  color: white;
  font-size: 1rem;
}

.panel-title {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
  margin-bottom: 14px;
}

.panel-title h2,
.panel-title h3 {
  margin: 6px 0 0;
  color: white;
  font-size: 1.22rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.52);
  border: 1px solid rgba(74, 222, 128, 0.2);
  font-size: 0.8rem;
  color: #bbf7d0;
}

.status-bar {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(148, 163, 184, 0.14);
  color: var(--arcade-muted);
  font-size: 0.82rem;
}

.control-stack {
  display: grid;
  gap: 12px;
}

.control-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.control-group .btn-control {
  width: 100%;
}

.timeline-meter {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  overflow: hidden;
}

.timeline-meter > span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--arcade-cyan), var(--arcade-violet));
  transition: width 0.2s ease;
}

.orbit-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-top: 14px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--arcade-muted);
  font-size: 0.8rem;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 999px;
}

.legend-swatch.trail { background: rgba(103, 232, 249, 0.95); }
.legend-swatch.prediction { background: rgba(244, 114, 182, 0.95); }
.legend-swatch.user { background: rgba(74, 222, 128, 0.95); }

.solar-selector {
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  width: min(900px, calc(100vw - 40px));
}

.selector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.selector-grid .btn-control {
  min-height: 52px;
}

.panel-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

@media (max-width: 1080px) {
  .hub-shell { grid-template-columns: 1fr; }
  .hub-footer { justify-content: flex-start; flex-wrap: wrap; }
  .hub-grid { grid-template-columns: 1fr 1fr; }
  .hub-card { grid-template-columns: 1fr; }
  .card-preview { min-height: 180px; }
}

@media (max-width: 860px) {
  #arcade-hub-ui { align-items: start; overflow: auto; }
  .hub-shell { padding-block: 24px; }
  .hub-grid { grid-template-columns: 1fr; gap: 20px; }
  .sim-top-bar {
    top: 12px;
    left: 12px;
    right: 12px;
    width: auto;
    flex-direction: column;
    align-items: stretch;
  }
  .sim-actions { justify-content: stretch; }
  .sim-actions .btn-control { flex: 1 1 calc(50% - 10px); }
  .hud-top-left,
  .hud-top-right { top: 152px; }
}

@media (max-width: 720px) {
  #arcade-hub-ui { padding: 16px; }
  .hub-copy,
  .hub-grid,
  .hud-panel,
  .sim-top-bar { border-radius: 20px; }
  .hub-title { font-size: clamp(2.2rem, 12vw, 3.5rem); }
  .hud-panel {
    position: static;
    width: auto !important;
  }
  #sim-content-layer, #solar-ui-container, #orbital-ui-container {
    padding: 152px 12px 12px;
    overflow: auto;
    display: grid;
    align-content: space-between;
    gap: 12px;
    pointer-events: none;
  }
  #solar-ui-container.ui-container-visible .hud-panel, #orbital-ui-container.ui-container-visible .hud-panel {
    pointer-events: auto;
  }
  .hud-top-left,
  .hud-top-right,
  .hud-bottom-left,
  .hud-bottom-right,
  .solar-selector {
    position: static !important;
    transform: none !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    bottom: auto !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  .data-grid,
  .panel-facts,
  .control-group { grid-template-columns: 1fr; }
  .btn-control,
  .btn-launch,
  .btn-back { min-height: 48px; }
  .solar-selector { margin-top: auto; }
}

@media (max-width: 480px) {
  .metric-pill { min-width: 100%; }
  .sim-actions .btn-control { flex-basis: 100%; }
  .card-content,
  .hub-copy,
  .hud-panel { padding: 20px; }
  .hub-grid { padding: 16px 0; }
  .loading-text { font-size: 0.8rem; letter-spacing: 0.18em; }
  .selector-grid { grid-template-columns: repeat(2, 1fr); }
  .hub-hero h1 { font-size: 2rem; }
  .card-header h2 { font-size: 1.5rem; }
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.48); }
  70% { box-shadow: 0 0 0 10px rgba(74, 222, 128, 0); }
  100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}

/* Solar System Explorer UI Toggle Overrides */
.fab-info {
  position: absolute;
  top: 100px;
  right: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(103, 232, 249, 0.4);
  color: #67e8f9;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
  backdrop-filter: blur(8px);
}

.fab-info:hover {
  transform: scale(1.05);
  background: rgba(30, 41, 59, 0.95);
  border-color: #67e8f9;
}

.fab-info:active {
  transform: scale(0.95);
}

#solar-ui-container, #orbital-ui-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none; /* Let clicks pass through empty space */
  z-index: 50;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

#solar-ui-container.ui-container-visible, #orbital-ui-container.ui-container-visible {
  opacity: 1;
  visibility: visible;
}

#solar-ui-container.ui-container-hidden, #orbital-ui-container.ui-container-hidden {
  opacity: 0;
  visibility: hidden;
}

.hud-panel {
  pointer-events: auto; /* Re-enable pointer events for panels */
  position: absolute;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

#solar-ui-container.ui-container-hidden .hud-panel, #orbital-ui-container.ui-container-hidden .hud-panel {
  transform: translateY(20px);
}

#solar-ui-container.ui-container-visible .hud-panel, #orbital-ui-container.ui-container-visible .hud-panel {
  transform: translateY(0);
}

.btn-close-panel {
  position: absolute;
  top: 12px;
  right: 12px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
  transition: color 0.2s ease;
  z-index: 10;
}

.btn-close-panel:hover {
  color: white;
}

@media (max-width: 768px) {
  .fab-info {
    top: auto;
    bottom: 24px;
    right: 24px;
  }

  .horizontal-scroll-mobile {
    display: flex !important;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 12px;
    padding-bottom: 8px; /* For scrollbar space */
    -webkit-overflow-scrolling: touch;
    /* Hide scrollbar for a cleaner look */
    scrollbar-width: none;
  }
  .horizontal-scroll-mobile::-webkit-scrollbar {
    display: none;
  }

  .horizontal-scroll-mobile .btn-control {
    flex: 0 0 auto;
    scroll-snap-align: start;
    white-space: nowrap;
    min-width: 120px;
  }
}


@media (max-width: 480px) {
  /* Fix vertical stacking inside the scrolling row for tiny screens */
  .horizontal-scroll-mobile {
    gap: 8px;
  }
}
