:root {
    --font-family: 'Fredoka One', cursive;
}

body,
html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    touch-action: none;
    overscroll-behavior: none;
    font-family: var(--font-family);
    user-select: none;
    -webkit-user-select: none;
    background-color: #000;
    /* Fallback */
}

#game-container {
    width: 100%;
    height: 100%;
    position: relative;
}

/* Scene Background */
#scene {
    width: 100%;
    height: 100%;
    position: relative;
    background-size: cover;
    background-position: center;
    background-color: #87CEEB;
    /* Fallback color */
    transition: background-image 1s ease-in-out;
    overflow: hidden;
}

/* Background Images per State */
#scene.sunny {
    background-image: url('assets/bg_sunny.png');
}

#scene.rainy {
    background-image: url('assets/bg_rainy.png');
}

#scene.snowy {
    background-image: url('assets/bg_snowy.png');
}

#scene.rainbow {
    background-image: url('assets/bg_rainbow.png');
}

/* Interactive Elements */
.interactive {
    cursor: pointer;
    transition: transform 0.2s;
    pointer-events: auto;
}

.interactive:active {
    transform: scale(0.9);
}

/* Sun Element */
#sun-element {
    position: absolute;
    top: 2%;
    left: 50%;
    /* Centering is handled in the animation to avoid conflict */
    width: 200px;
    /* Larger size */
    height: auto;
    mix-blend-mode: screen;
    opacity: 0;
    transition: opacity 1s ease;
    animation: rotateSun 40s linear infinite;
    z-index: 10;
}

/* Rainbow Element - CSS Art */
#rainbow-element {
    position: absolute;
    bottom: -50px;
    left: 50%;
    /* Centering handled in float animation */
    width: 600px;
    height: 300px;
    border-radius: 300px 300px 0 0;

    /* Transparent center */
    background: transparent;

    /* The Rainbow Stripes */
    box-shadow:
        0 0 0 20px #FF0000,
        /* Red */
        0 0 0 40px #FF7F00,
        /* Orange */
        0 0 0 60px #FFFF00,
        /* Yellow */
        0 0 0 80px #00FF00,
        /* Green */
        0 0 0 100px #0000FF,
        /* Blue */
        0 0 0 120px #4B0082,
        /* Indigo */
        0 0 0 140px #9400D3;
    /* Violet */

    opacity: 0;
    transition: opacity 1.5s ease;
    z-index: 5;
    pointer-events: none;

    /* Animations */
    animation: rainbowFloat 4s ease-in-out infinite alternate, rainbowShimmer 3s ease-in-out infinite alternate;
}

/* Visibility Logic */
#scene.sunny #sun-element {
    opacity: 1;
}

#scene.rainbow #sun-element {
    opacity: 1;
}

#scene.rainbow #rainbow-element {
    opacity: 0.8;
    /* Increased visibility */
}

/* Animations */
@keyframes rotateSun {
    from {
        transform: translateX(-50%) rotate(0deg);
    }

    to {
        transform: translateX(-50%) rotate(360deg);
    }
}

@keyframes rainbowFloat {
    0% {
        transform: translateX(-50%) translateY(0);
    }

    100% {
        transform: translateX(-50%) translateY(-20px);
    }
}

@keyframes rainbowShimmer {
    0% {
        filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.3));
    }

    50% {
        filter: drop-shadow(0 0 30px rgba(255, 255, 255, 0.6)) brightness(1.1);
    }

    100% {
        filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.3));
    }
}

/* Particles (Rain/Snow) */
.weather-container {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    pointer-events: none;
    z-index: 20;
}

.particle {
    position: absolute;
    pointer-events: none;
    line-height: 1;
    /* Tight line height for emojis */
}

.rain-drop {
    animation: rainFall linear forwards;
    transform-origin: center;
}

.snow-flake {
    animation: snowFall linear forwards;
}

@keyframes rainFall {
    0% {
        transform: translateY(-10vh) translateX(0) rotate(15deg);
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    100% {
        transform: translateY(110vh) translateX(-15vh) rotate(15deg);
        opacity: 0.8;
    }
}

@keyframes snowFall {
    0% {
        transform: translateY(-10vh) translateX(0) rotate(0deg);
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    25% {
        transform: translateY(20vh) translateX(25px) rotate(45deg);
    }

    50% {
        transform: translateY(50vh) translateX(-25px) rotate(90deg);
    }

    75% {
        transform: translateY(80vh) translateX(25px) rotate(135deg);
    }

    100% {
        transform: translateY(110vh) translateX(0) rotate(180deg);
        opacity: 0.8;
    }
}

/* UI Text */
#overlay-text {
    position: absolute;
    top: 15%;
    width: 100%;
    text-align: center;
    font-size: 3rem;
    color: white;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    z-index: 100;
    pointer-events: none;
    transition: all 0.5s;
}

#hint-text {
    position: absolute;
    bottom: 5%;
    width: 100%;
    text-align: center;
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.8);
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
    z-index: 100;
    pointer-events: none;
    animation: pulse 2s infinite;
}

.back-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    font-size: 30px;
    z-index: 100;
    text-decoration: none;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid #fff;
    color: #fff;
    transition: 0.2s;
}

.back-btn:hover {
    background: rgba(0, 0, 0, 0.5);
    transform: scale(1.1);
}

/* Interactive Feedback Animation Class */
.feedback-bounce {
    animation: bounce 0.5s !important;
}

@keyframes bounce {

    0%,
    100% {
        transform: scale(1) rotate(var(--rotation, 0deg));
    }

    50% {
        transform: scale(1.3) rotate(var(--rotation, 0deg));
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}