body {
    font-family: Arial, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-image: url('fondo-web.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
    color: white; 
    margin: 0;
    padding: 10px;
    min-height: 100vh;
    overflow-x: hidden;
}

h1 {
    margin: 10px 0;
    font-size: 1.4rem;
    text-align: center;
    text-shadow: 2px 2px 4px black;
}

.game-container {
    width: 95%;
    max-width: 500px;
    /* AJUSTE FIJO A 62vh */
    height: 62vh; 
    min-height: 320px; 
    max-height: 600px; 
    background-image: url('fondo.jpg'); 
    background-size: cover;
    background-position: center;
    border: 3px solid #fff;
    border-radius: 10px;
    position: relative;
    overflow: hidden;
    touch-action: none; 
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    margin-bottom: 8px; /* Reducido ligeramente */
}

.ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

#score, #timer {
    position: absolute;
    top: 10px;
    font-size: 1.2rem;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    background-color: rgba(0, 0, 0, 0.3);
    padding: 5px 10px;
    border-radius: 5px;
    min-width: 100px;
}

#score { left: 10px; text-align: left; }
#timer { right: 10px; text-align: right; }

#pause-button, #mute-button {
    position: absolute;
    right: 15px;
    font-size: 1.3rem;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: 42px; /* Tamaño optimizado */
    height: 42px;
    cursor: pointer;
    pointer-events: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 110;
}

#pause-button { top: 60px; }
#mute-button { top: 110px; }

#catcher {
    width: 110px;
    height: 75px;
    background-image: url('1.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center bottom;
    position: absolute;
    bottom: 0;
    left: calc(50% - 55px); 
    z-index: 50;
}

.snack {
    width: 60px;
    height: 60px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    position: absolute;
    top: -70px; 
    z-index: 10;
}

#message-container {
    text-align: center;
    width: 100%;
    min-height: 70px; /* Reducido para evitar scroll */
}

#message {
    font-size: 1.1rem;
    font-weight: bold;
    text-shadow: 1px 1px 3px black;
    margin-bottom: 8px;
}

#restart-button, #start-button {
    padding: 10px 30px;
    font-size: 1.1rem;
    background-color: #ff9800;
    color: white;
    border: none;
    border-radius: 50px; 
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    /* Margen de seguridad para iPhone */
    margin-bottom: env(safe-area-inset-bottom);
}

#game-logo {
    margin-top: 10px;
    max-width: 100px;
    height: auto;
}

/* CLASE ACTUALIZADA PARA EL FLASH ROJO SOBRE LA IMAGEN */
.error-flash {
    box-shadow: inset 0 0 60px 30px rgba(255, 0, 0, 0.7) !important;
    border: 3px solid red !important;
    transition: none !important;
}
/* Estilos para la ventana emergente */
.modal {
    display: none; /* Oculto por defecto */
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: #222;
    padding: 25px;
    border: 3px solid #ff9800;
    border-radius: 15px;
    text-align: center;
    max-width: 80%;
    box-shadow: 0 0 20px #ff9800;
}

.modal-content h2 {
    color: #ff9800;
    margin-top: 0;
}

.modal-content p {
    font-size: 1.1rem;
    line-height: 1.4;
    margin-bottom: 20px;
}

#close-modal-button {
    padding: 10px 25px;
    font-size: 1rem;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
}