:root {
            --game-bg: #000;
            --wall-color: #0b0b0b;
            --wall-inner: #96a29c;
            --score-color: #fff;
            --mission-bg:   #FFF9DB;  /* Cream background */
            --mission-text: #333333;  /* Dark grey text */
            --mission-border: #E0D7C6; /* Soft taupe for borders */
            --button-bg: #A8D5BA;        /* Mint green buttons */
            --button-hover: #84C8A2;     /* Slightly darker mint for hover */
            --font-main: 'Comic Neue', "Comic Sans MS", cursive, sans-serif;
        }

        body {
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            background-color: #111;
            font-family: 'Arial', sans-serif;
            overflow: hidden;
            color: #fff;
        }

        /* Loading screen */
        #loading-screen {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(135deg,#222, #444);
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            z-index: 1000;
            color: white;
        }

        #loading-text {
            font-size: 2.5em;
            margin-bottom: 30px;
            font-family: 'Fredoka One', cursive;
            text-shadow: 3px 3px 0 rgba(0,0,0,0.2);
        }

        #loading-bar-container {
            width: 80%;
            max-width: 500px;
            height: 30px;
            background: rgba(255, 255, 255, 0.3);
            border-radius: 15px;
            overflow: hidden;
            box-shadow: 0 5px 15px rgba(0,0,0,0.2);
        }

        #loading-bar {
            height: 100%;
            width: 0%;
            background: linear-gradient(45deg, #ffcc00,#2121de);
            border-radius: 15px;
            transition: width 0.5s;
        }

        /* Animations */
        @keyframes fadeIn {
            from { opacity: 0; }
            to { opacity: 10; }
        }

        @keyframes slideIn {
            from { transform: translateY(50px); opacity: 0; }
            to { transform: translateY(0); opacity: 1; }
        }

        .fade-in {
            animation: fadeIn 0.5s forwards;
        }

        .slide-in {
            animation: slideIn 0.5s forwards;
        }

        .game-container {
            position: relative;
            width: 100%;
            max-width: 800px;
            margin: 0 auto;
            box-shadow: 0 0 50px rgba(255, 255, 0, 0.3);
            border-radius: 10px;
            overflow: hidden;
        }

        .header {
            background-color: #000;
            padding: 15px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-bottom: 2px solid #2121de;
        }

        .title {
            font-size: 24px;
            font-weight: bold;
            color: #ffcc00;
            text-shadow: 0 0 10px rgba(255, 204, 0, 0.7);
        }

        .score-container {
            display: flex;
            gap: 20px;
        }

        .score, .kids-count {
            background-color: whitesmoke;
            padding: 8px 15px;
            border-radius: 20px;
            font-size: 18px;
            font-weight: bold;
            color: var(--game-bg);
            box-shadow: 0 0 10px rgba(33, 33, 222, 0.7);
        }

        /* Instructions */
        #instructions {
            position: absolute;
            bottom: 20px;
            right: 20px;
            background: rgba(196, 183, 183, 0.8);
            padding: 13px;
            border-radius: 15px;
            color: white;
            font-size: 1.1em;
            max-width: 300px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
            z-index: 10;
            border-left: 5px solid var(--accent-color);
        }

        #game-board {
            background-color: var(--game-bg);
            display: grid;
            grid-template-columns: repeat(20, 1fr);
            grid-template-rows: repeat(20, 1fr);
            width: 100%;
            aspect-ratio: 1/1;
            position: relative;
        }

        .wall {
            background-color: var(--wall-color);
            border: 2px solid var(--wall-inner);
            box-sizing: border-box;
            border-radius: 2px;
        }
        .kid {
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 1.6vw;
            animation: pulse 0.8s linear infinite;
        }

        .pacman {
            font-size: 1.6vw;
            display: flex;
            justify-content: center;
            align-items: center;
            width: 100%;
            height: 100%;
            position: relative;
            animation: pulse 0.5s linear infinite;
        }

        .gem {
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 1.6vw;
            animation: gemGlow 1s infinite alternate;
        }
        .death-screen {
            position: absolute;
            top: 0; left: 0; width: 100%; height: 100%;
            background-color: rgba(0, 0, 0, 0.9);
            display: flex; flex-direction: column;
            justify-content: center; align-items: center;
            color: #ff3b3b; font-family: 'Arial', sans-serif;
            z-index: 300;
            opacity: 0; transition: opacity 0.3s ease-in-out;
            pointer-events: none;
            }
            .death-screen.show {
            opacity: 1;
            pointer-events: auto;
            }
            .death-screen h2 {
            font-size: 48px;
            margin-bottom: 20px;
            text-shadow: 0 0 10px rgba(255, 59, 59, 0.7);
            }
            .death-screen p {
            font-size: 24px;
        }


        .mission-box {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background-color: var(--mission-bg);
            border: 3px solid var(--mission-border);
            border-radius: 15px;
            padding: 30px;
            width: 70%;
            max-width: 500px;
            z-index: 100;
            box-shadow: 0 0 30px rgba(255, 184, 174, 0.5);
            display: none;
        }

        .mission-title {
            font-size: 24px;
            margin-bottom: 50px;
            color: #FFB347; 
            text-align: center;
        }

        .mission-content {
            font-size: 18px;
            margin-bottom: 25px;
            line-height: 1.5;
            color: var(--mission-text);
        }
        .letter-grid{
            color: black;
            display: grid;
            grid-template-columns: repeat(5, 1fr);
            gap: 5px;
            text-align: center;
            font-size: 1.2em;
            line-height: 1.4em;
            margin: 15px 0;
        }
        .mission-timer {
            text-align: center;
            font-size: 1.5em;
            margin-bottom: 60px;
            color: #FF6347; /* Tomato color for timer */
            font-weight: bold;
        }
        .mission-controls {
            display: flex;
            justify-content: center;
            gap: 10px;
        }
        .start-button, .mission-button {
            background-color: var(--button-bg);
            color: white;
            border: none;
            padding: 12px 25px;
            font-size: 18px;
            border-radius: 25px;
            cursor: pointer;
            display: block;
            margin: 0 auto;
            transition: all 0.3s ease;
            margin-bottom: 50px;
        }
        .mission-button:hover {
            background-color: var(--button-hover);
            transform: scale(1.05);
        }
        .start-button:hover {
            background-color: var(--button-hover);
            transform: scale(1.05);
        }
            .mission-guide {
            text-align: center;
            font-size: 1.0em;
            color: black;
        }


        .game-over {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.8);
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            z-index: 200;
            display: none;
        }

        .game-over h2 {
            font-size: 48px;
            color: #ffcc00;
            margin-bottom: 20px;
            text-shadow: 0 0 10px rgba(255, 204, 0, 0.7);
        }

        .game-over p {
            font-size: 24px;
            color: #fff;
            margin-bottom: 30px;
        }

        .restart-button {
            background-color: #ffcc00;
            color: #000;
            border: none;
            padding: 15px 30px;
            font-size: 20px;
            border-radius: 30px;
            cursor: pointer;
            font-weight: bold;
            transition: all 0.3s ease;
            text-decoration: none;
        }

        .restart-button:hover {
            background-color: #fff;
            transform: scale(1.1);
        }

        @keyframes chomp {
            0% {
                clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
            }
            25% {
                clip-path: polygon(0 0, 100% 50%, 100% 100%, 0 100%);
            }
            50% {
                clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
            }
            75% {
                clip-path: polygon(0 0, 100% 0, 100% 50%, 0 100%);
            }
            100% {
                clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
            }
        }

        @keyframes pulse {
            0% {
                transform: scale(0.9);
                opacity: 0.7;
            }
            100% {
                transform: scale(1.1);
                opacity: 1;
            }
        }

        @keyframes gemGlow {
            0% {
                filter: drop-shadow(0 0 5px rgba(0, 255, 255, 0.7));
                transform: scale(1);
            }
            100% {
                filter: drop-shadow(0 0 15px rgba(0, 255, 255, 1));
                transform: scale(1.2);
            }
        }
        .ghost {
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 1.6vw;
            animation: float 1s ease-in-out infinite alternate;
            }

            @keyframes float {
            from { transform: translateY(0); }
            to   { transform: translateY(-10%); }
        }

        /* Touch controls styling */
        #touch-controls {
            display: none;
            position: fixed;
            bottom: 20px;
            right: 20px;
            width: 20vw;
            height: 20vw;
        }

        .touch-btn {
            position: absolute;
            width: 6vw;
            height: 6vw;
            font-size: 3vw;
            background-color: #ffcc00;
            color: #000;
            border: none;
            border-radius: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
        }

        #up-btn {
            top: 0;
            left: 7vw;
        }

        #left-btn {
            top: 7vw;
            left: 0;
        }

        #down-btn {
            bottom: 0;
            left: 7vw;
        }

        #right-btn {
            top: 7vw;
            right: 0;
        }

        @media (max-width: 1024px) {
            #touch-controls {
                display: block;
            }

            #instructions {
                position: fixed;
                top: 10px;
                left: 10px;
                right: 10px;
                bottom: auto;
                width: auto;
                max-width: none;
                background: rgba(0, 0, 0, 0.7);
                padding: 10px;
                font-size: 0.9em;
                z-index: 10;
                text-align: center;
            }
        }