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

body {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  overflow: hidden;
  background: linear-gradient(135deg, #0a0a15 0%, #151525 50%, #0a0a15 100%);
  color: #fff;
}

#scene-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

#webcam {
  display: none;
}

#webcam-canvas {
  display: none;
}

#webcam-preview {
  position: fixed;
  bottom: 80px;
  left: 20px;
  width: 200px;
  height: 150px;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
  transition: all 0.3s ease;
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.3);
}

#webcam-preview.hidden {
  opacity: 0;
  transform: scale(0.8);
  pointer-events: none;
}

#preview-canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#toggle-webcam {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  backdrop-filter: blur(10px);
  transition: background 0.2s;
}

#toggle-webcam:hover {
  background: rgba(255, 255, 255, 0.2);
}

#hand-indicator-left,
#hand-indicator-right {
  position: absolute;
  width: 16px;
  height: 16px;
  background: radial-gradient(circle, #8b5cf6 0%, transparent 70%);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

#template-panel {
  position: fixed;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.template-btn {
  width: 52px;
  height: 52px;
  border: 2px solid transparent;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  font-size: 24px;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.template-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(1.1);
}

.template-btn.active {
  border-color: #8b5cf6;
  background: rgba(139, 92, 246, 0.2);
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.5);
}

#gesture-indicator {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
}

#left-hand-orb,
#right-hand-orb {
  position: absolute;
  width: 60px;
  height: 60px;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.8) 0%, rgba(139, 92, 246, 0.2) 50%, transparent 70%);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.2s;
  box-shadow: 0 0 40px rgba(139, 92, 246, 0.6);
}

#connection-line {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

#energy-beam {
  stroke: url(#beam-gradient);
  stroke: rgba(139, 92, 246, 0.6);
  stroke-width: 4;
  opacity: 0;
  transition: opacity 0.2s;
  filter: drop-shadow(0 0 10px rgba(139, 92, 246, 0.8));
}

#distance-meter {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 200px;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
  z-index: 100;
}

#distance-fill {
  height: 100%;
  width: 50%;
  background: linear-gradient(90deg, #6366f1, #8b5cf6, #a855f7);
  border-radius: 4px;
  transition: width 0.1s ease-out;
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.5);
}

#instructions-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

#instructions-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

#instructions-content {
  text-align: center;
  max-width: 400px;
  padding: 40px;
}

#instructions-content h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 30px;
  background: linear-gradient(135deg, #8b5cf6, #a855f7, #ec4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.gesture-demo {
  font-size: 3rem;
  margin: 30px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.hand-icon {
  animation: pulse 1.5s ease-in-out infinite;
}

.hand-icon:first-child {
  animation-delay: 0s;
}

.hand-icon:last-child {
  animation-delay: 0.5s;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

#instructions-content p {
  font-size: 1.1rem;
  color: rgba(255, 255, 255, 0.8);
  margin: 10px 0;
  font-weight: 300;
}

#instructions-content strong {
  color: #a855f7;
  font-weight: 600;
}

#start-btn {
  margin-top: 30px;
  padding: 14px 36px;
  font-size: 1.1rem;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  background: linear-gradient(135deg, #8b5cf6, #a855f7);
  color: white;
  border: none;
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4);
}

#start-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 30px rgba(139, 92, 246, 0.6);
}

#control-bar {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  z-index: 100;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.control-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.control-group label {
  font-size: 0.85rem;
  font-weight: 300;
  color: rgba(255, 255, 255, 0.7);
  white-space: nowrap;
}

.control-group input[type="range"] {
  width: 80px;
  height: 4px;
  -webkit-appearance: none;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  outline: none;
}

.control-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: #8b5cf6;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.5);
}

.control-group span {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.5);
  min-width: 35px;
}

#control-bar button {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

#control-bar button:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

#footer {
  position: fixed;
  bottom: 8px;
  right: 20px;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.3);
  z-index: 100;
}

#footer a {
  color: rgba(139, 92, 246, 0.6);
  text-decoration: none;
  transition: color 0.2s;
}

#footer a:hover {
  color: #8b5cf6;
}

/* Mobile responsive */
@media (max-width: 768px) {
  #template-panel {
    right: 10px;
    padding: 8px;
    gap: 6px;
  }
  
  .template-btn {
    width: 44px;
    height: 44px;
    font-size: 20px;
  }
  
  #webcam-preview {
    width: 150px;
    height: 112px;
    bottom: 100px;
    left: 10px;
  }
  
  #control-bar {
    padding: 10px 16px;
    gap: 12px;
    flex-wrap: wrap;
    max-width: 90%;
  }
  
  .control-group {
    gap: 6px;
  }
  
  .control-group input[type="range"] {
    width: 60px;
  }
  
  .control-group label {
    font-size: 0.75rem;
  }
  
  #distance-meter {
    width: 150px;
  }
  
  #instructions-content {
    padding: 30px 20px;
  }
  
  #instructions-content h1 {
    font-size: 1.5rem;
  }
  
  .gesture-demo {
    font-size: 2.5rem;
  }
}

@media (max-width: 480px) {
  #control-bar {
    padding: 8px 12px;
    gap: 8px;
    bottom: 10px;
  }
  
  .control-group:first-child .control-group span {
    display: none;
  }
  
  #webcam-preview {
    display: none;
  }
}