/* --- Global Variables & Reset --- */
:root {
    --bg-color: #f8fafc;
    --text-color: #0f172a;
    --surface-color: #ffffff;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.dark-mode {
    --bg-color: #0f172a;
    --text-color: #f8fafc;
    --surface-color: #1e293b;
    --border: #334155;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s, color 0.3s;
}

/* --- Navigation --- */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    color: var(--primary);
}

.nav-btn {
    background: transparent;
    color: var(--text-color);
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    transition: 0.2s;
    margin-left: 0.5rem;
}

.nav-btn:hover { background-color: var(--border); }
.hidden { display: none !important; }

/* --- Layout & Views --- */
main {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.view { display: none; text-align: center; }
.view.active { display: block; animation: fadeIn 0.4s ease; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Homepage UI --- */
.hero { margin-bottom: 3rem; }
.hero h1 { font-size: 2.5rem; margin-bottom: 0.5rem; }

.game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.game-card {
    background-color: var(--surface-color);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.2s;
    border: 1px solid var(--border);
}

.game-card:hover { transform: translateY(-5px); }

.card-thumb {
    height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    color: white;
}

.card-content { padding: 1.5rem; text-align: left; }
.card-content h3 { margin-bottom: 0.5rem; }
.card-content p { color: #64748b; margin-bottom: 1.5rem; font-size: 0.9rem; }

/* --- Buttons --- */
.play-btn, .action-btn {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: 0.2s;
}
.play-btn:hover, .action-btn:hover { background-color: var(--primary-hover); }
.action-btn { margin-top: 1.5rem; }

/* --- Game 1: Chess UI --- */
.chessboard {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    width: 100%;
    max-width: 400px;
    margin: 1.5rem auto;
    border: 4px solid var(--surface-color);
    box-shadow: var(--shadow);
}

.square {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    cursor: pointer;
    user-select: none;
}

.square.light { background-color: #f0d9b5; color: #000; }
.square.dark { background-color: #b58863; color: #000; }
.square.selected { background-color: rgba(255, 255, 51, 0.7); }
.square.highlight { position: relative; }
.square.highlight::after {
    content: ''; position: absolute;
    width: 25%; height: 25%;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 50%;
}

/* --- Game 2: Quiz UI --- */
.quiz-container {
    max-width: 600px;
    margin: 0 auto;
    background-color: var(--surface-color);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.quiz-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
}

#quiz-timer { font-weight: bold; color: #ef4444; }

.options-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-top: 1.5rem;
}

.option-btn {
    padding: 1rem;
    background-color: transparent;
    border: 2px solid var(--border);
    color: var(--text-color);
    border-radius: 8px;
    cursor: pointer;
    transition: 0.2s;
    font-size: 1rem;
}

.option-btn:hover { border-color: var(--primary); background-color: rgba(59, 130, 246, 0.1); }
.option-btn.correct { background-color: #10b981; color: white; border-color: #10b981; }
.option-btn.wrong { background-color: #ef4444; color: white; border-color: #ef4444; }

/* --- Game 3: 15-Puzzle UI --- */
.puzzle-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    width: 100%;
    max-width: 350px;
    margin: 1.5rem auto;
    background-color: var(--border);
    padding: 5px;
    border-radius: 8px;
}

.tile {
    aspect-ratio: 1;
    background-color: var(--surface-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.1s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.tile.empty { background-color: transparent; box-shadow: none; cursor: default; }
.tile:hover:not(.empty) { transform: scale(0.95); }
.solve-btn { background-color: #10b981; margin-left: 1rem; }