@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

        body {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            height: 100vh;
            background-color: #000;
            color: white;
            font-family: 'Press Start 2P', cursive;
            text-align: center;
            overflow: hidden;
        }

        html, body {
            overflow-x: hidden; 
            width: 100%;
            height: 100%;
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        
        .hidden {
            display: none;
        }
        
        .button {
            margin: 10px;
            padding: 10px 20px;
            background: transparent;
            color: white;
            border: 2px solid white;
            font-size: 14px;
            cursor: pointer;
            text-transform: uppercase;
            width: 133.469px;
        }
        
        .button:hover {
            background: white;
            color: black;
        }

        .game-container {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(50px, 1fr)); 
            gap: 5px;
            max-width: max-content; 
            max-height: 100vh; 
            padding: 10px;
            margin: auto;
            box-sizing: border-box;
            place-items: center;
            overflow-y: auto;
        }

        .grid-2 { grid-template-columns: repeat(2, 80px); }
        .grid-4 { grid-template-columns: repeat(4, 80px); }
        .grid-6 { grid-template-columns: repeat(6, 80px); }
        .grid-8 { grid-template-columns: repeat(8, 80px); }

        .card {
            width: 100%; 
            aspect-ratio: 1 / 1; 
            max-width: 80px;
            font-size: 1.5rem;
            cursor: pointer;
        }

        @media (max-width: 730px) {
            html, body {
                overflow-y: hidden;
            }

            .game-container {
                display: flex;
                flex-wrap: wrap;
                justify-content: center;
            }
        
            .card {
                max-width: 80px; 
                font-size: 1.2rem; 
            }
        }
        
        .card-inner {
            width: 100%;
            height: 100%;
            position: relative;
            transform-style: preserve-3d;
            transition: transform 0.6s ease-in-out;
        }
        
        .card.flipped .card-inner {
            transform: rotateY(180deg);
        }
        
        .card-front,
        .card-back {
            width: 100%;
            height: 100%;
            position: absolute;
            backface-visibility: hidden;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 24px;
            background: white;
            color: black;
            border-radius: 5px;
        }
        
        .card-front {
            background: #444;
        }
        
        .card-back {
            transform: rotateY(180deg);
            background: #666;
        }
        
        @keyframes fadeOut {
            to {
                opacity: 0;
                visibility: hidden;
                transform: scale(0.8);
            }
        }

        @keyframes pixelateFadeOut {
            0% {
                opacity: 1;
                filter: none;
                transform: scale(1);
            }
            25% {
                opacity: 0.8;
                filter: blur(1px);
            }
            50% {
                opacity: 0.5;
                filter: blur(3px);
            }
            75% {
                opacity: 0.2;
                filter: blur(6px);
            }
            100% {
                opacity: 0;
                filter: blur(10px);
                transform: scale(0.8);
            }
        }
        
        .matched {
            animation: pixelateFadeOut 0.6s forwards;
        }
        

        /* End message animation */
        #message {
            font-size: 36px;
            white-space: nowrap;
            opacity: 0;
        }

        .show-message {
            opacity: 1;
            animation: slide-in 1s forwards;
        }

        @keyframes slide-in {
            from {
                transform: translateX(100%);
                opacity: 0;
            }
            to {
                transform: translateX(0);
                opacity: 1;
            }
        }

        @keyframes pixelate {
            0% { transform: scale(1.02); filter: contrast(120%) brightness(110%); }
            50% { transform: scale(1.05); filter: contrast(90%) brightness(90%); } 
            100% { transform: scale(1.02); filter: contrast(120%) brightness(110%); } 
        }
        
        @keyframes scanline {
            0% { background-position: 0 0; }
            100% { background-position: 0 100px; }
        }
        
         .button {
            animation: pixelate 0.2s infinite alternate;
            background-image: linear-gradient(
                rgba(255,255,255,0.1) 50%,
                rgba(0,0,0,0.1) 50%
            );
            background-size: 100% 4px;
            animation: scanline 0.5s linear infinite, pixelate 0.2s infinite alternate, glitchColor 0.2s infinite alternate;
        }

        @keyframes glitchColor {
            0% { text-shadow: -2px 0 red, 2px 0 cyan; }
            50% { text-shadow: 2px 0 red, -2px 0 cyan; }
            100% { text-shadow: -2px 0 red, 2px 0 cyan; }
        }

        /* MusicButton */

        @keyframes dance {
            0% { transform: rotate(0deg) scale(1); }
            25% { transform: rotate(-10deg) scale(1.1); }
            50% { transform: rotate(10deg) scale(1); }
            75% { transform: rotate(-5deg) scale(1.05); }
            100% { transform: rotate(0deg) scale(1); }
        }
        
        .dancing {
            animation: dance 0.5s infinite alternate ease-in-out;
        }
        
        .music-button {
            position: absolute;
            top: 20px;
            right: 20px;
            width: 50px;
            height: 50px;
            background-color: rgba(255, 255, 255, 0.1);
            border: 2px solid white;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: 0.3s ease;
        }
        
        .music-button:hover {
            background-color: white;
        }
        
        .music-button span {
            font-size: 24px;
            color: white;
            transition: 0.3s ease;
        }
        
        .music-button:hover span {
            color: black;
        }

        /* Flash Wrong */

        @keyframes flashRed {
            0% { background-color: #000; }
            25% { background-color: red; }
            50% { background-color: #000; }
            75% { background-color: red; }
            100% { background-color: #000; }
        }
        
        .flash-red {
            animation: flashRed 0.8s ease-in-out;
        }

        /* Flash Success */

        @keyframes flashGreen {
            0% { background-color: #000; }
            25% { background-color: green; }
            50% { background-color: #000; }
            75% { background-color: green; }
            100% { background-color: #000; }
        }

        .flash-green {
            animation: flashGreen 0.8s ease-in-out;
        }

        /* gameShuffling */

        @keyframes fadeOut {
            0% { opacity: 1; transform: scale(1); }
            50% { opacity: 0; transform: scale(0.8); }
            100% { opacity: 0; transform: scale(0.8); }
        }
        
        @keyframes fadeIn {
            0% { opacity: 0; transform: scale(0.8); }
            50% { opacity: 0; transform: scale(0.8); }
            100% { opacity: 1; transform: scale(1); }
        }

        @keyframes shake {
            0%, 100% { transform: translateX(0); }
            25% { transform: translateX(-5px); }
            50% { transform: translateX(5px); }
            75% { transform: translateX(-5px); }
        }

        .game-container.shuffling {
            animation: shake 0.5s ease-in-out, fadeOut 0.5s ease-in-out;
        }

        .game-container.shuffled {
            animation: fadeIn 0.5s ease-in-out;
        }

        /* Loading Screen Animation */

        .loading-screen {
            position: fixed;
            top: 0;
            left: 0;
            width: 100vw;
            height: 100vh;
            background-color: black;
            display: flex;
            justify-content: center;
            align-items: center;
            color: white;
            font-size: 2rem;
            font-family: 'Press Start 2P', cursive;
            animation: glitch 1s infinite alternate;
            z-index: 9999;
            transition: opacity 1s ease-in-out;
        }
        
        .loading-screen.hidden {
            opacity: 0;
            pointer-events: none;
        }
        
        .loading-text {
            text-shadow: 
                -2px 0 red, 
                2px 0 cyan, 
                0 -2px yellow, 
                0 2px blue;
            animation: glitchLoad 1s infinite alternate;
        }
        
        @keyframes glitchLoad {
            0% {
                transform: translate(0);
            }
            25% {
                transform: translate(2px, -2px);
            }
            50% {
                transform: translate(-2px, 2px);
            }
            75% {
                transform: translate(2px, 2px);
            }
            100% {
                transform: translate(0);
            }
        }

        
        
        
        