* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: #000000;
  overflow: hidden;
  font-family: 'Arial', sans-serif;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* Three.js canvas background */
#space-background {
  position: fixed;
  width: 100%;
  height: 100vh;
  display: block;
  top: 0;
  left: 0;
  z-index: -1;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

#space-background canvas {
  pointer-events: none !important;
}

/* Remove the old static starry background */
body::before {
  display: none;
}

.back-button {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 100;
}

.back-button a {
  color: #fff;
  text-decoration: none;
  font-size: 18px;
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
  display: inline-block;
}

.back-button a:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateX(-5px);
}

.solar-system {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

/* Sun */
.sun {
  position: absolute;
  width: 80px;
  height: 80px;
  z-index: 10;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulse 4s ease-in-out infinite;
  pointer-events: auto;
}

/* Larger invisible click area for Sun */
.sun::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 120%;
  height: 120%;
  min-width: 100px;
  min-height: 100px;
  border-radius: 50%;
  z-index: -1;
}

.sun img {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 30px rgba(255, 200, 0, 0.8));
  animation: rotate 30s linear infinite;
  pointer-events: none;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Orbits */
.orbit {
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  pointer-events: none; /* Don't block planet clicks */
}

/* Planet styling */
.planet {
  position: absolute;
  top: -15px; /* Adjust for better click area */
  left: 50%;
  transform: translateX(-50%);
  cursor: pointer;
  transition: transform 0.3s ease;
  pointer-events: auto; /* Make sure planets are clickable */
  z-index: 50;
}

/* Larger invisible click area */
.planet::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 150%;
  height: 150%;
  min-width: 30px;
  min-height: 30px;
  border-radius: 50%;
  z-index: -1;
}

.planet:hover {
  transform: translateX(-50%) scale(1.3);
  z-index: 100;
}

.planet img {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.3));
  pointer-events: none; /* Let clicks pass through to parent */
  animation: rotatePlanet 20s linear infinite;
}

