:root {
  --bg-deep-space: #0a0a1a;
  --visor-blue: #00d4ff;
  --visor-gold: #ffd700;
  --visor-red: #ff4444;
  --visor-purple: #9b59b6;
  --helmet-silver: #c0c0c0;
  --helmet-dark: #404050;
}

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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep-space);
  font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, sans-serif;
}

#app {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #1a1a2e 0%, #0a0a1a 70%);
  position: relative;
}

/* Starfield background effect */
#app::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(2px 2px at 20px 30px, white, transparent),
    radial-gradient(2px 2px at 40px 70px, rgba(255, 255, 255, 0.8), transparent),
    radial-gradient(1px 1px at 90px 40px, white, transparent),
    radial-gradient(2px 2px at 130px 80px, rgba(255, 255, 255, 0.6), transparent),
    radial-gradient(1px 1px at 160px 120px, white, transparent);
  background-size: 200px 200px;
  animation: twinkle 4s ease-in-out infinite alternate;
  opacity: 0.5;
  pointer-events: none;
}

@keyframes twinkle {
  0% {
    opacity: 0.3;
  }

  100% {
    opacity: 0.6;
  }
}

#avatar-canvas {
  max-width: 90vmin;
  max-height: 90vmin;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Control bar with listen toggle */
#control-bar {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
  padding: 8px 16px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

#listen-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 16px;
  transition: all 0.3s ease;
  color: #888;
}

#listen-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
}

#listen-toggle svg {
  width: 20px;
  height: 20px;
}

#listen-toggle .mic-off {
  display: none;
}

#listen-toggle .label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Listening state - mic active */
#listen-toggle.listening {
  color: #4ade80;
}

#listen-toggle.listening .mic-on {
  display: block;
  animation: pulse 1.5s ease-in-out infinite;
}

#listen-toggle.listening .mic-off {
  display: none;
}

/* Muted state - mic off */
#listen-toggle.muted {
  color: #f87171;
}

#listen-toggle.muted .mic-on {
  display: none;
}

#listen-toggle.muted .mic-off {
  display: block;
}

/* Speaking state */
#listen-toggle.speaking {
  color: #60a5fa;
}

#listen-toggle.speaking .mic-on {
  animation: pulse 0.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

#status-text {
  color: #888;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  min-width: 80px;
}

/* Debug panel - toggle with 'D' key */
#debug-panel {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 90%;
  padding: 12px;
  background: rgba(0, 0, 0, 0.8);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 100;
}

#debug-panel.hidden {
  display: none;
}

#debug-panel button {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
}

#debug-panel button:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: var(--visor-blue);
}

#debug-panel button:active {
  transform: scale(0.95);
}

/* Responsive */
@media (max-width: 600px) {
  #debug-panel button {
    padding: 6px 12px;
    font-size: 11px;
  }
}

/* Activation overlay - click to unlock audio */
#activation-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 26, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  cursor: pointer;
}

#activation-overlay .overlay-content {
  text-align: center;
  color: var(--visor-blue);
}

#activation-overlay .mic-container {
  position: relative;
  width: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
}

#activation-overlay .mic-icon {
  width: 48px;
  height: 48px;
  color: var(--visor-blue);
  position: relative;
  z-index: 2;
}

#activation-overlay p {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 4px;
  opacity: 0.7;
  font-weight: 300;
}

#activation-overlay .pulse-ring {
  position: absolute;
  inset: 0;
  border: 1px solid var(--visor-blue);
  border-radius: 50%;
  animation: pulse-ring 2s ease-out infinite;
  z-index: 1;
}

@keyframes pulse-ring {
  0% {
    transform: scale(0.8);
    opacity: 1;
  }

  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

@keyframes bounce {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-10px);
  }
}

/* 3D Flip Animation */
.avatar-flipper {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.avatar-flipper.flipped {
  transform: rotateY(180deg);
}

.avatar-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-front {
  z-index: 2;
}

.avatar-back {
  transform: rotateY(180deg);
  background: var(--bg-deep-space);
  z-index: 1;
}

/* Media Screen (Back Face) */
.media-screen {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 20px;
  color: var(--visor-blue);
}

.media-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(0, 212, 255, 0.2);
}

.flip-back-btn {
  background: rgba(0, 212, 255, 0.1);
  border: 1px solid rgba(0, 212, 255, 0.3);
  color: var(--visor-blue);
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
}

.flip-back-btn:hover {
  background: rgba(0, 212, 255, 0.2);
}

.file-count {
  font-size: 12px;
  opacity: 0.7;
}

.media-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin: 16px 0;
}

.media-placeholder {
  text-align: center;
  opacity: 0.5;
}

.placeholder-icon {
  font-size: 48px;
  display: block;
  margin-bottom: 8px;
}

.media-image,
.media-video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
}

.media-caption {
  font-size: 12px;
  opacity: 0.7;
  margin-top: 8px;
  text-align: center;
}

.media-title {
  font-size: 14px;
  margin-bottom: 12px;
  color: var(--visor-gold);
}

.media-text {
  font-size: 11px;
  font-family: monospace;
  background: rgba(0, 0, 0, 0.5);
  padding: 12px;
  border-radius: 8px;
  max-height: 200px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.media-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(0, 212, 255, 0.2);
}

.media-nav button {
  background: rgba(0, 212, 255, 0.1);
  border: 1px solid rgba(0, 212, 255, 0.3);
  color: var(--visor-blue);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s;
}

.media-nav button:hover:not(:disabled) {
  background: rgba(0, 212, 255, 0.2);
}

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

.nav-index {
  font-size: 12px;
  opacity: 0.7;
}

/* File Drop Zone */
.file-drop-zone {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 212, 255, 0);
  pointer-events: none;
  z-index: 50;
  opacity: 0;
  transition: all 0.3s;
}

.file-drop-zone.active {
  opacity: 1;
  background: rgba(0, 212, 255, 0.1);
}

.drop-ring {
  width: 150px;
  height: 150px;
  border: 3px dashed var(--visor-blue);
  border-radius: 50%;
  animation: drop-pulse 1s ease-in-out infinite;
}

.drop-text {
  position: absolute;
  bottom: 30%;
  color: var(--visor-blue);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 3px;
  animation: bounce 1s infinite;
}

@keyframes drop-pulse {

  0%,
  100% {
    transform: scale(1);
    opacity: 0.5;
  }

  50% {
    transform: scale(1.1);
    opacity: 1;
  }
}