:root {
  --bg-deep: #0a0510;
  --bg-mid: #120a1f;
  --purple-neon: #b347e0;
  --magenta: #ff2d95;
  --cyan: #00f0ff;
  --gold: #ffd700;
  --green-psyche: #39ff14;
  --teal: #00e5c7;
}

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

body {
  background: var(--bg-deep);
  color: #e0d0f0;
  font-family: 'Fira Code', monospace;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/* Sacred Geometry Background */
.sacred-bg {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
  overflow: hidden;
}

.sacred-bg svg {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0.08;
  animation: sacredRotate 120s linear infinite, sacredPulse 8s ease-in-out infinite;
}

@keyframes sacredRotate {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

@keyframes sacredPulse {
  0%, 100% { opacity: 0.06; }
  50% { opacity: 0.14; }
}

/* Breathing effect */
.breathe {
  animation: breathe 6s ease-in-out infinite;
}

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

/* Floating particles */
.particle {
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 1;
  animation: particleFloat linear infinite;
}

@keyframes particleFloat {
  0% { transform: translateY(100vh) rotate(0deg); opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { transform: translateY(-10vh) rotate(720deg); opacity: 0; }
}

/* Color shifting gradient overlay */
.gradient-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(ellipse at 20% 50%, rgba(179,71,224,0.08) 0%, transparent 50%),
              radial-gradient(ellipse at 80% 20%, rgba(0,240,255,0.06) 0%, transparent 50%),
              radial-gradient(ellipse at 50% 80%, rgba(255,45,149,0.06) 0%, transparent 50%);
  animation: gradientShift 12s ease-in-out infinite alternate;
}

@keyframes gradientShift {
  0% {
    background: radial-gradient(ellipse at 20% 50%, rgba(179,71,224,0.1) 0%, transparent 50%),
                radial-gradient(ellipse at 80% 20%, rgba(0,240,255,0.08) 0%, transparent 50%),
                radial-gradient(ellipse at 50% 80%, rgba(255,45,149,0.06) 0%, transparent 50%);
  }
  33% {
    background: radial-gradient(ellipse at 60% 30%, rgba(255,215,0,0.08) 0%, transparent 50%),
                radial-gradient(ellipse at 20% 80%, rgba(57,255,20,0.06) 0%, transparent 50%),
                radial-gradient(ellipse at 80% 60%, rgba(179,71,224,0.1) 0%, transparent 50%);
  }
  66% {
    background: radial-gradient(ellipse at 40% 70%, rgba(0,240,255,0.1) 0%, transparent 50%),
                radial-gradient(ellipse at 70% 30%, rgba(255,45,149,0.08) 0%, transparent 50%),
                radial-gradient(ellipse at 20% 20%, rgba(255,215,0,0.06) 0%, transparent 50%);
  }
  100% {
    background: radial-gradient(ellipse at 80% 50%, rgba(57,255,20,0.08) 0%, transparent 50%),
                radial-gradient(ellipse at 30% 70%, rgba(179,71,224,0.1) 0%, transparent 50%),
                radial-gradient(ellipse at 50% 20%, rgba(0,240,255,0.06) 0%, transparent 50%);
  }
}

/* Glassmorphism chat container */
.glass {
  background: rgba(10, 5, 20, 0.65);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(179, 71, 224, 0.15);
}

/* Title glow */
.title-glow {
  font-family: 'Cinzel Decorative', serif;
  background: linear-gradient(135deg, var(--cyan), var(--purple-neon), var(--magenta), var(--gold), var(--cyan));
  background-size: 400% 400%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: titleGradient 6s ease infinite;
  filter: drop-shadow(0 0 20px rgba(179,71,224,0.5)) drop-shadow(0 0 40px rgba(0,240,255,0.3));
}

@keyframes titleGradient {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* Subtitle morph */
.subtitle-morph {
  font-family: 'Fira Code', monospace;
  color: rgba(179,71,224,0.7);
  text-shadow: 0 0 10px rgba(179,71,224,0.3);
  transition: opacity 0.8s ease;
}

/* Third eye */
.third-eye {
  display: inline-block;
  animation: eyePulse 3s ease-in-out infinite;
}

@keyframes eyePulse {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 5px var(--purple-neon)); }
  50% { transform: scale(1.15); filter: drop-shadow(0 0 15px var(--cyan)); }
}

.eye-blink {
  animation: eyeBlink 0.2s ease-in-out;
}

@keyframes eyeBlink {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(0.1); }
}