@keyframes rotatePlanet {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Different rotation speeds for each planet */
.sun img {
  animation: rotatePlanet 30s linear infinite;
}

.mercury img {
  animation: rotatePlanet 10s linear infinite;
}

.venus img {
  animation: rotatePlanet 25s linear infinite reverse;
}

.earth img {
  animation: rotatePlanet 15s linear infinite;
}

.mars img {
  animation: rotatePlanet 18s linear infinite;
}

.jupiter img {
  animation: rotatePlanet 8s linear infinite;
}

.saturn img {
  animation: rotatePlanet 9s linear infinite;
}

.uranus img {
  animation: rotatePlanet 12s linear infinite;
}

.neptune img {
  animation: rotatePlanet 13s linear infinite;
}

.moon img {
  animation: rotatePlanet 5s linear infinite;
}

.planet-label {
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  color: white;
  font-size: 10px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  text-shadow: 0 0 5px rgba(0,0,0,0.8);
}

.planet:hover .planet-label,
.sun:hover .planet-label {
  opacity: 1;
}

.sun .planet-label {
  bottom: -25px;
  font-size: 12px;
}

/* Mercury */
.mercury-orbit {
  width: 140px;
  height: 140px;
  animation: orbit 8s linear infinite;
}

.mercury {
  width: 12px;
  height: 12px;
}

/* Venus */
.venus-orbit {
  width: 200px;
  height: 200px;
  animation: orbit 15s linear infinite;
}

.venus {
  width: 18px;
  height: 18px;
}

/* Earth */
.earth-orbit {
  width: 270px;
  height: 270px;
  animation: orbit 20s linear infinite;
}

.earth {
  width: 20px;
  height: 20px;
  position: relative;
}

/* Moon orbit around Earth */
.moon-orbit {
  position: absolute;
  width: 50px;
  height: 50px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  /* Counter-rotate to orbit independently of Earth's position */
  animation: orbitMoon 2s linear infinite;
  pointer-events: none;
}

@keyframes orbitMoon {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

.moon {
  position: absolute;
  width: 8px;
  height: 8px;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
}

.moon img {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 5px rgba(200, 200, 200, 0.5));
  pointer-events: none;
}

/* Mars */
.mars-orbit {
  width: 350px;
  height: 350px;
  animation: orbit 30s linear infinite;
}

.mars {
  width: 16px;
  height: 16px;
}

/* Jupiter */
.jupiter-orbit {
  width: 480px;
  height: 480px;
  animation: orbit 60s linear infinite;
}

.jupiter {
  width: 45px;
  height: 45px;
}

/* Saturn */
.saturn-orbit {
  width: 600px;
  height: 600px;
  animation: orbit 80s linear infinite;
}

.saturn {
  width: 40px;
  height: 40px;
}

/* Uranus */
.uranus-orbit {
  width: 700px;
  height: 700px;
  animation: orbit 100s linear infinite;
}

.uranus {
  width: 28px;
  height: 28px;
}

/* Neptune */
.neptune-orbit {
  width: 800px;
  height: 800px;
  animation: orbit 120s linear infinite;
}

.neptune {
  width: 26px;
  height: 26px;
}

/* Orbit animation */
@keyframes orbit {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Info panel */
.info-panel {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  padding: 15px 30px;
  color: white;
  text-align: center;
  backdrop-filter: blur(10px);
  z-index: 10;
}

.info-panel h2 {
  font-size: 20px;
  margin-bottom: 5px;
  color: #ffd700;
}

.info-panel p {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.8);
  margin: 0;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  .sun {
    width: 50px;
    height: 50px;
  }

  .planet {
    top: -10px;
  }

  .mercury-orbit {
    width: 90px;
    height: 90px;
  }

  .venus-orbit {
    width: 130px;
    height: 130px;
  }

  .earth-orbit {
    width: 170px;
    height: 170px;
  }

  .mars-orbit {
    width: 220px;
    height: 220px;
  }

  .jupiter-orbit {
    width: 300px;
    height: 300px;
  }

  .saturn-orbit {
    width: 370px;
    height: 370px;
  }

  .uranus-orbit {
    width: 430px;
    height: 430px;
  }

  .neptune-orbit {
    width: 490px;
    height: 490px;
  }

  .mercury { width: 8px; height: 8px; }
  .venus { width: 12px; height: 12px; }
  .earth { width: 14px; height: 14px; }
  .mars { width: 11px; height: 11px; }
  .jupiter { width: 30px; height: 30px; }
  .saturn { width: 28px; height: 28px; }
  .uranus { width: 20px; height: 20px; }
  .neptune { width: 18px; height: 18px; }

  .moon-orbit {
    width: 35px;
    height: 35px;
  }

  .moon {
    width: 5px;
    height: 5px;
  }

  .back-button {
    top: 10px;
    left: 10px;
  }

  .back-button a {
    font-size: 14px;
    padding: 8px 15px;
  }

  .info-panel {
    bottom: 10px;
    padding: 10px 20px;
  }

  .info-panel h2 {
    font-size: 16px;
  }

  .info-panel p {
    font-size: 12px;
  }

  .planet-label {
    font-size: 8px;
    bottom: -15px;
  }
}

@media (max-width: 480px) {
  .sun {
    width: 40px;
    height: 40px;
  }

  .planet {
    top: -8px;
  }

  .mercury-orbit { width: 70px; height: 70px; }
  .venus-orbit { width: 100px; height: 100px; }
  .earth-orbit { width: 130px; height: 130px; }
  .mars-orbit { width: 165px; height: 165px; }
  .jupiter-orbit { width: 220px; height: 220px; }
  .saturn-orbit { width: 270px; height: 270px; }
  .uranus-orbit { width: 310px; height: 310px; }
  .neptune-orbit { width: 350px; height: 350px; }

  .mercury { width: 6px; height: 6px; }
  .venus { width: 10px; height: 10px; }
  .earth { width: 11px; height: 11px; }
  .mars { width: 9px; height: 9px; }
  .jupiter { width: 22px; height: 22px; }
  .saturn { width: 20px; height: 20px; }
  .uranus { width: 15px; height: 15px; }
  .neptune { width: 14px; height: 14px; }

  .moon-orbit {
    width: 28px;
    height: 28px;
  }

  .moon {
    width: 4px;
    height: 4px;
  }

  .info-panel {
    padding: 8px 15px;
  }

  .info-panel h2 {
    font-size: 14px;
  }

  .info-panel p {
    font-size: 11px;
  }
}