/* Rescate Tortuga - Estilos del juego */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Fredoka', sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    overflow: hidden;
    height: 100vh;
}

#game-container {
    width: 100vw;
    height: 100vh;
    position: relative;
}

/* Pantallas del juego */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.screen.active {
    opacity: 1;
    visibility: visible;
}

/* Pantalla de inicio */
#start-screen {
    background: linear-gradient(135deg, #0f4c75 0%, #3282b8 50%, #0f4c75 100%);
    text-align: center;
    padding: 2rem;
    overflow-y: auto;
    height: 100vh;
    box-sizing: border-box;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Indicador de scroll para móviles */
@media (max-width: 768px) {
    #start-screen::after {
        content: "👆 Desliza para ver más";
        position: fixed;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        background: rgba(0, 0, 0, 0.7);
        color: white;
        padding: 8px 16px;
        border-radius: 20px;
        font-size: 0.8rem;
        z-index: 1000;
        animation: bounce 2s infinite;
        pointer-events: none;
    }
    
    @keyframes bounce {
        0%, 20%, 50%, 80%, 100% {
            transform: translateX(-50%) translateY(0);
        }
        40% {
            transform: translateX(-50%) translateY(-10px);
        }
        60% {
            transform: translateX(-50%) translateY(-5px);
        }
    }
    
    /* Ocultar indicador después de hacer scroll */
    #start-screen.scrolled::after {
        display: none;
    }
}

.logo h1 {
    font-size: 3.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.logo p {
    font-size: 1.2rem;
    opacity: 0.9;
    margin-bottom: 3rem;
}

.game-modes {
    display: flex;
    gap: 2rem;
    margin-bottom: 3rem;
    flex-wrap: wrap;
    justify-content: center;
}

.mode-btn {
    background: rgba(255,255,255,0.1);
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 15px;
    padding: 1.5rem;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 250px;
    backdrop-filter: blur(10px);
}

.mode-btn:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.5);
    transform: translateY(-5px);
}

.mode-btn h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.mode-btn p {
    font-size: 0.9rem;
    opacity: 0.8;
    margin-bottom: 1rem;
}

.seed-info {
    font-size: 0.8rem;
    opacity: 0.7;
    font-family: monospace;
}

.username-input {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    align-items: center;
}

#username {
    padding: 0.8rem 1rem;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 8px;
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 1rem;
    backdrop-filter: blur(10px);
}

#username::placeholder {
    color: rgba(255,255,255,0.6);
}

#username:focus {
    outline: none;
    border-color: #4CAF50;
    background: rgba(255,255,255,0.2);
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.3);
    transform: scale(1.02);
    transition: all 0.3s ease;
}

#start-game {
    padding: 0.8rem 2rem;
    background: #4CAF50;
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

#start-game:hover:not(:disabled) {
    background: #45a049;
    transform: translateY(-2px);
}

#start-game:disabled {
    background: rgba(255,255,255,0.2);
    cursor: not-allowed;
}

.leaderboard-preview {
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 1rem;
    backdrop-filter: blur(10px);
}

.leaderboard-preview h4 {
    margin-bottom: 0.5rem;
}

#top-scores {
    font-size: 0.9rem;
}

.toggle-btn {
    background: rgba(255,255,255,0.1);
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    color: white;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 0.5rem;
    backdrop-filter: blur(10px);
}

.toggle-btn:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.5);
}

/* Pantalla de juego */
#game-screen {
    background: #0a1929;
    flex-direction: row;
    justify-content: flex-start;
    position: relative;
    overflow: hidden;
    align-items: flex-start;
}

#game-hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.7);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    backdrop-filter: blur(5px);
}

.hud-left, .hud-center, .hud-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.oxygen-bar, .health-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.bar-container {
    width: 150px;
    height: 20px;
    background: rgba(255,255,255,0.2);
    border-radius: 10px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    transition: width 0.3s ease;
    width: 100%;
}

