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

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  background: #0a0a12;
  color: white;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#app {
  width: 100vw;
  height: 100vh;
  position: relative;
}

#canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Overlays */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 18, 0.95);
  z-index: 100;
  transition: opacity 0.3s ease;
}

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

.loading-content {
  text-align: center;
  color: #f5f5f5;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Info overlay */
#info {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 10;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
}

#info h1 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
  color: white;
}

#info p {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
}

/* Controls hint */
#controls-hint {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 16px;
  font-size: 12px;
  opacity: 0.5;
  z-index: 10;
}

#controls-hint span {
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border-radius: 20px;
}

/* Media panel */
.panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(20, 20, 28, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 20px;
  max-width: 90vw;
  max-height: 85vh;
  z-index: 200;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.panel.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.95);
}

.close-btn {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: white;
  font-size: 20px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.close-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

#media-container {
  max-width: 70vw;
  max-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

#media-container img,
#media-container video {
  max-width: 100%;
  max-height: 60vh;
  border-radius: 12px;
  object-fit: contain;
}

#media-info {
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
}

#cluster-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

#cluster-nav.hidden {
  display: none;
}

.nav-btn {
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: white;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s ease;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Panel backdrop */
#panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 150;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

#panel-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

/* Responsive */
@media (max-width: 768px) {
  #info h1 {
    font-size: 20px;
  }

  #controls-hint {
    flex-direction: column;
    align-items: center;
    gap: 8px;
  }

  .panel {
    padding: 16px;
    border-radius: 16px;
  }

  #media-container {
    max-width: 85vw;
  }
}