/* User message */
.msg-user {
  border: 1px solid rgba(0, 240, 255, 0.3);
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.1), inset 0 0 15px rgba(0, 240, 255, 0.05);
  background: rgba(0, 240, 255, 0.05);
}

/* Entity message */
.msg-entity {
  border: 1px solid rgba(179, 71, 224, 0.3);
  background: rgba(179, 71, 224, 0.05);
  box-shadow: 0 0 15px rgba(179, 71, 224, 0.1), inset 0 0 15px rgba(179, 71, 224, 0.05);
  animation: entityBorderShift 4s linear infinite;
}

@keyframes entityBorderShift {
  0% { border-color: rgba(179, 71, 224, 0.4); box-shadow: 0 0 15px rgba(179, 71, 224, 0.15); }
  25% { border-color: rgba(0, 240, 255, 0.4); box-shadow: 0 0 15px rgba(0, 240, 255, 0.15); }
  50% { border-color: rgba(255, 45, 149, 0.4); box-shadow: 0 0 15px rgba(255, 45, 149, 0.15); }
  75% { border-color: rgba(255, 215, 0, 0.4); box-shadow: 0 0 15px rgba(255, 215, 0, 0.15); }
  100% { border-color: rgba(179, 71, 224, 0.4); box-shadow: 0 0 15px rgba(179, 71, 224, 0.15); }
}

/* Materializing text */
.materialize-char {
  display: inline;
  animation: materialize 0.5s ease-out forwards;
  opacity: 0;
}

@keyframes materialize {
  0% { opacity: 0; filter: blur(8px); transform: translateY(5px); color: var(--cyan); }
  50% { filter: blur(2px); color: var(--magenta); }
  100% { opacity: 1; filter: blur(0); transform: translateY(0); color: inherit; }
}

/* Typing indicator */
.typing-geo {
  display: inline-block;
  width: 20px; height: 20px;
  animation: geoSpin 1.5s linear infinite;
}

@keyframes geoSpin {
  0% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(90deg) scale(1.2); }
  50% { transform: rotate(180deg) scale(1); }
  75% { transform: rotate(270deg) scale(0.8); }
  100% { transform: rotate(360deg) scale(1); }
}

/* Input glow */
.input-glow {
  transition: all 0.3s ease;
  border: 1px solid rgba(179, 71, 224, 0.3);
  background: rgba(10, 5, 20, 0.8);
}

.input-glow:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.2), 0 0 40px rgba(0, 240, 255, 0.1);
  outline: none;
}

/* Send button */
.send-btn {
  background: linear-gradient(135deg, rgba(179,71,224,0.3), rgba(0,240,255,0.3));
  border: 1px solid rgba(179,71,224,0.4);
  transition: all 0.3s ease;
}

.send-btn:hover {
  background: linear-gradient(135deg, rgba(179,71,224,0.5), rgba(0,240,255,0.5));
  box-shadow: 0 0 25px rgba(179,71,224,0.3);
  transform: scale(1.05);
}

.send-btn:active {
  transform: scale(0.95);
}

/* Send flash */
.send-flash {
  animation: sendFlash 0.4s ease-out;
}

@keyframes sendFlash {
  0% { box-shadow: 0 0 0 0 rgba(0,240,255,0.8); }
  100% { box-shadow: 0 0 60px 20px rgba(0,240,255,0); }
}

/* Intensity meter */
.intensity-bar {
  transition: all 0.5s ease;
}

/* Custom scrollbar */
.chat-scroll::-webkit-scrollbar {
  width: 4px;
}

