* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body {
    background-color: #1a1a1a;
    font-family: 'Arial', sans-serif;
    color: #00ff00;
}

.game-wrapper {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    min-height: 100%;
}

@keyframes rainbow {
    0% { color: #ff0000; } /* Rojo */
    14% { color: #ff7f00; } /* Naranja */
    28% { color: #ffff00; } /* Amarillo */
    42% { color: #00ff00; } /* Verde */
    57% { color: #0000ff; } /* Azul */
    71% { color: #8b00ff; } /* Violeta */
    85% { color: #ff00ff; } /* Magenta */
    100% { color: #ff0000; } /* Vuelve a rojo */
}

.game-title {
    font-family: 'Press Start 2P', cursive; /* Fuente estilo pixel art */
    font-size: 2.5rem; /* Reducido de 2.5rem */
    text-align: center;
    margin: 0 20px; /* Reducido de 20px */
    text-transform: uppercase;
    letter-spacing: 1px; /* Reducido de 2px */
    animation: rainbow 8s linear infinite;
    text-shadow: 
        1px 1px 0 #000,
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000;
    margin-right: 10px;  /* Espacio entre el título y la imagen */
}

@media (max-width: 500px) {
    .game-title {
        font-size: 1.2rem; /* Reducido de 1.8rem */
    }
}

#score, #message {
    margin-top: 0.5rem;
    font-size: 1.2rem;
    text-align: center;
}

.button-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
}

.button-container button {
    width: 40px;
    height: 40px;
    font-size: 20px;
    background-color: #333;
    color: #00ff00;
    border: 1px solid #00ff00;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
}

.button-container button:hover {
    background-color: #444;
    box-shadow: 0 0 5px #00ff00;
}

.button-container button:active {
    transform: scale(0.95);
}

@media (max-width: 500px) {
    .button-container button {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }
}

#pauseButton, #soundButton, #instructionsButton {
    width: 40px;
    height: 40px;
    font-size: 18px;
    background-color: #333;
    color: #00ff00;
    border: 1px solid #00ff00;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

#pauseButton:hover, #soundButton:hover, #instructionsButton:hover {
    background-color: #444;
    box-shadow: 0 0 5px #00ff00;
}

#pauseButton:active, #soundButton:active, #instructionsButton:active {
    transform: scale(0.95);
}

@media (max-width: 500px) {
    #pauseButton, #soundButton, #instructionsButton {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
}

#touch-controls {
    display: none; /* Hide by default */
    justify-content: center;
    align-items: center;
    margin-top: 10px;
}

.d-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 3px; /* Reduced spacing */
    width: 120px; /* Reduced overall size */
    height: 120px; /* Added to maintain aspect ratio */
}

.d-pad .direction-btn {
    width: 40px; /* Slightly smaller buttons */
    height: 40px;
    border-radius: 50%;
    border: none;
    background-color: #4CAF50;
    color: white;
    font-size: 18px; /* Slightly smaller font */
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    transition: background-color 0.3s ease;
}

#up { grid-area: 1 / 2 / 2 / 3; }
#left { grid-area: 2 / 1 / 3 / 2; }
#right { grid-area: 2 / 3 / 3 / 4; }
#down { grid-area: 3 / 2 / 4 / 3; }

.d-pad .direction-btn:active {
    background-color: #45a049;
}

@media (max-width: 768px) {
    body.touch-device #touch-controls {
        display: flex; /* Show only on touch devices with smaller screens */
    }
}

@media (max-height: 600px) {
    .game-frame {
        max-height: 40vh;
    }

    #score, #message {
        margin-top: 0.3rem;
        font-size: 1rem;
    }

    .button-container {
        margin-top: 0.3rem;
    }

    #pauseButton, #soundButton {
        padding: 0.3rem;
        font-size: 0.9rem;
    }

    .d-pad {
        width: 150px;
        height: 150px;
    }

    .d-pad button {
        font-size: 1.5rem;
    }
}

#scoreHistoryContainer {
    margin-top: 20px;
    background-color: rgba(0, 0, 0, 0.8);
    border: 2px solid #00ff00;
    border-radius: 10px;
    padding: 10px;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 0 10px #00ff00;
}

#scoreHistoryContainer h2 {
    color: #00ff00;
    text-align: center;
    margin-bottom: 10px;
    font-family: 'Press Start 2P', cursive;
    text-transform: uppercase;
    text-shadow: 0 0 5px #00ff00;
}

#scoreHistory {
    max-height: 200px;
    overflow-y: auto;
    padding-right: 10px;
}

#scoreHistory::-webkit-scrollbar {
    width: 8px;
}

#scoreHistory::-webkit-scrollbar-track {
    background: #001a00;
    border-radius: 4px;
}

#scoreHistory::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 4px;
}

#scoreHistory::-webkit-scrollbar-thumb:hover {
    background: #00cc00;
}

#scoreHistory ul {
    list-style-type: none;
    padding: 0;
}

#scoreHistory li {
    color: #ffffff;
    margin-bottom: 10px;
    padding: 5px;
    background-color: rgba(0, 255, 0, 0.1);
    border-radius: 5px;
    font-family: 'Courier New', monospace;
    transition: all 0.3s ease;
}

#scoreHistory li:hover {
    background-color: rgba(0, 255, 0, 0.2);
    transform: translateX(5px);
}

#scoreHistory li::before {
    content: '🐍';
    margin-right: 5px;
}

/* Estilos para el scroll */
.game-wrapper::-webkit-scrollbar {
    width: 10px;
}

.game-wrapper::-webkit-scrollbar-track {
    background: #001a00;
}

.game-wrapper::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 5px;
}

.game-wrapper::-webkit-scrollbar-thumb:hover {
    background: #00cc00;
}

@media (max-width: 500px) {
    .canvas-container {
        width: 300px;
        height: 300px;
    }
}

/* ... otros estilos ... */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
}

.modal-content {
    background-color: #1a1a1a;
    color: #00ff00;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #00ff00;
    border-radius: 10px;
    width: 80%;
    max-width: 500px;
    box-shadow: 0 0 20px #00ff00;
}

.close {
    color: #00ff00;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: #00cc00;
    text-decoration: none;
}

.modal-content h2 {
    margin-top: 0;
    text-align: center;
}

.modal-content ul {
    padding-left: 20px;
}

.modal-content li {
    margin-bottom: 10px;
}

@media (max-width: 500px) {
    .modal-content {
        margin: 10% auto;
        width: 90%;
        padding: 15px;
    }
}

.canvas-container {
    width: 400px; /* Tamaño fijo */
    height: 400px; /* Tamaño fijo */
    margin: 10px auto;
    border: 2px solid #00ff00;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
}

#gameCanvas {
    width: 100%;
    height: 100%;
    background-color: #000;
    transition: background-color 0.5s ease;
}

@media (max-width: 500px) {
    .canvas-container {
        width: 300px; /* Tamaño más pequeño pero fijo para móviles */
        height: 300px;
    }
}

.title-container {
    display: flex;
    align-items: center;
    justify-content: center;
    
}

.snake-icon {
    width: 50px;
    height: 50px;
    transition: transform 0.3s ease;
}

.snake-left {
    transform: scaleX(-1);
}

.snake-right:hover, .snake-left:hover {
    transform: scale(1.1);
}

.snake-left:hover {
    transform: scaleX(-1) scale(1.1);
}

/* Añadimos un pequeño margen superior al contenedor del canvas si es necesario */
.canvas-container {
    margin-top: 10px;
}

#touch-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 10px;
}

.d-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 3px; /* Reduced spacing */
    width: 120px; /* Reduced overall size */
    height: 120px; /* Added to maintain aspect ratio */
}

.d-pad .direction-btn {
    width: 40px; /* Slightly smaller buttons */
    height: 40px;
    border-radius: 50%;
    border: none;
    background-color: #4CAF50;
    color: white;
    font-size: 18px; /* Slightly smaller font */
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    transition: background-color 0.3s ease;
}

#up { grid-area: 1 / 2 / 2 / 3; }
#left { grid-area: 2 / 1 / 3 / 2; }
#right { grid-area: 2 / 3 / 3 / 4; }
#down { grid-area: 3 / 2 / 4 / 3; }

.d-pad .direction-btn:active {
    background-color: #45a049;
}

@media (max-width: 768px) {
    .d-pad {
        width: 150px;
        height: 150px;
    }

    .d-pad .direction-btn {
        width: 50px;
        height: 50px;
    }
}

.game-wrapper::-webkit-scrollbar-thumb:hover {
    background: #00cc00;
}

@media (max-width: 500px) {
    .canvas-container {
        width: 300px;
        height: 300px;
    }
}

/* ... otros estilos ... */

.modal {
    display: none;
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body {
    background-color: #1a1a1a;
    font-family: 'Arial', sans-serif;
    color: #00ff00;
}

.game-wrapper {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    min-height: 100%;
}

@keyframes rainbow {
    0% { color: #ff0000; } /* Rojo */
    14% { color: #ff7f00; } /* Naranja */
    28% { color: #ffff00; } /* Amarillo */
    42% { color: #00ff00; } /* Verde */
    57% { color: #0000ff; } /* Azul */
    71% { color: #8b00ff; } /* Violeta */
    85% { color: #ff00ff; } /* Magenta */
    100% { color: #ff0000; } /* Vuelve a rojo */
}

.game-title {
    font-family: 'Press Start 2P', cursive; /* Fuente estilo pixel art */
    font-size: 2.5rem; /* Reducido de 2.5rem */
    text-align: center;
    margin: 0 20px; /* Reducido de 20px */
    text-transform: uppercase;
    letter-spacing: 1px; /* Reducido de 2px */
    animation: rainbow 8s linear infinite;
    text-shadow: 
        1px 1px 0 #000,
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000;
    margin-right: 10px;  /* Espacio entre el título y la imagen */
}

@media (max-width: 500px) {
    .game-title {
        font-size: 1.2rem; /* Reducido de 1.8rem */
    }
}

#score, #message {
    margin-top: 0.5rem;
    font-size: 1.2rem;
    text-align: center;
}

.button-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
}

.button-container button {
    width: 40px;
    height: 40px;
    font-size: 20px;
    background-color: #333;
    color: #00ff00;
    border: 1px solid #00ff00;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
}

.button-container button:hover {
    background-color: #444;
    box-shadow: 0 0 5px #00ff00;
}

.button-container button:active {
    transform: scale(0.95);
}

@media (max-width: 500px) {
    .button-container button {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }
}

#pauseButton, #soundButton, #instructionsButton {
    width: 40px;
    height: 40px;
    font-size: 18px;
    background-color: #333;
    color: #00ff00;
    border: 1px solid #00ff00;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

#pauseButton:hover, #soundButton:hover, #instructionsButton:hover {
    background-color: #444;
    box-shadow: 0 0 5px #00ff00;
}

#pauseButton:active, #soundButton:active, #instructionsButton:active {
    transform: scale(0.95);
}

@media (max-width: 500px) {
    #pauseButton, #soundButton, #instructionsButton {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
}

#touch-controls {
    display: none; /* Hide by default */
    justify-content: center;
    align-items: center;
    margin-top: 10px;
}

.d-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 5px; /* Reduced spacing */
    width: 150px; /* Increased size for better touch */
    height: 150px;
}

.d-pad .direction-btn {
    width: 50px; /* Slightly smaller buttons */
    height: 50px;
    border-radius: 50%;
    border: none;
    background-color: #4CAF50;
    color: white;
    font-size: 24px; /* Increased font size */
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    transition: background-color 0.3s ease;
    margin: auto; /* Center the button within its grid cell */
}

#up { grid-area: 1 / 2 / 2 / 3; }
#left { grid-area: 2 / 1 / 3 / 2; }
#right { grid-area: 2 / 3 / 3 / 4; }
#down { grid-area: 3 / 2 / 4 / 3; }

.d-pad .direction-btn:active {
    background-color: #45a049;
}

@media (max-width: 768px) {
    body.touch-device #touch-controls {
        display: flex; /* Show only on touch devices with smaller screens */
    }
}

@media (max-height: 600px) {
    .game-frame {
        max-height: 40vh;
    }

    #score, #message {
        margin-top: 0.3rem;
        font-size: 1rem;
    }

    .button-container {
        margin-top: 0.3rem;
    }

    #pauseButton, #soundButton {
        padding: 0.3rem;
        font-size: 0.9rem;
    }

    .d-pad {
        width: 150px;
        height: 150px;
    }

    .d-pad button {
        font-size: 1.5rem;
    }
}

#scoreHistoryContainer {
    margin-top: 20px;
    background-color: rgba(0, 0, 0, 0.8);
    border: 2px solid #00ff00;
    border-radius: 10px;
    padding: 10px;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 0 10px #00ff00;
}

#scoreHistoryContainer h2 {
    color: #00ff00;
    text-align: center;
    margin-bottom: 10px;
    font-family: 'Press Start 2P', cursive;
    text-transform: uppercase;
    text-shadow: 0 0 5px #00ff00;
}

#scoreHistory {
    max-height: 200px;
    overflow-y: auto;
    padding-right: 10px;
}

#scoreHistory::-webkit-scrollbar {
    width: 8px;
}

#scoreHistory::-webkit-scrollbar-track {
    background: #001a00;
    border-radius: 4px;
}

#scoreHistory::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 4px;
}

#scoreHistory::-webkit-scrollbar-thumb:hover {
    background: #00cc00;
}

#scoreHistory ul {
    list-style-type: none;
    padding: 0;
}

#scoreHistory li {
    color: #ffffff;
    margin-bottom: 10px;
    padding: 5px;
    background-color: rgba(0, 255, 0, 0.1);
    border-radius: 5px;
    font-family: 'Courier New', monospace;
    transition: all 0.3s ease;
}

#scoreHistory li:hover {
    background-color: rgba(0, 255, 0, 0.2);
    transform: translateX(5px);
}

#scoreHistory li::before {
    content: '🐍';
    margin-right: 5px;
}

/* Estilos para el scroll */
.game-wrapper::-webkit-scrollbar {
    width: 10px;
}

.game-wrapper::-webkit-scrollbar {
    width: 10px;
}

.game-wrapper::-webkit-scrollbar-track {
    background: #001a00;
}

.game-wrapper::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 5px;
}

.game-wrapper::-webkit-scrollbar-thumb:hover {
    background: #00cc00;
}

@media (max-width: 500px) {
    .canvas-container {
        width: 300px;
        height: 300px;
    }
}

/* ... otros estilos ... */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
}

.modal-content {
    background-color: #1a1a1a;
    color: #00ff00;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #00ff00;
    border-radius: 10px;
    width: 80%;
    max-width: 500px;
    box-shadow: 0 0 20px #00ff00;
}

.close {
    color: #00ff00;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: #00cc00;
    text-decoration: none;
}

.modal-content h2 {
    margin-top: 0;
    text-align: center;
}

.modal-content ul {
    padding-left: 20px;
}

.modal-content li {
    margin-bottom: 10px;
}

@media (max-width: 500px) {
    .modal-content {
        margin: 10% auto;
        width: 90%;
        padding: 15px;
    }
}

.canvas-container {
    width: 400px; /* Tamaño fijo */
    height: 400px; /* Tamaño fijo */
    margin: 10px auto;
    border: 2px solid #00ff00;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
}

#gameCanvas {
    width: 100%;
    height: 100%;
    background-color: #000;
    transition: background-color 0.5s ease;
}

@media (max-width: 500px) {
    .canvas-container {
        width: 300px; /* Tamaño más pequeño pero fijo para móviles */
        height: 300px;
    }
}

.title-container {
    display: flex;
    align-items: center;
    justify-content: center;
    
}

.snake-icon {
    width: 50px;
    height: 50px;
    transition: transform 0.3s ease;
}

.snake-left {
    transform: scaleX(-1);
}

.snake-right:hover, .snake-left:hover {
    transform: scale(1.1);
}

.snake-left:hover {
    transform: scaleX(-1) scale(1.1);
}

/* Añadimos un pequeño margen superior al contenedor del canvas si es necesario */
.canvas-container {
    margin-top: 10px;
}

#touch-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 10px;
}

.d-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 3px; /* Reduced spacing */
    width: 120px; /* Reduced overall size */
    height: 120px; /* Added to maintain aspect ratio */
}

.d-pad .direction-btn {
    width: 40px; /* Slightly smaller buttons */
    height: 40px;
    border-radius: 50%;
    border: none;
    background-color: #4CAF50;
    color: white;
    font-size: 18px; /* Slightly smaller font */
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    transition: background-color 0.3s ease;
}

#up { grid-area: 1 / 2 / 2 / 3; }
#left { grid-area: 2 / 1 / 3 / 2; }
#right { grid-area: 2 / 3 / 3 / 4; }
#down { grid-area: 3 / 2 / 4 / 3; }

.d-pad .direction-btn:active {
    background-color: #45a049;
}

@media (max-width: 768px) {
    .d-pad {
        width: 150px;
        height: 150px;
    }

    .d-pad .direction-btn {
        width: 50px;
        height: 50px;
    }
}

.game-wrapper::-webkit-scrollbar-thumb:hover {
    background: #00cc00;
}

@media (max-width: 500px) {
    .canvas-container {
        width: 300px;
        height: 300px;
    }
}

/* ... otros estilos ... */

.modal {
    display: none;
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body {
    background-color: #1a1a1a;
    font-family: 'Arial', sans-serif;
    color: #00ff00;
}

.game-wrapper {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    min-height: 100%;
}

@keyframes rainbow {
    0% { color: #ff0000; } /* Rojo */
    14% { color: #ff7f00; } /* Naranja */
    28% { color: #ffff00; } /* Amarillo */
    42% { color: #00ff00; } /* Verde */
    57% { color: #0000ff; } /* Azul */
    71% { color: #8b00ff; } /* Violeta */
    85% { color: #ff00ff; } /* Magenta */
    100% { color: #ff0000; } /* Vuelve a rojo */
}

.game-title {
    font-family: 'Press Start 2P', cursive; /* Fuente estilo pixel art */
    font-size: 2.5rem; /* Reducido de 2.5rem */
    text-align: center;
    margin: 0 20px; /* Reducido de 20px */
    text-transform: uppercase;
    letter-spacing: 1px; /* Reducido de 2px */
    animation: rainbow 8s linear infinite;
    text-shadow: 
        1px 1px 0 #000,
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000;
    margin-right: 10px;  /* Espacio entre el título y la imagen */
}

@media (max-width: 500px) {
    .game-title {
        font-size: 1.2rem; /* Reducido de 1.8rem */
    }
}

#score, #message {
    margin-top: 0.5rem;
    font-size: 1.2rem;
    text-align: center;
}

.button-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
}

.button-container button {
    width: 40px;
    height: 40px;
    font-size: 20px;
    background-color: #333;
    color: #00ff00;
    border: 1px solid #00ff00;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
}

.button-container button:hover {
    background-color: #444;
    box-shadow: 0 0 5px #00ff00;
}

.button-container button:active {
    transform: scale(0.95);
}

@media (max-width: 500px) {
    .button-container button {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }
}

#pauseButton, #soundButton, #instructionsButton {
    width: 40px;
    height: 40px;
    font-size: 18px;
    background-color: #333;
    color: #00ff00;
    border: 1px solid #00ff00;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

#pauseButton:hover, #soundButton:hover, #instructionsButton:hover {
    background-color: #444;
    box-shadow: 0 0 5px #00ff00;
}

#pauseButton:active, #soundButton:active, #instructionsButton:active {
    transform: scale(0.95);
}

@media (max-width: 500px) {
    #pauseButton, #soundButton, #instructionsButton {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
}

#touch-controls {
    display: none; /* Hide by default */
    justify-content: center;
    align-items: center;
    margin-top: 10px;
}

.d-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 5px; /* Reduced spacing */
    width: 180px; /* Increased size for better touch */
    height: 180px;
}

.d-pad .direction-btn {
    width: 100%; /* Fill the entire grid cell */
    height: 100%;
    border-radius: 50%; /* Keep buttons circular */
    border: none;
    background-color: #4CAF50;
    color: white;
    font-size: 24px; /* Increased font size */
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    transition: background-color 0.3s ease;
}

#up { grid-area: 1 / 2 / 2 / 3; }
#left { grid-area: 2 / 1 / 3 / 2; }
#right { grid-area: 2 / 3 / 3 / 4; }
#down { grid-area: 3 / 2 / 4 / 3; }

.d-pad .direction-btn:active {
    background-color: #45a049;
}

@media (max-width: 768px) {
    body.touch-device #touch-controls {
        display: flex; /* Show only on touch devices with smaller screens */
    }
}

@media (max-height: 600px) {
    .game-frame {
        max-height: 40vh;
    }

    #score, #message {
        margin-top: 0.3rem;
        font-size: 1rem;
    }

    .button-container {
        margin-top: 0.3rem;
    }

    #pauseButton, #soundButton {
        padding: 0.3rem;
        font-size: 0.9rem;
    }

    .d-pad {
        width: 150px;
        height: 150px;
    }

    .d-pad button {
        font-size: 1.5rem;
    }
}

