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

body {
  overflow: hidden;
  background: #000;
  font-family: 'Space Mono', monospace;
  color: #c8b88a;
  cursor: none;
}

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

#scene-container canvas {
  display: block;
}

/* Welcome Screen */
#welcome-screen {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 1000;
  background: radial-gradient(ellipse at center, #0a0a1a 0%, #000000 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 1.5s ease;
}

#welcome-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

#welcome-content {
  text-align: center;
  max-width: 680px;
  padding: 40px;
  position: relative;
}

#welcome-glow {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(199,163,86,0.06) 0%, transparent 70%);
  pointer-events: none;
  animation: pulseGlow 4s ease-in-out infinite;
}

@keyframes pulseGlow {
  0%, 100% { opacity: 0.5; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
}

#welcome-title {
  font-family: 'Playfair Display', serif;
  font-weight: 900;
  font-size: 3.5rem;
  letter-spacing: 0.15em;
  color: #d4af37;
  text-shadow: 0 0 40px rgba(212,175,55,0.3), 0 0 80px rgba(212,175,55,0.1);
  margin-bottom: 24px;
  line-height: 1.15;
  animation: titleFade 2s ease-out;
}

@keyframes titleFade {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

#welcome-subtitle {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 1.1rem;
  color: #8a7a5a;
  margin-bottom: 28px;
  line-height: 1.6;
  animation: titleFade 2.5s ease-out;
}

#welcome-flavor {
  font-family: 'Space Mono', monospace;
  font-size: 0.75rem;
  color: #5a5040;
  line-height: 1.8;
  margin-bottom: 40px;
  animation: titleFade 3s ease-out;
}

#enter-btn {
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  background: transparent;
  color: #d4af37;
  border: 1px solid rgba(212,175,55,0.4);
  padding: 16px 48px;
  cursor: pointer;
  transition: all 0.4s ease;
  animation: titleFade 3.5s ease-out, btnPulse 3s ease-in-out infinite;
}

@keyframes btnPulse {
  0%, 100% { border-color: rgba(212,175,55,0.4); box-shadow: 0 0 20px rgba(212,175,55,0); }
  50% { border-color: rgba(212,175,55,0.8); box-shadow: 0 0 30px rgba(212,175,55,0.15); }
}

#enter-btn:hover {
  background: rgba(212,175,55,0.1);
  box-shadow: 0 0 40px rgba(212,175,55,0.2);
  border-color: #d4af37;
}

#welcome-footer {
  margin-top: 60px;
  animation: titleFade 4s ease-out;
}

#welcome-footer a {
  color: #3a3020;
  font-size: 0.7rem;
  text-decoration: none;
  transition: color 0.3s;
}

#welcome-footer a:hover { color: #8a7a5a; }

/* HUD */
#hud {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 100;
  pointer-events: none;
}

#hud > * { pointer-events: auto; }

#chamber-coords {
  position: absolute;
  top: 20px; left: 24px;
  font-family: 'Space Mono', monospace;
  font-size: 0.8rem;
  color: rgba(212,175,55,0.7);
  text-shadow: 0 0 10px rgba(212,175,55,0.3);
  pointer-events: none;
}

#crosshair {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 30px; height: 30px;
  pointer-events: none;
}

.cross-h, .cross-v {
  position: absolute;
  background: rgba(212,175,55,0.5);
  box-shadow: 0 0 6px rgba(212,175,55,0.3);
}

.cross-h {
  width: 20px; height: 1px;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}

.cross-v {
  width: 1px; height: 20px;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}

#orb-info {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(24px, -50%);
  font-size: 0.65rem;
  color: rgba(100,220,255,0.8);
  text-shadow: 0 0 8px rgba(100,220,255,0.4);
  pointer-events: none;
  white-space: nowrap;
}

#controls-hint {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.65rem;
  color: rgba(200,184,138,0.35);
  background: rgba(0,0,0,0.4);
  padding: 8px 20px;
  border-radius: 4px;
  border: 1px solid rgba(200,184,138,0.08);
  pointer-events: none;
  white-space: nowrap;
}

#discovery-counter {
  position: absolute;
  top: 20px; right: 24px;
  font-size: 0.7rem;
  color: rgba(180,140,255,0.6);
  text-shadow: 0 0 8px rgba(180,140,255,0.3);
  pointer-events: none;
}

#waveform-container {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
}

#waveform-canvas {
  display: block;
}

/* Sound Panel */
#sound-panel {
  position: fixed;
  top: 50%;
  right: 20px;
  transform: translateY(-50%);
  width: 320px;
  background: rgba(10,10,26,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(212,175,55,0.2);
  border-radius: 8px;
  padding: 20px;
  z-index: 200;
  box-shadow: 0 0 40px rgba(0,0,0,0.6), inset 0 0 40px rgba(212,175,55,0.02);
  transition: transform 0.3s ease, opacity 0.3s ease;
}

#sound-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