.health-fill {
    background: linear-gradient(90deg, #F44336, #FF5722);
    width: 100%;
}

.score-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.score, .combo {
    font-size: 0.9rem;
    font-weight: 600;
}

.turtles-following {
    font-size: 1.1rem;
    font-weight: 600;
    color: #FFD700;
}

.powerups {
    display: flex;
    gap: 0.5rem;
}

.powerup-icon {
    width: 30px;
    height: 30px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.game-stats {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.9rem;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 1200px;
    max-height: 800px;
    margin: 0 auto;
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 10px;
    background: linear-gradient(180deg, #87CEEB 0%, #4682B4 50%, #191970 100%);
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    object-fit: contain;
}

#game-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    gap: 1rem;
}

#game-controls button {
    padding: 0.8rem 1.5rem;
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 8px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
}

#game-controls button:hover {
    background: rgba(255,255,255,0.3);
}

/* Pantalla de pausa */
#pause-screen {
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(10px);
}

.pause-content {
    background: rgba(255,255,255,0.1);
    border-radius: 20px;
    padding: 3rem;
    text-align: center;
    backdrop-filter: blur(20px);
}

.pause-content h2 {
    font-size: 2.5rem;
    margin-bottom: 2rem;
}

.pause-stats {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
    font-size: 1.2rem;
}

.pause-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.pause-buttons button {
    padding: 1rem 2rem;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

#resume-btn {
    background: #4CAF50;
    color: white;
}

#restart-btn {
    background: #FF9800;
    color: white;
}

#main-menu-btn {
    background: #f44336;
    color: white;
}

/* Pantalla de game over */
#game-over-screen {
    background: rgba(0,0,0,0.9);
    backdrop-filter: blur(15px);
}

/* Pantalla de derrota */
#death-screen {
    background: linear-gradient(135deg, #1a0000 0%, #330000 50%, #000000 100%);
    backdrop-filter: blur(15px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.death-content {
    background: rgba(255,255,255,0.1);
    border-radius: 20px;
    padding: 3rem;
    text-align: center;
    backdrop-filter: blur(20px);
    max-width: 600px;
    border: 2px solid rgba(255,0,0,0.3);
}

.death-animation {
    position: relative;
    margin: 2rem 0;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dying-turtle {
    font-size: 4rem;
    animation: turtleDeath 2s ease-in-out infinite;
    z-index: 2;
}

.death-effects {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.bubble {
    position: absolute;
    font-size: 1.5rem;
    animation: bubbleFloat 3s ease-in-out infinite;
}

.bubble1 {
    left: 20%;
    animation-delay: 0s;
}

.bubble2 {
    right: 20%;
    animation-delay: 0.5s;
}

.bubble3 {
    left: 50%;
    top: 20%;
    animation-delay: 1s;
}

.death-title {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: #ff4444;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

.death-message {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    opacity: 0.9;
    color: #ffaaaa;
}

.death-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.death-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.death-buttons button {
    padding: 1rem 2rem;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 1000;
    position: relative;
}

#restart-game-btn {
    background: #4CAF50;
    color: white;
}

#restart-game-btn:hover {
    background: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

#main-menu-death-btn {
    background: #f44336;
    color: white;
}

#main-menu-death-btn:hover {
    background: #da190b;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

/* Animaciones */
@keyframes turtleDeath {
    0% { 
        transform: scale(1) rotate(0deg);
        filter: brightness(1);
    }
    25% { 
        transform: scale(1.1) rotate(5deg);
        filter: brightness(0.8);
    }
    50% { 
        transform: scale(0.9) rotate(-5deg);
        filter: brightness(0.6);
    }
    75% { 
        transform: scale(1.05) rotate(3deg);
        filter: brightness(0.4);
    }
    100% { 
        transform: scale(1) rotate(0deg);
        filter: brightness(0.2);
    }
}

@keyframes bubbleFloat {
    0% { 
        opacity: 0;
        transform: translateY(0) scale(0.5);
    }
    50% { 
        opacity: 1;
        transform: translateY(-50px) scale(1);
    }
    100% { 
        opacity: 0;
        transform: translateY(-100px) scale(0.5);
    }
}

.game-over-content {
    background: rgba(255,255,255,0.1);
    border-radius: 20px;
    padding: 3rem;
    text-align: center;
    backdrop-filter: blur(20px);
    max-width: 600px;
}

.game-over-content h2 {
    font-size: 2.5rem;
    margin-bottom: 2rem;
}

.final-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat {
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stat-label {
    font-size: 0.9rem;
    opacity: 0.8;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #FFD700;
}

.game-over-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.game-over-buttons button {
    padding: 1rem 2rem;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

#play-again-btn {
    background: #4CAF50;
    color: white;
}

#leaderboard-btn {
    background: #2196F3;
    color: white;
}

#main-menu-final-btn {
    background: #f44336;
    color: white;
}

/* Pantalla de leaderboard */
#leaderboard-screen {
    background: rgba(0,0,0,0.9);
    backdrop-filter: blur(15px);
}

.leaderboard-content {
    background: rgba(255,255,255,0.1);
    border-radius: 20px;
    padding: 2rem;
    backdrop-filter: blur(20px);
    max-width: 800px;
    width: 90%;
}

.leaderboard-content h2 {
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: 2rem;
}

.leaderboard-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    justify-content: center;
}

