/* === CSS Variables - Magic 8-Ball Theme === */
:root {
    --bg-gradient-start: #0f0a1f;
    --bg-gradient-mid: #1a0a2e;
    --bg-gradient-end: #0a0014;
    
    --ball-black: #0a0a0a;
    --ball-dark: #1a1a1a;
    --ball-shine: rgba(255, 255, 255, 0.15);
    
    --window-blue-dark: #0a1929;
    --window-blue: #1e3a5f;
    --window-blue-light: #2563eb;
    
    --text-white: #ffffff;
    --text-dim: rgba(255, 255, 255, 0.6);
    
    --accent-purple: #8b5cf6;
    --accent-pink: #ec4899;
    --accent-glow: rgba(139, 92, 246, 0.5);
    
    --font-display: 'Creepster', cursive;
    --font-body: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* === Reset & Base === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
}

body {
    font-family: var(--font-body);
    background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-mid), var(--bg-gradient-end));
    min-height: 100vh;
    color: var(--text-white);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
    position: relative;
}

/* === Starfield Background === */
.starfield {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.star {
    position: absolute;
    background: white;
    border-radius: 50%;
    animation: twinkle var(--duration) ease-in-out infinite;
    animation-delay: var(--delay);
}

@keyframes twinkle {
    0%, 100% { opacity: var(--opacity); transform: scale(1); }
    50% { opacity: 0.2; transform: scale(0.8); }
}

/* === Layout === */
.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    z-index: 1;
    flex: 1;
}

/* === Title === */
.title {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 8vw, 5rem);
    color: var(--text-white);
    text-shadow: 
        0 0 20px var(--accent-glow),
        0 0 40px var(--accent-glow),
        0 0 60px rgba(139, 92, 246, 0.3);
    margin-bottom: 40px;
    letter-spacing: 2px;
    text-align: center;
    animation: titlePulse 3s ease-in-out infinite;
}

@keyframes titlePulse {
    0%, 100% { 
        text-shadow: 
            0 0 20px var(--accent-glow),
            0 0 40px var(--accent-glow),
            0 0 60px rgba(139, 92, 246, 0.3);
    }
    50% { 
        text-shadow: 
            0 0 30px var(--accent-glow),
            0 0 60px var(--accent-glow),
            0 0 90px rgba(139, 92, 246, 0.5);
    }
}

/* === Magic 8-Ball === */
.magic-8-ball {
    cursor: pointer;
    transition: transform 0.2s ease;
    margin-bottom: 40px;
}

.magic-8-ball:hover {
    transform: scale(1.02);
}

.magic-8-ball:active {
    transform: scale(0.98);
}

.ball-outer {
    width: clamp(320px, 75vw, 500px);
    height: clamp(320px, 75vw, 500px);
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, var(--ball-dark), var(--ball-black) 60%);
    position: relative;
    box-shadow: 
        inset -20px -20px 40px rgba(0, 0, 0, 0.8),
        inset 10px 10px 30px rgba(255, 255, 255, 0.05),
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 100px var(--accent-glow);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* === Ball Shine Effect === */
.ball-shine {
    position: absolute;
    top: 8%;
    left: 15%;
    width: 35%;
    height: 25%;
    background: radial-gradient(ellipse, var(--ball-shine) 0%, transparent 70%);
    border-radius: 50%;
    transform: rotate(-30deg);
}

/* === The "8" Circle === */
.ball-eight {
    position: absolute;
    top: 12%;
    left: 50%;
    transform: translateX(-50%);
    width: 75px;
    height: 75px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 40%, #ffffff, #e0e0e0);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 
        inset -2px -2px 5px rgba(0, 0, 0, 0.2),
        0 3px 10px rgba(0, 0, 0, 0.3);
}

.ball-eight span {
    font-family: var(--font-display);
    font-size: 3rem;
    color: #000;
    font-weight: 400;
}

