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

body {
  overflow: hidden;
  background: #030712;
  color: #F9FAFB;
  font-family: 'Inter', system-ui, sans-serif;
  cursor: none;
}

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

#scene-container canvas {
  display: block;
}

.hidden { display: none !important; }

/* Custom Cursor */
#crosshair {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
  pointer-events: none;
}
#crosshair .crosshair-h,
#crosshair .crosshair-v {
  position: absolute;
  background: rgba(255,255,255,0.7);
}
#crosshair .crosshair-h {
  width: 16px; height: 1px;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}
#crosshair .crosshair-v {
  width: 1px; height: 16px;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}

/* Welcome Overlay */
#welcome-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #030712;
  transition: opacity 1.5s ease;
}
#welcome-overlay.dissolving {
  opacity: 0;
  pointer-events: none;
}
#starfield-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
}
#welcome-content {
  position: relative;
  z-index: 2;
  text-align: center;
  animation: fadeInUp 2s ease forwards;
}
#welcome-title {
  font-family: 'Inter', sans-serif;
  font-weight: 100;
  font-size: clamp(2.5rem, 8vw, 6rem);
  letter-spacing: 0.5em;
  color: #3B82F6;
  text-shadow: 0 0 40px rgba(59,130,246,0.5), 0 0 80px rgba(59,130,246,0.2);
  animation: glowPulse 3s ease-in-out infinite;
  margin-bottom: 0.5em;
}
#welcome-subtitle {
  font-weight: 200;
  font-size: clamp(0.8rem, 2vw, 1.2rem);
  color: #9CA3AF;
  letter-spacing: 0.3em;
  margin-bottom: 2em;
}
#welcome-instruction {
  font-weight: 300;
  font-size: clamp(0.75rem, 1.5vw, 1rem);
  color: #67E8F9;
  margin-bottom: 2.5em;
  animation: pulseText 2s ease-in-out infinite;
}
#begin-btn {
  background: none;
  border: none;
  cursor: pointer;
  transition: transform 0.3s ease, filter 0.3s ease;
}
#begin-btn:hover {
  transform: scale(1.1);
  filter: drop-shadow(0 0 20px rgba(59,130,246,0.6));
}
#begin-btn svg polygon {
  transition: stroke 0.3s, fill 0.3s;
}
#begin-btn:hover svg polygon {
  stroke: #60A5FA;
  fill: rgba(59,130,246,0.08);
}

/* Command Halo Collapsed */
#command-halo-collapsed {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
#halo-dot {
  width: 10px; height: 10px;
  background: #3B82F6;
  border-radius: 50%;
  box-shadow: 0 0 12px #3B82F6, 0 0 24px rgba(59,130,246,0.4);
  animation: dotPulse 2s ease-in-out infinite;
}
#halo-hint {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: #9CA3AF;
  letter-spacing: 0.1em;
}

/* Command Halo Active */
#command-halo {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
#halo-ring {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 400px; height: 400px;
  border-radius: 50%;
  border: 1px solid rgba(59,130,246,0.4);
  box-shadow: 0 0 40px rgba(59,130,246,0.15), inset 0 0 40px rgba(59,130,246,0.05);
  animation: ringRotate 20s linear infinite;
  pointer-events: none;
}
#halo-ring::after {
  content: '';
  position: absolute;
  top: -2px; left: -2px;
  right: -2px; bottom: -2px;
  border-radius: 50%;
  border: 1px solid transparent;
  border-top-color: #60A5FA;
  animation: ringRotate 8s linear infinite reverse;
}
#prompt-input {
  background: rgba(3,7,18,0.7);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(59,130,246,0.3);
  border-radius: 12px;
  padding: 16px 24px;
  width: 340px;
  max-width: 90vw;
  color: #F9FAFB;
  font-family: 'Inter', sans-serif;
  font-weight: 300;
  font-size: 1rem;
  resize: none;
  outline: none;
  text-align: center;
  text-shadow: 0 0 8px rgba(59,130,246,0.3);
  transition: border-color 0.3s;
  z-index: 1;
}
#prompt-input::placeholder {
  color: #4B5563;
}
#prompt-input:focus {
  border-color: rgba(59,130,246,0.6);
  box-shadow: 0 0 20px rgba(59,130,246,0.15);
}
#prompt-templates {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  max-width: 500px;
  z-index: 1;
}
.template-btn {
  background: rgba(3,7,18,0.6);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(59,130,246,0.2);
  border-radius: 20px;
  padding: 6px 14px;
  color: #9CA3AF;
  font-family: 'Inter', sans-serif;
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.3s;
}
.template-btn:hover {
  border-color: #3B82F6;
  color: #F9FAFB;
  box-shadow: 0 0 10px rgba(59,130,246,0.2);
}

/* Halo flash animation */
@keyframes haloFlash {
  0% { box-shadow: 0 0 40px rgba(59,130,246,0.15); transform: translate(-50%,-50%) scale(1); }
  50% { box-shadow: 0 0 120px rgba(59,130,246,0.6); transform: translate(-50%,-50%) scale(1.3); }
  100% { box-shadow: 0 0 0px rgba(59,130,246,0); transform: translate(-50%,-50%) scale(2); opacity: 0; }
}