.tab-btn {
    padding: 0.8rem 2rem;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 10px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab-btn.active {
    background: rgba(255,255,255,0.3);
    border-color: rgba(255,255,255,0.5);
}

#leaderboard-list {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 2rem;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
    margin-bottom: 0.5rem;
}

.leaderboard-rank {
    font-size: 1.5rem;
    font-weight: 700;
    color: #FFD700;
    min-width: 50px;
}

.leaderboard-player {
    flex: 1;
    margin-left: 1rem;
}

.leaderboard-score {
    font-size: 1.2rem;
    font-weight: 600;
}

.leaderboard-buttons {
    text-align: center;
}

#back-to-menu-btn {
    padding: 1rem 2rem;
    background: #f44336;
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

/* Responsive */
@media (max-width: 768px) {
    .game-modes {
        flex-direction: column;
        align-items: center;
    }
    
    .mode-btn {
        min-width: 200px;
    }
    
    .username-input {
        flex-direction: column;
        gap: 1rem;
    }
    
    #game-canvas {
        width: 100vw;
        height: calc(100vh - 80px);
        margin-top: 80px;
    }
    
    .hud-left, .hud-center, .hud-right {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .final-stats {
        grid-template-columns: 1fr;
    }
    
    .game-over-buttons, .pause-buttons {
        flex-direction: column;
        align-items: center;
    }
}

/* Animaciones */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.pulse {
    animation: pulse 0.5s ease-in-out;
}

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

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

/* Estilos para selección de modo */
.mode-btn.selected {
    background: linear-gradient(135deg, #FF9800 0%, #F57C00 100%) !important;
    transform: scale(1.05);
    box-shadow: 0 8px 16px rgba(255, 152, 0, 0.4) !important;
    border: 3px solid #FFC107;
}

.mode-btn.selected:hover {
    background: linear-gradient(135deg, #FFB74D 0%, #FF9800 100%) !important;
}

.username-input button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.username-input button:not(:disabled):hover {
    background: linear-gradient(135deg, #5CBF60 0%, #4CAF50 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

/* Mejoras para pantallas de alta resolución y zoom */
@media screen and (min-width: 1025px) {
    /* Desktop con alta resolución */
    #game-screen {
        position: relative;
        width: 100vw;
        height: 100vh;
        overflow: hidden;
    }
    
    #game-canvas {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: -moz-crisp-edges;
        image-rendering: pixelated;
        image-rendering: optimize-contrast;
    }
    
    #game-hud {
        position: relative;
        z-index: 20;
        backdrop-filter: blur(5px);
        background: rgba(0, 0, 0, 0.1);
    }
    
    .game-controls {
        position: relative;
        z-index: 20;
    }
}

/* Adaptaciones para zoom del sistema */
@media screen and (min-resolution: 144dpi) {
    /* Pantallas con zoom 150% */
    body {
        font-size: 14px;
    }
    
    #game-hud {
        padding: 8px 12px;
    }
    
    .hud-left, .hud-center, .hud-right {
        gap: 8px;
    }
}

