*, *::before, *::after {
    box-sizing: border-box;
}

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

.hidden {
    display: none !important;
}
/* Existing styles... */

#instructions {
    margin-top: 30px;
    font-size: 1em;
    color: #888;
}

#final-score, #high-score {
    font-family: 'Press Start 2P', cursive;
    font-size: 1.5em;
    color: #fff;
    margin: 10px 0;
}

#preview-container {
    margin: 20px 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

#previewCanvas {
    border: 2px solid #444;
    background-color: #111;
    box-shadow: inset 0 0 15px rgba(0,0,0,0.5);}

body {
    font-family: 'Poppins', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    background-color: #1a1a1a;
    color: #fff;
    overflow: hidden;
    background-image: radial-gradient(circle, #333 1px, transparent 1px);
    background-size: 20px 20px;
}

#home-screen, #game-over-screen, #game-over-container {
    width: 80vw;
    max-width: 900px;
    height: 80vh;
    max-height: 600px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
}

#settings-button {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    color: #fff;
    transition: transform 0.3s ease-in-out;
}

#settings-button:hover {
    transform: rotate(90deg);
}

/* --- Modern Settings Panel --- */

#settings-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#settings-screen.open {
    opacity: 1;
    pointer-events: all;
}

#settings-container {
    background: #2c2c2c;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    width: 90%;
    max-width: 500px;
    position: relative;
}

#close-settings-button {
    background: none;
    border: none;
    color: #888;
    font-size: 2em;
    cursor: pointer;
    align-self: flex-end;
    padding: 10px 20px;
    transition: color 0.3s;
}

#close-settings-button:hover {
    color: #fff;
}

.setting-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 20px 15px;
    background-color: rgba(255, 255, 255, 0.05); /* Subtle background */
    border-radius: 12px;
    border: 1px solid #444;
    transition: background-color 0.3s, border-color 0.3s;
}

.setting-option:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: #666;
}

.setting-option label {
    font-size: 1.1em;
    color: #eee;
    font-weight: 500;
}

/* Custom styling for color inputs */
input[type="color"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 40px;
    height: 40px;
    background-color: transparent;
    border: none;
    cursor: pointer;
}
input[type="color"]::-webkit-color-swatch {
    border-radius: 50%;
    border: 2px solid #fff;
}
input[type="color"]::-moz-color-swatch {
    border-radius: 50%;
    border: 2px solid #fff;
}

/* Custom styling for select dropdown */
.select-container {
    position: relative;
    display: inline-block;
}

#theme-selection {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-color: #333;
    color: #fff;
    padding: 12px 45px 12px 20px;
    border-radius: 8px;
    border: 1px solid #555;
    cursor: pointer;
    font-family: 'Poppins', sans-serif;
    font-size: 1em;
    width: 150px; /* Give it a fixed width */
    transition: background-color 0.3s;
}

#theme-selection:hover {
    background-color: #444;
}

.select-container::after {
    content: '▼';
    font-size: 12px;
    position: absolute;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    color: #aaa;
    pointer-events: none;
}

#save-settings-button {
    font-family: 'Poppins', sans-serif;
    font-size: 1.2em;
    padding: 18px 30px;
    cursor: pointer;
    border: none;
    border-radius: 12px;
    background-color: #4dff4d;
    color: #111;
    font-weight: 600;
    transition: background-color 0.3s, transform 0.2s;
    width: 100%;
    margin-top: 30px;
    text-align: center;
}

#save-settings-button:hover {
    background-color: #fff;
    transform: scale(1.03);
}


#game-container {
    width: 80vw;
    max-width: 900px;
    text-align: center;
    background-color: #2c2c2c;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    position: relative;
    touch-action: none;
    -ms-touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: rgba(0,0,0,0);
    overflow: hidden;
}

#gameCanvas {
    box-sizing: content-box;
    border: 2px solid #444;
    background-color: #111;
    box-shadow: 0 0 20px rgba(77, 255, 77, 0.2), inset 0 0 15px rgba(0,0,0,0.5); /* Enhanced neon glow */
    touch-action: none;
    -ms-touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: rgba(0,0,0,0);
    overflow: hidden;
    transition: transform 0.1s; /* Smooth shake */
}

.shake {
    animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    perspective: 1000px;
}

@keyframes shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

.combo-text {
    position: absolute;
    font-family: 'Press Start 2P', cursive;
    color: #ffeb3b;
    font-size: 1.5em;
    pointer-events: none;
    animation: floatUp 1s ease-out forwards;
    text-shadow: 2px 2px 0 #000;
    z-index: 10;
}

