:root {
  --primary-color: #00d4ff;
  --bg-color: #000;
  --text-color: #fff;
  --panel-bg: rgba(20, 20, 30, 0.8);
}

body {
  margin: 0;
  overflow: hidden;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  /* Remove tap highlight on mobile */
}

#canvas-container {
  width: 100vw;
  height: 100vh;
  /* Fallback */
  height: 100dvh;
  /* Mobile fix */
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
}

#ui-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
}

/* Main Title */
.main-title {
  position: absolute;
  top: 30px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 32px;
  font-weight: 300;
  text-transform: uppercase;
  letter-spacing: 4px;
  color: white;
  text-shadow: 0 0 20px rgba(0, 212, 255, 0.5);
  margin: 0;
  pointer-events: none;
  text-align: center;
  white-space: nowrap;
  width: 100%;
}

/* Controls Panel */
.controls-panel {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-bg);
  padding: 15px 25px;
  border-radius: 30px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  transition: bottom 0.3s ease;
}

.control-group {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.control-group label {
  font-size: 12px;
  margin-bottom: 5px;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 1px;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 150px;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary-color);
  cursor: pointer;
  transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

button.reset-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
  white-space: nowrap;
}

button.reset-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: white;
}

/* Planet Info Panel */
.info-panel {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 300px;
  max-width: 90%;
  /* Safety for smaller screens */
  background: var(--panel-bg);
  border-radius: 15px;
  padding: 20px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transform: translateX(120%);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: auto;
  z-index: 20;
}

.info-panel.active {
  transform: translateX(0);
}

.info-panel h2 {
  margin: 0 0 10px 0;
  color: var(--primary-color);
  font-size: 28px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  padding-bottom: 10px;
}

.info-panel p {
  line-height: 1.6;
  font-size: 14px;
  color: #ddd;
}

.info-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 15px;
}

.stat-item {
  background: rgba(255, 255, 255, 0.05);
  padding: 8px;
  border-radius: 8px;
}

.stat-label {
  display: block;
  font-size: 11px;
  color: #aaa;
}

.stat-value {
  display: block;
  font-size: 14px;
  font-weight: bold;
}

.close-btn {
  position: absolute;
  top: 10px;
  right: 15px;
  background: none;
  border: none;
  color: #aaa;
  font-size: 24px;
  cursor: pointer;
  padding: 5px;
}

.close-btn:hover {
  color: white;
}

.footer {
  position: absolute;
  bottom: 20px;
  width: 100%;
  text-align: center;
  color: rgba(255, 255, 255, 0.4);
  font-size: 13px;
  letter-spacing: 1px;
  pointer-events: none;
  font-weight: 300;
}

/* 3D Labels */
.planet-label {
  position: absolute;
  color: #fff;
  font-family: 'Segoe UI', sans-serif;
  font-weight: bold;
  font-size: 14px;
  background: rgba(0, 0, 0, 0.6);
  padding: 4px 8px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 12px;
  pointer-events: none;
  /* Use transform ONLY for centering relative to the top/left coordinate set by JS */
  transform: translate(-50%, -120%);
  white-space: nowrap;
  backdrop-filter: blur(4px);
  transition: opacity 0.2s;
  opacity: 0.9;
  text-shadow: 0 0 4px #000;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
  /* Ensure it starts at 0,0 so JS setting left/top works as absolute coordinates */
  left: 0;
  top: 0;
}

@media (max-width: 768px) {
  .planet-label {
    font-size: 10px;
    /* Smaller labels on mobile */
    padding: 2px 5px;
    transform: translate(-50%, -150%);
    /* Move a bit higher up to clear small planets */
  }
}

/* Loading Screen */
#loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  transition: opacity 0.5s;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: var(--primary-color);
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* --- MOBILE RESPONSIVE STYLES --- */
@media (max-width: 768px) {
  .main-title {
    font-size: 20px;
    letter-spacing: 2px;
    top: 20px;
    white-space: normal;
    padding: 0 20px;
    line-height: 1.4;
  }

  /* Move controls up slightly to avoid overlapping native home bars */
  .controls-panel {
    width: 85%;
    padding: 10px 15px;
    gap: 15px;
    bottom: 50px;
    flex-wrap: wrap;
    /* Allow wrapping if very small */
  }

  .footer {
    bottom: 15px;
    font-size: 11px;
  }

  /* Bottom Sheet for Info Panel on Mobile */
  .info-panel {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    border-radius: 20px 20px 0 0;
    transform: translateY(110%);
    /* Start hidden below */
    border-left: none;
    border-right: none;
    border-bottom: none;
  }

  .info-panel.active {
    transform: translateY(0);
  }

  /* When info panel is active, hide controls to clear view */
  body:has(.info-panel.active) .controls-panel {
    bottom: -100px;
    /* Slide away */
  }

  /* Or safer selector if :has isn't supported in target env (it is modern though) */
}