/* Base styles for a cosmic, playful background - DEEPER DARK */
body {
    font-family: 'Nunito', sans-serif;
    background: linear-gradient(180deg, #0d0321 0%, #200f3d 50%, #0d0321 100%); /* Even deeper space gradient */
    background-attachment: fixed;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    color: #f0f0f0; /* Slightly brighter light text for contrast */
    position: relative;
    overflow-x: hidden;
}

/* Animated background stars/sparkles */
.stars {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: -1;
}

.star {
    position: absolute;
    background-color: #fff;
    border-radius: 50%;
    opacity: 0;
    animation: twinkle 5s infinite ease-in-out;
}

/* Generate multiple stars with varying sizes and delays */
.star:nth-child(1) { width: 2px; height: 2px; top: 10%; left: 20%; animation-delay: 0s; }
.star:nth-child(2) { width: 3px; height: 3px; top: 30%; left: 70%; animation-delay: 1s; }
.star:nth-child(3) { width: 1px; height: 1px; top: 50%; left: 40%; animation-delay: 2s; }
.star:nth-child(4) { width: 2px; height: 2px; top: 70%; left: 10%; animation-delay: 3s; }
.star:nth-child(5) { width: 3px; height: 3px; top: 20%; left: 90%; animation-delay: 4s; }
.star:nth-child(6) { width: 2px; height: 2px; top: 80%; left: 50%; animation-delay: 0.5s; }
.star:nth-child(7) { width: 1px; height: 1px; top: 40%; left: 5%; animation-delay: 1.5s; }
.star:nth-child(8) { width: 3px; height: 3px; top: 60%; left: 80%; animation-delay: 2.5s; }
.star:nth-child(9) { width: 2px; height: 2px; top: 15%; left: 60%; animation-delay: 3.5s; }
.star:nth-child(10) { width: 1px; height: 1px; top: 90%; left: 30%; animation-delay: 4.5s; }

@keyframes twinkle {
    0%, 100% { opacity: 0; transform: scale(0.5); }
    50% { opacity: 1; transform: scale(1.2); }
}

.font-fredoka {
    font-family: 'Fredoka One', cursive;
}

/* Title styling with distinct colors set by JS */
.title-char {
    display: inline-block;
    transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55), text-shadow 0.3s ease-in-out;
    text-shadow: 0 0 8px rgba(255,255,255,0.7); /* Stronger glow for readability */
    will-change: transform, text-shadow; /* Optimize for animation */
}
.title-char:hover {
    transform: translateY(-20px) rotate(10deg) scale(1.2); /* More dramatic bounce and rotate */
    text-shadow: 0 0 20px rgba(255,255,255,1), 0 0 30px currentColor; /* Intense glow based on current letter color */
}

/* Collapsible Header Styles */
#header-content-wrapper {
    max-height: 300px; /* Approximate initial height of the header */
    overflow: hidden;
    transition: max-height 0.5s ease-out, opacity 0.5s ease-out, margin-bottom 0.5s ease-out; /* Added margin-bottom to transition */
    opacity: 1;
    margin-bottom: 16px; /* Original margin-bottom from header */
}

#header-content-wrapper.collapsed {
    max-height: 0;
    opacity: 0;
    margin-bottom: 0; /* Remove margin when collapsed */
}

/* Toggle Header Button */
#toggle-header-button {
    position: absolute;
    top: 10px; /* Adjust as needed for positioning */
    right: 10px; /* Adjust as needed for positioning */
    background-color: rgba(129, 140, 248, 0.7); /* Soft purple */
    border: 2px solid rgba(255, 255, 255, 0.5);
    color: white;
    padding: 0.5rem;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease-in-out;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    z-index: 100; /* Ensure it's above other content */
}

#toggle-header-button:hover {
    background-color: rgba(129, 140, 248, 1);
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

#toggle-header-button svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

/* Game card styling - floating platforms */
.game-card {
    background-color: rgba(32, 15, 61, 0.9); /* A slightly more opaque version of the background color */
    border-radius: 2rem; /* Slightly less rounded than before for smaller size, but still rounded */
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.4), 0 8px 12px rgba(0, 0, 0, 0.3); /* Slightly reduced shadow */
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), box-shadow 0.4s ease, border-color 0.4s ease;
    border: 2px solid rgba(255, 255, 255, 0.2); /* Slightly thinner border */
    display: flex;
    flex-direction: column;
    justify-content: center; /* Center content vertically */
    align-items: center;
    padding: 1.5rem; /* Reduced padding to make cards smaller */
    position: relative;
    overflow: hidden;
    transform: translateY(0); /* Initial state for animation */
    animation: float-card 8s infinite ease-in-out alternate; /* Gentle floating animation */
}

/* Individual card float delays */
.game-card:nth-child(odd) { animation-delay: 0s; }
.game-card:nth-child(even) { animation-delay: 1s; }
.game-card:nth-child(3n) { animation-delay: 0.5s; }

@keyframes float-card {
    0% { transform: translateY(0); }
    50% { transform: translateY(-10px); } /* Slightly less vertical float */
    100% { transform: translateY(0); }
}

.game-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 2rem; /* Match card border-radius */
    padding: 3px; /* Slightly thinner glowing border */
    background: linear-gradient(45deg, var(--card-gradient-start), var(--card-gradient-end));
    -webkit-mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: -1;
}

.game-card:hover::before {
    opacity: 1;
}

