/* --- Basic Setup --- */
html {
    background-color: #000000;
}

body {
    background-color: #000000;
    font-family: 'Cinzel', serif;
    margin: 0;
    overflow: hidden; /* Hide scrollbars */
    color: #fff;
}

/* This container is needed for the 3D perspective effect on mouse-over */
.container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    perspective: 1000px; /* Enables 3D space for children */
}

/* --- FEATURE: Stylish Title --- */
h1 {
    font-family: 'Playfair Display', serif;
    font-weight: 400;
    font-style: italic;
    font-size: 3rem;
    color: #ffd700;
    text-shadow: 0 0 5px #ffd700, 0 0 15px #f0a500;
    margin: 0;
}

/* --- The 8-Ball Styling (Corrected Version 2.0) --- */
#magic-8-ball {
    width: 350px;
    height: 350px;
    background-image: url('magic-ball.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    position: relative;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;

    /* Transition for the mouse-out effect */
    transition: transform 0.2s ease-out;

    animation: grandEntrance 1.5s 0.5s ease-out forwards;
}

/* This class now ONLY applies the idle glow */
#magic-8-ball.idle {
    animation: idleGlow 4s infinite ease-in-out;
}

/* This class correctly overrides the idle glow with the new shake */
#magic-8-ball.shake {
    animation: progressiveShake 1s ease-in-out; /* Increased duration */
}

/* --- The Answer Text Styling --- */
#answer {
    position: absolute;
    width: 45%;
    font-family: 'Cinzel', serif;
    font-size: 1.4em;
    font-weight: bold;
    color: #cce7f0;
    text-shadow: 0 0 5px #ffffff, 0 0 10px #8bebfd;
    line-height: 1.2;
    opacity: 0; /* Hidden by default */
}

/* Add this class to trigger the answer reveal */
#answer.reveal {
    opacity: 1;
    animation: liquidReveal 1s ease-out;
}

/* --- KEYFRAME ANIMATIONS --- */

@keyframes grandEntrance {
    from {
        opacity: 0;
        transform: translateY(-100px) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes idleGlow {
    0%, 100% {
        filter: drop-shadow(0 0 10px #f0a500);
    }
    50% {
        filter: drop-shadow(0 0 25px #ffd700);
    }
}

@keyframes progressiveShake {
    0% { transform: translate(0, 0) rotate(0deg) scale(1); }
    10% { transform: translate(-2px, -1px) rotate(-1deg) scale(1.02); } /* Slow start */
    20% { transform: translate(2px, 1px) rotate(1deg) scale(1.02); }
    30% { transform: translate(-4px, -2px) rotate(-2deg) scale(1.04); } /* Gradually increasing */
    40% { transform: translate(4px, 2px) rotate(2deg) scale(1.04); }
    50% { transform: translate(-6px, -3px) rotate(-3deg) scale(1.06); }
    60% { transform: translate(6px, 3px) rotate(3deg) scale(1.06); }
    70% { transform: translate(-8px, -4px) rotate(-4deg) scale(1.08); } /* Approaching faster shake */
    80% { transform: translate(8px, 4px) rotate(4deg) scale(1.08); }
    90% { transform: translate(0, 0) rotate(0deg) scale(1.1); filter: drop-shadow(0 0 15px #ffffff); } /* Moment before reveal */
    100% { transform: translate(0, 0) rotate(0deg) scale(1); }
}

@keyframes liquidReveal {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.8);
        filter: blur(5px);
    }
    50% {
        opacity: 0.8;
        transform: translateY(-5px) scale(1.05);
        filter: blur(2px);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}
