/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Fredoka', sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Prevent layout shift - Reserve space for images */
img {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Prevent CLS by reserving space for key elements */
.nav-logo h1 {
    min-height: 2.2rem; /* Reserve space for logo */
}

.hero-image {
    min-height: 120px; /* Reserve space for mascot */
}

/* Ensure consistent spacing */
.game-icon {
    min-height: 56px; /* Reserve space for emoji icons */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Header and Navigation */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
    contain: layout style; /* Contain header layout */
}

.navbar {
    padding: 1rem 0;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-logo h1 {
    color: #FF6B35;
    font-size: 1.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-icon {
    height: 16px !important;
    width: 16px !important;
    object-fit: contain !important;
    max-height: 16px !important;
    max-width: 16px !important;
    display: inline-block !important;
    flex-shrink: 0;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-link {
    text-decoration: none;
    color: #333;
    font-weight: 500;
    transition: color 0.3s ease;
}

.nav-link:hover {
    color: #FF6B35;
}

.hamburger {
    display: none;
    flex-direction: column;
    cursor: pointer;
}

.bar {
    width: 25px;
    height: 3px;
    background-color: #333;
    margin: 3px 0;
    transition: 0.3s;
}

/* Main Content */
.main-content {
    margin-top: 80px;
}

/* Hero Section */
.hero {
    padding: 80px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
    padding-left: 20px;
    padding-right: 20px;
    min-height: 400px; /* Reserve space for hero section */
}

.hero-content {
    flex: 1;
    max-width: 500px;
}

.hero-title {
    font-size: 3.5rem;
    color: white;
    margin-bottom: 1rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    font-weight: 600;
}

.hero-subtitle {
    font-size: 1.3rem;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 2rem;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.hero-image {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.fox-mascot {
    font-size: 8rem;
    animation: float 6s ease-in-out infinite;
    text-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    will-change: transform;
    width: 120px;
    height: 120px;
    flex-shrink: 0;
}

.mascot-image {
    height: 48px !important;
    width: 48px !important;
    object-fit: contain !important;
    max-height: 48px !important;
    max-width: 48px !important;
    display: block !important;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.2));
    flex-shrink: 0;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 15px 30px;
    text-decoration: none;
    border-radius: 50px;
    font-weight: 600;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(45deg, #FF6B35, #F7931E);
    color: white;
    box-shadow: 0 5px 15px rgba(255, 107, 53, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 53, 0.5);
}

.btn-secondary {
    background: linear-gradient(45deg, #4ECDC4, #44A08D);
    color: white;
    box-shadow: 0 5px 15px rgba(78, 205, 196, 0.4);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(78, 205, 196, 0.5);
}

/* Games Section */
.games-section {
    padding: 80px 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
}

.section-title {
    text-align: center;
    font-size: 2.5rem;
    color: #333;
    margin-bottom: 3rem;
    font-weight: 600;
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
    contain: layout style; /* Improve rendering performance */
}

.game-card {
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    border: 3px solid transparent;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
    contain: layout style; /* Prevent layout shifts within cards */
    min-height: 400px; /* Reserve consistent space for game cards */
}

.game-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.12);
    border-color: #FF6B35;
}

.game-content {
    padding: 2rem;
    text-align: center;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.game-description-section {
    padding: 1rem 2rem 2rem;
    background: linear-gradient(to bottom, #f8f9fa, #e9ecef);
    border-top: 1px solid #dee2e6;
    margin-top: auto;
}

.game-description-section .game-description {
    font-size: 0.95rem;
    color: #666;
    line-height: 1.5;
    margin: 0;
    text-align: center;
}

.game-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    border-color: #FF6B35;
}

.game-mode {
    position: absolute;
    top: 15px;
    right: 15px;
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 2;
}

.game-mode.single {
    background: linear-gradient(45deg, #28a745, #20c997);
    color: white;
}

.game-mode.coop {
    background: linear-gradient(45deg, #FF6B35, #F7931E);
    color: white;
}

.game-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    will-change: auto;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-5px); }
    60% { transform: translateY(-2px); }
}

.game-content h3 {
    font-size: 1.5rem;
    margin: 0.5rem 0 1rem;
    color: #333;
    font-weight: 700;
}

.age-range {
    background: linear-gradient(45deg, #6c5ce7, #a29bfe);
    color: white;
    padding: 5px 15px;
    border-radius: 15px;
    font-size: 0.85rem;
    font-weight: 600;
    margin: 1rem 0;
    display: inline-block;
}

.game-card p {
    color: #666;
    margin-bottom: 1.5rem;
    font-size: 1rem;
}

.game-description {
    color: #555;
    margin-bottom: 1.5rem;
    font-size: 1rem;
    line-height: 1.5;
    font-weight: 500;
}

/* Educational Styles */
.educational-benefits {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 15px;
    margin: 1.5rem 0;
    text-align: left;
}

.educational-benefits h4 {
    color: #333;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
    text-align: center;
}

.educational-benefits ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.educational-benefits li {
    margin: 0.75rem 0;
    font-size: 0.9rem;
    line-height: 1.4;
    color: #555;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.educational-benefits strong {
    color: #333;
}

.age-range {
    background: linear-gradient(45deg, #4f46e5, #7c3aed);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
    margin: 1rem 0;
    display: inline-block;
}

.section-subtitle {
    text-align: center;
    color: #666;
    font-size: 1.2rem;
    margin-bottom: 3rem;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.6;
}

/* About Section */
.about-section {
    padding: 80px 0;
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    color: white;
}

.about-content {
    text-align: center;
    max-width: 800px;
    margin: 0 auto;
}

.about-content p {
    font-size: 1.2rem;
    margin-bottom: 3rem;
    line-height: 1.8;
}

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    margin-top: 3rem;
}

.feature {
    background: rgba(255, 255, 255, 0.1);
    padding: 2rem;
    border-radius: 15px;
    backdrop-filter: blur(10px);
}

.feature-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.feature h3 {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

/* Footer */
.footer {
    background: #333;
    color: white;
    text-align: center;
    padding: 2rem 0;
}

/* Footer support text */
.footer-support {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    opacity: 0.9;
}

.footer-support a:hover {
    text-decoration: underline !important;
}

/* Search and Filter Styles */
.search-filter-container {
    background: rgba(255, 255, 255, 0.9);
    padding: 2rem;
    border-radius: 20px;
    margin-bottom: 3rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.search-box {
    position: relative;
    max-width: 400px;
    margin: 0 auto 2rem;
}

.search-box input {
    width: 100%;
    padding: 15px 50px 15px 20px;
    border: 2px solid #e9ecef;
    border-radius: 25px;
    font-size: 1.1rem;
    font-family: 'Fredoka', sans-serif;
    transition: all 0.3s ease;
    background: white;
}

.search-box input:focus {
    outline: none;
    border-color: #FF6B35;
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

.search-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
    color: #666;
}

.filter-tags {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.filter-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.filter-group label {
    font-weight: 600;
    color: #333;
    margin-right: 0.5rem;
    min-width: 100px;
    font-size: 1rem;
}

.filter-tag {
    background: #e9ecef;
    color: #495057;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Fredoka', sans-serif;
}

.filter-tag:hover {
    background: rgba(255, 107, 53, 0.1);
    transform: translateY(-2px);
}

.filter-tag.active {
    background: #FF6B35;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
}

/* Game Tags */
.game-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 1rem 0;
    justify-content: center;
}

.tag {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

.tag.subject {
    background: linear-gradient(45deg, #4ECDC4, #44A08D);
    color: white;
}

.tag.mode {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
}

/* Game Card Updates */
.game-card.hidden {
    display: none;
}

.game-card {
    transition: all 0.3s ease;
}

.game-card.highlight {
    transform: scale(1.02);
    box-shadow: 0 15px 40px rgba(255, 107, 53, 0.2);
    border-color: #FF6B35;
}

/* Search and Filter Results */
.results-counter {
    text-align: center;
    margin: 1rem 0;
    padding: 0.5rem;
    font-size: 1rem;
    color: #666;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 10px;
    backdrop-filter: blur(10px);
}

.results-counter.no-results {
    color: #ff6b6b;
    font-weight: 600;
    background: rgba(255, 107, 107, 0.1);
    border: 2px solid rgba(255, 107, 107, 0.3);
}

/* Performance optimization: Reduce animations for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    .fox-mascot,
    .game-icon {
        animation: none;
    }
    
    .game-card:hover,
    .btn-primary:hover,
    .btn-secondary:hover {
        transform: none;
    }
    
    * {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .hamburger {
        display: flex;
    }
    
    .nav-menu {
        position: fixed;
        left: -100%;
        top: 70px;
        flex-direction: column;
        background-color: white;
        width: 100%;
        text-align: center;
        transition: 0.3s;
        box-shadow: 0 10px 27px rgba(0, 0, 0, 0.05);
        padding: 2rem 0;
    }
    
    .nav-menu.active {
        left: 0;
    }
    
    .hero {
        flex-direction: column;
        text-align: center;
        padding: 40px 20px;
    }
    
    .hero-title {
        font-size: 2.5rem;
    }
    
    .fox-mascot {
        font-size: 6rem;
        margin-top: 2rem;
    }
    
    .fox-mascot .mascot-image {
        height: 40px !important;
        width: 40px !important;
        max-height: 40px !important;
        max-width: 40px !important;
    }
    
    .games-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .learning-areas {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .features {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    
    .learning-objectives {
        flex-direction: column;
        align-items: center;
    }
    
    .objective {
        width: fit-content;
    }
    
    .educational-benefits li {
        font-size: 0.85rem;
    }
    
    .game-mode {
        position: static;
        margin-bottom: 1rem;
        display: block;
        width: fit-content;
        margin-left: auto;
        margin-right: auto;
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: 2rem;
    }
    
    .hero-subtitle {
        font-size: 1.1rem;
    }
    
    .btn {
        padding: 12px 24px;
        font-size: 1rem;
    }
    
    .section-title {
        font-size: 2rem;
    }
    
    .features {
        grid-template-columns: 1fr;
    }
    
    .educational-benefits {
        padding: 1rem;
    }
    
    .educational-benefits li {
        font-size: 0.8rem;
    }
    
    .learning-area {
        padding: 1.5rem;
    }
    
    .learning-icon {
        font-size: 2.5rem;
    }
}
