/* CSS Variables for Theming */
:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --accent-color: #f093fb;
    --bg-color: #f5f7fa;
    --card-bg: #ffffff;
    --text-color: #2d3748;
    --text-light: #718096;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 10px 25px rgba(0, 0, 0, 0.15);
    --ad-spacing: 20px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, var(--bg-color) 0%, #e0e7ff 100%);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
}

/* Header */
header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 2rem 1rem;
    text-align: center;
    box-shadow: var(--shadow);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* AdSense Ad Containers */
.ad-container {
    background: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    margin: var(--ad-spacing) auto;
    text-align: center;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ad-banner {
    width: 100%;
    max-width: 728px;
    min-height: 90px;
}

.ad-sidebar {
    width: 100%;
    max-width: 300px;
    min-height: 250px;
}

.ad-mobile {
    width: 100%;
    max-width: 320px;
    min-height: 100px;
}

.ad-inline {
    width: 100%;
    max-width: 300px;
    min-height: 250px;
    margin: var(--ad-spacing) auto;
}

/* Main Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* Game Grid */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
}

.game-card {
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
}

.game-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

.game-thumbnail {
    width: 100%;
    height: 200px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.game-info {
    padding: 1.5rem;
}

.game-info h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.game-info p {
    color: var(--text-light);
    font-size: 0.95rem;
}

/* Game Page Styles */
.game-page {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.game-header {
    text-align: center;
    margin-bottom: 2rem;
}

.game-header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.game-wrapper {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.game-area {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.game-canvas-container {
    position: relative;
    background: #1a202c;
    border-radius: 8px;
    padding: 10px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

canvas {
    display: block;
    border-radius: 4px;
}

.game-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    max-width: 600px;
}

.score-board {
    display: flex;
    justify-content: space-around;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 1rem;
    border-radius: 8px;
    font-size: 1.2rem;
    font-weight: bold;
}

.instructions {
    background: #f7fafc;
    padding: 1.5rem;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.instructions h3 {
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.instructions ul {
    list-style-position: inside;
    color: var(--text-light);
}

.instructions li {
    margin: 0.5rem 0;
}

/* Buttons */
.btn {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: var(--shadow);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.btn:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--text-light);
}

.back-link {
    display: inline-block;
    margin-bottom: 1rem;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}

.back-link:hover {
    color: var(--secondary-color);
}

/* Footer */
footer {
    background: var(--text-color);
    color: white;
    text-align: center;
    padding: 2rem 1rem;
    margin-top: 4rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }

    .games-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .game-header h1 {
        font-size: 2rem;
    }

    .game-wrapper {
        flex-direction: column;
    }

    .ad-sidebar {
        max-width: 100%;
    }

    .score-board {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
}

@media (min-width: 769px) {
    .game-wrapper {
        flex-direction: row;
        align-items: flex-start;
    }

    .game-area {
        flex: 1;
    }

    .ad-sidebar {
        flex: 0 0 300px;
    }
}

/* Touch Controls for Mobile */
.touch-controls {
    display: none;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 1rem;
    max-width: 300px;
}

.touch-controls button {
    background: rgba(102, 126, 234, 0.8);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 8px;
    font-size: 1.2rem;
    cursor: pointer;
    touch-action: manipulation;
}

@media (max-width: 768px) {
    .touch-controls {
        display: grid;
    }
}

/* Memory Game Styles */
#game-container {
    display: grid;
    gap: 10px;
    max-width: 500px;
    width: 100%;
    margin: 0 auto;
}

.memory-card {
    aspect-ratio: 1;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    cursor: pointer;
    transition: transform 0.3s ease, opacity 0.3s ease;
    box-shadow: var(--shadow);
    color: white;
    user-select: none;
}

.memory-card:hover {
    transform: scale(1.05);
}

.memory-card.flipped {
    background: var(--card-bg);
    color: var(--text-color);
    transform: rotateY(180deg);
}

.memory-card.matched {
    background: #48bb78;
    opacity: 0.7;
    cursor: default;
}

.memory-card.matched:hover {
    transform: none;
}

@media (max-width: 768px) {
    .memory-card {
        font-size: 2rem;
    }
}