#scoreHistoryContainer {
    margin-top: 20px;
    background-color: rgba(0, 0, 0, 0.8);
    border: 2px solid #00ff00;
    border-radius: 10px;
    padding: 10px;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 0 10px #00ff00;
}

#scoreHistoryContainer h2 {
    color: #00ff00;
    text-align: center;
    margin-bottom: 10px;
    font-family: 'Press Start 2P', cursive;
    text-transform: uppercase;
    text-shadow: 0 0 5px #00ff00;
}

#scoreHistory {
    max-height: 200px;
    overflow-y: auto;
    padding-right: 10px;
}

#scoreHistory::-webkit-scrollbar {
    width: 8px;
}

#scoreHistory::-webkit-scrollbar-track {
    background: #001a00;
    border-radius: 4px;
}

#scoreHistory::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 4px;
}

#scoreHistory::-webkit-scrollbar-thumb:hover {
    background: #00cc00;
}

#scoreHistory ul {
    list-style-type: none;
    padding: 0;
}

#scoreHistory li {
    color: #ffffff;
    margin-bottom: 10px;
    padding: 5px;
    background-color: rgba(0, 255, 0, 0.1);
    border-radius: 5px;
    font-family: 'Courier New', monospace;
    transition: all 0.3s ease;
}

#scoreHistory li:hover {
    background-color: rgba(0, 255, 0, 0.2);
    transform: translateX(5px);
}

#scoreHistory li::before {
    content: '🐍';
    margin-right: 5px;
}

/* Estilos para el scroll */
.game-wrapper::-webkit-scrollbar {
    width: 10px;
}

.game-wrapper::-webkit-scrollbar {
    width: 10px;
}

.game-wrapper::-webkit-scrollbar-track {
    background: #001a00;
}

.game-wrapper::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 5px;
}

.game-wrapper::-webkit-scrollbar-thumb:hover {
    background: #00cc00;
}

@media (max-width: 500px) {
    .canvas-container {
        width: 300px;
        height: 300px;
    }
}

/* ... otros estilos ... */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
}

.modal-content {
    background-color: #1a1a1a;
    color: #00ff00;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #00ff00;
    border-radius: 10px;
    width: 80%;
    max-width: 500px;
    box-shadow: 0 0 20px #00ff00;
}

.close {
    color: #00ff00;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: #00cc00;
    text-decoration: none;
}

.modal-content h2 {
    margin-top: 0;
    text-align: center;
}

.modal-content ul {
    padding-left: 20px;
}

.modal-content li {
    margin-bottom: 10px;
}

@media (max-width: 500px) {
    .modal-content {
        margin: 10% auto;
        width: 90%;
        padding: 15px;
    }
}

.canvas-container {
    width: 400px; /* Tamaño fijo */
    height: 400px; /* Tamaño fijo */
    margin: 10px auto;
    border: 2px solid #00ff00;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
}

#gameCanvas {
    width: 100%;
    height: 100%;
    background-color: #000;
    transition: background-color 0.5s ease;
}

@media (max-width: 500px) {
    .canvas-container {
        width: 300px; /* Tamaño más pequeño pero fijo para móviles */
        height: 300px;
    }
}

.title-container {
    display: flex;
    align-items: center;
    justify-content: center;
    
}

.snake-icon {
    width: 50px;
    height: 50px;
    transition: transform 0.3s ease;
}

.snake-left {
    transform: scaleX(-1);
}

.snake-right:hover, .snake-left:hover {
    transform: scale(1.1);
}

.snake-left:hover {
    transform: scaleX(-1) scale(1.1);
}

/* Añadimos un pequeño margen superior al contenedor del canvas si es necesario */
.canvas-container {
    margin-top: 10px;
}

#touch-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 10px;
}

.d-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 3px; /* Reduced spacing */
    width: 120px; /* Reduced overall size */
    height: 120px; /* Added to maintain aspect ratio */
}

.d-pad .direction-btn {
    width: 40px; /* Slightly smaller buttons */
    height: 40px;
    border-radius: 50%;
    border: none;
    background-color: #4CAF50;
    color: white;
    font-size: 18px; /* Slightly smaller font */
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    transition: background-color 0.3s ease;
}

#up { grid-area: 1 / 2 / 2 / 3; }
#left { grid-area: 2 / 1 / 3 / 2; }
#right { grid-area: 2 / 3 / 3 / 4; }
#down { grid-area: 3 / 2 / 4 / 3; }

.d-pad .direction-btn:active {
    background-color: #45a049;
}

@media (max-width: 768px) {
    .d-pad {
        width: 150px;
        height: 150px;
    }

    .d-pad .direction-btn {
        width: 50px;
        height: 50px;
    }
}

.game-wrapper::-webkit-scrollbar-thumb:hover {
    background: #00cc00;
}

@media (max-width: 500px) {
    .canvas-container {
        width: 300px;
        height: 300px;
    }
}

/* ... otros estilos ... */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
}

.modal-content {
    background-color: #1a1a1a;
    color: #00ff00;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #00ff00;
    border-radius: 10px;
    width: 80%;
    max-width: 500px;
    box-shadow: 0 0 20px #00ff00;
}

.close {
    color: #00ff00;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: #00cc00;
    text-decoration: none;
}

.modal-content h2 {
    margin-top: 0;
    text-align: center;
}

.modal-content ul {
    padding-left: 20px;
}

.modal-content li {
    margin-bottom: 10px;
}

@media (max-width: 500px) {
    .modal-content {
        margin: 10% auto;
        width: 90%;
        padding: 15px;
    }
}

.canvas-container {
    width: 400px; /* Tamaño fijo */
    height: 400px; /* Tamaño fijo */
    margin: 10px auto;
    border: 2px solid #00ff00;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
}

#gameCanvas {
    width: 100%;
    height: 100%;
    background-color: #000;
    transition: background-color 0.5s ease;
}

@media (max-width: 500px) {
    .canvas-container {
        width: 300px; /* Tamaño más pequeño pero fijo para móviles */
        height: 300px;
    }
}

.title-container {
    display: flex;
    align-items: center;
    justify-content: center;
    
}

.snake-icon {
    width: 50px;
    height: 50px;
    transition: transform 0.3s ease;
}

.snake-left {
    transform: scaleX(-1);
}

.snake-right:hover, .snake-left:hover {
    transform: scale(1.1);
}

.snake-left:hover {
    transform: scaleX(-1) scale(1.1);
}

/* Añadimos un pequeño margen superior al contenedor del canvas si es necesario */
.canvas-container {
    margin-top: 10px;
}

#touch-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 10px;
}

.d-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 3px; /* Reduced spacing */
    width: 120px; /* Reduced overall size */
    height: 120px; /* Added to maintain aspect ratio */
}

.d-pad .direction-btn {
    width: 40px; /* Slightly smaller buttons */
    height: 40px;
    border-radius: 50%;
    border: none;
    background-color: #4CAF50;
    color: white;
    font-size: 18px; /* Slightly smaller font */
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    transition: background-color 0.3s ease;
}

#up { grid-area: 1 / 2 / 2 / 3; }
#left { grid-area: 2 / 1 / 3 / 2; }
#right { grid-area: 2 / 3 / 3 / 4; }
#down { grid-area: 3 / 2 / 4 / 3; }

.d-pad .direction-btn:active {
    background-color: #45a049;
}

@media (max-width: 768px) {
    .d-pad {
        width: 150px;
        height: 150px;
    }

    .d-pad .direction-btn {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
}

@media (max-height: 600px) {
    .game-frame {
        max-height: 40vh;
    }

    #score, #message {
        margin-top: 0.3rem;
        font-size: 1rem;
    }

    .button-container {
        margin-top: 0.3rem;
    }

    #pauseButton, #soundButton {
        padding: 0.3rem;
        font-size: 0.9rem;
    }

    .d-pad {
        width: 150px;
        height: 150px;
    }

    .d-pad button {
        font-size: 1.5rem;
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body {
    background-color: #1a1a1a;
    font-family: 'Arial', sans-serif;
    color: #00ff00;
}

.game-wrapper {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    min-height: 100%;
}

@keyframes rainbow {
    0% { color: #ff0000; } /* Rojo */
    14% { color: #ff7f00; } /* Naranja */
    28% { color: #ffff00; } /* Amarillo */
    42% { color: #00ff00; } /* Verde */
    57% { color: #0000ff; } /* Azul */
    71% { color: #8b00ff; } /* Violeta */
    85% { color: #ff00ff; } /* Magenta */
    100% { color: #ff0000; } /* Vuelve a rojo */
}

.game-title {
    font-family: 'Press Start 2P', cursive; /* Fuente estilo pixel art */
    font-size: 2.5rem; /* Reducido de 2.5rem */
    text-align: center;
    margin: 0 20px; /* Reducido de 20px */
    text-transform: uppercase;
    letter-spacing: 1px; /* Reducido de 2px */
    animation: rainbow 8s linear infinite;
    text-shadow: 
        1px 1px 0 #000,
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000;
    margin-right: 10px;  /* Espacio entre el título y la imagen */
}

@media (max-width: 500px) {
    .game-title {
        font-size: 1.2rem; /* Reducido de 1.8rem */
    }
}

#score, #message {
    margin-top: 0.5rem;
    font-size: 1.2rem;
    text-align: center;
}

.button-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
}

.button-container button {
    width: 40px;
    height: 40px;
    font-size: 20px;
    background-color: #333;
    color: #00ff00;
    border: 1px solid #00ff00;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
}

.button-container button:hover {
    background-color: #444;
    box-shadow: 0 0 5px #00ff00;
}

.button-container button:active {
    transform: scale(0.95);
}

@media (max-width: 500px) {
    .button-container button {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }
}

#pauseButton, #soundButton, #instructionsButton {
    width: 40px;
    height: 40px;
    font-size: 18px;
    background-color: #333;
    color: #00ff00;
    border: 1px solid #00ff00;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

#pauseButton:hover, #soundButton:hover, #instructionsButton:hover {
    background-color: #444;
    box-shadow: 0 0 5px #00ff00;
}

#pauseButton:active, #soundButton:active, #instructionsButton:active {
    transform: scale(0.95);
}

@media (max-width: 500px) {
    #pauseButton, #soundButton, #instructionsButton {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
}

#touch-controls {
    display: none; /* Hide by default for all screen sizes */
}

@media (max-width: 768px) {
    #touch-controls {
        display: flex; /* Show only on screens smaller than 768px */
        justify-content: center;
        align-items: center;
        margin-top: 10px;
    }

    .d-pad {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: repeat(3, 1fr);
        gap: 5px;
        width: 150px;
        height: 150px;
    }

    .d-pad .direction-btn {
        width: 50px;
        height: 50px;
        border-radius: 50%;
        border: none;
        background-color: #4CAF50;
        color: white;
        font-size: 20px;
        cursor: pointer;
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 0;
    }

    #up { grid-area: 1 / 2 / 2 / 3; }
    #left { grid-area: 2 / 1 / 3 / 2; }
    #right { grid-area: 2 / 3 / 3 / 4; }
    #down { grid-area: 3 / 2 / 4 / 3; }
}

@media (max-height: 600px) {
    .game-frame {
        max-height: 40vh;
    }

    #score, #message {
        margin-top: 0.3rem;
        font-size: 1rem;
    }

    .button-container {
        margin-top: 0.3rem;
    }

    #pauseButton, #soundButton {
        padding: 0.3rem;
        font-size: 0.9rem;
    }

    .d-pad {
        width: 150px;
        height: 150px;
    }

    .d-pad button {
        font-size: 1.5rem;
    }
}

#scoreHistoryContainer {
    margin-top: 20px;
    background-color: rgba(0, 0, 0, 0.8);
    border: 2px solid #00ff00;
    border-radius: 10px;
    padding: 10px;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 0 10px #00ff00;
}

#scoreHistoryContainer h2 {
    color: #00ff00;
    text-align: center;
    margin-bottom: 10px;
    font-family: 'Press Start 2P', cursive;
    text-transform: uppercase;
    text-shadow: 0 0 5px #00ff00;
}

#scoreHistory {
    max-height: 200px;
    overflow-y: auto;
    padding-right: 10px;
}

#scoreHistory::-webkit-scrollbar {
    width: 8px;
}

#scoreHistory::-webkit-scrollbar-track {
    background: #001a00;
    border-radius: 4px;
}

#scoreHistory::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 4px;
}

#scoreHistory::-webkit-scrollbar-thumb:hover {
    background: #00cc00;
}

#scoreHistory ul {
    list-style-type: none;
    padding: 0;
}

#scoreHistory li {
    color: #ffffff;
    margin-bottom: 10px;
    padding: 5px;
    background-color: rgba(0, 255, 0, 0.1);
    border-radius: 5px;
    font-family: 'Courier New', monospace;
    transition: all 0.3s ease;
}

#scoreHistory li:hover {
    background-color: rgba(0, 255, 0, 0.2);
    transform: translateX(5px);
}

#scoreHistory li::before {
    content: '🐍';
    margin-right: 5px;
}

/* Estilos para el scroll */
.game-wrapper::-webkit-scrollbar-track {
    background: #001a00;
}

.game-wrapper::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 5px;
}

.game-wrapper::-webkit-scrollbar-thumb:hover {
.game-wrapper::-webkit-scrollbar-thumb:hover {
    background: #00cc00;
}

@media (max-width: 500px) {
    .canvas-container {
        width: 300px;
        height: 300px;
    }
}

/* ... otros estilos ... */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
}

.modal-content {
    background-color: #1a1a1a;
    color: #00ff00;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #00ff00;
    border-radius: 10px;
    width: 80%;
    max-width: 500px;
    box-shadow: 0 0 20px #00ff00;
}

.close {
    color: #00ff00;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: #00cc00;
    text-decoration: none;
}

.modal-content h2 {
    margin-top: 0;
    text-align: center;
}

.modal-content ul {
    padding-left: 20px;
}

.modal-content li {
    margin-bottom: 10px;
}

@media (max-width: 500px) {
    .modal-content {
        margin: 10% auto;
        width: 90%;
        padding: 15px;
    }
}

.canvas-container {
    width: 400px; /* Tamaño fijo */
    height: 400px; /* Tamaño fijo */
    margin: 10px auto;
    border: 2px solid #00ff00;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
}

#gameCanvas {
    width: 100%;
    height: 100%;
    background-color: #000;
    transition: background-color 0.5s ease;
}

@media (max-width: 500px) {
    .canvas-container {
        width: 300px; /* Tamaño más pequeño pero fijo para móviles */
        height: 300px;
    }
}

.title-container {
    display: flex;
    align-items: center;
    justify-content: center;
    
}

.snake-icon {
    width: 50px;
    height: 50px;
    transition: transform 0.3s ease;
}

.snake-left {
    transform: scaleX(-1);
}

.snake-right:hover, .snake-left:hover {
    transform: scale(1.1);
}

.snake-left:hover {
    transform: scaleX(-1) scale(1.1);
}

/* Añadimos un pequeño margen superior al contenedor del canvas si es necesario */
.canvas-container {
    margin-top: 10px;
}

#touch-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 10px;
}

.d-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 3px; /* Reduced spacing */
    width: 120px; /* Reduced overall size */
    height: 120px; /* Added to maintain aspect ratio */
}

.d-pad .direction-btn {
    width: 40px; /* Slightly smaller buttons */
    height: 40px;
    border-radius: 50%;
    border: none;
    background-color: #4CAF50;
    color: white;
    font-size: 18px; /* Slightly smaller font */
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    transition: background-color 0.3s ease;
}

#up { grid-area: 1 / 2 / 2 / 3; }
#left { grid-area: 2 / 1 / 3 / 2; }
#right { grid-area: 2 / 3 / 3 / 4; }
#down { grid-area: 3 / 2 / 4 / 3; }

.d-pad .direction-btn:active {
    background-color: #45a049;
}

@media (max-width: 768px) {
    .d-pad {
        width: 150px;
        height: 150px;
    }

    .d-pad .direction-btn {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
}

@media (max-height: 600px) {
    .game-frame {
        max-height: 40vh;
    }

    #score, #message {
        margin-top: 0.3rem;
        font-size: 1rem;
    }

    .button-container {
        margin-top: 0.3rem;
    }

    #pauseButton, #soundButton {
        padding: 0.3rem;
        font-size: 0.9rem;
    }

    .d-pad {
        width: 150px;
        height: 150px;
    }

    .d-pad button {
        font-size: 1.5rem;
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body {
    background-color: #1a1a1a;
    font-family: 'Arial', sans-serif;
    color: #00ff00;
}

.game-wrapper {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    min-height: 100%;
}

@keyframes rainbow {
    0% { color: #ff0000; } /* Rojo */
    14% { color: #ff7f00; } /* Naranja */
    28% { color: #ffff00; } /* Amarillo */
    42% { color: #00ff00; } /* Verde */
    57% { color: #0000ff; } /* Azul */
    71% { color: #8b00ff; } /* Violeta */
    85% { color: #ff00ff; } /* Magenta */
    100% { color: #ff0000; } /* Vuelve a rojo */
}

.game-title {
    font-family: 'Press Start 2P', cursive; /* Fuente estilo pixel art */
    font-size: 2.5rem; /* Reducido de 2.5rem */
    text-align: center;
    margin: 0 20px; /* Reducido de 20px */
    text-transform: uppercase;
    letter-spacing: 1px; /* Reducido de 2px */
    animation: rainbow 8s linear infinite;
    text-shadow: 
        1px 1px 0 #000,
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000;
    margin-right: 10px;  /* Espacio entre el título y la imagen */
}

@media (max-width: 500px) {
    .game-title {
        font-size: 1.2rem; /* Reducido de 1.8rem */
    }
}

#score, #message {
    margin-top: 0.5rem;
    font-size: 1.2rem;
    text-align: center;
}

.button-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
}

.button-container button {
    width: 40px;
    height: 40px;
    font-size: 20px;
    background-color: #333;
    color: #00ff00;
    border: 1px solid #00ff00;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
}

.button-container button:hover {
    background-color: #444;
    box-shadow: 0 0 5px #00ff00;
}

.button-container button:active {
    transform: scale(0.95);
}

@media (max-width: 500px) {
    .button-container button {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }
}

#pauseButton, #soundButton, #instructionsButton {
    width: 40px;
    height: 40px;
    font-size: 18px;
    background-color: #333;
    color: #00ff00;
    border: 1px solid #00ff00;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

#pauseButton:hover, #soundButton:hover, #instructionsButton:hover {
    background-color: #444;
    box-shadow: 0 0 5px #00ff00;
}

#pauseButton:active, #soundButton:active, #instructionsButton:active {
    transform: scale(0.95);
}

@media (max-width: 500px) {
    #pauseButton, #soundButton, #instructionsButton {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
}

#touch-controls {
    display: none; /* Hide by default for all screen sizes */
}

@media (max-width: 768px) {
    #touch-controls {
        display: flex; /* Show only on screens smaller than 768px */
        justify-content: center;
        align-items: center;
        margin-top: 10px;
    }

    .d-pad {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: repeat(3, 1fr);
        gap: 5px;
        width: 150px;
        height: 150px;
    }

    .d-pad .direction-btn {
        width: 50px;
        height: 50px;
        border-radius: 50%;
        border: none;
        background-color: #4CAF50;
        color: white;
        font-size: 20px;
        cursor: pointer;
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 0;
    }

    #up { grid-area: 1 / 2 / 2 / 3; }
    #left { grid-area: 2 / 1 / 3 / 2; }
    #right { grid-area: 2 / 3 / 3 / 4; }
    #down { grid-area: 3 / 2 / 4 / 3; }
}

@media (max-height: 600px) {
    .game-frame {
        max-height: 40vh;
    }

    #score, #message {
        margin-top: 0.3rem;
        font-size: 1rem;
    }

    .button-container {
        margin-top: 0.3rem;
    }

    #pauseButton, #soundButton {
        padding: 0.3rem;
        font-size: 0.9rem;
    }

    .d-pad {
        width: 150px;
        height: 150px;
    }

    .d-pad button {
        font-size: 1.5rem;
    }
}

#scoreHistoryContainer {
    margin-top: 20px;
    background-color: rgba(0, 0, 0, 0.8);
    border: 2px solid #00ff00;
    border-radius: 10px;
    padding: 10px;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 0 10px #00ff00;
}