.chat-scroll::-webkit-scrollbar-track {
  background: rgba(10, 5, 20, 0.5);
}

.chat-scroll::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--purple-neon), var(--cyan));
  border-radius: 2px;
}

/* Entity avatar pulse */
.entity-avatar {
  animation: avatarPulse 2s ease-in-out infinite;
}

@keyframes avatarPulse {
  0%, 100% { filter: drop-shadow(0 0 5px var(--purple-neon)); transform: scale(1); }
  50% { filter: drop-shadow(0 0 15px var(--cyan)) drop-shadow(0 0 25px var(--magenta)); transform: scale(1.1); }
}

/* Breakthrough animation */
.breakthrough-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 9999;
  pointer-events: none;
  animation: breakthrough 3s ease-out forwards;
}

@keyframes breakthrough {
  0% {
    background: radial-gradient(circle at center, rgba(255,255,255,1) 0%, rgba(179,71,224,0.8) 30%, transparent 60%);
    opacity: 1;
  }
  20% {
    background: radial-gradient(circle at center, rgba(0,240,255,1) 0%, rgba(255,45,149,0.8) 40%, rgba(255,215,0,0.6) 60%, transparent 80%);
    opacity: 1;
  }
  50% {
    background: radial-gradient(circle at center, rgba(57,255,20,0.8) 0%, rgba(179,71,224,0.6) 30%, rgba(0,240,255,0.4) 50%, transparent 70%);
    opacity: 0.8;
  }
  100% {
    background: radial-gradient(circle at center, transparent 0%, transparent 100%);
    opacity: 0;
  }
}

/* Glitch effect for max intensity */
.glitch {
  animation: glitch 0.3s ease-in-out;
}

@keyframes glitch {
  0% { transform: translate(0); filter: hue-rotate(0deg); }
  20% { transform: translate(-5px, 3px); filter: hue-rotate(90deg); }
  40% { transform: translate(3px, -5px); filter: hue-rotate(180deg); }
  60% { transform: translate(-3px, 5px); filter: hue-rotate(270deg); }
  80% { transform: translate(5px, -3px); filter: hue-rotate(360deg); }
  100% { transform: translate(0); filter: hue-rotate(0deg); }
}

/* Intensity-driven wavy text */
.wavy-text {
  animation: textWave 2s ease-in-out infinite;
}

@keyframes textWave {
  0%, 100% { transform: translateY(0); }
  25% { transform: translateY(-1px); }
  75% { transform: translateY(1px); }
}

/* New trip button */
.new-trip-btn {
  font-family: 'Cinzel Decorative', serif;
  background: rgba(255, 45, 149, 0.1);
  border: 1px solid rgba(255, 45, 149, 0.3);
  color: var(--magenta);
  transition: all 0.3s ease;
}

.new-trip-btn:hover {
  background: rgba(255, 45, 149, 0.2);
  box-shadow: 0 0 20px rgba(255, 45, 149, 0.2);
}

/* Sound toggle */
.sound-toggle {
  transition: all 0.3s ease;
}

.sound-toggle:hover {
  filter: drop-shadow(0 0 8px var(--gold));
}

/* Footer */
.dmt-footer a {
  color: var(--purple-neon);
  text-decoration: none;
  transition: all 0.3s ease;
}

.dmt-footer a:hover {
  color: var(--cyan);
  text-shadow: 0 0 10px var(--cyan);
}

/* Responsive */
@media (max-width: 640px) {
  .sacred-bg svg {
    width: 600px !important;
    height: 600px !important;
  }
}

/* Intensity-based speed modifiers */
.intensity-fast .gradient-overlay { animation-duration: 6s !important; }
.intensity-fast .sacred-bg svg { animation-duration: 60s, 4s !important; }
.intensity-fast .msg-entity { animation-duration: 2s !important; }

.intensity-max .gradient-overlay { animation-duration: 3s !important; }
.intensity-max .sacred-bg svg { animation-duration: 30s, 2s !important; }