* { box-sizing: border-box; touch-action: manipulation; font-family: 'Comic Neue', cursive; margin: 0; padding: 0; }

body {
    background: #050A30 url('fondo.jpg') no-repeat center center fixed;
    background-size: cover;
    display: flex; 
    justify-content: center; 
    align-items: center;
    height: 100dvh; 
    overflow: hidden;
}

.container {
    background: #FF6B6B; 
    width: 92vw; 
    height: 85dvh; 
    max-height: 85dvh;
    max-width: 420px;
    padding: 12px; 
    border-radius: 20px; 
    border: 4px solid black;
    box-shadow: 6px 6px 0px #000;
    display: flex; 
    flex-direction: column; 
    /* Quitamos space-between para controlar los gaps manualmente */
    justify-content: flex-start; 
    overflow: hidden;
}

.titulo-principal { 
    color: #FFD700; 
    font-size: 1.3rem; 
    text-align: center; 
    text-shadow: 2px 2px 0px black;
    margin-top: 5px;
    margin-bottom: 12px; /* Espacio extra */
}

.selector-nivel { 
    display: flex; 
    justify-content: center; 
    gap: 10px; 
    margin-bottom: 12px; /* Espacio extra */
}

.selector-nivel button {
    background: rgba(0, 0, 0, 0.3); border: 2px solid black; color: white;
    padding: 4px 12px; border-radius: 10px; font-size: 0.85rem;
}
.selector-nivel button.active { background: #FFD700; color: black; }

.stats { 
    background: rgba(255, 255, 255, 0.2); 
    padding: 6px; 
    border-radius: 10px; 
    border: 2px solid black; 
    display: flex; 
    justify-content: space-around; 
    font-size: 0.85rem;
    margin-bottom: 5px;
}

.display-area { 
    flex: 1; /* Esta zona absorberá el espacio sobrante o se encogerá */
    display: flex; 
    flex-direction: column; 
    justify-content: center; 
    align-items: center;
    min-height: 0;
}

input {
    background: transparent; border: none; color: white; 
    font-size: 3.5rem; 
    text-align: center; width: 100%; font-weight: 900; 
    text-shadow: 4px 4px 0px black; outline: none;
}

#mensaje { font-size: 1.2rem; font-weight: bold; color: #fff; text-shadow: 2px 2px 0px black; }

.teclado { 
    display: grid; 
    grid-template-columns: repeat(3, 1fr); 
    gap: 5px; 
    margin-bottom: 10px;
}

.teclado button {
    background: #48C9B0; border: 3px solid black; border-radius: 10px;
    color: white; font-size: 1.5rem; 
    padding: 8px 0; /* Un poco más compacto para asegurar que el footer quepa */
    box-shadow: 3px 3px 0px black;
}

.btn-send { grid-column: span 2; background: #FFD700 !important; color: black !important; }

.footer-controls { 
    margin-top: auto; /* Empuja el footer al final de la caja */
    display: flex; flex-direction: column; align-items: center; 
    gap: 4px; 
    padding-bottom: 5px;
}

#btnReiniciar { background: #58D68D; color: white; width: 100%; padding: 6px; border-radius: 12px; border: 3px solid black; font-size: 1rem; }
#btnInstrucciones { background: transparent; color: #fff; border: none; text-decoration: underline; font-size: 0.85rem; }

.legal-line { display: flex; justify-content: center; align-items: center; gap: 5px; }
.legal-line a, .legal-line span { font-size: 0.6rem; color: white; text-decoration: none; }

.modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.8); justify-content: center; align-items: center; z-index: 100; }
.modal-content { background: #fff; padding: 20px; border-radius: 20px; border: 4px solid black; width: 80%; text-align: center; }