#scoreHistoryContainer h2 {
    color: #00ff00;
    text-align: center;
    margin-bottom: 10px;
    font-family: 'Press Start 2P', cursive;
    text-transform: uppercase;
    text-shadow: 0 0 5px #00ff00;
}

#scoreHistory {
    max-height: 200px;
    overflow-y: auto;
    padding-right: 10px;
}

#scoreHistory::-webkit-scrollbar {
    width: 8px;
}

#scoreHistory::-webkit-scrollbar-track {
    background: #001a00;
    border-radius: 4px;
}

#scoreHistory::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 4px;
}

#scoreHistory::-webkit-scrollbar-thumb:hover {
    background: #00cc00;
}

#scoreHistory ul {
    list-style-type: none;
    padding: 0;
}

#scoreHistory li {
    color: #ffffff;
    margin-bottom: 10px;
    padding: 5px;
    background-color: rgba(0, 255, 0, 0.1);
    border-radius: 5px;
    font-family: 'Courier New', monospace;
    transition: all 0.3s ease;
}

#scoreHistory li:hover {
    background-color: rgba(0, 255, 0, 0.2);
    transform: translateX(5px);
}

#scoreHistory li::before {
    content: '🐍';
    margin-right: 5px;
}

/* Estilos para el scroll */
.game-wrapper::-webkit-scrollbar-track {
    background: #001a00;
}

.game-wrapper::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 5px;
}

.game-wrapper::-webkit-scrollbar-thumb:hover {
    background: #00cc00;
}

@media (max-width: 500px) {
    .canvas-container {
        width: 300px;
        height: 300px;
    }
}

/* ... otros estilos ... */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
}

.modal-content {
    background-color: #1a1a1a;
    color: #00ff00;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #00ff00;
    border-radius: 10px;
    width: 80%;
    max-width: 500px;
    box-shadow: 0 0 20px #00ff00;
}

.close {
    color: #00ff00;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: #00cc00;
    text-decoration: none;
}

.modal-content h2 {
    margin-top: 0;
    text-align: center;
}

.modal-content ul {
    padding-left: 20px;
}

.modal-content li {
    margin-bottom: 10px;
}

@media (max-width: 500px) {
    .modal-content {
        margin: 10% auto;
        width: 90%;
        padding: 15px;
    }
}

.canvas-container {
    width: 400px; /* Tamaño fijo */
    height: 400px; /* Tamaño fijo */
    margin: 10px auto;
    border: 2px solid #00ff00;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
}

#gameCanvas {
    width: 100%;
    height: 100%;
    background-color: #000;
    transition: background-color 0.5s ease;
}

@media (max-width: 500px) {
    .canvas-container {
        width: 300px; /* Tamaño más pequeño pero fijo para móviles */
        height: 300px;
    }
}

.title-container {
    display: flex;
    align-items: center;
    justify-content: center;
    
}

.snake-icon {
    width: 50px;
    height: 50px;
    transition: transform 0.3s ease;
}

.snake-left {
    transform: scaleX(-1);
}

.snake-right:hover, .snake-left:hover {
    transform: scale(1.1);
}

.snake-left:hover {
    transform: scaleX(-1) scale(1.1);
}

/* Añadimos un pequeño margen superior al contenedor del canvas si es necesario */
.canvas-container {
    margin-top: 10px;
}

#touch-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 10px;
}

.d-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 3px; /* Reduced spacing */
    width: 120px; /* Reduced overall size */
    height: 120px; /* Added to maintain aspect ratio */
}

.d-pad .direction-btn {
    width: 40px; /* Slightly smaller buttons */
    height: 40px;
    border-radius: 50%;
    border: none;
    background-color: #4CAF50;
    color: white;
    font-size: 18px; /* Slightly smaller font */
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    transition: background-color 0.3s ease;
}

#up { grid-area: 1 / 2 / 2 / 3; }
#left { grid-area: 2 / 1 / 3 / 2; }
#right { grid-area: 2 / 3 / 3 / 4; }
#down { grid-area: 3 / 2 / 4 / 3; }

.d-pad .direction-btn:active {
    background-color: #45a049;
}

@media (max-width: 768px) {
    .d-pad {
        width: 150px;
        height: 150px;
    }

    .d-pad .direction-btn {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
}

@media (max-height: 600px) {
    .game-frame {
        max-height: 40vh;
    }

    #score, #message {
        margin-top: 0.3rem;
        font-size: 1rem;
    }

    .button-container {
        margin-top: 0.3rem;
    }

    #pauseButton, #soundButton {
        padding: 0.3rem;
        font-size: 0.9rem;
    }

    .d-pad {
        width: 150px;
        height: 150px;
    }

    .d-pad button {
        font-size: 1.5rem;
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body {
    background-color: #1a1a1a;
    font-family: 'Arial', sans-serif;
    color: #00ff00;
}

.game-wrapper {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    min-height: 100%;
}

@keyframes rainbow {
    0% { color: #ff0000; } /* Rojo */
    14% { color: #ff7f00; } /* Naranja */
    28% { color: #ffff00; } /* Amarillo */
    42% { color: #00ff00; } /* Verde */
    57% { color: #0000ff; } /* Azul */
    71% { color: #8b00ff; } /* Violeta */
    85% { color: #ff00ff; } /* Magenta */
    100% { color: #ff0000; } /* Vuelve a rojo */
}

.game-title {
    font-family: 'Press Start 2P', cursive; /* Fuente estilo pixel art */
    font-size: 2.5rem; /* Reducido de 2.5rem */
    text-align: center;
    margin: 0 20px; /* Reducido de 20px */
    text-transform: uppercase;
    letter-spacing: 1px; /* Reducido de 2px */
    animation: rainbow 8s linear infinite;
    text-shadow: 
        1px 1px 0 #000,
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000;
    margin-right: 10px;  /* Espacio entre el título y la imagen */
}

@media (max-width: 500px) {
    .game-title {
        font-size: 1.2rem; /* Reducido de 1.8rem */
    }
}

#score, #message {
    margin-top: 0.5rem;
    font-size: 1.2rem;
    text-align: center;
}

.button-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
}

.button-container button {
    width: 40px;
    height: 40px;
    font-size: 20px;
    background-color: #333;
    color: #00ff00;
    border: 1px solid #00ff00;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
}

.button-container button:hover {
    background-color: #444;
    box-shadow: 0 0 5px #00ff00;
}

.button-container button:active {
    transform: scale(0.95);
}

@media (max-width: 500px) {
    .button-container button {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }
}

#pauseButton, #soundButton, #instructionsButton {
    width: 40px;
    height: 40px;
    font-size: 18px;
    background-color: #333;
    color: #00ff00;
    border: 1px solid #00ff00;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

#pauseButton:hover, #soundButton:hover, #instructionsButton:hover {
    background-color: #444;
    box-shadow: 0 0 5px #00ff00;
}

#pauseButton:active, #soundButton:active, #instructionsButton:active {
    transform: scale(0.95);
}

@media (max-width: 500px) {
    #pauseButton, #soundButton, #instructionsButton {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
}

#touch-controls {
    display: none; /* Hide by default for all screen sizes */
}

@media (max-width: 768px) {
    #touch-controls {
        display: flex; /* Show only on screens smaller than 768px */
        justify-content: center;
        align-items: center;
        margin-top: 10px;
    }

    .d-pad {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: repeat(3, 1fr);
        gap: 5px;
        width: 150px;
        height: 150px;
    }

    .d-pad .direction-btn {
        width: 50px;
        height: 50px;
        border-radius: 50%;
        border: none;
        background-color: #4CAF50;
        color: white;
        font-size: 20px;
        cursor: pointer;
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 0;
    }

    #up { grid-area: 1 / 2 / 2 / 3; }
    #left { grid-area: 2 / 1 / 3 / 2; }
    #right { grid-area: 2 / 3 / 3 / 4; }
    #down { grid-area: 3 / 2 / 4 / 3; }
}

@media (max-height: 600px) {
    .game-frame {
        max-height: 40vh;
    }

    #score, #message {
        margin-top: 0.3rem;
        font-size: 1rem;
    }

    .button-container {
        margin-top: 0.3rem;
    }

    #pauseButton, #soundButton {
        padding: 0.3rem;
        font-size: 0.9rem;
    }

    .d-pad {
        width: 150px;
        height: 150px;
    }

    .d-pad button {
        font-size: 1.5rem;
    }
}

#scoreHistoryContainer {
    margin-top: 20px;
    background-color: rgba(0, 0, 0, 0.8);
    border: 2px solid #00ff00;
    border-radius: 10px;
    padding: 10px;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 0 10px #00ff00;
}

#scoreHistoryContainer h2 {
    color: #00ff00;
    text-align: center;
    margin-bottom: 10px;
    font-family: 'Press Start 2P', cursive;
    text-transform: uppercase;
    text-shadow: 0 0 5px #00ff00;
}

#scoreHistory {
    max-height: 200px;
    overflow-y: auto;
    padding-right: 10px;
}

#scoreHistory::-webkit-scrollbar {
    width: 8px;
}

#scoreHistory::-webkit-scrollbar-track {
    background: #001a00;
    border-radius: 4px;
}

#scoreHistory::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 4px;
}

#scoreHistory::-webkit-scrollbar-thumb:hover {
    background: #00cc00;
}

#scoreHistory ul {
    list-style-type: none;
    padding: 0;
}

#scoreHistory li {
    color: #ffffff;
    margin-bottom: 10px;
    padding: 5px;
    background-color: rgba(0, 255, 0, 0.1);
    border-radius: 5px;
    font-family: 'Courier New', monospace;
    transition: all 0.3s ease;
}

#scoreHistory li:hover {
    background-color: rgba(0, 255, 0, 0.2);
    transform: translateX(5px);
}

#scoreHistory li::before {
    content: '🐍';
    margin-right: 5px;
}

/* Estilos para el scroll */
.game-wrapper::-webkit-scrollbar {
    width: 10px;
}

.game-wrapper::-webkit-scrollbar-track {
    background: #001a00;
}

.game-wrapper::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 5px;
}

.game-wrapper::-webkit-scrollbar-thumb:hover {
    background: #00cc00;
}

@media (max-width: 500px) {
    .canvas-container {
        width: 300px;
        height: 300px;
    }
}

/* ... otros estilos ... */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
}

.modal-content {
    background-color: #1a1a1a;
    color: #00ff00;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #00ff00;
    border-radius: 10px;
    width: 80%;
    max-width: 500px;
    box-shadow: 0 0 20px #00ff00;
}

.close {
    color: #00ff00;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: #00cc00;
    text-decoration: none;
}

.modal-content h2 {
    margin-top: 0;
    text-align: center;
}

.modal-content ul {
    padding-left: 20px;
}

.modal-content li {
    margin-bottom: 10px;
}

@media (max-width: 500px) {
    .modal-content {
        margin: 10% auto;
        width: 90%;
        padding: 15px;
    }
}

.canvas-container {
    width: 400px; /* Tamaño fijo */
    height: 400px; /* Tamaño fijo */
    margin: 10px auto;
    border: 2px solid #00ff00;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
}

#gameCanvas {
    width: 100%;
    height: 100%;
    background-color: #000;
    transition: background-color 0.5s ease;
}

@media (max-width: 500px) {
    .canvas-container {
        width: 300px; /* Tamaño más pequeño pero fijo para móviles */
        height: 300px;
    }
}

.title-container {
    display: flex;
    align-items: center;
    justify-content: center;
    
}

.snake-icon {
    width: 50px;
    height: 50px;
    transition: transform 0.3s ease;
}

.snake-left {
    transform: scaleX(-1);
}

.snake-right:hover, .snake-left:hover {
    transform: scale(1.1);
}

.snake-left:hover {
    transform: scaleX(-1) scale(1.1);
}

/* Añadimos un pequeño margen superior al contenedor del canvas si es necesario */
.canvas-container {
    margin-top: 10px;
}

#touch-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 10px;
}

.d-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 3px; /* Reduced spacing */
    width: 120px; /* Reduced overall size */
    height: 120px; /* Added to maintain aspect ratio */
}

.d-pad .direction-btn {
    width: 40px; /* Slightly smaller buttons */
    height: 40px;
    border-radius: 50%;
    border: none;
    background-color: #4CAF50;
    color: white;
    font-size: 18px; /* Slightly smaller font */
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    transition: background-color 0.3s ease;
}

#up { grid-area: 1 / 2 / 2 / 3; }
#left { grid-area: 2 / 1 / 3 / 2; }
#right { grid-area: 2 / 3 / 3 / 4; }
#down { grid-area: 3 / 2 / 4 / 3; }

.d-pad .direction-btn:active {
    background-color: #45a049;
}

@media (max-width: 768px) {
    .d-pad {
        width: 150px;
        height: 150px;
    }

    .d-pad .direction-btn {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
}

@media (max-height: 600px) {
    .game-frame {
        max-height: 40vh;
    }

    #score, #message {
        margin-top: 0.3rem;
        font-size: 1rem;
    }

    .button-container {
        margin-top: 0.3rem;
    }

    #pauseButton, #soundButton {
        padding: 0.3rem;
        font-size: 0.9rem;
    }

    .d-pad {
        width: 150px;
        height: 150px;
    }

    .d-pad button {
        font-size: 1.5rem;
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body {
    background-color: #1a1a1a;
    font-family: 'Arial', sans-serif;
    color: #00ff00;
}

.game-wrapper {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    min-height: 100%;
}

@keyframes rainbow {
    0% { color: #ff0000; } /* Rojo */
    14% { color: #ff7f00; } /* Naranja */
    28% { color: #ffff00; } /* Amarillo */
    42% { color: #00ff00; } /* Verde */
    57% { color: #0000ff; } /* Azul */
    71% { color: #8b00ff; } /* Violeta */
    85% { color: #ff00ff; } /* Magenta */
    100% { color: #ff0000; } /* Vuelve a rojo */
}

.game-title {
    font-family: 'Press Start 2P', cursive; /* Fuente estilo pixel art */
    font-size: 2.5rem; /* Reducido de 2.5rem */
    text-align: center;
    margin: 0 20px; /* Reducido de 20px */
    text-transform: uppercase;
    letter-spacing: 1px; /* Reducido de 2px */
    animation: rainbow 8s linear infinite;
    text-shadow: 
        1px 1px 0 #000,
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000;
    margin-right: 10px;  /* Espacio entre el título y la imagen */
}

@media (max-width: 500px) {
    .game-title {
        font-size: 1.2rem; /* Reducido de 1.8rem */
    }
}

#score, #message {
    margin-top: 0.5rem;
    font-size: 1.2rem;
    text-align: center;
}

.button-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
}

.button-container button {
    width: 40px;
    height: 40px;
    font-size: 20px;
    background-color: #333;
    color: #00ff00;
    border: 1px solid #00ff00;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
}

.button-container button:hover {
    background-color: #444;
    box-shadow: 0 0 5px #00ff00;
}

.button-container button:active {
    transform: scale(0.95);
}

@media (max-width: 500px) {
    .button-container button {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }
}

#pauseButton, #soundButton, #instructionsButton {
    width: 40px;
    height: 40px;
    font-size: 18px;
    background-color: #333;
    color: #00ff00;
    border: 1px solid #00ff00;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

#pauseButton:hover, #soundButton:hover, #instructionsButton:hover {
    background-color: #444;
    box-shadow: 0 0 5px #00ff00;
}

#pauseButton:active, #soundButton:active, #instructionsButton:active {
    transform: scale(0.95);
}

@media (max-width: 500px) {
    #pauseButton, #soundButton, #instructionsButton {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
}

#touch-controls {
    display: none; /* Hide by default for all screen sizes */
}

@media (max-width: 768px) {
    #touch-controls {
        display: flex; /* Show only on screens smaller than 768px */
        justify-content: center;
        align-items: center;
        margin-top: 10px;
    }

    .d-pad {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: repeat(3, 1fr);
        gap: 5px;
        width: 150px;
        height: 150px;
    }

    .d-pad .direction-btn {
        width: 50px;
        height: 50px;
        border-radius: 50%;
        border: none;
        background-color: #4CAF50;
        color: white;
        font-size: 20px;
        cursor: pointer;
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 0;
    }

    #up { grid-area: 1 / 2 / 2 / 3; }
    #left { grid-area: 2 / 1 / 3 / 2; }
    #right { grid-area: 2 / 3 / 3 / 4; }
    #down { grid-area: 3 / 2 / 4 / 3; }
}

@media (max-height: 600px) {
    .game-frame {
        max-height: 40vh;
    }

    #score, #message {
        margin-top: 0.3rem;
        font-size: 1rem;
    }

    .button-container {
        margin-top: 0.3rem;
    }

    #pauseButton, #soundButton {
        padding: 0.3rem;
        font-size: 0.9rem;
    }

    .d-pad {
        width: 150px;
        height: 150px;
    }

    .d-pad button {
        font-size: 1.5rem;
    }
}

#scoreHistoryContainer {
    margin-top: 20px;
    background-color: rgba(0, 0, 0, 0.8);
    border: 2px solid #00ff00;
    border-radius: 10px;
    padding: 10px;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 0 10px #00ff00;
}

#scoreHistoryContainer h2 {
    color: #00ff00;
    text-align: center;
    margin-bottom: 10px;
    font-family: 'Press Start 2P', cursive;
    text-transform: uppercase;
    text-shadow: 0 0 5px #00ff00;
}