@media screen and (min-resolution: 120dpi) and (max-resolution: 143dpi) {
    /* Pantallas con zoom 125% */
    body {
        font-size: 15px;
    }
    
    #game-hud {
        padding: 10px 15px;
    }
}

/* Mejoras para tablets */
@media screen and (min-width: 769px) and (max-width: 1024px) {
    #game-screen {
        position: relative;
        width: 100vw;
        height: 100vh;
    }
    
    #game-hud {
        padding: 12px 20px;
        font-size: 16px;
    }
    
    .game-controls {
        padding: 15px;
    }
    
    .game-controls button {
        padding: 12px 20px;
        font-size: 16px;
    }
}

/* Mejoras específicas para móviles */
@media screen and (max-width: 768px) {
    #game-screen {
        position: relative;
        width: 100vw;
        height: 100vh;
        overflow: hidden;
    }
    
    #game-hud {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        z-index: 30;
        background: rgba(0, 0, 0, 0.3);
        backdrop-filter: blur(3px);
        padding: 8px 12px;
    }
    
    #game-canvas {
        position: absolute;
        z-index: 10;
    }
    
    .game-controls {
        display: none !important;
    }
}

/* Controles táctiles - SE ACTIVAN VIA JAVASCRIPT */
#touch-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 200px;
    z-index: 1000;
    display: none; /* Se activa via JavaScript */
    visibility: hidden; /* Se activa via JavaScript */
    pointer-events: auto; /* CAMBIADO: permitir eventos táctiles */
}

@media screen and (max-width: 480px) {
    #touch-controls {
        height: 150px;
    }
}

/* Joystick virtual */
#joystick-container {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 100px;
    height: 100px;
}

#joystick-base {
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.2);
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    position: relative;
    touch-action: none;
}

#joystick-knob {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.8);
    border: 2px solid rgba(255, 255, 255, 1);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: transform 0.1s ease;
    pointer-events: none;
}

/* Botones táctiles */
.touch-buttons {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    gap: 15px;
}

.touch-btn {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.2);
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
    touch-action: none;
    user-select: none;
}

.touch-btn:active {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(0.95);
}

/* Optimizaciones de rendimiento */
#game-canvas {
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Prevenir zoom accidental en móviles */
@media screen and (max-width: 768px) {
    * {
        touch-action: manipulation;
    }
    
    input, button, select, textarea {
        touch-action: auto;
    }
}

/* ===== CONTROLES TÁCTILES Y DE ESCRITORIO ===== */

/* Joystick y controles para móvil */
.touch-joystick {
    position: absolute;
    left: 50px;
    bottom: 50px;
    pointer-events: all;
}

.joystick-base {
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.15);
    border: 4px solid rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    position: relative;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), inset 0 2px 10px rgba(255, 255, 255, 0.1);
    transition: all 0.2s ease;
    touch-action: none;
}

.joystick-base:active {
    transform: scale(1.05);
    border-color: rgba(255, 255, 255, 0.8);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.4), inset 0 2px 15px rgba(255, 255, 255, 0.2);
}

.joystick-knob {
    width: 60px;
    height: 60px;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.7));
    border: 2px solid rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.1s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4), inset 0 2px 5px rgba(255, 255, 255, 0.3);
    pointer-events: none;
}

