        /* --- ROOT VARIABLES & GENERAL SETUP --- */
        :root {
            --bg-color: #f4f7fc;
            --primary-color: #367cff;
            --secondary-color: #6a11cb;
            --accent-color: #ff6b6b;
            --text-color: #343a40;
            --light-text-color: #f8f9fa;
            --container-bg: rgba(255, 255, 255, 0.9);
            --border-color: #dee2e6;
            --shadow-color: rgba(0, 0, 0, 0.08);
            --success-color: #28a745;
            --error-color: #dc3545;
            --font-display: 'Poppins', sans-serif;
            --font-mono: 'Roboto Mono', monospace;
        }

        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }

        html {
            scroll-behavior: smooth;
        }

        body {
            font-family: var(--font-display);
            background-color: var(--bg-color);
            color: var(--text-color);
            overflow: hidden;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            text-align: center;
        }

        #background-canvas {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: -1;
        }
        
        /* --- MAIN CONTAINER & LAYOUT --- */
        .main-container {
            width: 98%;
            max-width: 1200px;
            height: 95vh;
            max-height: 800px;
            background: var(--container-bg);
            border: 1px solid var(--border-color);
            border-radius: 24px;
            box-shadow: 0 15px 40px var(--shadow-color);
            backdrop-filter: blur(15px);
            -webkit-backdrop-filter: blur(15px);
            display: flex;
            overflow: hidden;
            animation: fadeIn 1s ease-out;
        }

        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(20px); }
            to { opacity: 1; transform: translateY(0); }
        }

        .sidebar {
            width: 260px;
            background-color: #fff;
            border-right: 1px solid var(--border-color);
            padding: 2rem 1rem;
            display: flex;
            flex-direction: column;
            flex-shrink: 0;
        }

        .sidebar-header {
            font-family: var(--font-display);
            font-size: 1.8rem;
            font-weight: 700;
            color: var(--primary-color);
            margin-bottom: 2rem;
            text-align: left;
        }

        .sidebar-nav a {
            display: flex;
            align-items: center;
            padding: 0.9rem 1rem;
            margin-bottom: 0.5rem;
            border-radius: 10px;
            color: #5a6a85;
            text-decoration: none;
            font-weight: 600;
            transition: all 0.2s ease;
        }
        .sidebar-nav a:hover {
            background-color: var(--bg-color);
            color: var(--primary-color);
        }
        .sidebar-nav a.active {
            background-color: var(--primary-color);
            color: var(--light-text-color);
            box-shadow: 0 4px 10px rgba(54, 124, 255, 0.3);
        }
        .sidebar-nav a svg {
            width: 22px;
            height: 22px;
            margin-right: 1rem;
        }

        .content-area {
            flex-grow: 1;
            padding: 2rem;
            overflow-y: auto;
        }

        .page {
            display: none;
        }
        .page.active {
            display: block;
            animation: slideIn 0.5s ease-out;
        }
        
        @keyframes slideIn {
            from { opacity: 0; transform: translateX(10px); }
            to { opacity: 1; transform: translateX(0); }
        }

        /* --- HEADER & PLAYER STATS --- */
        .page-header {
            font-size: 2.2rem;
            font-weight: 700;
            margin-bottom: 1.5rem;
            text-align: left;
        }
        .page-subheader {
            font-size: 1.1rem;
            color: #6c757d;
            margin-bottom: 2rem;
            text-align: left;
        }

        .player-stats-card {
            background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
            color: var(--light-text-color);
            padding: 1.5rem;
            border-radius: 16px;
            margin-bottom: 2rem;
            box-shadow: 0 8px 25px rgba(106, 17, 203, 0.2);
        }
        .player-level {
            font-family: var(--font-mono);
            font-size: 1.2rem;
            font-weight: 700;
        }
        .xp-bar-container {
            height: 12px;
            background-color: rgba(255,255,255,0.2);
            border-radius: 6px;
            margin: 0.5rem 0;
            overflow: hidden;
        }
        .xp-bar {
            width: 0%;
            height: 100%;
            background-color: var(--accent-color);
            border-radius: 6px;
            transition: width 0.5s ease-out;
        }
        .xp-text {
            font-size: 0.8rem;
            font-family: var(--font-mono);
            text-align: right;
        }

        /* --- GAME GRID & BUTTONS --- */
        .game-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 1.5rem;
        }
        .game-card {
            background-color: #fff;
            border: 1px solid var(--border-color);
            border-radius: 16px;
            padding: 1.5rem;
            transition: all 0.3s ease;
            cursor: pointer;
        }
        .game-card:hover {
            transform: translateY(-8px);
            box-shadow: 0 12px 25px var(--shadow-color);
        }
        .game-card h3 {
            font-size: 1.4rem;
            margin-bottom: 0.5rem;
        }
        .game-card p {
            font-size: 0.95rem;
            color: #6c757d;
            min-height: 40px;
        }
        .game-card .play-btn {
            margin-top: 1rem;
            background-color: var(--primary-color);
            color: white;
            border: none;
            padding: 0.6rem 1.2rem;
            border-radius: 8px;
            font-weight: 600;
            cursor: pointer;
        }

        /* --- MODAL STYLES --- */
        .game-modal {
            position: fixed; top: 0; left: 0; width: 100%; height: 100%;
            background-color: rgba(0,0,0,0.6);
            display: none; justify-content: center; align-items: center;
            z-index: 1000; animation: fadeIn 0.3s ease;
        }
        .game-modal.active { display: flex; }
        .modal-content {
            background: var(--bg-color); padding: 2rem; border-radius: 16px;
            width: 90%; max-width: 600px;
            box-shadow: 0 10px 40px rgba(0,0,0,0.2);
            position: relative;
        }
        .modal-close-btn {
            position: absolute; top: 1rem; right: 1rem;
            background: none; border: none; font-size: 1.8rem;
            cursor: pointer; color: #6c757d;
        }
        .modal-content h2 {
            font-size: 1.8rem; margin-bottom: 1.5rem; color: var(--primary-color);
        }
        .game-info {
            display: flex; justify-content: space-between;
            font-family: var(--font-mono); margin-bottom: 1rem; font-size: 1.2rem;
            padding: 0.8rem; background-color: #e9ecef; border-radius: 8px;
        }
        .feedback {
            margin-top: 1rem; font-size: 1.1rem; height: 25px; font-weight: 600;
        }
        .feedback.correct { color: var(--success-color); }
        .feedback.incorrect { color: var(--error-color); }
        
        /* --- GAME-SPECIFIC STYLES --- */
        #math-problem, #scrambled-word, #logic-statement {
            font-size: 2rem; font-family: var(--font-mono); color: var(--secondary-color);
            margin: 2rem 0; background-color: #fff; padding: 1rem; border-radius: 8px;
            border: 1px solid var(--border-color);
        }
        .modal-content input {
            width: 100%; padding: 0.8rem; font-size: 1.5rem;
            background-color: #fff; border: 2px solid #ced4da; border-radius: 10px;
            color: var(--text-color); text-align: center; font-family: var(--font-mono);
        }
        #reaction-area {
            width: 100%; height: 250px; background-color: #6c757d; border-radius: 16px;
            position: relative; cursor: pointer;
        }
        .reaction-target {
            width: 60px; height: 60px; background-color: var(--accent-color);
            border-radius: 50%; position: absolute;
            transform: scale(0); animation: popIn 0.2s forwards;
        }
        @keyframes popIn {
            to { transform: scale(1); }
        }
        #memory-grid {
            display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
            margin: 1.5rem auto; width: 100%; max-width: 400px;
        }
        .memory-tile {
            width: 100%; padding-bottom: 100%; background-color: #e9ecef;
            border: 2px solid #ced4da; border-radius: 10px; cursor: pointer;
            transition: all 0.2s ease;
        }
        .memory-tile.active { background-color: var(--primary-color); }
        .logic-options { display: flex; justify-content: center; gap: 1rem; margin-top: 1rem; }
        .logic-btn { font-size: 1.2rem; padding: 0.8rem 2rem; font-weight: 600; border-radius: 8px; }
        .logic-btn.true { background-color: var(--success-color); color: white; }
        .logic-btn.false { background-color: var(--error-color); color: white; }
        
        /* --- DASHBOARD & ACHIEVEMENTS --- */
        .dashboard-grid {
            display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem;
        }
        .chart-container {
            background-color: #fff; padding: 1.5rem; border-radius: 16px;
            border: 1px solid var(--border-color);
        }
        .achievements-grid {
            display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 1rem;
        }
        .achievement-card {
            background-color: #e9ecef; padding: 1rem; border-radius: 12px;
            opacity: 0.5; border: 2px dashed #adb5bd;
        }
        .achievement-card.unlocked {
            opacity: 1; background-color: var(--success-color); color: white;
            border: 2px solid var(--success-color);
        }
        .achievement-card h4 { font-size: 1rem; }
        .achievement-card p { font-size: 0.8rem; }
        
        /* --- UTILITY & RESPONSIVE --- */
        .toast {
            position: fixed; bottom: -100px; left: 50%;
            transform: translateX(-50%); background-color: var(--secondary-color);
            color: white; padding: 1rem 2rem; border-radius: 8px;
            box-shadow: 0 5px 15px rgba(0,0,0,0.2);
            transition: bottom 0.5s ease-in-out; z-index: 2000;
        }
        .toast.show { bottom: 20px; }
        
        @media (max-width: 992px) {
            .main-container { flex-direction: column; height: auto; max-height: none; }
            .sidebar { width: 100%; height: auto; border-right: none; border-bottom: 1px solid var(--border-color); flex-direction: row; justify-content: space-around; padding: 0.5rem; }
            .sidebar-header { display: none; }
            .sidebar-nav { display: flex; width: 100%; }
            .sidebar-nav a { flex-grow: 1; justify-content: center; margin: 0.2rem; }
            .sidebar-nav a span { display: none; }
            .dashboard-grid { grid-template-columns: 1fr; }
        }
        @media (max-width: 480px) {
            .game-grid { grid-template-columns: 1fr; }
        }