#scoreHistory {
    max-height: 200px;
    overflow-y: auto;
    padding-right: 10px;
}

#scoreHistory::-webkit-scrollbar {
    width: 8px;
}

#scoreHistory::-webkit-scrollbar-track {
    background: #001a00;
    border-radius: 4px;
}

#scoreHistory::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 4px;
}

#scoreHistory::-webkit-scrollbar-thumb:hover {
    background: #00cc00;
}

#scoreHistory ul {
    list-style-type: none;
    padding: 0;
}

#scoreHistory li {
    color: #ffffff;
    margin-bottom: 10px;
    padding: 5px;
    background-color: rgba(0, 255, 0, 0.1);
    border-radius: 5px;
    font-family: 'Courier New', monospace;
    transition: all 0.3s ease;
}

#scoreHistory li:hover {
    background-color: rgba(0, 255, 0, 0.2);
    transform: translateX(5px);
}

#scoreHistory li::before {
    content: '🐍';
    margin-right: 5px;
}

/* Estilos para el scroll */
.game-wrapper::-webkit-scrollbar {
    width: 10px;
}

.game-wrapper::-webkit-scrollbar-track {
    background: #001a00;
}

.game-wrapper::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 5px;
}

.game-wrapper::-webkit-scrollbar-thumb:hover {
    background: #00cc00;
}

@media (max-width: 500px) {
    .canvas-container {
        width: 300px;
        height: 300px;
    }
}

/* ... otros estilos ... */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
}

.modal-content {
    background-color: #1a1a1a;
    color: #00ff00;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #00ff00;
    border-radius: 10px;
    width: 80%;
    max-width: 500px;
    box-shadow: 0 0 20px #00ff00;
}

.close {
    color: #00ff00;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: #00cc00;
    text-decoration: none;
}

.modal-content h2 {
    margin-top: 0;
    text-align: center;
}

.modal-content ul {
    padding-left: 20px;
}

.modal-content li {
    margin-bottom: 10px;
}

@media (max-width: 500px) {
    .modal-content {
        margin: 10% auto;
        width: 90%;
        padding: 15px;
    }
}

.canvas-container {
    width: 400px; /* Tamaño fijo */
    height: 400px; /* Tamaño fijo */
    margin: 10px auto;
    border: 2px solid #00ff00;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
}

#gameCanvas {
    width: 100%;
    height: 100%;
    background-color: #000;
    transition: background-color 0.5s ease;
}

@media (max-width: 500px) {
    .canvas-container {
        width: 300px; /* Tamaño más pequeño pero fijo para móviles */
        height: 300px;
    }
}

.title-container {
    display: flex;
    align-items: center;
    justify-content: center;
    
}

.snake-icon {
    width: 50px;
    height: 50px;
    transition: transform 0.3s ease;
}

.snake-left {
    transform: scaleX(-1);
}

.snake-right:hover, .snake-left:hover {
    transform: scale(1.1);
}

.snake-left:hover {
    transform: scaleX(-1) scale(1.1);
}

/* Añadimos un pequeño margen superior al contenedor del canvas si es necesario */
.canvas-container {
    margin-top: 10px;
}

#touch-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 10px;
}

.d-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 3px; /* Reduced spacing */
    width: 120px; /* Reduced overall size */
    height: 120px; /* Added to maintain aspect ratio */
}

.d-pad .direction-btn {
    width: 40px; /* Slightly smaller buttons */
    height: 40px;
    border-radius: 50%;
    border: none;
    background-color: #4CAF50;
    color: white;
    font-size: 18px; /* Slightly smaller font */
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    transition: background-color 0.3s ease;
}

#up { grid-area: 1 / 2 / 2 / 3; }
#left { grid-area: 2 / 1 / 3 / 2; }
#right { grid-area: 2 / 3 / 3 / 4; }
#down { grid-area: 3 / 2 / 4 / 3; }

.d-pad .direction-btn:active {
    background-color: #45a049;
}

@media (max-width: 768px) {
    .d-pad {
        width: 150px;
        height: 150px;
    }

    .d-pad .direction-btn {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
}

@media (max-height: 600px) {
    .game-frame {
        max-height: 40vh;
    }

* {
* {
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body {
    background-color: #1a1a1a;
    font-family: 'Arial', sans-serif;
    color: #00ff00;
}

.game-wrapper {
    height: 100%;
    overflow-y: auto;
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body {
    background-color: #1a1a1a;
    font-family: 'Arial', sans-serif;
    color: #00ff00;
}

.game-wrapper {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    min-height: 100%;
}

@keyframes rainbow {
    0% { color: #ff0000; } /* Rojo */
    14% { color: #ff7f00; } /* Naranja */
    28% { color: #ffff00; } /* Amarillo */
    42% { color: #00ff00; } /* Verde */
    57% { color: #0000ff; } /* Azul */
    71% { color: #8b00ff; } /* Violeta */
    85% { color: #ff00ff; } /* Magenta */
    100% { color: #ff0000; } /* Vuelve a rojo */
}

.game-title {
    font-family: 'Press Start 2P', cursive; /* Fuente estilo pixel art */
    font-size: 2.5rem; /* Reducido de 2.5rem */
    text-align: center;
    margin: 0 20px; /* Reducido de 20px */
    text-transform: uppercase;
    letter-spacing: 1px; /* Reducido de 2px */
    animation: rainbow 8s linear infinite;
    text-shadow: 
        1px 1px 0 #000,
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000;
    margin-right: 10px;  /* Espacio entre el título y la imagen */
}

@media (max-width: 500px) {
    .game-title {
        font-size: 1.2rem; /* Reducido de 1.8rem */
    }
}

#score, #message {
    margin-top: 0.5rem;
    font-size: 1.2rem;
    text-align: center;
}

.button-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
}

.button-container button {
    width: 40px;
    height: 40px;
    font-size: 20px;
    background-color: #333;
    color: #00ff00;
    border: 1px solid #00ff00;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
}

.button-container button:hover {
    background-color: #444;
    box-shadow: 0 0 5px #00ff00;
}

.button-container button:active {
    transform: scale(0.95);
}

@media (max-width: 500px) {
    .button-container button {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }
}

#pauseButton, #soundButton, #instructionsButton {
    width: 40px;
    height: 40px;
    font-size: 18px;
    background-color: #333;
    color: #00ff00;
    border: 1px solid #00ff00;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

#pauseButton:hover, #soundButton:hover, #instructionsButton:hover {
    background-color: #444;
    box-shadow: 0 0 5px #00ff00;
}

#pauseButton:active, #soundButton:active, #instructionsButton:active {
    transform: scale(0.95);
}

@media (max-width: 500px) {
    #pauseButton, #soundButton, #instructionsButton {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
}

#touch-controls {
    display: none; /* Hide by default */
    justify-content: center;
    align-items: center;
    margin-top: 10px;
}

.d-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 3px; /* Reduced spacing */
    width: 120px; /* Reduced overall size */
    height: 120px; /* Added to maintain aspect ratio */
}

.d-pad .direction-btn {
    width: 40px; /* Slightly smaller buttons */
    height: 40px;
    border-radius: 50%;
    border: none;
    background-color: #4CAF50;
    color: white;
    font-size: 18px; /* Slightly smaller font */
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    transition: background-color 0.3s ease;
}

#up { grid-area: 1 / 2 / 2 / 3; }
#left { grid-area: 2 / 1 / 3 / 2; }
#right { grid-area: 2 / 3 / 3 / 4; }
#down { grid-area: 3 / 2 / 4 / 3; }

.d-pad .direction-btn:active {
    background-color: #45a049;
}

@media (max-width: 768px) {
    body.touch-device #touch-controls {
        display: flex; /* Show only on touch devices with smaller screens */
    }

    .d-pad {
        width: 150px;
        height: 150px;
    }

    .d-pad .direction-btn {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
}

@media (max-height: 600px) {
    .game-frame {
        max-height: 40vh;
    }

    #score, #message {
        margin-top: 0.3rem;
        font-size: 1rem;
    }

    .button-container {
        margin-top: 0.3rem;
    }

    #pauseButton, #soundButton {
        padding: 0.3rem;
        font-size: 0.9rem;
    }

    .d-pad {
        width: 150px;
        height: 150px;
    }

    .d-pad button {
        font-size: 1.5rem;
    }
}

#scoreHistoryContainer {
    margin-top: 20px;
    background-color: rgba(0, 0, 0, 0.8);
    border: 2px solid #00ff00;
    border-radius: 10px;
    padding: 10px;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 0 10px #00ff00;
}

#scoreHistoryContainer h2 {
    color: #00ff00;
    text-align: center;
    margin-bottom: 10px;
    font-family: 'Press Start 2P', cursive;
    text-transform: uppercase;
    text-shadow: 0 0 5px #00ff00;
}

#scoreHistory {
    max-height: 200px;
    overflow-y: auto;
    padding-right: 10px;
}

#scoreHistory::-webkit-scrollbar {
    width: 8px;
}

#scoreHistory::-webkit-scrollbar-track {
    background: #001a00;
    border-radius: 4px;
}

#scoreHistory::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 4px;
}

#scoreHistory::-webkit-scrollbar-thumb:hover {
    background: #00cc00;
}

#scoreHistory ul {
    list-style-type: none;
    padding: 0;
}

#scoreHistory li {
    color: #ffffff;
    margin-bottom: 10px;
    padding: 5px;
    background-color: rgba(0, 255, 0, 0.1);
    border-radius: 5px;
    font-family: 'Courier New', monospace;
    transition: all 0.3s ease;
}

#scoreHistory li:hover {
    background-color: rgba(0, 255, 0, 0.2);
    transform: translateX(5px);
}

#scoreHistory li::before {
    content: '🐍';
    margin-right: 5px;
}

/* Estilos para el scroll */
.game-wrapper::-webkit-scrollbar {
    width: 10px;
}

.game-wrapper::-webkit-scrollbar-track {
    background: #001a00;
}

.game-wrapper::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 5px;
}

.game-wrapper::-webkit-scrollbar-thumb:hover {
    background: #00cc00;
}

@media (max-width: 500px) {
    .canvas-container {
        width: 300px;
        height: 300px;
    }
}

/* ... otros estilos ... */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
}

.modal-content {
    background-color: #1a1a1a;
    color: #00ff00;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #00ff00;
    border-radius: 10px;
    width: 80%;
    max-width: 500px;
    box-shadow: 0 0 20px #00ff00;
}

.close {
    color: #00ff00;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: #00cc00;
    text-decoration: none;
}

.modal-content h2 {
    margin-top: 0;
    text-align: center;
}

.modal-content ul {
    padding-left: 20px;
}

.modal-content li {
    margin-bottom: 10px;
}

@media (max-width: 500px) {
    .modal-content {
        margin: 10% auto;
        width: 90%;
        padding: 15px;
    }
}

.canvas-container {
    width: 400px; /* Tamaño fijo */
    height: 400px; /* Tamaño fijo */
    margin: 10px auto;
    border: 2px solid #00ff00;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
}

#gameCanvas {
    width: 100%;
    height: 100%;
    background-color: #000;
    transition: background-color 0.5s ease;
}

@media (max-width: 500px) {
    .canvas-container {
        width: 300px; /* Tamaño más pequeño pero fijo para móviles */
        height: 300px;
    }
}

.title-container {
    display: flex;
    align-items: center;
    justify-content: center;
    
}

.snake-icon {
    width: 50px;
    height: 50px;
    transition: transform 0.3s ease;
}

.snake-left {
    transform: scaleX(-1);
}

.snake-right:hover, .snake-left:hover {
    transform: scale(1.1);
}

.snake-left:hover {
    transform: scaleX(-1) scale(1.1);
}

/* Añadimos un pequeño margen superior al contenedor del canvas si es necesario */
.canvas-container {
    margin-top: 10px;
}

#touch-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 10px;
}

.d-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 3px; /* Reduced spacing */
    width: 120px; /* Reduced overall size */
    height: 120px; /* Added to maintain aspect ratio */
}

.d-pad .direction-btn {
    width: 40px; /* Slightly smaller buttons */
    height: 40px;
    border-radius: 50%;
    border: none;
    background-color: #4CAF50;
    color: white;
    font-size: 18px; /* Slightly smaller font */
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    transition: background-color 0.3s ease;
}

#up { grid-area: 1 / 2 / 2 / 3; }
#left { grid-area: 2 / 1 / 3 / 2; }
#right { grid-area: 2 / 3 / 3 / 4; }
#down { grid-area: 3 / 2 / 4 / 3; }

.d-pad .direction-btn:active {
    background-color: #45a049;
}

@media (max-width: 768px) {
    .d-pad {
        width: 150px;
        height: 150px;
    }

    .d-pad .direction-btn {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
}

@media (max-height: 600px) {
    .game-frame {
        max-height: 40vh;
    }

* {
* {
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body {
    background-color: #1a1a1a;
    font-family: 'Arial', sans-serif;
    color: #00ff00;
}

.game-wrapper {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    min-height: 100%;
}

@keyframes rainbow {
    0% { color: #ff0000; } /* Rojo */
    14% { color: #ff7f00; } /* Naranja */
    28% { color: #ffff00; } /* Amarillo */
    42% { color: #00ff00; } /* Verde */
    57% { color: #0000ff; } /* Azul */
    71% { color: #8b00ff; } /* Violeta */
    85% { color: #ff00ff; } /* Magenta */
    100% { color: #ff0000; } /* Vuelve a rojo */
}

.game-title {
    font-family: 'Press Start 2P', cursive; /* Fuente estilo pixel art */
    font-size: 2.5rem; /* Reducido de 2.5rem */
    text-align: center;
    margin: 0 20px; /* Reducido de 20px */
    text-transform: uppercase;
    letter-spacing: 1px; /* Reducido de 2px */
    animation: rainbow 8s linear infinite;
    text-shadow: 
        1px 1px 0 #000,
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000;
    margin-right: 10px;  /* Espacio entre el título y la imagen */
}

@media (max-width: 500px) {
    .game-title {
        font-size: 1.2rem; /* Reducido de 1.8rem */
    }
}

#score, #message {
    margin-top: 0.5rem;
    font-size: 1.2rem;
    text-align: center;
}

.button-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
}

.button-container button {
    width: 40px;
    height: 40px;
    font-size: 20px;
    background-color: #333;
    color: #00ff00;
    border: 1px solid #00ff00;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
}

.button-container button:hover {
    background-color: #444;
    box-shadow: 0 0 5px #00ff00;
}

.button-container button:active {
    transform: scale(0.95);
}

@media (max-width: 500px) {
    .button-container button {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }
}

#pauseButton, #soundButton, #instructionsButton {
    width: 40px;
    height: 40px;
    font-size: 18px;
    background-color: #333;
    color: #00ff00;
    border: 1px solid #00ff00;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

#pauseButton:hover, #soundButton:hover, #instructionsButton:hover {
    background-color: #444;
    box-shadow: 0 0 5px #00ff00;
}

#pauseButton:active, #soundButton:active, #instructionsButton:active {
    transform: scale(0.95);
}

@media (max-width: 500px) {
    #pauseButton, #soundButton, #instructionsButton {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
}

#touch-controls {
    display: none; /* Hide by default */
    justify-content: center;
    align-items: center;
    margin-top: 10px;
}

.d-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 3px; /* Reduced spacing */
    width: 120px; /* Reduced overall size */
    height: 120px; /* Added to maintain aspect ratio */
}

.d-pad .direction-btn {
    width: 40px; /* Slightly smaller buttons */
    height: 40px;
    border-radius: 50%;
    border: none;
    background-color: #4CAF50;
    color: white;
    font-size: 18px; /* Slightly smaller font */
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    transition: background-color 0.3s ease;
}

#up { grid-area: 1 / 2 / 2 / 3; }
#left { grid-area: 2 / 1 / 3 / 2; }
#right { grid-area: 2 / 3 / 3 / 4; }
#down { grid-area: 3 / 2 / 4 / 3; }

.d-pad .direction-btn:active {
    background-color: #45a049;
}

@media (max-width: 768px) {
    body.touch-device #touch-controls {
        display: flex; /* Show only on touch devices with smaller screens */
    }

    .d-pad {
        width: 150px;
        height: 150px;
    }

    .d-pad .direction-btn {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
}

@media (max-height: 600px) {
    .game-frame {
        max-height: 40vh;
    }

    #score, #message {
        margin-top: 0.3rem;
        font-size: 1rem;
    }

    .button-container {
        margin-top: 0.3rem;
    }

    #pauseButton, #soundButton {
        padding: 0.3rem;
        font-size: 0.9rem;
    }

    .d-pad {
        width: 150px;
        height: 150px;
    }

    .d-pad button {
        font-size: 1.5rem;
    }
}

#scoreHistoryContainer {
    margin-top: 20px;
    background-color: rgba(0, 0, 0, 0.8);
    border: 2px solid #00ff00;
    border-radius: 10px;
    padding: 10px;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 0 10px #00ff00;
}

#scoreHistoryContainer h2 {
    color: #00ff00;
    text-align: center;
    margin-bottom: 10px;
    font-family: 'Press Start 2P', cursive;
    text-transform: uppercase;
    text-shadow: 0 0 5px #00ff00;
}

#scoreHistory {
    max-height: 200px;
    overflow-y: auto;
    padding-right: 10px;
}

#scoreHistory::-webkit-scrollbar {
    width: 8px;
}

#scoreHistory::-webkit-scrollbar-track {
    background: #001a00;
    border-radius: 4px;
}

#scoreHistory::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 4px;
}

#scoreHistory::-webkit-scrollbar-thumb:hover {
    background: #00cc00;
}

#scoreHistory ul {
    list-style-type: none;
    padding: 0;
}

#scoreHistory li {
    color: #ffffff;
    margin-bottom: 10px;
    padding: 5px;
    background-color: rgba(0, 255, 0, 0.1);
    border-radius: 5px;
    font-family: 'Courier New', monospace;
    transition: all 0.3s ease;
}

#scoreHistory li:hover {
    background-color: rgba(0, 255, 0, 0.2);
    transform: translateX(5px);
}

#scoreHistory li::before {
    content: '🐍';
    margin-right: 5px;
}

/* Estilos para el scroll */
.game-wrapper::-webkit-scrollbar {
    width: 10px;
}

.game-wrapper::-webkit-scrollbar-track {
    background: #001a00;
}

.game-wrapper::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 5px;
}

.game-wrapper::-webkit-scrollbar-thumb:hover {
    background: #00cc00;
}

@media (max-width: 500px) {
    .canvas-container {
        width: 300px;
        height: 300px;
    }
}

/* ... otros estilos ... */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
}

.modal-content {
    background-color: #1a1a1a;
    color: #00ff00;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #00ff00;
    border-radius: 10px;
    width: 80%;
    max-width: 500px;
    box-shadow: 0 0 20px #00ff00;
}

.close {
    color: #00ff00;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: #00cc00;
    text-decoration: none;
}

.modal-content h2 {
    margin-top: 0;
    text-align: center;
}

.modal-content ul {
    padding-left: 20px;
}

.modal-content li {
    margin-bottom: 10px;
}

@media (max-width: 500px) {
    .modal-content {
        margin: 10% auto;
        width: 90%;
        padding: 15px;
    }
}

.canvas-container {
    width: 400px; /* Tamaño fijo */
    height: 400px; /* Tamaño fijo */
    margin: 10px auto;
    border: 2px solid #00ff00;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
}

#gameCanvas {
    width: 100%;
    height: 100%;
    background-color: #000;
    transition: background-color 0.5s ease;
}