.joystick-knob::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    background: rgba(0, 150, 255, 0.6);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 10px rgba(0, 150, 255, 0.4);
}

.touch-buttons {
    position: absolute;
    right: 50px;
    bottom: 50px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    pointer-events: all;
}

.touch-btn {
    width: 80px;
    height: 80px;
    border: 4px solid rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    font-size: 2rem;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    cursor: pointer;
    backdrop-filter: blur(10px);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), inset 0 2px 10px rgba(255, 255, 255, 0.1);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    touch-action: none;
    user-select: none;
}

.touch-btn:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.8);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4), inset 0 4px 15px rgba(255, 255, 255, 0.2);
}

.boost-btn:active {
    background: rgba(255, 215, 0, 0.4);
    border-color: rgba(255, 215, 0, 0.8);
    box-shadow: 0 2px 10px rgba(255, 215, 0, 0.3), inset 0 4px 15px rgba(255, 255, 255, 0.2);
}

/* Media queries para responsive */
@media (max-width: 768px) {
    /* Pantalla de inicio responsive */
    #start-screen {
        padding: 0.5rem;
        overflow-y: auto;
        height: 100vh;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
    }
    
    .logo {
        flex-shrink: 0;
        margin-bottom: 1rem;
    }
    
    .logo h1 {
        font-size: 2rem;
        margin-bottom: 0.3rem;
        line-height: 1.2;
    }
    
    .logo p {
        font-size: 0.9rem;
        margin-bottom: 0.8rem;
        line-height: 1.3;
    }
    
    .game-modes {
        flex-direction: column;
        gap: 0.6rem;
        margin-bottom: 1rem;
        flex-shrink: 0;
    }
    
    .mode-btn {
        min-width: auto;
        width: 100%;
        padding: 0.8rem;
        margin: 0;
    }
    
    .mode-btn h3 {
        font-size: 1.1rem;
        margin-bottom: 0.2rem;
        line-height: 1.2;
    }
    
    .mode-btn p {
        font-size: 0.8rem;
        margin-bottom: 0.3rem;
        line-height: 1.2;
    }
    
    .seed-info {
        font-size: 0.7rem;
        line-height: 1.2;
    }
    
    .username-input {
        flex-direction: column;
        gap: 0.8rem;
        margin-bottom: 1rem;
        width: 100%;
        flex-shrink: 0;
    }
    
    #username {
        width: 100%;
        padding: 0.8rem;
        font-size: 16px; /* Evita zoom automático en iOS */
        border-radius: 8px;
        -webkit-appearance: none;
        -webkit-border-radius: 8px;
    }
    
    #start-game {
        width: 100%;
        padding: 0.8rem;
        font-size: 1rem;
        border-radius: 8px;
        min-height: 45px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        box-shadow: 0 3px 10px rgba(76, 175, 80, 0.3);
    }
    
    #start-game:not(:disabled):active {
        transform: scale(0.98);
        box-shadow: 0 2px 6px rgba(76, 175, 80, 0.5);
    }
    
    .leaderboard-preview {
        margin-top: 0.8rem;
        flex-shrink: 0;
    }
    
    .leaderboard-preview h4 {
        font-size: 1rem;
        margin-bottom: 0.3rem;
    }
    
    /* Leaderboard colapsible en móviles */
    #top-scores {
        display: none;
        margin-top: 0.5rem;
    }
    
    .leaderboard-preview.expanded #top-scores {
        display: block;
    }
    
    .toggle-btn {
        width: 100%;
        padding: 0.6rem;
        font-size: 0.8rem;
        margin-top: 0.3rem;
    }
    
    /* Controles táctiles */
    .touch-controls {
        display: block;
    }
    
    #game-canvas {
        width: 100vw !important;
        height: calc(100vh - 200px) !important;
        object-fit: contain;
        max-width: 100%;
        max-height: 100%;
        margin-top: 0 !important;
        border-radius: 0;
        border: none;
        transform: scale(1.05);
        transform-origin: center top;
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
        z-index: 1;
    }
    
    .game-hud {
        padding: 8px;
        height: 70px;
        overflow: hidden;
        background: rgba(0, 0, 0, 0.2);
        backdrop-filter: blur(3px);
        z-index: 100;
    }
    
    .hud-top, .hud-bottom {
        flex-direction: row;
        gap: 8px;
        align-items: center;
    }
    
    .score-info, .time-info, .oxygen-bar, .health-bar, .turtle-info {
        font-size: 0.8rem;
        flex-shrink: 0;
        color: white;
        text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    }
    
    .bar-container {
        width: 80px;
        height: 8px;
    }
    
    .oxygen-bar, .health-bar {
        gap: 0.3rem;
    }
    
    .oxygen-bar span, .health-bar span {
        font-size: 0.7rem;
    }
    
    
    .death-content {
        padding: 1rem;
        margin: 0.3rem;
        max-height: 70vh;
        overflow-y: auto;
    }
    
    .death-title {
        font-size: 1.4rem;
        margin-bottom: 0.3rem;
    }
    
    .death-message {
        font-size: 0.9rem;
        margin-bottom: 0.6rem;
    }
    
    .death-animation {
        height: 80px;
        margin: 0.6rem 0;
    }
    
    .dying-turtle {
        font-size: 2.2rem;
    }
    
    .death-stats {
        grid-template-columns: 1fr;
        gap: 0.3rem;
        margin-bottom: 0.6rem;
        font-size: 0.8rem;
    }
    
    .death-buttons {
        flex-direction: column;
        gap: 0.3rem;
    }
    
    .death-buttons button {
        width: 100%;
        padding: 0.6rem;
        font-size: 0.8rem;
        margin-bottom: 0;
    }
}