@keyframes floatUp {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-50px) scale(1.5); }
}

#score-container {
    font-size: 2em;
    font-weight: 600;
    margin-top: 20px;
    color: #4dff4d;
}

#game-over-container h2 {
    font-family: 'Press Start 2P', cursive;
    font-size: 3em;
    color: #fff;
    text-shadow: 0 0 10px #ff00de, 0 0 20px #ff00de;
    animation: flicker 1.5s infinite alternate;
    margin-bottom: 20px;
}

@keyframes flicker {
    0%, 18%, 22%, 25%, 53%, 57%, 100% {
        text-shadow:
        0 0 4px #fff,
        0 0 11px #fff,
        0 0 19px #fff,
        0 0 40px #ff00de,
        0 0 80px #ff00de,
        0 0 90px #ff00de,
        0 0 100px #ff00de,
        0 0 150px #ff00de;
    }
    20%, 24%, 55% {
        text-shadow: none;
    }
}

#start-button, #restart-button ,#home-button {
    font-family: 'Press Start 2P', cursive;
    font-size: 1em;
    padding: 15px 30px;
    cursor: pointer;
    border: 2px solid #fff;
    border-radius: 10px;
    background-color: transparent;
    color: #fff;
    transition: all 0.3s ease;
    margin: 10px;
    text-transform: uppercase;
}

#start-button:hover, #restart-button:hover, #home-button:hover {
    background-color: #fff;
    color: #1a1a1a;
    box-shadow: 0 0 20px #fff;
} 

#instructions {
    margin-top: 30px;
    font-size: 1em;
    color: #888;
}

#final-score, #high-score {
    font-family: 'Press Start 2P', cursive;
    font-size: 1.5em;
    color: #fff;
    margin: 10px 0;
}
#difficulty-selection {
    width: 100%;
    margin: 20px 0;
    text-align: center;
}

#difficulty-selection label {
    font-size: 1.2em;
    margin-bottom: 15px;
    display: block;
}

.difficulty-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.difficulty-button {
    font-family: 'Poppins', sans-serif;
    font-size: 1em;
    padding: 10px 20px;
    cursor: pointer;
    border: 2px solid #444;
    border-radius: 10px;
    background-color: transparent;
    color: #fff;
    transition: all 0.3s ease;
}

.difficulty-button.active,
.difficulty-button:hover {
    background-color: #4dff4d;
    color: #111;
    border-color: #4dff4d;
}

@media (max-width: 768px) {
    #game-container {
        width: 90vw;
        padding: 20px;
    }

    #gameCanvas {
        width: 100%;
        height: auto;
    }

    #score-container {
        font-size: 1.5em;
    }

    #game-over-container h2 {
        font-size: 2em;
    }

    #start-button, #restart-button, #home-button {
        font-size: 1em;
        padding: 10px 20px;
    }

    #instructions {
        font-size: 0.9em;
    }
}

#mode-selection {
    margin: 20px 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#mode-selection label {
    font-size: 1.2em;
    margin-right: 10px;
}

#infinite-mode {
    width: 20px;
    height: 20px;
}

/* Modern Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: #4dff4d;
}

input:focus + .slider {
    box-shadow: 0 0 1px #4dff4d;
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}


/* --- Modern Pause Screen --- */

#pause-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    z-index: 100;

    /* Modern translucent background */
    background-color: rgba(26, 26, 26, 0.2) !important; /* Use important to override existing rules */
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
    
    /* Fade in animation */
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

#pause-screen h2 {
    font-size: 3.5em;
    color: #fff;
    font-weight: 600;
    margin-bottom: 10px;
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

#pause-screen p {
    font-size: 1.5em;
    color: #eee;
    margin-bottom: 40px;
}

#pause-screen button {
    font-family: 'Poppins', sans-serif;
    font-size: 1.2em;
    padding: 15px 40px;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 50px; /* Pill shape */
    font-weight: 600;
    transition: all 0.3s ease;
    margin: 10px;
    min-width: 200px;
}

#resume-button {
    background-color: #4dff4d;
    color: #111;
}

#resume-button:hover {
    background-color: #fff;
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(77, 255, 77, 0.5);
}

#pause-home-button {
    background-color: transparent;
    color: #fff;
    border-color: #fff;
}

#pause-home-button:hover {
    background-color: #fff;
    color: #111;
    transform: scale(1.05);
}