/* === Answer Window === */
.answer-window {
    width: 55%;
    height: 55%;
    border-radius: 50%;
    background: radial-gradient(circle, var(--window-blue), var(--window-blue-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 
        inset 0 0 30px rgba(0, 0, 0, 0.5),
        0 0 20px rgba(30, 58, 95, 0.5);
    position: relative;
    overflow: hidden;
}

.answer-window::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.1), transparent 50%);
    border-radius: 50%;
}

/* === Answer Triangle === */
.answer-triangle {
    width: 0;
    height: 0;
    border-left: 130px solid transparent;
    border-right: 130px solid transparent;
    border-bottom: 220px solid var(--window-blue-light);
    position: relative;
    filter: drop-shadow(0 0 20px rgba(37, 99, 235, 0.5));
    display: flex;
    align-items: center;
    justify-content: center;
}

.answer-text {
    position: absolute;
    bottom: -190px;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-white);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    line-height: 1.3;
    transition: opacity 0.3s ease;
}

/* === Shake Animation === */
.magic-8-ball.shaking {
    animation: shake 0.6s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: rotate(0deg) translateX(0); }
    10% { transform: rotate(-8deg) translateX(-10px); }
    20% { transform: rotate(8deg) translateX(10px); }
    30% { transform: rotate(-8deg) translateX(-10px); }
    40% { transform: rotate(8deg) translateX(10px); }
    50% { transform: rotate(-5deg) translateX(-5px); }
    60% { transform: rotate(5deg) translateX(5px); }
    70% { transform: rotate(-3deg) translateX(-3px); }
    80% { transform: rotate(3deg) translateX(3px); }
    90% { transform: rotate(-1deg) translateX(-1px); }
}

/* === Answer Fade Animation === */
.answer-text.fade-out {
    opacity: 0;
}

.answer-text.fade-in {
    animation: fadeInUp 0.5s ease forwards;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* === Shake Button === */
.shake-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px 32px;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
    color: white;
    border: none;
    border-radius: 50px;
    font-family: var(--font-body);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 
        0 4px 20px rgba(139, 92, 246, 0.4),
        0 0 40px rgba(139, 92, 246, 0.2);
}

.shake-button:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 
        0 8px 30px rgba(139, 92, 246, 0.5),
        0 0 60px rgba(139, 92, 246, 0.3);
}

.shake-button:active {
    transform: translateY(0) scale(0.98);
}

.shake-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.button-icon {
    font-size: 1.5rem;
}

/* === Instruction Text === */
.instruction {
    margin-top: 24px;
    font-size: 0.9rem;
    color: var(--text-dim);
    text-align: center;
}

/* === Footer === */
.footer {
    text-align: center;
    padding: 24px 20px;
    color: var(--text-dim);
    font-size: 0.8rem;
    z-index: 1;
}

.footer p {
    margin-bottom: 6px;
}

.disclaimer {
    font-size: 0.7rem;
    opacity: 0.6;
}

/* === Responsive Design === */
@media (max-width: 480px) {
    .container {
        padding: 30px 16px;
    }
    
    .title {
        margin-bottom: 30px;
    }
    
    .ball-eight {
        width: 65px;
        height: 65px;
    }
    
    .ball-eight span {
        font-size: 2.5rem;
    }
    
    .answer-triangle {
        border-left: 90px solid transparent;
        border-right: 90px solid transparent;
        border-bottom: 160px solid var(--window-blue-light);
    }
    
    .answer-text {
        width: 150px;
        font-size: 0.8rem;
        bottom: -135px;
    }
    
    .shake-button {
        padding: 14px 28px;
        font-size: 1rem;
    }
    
    .magic-8-ball {
        margin-bottom: 30px;
    }
}

/* === Mystical floating effect on idle === */
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.magic-8-ball:not(.shaking) {
    animation: float 4s ease-in-out infinite;
}

.magic-8-ball:hover:not(.shaking) {
    animation-play-state: paused;
}
