:root {
    --color-bg: #0b0212;
    /* Darker, richer purple-black */
    --color-primary: #D4AF37;
    /* Classic Gold */
    --color-primary-glow: rgba(212, 175, 55, 0.4);
    --color-secondary: #3b0f70;
    /* Deep Royal Purple */
    --color-accent: #b388ff;
    /* Soft violet for accents */
    --color-text-main: #f0f0f5;
    --color-text-muted: #bdc3c7;
    --glass-bg: rgba(20, 10, 30, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);

    --font-heading: 'Cinzel', serif;
    --font-body: 'Outfit', sans-serif;

    --transition-speed: 1.2s;
    /* Slowed down for mystery */
    --card-width: 140px;
    /* Slightly larger cards */
    --card-height: 235px;
}

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

body {
    background-color: var(--color-bg);
    color: var(--color-text-main);
    font-family: var(--font-body);
    overflow-x: hidden;
    min-height: 100vh;
}

/* Background Effects */
.stars-bg,
.nebula-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

.stars-bg {
    background-image:
        radial-gradient(white, rgba(255, 255, 255, .2) 2px, transparent 3px),
        radial-gradient(white, rgba(255, 255, 255, .15) 1px, transparent 2px),
        radial-gradient(white, rgba(255, 255, 255, .1) 2px, transparent 3px);
    background-size: 550px 550px, 350px 350px, 250px 250px;
    background-position: 0 0, 40px 60px, 130px 270px;
    animation: twinkle 20s linear infinite;
}

.nebula-bg {
    background: radial-gradient(circle at 50% 50%, var(--color-secondary), transparent 70%);
    opacity: 0.4;
    filter: blur(80px);
    animation: breathe 10s ease-in-out infinite alternate;
}

@keyframes twinkle {
    from {
        transform: translateY(0);
    }

    to {
        transform: translateY(-550px);
    }
}

@keyframes breathe {
    from {
        transform: scale(1);
        opacity: 0.3;
    }

    to {
        transform: scale(1.1);
        opacity: 0.5;
    }
}

/* Typography */
h1,
h2,
h3 {
    font-family: var(--font-heading);
    color: var(--color-primary);
    text-shadow: 0 0 20px var(--color-primary-glow);
    text-align: center;
}

h1 {
    font-size: 3.5rem;
    margin-bottom: 1rem;
}

h2 {
    font-size: 2.5rem;
    margin-bottom: 2rem;
}

p {
    font-size: 1.2rem;
    color: var(--color-text-muted);
    text-align: center;
    margin-bottom: 2rem;
}

/* Buttons */
button {
    cursor: pointer;
    font-family: var(--font-body);
    font-weight: 600;
    padding: 1.2rem 3.5rem;
    /* Larger touch target */
    border-radius: 50px;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    text-transform: uppercase;
    letter-spacing: 3px;
    font-size: 1rem;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary), #996515);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #05010a;
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.3);
}

.btn-primary::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    bottom: -50%;
    left: -50%;
    background: linear-gradient(to bottom, rgba(229, 172, 142, 0), rgba(255, 255, 255, 0.5) 50%, rgba(229, 172, 142, 0));
    transform: rotateZ(60deg) translate(-5em, 7.5em);
    opacity: 0;
    transition: all 0.5s;
}

.btn-primary:hover::after {
    opacity: 1;
    transform: rotateZ(60deg) translate(1em, -9em);
}

.btn-primary:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 0 40px rgba(212, 175, 55, 0.6);
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--color-primary);
    color: var(--color-primary);
    padding: 1rem 3rem;
}

.btn-secondary:hover {
    background: rgba(212, 175, 55, 0.1);
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.2);
}

.hidden {
    display: none !important;
    opacity: 0;
}

/* Layout */
.tarot-experience {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 2rem;
    position: relative;
    perspective: 1200px;
    background: radial-gradient(circle at center, #1a0b2e 0%, #000000 100%);
}

.content-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 2;
    max-width: 800px;
    text-align: center;
}

/* Stage 1: Landing */
.mystic-circle {
    width: 200px;
    height: 200px;
    border: 2px solid var(--color-primary);
    border-radius: 50%;
    margin-bottom: 3rem;
    box-shadow: 0 0 50px var(--color-primary-glow), inset 0 0 50px var(--color-primary-glow);
    animation: rotateCircle 20s linear infinite;
    position: relative;
}

.mystic-circle::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70%;
    height: 70%;
    border: 1px solid rgba(212, 175, 55, 0.5);
    border-radius: 50%;
}

