 :root {
            --bg-color-light: #f3e5f5;
            --card-bg-light: #ffffff;
            --text-color-light: #4a148c;
            --secondary-text-light: #7b1fa2;
            --primary-color: #6a4fe6; /* Purple */
            --border-color-light: #ce93d8;
            --card-back-color: #ba68c8; /* Purple */
            --card-text-color: #4a148c;
            --matched-card-color: #4CAF50; /* Green */
            --button-text-color: #ffffff;
            --hover-color: #9c27b0;
            --shadow: rgba(0, 0, 0, 0.1);
        }

        body.dark-mode {
            --bg-color-light: #263238;
            --card-bg-light: #37474f;
            --text-color-light: #eceff1;
            --secondary-text-light: #b0bec5;
            --border-color-light: #455a64;
            --card-back-color: #546e7a;
            --card-text-color: #eceff1;
            --hover-color: #607d8b;
            --shadow: rgba(0, 0, 0, 0.4);
        }

        /* --- Global Styles --- */
        body {
            font-family: 'Arial', sans-serif;
            background-color: var(--bg-color-light);
            color: var(--text-color-light);
            margin: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh; /* Ensures content takes full viewport height */
            transition: background-color 0.3s, color 0.3s;
            overflow-y: auto; /* Allow scrolling if content overflows */
        }

        /* --- Game Container --- */
        .game-container {
            background-color: var(--card-bg-light);
            border-radius: 15px;
            box-shadow: 0 10px 30px var(--shadow);
            padding: 30px;
            display: flex;
            flex-direction: column;
            align-items: center;
            width: 95%; /* Responsive width */
            max-width: 800px; /* Max width for larger screens */
            position: relative;
            min-height: 70vh; /* Minimum height for better spacing */
            margin: 20px 0; /* Add vertical margin for spacing on small screens */
            box-sizing: border-box; /* Include padding in element's total width and height */
        }

        h1 {
            color: var(--primary-color);
            margin-bottom: 5px;
            font-size: 2.2em;
        }

        p {
            color: var(--secondary-text-light);
            margin-bottom: 20px;
            text-align: center;
            font-size: 1.1em;
        }

        /* --- Game Information (Timer & Moves) --- */
        .game-info {
            width: 100%;
            display: flex;
            justify-content: space-around;
            margin-bottom: 20px;
            flex-wrap: wrap; /* Allows items to wrap on smaller screens */
            gap: 10px; /* Space between info items */
        }

        .game-info span {
            font-size: 1.2rem;
            font-weight: bold;
            color: var(--text-color-light);
        }

        /* --- Memory Grid Container --- */
        .memory-grid-container {
            width: 100%;
            display: flex;
            justify-content: center;
            margin-bottom: 25px; /* Space below the grid */
        }

        .memory-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
            gap: 15px;
            padding: 15px;
            background-color: var(--bg-color-light);
            border-radius: 8px;
            box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.05);
            max-width: 600px; /* Max width for the grid */
            width: 100%; /* Ensures it takes full width of its container up to max-width */
        }

        /* --- Memory Card Styles --- */
        .memory-card {
            width: 100%;
            padding-top: 100%; /* Makes the card a perfect square */
            position: relative;
            cursor: pointer;
            perspective: 1000px; /* For 3D flip effect */
            background-color: transparent;
            border-radius: 8px;
        }

        .card-inner {
            position: absolute;
            width: 100%;
            height: 100%;
            top: 0;
            left: 0;
            transform-style: preserve-3d;
            transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275); /* Springy transition */
            border-radius: 8px;
            box-shadow: 0 4px 10px var(--shadow);
        }

        .memory-card.flipped .card-inner {
            transform: rotateY(180deg);
        }

        .card-front, .card-back {
            position: absolute;
            width: 100%;
            height: 100%;
            top: 0;
            left: 0;
            backface-visibility: hidden; /* Hides the back of element when facing away */
            border-radius: 8px;
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 1em; /* Adjusted for better readability */
            text-align: center;
            padding: 8px; /* Increased padding */
            box-sizing: border-box;
            word-break: break-word;
            line-height: 1.3;
            font-weight: bold;
        }

        .card-back {
            background-color: var(--card-back-color);
            color: var(--button-text-color);
            transform: rotateY(0deg);
            transition: background-color 0.3s;
        }
        .card-back .material-icons {
            font-size: 2.8em; /* Slightly larger icon */
        }

        .card-front {
            background-color: var(--card-bg-light);
            color: var(--card-text-color);
            transform: rotateY(180deg);
            border: 1px solid var(--border-color-light);
        }
        
        .memory-card.matched .card-front {
            background-color: var(--matched-card-color);
            color: white;
            box-shadow: 0 0 15px rgba(76, 175, 80, 0.5); /* Glowing effect for matched cards */
        }

        /* --- Game Controls (Buttons) --- */
        .game-controls {
            display: flex;
            gap: 20px; /* Space between buttons */
            flex-wrap: wrap;
            justify-content: center;
            margin-top: 10px; /* Space above controls */
        }

        .btn {
            padding: 12px 25px; /* Larger padding for better touch targets */
            border: none;
            border-radius: 25px;
            cursor: pointer;
            font-size: 1.1rem;
            font-weight: bold;
            transition: background-color 0.2s, transform 0.1s;
        }

        .btn-primary {
            background-color: var(--primary-color);
            color: var(--button-text-color);
        }

        .btn-primary:hover {
            background-color: var(--hover-color);
            transform: translateY(-2px); /* Slight lift on hover */
        }

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

        /* --- Game Over Overlay --- */
        .game-overlay {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.8); /* Darker overlay */
            color: white;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            font-size: 2.5em; /* Larger text */
            font-weight: bold;
            border-radius: 15px;
            z-index: 1000; /* Higher z-index to cover everything */
            opacity: 0;
            visibility: hidden;
            transition: opacity 0.5s ease-in-out, visibility 0.5s ease-in-out;
            text-shadow: 2px 2px 4px rgba(0,0,0,0.5); /* Text shadow for readability */
        }

        .game-overlay.active {
            opacity: 1;
            visibility: visible;
        }
        .game-overlay .material-icons {
            font-size: 5em; /* Very large icon for celebration */
            margin-bottom: 15px;
            color: #FFD700; /* Gold color for celebration icon */
        }
        .game-overlay #finalTime,
        .game-overlay #finalMoves {
            font-size: 0.9em;
            margin-top: 10px;
            color: #f0f0f0;
        }

        /* --- Theme Toggle Button --- */
        .theme-toggle {
            position: absolute;
            top: 20px;
            right: 20px;
            background: var(--card-bg-light);
            border: 1px solid var(--border-color-light);
            border-radius: 50%;
            width: 45px; /* Slightly larger toggle */
            height: 45px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: background-color 0.3s, border-color 0.3s, transform 0.2s;
            z-index: 1010; /* Above overlay */
            box-shadow: 0 2px 4px var(--shadow);
        }
        
        .theme-toggle .material-icons {
            font-size: 24px; /* Larger icon */
            color: var(--text-color-light);
            transition: color 0.3s;
        }

        .theme-toggle:hover {
            background-color: var(--bg-color-light);
            transform: scale(1.05);
        }
        
        /* --- Modal for Game Messages --- */
        .modal {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.6);
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 1000;
        }
        .modal-content {
            background-color: var(--card-bg-light);
            padding: 30px;
            border-radius: 12px;
            text-align: center;
            box-shadow: 0 10px 20px var(--shadow);
            max-width: 400px;
            width: 80%;
        }
        .modal-content h3 {
            margin: 0 0 10px;
            font-size: 1.5rem;
            color: var(--primary-color);
        }
        .modal-content p {
            font-size: 1rem;
            margin-bottom: 20px;
        }

        /* --- Explore More Section --- */
        .resources-section {
            width: 100%;
            margin-top: 30px;
            padding-top: 20px;
            border-top: 1px solid var(--border-color-light);
            text-align: center;
        }
        .resources-section h3 {
            color: var(--primary-color);
            margin-bottom: 15px;
        }
        .resources-list {
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            gap: 15px;
            list-style: none;
            padding: 0;
        }
        .resources-list a {
            padding: 10px 15px;
            border-radius: 8px;
            background-color: var(--card-bg-light);
            border: 1px solid var(--border-color-light);
            text-decoration: none;
            color: var(--text-color-light);
            transition: background-color 0.2s, transform 0.2s;
            display: flex;
            align-items: center;
            font-weight: bold;
        }
        .resources-list a:hover {
            transform: translateY(-2px);
            background-color: var(--hover-color);
            color: white;
        }
        .resources-list a:hover .material-icons {
             color: white;
        }
        .resources-list a .material-icons {
            margin-right: 8px;
            color: var(--primary-color);
            transition: color 0.2s;
        }