:root {
    --cosmic-void: #0a0e27;
    --nebula-purple: #9945ff;
    --astral-cyan: #14f195;
    --psyche-gold: #ffd700;
    --shadow-blue: #1a1f4e;
    --revelation-white: #f0f6ff;
    --anima-pink: #ff45b5;
    --animus-orange: #ff6b45;
}

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

body {
    font-family: 'Space Grotesk', sans-serif;
    background: var(--cosmic-void);
    color: var(--revelation-white);
    overflow-x: hidden;
    min-height: 100vh;
    position: relative;
}

#cosmos-container {
    position: relative;
    min-height: 100vh;
    background: radial-gradient(ellipse at center, #1a1f4e 0%, #0a0e27 50%, #000 100%);
    animation: cosmicPulse 20s ease-in-out infinite;
}

@keyframes cosmicPulse {
    0%, 100% { filter: brightness(1) hue-rotate(0deg); }
    50% { filter: brightness(1.2) hue-rotate(10deg); }
}

#particle-nebula {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.3;
    z-index: 1;
}

#astral-plane {
    position: relative;
    z-index: 2;
    padding: 2rem;
    max-width: 1600px;
    margin: 0 auto;
}

#ethereal-header {
    text-align: center;
    margin-bottom: 3rem;
    animation: descendFromVoid 1.5s ease-out;
}

@keyframes descendFromVoid {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.psyche-title {
    font-size: clamp(2.5rem, 8vw, 5rem);
    font-weight: 700;
    letter-spacing: 0.1em;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--nebula-purple), var(--astral-cyan), var(--psyche-gold));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: chromaticShift 8s ease-in-out infinite;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.glyph {
    font-family: 'Crimson Text', serif;
    font-style: italic;
    font-size: 0.7em;
    opacity: 0.8;
    animation: glyphRotate 10s linear infinite;
}

@keyframes glyphRotate {
    from { transform: rotateY(0deg); }
    to { transform: rotateY(360deg); }
}

@keyframes chromaticShift {
    0%, 100% { filter: hue-rotate(0deg); }
    33% { filter: hue-rotate(120deg); }
    66% { filter: hue-rotate(240deg); }
}

.subtitle {
    font-family: 'Crimson Text', serif;
    font-size: clamp(1rem, 3vw, 1.5rem);
    font-style: italic;
    opacity: 0.8;
    letter-spacing: 0.2em;
    animation: fadeInUp 2s ease-out 0.5s both;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 0.8;
        transform: translateY(0);
    }
}

#dimension-selector {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 3rem;
    flex-wrap: wrap;
    animation: fadeInUp 2s ease-out 0.8s both;
}

.dimension-btn {
    padding: 0.75rem 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--revelation-white);
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.9rem;
    letter-spacing: 0.1em;
    cursor: pointer;
    border-radius: 50px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

.dimension-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: radial-gradient(circle, var(--astral-cyan), transparent);
    transition: width 0.6s, height 0.6s;
    transform: translate(-50%, -50%);
    border-radius: 50%;
}

.dimension-btn:hover::before {
    width: 200%;
    height: 200%;
}

.dimension-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(20, 241, 149, 0.3);
    border-color: var(--astral-cyan);
}

.dimension-btn.active {
    background: linear-gradient(135deg, var(--nebula-purple), var(--astral-cyan));
    border: none;
    animation: dimensionPulse 2s ease-in-out infinite;
}

@keyframes dimensionPulse {
    0%, 100% { box-shadow: 0 0 20px rgba(20, 241, 149, 0.5); }
    50% { box-shadow: 0 0 40px rgba(153, 69, 255, 0.8); }
}

#mandala-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 2rem;
    padding: 2rem;
    animation: gridMaterialize 2s ease-out 1s both;
}

@keyframes gridMaterialize {
    from {
        opacity: 0;
        transform: scale(0.8) rotateX(10deg);
    }
    to {
        opacity: 1;
        transform: scale(1) rotateX(0);
    }
}

.psyche-symbol {
    width: 120px;
    height: 120px;
    cursor: pointer;
    position: relative;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    animation: symbolFloat 6s ease-in-out infinite;
    animation-delay: calc(var(--index) * 0.1s);
}

@keyframes symbolFloat {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-10px) rotate(5deg); }
    75% { transform: translateY(5px) rotate(-5deg); }
}

.psyche-symbol:hover {
    transform: scale(1.2) rotate(360deg);
    filter: drop-shadow(0 0 30px var(--astral-cyan));
    z-index: 10;
}

