body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    background-color: #2c3e50;
    background-image: linear-gradient(to bottom right, #2c3e50, #1a2530);
    font-family: 'Arial', sans-serif;
    overscroll-behavior: contain; /* Previene el rebote en iOS */
    -webkit-tap-highlight-color: transparent; /* Elimina el resaltado al tocar en móviles */
    touch-action: manipulation; /* Mejora la respuesta táctil */
    transition: background-color 0.5s ease;
}

.game-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 500px;
    position: relative;
    padding: 10px;
    box-sizing: border-box;
}

.game-container {
    text-align: center;
    position: relative;
    width: 100%;
    margin-top: 20px;
    overflow: hidden;
}

canvas {
    border: 2px solid #fff;
    background-color: #000;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    max-width: 100%;
    will-change: transform; /* Optimiza las animaciones */
    image-rendering: pixelated; /* Mejora el renderizado de píxeles */
    image-rendering: crisp-edges;
}

.game-info {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
}

.score, .level {
    color: #fff;
    font-size: 24px;
}

.menu {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.8);
    padding: 20px;
    border-radius: 10px;
    z-index: 100;
    color: white;
    width: 80%;
    max-width: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.game-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 15px;
}

.game-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 10px;
}

.install-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    z-index: 1000;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

.install-button:hover {
    background-color: #45a049;
}

.toggle-controls {
    margin-top: 10px;
    background-color: #3498db;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    display: none; /* Oculto por defecto, se mostrará con JS */
}

.mobile-controls {
    display: none; /* Oculto por defecto, se mostrará con JS */
    margin-top: 20px;
    width: 100%;
    position: relative;
    z-index: 15;
}

.mobile-controls button {
    width: 80px;
    height: 80px;
    font-size: 32px;
    margin: 5px;
    background-color: rgba(76, 175, 80, 0.8);
    color: white;
    border: none;
    border-radius: 10px; /* Cambiado a rectangular con bordes redondeados */
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    display: flex;
    justify-content: center;
    align-items: center;
}

.desktop-touch-controls {
    display: none; /* Oculto por defecto, se mostrará con JS */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 15; /* Asegura que esté por encima del canvas pero por debajo del menú */
}

.touch-control-button {
    position: absolute;
    width: 60px;
    height: 100px;
    background-color: rgba(76, 175, 80, 0.6);
    color: white;
    border: none;
    border-radius: 10px; /* Cambiado a rectangular con bordes redondeados */
    font-size: 24px;
    cursor: pointer;
    pointer-events: auto;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    display: flex;
    justify-content: center;
    align-items: center;
}

#leftTouchControl {
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
}

#rightTouchControl {
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
}

.rotation-controls {
    display: flex;
    justify-content: space-between;
    width: 100%;
    padding: 0 20px;
    margin: 20px 0;
    box-sizing: border-box;
}

.top-scores-container {
    width: 100%;
    margin-bottom: 10px;
}

.toggle-scores {
    width: 100%;
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 8px;
    border-radius: 5px 5px 0 0;
    cursor: pointer;
    font-weight: bold;
    text-align: center;
}

.top-scores {
    background-color: rgba(0, 0, 0, 0.8);
    padding: 10px;
    border-radius: 0 0 5px 5px;
    color: white;
    width: 100%;
    box-sizing: border-box;
    display: none; /* Oculto por defecto, se mostrará con JS */
}

.score-tabs {
    display: flex;
    border-bottom: 1px solid #4CAF50;
    margin-bottom: 10px;
}

.score-tab {
    background-color: transparent;
    color: white;
    border: none;
    padding: 8px 15px;
    cursor: pointer;
    opacity: 0.7;
    flex: 1;
}

.score-tab.active {
    opacity: 1;
    border-bottom: 2px solid #4CAF50;
    font-weight: bold;
}

.score-tab-content {
    display: none;
}

.score-tab-content.active {
    display: block;
}

.top-scores table {
    width: 100%;
    border-collapse: collapse;
}