/* Weave Manifest */
#weave-manifest {
  position: fixed;
  top: 16px; right: 16px;
  z-index: 100;
  background: rgba(0,10,30,0.7);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(59,130,246,0.25);
  border-radius: 8px;
  padding: 14px 18px;
  min-width: 220px;
  transition: opacity 0.5s ease;
}
#weave-manifest.faded { opacity: 0.15; }
#manifest-header {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6rem;
  color: #3B82F6;
  letter-spacing: 0.2em;
  margin-bottom: 10px;
  text-shadow: 0 0 10px rgba(59,130,246,0.3);
}
.manifest-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
}
.manifest-label {
  color: #6B7280;
  letter-spacing: 0.1em;
}
.manifest-row span:last-child {
  color: #67E8F9;
  text-shadow: 0 0 6px rgba(103,232,249,0.3);
}
.manifest-row.warning span:last-child {
  color: #FBBF24;
  text-shadow: 0 0 6px rgba(251,191,36,0.4);
}

/* Compass */
#compass-widget {
  position: fixed;
  bottom: 20px; left: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
}
#compass-canvas {
  width: 80px; height: 80px;
}
#compass-info {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6rem;
  color: #9CA3AF;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
#compass-heading {
  color: #3B82F6;
  font-weight: 700;
  text-shadow: 0 0 8px rgba(59,130,246,0.4);
}

/* Sound Toggle */
#sound-toggle {
  position: fixed;
  top: 16px; left: 16px;
  z-index: 100;
  background: rgba(0,10,30,0.5);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(59,130,246,0.2);
  border-radius: 6px;
  padding: 8px;
  cursor: pointer;
  transition: border-color 0.3s;
}
#sound-toggle:hover {
  border-color: #3B82F6;
}

/* Screenshot */
#screenshot-btn {
  position: fixed;
  top: 16px; left: 56px;
  z-index: 100;
  background: rgba(0,10,30,0.5);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(59,130,246,0.2);
  border-radius: 6px;
  padding: 8px;
  cursor: pointer;
  transition: border-color 0.3s;
}
#screenshot-btn:hover {
  border-color: #3B82F6;
}

/* History */
#history-tab {
  position: fixed;
  top: 50%; left: 0;
  transform: translateY(-50%);
  z-index: 100;
  background: rgba(0,10,30,0.6);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(59,130,246,0.2);
  border-left: none;
  border-radius: 0 6px 6px 0;
  padding: 10px 8px;
  cursor: pointer;
  transition: background 0.3s;
}
#history-tab:hover {
  background: rgba(59,130,246,0.15);
}
#history-sidebar {
  position: fixed;
  top: 0; left: 0;
  width: 280px; height: 100%;
  z-index: 150;
  background: rgba(0,10,30,0.85);
  backdrop-filter: blur(16px);
  border-right: 1px solid rgba(59,130,246,0.2);
  padding: 20px;
  overflow-y: auto;
}
#history-header {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  color: #3B82F6;
  letter-spacing: 0.2em;
  margin-bottom: 16px;
  text-shadow: 0 0 10px rgba(59,130,246,0.3);
}
.history-entry {
  background: rgba(59,130,246,0.05);
  border: 1px solid rgba(59,130,246,0.15);
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.3s;
}
.history-entry:hover {
  border-color: #3B82F6;
  background: rgba(59,130,246,0.1);
}
.history-prompt {
  font-size: 0.75rem;
  color: #D1D5DB;
  margin-bottom: 4px;
  line-height: 1.4;
}
.history-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.55rem;
  color: #6B7280;
}
.history-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

/* Object Tooltip */
#object-tooltip {
  position: fixed;
  z-index: 500;
  background: rgba(0,10,30,0.8);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(59,130,246,0.3);
  border-radius: 4px;
  padding: 4px 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6rem;
  color: #67E8F9;
  pointer-events: none;
  text-shadow: 0 0 6px rgba(103,232,249,0.3);
}

/* Controls Hint */
#controls-hint {
  position: fixed;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6rem;
  color: #6B7280;
  letter-spacing: 0.05em;
  text-align: center;
  pointer-events: none;
}

/* Footer */
#footer {
  position: fixed;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.5rem;
  color: #374151;
  white-space: nowrap;
}
#footer a {
  color: #4B5563;
  text-decoration: none;
}
#footer a:hover {
  color: #3B82F6;
}

/* Keyframes */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes glowPulse {
  0%, 100% { text-shadow: 0 0 40px rgba(59,130,246,0.5), 0 0 80px rgba(59,130,246,0.2); }
  50% { text-shadow: 0 0 60px rgba(59,130,246,0.7), 0 0 120px rgba(59,130,246,0.3); }
}
@keyframes pulseText {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
@keyframes dotPulse {
  0%, 100% { box-shadow: 0 0 12px #3B82F6, 0 0 24px rgba(59,130,246,0.4); transform: scale(1); }
  50% { box-shadow: 0 0 20px #60A5FA, 0 0 40px rgba(59,130,246,0.6); transform: scale(1.3); }
}
@keyframes ringRotate {
  from { transform: translate(-50%,-50%) rotate(0deg); }
  to { transform: translate(-50%,-50%) rotate(360deg); }
}

/* Mobile */
@media (max-width: 768px) {
  #command-halo {
    top: auto;
    bottom: 0;
    left: 0;
    transform: none;
    width: 100%;
    padding: 20px;
    background: rgba(3,7,18,0.9);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(59,130,246,0.2);
    border-radius: 16px 16px 0 0;
  }
  #halo-ring { display: none; }
  #prompt-input { width: 100%; }
  #prompt-templates { max-width: 100%; }
  #compass-widget { transform: scale(0.75); transform-origin: bottom left; }
  #weave-manifest { font-size: 0.55rem; min-width: 160px; }
  #history-sidebar { width: 100%; }
  #welcome-title { letter-spacing: 0.25em; }
}