@media (max-width: 480px) {
    /* Pantalla de inicio para móviles pequeños */
    #start-screen {
        padding: 0.3rem;
    }
    
    .logo {
        margin-bottom: 0.8rem;
    }
    
    .logo h1 {
        font-size: 1.8rem;
        margin-bottom: 0.2rem;
        line-height: 1.1;
    }
    
    .logo p {
        font-size: 0.8rem;
        margin-bottom: 0.6rem;
        line-height: 1.2;
    }
    
    .game-modes {
        gap: 0.5rem;
        margin-bottom: 0.8rem;
    }
    
    .mode-btn {
        padding: 0.6rem;
    }
    
    .mode-btn h3 {
        font-size: 1rem;
        margin-bottom: 0.1rem;
        line-height: 1.1;
    }
    
    .mode-btn p {
        font-size: 0.7rem;
        margin-bottom: 0.2rem;
        line-height: 1.1;
    }
    
    .seed-info {
        font-size: 0.6rem;
        line-height: 1.1;
    }
    
    .username-input {
        gap: 0.6rem;
        margin-bottom: 0.8rem;
    }
    
    #username {
        padding: 0.6rem;
        font-size: 16px;
    }
    
    #start-game {
        padding: 0.6rem;
        font-size: 0.9rem;
        min-height: 40px;
    }
    
    .leaderboard-preview {
        margin-top: 0.6rem;
    }
    
    .leaderboard-preview h4 {
        font-size: 0.9rem;
        margin-bottom: 0.2rem;
    }
    
    /* Controles táctiles */
    .touch-controls {
        height: 150px;
    }
    
    .touch-joystick {
        left: 30px;
        bottom: 30px;
    }
    
    .joystick-base {
        width: 100px;
        height: 100px;
        border-width: 3px;
    }
    
    .joystick-knob {
        width: 50px;
        height: 50px;
        pointer-events: none; /* Evitar interferencias con eventos táctiles */
    }
    
    .joystick-knob::before {
        width: 16px;
        height: 16px;
    }
    
    .touch-buttons {
        right: 30px;
        bottom: 30px;
    }
    
    .touch-btn {
        width: 70px;
        height: 70px;
        font-size: 1.5rem;
    }
    
    #game-canvas {
        height: calc(100vh - 150px) !important;
        object-fit: contain;
        max-width: 100%;
        max-height: 100%;
        margin-top: 0 !important;
        border-radius: 0;
        border: none;
        transform: scale(1.08);
        transform-origin: center top;
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
        z-index: 1;
    }
    
    .game-hud {
        padding: 4px;
        height: 60px;
        overflow: hidden;
        background: rgba(0, 0, 0, 0.2);
        backdrop-filter: blur(3px);
        z-index: 100;
    }
    
    .hud-top, .hud-bottom {
        flex-direction: row;
        gap: 4px;
        align-items: center;
    }
    
    .score-info, .time-info, .oxygen-bar, .health-bar, .turtle-info {
        font-size: 0.7rem;
        flex-shrink: 0;
        color: white;
        text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    }
    
    .bar-container {
        width: 60px;
        height: 6px;
    }
    
    .oxygen-bar, .health-bar {
        gap: 0.2rem;
    }
    
    .oxygen-bar span, .health-bar span {
        font-size: 0.6rem;
    }
    
    
    .death-content {
        padding: 0.8rem;
        margin: 0.2rem;
        max-height: 60vh;
        overflow-y: auto;
    }
    
    .death-title {
        font-size: 1.2rem;
        margin-bottom: 0.2rem;
    }
    
    .death-message {
        font-size: 0.8rem;
        margin-bottom: 0.5rem;
    }
    
    .death-animation {
        height: 60px;
        margin: 0.4rem 0;
    }
    
    .dying-turtle {
        font-size: 1.8rem;
    }
    
    .death-stats {
        grid-template-columns: 1fr;
        gap: 0.2rem;
        margin-bottom: 0.5rem;
        font-size: 0.7rem;
    }
    
    .death-buttons {
        flex-direction: column;
        gap: 0.2rem;
    }
    
    .death-buttons button {
        width: 100%;
        padding: 0.5rem;
        font-size: 0.7rem;
        margin-bottom: 0;
    }
}