@media (max-width: 500px) {
    .canvas-container {
        width: 300px; /* Tamaño más pequeño pero fijo para móviles */
        height: 300px;
    }
}

.title-container {
    display: flex;
    align-items: center;
    justify-content: center;
    
}

.snake-icon {
    width: 50px;
    height: 50px;
    transition: transform 0.3s ease;
}

.snake-left {
    transform: scaleX(-1);
}

.snake-right:hover, .snake-left:hover {
    transform: scale(1.1);
}

.snake-left:hover {
    transform: scaleX(-1) scale(1.1);
}

/* Añadimos un pequeño margen superior al contenedor del canvas si es necesario */
.canvas-container {
    margin-top: 10px;
}

#touch-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 10px;
}

.d-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 3px; /* Reduced spacing */
    width: 120px; /* Reduced overall size */
    height: 120px; /* Added to maintain aspect ratio */
}

.d-pad .direction-btn {
    width: 40px; /* Slightly smaller buttons */
    height: 40px;
    border-radius: 50%;
    border: none;
    background-color: #4CAF50;
    color: white;
    font-size: 18px; /* Slightly smaller font */
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    transition: background-color 0.3s ease;
}

#up { grid-area: 1 / 2 / 2 / 3; }
#left { grid-area: 2 / 1 / 3 / 2; }
#right { grid-area: 2 / 3 / 3 / 4; }
#down { grid-area: 3 / 2 / 4 / 3; }

.d-pad .direction-btn:active {
    background-color: #45a049;
}

@media (max-width: 768px) {
    .d-pad {
        width: 150px;
        height: 150px;
    }

    .d-pad .direction-btn {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
}

@media (max-height: 600px) {
    .game-frame {
        max-height: 40vh;
    }

* {
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body {
    background-color: #1a1a1a;
    font-family: 'Arial', sans-serif;
    color: #00ff00;
}

.game-wrapper {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    min-height: 100%;
}

@keyframes rainbow {
    0% { color: #ff0000; } /* Rojo */
    14% { color: #ff7f00; } /* Naranja */
    28% { color: #ffff00; } /* Amarillo */
    42% { color: #00ff00; } /* Verde */
    57% { color: #0000ff; } /* Azul */
    71% { color: #8b00ff; } /* Violeta */
    85% { color: #ff00ff; } /* Magenta */
    100% { color: #ff0000; } /* Vuelve a rojo */
}

.game-title {
    font-family: 'Press Start 2P', cursive; /* Fuente estilo pixel art */
    font-size: 2.5rem; /* Reducido de 2.5rem */
    text-align: center;
    margin: 0 20px; /* Reducido de 20px */
    text-transform: uppercase;
    letter-spacing: 1px; /* Reducido de 2px */
    animation: rainbow 8s linear infinite;
    text-shadow: 
        1px 1px 0 #000,
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000;
    margin-right: 10px;  /* Espacio entre el título y la imagen */
}

@media (max-width: 500px) {
    .game-title {
        font-size: 1.2rem; /* Reducido de 1.8rem */
    }
}

#score, #message {
    margin-top: 0.5rem;
    font-size: 1.2rem;
    text-align: center;
}

.button-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
}

.button-container button {
    width: 40px;
    height: 40px;
    font-size: 20px;
    background-color: #333;
    color: #00ff00;
    border: 1px solid #00ff00;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
}

.button-container button:hover {
    background-color: #444;
    box-shadow: 0 0 5px #00ff00;
}

.button-container button:active {
    transform: scale(0.95);
}

@media (max-width: 500px) {
    .button-container button {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }
}

#pauseButton, #soundButton, #instructionsButton {
    width: 40px;
    height: 40px;
    font-size: 18px;
    background-color: #333;
    color: #00ff00;
    border: 1px solid #00ff00;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

#pauseButton:hover, #soundButton:hover, #instructionsButton:hover {
    background-color: #444;
    box-shadow: 0 0 5px #00ff00;
}

#pauseButton:active, #soundButton:active, #instructionsButton:active {
    transform: scale(0.95);
}

@media (max-width: 500px) {
    #pauseButton, #soundButton, #instructionsButton {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
}

#touch-controls {
    display: none; /* Hide by default */
    justify-content: center;
    align-items: center;
    margin-top: 10px;
}

.d-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 3px; /* Reduced spacing */
    width: 120px; /* Reduced overall size */
    height: 120px; /* Added to maintain aspect ratio */
}

.d-pad .direction-btn {
    width: 40px; /* Slightly smaller buttons */
    height: 40px;
    border-radius: 50%;
    border: none;
    background-color: #4CAF50;
    color: white;
    font-size: 18px; /* Slightly smaller font */
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    transition: background-color 0.3s ease;
}

#up { grid-area: 1 / 2 / 2 / 3; }
#left { grid-area: 2 / 1 / 3 / 2; }
#right { grid-area: 2 / 3 / 3 / 4; }
#down { grid-area: 3 / 2 / 4 / 3; }

.d-pad .direction-btn:active {
    background-color: #45a049;
}

body.touch-device #touch-controls {
    display: flex; /* Show only when body has 'touch-device' class */
}

@media (max-width: 768px) {
    .d-pad {
        width: 150px;
        height: 150px;
    }

    .d-pad .direction-btn {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
}

@media (max-height: 600px) {
    .game-frame {
        max-height: 40vh;
    }

    #score, #message {
        margin-top: 0.3rem;
        font-size: 1rem;
    }

    .button-container {
        margin-top: 0.3rem;
    }

    #pauseButton, #soundButton {
        padding: 0.3rem;
        font-size: 0.9rem;
    }

    .d-pad {
        width: 150px;
        height: 150px;
    }

    .d-pad button {
        font-size: 1.5rem;
    }
}

#scoreHistoryContainer {
    margin-top: 20px;
    background-color: rgba(0, 0, 0, 0.8);
    border: 2px solid #00ff00;
    border-radius: 10px;
    padding: 10px;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 0 10px #00ff00;
}

#scoreHistoryContainer h2 {
    color: #00ff00;
    text-align: center;
    margin-bottom: 10px;
    font-family: 'Press Start 2P', cursive;
    text-transform: uppercase;
    text-shadow: 0 0 5px #00ff00;
}

#scoreHistory {
    max-height: 200px;
    overflow-y: auto;
    padding-right: 10px;
}

#scoreHistory::-webkit-scrollbar {
    width: 8px;
}

#scoreHistory::-webkit-scrollbar-track {
    background: #001a00;
    border-radius: 4px;
}

#scoreHistory::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 4px;
}

#scoreHistory::-webkit-scrollbar-thumb:hover {
    background: #00cc00;
}

#scoreHistory ul {
    list-style-type: none;
    padding: 0;
}

#scoreHistory li {
    color: #ffffff;
    margin-bottom: 10px;
    padding: 5px;
    background-color: rgba(0, 255, 0, 0.1);
    border-radius: 5px;
    font-family: 'Courier New', monospace;
    transition: all 0.3s ease;
}

#scoreHistory li:hover {
    background-color: rgba(0, 255, 0, 0.2);
    transform: translateX(5px);
}

#scoreHistory li::before {
    content: '🐍';
    margin-right: 5px;
}

/* Estilos para el scroll */
.game-wrapper::-webkit-scrollbar {
    width: 10px;
}

.game-wrapper::-webkit-scrollbar-track {
    background: #001a00;
}

.game-wrapper::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 5px;
}

.game-wrapper::-webkit-scrollbar-thumb:hover {
    background: #00cc00;
}

@media (max-width: 500px) {
    .canvas-container {
        width: 300px;
        height: 300px;
    }
}

/* ... otros estilos ... */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
}

.modal-content {
    background-color: #1a1a1a;
    color: #00ff00;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #00ff00;
    border-radius: 10px;
    width: 80%;
    max-width: 500px;
    box-shadow: 0 0 20px #00ff00;
}

.close {
    color: #00ff00;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: #00cc00;
    text-decoration: none;
}

.modal-content h2 {
    margin-top: 0;
    text-align: center;
}

.modal-content ul {
    padding-left: 20px;
}

.modal-content li {
    margin-bottom: 10px;
}

@media (max-width: 500px) {
    .modal-content {
        margin: 10% auto;
        width: 90%;
        padding: 15px;
    }
}

.canvas-container {
    width: 400px; /* Tamaño fijo */
    height: 400px; /* Tamaño fijo */
    margin: 10px auto;
    border: 2px solid #00ff00;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
}

#gameCanvas {
    width: 100%;
    height: 100%;
    background-color: #000;
    transition: background-color 0.5s ease;
}

@media (max-width: 500px) {
    .canvas-container {
        width: 300px; /* Tamaño más pequeño pero fijo para móviles */
        height: 300px;
    }
}

.title-container {
    display: flex;
    align-items: center;
    justify-content: center;
    
}

.snake-icon {
    width: 50px;
    height: 50px;
    transition: transform 0.3s ease;
}

.snake-left {
    transform: scaleX(-1);
}

.snake-right:hover, .snake-left:hover {
    transform: scale(1.1);
}

.snake-left:hover {
    transform: scaleX(-1) scale(1.1);
}

/* Añadimos un pequeño margen superior al contenedor del canvas si es necesario */
.canvas-container {
    margin-top: 10px;
}

#touch-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 10px;
}

.d-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 3px; /* Reduced spacing */
    width: 120px; /* Reduced overall size */
    height: 120px; /* Added to maintain aspect ratio */
}

.d-pad .direction-btn {
    width: 40px; /* Slightly smaller buttons */
    height: 40px;
    border-radius: 50%;
    border: none;
    background-color: #4CAF50;
    color: white;
    font-size: 18px; /* Slightly smaller font */
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    transition: background-color 0.3s ease;
}

#up { grid-area: 1 / 2 / 2 / 3; }
#left { grid-area: 2 / 1 / 3 / 2; }
#right { grid-area: 2 / 3 / 3 / 4; }
#down { grid-area: 3 / 2 / 4 / 3; }

.d-pad .direction-btn:active {
    background-color: #45a049;
}

@media (max-width: 768px) {
    .d-pad {
        width: 150px;
        height: 150px;
    }

    .d-pad .direction-btn {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
}

@media (max-height: 600px) {
    .game-frame {
        max-height: 40vh;
    }

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body {
    background-color: #1a1a1a;
    font-family: 'Arial', sans-serif;
    color: #00ff00;
}

.game-wrapper {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    min-height: 100%;
}

@keyframes rainbow {
    0% { color: #ff0000; } /* Rojo */
    14% { color: #ff7f00; } /* Naranja */
    28% { color: #ffff00; } /* Amarillo */
    42% { color: #00ff00; } /* Verde */
    57% { color: #0000ff; } /* Azul */
    71% { color: #8b00ff; } /* Violeta */
    85% { color: #ff00ff; } /* Magenta */
    100% { color: #ff0000; } /* Vuelve a rojo */
}

.game-title {
    font-family: 'Press Start 2P', cursive; /* Fuente estilo pixel art */
    font-size: 2.5rem; /* Reducido de 2.5rem */
    text-align: center;
    margin: 0 20px; /* Reducido de 20px */
    text-transform: uppercase;
    letter-spacing: 1px; /* Reducido de 2px */
    animation: rainbow 8s linear infinite;
    text-shadow: 
        1px 1px 0 #000,
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000;
    margin-right: 10px;  /* Espacio entre el título y la imagen */
}

@media (max-width: 500px) {
    .game-title {
        font-size: 1.2rem; /* Reducido de 1.8rem */
    }
}

#score, #message {
    margin-top: 0.5rem;
    font-size: 1.2rem;
    text-align: center;
}

.button-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
}

.button-container button {
    width: 40px;
    height: 40px;
    font-size: 20px;
    background-color: #333;
    color: #00ff00;
    border: 1px solid #00ff00;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
}

.button-container button:hover {
    background-color: #444;
    box-shadow: 0 0 5px #00ff00;
}

.button-container button:active {
    transform: scale(0.95);
}

@media (max-width: 500px) {
    .button-container button {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }
}

#pauseButton, #soundButton, #instructionsButton {
    width: 40px;
    height: 40px;
    font-size: 18px;
    background-color: #333;
    color: #00ff00;
    border: 1px solid #00ff00;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

#pauseButton:hover, #soundButton:hover, #instructionsButton:hover {
    background-color: #444;
    box-shadow: 0 0 5px #00ff00;
}

#pauseButton:active, #soundButton:active, #instructionsButton:active {
    transform: scale(0.95);
}

@media (max-width: 500px) {
    #pauseButton, #soundButton, #instructionsButton {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
}

#touch-controls {
    display: none; /* Hide by default */
    justify-content: center;
    align-items: center;
    margin-top: 10px;
}

.d-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 3px; /* Reduced spacing */
    width: 120px; /* Reduced overall size */
    height: 120px; /* Added to maintain aspect ratio */
}

.d-pad .direction-btn {
    width: 40px; /* Slightly smaller buttons */
    height: 40px;
    border-radius: 50%;
    border: none;
    background-color: #4CAF50;
    color: white;
    font-size: 18px; /* Slightly smaller font */
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    transition: background-color 0.3s ease;
}

#up { grid-area: 1 / 2 / 2 / 3; }
#left { grid-area: 2 / 1 / 3 / 2; }
#right { grid-area: 2 / 3 / 3 / 4; }
#down { grid-area: 3 / 2 / 4 / 3; }

.d-pad .direction-btn:active {
    background-color: #45a049;
}

@media (max-width: 768px) {
    #touch-controls {
        display: flex; /* Show on mobile devices */
    }

    .d-pad {
        width: 150px;
        height: 150px;
    }

    .d-pad .direction-btn {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
}

@media (max-height: 600px) {
    .game-frame {
        max-height: 40vh;
    }

    #score, #message {
        margin-top: 0.3rem;
        font-size: 1rem;
    }

    .button-container {
        margin-top: 0.3rem;
    }

    #pauseButton, #soundButton {
        padding: 0.3rem;
        font-size: 0.9rem;
    }

    .d-pad {
        width: 150px;
        height: 150px;
    }

    .d-pad button {
        font-size: 1.5rem;
    }
}

#scoreHistoryContainer {
    margin-top: 20px;
    background-color: rgba(0, 0, 0, 0.8);
    border: 2px solid #00ff00;
    border-radius: 10px;
    padding: 10px;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 0 10px #00ff00;
}

#scoreHistoryContainer h2 {
    color: #00ff00;
    text-align: center;
    margin-bottom: 10px;
    font-family: 'Press Start 2P', cursive;
    text-transform: uppercase;
    text-shadow: 0 0 5px #00ff00;
}

#scoreHistory {
    max-height: 200px;
    overflow-y: auto;
    padding-right: 10px;
}

#scoreHistory::-webkit-scrollbar {
    width: 8px;
}

#scoreHistory::-webkit-scrollbar-track {
    background: #001a00;
    border-radius: 4px;
}

#scoreHistory::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 4px;
}

#scoreHistory::-webkit-scrollbar-thumb:hover {
    background: #00cc00;
}

#scoreHistory ul {
    list-style-type: none;
    padding: 0;
}

#scoreHistory li {
    color: #ffffff;
    margin-bottom: 10px;
    padding: 5px;
    background-color: rgba(0, 255, 0, 0.1);
    border-radius: 5px;
    font-family: 'Courier New', monospace;
    transition: all 0.3s ease;
}

#scoreHistory li:hover {
    background-color: rgba(0, 255, 0, 0.2);
    transform: translateX(5px);
}

#scoreHistory li::before {
    content: '🐍';
    margin-right: 5px;
}

/* Estilos para el scroll */
.game-wrapper::-webkit-scrollbar {
    width: 10px;
}

.game-wrapper::-webkit-scrollbar-track {
    background: #001a00;
}

.game-wrapper::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 5px;
}

.game-wrapper::-webkit-scrollbar-thumb:hover {
    background: #00cc00;
}

@media (max-width: 500px) {
    .canvas-container {
        width: 300px;
        height: 300px;
    }
}

/* ... otros estilos ... */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
}

.modal-content {
    background-color: #1a1a1a;
    color: #00ff00;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #00ff00;
    border-radius: 10px;
    width: 80%;
    max-width: 500px;
    box-shadow: 0 0 20px #00ff00;
}

.close {
    color: #00ff00;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: #00cc00;
    text-decoration: none;
}

.modal-content h2 {
    margin-top: 0;
    text-align: center;
}

.modal-content ul {
    padding-left: 20px;
}

.modal-content li {
    margin-bottom: 10px;
}

@media (max-width: 500px) {
    .modal-content {
        margin: 10% auto;
        width: 90%;
        padding: 15px;
    }
}

.canvas-container {
    width: 400px; /* Tamaño fijo */
    height: 400px; /* Tamaño fijo */
    margin: 10px auto;
    border: 2px solid #00ff00;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
}

#gameCanvas {
    width: 100%;
    height: 100%;
    background-color: #000;
    transition: background-color 0.5s ease;
}

@media (max-width: 500px) {
    .canvas-container {
        width: 300px; /* Tamaño más pequeño pero fijo para móviles */
        height: 300px;
    }
}

.title-container {
    display: flex;
    align-items: center;
    justify-content: center;
    
}

.snake-icon {
    width: 50px;
    height: 50px;
    transition: transform 0.3s ease;
}

.snake-left {
    transform: scaleX(-1);
}

.snake-right:hover, .snake-left:hover {
    transform: scale(1.1);
}

.snake-left:hover {
    transform: scaleX(-1) scale(1.1);
}

/* Añadimos un pequeño margen superior al contenedor del canvas si es necesario */
.canvas-container {
    margin-top: 10px;
}

#touch-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 10px;
}

.d-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 3px; /* Reduced spacing */
    width: 120px; /* Reduced overall size */
    height: 120px; /* Added to maintain aspect ratio */
}

.d-pad .direction-btn {
    width: 40px; /* Slightly smaller buttons */
    height: 40px;
    border-radius: 50%;
    border: none;
    background-color: #4CAF50;
    color: white;
    font-size: 18px; /* Slightly smaller font */
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    transition: background-color 0.3s ease;
}

#up { grid-area: 1 / 2 / 2 / 3; }
#left { grid-area: 2 / 1 / 3 / 2; }
#right { grid-area: 2 / 3 / 3 / 4; }
#down { grid-area: 3 / 2 / 4 / 3; }

.d-pad .direction-btn:active {
    background-color: #45a049;
}

