:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #f59e0b;
    --success: #10b981;
    --danger: #ef4444;
    --dark: #1f2937;
    --darker: #111827;
    --light: #f3f4f6;
    --text: #374151;
    --text-light: #6b7280;
    --border: #e5e7eb;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Cairo', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    color: var(--primary);
    font-size: 2rem;
    font-weight: 700;
}

.home-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.home-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

/* Main Content */
.main {
    padding: 2rem 0;
}

.section {
    display: none;
}

.section.active {
    display: block;
}

/* Welcome Section */
.welcome {
    text-align: center;
    margin-bottom: 3rem;
    color: white;
}

.welcome h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.welcome p {
    font-size: 1.2rem;
    opacity: 0.9;
}

/* Games Grid */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
}

.game-card {
    background: white;
    border-radius: 20px;
    padding: 2rem;
    text-align: center;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s ease;
    cursor: pointer;
}

.game-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.game-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.game-card h3 {
    color: var(--primary);
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.game-card p {
    color: var(--text-light);
    margin-bottom: 1.5rem;
}

.play-btn {
    background: linear-gradient(45deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.play-btn:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow);
}

/* Game Sections */
.game-section {
    background: white;
    margin: 2rem 0;
    border-radius: 20px;
    padding: 2rem;
    box-shadow: var(--shadow-lg);
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.game-header h2 {
    color: var(--primary);
    font-size: 2rem;
}

.game-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.game-controls > div {
    background: var(--light);
    padding: 0.5rem 1rem;
    border-radius: 10px;
    font-weight: 600;
}

.control-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.control-btn:hover {
    background: var(--primary-dark);
}

/* Canvas Games */
canvas {
    border: 3px solid var(--primary);
    border-radius: 15px;
    display: block;
    margin: 0 auto;
    background: #000;
}

/* Puzzle Game */
.puzzle-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    max-width: 400px;
    margin: 0 auto;
    background: var(--primary);
    padding: 10px;
    border-radius: 15px;
}

.puzzle-tile {
    aspect-ratio: 1;
    background: white;
    border: none;
    border-radius: 10px;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--primary);
}

.puzzle-tile:hover {
    background: var(--light);
}

.puzzle-tile.empty {
    background: transparent;
    cursor: default;
}

/* Tic Tac Toe */
.tictactoe-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    max-width: 300px;
    margin: 0 auto;
    background: var(--primary);
    padding: 15px;
    border-radius: 15px;
}

.tictactoe-cell {
    aspect-ratio: 1;
    background: white;
    border: none;
    border-radius: 10px;
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--primary);
}

.tictactoe-cell:hover {
    background: var(--light);
}

.tictactoe-cell:disabled {
    cursor: not-allowed;
}

/* Memory Game */
.memory-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    max-width: 400px;
    margin: 0 auto;
}

.memory-card {
    aspect-ratio: 1;
    background: var(--primary);
    border: none;
    border-radius: 15px;
    font-size: 2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    color: white;
    position: relative;
    overflow: hidden;
}

.memory-card:hover {
    background: var(--primary-dark);
}

.memory-card.flipped {
    background: white;
    color: var(--primary);
    border: 3px solid var(--primary);
}

.memory-card.matched {
    background: var(--success);
    cursor: default;
}

/* Game Instructions */
.game-instructions {
    margin-top: 2rem;
    padding: 1rem;
    background: var(--light);
    border-radius: 10px;
    text-align: center;
}

/* Game Result */
.game-result {
    text-align: center;
    margin: 1rem 0;
    padding: 1rem;
    border-radius: 10px;
    font-size: 1.2rem;
    font-weight: bold;
}

.game-result.win {
    background: var(--success);
    color: white;
}

.game-result.draw {
    background: var(--secondary);
    color: white;
}

/* Footer */
.footer {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 2rem 0;
    text-align: center;
    margin-top: 3rem;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header h1 {
        font-size: 1.5rem;
    }
    
    .welcome h2 {
        font-size: 2rem;
    }
    
    .games-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .game-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .game-controls {
        justify-content: center;
    }
    
    canvas {
        max-width: 100%;
        height: auto;
    }
    
    .puzzle-board,
    .tictactoe-board,
    .memory-board {
        max-width: 90vw;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 10px;
    }
    
    .game-section {
        margin: 1rem 0;
        padding: 1rem;
    }
    
    .game-card {
        padding: 1.5rem;
    }
    
    .game-icon {
        font-size: 3rem;
    }
}