#panel-seed-label {
  font-family: 'Playfair Display', serif;
  font-size: 0.9rem;
  color: #d4af37;
}

#close-panel-btn {
  background: none;
  border: none;
  color: rgba(200,184,138,0.5);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 8px;
}

#close-panel-btn:hover { color: #d4af37; }

#panel-seed-value {
  font-family: 'Space Mono', monospace;
  font-size: 0.6rem;
  color: rgba(100,220,255,0.7);
  word-break: break-all;
  margin-bottom: 16px;
  padding: 6px 10px;
  background: rgba(0,0,0,0.3);
  border-radius: 4px;
  border: 1px solid rgba(100,220,255,0.1);
}

#panel-oscilloscope, #panel-spectrum {
  display: block;
  width: 100%;
  margin-bottom: 12px;
  border-radius: 4px;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(212,175,55,0.08);
}

#sound-properties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.prop {
  display: flex;
  flex-direction: column;
}

.prop-label {
  font-size: 0.55rem;
  color: rgba(200,184,138,0.4);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 2px;
}

.prop-val {
  font-size: 0.75rem;
  color: rgba(212,175,55,0.8);
}

#panel-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.panel-btn {
  font-family: 'Space Mono', monospace;
  font-size: 0.65rem;
  background: rgba(212,175,55,0.08);
  border: 1px solid rgba(212,175,55,0.2);
  color: #c8b88a;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.panel-btn:hover {
  background: rgba(212,175,55,0.15);
  border-color: rgba(212,175,55,0.4);
}

.panel-btn.playing {
  background: rgba(212,175,55,0.2);
  border-color: #d4af37;
  color: #d4af37;
}

#share-output {
  margin-top: 8px;
  font-size: 0.6rem;
  color: rgba(100,220,255,0.7);
  word-break: break-all;
  padding: 6px;
  background: rgba(0,0,0,0.3);
  border-radius: 4px;
}

/* Nav Panel */
#nav-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 400px;
  max-height: 80vh;
  overflow-y: auto;
  background: rgba(10,10,26,0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(212,175,55,0.2);
  border-radius: 8px;
  padding: 24px;
  z-index: 300;
  box-shadow: 0 0 60px rgba(0,0,0,0.8);
}

#nav-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem;
  color: #d4af37;
  margin-bottom: 20px;
  text-align: center;
}

#nav-section label, #saved-section label {
  display: block;
  font-size: 0.65rem;
  color: rgba(200,184,138,0.5);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 8px;
}

.nav-input-row {
  display: flex;
  gap: 6px;
}

.nav-input-row input {
  flex: 1;
  font-family: 'Space Mono', monospace;
  font-size: 0.7rem;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(212,175,55,0.15);
  color: #c8b88a;
  padding: 8px;
  border-radius: 4px;
  outline: none;
  width: 60px;
}

.nav-input-row input:focus {
  border-color: rgba(212,175,55,0.4);
}

.nav-input-row button {
  font-family: 'Space Mono', monospace;
  font-size: 0.65rem;
  background: rgba(212,175,55,0.15);
  border: 1px solid rgba(212,175,55,0.3);
  color: #d4af37;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
}

.nav-input-row button:hover {
  background: rgba(212,175,55,0.25);
}

#saved-section {
  margin-top: 20px;
  border-top: 1px solid rgba(212,175,55,0.1);
  padding-top: 16px;
}

#saved-list {
  max-height: 200px;
  overflow-y: auto;
}

.saved-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  margin-bottom: 4px;
  background: rgba(0,0,0,0.3);
  border-radius: 4px;
  border: 1px solid rgba(212,175,55,0.06);
  cursor: pointer;
  transition: background 0.2s;
}

.saved-item:hover {
  background: rgba(212,175,55,0.08);
}

.saved-item-seed {
  font-size: 0.55rem;
  color: rgba(100,220,255,0.6);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}

.saved-item-chamber {
  font-size: 0.5rem;
  color: rgba(200,184,138,0.3);
}

.saved-item-delete {
  background: none;
  border: none;
  color: rgba(255,100,100,0.4);
  cursor: pointer;
  font-size: 0.7rem;
  padding: 2px 6px;
}

.saved-item-delete:hover { color: rgba(255,100,100,0.8); }

#stats-section {
  margin-top: 16px;
  border-top: 1px solid rgba(212,175,55,0.1);
  padding-top: 12px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  color: rgba(200,184,138,0.4);
  margin-bottom: 4px;
}

.stat-row span:last-child {
  color: rgba(212,175,55,0.7);
}

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(212,175,55,0.2); border-radius: 2px; }

@media (max-width: 600px) {
  #welcome-title { font-size: 2rem; }
  #welcome-subtitle { font-size: 0.9rem; }
  #sound-panel { width: 260px; right: 10px; }
  #nav-panel { width: 90%; }
  #controls-hint { font-size: 0.5rem; padding: 6px 12px; }
}