:root {
  --bg-color: #ecf3f8;
  --text-primary: #0a2540;
  --text-secondary: #2b5b7f;
  --text-dim: #6288a8;
  --accent-cyan: #007bb8;
  --accent-emerald: #008a54;
  --accent-amber: #c46800;
  --accent-violet: #7a22b8;
  --glass-bg: rgba(255, 255, 255, 0.82);
  --glass-border: rgba(0, 120, 180, 0.22);
  --glass-highlight: rgba(255, 255, 255, 0.9);
  --font-sans: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.01em;
}

/* Background Canvas */
#stage {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  z-index: 1;
  background-color: #ecf3f8;
  touch-action: none;
  cursor: crosshair;
}

/* Atmospheric Luminous Vignette */
#vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0) 45%, rgba(185, 210, 230, 0.25) 80%, rgba(140, 180, 210, 0.45) 100%);
  mix-blend-mode: multiply;
}

/* UI Container & Auto-Fade Logic */
#ui-container {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 28px 36px;
  pointer-events: none;
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

#ui-container.idle {
  opacity: 0.18;
  filter: blur(0.5px);
}

#ui-container.idle:hover {
  opacity: 1;
  filter: blur(0);
}

/* Top Header */
#header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.logo-mark {
  color: var(--accent-cyan);
  font-size: 18px;
  filter: drop-shadow(0 0 6px rgba(0, 123, 184, 0.6));
  animation: pulse-glow 3s infinite alternate ease-in-out;
  transition: filter 0.3s ease, transform 0.3s ease;
}

.logo-text {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.22em;
  background: linear-gradient(135deg, #0a2540 0%, #03527e 60%, #007bb8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  transition: all 0.3s ease;
}

/* Hidden Easter Egg: Circling Glow Effect */
.logo-text.glow-active {
  background: linear-gradient(135deg, #ffffff 0%, #a6f2ff 50%, #00f0ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 10px rgba(0, 240, 255, 0.95)) drop-shadow(0 0 24px rgba(0, 180, 255, 0.85)) drop-shadow(0 0 40px rgba(0, 140, 255, 0.6));
  transform: scale(1.05);
}

.brand.glow-active .logo-mark {
  filter: drop-shadow(0 0 16px rgba(0, 240, 255, 1)) drop-shadow(0 0 28px rgba(0, 180, 255, 0.9));
  transform: scale(1.35) rotate(45deg);
}

/* Secondary Hidden Easter Egg: 7 Circles Time-Freeze Effect */
.logo-text.code-frozen {
  background: linear-gradient(135deg, #ffffff 0%, #00f0ff 45%, #0088ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 14px rgba(0, 240, 255, 1)) drop-shadow(0 0 32px rgba(0, 180, 255, 0.9));
  animation: frozen-pulse 1.4s ease-in-out infinite alternate;
}

.brand.code-frozen .logo-mark {
  filter: drop-shadow(0 0 20px rgba(0, 240, 255, 1)) drop-shadow(0 0 36px rgba(0, 180, 255, 0.95));
  animation: frozen-spin 7s cubic-bezier(0.16, 1, 0.3, 1) infinite;
}

@keyframes frozen-pulse {
  0% { transform: scale(1.05); filter: drop-shadow(0 0 10px rgba(0, 240, 255, 0.8)) drop-shadow(0 0 22px rgba(0, 180, 255, 0.6)); }
  100% { transform: scale(1.10); filter: drop-shadow(0 0 18px rgba(0, 240, 255, 1)) drop-shadow(0 0 40px rgba(0, 150, 255, 0.95)); }
}

@keyframes frozen-spin {
  0% { transform: scale(1.4) rotate(0deg); }
  50% { transform: scale(1.55) rotate(180deg); }
  100% { transform: scale(1.4) rotate(360deg); }
}

/* Center Screen Matrix Freeze Revelation */
#center-message {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.92);
  max-width: 640px;
  width: 90%;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 19px;
  line-height: 1.65;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: #033c5e;
  background: rgba(255, 255, 255, 0.88);
  padding: 26px 36px;
  border-radius: 18px;
  border: 1px solid rgba(0, 180, 255, 0.42);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow:
    0 24px 60px rgba(0, 60, 120, 0.16),
    0 0 35px rgba(0, 200, 255, 0.35);
  text-shadow: 0 0 14px rgba(0, 180, 255, 0.4);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.6s, background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
  z-index: 50;
  user-select: none;
}

#center-message.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  cursor: pointer;
  transform: translate(-50%, -50%) scale(1);
}

#center-message.is-active:hover {
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(0, 200, 255, 0.7);
  box-shadow:
    0 30px 70px rgba(0, 80, 160, 0.22),
    0 0 45px rgba(0, 220, 255, 0.55);
  transform: translate(-50%, -50%) scale(1.02);
}

#center-message.is-active:active {
  transform: translate(-50%, -50%) scale(0.99);
}

/* Bottom Controls */
#footer {
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: auto;
  gap: 20px;
}

/* Quick HUD & Borderless Icon Controls */
.quick-hud {
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  padding: 0;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.hud-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 50%;
  padding: 0;
  transition: color 0.2s ease, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), background 0.2s ease;
}

.hud-icon-btn:hover {
  color: var(--text-primary);
  background: rgba(0, 123, 184, 0.08);
  transform: translateY(-2px);
  border: none;
}

.hud-icon-btn:active {
  transform: translateY(0);
}

.hud-icon-btn.active-state {
  color: var(--accent-cyan);
  background: rgba(0, 123, 184, 0.12);
  filter: drop-shadow(0 0 8px rgba(0, 180, 255, 0.4));
  border: none;
}

/* Audio Toggle States */
.hud-icon-btn .icon-audio-on {
  display: none;
}

.hud-icon-btn .icon-audio-muted {
  display: block;
}

.hud-icon-btn.audio-playing .icon-audio-on {
  display: block;
}

.hud-icon-btn.audio-playing .icon-audio-muted {
  display: none;
}

.hud-icon-btn.audio-playing .audio-wave {
  animation: sound-wave 1.2s ease-in-out infinite alternate;
}

/* Fullscreen Toggle States */
.hud-icon-btn .icon-fs-enter {
  display: block;
}

.hud-icon-btn .icon-fs-exit {
  display: none;
}

.hud-icon-btn.is-fullscreen .icon-fs-enter {
  display: none;
}

.hud-icon-btn.is-fullscreen .icon-fs-exit {
  display: block;
}

/* Animations */
@keyframes pulse-glow {
  0% { transform: scale(1); filter: drop-shadow(0 0 4px rgba(0, 123, 184, 0.5)); }
  100% { transform: scale(1.15); filter: drop-shadow(0 0 10px rgba(0, 123, 184, 0.8)); }
}

@keyframes sound-wave {
  0% { opacity: 0.2; }
  100% { opacity: 1; }
}

/* Mobile & Tablet Responsiveness */
@media (max-width: 900px) {
  #ui-container {
    padding: 18px;
  }

  #header {
    justify-content: flex-start;
  }

  #footer {
    width: 100%;
  }

  .quick-hud {
    justify-content: center;
    gap: 16px;
  }
}