/* Define custom properties for card gradient colors - brighter, more magical */
.game-card.alphabet { --card-gradient-start: #818cf8; --card-gradient-end: #a78bfa; } /* Soft blue-violet */
.game-card.addition { --card-gradient-start: #4ade80; --card-gradient-end: #22c55e; } /* Vibrant green */
.game-card.subtraction { --card-gradient-start: #f87171; --card-gradient-end: #ef4444; } /* Warm red */
.game-card.colors { --card-gradient-start: #fb7185; --card-gradient-end: #ec4899; } /* Playful pink */
.game-card.logic { --card-gradient-start: #facc15; --card-gradient-end: #fbbf24; } /* Sunny yellow */
.game-card.memory { --card-gradient-start: #67e8f9; --card-gradient-end: #22d3ee; } /* Aqua blue */
.game-card.coding { --card-gradient-start: #8B5CF6; --card-gradient-end: #6D28D9; } /* Vibrant purple for new coding game */
.game-card.counting-numbers { --card-gradient-start: #8BC34A; --card-gradient-end: #4CAF50; } /* Green for counting game */
.game-card.coming-soon { --card-gradient-start: #94a3b8; --card-gradient-end: #64748b; } /* Muted gray */


.game-card:hover {
    transform: translateY(-15px) scale(1.05); /* Less dramatic lift and scale */
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5), 0 10px 15px rgba(0, 0, 0, 0.4); /* Reduced shadow on hover */
    border-color: rgba(255, 255, 255, 0.3); /* Slightly brighter border on hover */
}

.game-icon {
    width: 80%; /* Reduced icon size */
    height: auto;
    margin-bottom: 1.5rem; /* Reduced space below icon */
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
}
.game-icon svg {
    width: 100%;
    height: auto;
    max-width: 120px; /* Reduced max size for icons */
    max-height: 120px;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); /* Slightly faster springy icon animation */
}
.game-card:hover .game-icon svg {
    transform: scale(1.1) rotate(3deg); /* Less dramatic icon pop and rotate */
}

.game-title {
    font-size: 1.8rem; /* Reduced font size for title */
    font-weight: 700;
    text-align: center;
    color: #f0f0f0; /* Very light text */
    text-shadow: 0 3px 6px rgba(0,0,0,0.7); /* Deeper text shadow */
}

/* Specific text colors for game titles to match their themes - vibrant */
.game-card.alphabet .game-title { color: #c3dafe; }
.game-card.addition .game-title { color: #bbf7d0; }
.game-card.subtraction .game-title { color: #fecdd3; }
.game-card.colors .game-title { color: #fbcfe8; }
.game-card.logic .game-title { color: #fde68a; }
.game-card.memory .game-title { color: #a5f3fc; }
.game-card.coding .game-title { color: #e0b0ff; } /* Light purple for coding title */
.game-card.counting-numbers .game-title { color: #dcedc8; } /* Light green for counting title */
.game-card.coming-soon .game-title { color: #e2e8f0; }

/* Music toggle button styling - floating orb */
#music-toggle-button {
    background: linear-gradient(45deg, #a78bfa, #818cf8); /* Purple-blue gradient */
    border: 3px solid rgba(255, 255, 255, 0.5); /* White border */
    color: white;
    padding: 1rem; /* Larger padding */
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.4s ease-in-out;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 20px rgba(167, 139, 250, 0.8); /* Strong glowing shadow */
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 1000;
    animation: pulse 2s infinite ease-in-out alternate; /* Pulsing animation */
}

#music-toggle-button:hover {
    transform: scale(1.2) translateY(-8px); /* More pronounced lift and grow */
    box-shadow: 0 0 30px rgba(167, 139, 250, 1), 0 0 50px rgba(129, 140, 248, 0.8); /* Intense glow */
    animation: none; /* Stop pulse on hover */
}

@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 20px rgba(167, 139, 250, 0.8); }
    100% { transform: scale(1.05); box-shadow: 0 0 30px rgba(167, 139, 250, 1); }
}

#music-toggle-button svg {
    width: 32px; /* Even larger icon */
    height: 32px;
    fill: currentColor;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .game-card {
        padding: 1rem; /* Further reduced padding */
        border-radius: 1.5rem; /* Further reduced border-radius */
    }
    .game-title {
        font-size: 1.5rem; /* Further reduced font size */
    }
    .game-icon {
        margin-bottom: 1rem; /* Further reduced margin */
    }
    .game-icon svg {
        max-width: 100px; /* Further reduced max size */
        max-height: 100px;
    }
    #music-toggle-button {
        bottom: 15px;
        right: 15px;
        padding: 0.8rem;
    }
    #music-toggle-button svg {
        width: 28px;
        height: 28px;
    }
    #main-title {
        font-size: 4rem; /* Adjusted for smaller screens */
    }
    .stars { display: none; /* Hide stars on small screens for performance */ }
    .grid {
        gap: 0.8rem; /* Reduced gap for smaller screens */
    }
}

@media (max-width: 480px) {
    .game-card {
        padding: 0.8rem; /* Even further reduced padding */
        border-radius: 1rem; /* Even further reduced border-radius */
    }
    .game-title {
        font-size: 1.2rem; /* Even further reduced font size */
    }
    .game-icon {
        margin-bottom: 0.8rem; /* Even further reduced margin */
    }
    .game-icon svg {
        max-width: 80px; /* Even further reduced max size */
        max-height: 80px;
    }
    #main-title {
        font-size: 3rem; /* Adjusted for smallest screens */
    }
    #music-toggle-button {
        bottom: 10px;
        right: 10px;
        padding: 0.6rem;
    }
    #music-toggle-button svg {
        width: 24px;
        height: 24px;
    }
    .grid {
        gap: 0.6rem; /* Even further reduced gap */
    }
}