@media (max-width: 768px) {
    .d-pad {
        width: 150px;
        height: 150px;
    }

    .d-pad .direction-btn {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
}

@media (max-height: 600px) {
    .game-frame {
        max-height: 40vh;
    }

    #score, #message {
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body {
    background-color: #1a1a1a;
    font-family: 'Arial', sans-serif;
    color: #00ff00;
}

.game-wrapper {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    min-height: 100%;
}

@keyframes rainbow {
    0% { color: #ff0000; } /* Rojo */
    14% { color: #ff7f00; } /* Naranja */
    28% { color: #ffff00; } /* Amarillo */
    42% { color: #00ff00; } /* Verde */
    57% { color: #0000ff; } /* Azul */
    71% { color: #8b00ff; } /* Violeta */
    85% { color: #ff00ff; } /* Magenta */
    100% { color: #ff0000; } /* Vuelve a rojo */
}

.game-title {
    font-family: 'Press Start 2P', cursive; /* Fuente estilo pixel art */
    font-size: 2.5rem; /* Reducido de 2.5rem */
    text-align: center;
    margin: 0 20px; /* Reducido de 20px */
    text-transform: uppercase;
    letter-spacing: 1px; /* Reducido de 2px */
    animation: rainbow 8s linear infinite;
    text-shadow: 
        1px 1px 0 #000,
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000;
    margin-right: 10px;  /* Espacio entre el título y la imagen */
}

@media (max-width: 500px) {
    .game-title {
        font-size: 1.2rem; /* Reducido de 1.8rem */
    }
}

#score, #message {
    margin-top: 0.5rem;
    font-size: 1.2rem;
    text-align: center;
}

.button-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
}

.button-container button {
    width: 40px;
    height: 40px;
    font-size: 20px;
    background-color: #333;
    color: #00ff00;
    border: 1px solid #00ff00;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
}

.button-container button:hover {
    background-color: #444;
    box-shadow: 0 0 5px #00ff00;
}

.button-container button:active {
    transform: scale(0.95);
}

@media (max-width: 500px) {
    .button-container button {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }
}

#pauseButton, #soundButton, #instructionsButton {
    width: 40px;
    height: 40px;
    font-size: 18px;
    background-color: #333;
    color: #00ff00;
    border: 1px solid #00ff00;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

#pauseButton:hover, #soundButton:hover, #instructionsButton:hover {
    background-color: #444;
    box-shadow: 0 0 5px #00ff00;
}

#pauseButton:active, #soundButton:active, #instructionsButton:active {
    transform: scale(0.95);
}

@media (max-width: 500px) {
    #pauseButton, #soundButton, #instructionsButton {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
}

#touch-controls {
    margin-top: 10px; /* Reducido de 20px a 10px */
    display: none;
    width: 100%;
}

.d-pad {
    position: relative;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 5px; /* Reducido de 10px a 5px */
    width: 150px; /* Reducido de 180px a 150px */
    height: 150px; /* Reducido de 180px a 150px */
    margin: 0 auto;
}

.d-pad .direction-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background-color: #4CAF50;
    color: white;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    transition: background-color 0.3s ease;
}

.d-pad .direction-btn:active {
    background-color: #45a049;
}

@media (max-width: 768px) {
    .d-pad .direction-btn {
        width: 60px;
        height: 60px;
        font-size: 24px;
    }
}

.d-pad #up { grid-area: 1 / 2 / 2 / 3; }
.d-pad #left { grid-area: 2 / 1 / 3 / 2; }
.d-pad #right { grid-area: 2 / 3 / 3 / 4; }
.d-pad #down { grid-area: 3 / 2 / 4 / 3; }

@media (max-width: 768px) {
    .game-container {
        justify-content: flex-start;
        padding-top: 1rem;
    }

    .game-frame {
        max-height: 50vh;
    }

    #touch-controls {
        display: flex;
        justify-content: center;
        align-items: center;
        margin-top: 20px;
    }

    .d-pad {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: repeat(3, 1fr);
        gap: 10px;
        width: 200px;
        height: 200px;
    }

    .d-pad button {
        width: 100%;
        height: 100%;
    }

    .d-pad #up { grid-area: 1 / 2 / 2 / 3; }
    .d-pad #left { grid-area: 2 / 1 / 3 / 2; }
    .d-pad #right { grid-area: 2 / 3 / 3 / 4; }
    .d-pad #down { grid-area: 3 / 2 / 4 / 3; }
}

@media (max-height: 600px) {
    .game-frame {
        max-height: 40vh;
    }

    #score, #message {
        margin-top: 0.3rem;
        font-size: 1rem;
    }

    .button-container {
        margin-top: 0.3rem;
    }

    #pauseButton, #soundButton {
        padding: 0.3rem;
        font-size: 0.9rem;
    }

    .d-pad {
        width: 150px;
        height: 150px;
    }

    .d-pad button {
        font-size: 1.5rem;
    }
}

#scoreHistoryContainer {
    margin-top: 20px;
    background-color: rgba(0, 0, 0, 0.8);
    border: 2px solid #00ff00;
    border-radius: 10px;
    padding: 10px;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 0 10px #00ff00;
}

#scoreHistoryContainer h2 {
    color: #00ff00;
    text-align: center;
    margin-bottom: 10px;
    font-family: 'Press Start 2P', cursive;
    text-transform: uppercase;
    text-shadow: 0 0 5px #00ff00;
}

#scoreHistory {
    max-height: 200px;
    overflow-y: auto;
    padding-right: 10px;
}

#scoreHistory::-webkit-scrollbar {
    width: 8px;
}

#scoreHistory::-webkit-scrollbar-track {
    background: #001a00;
    border-radius: 4px;
}

#scoreHistory::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 4px;
}

#scoreHistory::-webkit-scrollbar-thumb:hover {
    background: #00cc00;
}

#scoreHistory ul {
    list-style-type: none;
    padding: 0;
}

#scoreHistory li {
    color: #ffffff;
    margin-bottom: 10px;
    padding: 5px;
    background-color: rgba(0, 255, 0, 0.1);
    border-radius: 5px;
    font-family: 'Courier New', monospace;
    transition: all 0.3s ease;
}

#scoreHistory li:hover {
    background-color: rgba(0, 255, 0, 0.2);
    transform: translateX(5px);
}

#scoreHistory li::before {
    content: '🐍';
    margin-right: 5px;
}

/* Estilos para el scroll */
.game-wrapper::-webkit-scrollbar {
    width: 10px;
}

.game-wrapper::-webkit-scrollbar-track {
    background: #001a00;
}

.game-wrapper::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 5px;
}

.game-wrapper::-webkit-scrollbar-thumb:hover {
    background: #00cc00;
}

@media (max-width: 500px) {
    .canvas-container {
        width: 300px;
        height: 300px;
    }
}

/* ... otros estilos ... */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
}

.modal-content {
    background-color: #1a1a1a;
    color: #00ff00;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #00ff00;
    border-radius: 10px;
    width: 80%;
    max-width: 500px;
    box-shadow: 0 0 20px #00ff00;
}

.close {
    color: #00ff00;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: #00cc00;
    text-decoration: none;
}

.modal-content h2 {
    margin-top: 0;
    text-align: center;
}

.modal-content ul {
    padding-left: 20px;
}

.modal-content li {
    margin-bottom: 10px;
}

@media (max-width: 500px) {
    .modal-content {
        margin: 10% auto;
        width: 90%;
        padding: 15px;
    }
}

.canvas-container {
    width: 400px; /* Tamaño fijo */
    height: 400px; /* Tamaño fijo */
    margin: 10px auto;
    border: 2px solid #00ff00;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
}

#gameCanvas {
    width: 100%;
    height: 100%;
    background-color: #000;
    transition: background-color 0.5s ease;
}

@media (max-width: 500px) {
    .canvas-container {
        width: 300px; /* Tamaño más pequeño pero fijo para móviles */
        height: 300px;
    }
}

.title-container {
    display: flex;
    align-items: center;
    justify-content: center;
    
}

.snake-icon {
    width: 50px;
    height: 50px;
    transition: transform 0.3s ease;
}

.snake-left {
    transform: scaleX(-1);
}

.snake-right:hover, .snake-left:hover {
    transform: scale(1.1);
}

.snake-left:hover {
    transform: scaleX(-1) scale(1.1);
}

/* Añadimos un pequeño margen superior al contenedor del canvas si es necesario */
.canvas-container {
    margin-top: 10px;
}

#touch-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 10px;
}

.d-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 3px; /* Reduced spacing */
    width: 120px; /* Reduced overall size */
    height: 120px; /* Added to maintain aspect ratio */
}

.d-pad .direction-btn {
    width: 40px; /* Slightly smaller buttons */
    height: 40px;
    border-radius: 50%;
    border: none;
    background-color: #4CAF50;
    color: white;
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body {
    background-color: #1a1a1a;
    font-family: 'Arial', sans-serif;
    color: #00ff00;
}

.game-wrapper {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    min-height: 100%;
}

@keyframes rainbow {
    0% { color: #ff0000; } /* Rojo */
    14% { color: #ff7f00; } /* Naranja */
    28% { color: #ffff00; } /* Amarillo */
    42% { color: #00ff00; } /* Verde */
    57% { color: #0000ff; } /* Azul */
    71% { color: #8b00ff; } /* Violeta */
    85% { color: #ff00ff; } /* Magenta */
    100% { color: #ff0000; } /* Vuelve a rojo */
}

.game-title {
    font-family: 'Press Start 2P', cursive; /* Fuente estilo pixel art */
    font-size: 2.5rem; /* Reducido de 2.5rem */
    text-align: center;
    margin: 0 20px; /* Reducido de 20px */
    text-transform: uppercase;
    letter-spacing: 1px; /* Reducido de 2px */
    animation: rainbow 8s linear infinite;
    text-shadow: 
        1px 1px 0 #000,
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000;
    margin-right: 10px;  /* Espacio entre el título y la imagen */
}

@media (max-width: 500px) {
    .game-title {
        font-size: 1.2rem; /* Reducido de 1.8rem */
    }
}

#score, #message {
    margin-top: 0.5rem;
    font-size: 1.2rem;
    text-align: center;
}

.button-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
}

.button-container button {
    width: 40px;
    height: 40px;
    font-size: 20px;
    background-color: #333;
    color: #00ff00;
    border: 1px solid #00ff00;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
}

.button-container button:hover {
    background-color: #444;
    box-shadow: 0 0 5px #00ff00;
}

.button-container button:active {
    transform: scale(0.95);
}

@media (max-width: 500px) {
    .button-container button {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }
}

#pauseButton, #soundButton, #instructionsButton {
    width: 40px;
    height: 40px;
    font-size: 18px;
    background-color: #333;
    color: #00ff00;
    border: 1px solid #00ff00;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

#pauseButton:hover, #soundButton:hover, #instructionsButton:hover {
    background-color: #444;
    box-shadow: 0 0 5px #00ff00;
}

#pauseButton:active, #soundButton:active, #instructionsButton:active {
    transform: scale(0.95);
}

@media (max-width: 500px) {
    #pauseButton, #soundButton, #instructionsButton {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
}

#touch-controls {
    margin-top: 10px; /* Reducido de 20px a 10px */
    display: none;
    width: 100%;
}

.d-pad {
    position: relative;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 5px; /* Reducido de 10px a 5px */
    width: 150px; /* Reducido de 180px a 150px */
    height: 150px; /* Reducido de 180px a 150px */
    margin: 0 auto;
}

.d-pad .direction-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background-color: #4CAF50;
    color: white;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    transition: background-color 0.3s ease;
}

.d-pad .direction-btn:active {
    background-color: #45a049;
}

@media (max-width: 768px) {
    .d-pad .direction-btn {
        width: 60px;
        height: 60px;
        font-size: 24px;
    }
}

.d-pad #up { grid-area: 1 / 2 / 2 / 3; }
.d-pad #left { grid-area: 2 / 1 / 3 / 2; }
.d-pad #right { grid-area: 2 / 3 / 3 / 4; }
.d-pad #down { grid-area: 3 / 2 / 4 / 3; }

@media (max-width: 768px) {
    .game-container {
        justify-content: flex-start;
        padding-top: 1rem;
    }

    .game-frame {
        max-height: 50vh;
    }

    #touch-controls {
        display: flex;
        justify-content: center;
        align-items: center;
        margin-top: 20px;
    }

    .d-pad {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: repeat(3, 1fr);
        gap: 10px;
        width: 200px;
        height: 200px;
    }

    .d-pad button {
        width: 100%;
        height: 100%;
    }

    .d-pad #up { grid-area: 1 / 2 / 2 / 3; }
    .d-pad #left { grid-area: 2 / 1 / 3 / 2; }
    .d-pad #right { grid-area: 2 / 3 / 3 / 4; }
    .d-pad #down { grid-area: 3 / 2 / 4 / 3; }
}

@media (max-height: 600px) {
    .game-frame {
        max-height: 40vh;
    }

    #score, #message {
        margin-top: 0.3rem;
        font-size: 1rem;
    }

    .button-container {
        margin-top: 0.3rem;
    }

    #pauseButton, #soundButton {
        padding: 0.3rem;
        font-size: 0.9rem;
    }

    .d-pad {
        width: 150px;
        height: 150px;
    }

    .d-pad button {
        font-size: 1.5rem;
    }
}

#scoreHistoryContainer {
    margin-top: 20px;
    background-color: rgba(0, 0, 0, 0.8);
    border: 2px solid #00ff00;
    border-radius: 10px;
    padding: 10px;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 0 10px #00ff00;
}

#scoreHistoryContainer h2 {
    color: #00ff00;
    text-align: center;
    margin-bottom: 10px;
    font-family: 'Press Start 2P', cursive;
    text-transform: uppercase;
    text-shadow: 0 0 5px #00ff00;
}

#scoreHistory {
    max-height: 200px;
    overflow-y: auto;
    padding-right: 10px;
}

#scoreHistory::-webkit-scrollbar {
    width: 8px;
}

#scoreHistory::-webkit-scrollbar-track {
    background: #001a00;
    border-radius: 4px;
}

#scoreHistory::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 4px;
}

#scoreHistory::-webkit-scrollbar-thumb:hover {
    background: #00cc00;
}

#scoreHistory ul {
    list-style-type: none;
    padding: 0;
}

#scoreHistory li {
    color: #ffffff;
    margin-bottom: 10px;
    padding: 5px;
    background-color: rgba(0, 255, 0, 0.1);
    border-radius: 5px;
    font-family: 'Courier New', monospace;
    transition: all 0.3s ease;
}

#scoreHistory li:hover {
    background-color: rgba(0, 255, 0, 0.2);
    transform: translateX(5px);
}

#scoreHistory li::before {
    content: '🐍';
    margin-right: 5px;
}

/* Estilos para el scroll */
.game-wrapper::-webkit-scrollbar {
    width: 10px;
}

.game-wrapper::-webkit-scrollbar-track {
    background: #001a00;
}

.game-wrapper::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 5px;
}

.game-wrapper::-webkit-scrollbar-thumb:hover {
    background: #00cc00;
}

@media (max-width: 500px) {
    .canvas-container {
        width: 300px;
        height: 300px;
    }
}

/* ... otros estilos ... */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
}

.modal-content {
    background-color: #1a1a1a;
    color: #00ff00;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #00ff00;
    border-radius: 10px;
    width: 80%;
    max-width: 500px;
    box-shadow: 0 0 20px #00ff00;
}

.close {
    color: #00ff00;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: #00cc00;
    text-decoration: none;
}

.modal-content h2 {
    margin-top: 0;
    text-align: center;
}

.modal-content ul {
    padding-left: 20px;
}

.modal-content li {
    margin-bottom: 10px;
}

@media (max-width: 500px) {
    .modal-content {
        margin: 10% auto;
        width: 90%;
        padding: 15px;
    }
}

.canvas-container {
    width: 400px; /* Tamaño fijo */
    height: 400px; /* Tamaño fijo */
    margin: 10px auto;
    border: 2px solid #00ff00;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
}

#gameCanvas {
    width: 100%;
    height: 100%;
    background-color: #000;
    transition: background-color 0.5s ease;
}

@media (max-width: 500px) {
    .canvas-container {
        width: 300px; /* Tamaño más pequeño pero fijo para móviles */
        height: 300px;
    }
}

.title-container {
    display: flex;
    align-items: center;
    justify-content: center;
    
}

.snake-icon {
    width: 50px;
    height: 50px;
    transition: transform 0.3s ease;
}

.snake-left {
    transform: scaleX(-1);
}

.snake-right:hover, .snake-left:hover {
    transform: scale(1.1);
}

.snake-left:hover {
    transform: scaleX(-1) scale(1.1);
}

/* Añadimos un pequeño margen superior al contenedor del canvas si es necesario */
.canvas-container {
    margin-top: 10px;
}

#touch-controls {
    margin-top: 10px;
}

.d-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 5px; /* Reduced spacing */
    width: 150px; /* Adjust as needed */
    margin: 0 auto;
}

.direction-btn {
    width: 50px; /* Adjust size as needed */
    height: 50px; /* Make it square */
    border-radius: 50%; /* Make it circular */
    border: none;
    background-color: #4CAF50; /* Green background */
    color: white;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    justify-content: center;
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body {
    background-color: #1a1a1a;
    font-family: 'Arial', sans-serif;
    color: #00ff00;
}

.game-wrapper {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    min-height: 100%;
}

@keyframes rainbow {
    0% { color: #ff0000; } /* Rojo */
    14% { color: #ff7f00; } /* Naranja */
    28% { color: #ffff00; } /* Amarillo */
    42% { color: #00ff00; } /* Verde */
    57% { color: #0000ff; } /* Azul */
    71% { color: #8b00ff; } /* Violeta */
    85% { color: #ff00ff; } /* Magenta */
    100% { color: #ff0000; } /* Vuelve a rojo */
}

.game-title {
    font-family: 'Press Start 2P', cursive; /* Fuente estilo pixel art */
    font-size: 2.5rem; /* Reducido de 2.5rem */
    text-align: center;
    margin: 0 20px; /* Reducido de 20px */
    text-transform: uppercase;
    letter-spacing: 1px; /* Reducido de 2px */
    animation: rainbow 8s linear infinite;
    text-shadow: 
        1px 1px 0 #000,
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000;
    margin-right: 10px;  /* Espacio entre el título y la imagen */
}

@media (max-width: 500px) {
    .game-title {
        font-size: 1.2rem; /* Reducido de 1.8rem */
    }
}

#score, #message {
    margin-top: 0.5rem;
    font-size: 1.2rem;
    text-align: center;
}

.button-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
}

.button-container button {
    width: 40px;
    height: 40px;
    font-size: 20px;
    background-color: #333;
    color: #00ff00;
    border: 1px solid #00ff00;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
}

.button-container button:hover {
    background-color: #444;
    box-shadow: 0 0 5px #00ff00;
}

.button-container button:active {
    transform: scale(0.95);
}

@media (max-width: 500px) {
    .button-container button {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }
}

#pauseButton, #soundButton, #instructionsButton {
    width: 40px;
    height: 40px;
    font-size: 18px;
    background-color: #333;
    color: #00ff00;
    border: 1px solid #00ff00;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

#pauseButton:hover, #soundButton:hover, #instructionsButton:hover {
    background-color: #444;
    box-shadow: 0 0 5px #00ff00;
}

#pauseButton:active, #soundButton:active, #instructionsButton:active {
    transform: scale(0.95);
}

@media (max-width: 500px) {
    #pauseButton, #soundButton, #instructionsButton {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
}

#touch-controls {
    margin-top: 10px; /* Reducido de 20px a 10px */
    display: none;
    width: 100%;
}

.d-pad {
    position: relative;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 5px; /* Reducido de 10px a 5px */
    width: 150px; /* Reducido de 180px a 150px */
    height: 150px; /* Reducido de 180px a 150px */
    margin: 0 auto;
}

.d-pad button {
    width: 100%;
    height: 100%;
    font-size: 20px; /* Reducido de 24px a 20px */
    background-color: rgba(0, 255, 0, 0.2);
    border: 2px solid #00ff00;
    color: #00ff00;
    border-radius: 5px; /* Cambiado de 50% a 5px para un aspecto más cuadrado */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.2s ease;
}

.d-pad button:active {
    background-color: rgba(0, 255, 0, 0.5);
    transform: scale(0.95);
}

.d-pad #up { grid-area: 1 / 2 / 2 / 3; }
.d-pad #left { grid-area: 2 / 1 / 3 / 2; }
.d-pad #right { grid-area: 2 / 3 / 3 / 4; }
.d-pad #down { grid-area: 3 / 2 / 4 / 3; }

@media (max-width: 768px) {
    .game-container {
        justify-content: flex-start;
        padding-top: 1rem;
    }

    .game-frame {
        max-height: 50vh;
    }

    #touch-controls {
        display: flex;
        justify-content: center;
        align-items: center;
        margin-top: 20px;
    }

    .d-pad {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: repeat(3, 1fr);
        gap: 10px;
        width: 200px;
        height: 200px;
    }

    .d-pad button {
        width: 100%;
        height: 100%;
    }

    .d-pad #up { grid-area: 1 / 2 / 2 / 3; }
    .d-pad #left { grid-area: 2 / 1 / 3 / 2; }
    .d-pad #right { grid-area: 2 / 3 / 3 / 4; }
    .d-pad #down { grid-area: 3 / 2 / 4 / 3; }
}

@media (max-height: 600px) {
    .game-frame {
        max-height: 40vh;
    }

    #score, #message {
        margin-top: 0.3rem;
        font-size: 1rem;
    }

    .button-container {
        margin-top: 0.3rem;
    }

    #pauseButton, #soundButton {
        padding: 0.3rem;
        font-size: 0.9rem;
    }

    .d-pad {
        width: 150px;
        height: 150px;
    }

    .d-pad button {
        font-size: 1.5rem;
    }
}

#scoreHistoryContainer {
    margin-top: 20px;
    background-color: rgba(0, 0, 0, 0.8);
    border: 2px solid #00ff00;
    border-radius: 10px;
    padding: 10px;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 0 10px #00ff00;
}