@keyframes rotateCircle {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Stage 2: Deck */
.controls {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    width: 100%;
    margin-top: 2rem;
}

.deck-container {
    position: relative;
    width: var(--card-width);
    height: var(--card-height);
    margin: 3rem auto;
    perspective: 1200px;
    /* Stack effect hint underneath */
    box-shadow:
        0 0 0 1px #3b0f70,
        0 5px 0 0 #2d0b59,
        0 10px 0 0 #1f0640,
        0 15px 30px rgba(0, 0, 0, 0.8);
    border-radius: 12px;
    background: rgba(45, 11, 89, 0.2);
}

.tarot-card {
    position: absolute;
    width: 100%;
    height: 100%;
    background: #000;
    border-radius: 12px;
    /* Subtle border for stack definition */
    border: 1px solid rgba(212, 175, 55, 0.3);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: transform var(--transition-speed) cubic-bezier(0.25, 0.46, 0.45, 0.94), box-shadow 0.6s ease;
    transform-style: preserve-3d;
}

.tarot-card:hover {
    box-shadow: 0 0 25px rgba(212, 175, 55, 0.6);
}

.tarot-card .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    /* Sophisticated back pattern */
    background: #1c1c1c;
    background-image:
        radial-gradient(circle at 50% 50%, #2d0b59 0%, transparent 60%),
        repeating-linear-gradient(45deg, rgba(212, 175, 55, 0.1) 0px, rgba(212, 175, 55, 0.1) 1px, transparent 1px, transparent 10px);
    border: 2px solid #5a4080;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tarot-card .card-back::before {
    content: '✦';
    color: var(--color-primary);
    font-size: 4rem;
    opacity: 0.8;
    text-shadow: 0 0 15px var(--color-primary);
}

.tarot-card .card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    transform: rotateY(180deg);
    background: #000;
    border: 2px solid var(--color-primary);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.8);
}

.card-face img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.95;
    /* Slight fade for integration */
}

/* Card Animations classes */
.card-shuffling {
    animation: shuffleMove 1s ease-in-out infinite alternate;
}

@keyframes shuffleMove {
    from {
        transform: translateX(0) scale(1);
    }

    to {
        transform: translateX(15px) rotate(4deg) scale(1.05);
    }
}

.card-selected {
    border-color: var(--color-primary);
    box-shadow: 0 0 40px var(--color-primary-glow), 0 0 80px rgba(212, 175, 55, 0.2);
    z-index: 1000 !important;
}

/* Stage 4: Spread Alignment fixes */
#stage-reveal {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.spread-layout {
    display: flex;
    gap: 2rem;
    justify-content: center;
    margin: 3rem 0;
    flex-wrap: wrap;
    width: 100%;
    max-width: 900px;
}

.card-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: var(--card-width);
}

/* Stage 5: Result / Full Reading */
.reading-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    width: 100%;
    margin-top: 3rem;
}

.reading-card {
    background: rgba(20, 10, 40, 0.6);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    padding: 2rem;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: transform 0.4s ease, box-shadow 0.4s ease;
}

.reading-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border-color: var(--color-primary);
}

.reading-card h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--color-accent);
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 0.5rem;
    width: 100%;
}

.reading-card img {
    width: 120px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    margin-bottom: 1.5rem;
    border: 1px solid var(--color-primary);
}

.reading-card h4 {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    color: var(--color-primary);
    margin-bottom: 0.5rem;
}

.reading-card p {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--color-text-muted);
}

.cta-container {
    margin-top: 4rem;
    text-align: center;
    padding: 3rem;
    background: linear-gradient(to bottom, transparent, rgba(45, 11, 89, 0.2));
    border-radius: 20px;
    width: 100%;
}

.cta-container p {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    color: #fff;
    font-family: var(--font-heading);
}

/* Scrollbar refinement */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #0b0212;
}

::-webkit-scrollbar-thumb {
    background: #2d0b59;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #D4AF37;
}

#reveal-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 1rem;
    width: 100%;
    text-align: center;
}


.slot-label {
    margin-bottom: 1rem;
    font-family: var(--font-heading);
    color: var(--color-primary);
    text-transform: uppercase;
    font-size: 0.9rem;
    letter-spacing: 2px;
}

.card-placeholder {
    width: var(--card-width);
    height: var(--card-height);
    border: 2px dashed var(--glass-border);
    border-radius: 10px;
    background: var(--glass-bg);
}

/* Modal / Gate */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(5px);
}

.glass-panel {
    background: rgba(20, 10, 40, 0.9);
    border: 1px solid var(--color-primary);
    padding: 3rem;
    border-radius: 20px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    box-shadow: 0 0 50px rgba(212, 175, 55, 0.2);
}

.glass-panel input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--color-primary);
    padding: 1rem;
    width: 100%;
    margin-bottom: 1rem;
    color: white;
    border-radius: 5px;
}

.glass-panel input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

/* Animations */
.fade-in-up {
    animation: fadeInUp 1s ease forwards;
    opacity: 0;
    transform: translateY(20px);
}

.delay-1 {
    animation-delay: 0.2s;
}

.delay-2 {
    animation-delay: 0.4s;
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    :root {
        --card-width: 80px;
        --card-height: 140px;
    }

    h1 {
        font-size: 2.2rem;
    }

    h2 {
        font-size: 1.8rem;
    }

    .spread-layout {
        gap: 0.5rem;
    }

    .mystic-circle {
        width: 150px;
        height: 150px;
    }

    .glass-panel {
        padding: 1.5rem;
    }
}