/* Media query para pantallas muy pequeñas */
@media (max-width: 360px) {
    #start-screen {
        padding: 0.3rem;
    }
    
    .logo h1 {
        font-size: 1.8rem;
    }
    
    .logo p {
        font-size: 0.8rem;
    }
    
    .mode-btn {
        padding: 0.6rem;
    }
    
    .mode-btn h3 {
        font-size: 1rem;
    }
    
    .mode-btn p {
        font-size: 0.7rem;
    }
    
    #username {
        padding: 0.6rem;
        font-size: 0.8rem;
    }
    
    #start-game {
        padding: 0.6rem;
        font-size: 0.9rem;
    }
    
    .leaderboard-preview {
        font-size: 0.8rem;
    }
    
    /* Pantalla de muerte para pantallas muy pequeñas */
    .death-content {
        padding: 0.6rem;
        margin: 0.1rem;
        max-height: 50vh;
        overflow-y: auto;
    }
    
    .death-title {
        font-size: 1.1rem;
        margin-bottom: 0.1rem;
    }
    
    .death-message {
        font-size: 0.7rem;
        margin-bottom: 0.4rem;
    }
    
    .death-animation {
        height: 50px;
        margin: 0.3rem 0;
    }
    
    .dying-turtle {
        font-size: 1.5rem;
    }
    
    .death-stats {
        gap: 0.1rem;
        margin-bottom: 0.4rem;
        font-size: 0.6rem;
    }
    
    .death-buttons button {
        padding: 0.4rem;
        font-size: 0.6rem;
    }
}

/* Detectar si es dispositivo táctil */
@media (hover: none) and (pointer: coarse) {
    .touch-controls {
        display: block;
    }
    
    /* Ocultar controles de teclado en pantallas táctiles */
    .game-controls {
        display: none;
    }
}