#scoreHistoryContainer h2 {
    color: #00ff00;
    text-align: center;
    margin-bottom: 10px;
    font-family: 'Press Start 2P', cursive;
    text-transform: uppercase;
    text-shadow: 0 0 5px #00ff00;
}

#scoreHistory {
    max-height: 200px;
    overflow-y: auto;
    padding-right: 10px;
}

#scoreHistory::-webkit-scrollbar {
    width: 8px;
}

#scoreHistory::-webkit-scrollbar-track {
    background: #001a00;
    border-radius: 4px;
}

#scoreHistory::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 4px;
}

#scoreHistory::-webkit-scrollbar-thumb:hover {
    background: #00cc00;
}

#scoreHistory ul {
    list-style-type: none;
    padding: 0;
}

#scoreHistory li {
    color: #ffffff;
    margin-bottom: 10px;
    padding: 5px;
    background-color: rgba(0, 255, 0, 0.1);
    border-radius: 5px;
    font-family: 'Courier New', monospace;
    transition: all 0.3s ease;
}

#scoreHistory li:hover {
    background-color: rgba(0, 255, 0, 0.2);
    transform: translateX(5px);
}

#scoreHistory li::before {
    content: '🐍';
    margin-right: 5px;
}

/* Estilos para el scroll */
.game-wrapper::-webkit-scrollbar {
    width: 10px;
}

.game-wrapper::-webkit-scrollbar-track {
    background: #001a00;
}

.game-wrapper::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 5px;
}

.game-wrapper::-webkit-scrollbar-thumb:hover {
    background: #00cc00;
}

@media (max-width: 500px) {
    .canvas-container {
        width: 300px;
        height: 300px;
    }
}

/* ... otros estilos ... */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
}

.modal-content {
    background-color: #1a1a1a;
    color: #00ff00;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #00ff00;
    border-radius: 10px;
    width: 80%;
    max-width: 500px;
    box-shadow: 0 0 20px #00ff00;
}

.close {
    color: #00ff00;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: #00cc00;
    text-decoration: none;
}

.modal-content h2 {
    margin-top: 0;
    text-align: center;
}

.modal-content ul {
    padding-left: 20px;
}

.modal-content li {
    margin-bottom: 10px;
}

@media (max-width: 500px) {
    .modal-content {
        margin: 10% auto;
        width: 90%;
        padding: 15px;
    }
}

.canvas-container {
    width: 400px; /* Tamaño fijo */
    height: 400px; /* Tamaño fijo */
    margin: 10px auto;
    border: 2px solid #00ff00;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
}

#gameCanvas {
    width: 100%;
    height: 100%;
    background-color: #000;
    transition: background-color 0.5s ease;
}

@media (max-width: 500px) {
    .canvas-container {
        width: 300px; /* Tamaño más pequeño pero fijo para móviles */
        height: 300px;
    }
}

.title-container {
    display: flex;
    align-items: center;
    justify-content: center;
    
}

.snake-icon {
    width: 50px;
    height: 50px;
    transition: transform 0.3s ease;
}

.snake-left {
    transform: scaleX(-1);
}

.snake-right:hover, .snake-left:hover {
    transform: scale(1.1);
}

.snake-left:hover {
    transform: scaleX(-1) scale(1.1);
}

/* Añadimos un pequeño margen superior al contenedor del canvas si es necesario */
.canvas-container {
    margin-top: 10px;
}

#touch-controls {
    margin-top: 10px;
}

.d-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 5px; /* Reduced spacing */
    width: 150px; /* Adjust as needed */
    margin: 0 auto;
}

.direction-btn {
    width: 50px; /* Adjust size as needed */
    height: 50px; /* Make it square */
    border-radius: 50%; /* Make it circular */
    border: none;
    background-color: #4CAF50; /* Green background */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body {
    background-color: #1a1a1a;
    font-family: 'Arial', sans-serif;
    color: #00ff00;
}

.game-wrapper {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    min-height: 100%;
}

@keyframes rainbow {
    0% { color: #ff0000; } /* Rojo */
    14% { color: #ff7f00; } /* Naranja */
    28% { color: #ffff00; } /* Amarillo */
    42% { color: #00ff00; } /* Verde */
    57% { color: #0000ff; } /* Azul */
    71% { color: #8b00ff; } /* Violeta */
    85% { color: #ff00ff; } /* Magenta */
    100% { color: #ff0000; } /* Vuelve a rojo */
}

.game-title {
    font-family: 'Press Start 2P', cursive; /* Fuente estilo pixel art */
    font-size: 2.5rem; /* Reducido de 2.5rem */
    text-align: center;
    margin: 0 20px; /* Reducido de 20px */
    text-transform: uppercase;
    letter-spacing: 1px; /* Reducido de 2px */
    animation: rainbow 8s linear infinite;
    text-shadow: 
        1px 1px 0 #000,
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000;
    margin-right: 10px;  /* Espacio entre el título y la imagen */
}

@media (max-width: 500px) {
    .game-title {
        font-size: 1.2rem; /* Reducido de 1.8rem */
    }
}

#score, #message {
    margin-top: 0.5rem;
    font-size: 1.2rem;
    text-align: center;
}

.button-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
}

.button-container button {
    width: 40px;
    height: 40px;
    font-size: 20px;
    background-color: #333;
    color: #00ff00;
    border: 1px solid #00ff00;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
}

.button-container button:hover {
    background-color: #444;
    box-shadow: 0 0 5px #00ff00;
}

.button-container button:active {
    transform: scale(0.95);
}

@media (max-width: 500px) {
    .button-container button {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }
}

#pauseButton, #soundButton, #instructionsButton {
    width: 40px;
    height: 40px;
    font-size: 18px;
    background-color: #333;
    color: #00ff00;
    border: 1px solid #00ff00;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

#pauseButton:hover, #soundButton:hover, #instructionsButton:hover {
    background-color: #444;
    box-shadow: 0 0 5px #00ff00;
}

#pauseButton:active, #soundButton:active, #instructionsButton:active {
    transform: scale(0.95);
}

@media (max-width: 500px) {
    #pauseButton, #soundButton, #instructionsButton {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
}

#touch-controls {
    margin-top: 10px; /* Reducido de 20px a 10px */
    display: none;
    width: 100%;
}

.d-pad {
    position: relative;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 5px; /* Reducido de 10px a 5px */
    width: 150px; /* Reducido de 180px a 150px */
    height: 150px; /* Reducido de 180px a 150px */
    margin: 0 auto;
}

.d-pad button {
    width: 100%;
    height: 100%;
    font-size: 20px; /* Reducido de 24px a 20px */
    background-color: rgba(0, 255, 0, 0.2);
    border: 2px solid #00ff00;
    color: #00ff00;
    border-radius: 5px; /* Cambiado de 50% a 5px para un aspecto más cuadrado */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.2s ease;
}

.d-pad button:active {
    background-color: rgba(0, 255, 0, 0.5);
    transform: scale(0.95);
}

.d-pad #up { grid-area: 1 / 2 / 2 / 3; }
.d-pad #left { grid-area: 2 / 1 / 3 / 2; }
.d-pad #right { grid-area: 2 / 3 / 3 / 4; }
.d-pad #down { grid-area: 3 / 2 / 4 / 3; }

@media (max-width: 768px) {
    .game-container {
        justify-content: flex-start;
        padding-top: 1rem;
    }

    .game-frame {
        max-height: 50vh;
    }

    #touch-controls {
        display: flex;
        justify-content: center;
        align-items: center;
        margin-top: 20px;
    }

    .d-pad {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: repeat(3, 1fr);
        gap: 10px;
        width: 200px;
        height: 200px;
    }

    .d-pad button {
        width: 100%;
        height: 100%;
    }

    .d-pad #up { grid-area: 1 / 2 / 2 / 3; }
    .d-pad #left { grid-area: 2 / 1 / 3 / 2; }
    .d-pad #right { grid-area: 2 / 3 / 3 / 4; }
    .d-pad #down { grid-area: 3 / 2 / 4 / 3; }
}

@media (max-height: 600px) {
    .game-frame {
        max-height: 40vh;
    }

    #score, #message {
        margin-top: 0.3rem;
        font-size: 1rem;
    }

    .button-container {
        margin-top: 0.3rem;
    }

    #pauseButton, #soundButton {
        padding: 0.3rem;
        font-size: 0.9rem;
    }

    .d-pad {
        width: 150px;
        height: 150px;
    }

    .d-pad button {
        font-size: 1.5rem;
    }
}

#scoreHistoryContainer {
    margin-top: 20px;
    background-color: rgba(0, 0, 0, 0.8);
    border: 2px solid #00ff00;
    border-radius: 10px;
    padding: 10px;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 0 10px #00ff00;
}

#scoreHistoryContainer h2 {
    color: #00ff00;
    text-align: center;
    margin-bottom: 10px;
    font-family: 'Press Start 2P', cursive;
    text-transform: uppercase;
    text-shadow: 0 0 5px #00ff00;
}

#scoreHistory {
    max-height: 200px;
    overflow-y: auto;
    padding-right: 10px;
}

#scoreHistory::-webkit-scrollbar {
    width: 8px;
}

#scoreHistory::-webkit-scrollbar-track {
    background: #001a00;
    border-radius: 4px;
}

#scoreHistory::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 4px;
}

#scoreHistory::-webkit-scrollbar-thumb:hover {
    background: #00cc00;
}

#scoreHistory ul {
    list-style-type: none;
    padding: 0;
}

#scoreHistory li {
    color: #ffffff;
    margin-bottom: 10px;
    padding: 5px;
    background-color: rgba(0, 255, 0, 0.1);
    border-radius: 5px;
    font-family: 'Courier New', monospace;
    transition: all 0.3s ease;
}

#scoreHistory li:hover {
    background-color: rgba(0, 255, 0, 0.2);
    transform: translateX(5px);
}

#scoreHistory li::before {
    content: '🐍';
    margin-right: 5px;
}

/* Estilos para el scroll */
.game-wrapper::-webkit-scrollbar {
    width: 10px;
}

.game-wrapper::-webkit-scrollbar-track {
    background: #001a00;
}

.game-wrapper::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 5px;
}

.game-wrapper::-webkit-scrollbar-thumb:hover {
    background: #00cc00;
}

@media (max-width: 500px) {
    .canvas-container {
        width: 300px;
        height: 300px;
    }
}

/* ... otros estilos ... */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
}

.modal-content {
    background-color: #1a1a1a;
    color: #00ff00;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #00ff00;
    border-radius: 10px;
    width: 80%;
    max-width: 500px;
    box-shadow: 0 0 20px #00ff00;
}

.close {
    color: #00ff00;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: #00cc00;
    text-decoration: none;
}

.modal-content h2 {
    margin-top: 0;
    text-align: center;
}

.modal-content ul {
    padding-left: 20px;
}

.modal-content li {
    margin-bottom: 10px;
}

@media (max-width: 500px) {
    .modal-content {
        margin: 10% auto;
        width: 90%;
        padding: 15px;
    }
}

.canvas-container {
    width: 400px; /* Tamaño fijo */
    height: 400px; /* Tamaño fijo */
    margin: 10px auto;
    border: 2px solid #00ff00;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
}

#gameCanvas {
    width: 100%;
    height: 100%;
    background-color: #000;
    transition: background-color 0.5s ease;
}

@media (max-width: 500px) {
    .canvas-container {
        width: 300px; /* Tamaño más pequeño pero fijo para móviles */
        height: 300px;
    }
}

.title-container {
    display: flex;
    align-items: center;
    justify-content: center;
    
}

.snake-icon {
    width: 50px;
    height: 50px;
    transition: transform 0.3s ease;
}

.snake-left {
    transform: scaleX(-1);
}

.snake-right:hover, .snake-left:hover {
    transform: scale(1.1);
}

.snake-left:hover {
    transform: scaleX(-1) scale(1.1);
}

/* Añadimos un pequeño margen superior al contenedor del canvas si es necesario */
.canvas-container {
    margin-top: 10px;
}

#touch-controls {
    margin-top: 10px;
}

.d-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 5px; /* Reduced spacing */
    width: 150px; /* Adjust as needed */
    margin: 0 auto;
}

.direction-btn {
    width: 50px; /* Adjust size as needed */
    height: 50px; /* Make it square */
    border-radius: 50%; /* Make it circular */
    border: none;
    background-color: #4CAF50; /* Green background */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body {
    background-color: #1a1a1a;
    font-family: 'Arial', sans-serif;
    color: #00ff00;
}

.game-wrapper {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    min-height: 100%;
}

@keyframes rainbow {
    0% { color: #ff0000; } /* Rojo */
    14% { color: #ff7f00; } /* Naranja */
    28% { color: #ffff00; } /* Amarillo */
    42% { color: #00ff00; } /* Verde */
    57% { color: #0000ff; } /* Azul */
    71% { color: #8b00ff; } /* Violeta */
    85% { color: #ff00ff; } /* Magenta */
    100% { color: #ff0000; } /* Vuelve a rojo */
}

.game-title {
    font-family: 'Press Start 2P', cursive; /* Fuente estilo pixel art */
    font-size: 2.5rem; /* Reducido de 2.5rem */
    text-align: center;
    margin: 0 20px; /* Reducido de 20px */
    text-transform: uppercase;
    letter-spacing: 1px; /* Reducido de 2px */
    animation: rainbow 8s linear infinite;
    text-shadow: 
        1px 1px 0 #000,
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000;
    margin-right: 10px;  /* Espacio entre el título y la imagen */
}

@media (max-width: 500px) {
    .game-title {
        font-size: 1.2rem; /* Reducido de 1.8rem */
    }
}

#score, #message {
    margin-top: 0.5rem;
    font-size: 1.2rem;
    text-align: center;
}

.button-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
}

.button-container button {
    width: 40px;
    height: 40px;
    font-size: 20px;
    background-color: #333;
    color: #00ff00;
    border: 1px solid #00ff00;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
}

.button-container button:hover {
    background-color: #444;
    box-shadow: 0 0 5px #00ff00;
}

.button-container button:active {
    transform: scale(0.95);
}

@media (max-width: 500px) {
    .button-container button {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }
}

#pauseButton, #soundButton, #instructionsButton {
    width: 40px;
    height: 40px;
    font-size: 18px;
    background-color: #333;
    color: #00ff00;
    border: 1px solid #00ff00;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

#pauseButton:hover, #soundButton:hover, #instructionsButton:hover {
    background-color: #444;
    box-shadow: 0 0 5px #00ff00;
}

#pauseButton:active, #soundButton:active, #instructionsButton:active {
    transform: scale(0.95);
}

@media (max-width: 500px) {
    #pauseButton, #soundButton, #instructionsButton {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
}

#touch-controls {
    margin-top: 10px; /* Reducido de 20px a 10px */
    display: none;
    width: 100%;
}

.d-pad {
    position: relative;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 5px; /* Reducido de 10px a 5px */
    width: 150px; /* Reducido de 180px a 150px */
    height: 150px; /* Reducido de 180px a 150px */
    margin: 0 auto;
}

.d-pad button {
    width: 100%;
    height: 100%;
    font-size: 20px; /* Reducido de 24px a 20px */
    background-color: rgba(0, 255, 0, 0.2);
    border: 2px solid #00ff00;
    color: #00ff00;
    border-radius: 5px; /* Cambiado de 50% a 5px para un aspecto más cuadrado */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.2s ease;
}

.d-pad button:active {
    background-color: rgba(0, 255, 0, 0.5);
    transform: scale(0.95);
}

.d-pad #up { grid-area: 1 / 2 / 2 / 3; }
.d-pad #left { grid-area: 2 / 1 / 3 / 2; }
.d-pad #right { grid-area: 2 / 3 / 3 / 4; }
.d-pad #down { grid-area: 3 / 2 / 4 / 3; }

@media (max-width: 768px) {
    .game-container {
        justify-content: flex-start;
        padding-top: 1rem;
    }

    .game-frame {
        max-height: 50vh;
    }

    #touch-controls {
        display: flex;
        justify-content: center;
        align-items: center;
        margin-top: 20px;
    }

    .d-pad {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: repeat(3, 1fr);
        gap: 10px;
        width: 200px;
        height: 200px;
    }

    .d-pad button {
        width: 100%;
        height: 100%;
    }

    .d-pad #up { grid-area: 1 / 2 / 2 / 3; }
    .d-pad #left { grid-area: 2 / 1 / 3 / 2; }
    .d-pad #right { grid-area: 2 / 3 / 3 / 4; }
    .d-pad #down { grid-area: 3 / 2 / 4 / 3; }
}

@media (max-height: 600px) {
    .game-frame {
        max-height: 40vh;
    }

    #score, #message {
        margin-top: 0.3rem;
        font-size: 1rem;
    }

    .button-container {
        margin-top: 0.3rem;
    }

    #pauseButton, #soundButton {
        padding: 0.3rem;
        font-size: 0.9rem;
    }

    .d-pad {
        width: 150px;
        height: 150px;
    }

    .d-pad button {
        font-size: 1.5rem;
    }
}

#scoreHistoryContainer {
    margin-top: 20px;
    background-color: rgba(0, 0, 0, 0.8);
    border: 2px solid #00ff00;
    border-radius: 10px;
    padding: 10px;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 0 10px #00ff00;
}

#scoreHistoryContainer h2 {
    color: #00ff00;
    text-align: center;
    margin-bottom: 10px;
    font-family: 'Press Start 2P', cursive;
    text-transform: uppercase;
    text-shadow: 0 0 5px #00ff00;
}

#scoreHistory {
    max-height: 200px;
    overflow-y: auto;
    padding-right: 10px;
}

#scoreHistory::-webkit-scrollbar {
    width: 8px;
}

#scoreHistory::-webkit-scrollbar-track {
    background: #001a00;
    border-radius: 4px;
}

#scoreHistory::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 4px;
}

#scoreHistory::-webkit-scrollbar-thumb:hover {
    background: #00cc00;
}

#scoreHistory ul {
    list-style-type: none;
    padding: 0;
}

#scoreHistory li {
    color: #ffffff;
    margin-bottom: 10px;
    padding: 5px;
    background-color: rgba(0, 255, 0, 0.1);
    border-radius: 5px;
    font-family: 'Courier New', monospace;
    transition: all 0.3s ease;
}

