:root {
    --bg-color: #f0f8ff;
    --text-color: #333;
    --card-bg: #ffffff;
    --primary-color: #ff6b6b;
    --bubble-color: #4facfe;
    --animal-color: #4caf50;
    --paint-color: #fca311;
    --number-color: #a855f7;
    --music-color: #ec4899;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Comic Sans MS', 'Chalkboard SE', 'Comic Neue', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    touch-action: manipulation;
    overflow-x: hidden;
}

/* Prevent accidental back navigation */
html {
    overscroll-behavior-x: none;
}

header {
    margin-bottom: 30px;
    text-align: center;
}

h1 {
    font-size: 3rem;
    color: var(--primary-color);
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
    animation: titlePulse 3s ease-in-out infinite;
}

@keyframes titlePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

.game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    width: 100%;
    max-width: 1100px;
}

.game-card {
    background-color: var(--card-bg);
    border-radius: 24px;
    padding: 25px;
    text-align: center;
    text-decoration: none;
    color: var(--text-color);
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 4px solid transparent;
    opacity: 0;
    transform: translateY(30px);
    animation: cardSlideIn 0.5s forwards;
}

.game-card:nth-child(1)  { animation-delay: 0.02s; }
.game-card:nth-child(2)  { animation-delay: 0.06s; }
.game-card:nth-child(3)  { animation-delay: 0.10s; }
.game-card:nth-child(4)  { animation-delay: 0.14s; }
.game-card:nth-child(5)  { animation-delay: 0.18s; }
.game-card:nth-child(6)  { animation-delay: 0.22s; }
.game-card:nth-child(7)  { animation-delay: 0.26s; }
.game-card:nth-child(8)  { animation-delay: 0.30s; }
.game-card:nth-child(9)  { animation-delay: 0.34s; }
.game-card:nth-child(10) { animation-delay: 0.38s; }
.game-card:nth-child(11) { animation-delay: 0.42s; }
.game-card:nth-child(12) { animation-delay: 0.46s; }
.game-card:nth-child(13) { animation-delay: 0.50s; }
.game-card:nth-child(14) { animation-delay: 0.54s; }
.game-card:nth-child(15) { animation-delay: 0.58s; }
.game-card:nth-child(16) { animation-delay: 0.62s; }
.game-card:nth-child(17) { animation-delay: 0.66s; }

@keyframes cardSlideIn {
    0% { opacity: 0; transform: translateY(30px) scale(0.95); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

.game-card:hover, .game-card:active {
    transform: translateY(-8px) scale(1.03);
    box-shadow: 0 16px 40px rgba(0,0,0,0.15);
}

.game-card .icon {
    font-size: 4.5rem;
    margin-bottom: 12px;
    line-height: 1;
    display: inline-block;
}

.game-card .icon.bounce {
    animation: iconFloat 3s ease-in-out infinite;
}

.game-card .icon.tap-bounce {
    animation: iconTap 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes iconFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

@keyframes iconTap {
    0% { transform: scale(1); }
    40% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.game-card h2 {
    font-size: 1.5rem;
    transition: transform 0.2s;
}

/* Themes */
.game-card.bubble-theme { 
    border-color: var(--bubble-color);
    background: linear-gradient(135deg, #ffffff 60%, #e8f4fd 100%);
}
.game-card.bubble-theme:hover { border-color: #2980ef; }

.game-card.animal-theme { 
    border-color: var(--animal-color);
    background: linear-gradient(135deg, #ffffff 60%, #e8f5e9 100%);
}
.game-card.animal-theme:hover { border-color: #2e9d4e; }

.game-card.paint-theme { 
    border-color: var(--paint-color);
    background: linear-gradient(135deg, #ffffff 60%, #fff8e1 100%);
}
.game-card.paint-theme:hover { border-color: #e8960a; }

.game-card.number-theme { 
    border-color: var(--number-color);
    background: linear-gradient(135deg, #ffffff 60%, #f3e8ff 100%);
}
.game-card.number-theme:hover { border-color: #9333ea; }

.game-card.music-theme { 
    border-color: var(--music-color);
    background: linear-gradient(135deg, #ffffff 60%, #fce7f3 100%);
}
.game-card.music-theme:hover { border-color: #db2777; }

/* Responsive */
@media (max-width: 768px) {
    h1 { font-size: 2.2rem; }
    header { margin-bottom: 15px; }
    .game-grid { 
        grid-template-columns: repeat(2, 1fr);
        gap: 12px; 
    }
    .game-card { 
        padding: 15px; 
    }
    .game-card .icon { 
        font-size: 3.5rem; 
        margin-bottom: 8px;
    }
    .game-card h2 { font-size: 1.2rem; }
}

@media (max-width: 400px) {
    body { padding: 10px; }
    .game-grid { 
        grid-template-columns: repeat(2, 1fr);
        gap: 8px; 
    }
    .game-card { 
        padding: 12px; 
    }
    .game-card .icon { font-size: 2.8rem; }
    .game-card h2 { font-size: 1rem; }
}