.top-scores th, .top-scores td {
    padding: 6px;
    text-align: center;
    border-bottom: 1px solid #4CAF50;
}

.country-flag {
    font-size: 18px;
    display: inline-block;
}

.unknown-flag {
    font-size: 16px;
    opacity: 0.7;
}

#startButton {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 18px;
    margin: 20px 0 10px 0;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

#startButton:hover {
    background-color: #45a049;
}

.game-modes {
    margin: 15px 0;
    width: 100%;
}

.mode-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 5px;
    margin-top: 10px;
}

.mode-button {
    background-color: #34495e;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mode-button.active {
    background-color: #4CAF50;
    transform: scale(1.05);
}

.mode-button:hover {
    background-color: #2980b9;
}

.customization {
    margin: 15px 0;
    width: 100%;
}

.color-options {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 10px 0;
}

.color-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid white;
    cursor: pointer;
    transition: transform 0.2s;
}

.color-btn:hover {
    transform: scale(1.1);
}

.color-btn.active {
    transform: scale(1.2);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
}

.theme-toggle {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin: 10px 0;
}

.theme-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid white;
    background-color: #34495e;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 16px;
    transition: all 0.3s ease;
}

.theme-btn.active {
    background-color: #4CAF50;
    transform: scale(1.1);
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
    background-color: #ccc;
    border-radius: 12px;
    transition: all 0.3s;
}

.toggle-switch:after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: white;
    top: 2px;
    left: 2px;
    transition: all 0.3s;
}

input[type="checkbox"]:checked + .toggle-switch {
    background-color: #4CAF50;
}

input[type="checkbox"]:checked + .toggle-switch:after {
    left: 28px;
}

input[type="checkbox"] {
    display: none;
}

.powerup-hud {
    position: absolute;
    top: 10px;
    right: 60px; /* Ajustado para no solapar con el botón de pausa */
    z-index: 10;
}

.active-powerup {
    display: flex;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 5px;
    border-radius: 5px;
    color: white;
}

.active-powerup img {
    width: 30px;
    height: 30px;
    margin-right: 5px;
}

.powerup-timer {
    width: 50px;
    height: 5px;
    background-color: #3498db;
    border-radius: 2px;
}

.hidden {
    display: none !important;
}

.pause-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 20px 40px;
    border-radius: 10px;
    font-size: 24px;
    font-weight: bold;
    z-index: 1000;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

.timer-display {
    position: absolute;
    top: 10px;
    left: 10px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 18px;
    z-index: 10;
}

.pause-button {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 20;
    display: none; /* Se mostrará solo cuando el juego esté activo */
}

.pause-button button {
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
}

.pause-button button:hover {
    background-color: rgba(0, 0, 0, 0.9);
}

.obstacle {
    fill: #7f8c8d;
    stroke: #2c3e50;
    stroke-width: 2px;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

@keyframes shake {
    0%, 100% { transform: translate(0, 0); }
    10%, 30%, 50%, 70%, 90% { transform: translate(-5px, 0); }
    20%, 40%, 60%, 80% { transform: translate(5px, 0); }
}

.pulse {
    animation: pulse 0.3s ease;
}

.shake {
    animation: shake 0.5s ease;
}

.dark-theme {
    background-color: #121212;
}

.light-theme {
    background-color: #f5f5f5;
}

.player-info {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-top: 10px;
}

.player1-info, .player2-info {
    color: white;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 5px 10px;
    border-radius: 5px;
}

.player1-info {
    color: #4CAF50;
}

.player2-info {
    color: #3498db;
}

@media (max-width: 768px) {
    .game-wrapper {
        padding: 10px;
        height: 100%;
        justify-content: flex-start;
        max-width: 100%;
    }
    
    .mobile-controls button {
        width: 70px;
        height: 70px;
        font-size: 28px;
    }
    
    body {
        height: 100vh;
        padding: 0;
        margin: 0;
        overflow: hidden;
    }
    
    canvas {
        max-height: 70vh;
    }
    
    .game-info {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }
    
    .menu {
        width: 90%;
        max-width: none;
    }
}