.psyche-symbol svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 0 10px rgba(153, 69, 255, 0.5));
}

.psyche-symbol.revealed {
    animation: symbolReveal 1s ease-out;
}

@keyframes symbolReveal {
    0% {
        transform: scale(1) rotateY(0);
        filter: brightness(1);
    }
    50% {
        transform: scale(1.5) rotateY(180deg);
        filter: brightness(2) hue-rotate(180deg);
    }
    100% {
        transform: scale(1) rotateY(360deg);
        filter: brightness(1);
    }
}

#revelation-portal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 14, 39, 0.95);
    backdrop-filter: blur(20px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.5s ease;
}

#revelation-portal.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.9);
}

.portal-content {
    background: linear-gradient(135deg, rgba(26, 31, 78, 0.9), rgba(10, 14, 39, 0.9));
    border: 2px solid var(--astral-cyan);
    border-radius: 20px;
    padding: 3rem;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: portalOpen 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 100px rgba(20, 241, 149, 0.3);
}

@keyframes portalOpen {
    from {
        transform: scale(0) rotate(180deg);
        opacity: 0;
    }
    to {
        transform: scale(1) rotate(0);
        opacity: 1;
    }
}

.close-portal {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: var(--astral-cyan);
    font-size: 2rem;
    cursor: pointer;
    transition: transform 0.3s;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-portal:hover {
    transform: rotate(90deg) scale(1.2);
}

.symbol-amplified {
    width: 200px;
    height: 200px;
    margin: 0 auto 2rem;
    animation: infiniteRotate 20s linear infinite;
}

@keyframes infiniteRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.archetype-name {
    font-family: 'Crimson Text', serif;
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: 1.5rem;
    background: linear-gradient(90deg, var(--psyche-gold), var(--anima-pink), var(--animus-orange));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: textGlow 3s ease-in-out infinite;
}

@keyframes textGlow {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.5) drop-shadow(0 0 20px currentColor); }
}

.psychological-exegesis {
    font-family: 'Crimson Text', serif;
    font-size: 1.1rem;
    line-height: 1.8;
    text-align: justify;
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, rgba(153, 69, 255, 0.05), rgba(20, 241, 149, 0.05));
    border-left: 3px solid var(--nebula-purple);
    border-radius: 8px;
    opacity: 0.9;
    animation: textReveal 1s ease-out;
}

.simple-interpretation {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, rgba(20, 241, 149, 0.08), rgba(255, 215, 0, 0.08));
    border-left: 3px solid var(--astral-cyan);
    border-radius: 8px;
    animation: textReveal 1.2s ease-out;
}

.interpretation-label {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--astral-cyan);
    margin-bottom: 0.8rem;
    opacity: 0.8;
}

.simple-text {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--revelation-white);
    opacity: 0.95;
}

@keyframes textReveal {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 0.9;
        transform: translateY(0);
    }
}

.resonance-meter {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.meter-bar {
    flex: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.meter-bar::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: var(--resonance, 0%);
    background: linear-gradient(90deg, var(--nebula-purple), var(--astral-cyan));
    animation: resonancePulse 2s ease-in-out infinite;
    transition: width 1s ease-out;
}

@keyframes resonancePulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

#loading-vortex {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 100;
    transition: opacity 0.5s;
}

#loading-vortex.hidden {
    opacity: 0;
    pointer-events: none;
}

.vortex-spinner {
    width: 100px;
    height: 100px;
    margin: 0 auto 1rem;
}

.loading-text {
    font-family: 'Crimson Text', serif;
    font-style: italic;
    opacity: 0.8;
    animation: loadingPulse 2s ease-in-out infinite;
}

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

@media (max-width: 768px) {
    #mandala-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 1rem;
        padding: 1rem;
    }
    
    .psyche-symbol {
        width: 80px;
        height: 80px;
    }
    
    .portal-content {
        padding: 2rem 1.5rem;
    }
    
    .symbol-amplified {
        width: 150px;
        height: 150px;
    }
    
    .psyche-title {
        flex-direction: column;
        gap: 0.5rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.symbol-constellation > * {
    opacity: 0;
    animation: constellationAppear 0.8s ease-out forwards;
}

@keyframes constellationAppear {
    from {
        opacity: 0;
        transform: scale(0) rotate(180deg);
    }
    to {
        opacity: 1;
        transform: scale(1) rotate(0);
    }
}

.symbol-constellation > *:nth-child(n) {
    animation-delay: calc(var(--index, 0) * 0.03s);
}