:root {
    --bg-color: #1a0b2e; /* Deep purple night sky */
    --text-color: #ffffff;
    --accent-orange: #ff7b00;
    --accent-purple: #9d4edd;
    --accent-green: #38b000;
    --star-color: #ffe066;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Fredoka One', cursive; /* Playful kid's font */
    overflow-x: hidden;
    overflow-y: auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

/* Background Night Sky */
.night-sky {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
}

.moon {
    position: absolute;
    top: 50px;
    right: 50px;
    width: 150px;
    height: 150px;
    background: #ffe066;
    border-radius: 50%;
    box-shadow: 0 0 40px #ffe066, inset -20px -20px 0 0px #ffb703;
    animation: gentle-bob 4s ease-in-out infinite alternate;
}

.star {
    position: absolute;
    background: white;
    border-radius: 50%;
    animation: twinkle varies infinite alternate;
}

/* Header */
.glass-header {
    margin-top: 40px;
    padding: 20px 40px;
    border-radius: 30px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 3px solid rgba(255, 255, 255, 0.2);
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 10;
}

.glass-header h1 {
    font-size: 3rem;
    color: var(--accent-orange);
    text-shadow: 2px 2px 0px #000, 4px 4px 0px #3c096c;
    letter-spacing: 2px;
}

.glass-header p {
    font-family: 'Nunito', sans-serif;
    font-size: 1.5rem;
    margin-top: 10px;
    color: #ffd166;
}

/* Main Playground */
.playground {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 40px;
    padding: 40px;
    width: 100%;
    max-width: 1200px;
    margin-top: 20px;
    position: relative;
    z-index: 10;
}

/* Character Containers */
.character-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    transition: transform 0.2s;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.character {
    width: 250px;
    height: auto;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.6));
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), filter 0.3s;
}

.character:hover {
    transform: scale(1.1);
}

.character:active {
    transform: scale(0.9);
}

/* Spider Area */
.spider-area {
    position: relative;
    top: -40px;
}

.spider-thread {
    width: 4px;
    height: 150px;
    background-color: rgba(255, 255, 255, 0.5);
    margin-bottom: -150px;
    z-index: -1;
}

.web-corner {
    position: absolute;
    top: -50px;
    left: -100px;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle at 0 0, transparent 40%, rgba(255,255,255,0.1) 45%, transparent 50%),
                radial-gradient(circle at 0 0, transparent 60%, rgba(255,255,255,0.1) 65%, transparent 70%);
    z-index: -2;
}

.swing {
    animation: swing 3s ease-in-out infinite alternate;
    transform-origin: top center;
}

/* Pumpkin Area */
.pumpkin-area {
    margin-top: 50px;
}

.glowing {
    filter: drop-shadow(0 0 30px var(--accent-orange));
}

.bounce {
    animation: bounce 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Candy Container */
.candy-area {
    margin-top: 30px;
}

.shake {
    animation: shake 0.5s;
}

/* Candy Burst Overlay */
#candy-burst-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

.falling-candy {
    position: absolute;
    width: 40px;
    height: 40px;
    border-radius: 5px;
    animation: popAndFall 1.5s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

/* Animations */
@keyframes twinkle {
    from { opacity: 0.3; transform: scale(1); }
    to { opacity: 1; transform: scale(1.2); }
}

@keyframes gentle-bob {
    from { transform: translateY(0); }
    to { transform: translateY(20px); }
}

@keyframes swing {
    0% { transform: rotate(10deg); }
    100% { transform: rotate(-10deg); }
}

@keyframes bounce {
    0%, 100% { transform: scale(1) translateY(0); }
    50% { transform: scale(1.2) translateY(-40px); }
}

@keyframes shake {
    0% { transform: translateX(0) scale(1.1); }
    25% { transform: translateX(-15px) rotate(-10deg) scale(1.1); }
    50% { transform: translateX(15px) rotate(10deg) scale(1.1); }
    75% { transform: translateX(-15px) rotate(-10deg) scale(1.1); }
    100% { transform: translateX(0) scale(1.1); }
}

@keyframes popAndFall {
    0% { transform: translateY(0) scale(0) rotate(0deg); opacity: 1; }
    30% { transform: translateY(-100px) scale(1.5) rotate(180deg); opacity: 1; }
    100% { transform: translateY(800px) scale(1) rotate(400deg); opacity: 0; }
}

/* Responsive adjust for toddlers on iPad / Tablets */
@media (max-width: 800px) {
    .glass-header h1 {
        font-size: 2.2rem;
    }
    .playground {
        flex-direction: column;
        gap: 60px;
    }
    .character {
        width: 200px;
    }
}