#scoreHistory li:hover {
    background-color: rgba(0, 255, 0, 0.2);
    transform: translateX(5px);
}

#scoreHistory li::before {
    content: '🐍';
    margin-right: 5px;
}

/* Estilos para el scroll */
.game-wrapper::-webkit-scrollbar {
    width: 10px;
}

.game-wrapper::-webkit-scrollbar-track {
    background: #001a00;
}

.game-wrapper::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 5px;
}

.game-wrapper::-webkit-scrollbar-thumb:hover {
    background: #00cc00;
}

@media (max-width: 500px) {
    .canvas-container {
        width: 300px;
        height: 300px;
    }
}

/* ... otros estilos ... */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
}

.modal-content {
    background-color: #1a1a1a;
    color: #00ff00;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #00ff00;
    border-radius: 10px;
    width: 80%;
    max-width: 500px;
    box-shadow: 0 0 20px #00ff00;
}

.close {
    color: #00ff00;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: #00cc00;
    text-decoration: none;
}

.modal-content h2 {
    margin-top: 0;
    text-align: center;
}

.modal-content ul {
    padding-left: 20px;
}

.modal-content li {
    margin-bottom: 10px;
}

@media (max-width: 500px) {
    .modal-content {
        margin: 10% auto;
        width: 90%;
        padding: 15px;
    }
}

.canvas-container {
    width: 400px; /* Tamaño fijo */
    height: 400px; /* Tamaño fijo */
    margin: 10px auto;
    border: 2px solid #00ff00;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
}

#gameCanvas {
    width: 100%;
    height: 100%;
    background-color: #000;
    transition: background-color 0.5s ease;
}

@media (max-width: 500px) {
    .canvas-container {
        width: 300px; /* Tamaño más pequeño pero fijo para móviles */
        height: 300px;
    }
}

.title-container {
    display: flex;
    align-items: center;
    justify-content: center;
    
}

.snake-icon {
    width: 50px;
    height: 50px;
    transition: transform 0.3s ease;
}

.snake-left {
    transform: scaleX(-1);
}

.snake-right:hover, .snake-left:hover {
    transform: scale(1.1);
}

.snake-left:hover {
    transform: scaleX(-1) scale(1.1);
}

/* Añadimos un pequeño margen superior al contenedor del canvas si es necesario */
.canvas-container {
    margin-top: 10px;
}

#touch-controls {
    margin-top: 10px;
}

.d-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 5px; /* Reduced spacing */
    width: 150px; /* Adjust as needed */
    margin: 0 auto;
}

.direction-btn {
    width: 50px; /* Adjust size as needed */
    height: 50px; /* Make it square */
    border-radius: 50%; /* Make it circular */
    border: none;
    background-color: #4CAF50; /* Green background */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body {
    background-color: #1a1a1a;
    font-family: 'Arial', sans-serif;
    color: #00ff00;
}

.game-wrapper {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    min-height: 100%;
}

@keyframes rainbow {
    0% { color: #ff0000; } /* Rojo */
    14% { color: #ff7f00; } /* Naranja */
    28% { color: #ffff00; } /* Amarillo */
    42% { color: #00ff00; } /* Verde */
    57% { color: #0000ff; } /* Azul */
    71% { color: #8b00ff; } /* Violeta */
    85% { color: #ff00ff; } /* Magenta */
    100% { color: #ff0000; } /* Vuelve a rojo */
}

.game-title {
    font-family: 'Press Start 2P', cursive; /* Fuente estilo pixel art */
    font-size: 2.5rem; /* Reducido de 2.5rem */
    text-align: center;
    margin: 0 20px; /* Reducido de 20px */
    text-transform: uppercase;
    letter-spacing: 1px; /* Reducido de 2px */
    animation: rainbow 8s linear infinite;
    text-shadow: 
        1px 1px 0 #000,
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000;
    margin-right: 10px;  /* Espacio entre el título y la imagen */
}

@media (max-width: 500px) {
    .game-title {
        font-size: 1.2rem; /* Reducido de 1.8rem */
    }
}

#score, #message {
    margin-top: 0.5rem;
    font-size: 1.2rem;
    text-align: center;
}

.button-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
}

.button-container button {
    width: 40px;
    height: 40px;
    font-size: 20px;
    background-color: #333;
    color: #00ff00;
    border: 1px solid #00ff00;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
}

.button-container button:hover {
    background-color: #444;
    box-shadow: 0 0 5px #00ff00;
}

.button-container button:active {
    transform: scale(0.95);
}

@media (max-width: 500px) {
    .button-container button {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }
}

#pauseButton, #soundButton, #instructionsButton {
    width: 40px;
    height: 40px;
    font-size: 18px;
    background-color: #333;
    color: #00ff00;
    border: 1px solid #00ff00;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

#pauseButton:hover, #soundButton:hover, #instructionsButton:hover {
    background-color: #444;
    box-shadow: 0 0 5px #00ff00;
}

#pauseButton:active, #soundButton:active, #instructionsButton:active {
    transform: scale(0.95);
}

@media (max-width: 500px) {
    #pauseButton, #soundButton, #instructionsButton {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
}

#touch-controls {
    margin-top: 10px; /* Reducido de 20px a 10px */
    display: none;
    width: 100%;
}

.d-pad {
    position: relative;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 5px; /* Reducido de 10px a 5px */
    width: 150px; /* Reducido de 180px a 150px */
    height: 150px; /* Reducido de 180px a 150px */
    margin: 0 auto;
}

.d-pad button {
    width: 100%;
    height: 100%;
    font-size: 20px; /* Reducido de 24px a 20px */
    background-color: rgba(0, 255, 0, 0.2);
    border: 2px solid #00ff00;
    color: #00ff00;
    border-radius: 5px; /* Cambiado de 50% a 5px para un aspecto más cuadrado */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.2s ease;
}

.d-pad button:active {
    background-color: rgba(0, 255, 0, 0.5);
    transform: scale(0.95);
}

.d-pad #up { grid-area: 1 / 2 / 2 / 3; }
.d-pad #left { grid-area: 2 / 1 / 3 / 2; }
.d-pad #right { grid-area: 2 / 3 / 3 / 4; }
.d-pad #down { grid-area: 3 / 2 / 4 / 3; }

@media (max-width: 768px) {
    .game-container {
        justify-content: flex-start;
        padding-top: 1rem;
    }

    .game-frame {
        max-height: 50vh;
    }

    #touch-controls {
        display: flex;
        justify-content: center;
        align-items: center;
        margin-top: 20px;
    }

    .d-pad {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: repeat(3, 1fr);
        gap: 10px;
        width: 200px;
        height: 200px;
    }

    .d-pad button {
        width: 100%;
        height: 100%;
    }

    .d-pad #up { grid-area: 1 / 2 / 2 / 3; }
    .d-pad #left { grid-area: 2 / 1 / 3 / 2; }
    .d-pad #right { grid-area: 2 / 3 / 3 / 4; }
    .d-pad #down { grid-area: 3 / 2 / 4 / 3; }
}

@media (max-height: 600px) {
    .game-frame {
        max-height: 40vh;
    }

    #score, #message {
        margin-top: 0.3rem;
        font-size: 1rem;
    }

    .button-container {
        margin-top: 0.3rem;
    }

    #pauseButton, #soundButton {
        padding: 0.3rem;
        font-size: 0.9rem;
    }

    .d-pad {
        width: 150px;
        height: 150px;
    }

    .d-pad button {
        font-size: 1.5rem;
    }
}

#scoreHistoryContainer {
    margin-top: 20px;
    background-color: rgba(0, 0, 0, 0.8);
    border: 2px solid #00ff00;
    border-radius: 10px;
    padding: 10px;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 0 10px #00ff00;
}

#scoreHistoryContainer h2 {
    color: #00ff00;
    text-align: center;
    margin-bottom: 10px;
    font-family: 'Press Start 2P', cursive;
    text-transform: uppercase;
    text-shadow: 0 0 5px #00ff00;
}

#scoreHistory {
    max-height: 200px;
    overflow-y: auto;
    padding-right: 10px;
}

#scoreHistory::-webkit-scrollbar {
    width: 8px;
}

#scoreHistory::-webkit-scrollbar-track {
    background: #001a00;
    border-radius: 4px;
}

#scoreHistory::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 4px;
}

#scoreHistory::-webkit-scrollbar-thumb:hover {
    background: #00cc00;
}

#scoreHistory ul {
    list-style-type: none;
    padding: 0;
}

#scoreHistory li {
    color: #ffffff;
    margin-bottom: 10px;
    padding: 5px;
    background-color: rgba(0, 255, 0, 0.1);
    border-radius: 5px;
    font-family: 'Courier New', monospace;
    transition: all 0.3s ease;
}

#scoreHistory li:hover {
    background-color: rgba(0, 255, 0, 0.2);
    transform: translateX(5px);
}

#scoreHistory li::before {
    content: '🐍';
    margin-right: 5px;
}

/* Estilos para el scroll */
.game-wrapper::-webkit-scrollbar {
    width: 10px;
}

.game-wrapper::-webkit-scrollbar-track {
    background: #001a00;
}

.game-wrapper::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 5px;
}

.game-wrapper::-webkit-scrollbar-thumb:hover {
    background: #00cc00;
}

@media (max-width: 500px) {
    .canvas-container {
        width: 300px;
        height: 300px;
    }
}

/* ... otros estilos ... */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
}

.modal-content {
    background-color: #1a1a1a;
    color: #00ff00;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #00ff00;
    border-radius: 10px;
    width: 80%;
    max-width: 500px;
    box-shadow: 0 0 20px #00ff00;
}

.close {
    color: #00ff00;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: #00cc00;
    text-decoration: none;
}

.modal-content h2 {
    margin-top: 0;
    text-align: center;
}

.modal-content ul {
    padding-left: 20px;
}

.modal-content li {
    margin-bottom: 10px;
}

@media (max-width: 500px) {
    .modal-content {
        margin: 10% auto;
        width: 90%;
        padding: 15px;
    }
}

.canvas-container {
    width: 400px; /* Tamaño fijo */
    height: 400px; /* Tamaño fijo */
    margin: 10px auto;
    border: 2px solid #00ff00;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
}

#gameCanvas {
    width: 100%;
    height: 100%;
    background-color: #000;
    transition: background-color 0.5s ease;
}

@media (max-width: 500px) {
    .canvas-container {
        width: 300px; /* Tamaño más pequeño pero fijo para móviles */
        height: 300px;
    }
}

.title-container {
    display: flex;
    align-items: center;
    justify-content: center;
    
}

.snake-icon {
    width: 50px;
    height: 50px;
    transition: transform 0.3s ease;
}

.snake-left {
    transform: scaleX(-1);
}

.snake-right:hover, .snake-left:hover {
    transform: scale(1.1);
}

.snake-left:hover {
    transform: scaleX(-1) scale(1.1);
}

/* Añadimos un pequeño margen superior al contenedor del canvas si es necesario */
.canvas-container {
    margin-top: 10px;
}

#touch-controls {
    margin-top: 10px;
}

.d-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 5px; /* Reduced spacing */
    width: 150px; /* Adjust as needed */
    margin: 0 auto;
}

.direction-btn {
    width: 50px; /* Adjust size as needed */
    height: 50px; /* Make it square */
    border-radius: 50%; /* Make it circular */
    border: none;
    background-color: #4CAF50; /* Green background */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body {
    background-color: #1a1a1a;
    font-family: 'Arial', sans-serif;
    color: #00ff00;
}

.game-wrapper {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    min-height: 100%;
}

@keyframes rainbow {
    0% { color: #ff0000; } /* Rojo */
    14% { color: #ff7f00; } /* Naranja */
    28% { color: #ffff00; } /* Amarillo */
    42% { color: #00ff00; } /* Verde */
    57% { color: #0000ff; } /* Azul */
    71% { color: #8b00ff; } /* Violeta */
    85% { color: #ff00ff; } /* Magenta */
    100% { color: #ff0000; } /* Vuelve a rojo */
}

.game-title {
    font-family: 'Press Start 2P', cursive; /* Fuente estilo pixel art */
    font-size: 2.5rem; /* Reducido de 2.5rem */
    text-align: center;
    margin: 0 20px; /* Reducido de 20px */
    text-transform: uppercase;
    letter-spacing: 1px; /* Reducido de 2px */
    animation: rainbow 8s linear infinite;
    text-shadow: 
        1px 1px 0 #000,
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000;
    margin-right: 10px;  /* Espacio entre el título y la imagen */
}

@media (max-width: 500px) {
    .game-title {
        font-size: 1.2rem; /* Reducido de 1.8rem */
    }
}

#score, #message {
    margin-top: 0.5rem;
    font-size: 1.2rem;
    text-align: center;
}

.button-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
}

.button-container button {
    width: 40px;
    height: 40px;
    font-size: 20px;
    background-color: #333;
    color: #00ff00;
    border: 1px solid #00ff00;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
}

.button-container button:hover {
    background-color: #444;
    box-shadow: 0 0 5px #00ff00;
}

.button-container button:active {
    transform: scale(0.95);
}

@media (max-width: 500px) {
    .button-container button {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }
}

#pauseButton, #soundButton, #instructionsButton {
    width: 40px;
    height: 40px;
    font-size: 18px;
    background-color: #333;
    color: #00ff00;
    border: 1px solid #00ff00;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

#pauseButton:hover, #soundButton:hover, #instructionsButton:hover {
    background-color: #444;
    box-shadow: 0 0 5px #00ff00;
}

#pauseButton:active, #soundButton:active, #instructionsButton:active {
    transform: scale(0.95);
}

@media (max-width: 500px) {
    #pauseButton, #soundButton, #instructionsButton {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
}

#touch-controls {
    margin-top: 10px; /* Reducido de 20px a 10px */
    display: none;
    width: 100%;
}

.d-pad {
    position: relative;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 5px; /* Reducido de 10px a 5px */
    width: 150px; /* Reducido de 180px a 150px */
    height: 150px; /* Reducido de 180px a 150px */
    margin: 0 auto;
}

.d-pad button {
    width: 100%;
    height: 100%;
    font-size: 20px; /* Reducido de 24px a 20px */
    background-color: rgba(0, 255, 0, 0.2);
    border: 2px solid #00ff00;
    color: #00ff00;
    border-radius: 5px; /* Cambiado de 50% a 5px para un aspecto más cuadrado */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.2s ease;
}

.d-pad button:active {
    background-color: rgba(0, 255, 0, 0.5);
    transform: scale(0.95);
}

.d-pad #up { grid-area: 1 / 2 / 2 / 3; }
.d-pad #left { grid-area: 2 / 1 / 3 / 2; }
.d-pad #right { grid-area: 2 / 3 / 3 / 4; }
.d-pad #down { grid-area: 3 / 2 / 4 / 3; }

@media (max-width: 768px) {
    .game-container {
        justify-content: flex-start;
        padding-top: 1rem;
    }

    .game-frame {
        max-height: 50vh;
    }

    #touch-controls {
        display: flex;
        justify-content: center;
        align-items: center;
        margin-top: 20px;
    }

    .d-pad {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: repeat(3, 1fr);
        gap: 10px;
        width: 200px;
        height: 200px;
    }

    .d-pad button {
        width: 100%;
        height: 100%;
    }

    .d-pad #up { grid-area: 1 / 2 / 2 / 3; }
    .d-pad #left { grid-area: 2 / 1 / 3 / 2; }
    .d-pad #right { grid-area: 2 / 3 / 3 / 4; }
    .d-pad #down { grid-area: 3 / 2 / 4 / 3; }
}

@media (max-height: 600px) {
    .game-frame {
        max-height: 40vh;
    }

    #score, #message {
        margin-top: 0.3rem;
        font-size: 1rem;
    }

    .button-container {
        margin-top: 0.3rem;
    }

    #pauseButton, #soundButton {
        padding: 0.3rem;
        font-size: 0.9rem;
    }

    .d-pad {
        width: 150px;
        height: 150px;
    }

    .d-pad button {
        font-size: 1.5rem;
    }
}

#scoreHistoryContainer {
    margin-top: 20px;
    background-color: rgba(0, 0, 0, 0.8);
    border: 2px solid #00ff00;
    border-radius: 10px;
    padding: 10px;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 0 10px #00ff00;
}

#scoreHistoryContainer h2 {
    color: #00ff00;
    text-align: center;
    margin-bottom: 10px;
    font-family: 'Press Start 2P', cursive;
    text-transform: uppercase;
    text-shadow: 0 0 5px #00ff00;
}

#scoreHistory {
    max-height: 200px;
    overflow-y: auto;
    padding-right: 10px;
}

#scoreHistory::-webkit-scrollbar {
    width: 8px;
}

#scoreHistory::-webkit-scrollbar-track {
    background: #001a00;
    border-radius: 4px;
}

#scoreHistory::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 4px;
}

#scoreHistory::-webkit-scrollbar-thumb:hover {
    background: #00cc00;
}

#scoreHistory ul {
    list-style-type: none;
    padding: 0;
}

#scoreHistory li {
    color: #ffffff;
    margin-bottom: 10px;
    padding: 5px;
    background-color: rgba(0, 255, 0, 0.1);
    border-radius: 5px;
    font-family: 'Courier New', monospace;
    transition: all 0.3s ease;
}

#scoreHistory li:hover {
    background-color: rgba(0, 255, 0, 0.2);
    transform: translateX(5px);
}

#scoreHistory li::before {
    content: '🐍';
    margin-right: 5px;
}

/* Estilos para el scroll */
.game-wrapper::-webkit-scrollbar {
    width: 10px;
}

.game-wrapper::-webkit-scrollbar-track {
    background: #001a00;
}

.game-wrapper::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 5px;
}

.game-wrapper::-webkit-scrollbar-thumb:hover {
    background: #00cc00;
}

@media (max-width: 500px) {
    .canvas-container {
        width: 300px;
        height: 300px;
    }
}

/* ... otros estilos ... */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
}

.modal-content {
    background-color: #1a1a1a;
    color: #00ff00;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #00ff00;
    border-radius: 10px;
    width: 80%;
    max-width: 500px;
    box-shadow: 0 0 20px #00ff00;
}

.close {
    color: #00ff00;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: #00cc00;
    text-decoration: none;
}

.modal-content h2 {
    margin-top: 0;
    text-align: center;
}

.modal-content ul {
    padding-left: 20px;
}

.modal-content li {
    margin-bottom: 10px;
}

@media (max-width: 500px) {
    .modal-content {
        margin: 10% auto;
        width: 90%;
        padding: 15px;
    }
}

.canvas-container {
    width: 400px; /* Tamaño fijo */
    height: 400px; /* Tamaño fijo */
    margin: 10px auto;
    border: 2px solid #00ff00;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
}

#gameCanvas {
    width: 100%;
    height: 100%;
    background-color: #000;
    transition: background-color 0.5s ease;
}

@media (max-width: 500px) {
    .canvas-container {
        width: 300px; /* Tamaño más pequeño pero fijo para móviles */
        height: 300px;
    }
}

.title-container {
    display: flex;
    align-items: center;
    justify-content: center;
    
}

.snake-icon {
    width: 50px;
    height: 50px;
    transition: transform 0.3s ease;
}

.snake-left {
    transform: scaleX(-1);
}

.snake-right:hover, .snake-left:hover {
    transform: scale(1.1);
}

.snake-left:hover {
    transform: scaleX(-1) scale(1.1);
}

/* Añadimos un pequeño margen superior al contenedor del canvas si es necesario */
.canvas-container {
    margin-top: 10px;
}