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

/* Base background container */
.cosmic-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #ffffff;
    overflow: hidden;
    z-index: -1;
}

/* Grain effect */
.cosmic-background::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    opacity: 0.20;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='noiseFilter'><feTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23noiseFilter)'/></svg>");
    background-repeat: repeat;
    background-size: 200px 200px;
}

/* Gradient blob base class */
.gradient-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
    transform: translate3d(0, 0, 0);
    will-change: transform;
    mix-blend-mode: multiply;
}

/* Individual blob styles and animations */
.blob-1 {
    width: 60vmax;
    height: 60vmax;
    background: radial-gradient(circle at 30% 30%, 
        rgba(120, 40, 180, 0.4) 0%, 
        rgba(80, 20, 140, 0.2) 40%, 
        transparent 70%);
    top: -20%;
    left: -20%;
    animation: float-1 12s ease-in-out infinite;
}

.blob-2 {
    width: 50vmax;
    height: 50vmax;
    background: radial-gradient(circle at 60% 40%, 
        rgba(40, 90, 180, 0.4) 0%, 
        rgba(20, 50, 120, 0.2) 50%, 
        transparent 70%);
    bottom: -30%;
    right: -25%;
    animation: float-2 15s ease-in-out infinite;
}

.blob-3 {
    width: 70vmax;
    height: 70vmax;
    background: radial-gradient(circle at 40% 50%, 
        rgba(180, 40, 120, 0.4) 0%, 
        rgba(120, 20, 80, 0.2) 45%, 
        transparent 70%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: float-3 18s ease-in-out infinite;
}

.blob-4 {
    width: 45vmax;
    height: 45vmax;
    background: radial-gradient(circle at 50% 50%, 
        rgba(40, 180, 160, 0.4) 0%, 
        rgba(20, 120, 100, 0.2) 50%, 
        transparent 70%);
    top: 20%;
    right: 10%;
    animation: float-4 10s ease-in-out infinite;
}

.blob-5 {
    width: 55vmax;
    height: 55vmax;
    background: radial-gradient(circle at 45% 45%, 
        rgba(100, 40, 200, 0.4) 0%, 
        rgba(60, 20, 140, 0.2) 50%, 
        transparent 70%);
    bottom: 10%;
    left: 15%;
    animation: float-5 14s ease-in-out infinite;
    mix-blend-mode: multiply;
}

/* Keyframe animations for each blob */
@keyframes float-1 {
    0%, 100% {
        transform: translate3d(0, 0, 0) rotate(0deg) scale(1);
    }
    25% {
        transform: translate3d(30vw, 10vh, 0) rotate(90deg) scale(1.1);
    }
    50% {
        transform: translate3d(10vw, 30vh, 0) rotate(180deg) scale(0.9);
    }
    75% {
        transform: translate3d(-10vw, 20vh, 0) rotate(270deg) scale(1.05);
    }
}

@keyframes float-2 {
    0%, 100% {
        transform: translate3d(0, 0, 0) rotate(0deg) scale(1);
    }
    33% {
        transform: translate3d(-25vw, -20vh, 0) rotate(-120deg) scale(1.15);
    }
    66% {
        transform: translate3d(-35vw, -10vh, 0) rotate(-240deg) scale(0.85);
    }
}

@keyframes float-3 {
    0%, 100% {
        transform: translate(-50%, -50%) translate3d(0, 0, 0) rotate(0deg) scale(1);
    }
    20% {
        transform: translate(-50%, -50%) translate3d(15vw, -10vh, 0) rotate(72deg) scale(0.9);
    }
    40% {
        transform: translate(-50%, -50%) translate3d(-10vw, -15vh, 0) rotate(144deg) scale(1.1);
    }
    60% {
        transform: translate(-50%, -50%) translate3d(-20vw, 10vh, 0) rotate(216deg) scale(0.95);
    }
    80% {
        transform: translate(-50%, -50%) translate3d(10vw, 15vh, 0) rotate(288deg) scale(1.05);
    }
}

@keyframes float-4 {
    0%, 100% {
        transform: translate3d(0, 0, 0) rotate(0deg) scale(1);
    }
    50% {
        transform: translate3d(-30vw, 25vh, 0) rotate(-180deg) scale(1.2);
    }
}

@keyframes float-5 {
    0%, 100% {
        transform: translate3d(0, 0, 0) rotate(0deg) scale(1);
    }
    25% {
        transform: translate3d(20vw, -15vh, 0) rotate(90deg) scale(0.8);
    }
    50% {
        transform: translate3d(30vw, -25vh, 0) rotate(180deg) scale(1.1);
    }
    75% {
        transform: translate3d(15vw, -10vh, 0) rotate(270deg) scale(0.95);
    }
}

/* Performance optimization for mobile */
@media (max-width: 768px) {
    .gradient-blob {
        filter: blur(60px);
    }
    
    .blob-1, .blob-2, .blob-3, .blob-4, .blob-5 {
        animation-duration: 15s, 18s, 20s, 12s, 16s;
    }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .gradient-blob {
        animation: none;
    }
}

/* Dark mode styles */
[data-theme="dark"] .cosmic-background {
    background-color: #0a0a0a;
}

[data-theme="dark"] .gradient-blob {
    opacity: 0.3;
    mix-blend-mode: screen;
}

[data-theme="dark"] .blob-1 {
    background: radial-gradient(circle at 30% 30%, 
        rgba(120, 40, 180, 0.8) 0%, 
        rgba(80, 20, 140, 0.4) 40%, 
        transparent 70%);
}

[data-theme="dark"] .blob-2 {
    background: radial-gradient(circle at 60% 40%, 
        rgba(40, 90, 180, 0.7) 0%, 
        rgba(20, 50, 120, 0.3) 50%, 
        transparent 70%);
}

[data-theme="dark"] .blob-3 {
    background: radial-gradient(circle at 40% 50%, 
        rgba(180, 40, 120, 0.6) 0%, 
        rgba(120, 20, 80, 0.3) 45%, 
        transparent 70%);
}

[data-theme="dark"] .blob-4 {
    background: radial-gradient(circle at 50% 50%, 
        rgba(40, 180, 160, 0.5) 0%, 
        rgba(20, 120, 100, 0.2) 50%, 
        transparent 70%);
}

[data-theme="dark"] .blob-5 {
    background: radial-gradient(circle at 45% 45%, 
        rgba(100, 40, 200, 0.5) 0%, 
        rgba(60, 20, 140, 0.2) 50%, 
        transparent 70%);
    mix-blend-mode: color-dodge;
} 