/* Common styles for all games */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #e74c3c;
    --background-color: #f5f6fa;
    --card-background: #ffffff;
    --text-color: #2c3e50;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

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

html {
    height: 100%;
    margin: 0;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* Header and Navigation Styles */
header {
    text-align: left;
    margin-bottom: 3rem;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-radius: 0 0 20px 20px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.logo-container {
    margin: 0;
    display: flex;
    align-items: center;
}

.logo {
    height: 60px;
    width: auto;
    filter: none; /* Remove the filter that was making it white */
}

header .subtitle {
    font-size: 1rem;
    opacity: 0.9;
    margin: 0;
    display: none; /* Hide subtitle on desktop */
}

.main-nav {
    margin: 0;
}

.main-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    gap: 1.5rem;
    flex-wrap: nowrap;
}

.main-nav a {
    color: white;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.main-nav a:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

/* General Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.category-section {
    margin-bottom: 3rem;
}

.category-title {
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--secondary-color);
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 2rem;
    padding: 1rem;
}

.game-card {
    background: var(--card-background);
    border-radius: 15px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: var(--shadow);
}

.game-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.game-card a {
    text-decoration: none;
    color: var(--text-color);
    display: block;
    padding: 1.5rem;
}

.game-icon {
    width: 100%;
    height: 150px;
    background-color: var(--secondary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: white;
    margin-bottom: 1rem;
    border-radius: 10px;
}

.game-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.game-description {
    font-size: 0.9rem;
    color: #666;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        padding: 1rem;
        text-align: center;
    }

    .header-left {
        flex-direction: column;
        gap: 0.5rem;
    }

    .logo {
        height: 50px; /* Slightly smaller on mobile */
    }

    header .subtitle {
        display: block; /* Show subtitle on mobile */
        font-size: 0.9rem;
    }

    .main-nav ul {
        flex-direction: column;
        gap: 0.5rem;
        align-items: center;
        margin-top: 1rem;
    }

    .main-nav a {
        font-size: 0.9rem;
        padding: 0.3rem 0.8rem;
    }

    .container {
        padding: 1rem;
    }

    .games-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 1rem;
    }
}

/* Other common styles */
.game-container {
    position: relative;
}

#gameCanvas {
    background-color: #000;
    border: 2px solid #2121DE;
}

#score {
    position: absolute;
    top: -30px;
    left: 0;
    color: #FFFFFF;
    font-size: 20px;
}

#startMessage {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #FFFFFF;
    font-size: 24px;
    text-align: center;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.back-button {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 8px 16px;
    background-color: #2121DE;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 14px;
    transition: background-color 0.3s;
    z-index: 1000;
}

.back-button:hover {
    background-color: #1a1a9e;
}

/* Ad Containers */
.ad-container {
    width: 100%;
    max-width: 1200px;
    text-align: center;
    background: #f5f5f5;
    border-radius: 5px;
    overflow: hidden;
    margin: 0;
}

.top-ad {
    margin-bottom: 30px;
}

.bottom-ad {
    margin-top: 30px;
}

/* Ad Grid Layout */
.ad-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    padding: 1rem;
    margin: 2rem 0;
}

/* Square and Rectangle Ads */
.square-ad {
    width: 100%;
    max-width: 300px;
    aspect-ratio: 1/1;
    background: #f5f5f5;
    border-radius: 5px;
    overflow: hidden;
}

.rectangle-ad {
    width: 100%;
    max-width: 728px; /* Standard leaderboard size */
    aspect-ratio: 728/90; /* Standard leaderboard aspect ratio */
    background: #f5f5f5;
    border-radius: 5px;
    overflow: hidden;
}

@media (max-width: 768px) {
    .ad-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .square-ad {
        max-width: 250px;
    }

    .rectangle-ad {
        max-width: 300px; /* Switch to a typical square ad size on mobile */
        aspect-ratio: 1/1; /* Force square shape on mobile */
    }
}

/* Interstitial Ad Overlay */
.interstitial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0; /* Stretch to bottom */
    background: rgba(0, 0, 0, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.interstitial-overlay.active {
    display: flex;
}

.interstitial-content {
    background: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    max-width: 90%;
    width: 600px;
    /* Remove any explicit height/min-height that could conflict */
}

.interstitial-content h2 {
    margin-bottom: 15px;
    color: #333;
}

.interstitial-content p {
    margin-bottom: 20px;
    color: #666;
}

.interstitial-ad {
    margin: 20px 0;
    min-height: 250px;
}

.skip-ad {
    background: #2196F3;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
}

.skip-ad:hover {
    background: #1976D2;
}

.skip-ad:disabled {
    background: #ccc;
    cursor: not-allowed;
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .games-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 1rem;
    }

    h1 {
        font-size: 2rem;
    }
}

footer {
    background-color: var(--primary-color);
    color: white;
    text-align: center;
    padding: 1.5rem 0;
    margin-top: 3rem;
    font-size: 0.9rem;
}

footer .container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

footer a {
    color: white;
    text-decoration: none;
    transition: text-decoration 0.3s ease;
}

footer a:hover {
    text-decoration: underline;
}

@media (max-width: 768px) {
    footer .container {
        padding: 1rem;
    }
}