body {
    font-family: 'Roboto Mono', monospace;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 2rem;
    background-color: #3a3a3a;
    background-image: radial-gradient(rgba(0,0,0,0) 50%, rgba(0,0,0,0.6) 100%), radial-gradient(#222 15%, transparent 16%), radial-gradient(#222 15%, transparent 16%);
    background-size: cover, 8px 8px, 8px 8px;
    background-position: center, 0 0, 4px 4px;
    min-height: 100vh;
    color: #333;
}

/* --- ESTRUCTURA DESKTOP --- */
.main-container {
    display: flex;
    flex-direction: row; /* Ranking izq | Juego centro | Lista der */
    align-items: flex-start;
    justify-content: center;
    width: 100%;
    max-width: 1200px;
    margin-bottom: 2rem;
    gap: 2rem;
}

.ranking-container {
    background-color: #f9f9f9;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
    text-align: left;
    width: 250px;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.contenedor-juego {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 500px; /* Ancho controlado en el centro */
    position: relative;
}
.titulo{
    color: #fff;
}
.lista-palabras {
    background-color: #fff;
    border-radius: 8px;
    padding: 1rem;
    text-align: left;
    width: 250px;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    max-height: 400px;
    overflow-y: auto;
    margin-top: 20px;
}

/* --- ESTILOS GENERALES --- */
h1 {
    color: #fff;
    text-shadow: 2px 2px 4px #000;
    margin-bottom: 1.5rem;
    text-align: center;
}

/* TABS RANKING */
.tabs-ranking { display: flex; border-bottom: 2px solid #ccc; margin-bottom: 15px; }
.tab-link { padding: 10px; cursor: pointer; border: none; background: transparent; font-family: 'Roboto Mono'; font-weight: 500; color: #555; border-bottom: 3px solid transparent; flex: 1; }
.tab-link:hover { color: #000; }
.tab-link.active { color: #007bff; border-bottom: 3px solid #007bff; }
.tab-content { display: none; }
.tab-content.active { display: block; }
.ranking-contenido ul { list-style: none; padding: 0; margin: 0; }
.ranking-contenido li { padding: 8px 0; border-bottom: 1px solid #eee; font-size: 0.9rem; }

/* SELECTOR DIFICULTAD */
.dificultad-selector { margin-bottom: 1.5rem; text-align: center; width: 100%; }
.dificultad-selector .subt { color: #ddd; font-size: 1rem; margin-bottom: 10px; font-weight: normal; }
.dificultad-selector button {
    background-color: #6c757d; color: white; cursor: pointer;
    border-bottom: 5px solid #545b62; transform: translateY(0);
    transition: all 0.1s; font-weight: bold; text-transform: uppercase;
    margin: 0.2rem;
}
.dificultad-selector button.active { background-color: #6c757d; border: 2px solid #fff; }
.dificultad-selector button:hover { background-color: #5a6268; }
.dificultad-selector button:active { transform: translateY(3px); border-bottom-width: 2px; }

/* PATENTE */
.patente {
    font-size: 3rem; margin: 1.5rem auto; padding: 0.5rem 2.5rem;
    background-color: #000; color: #fff; border: 5px solid #fff;
    border-radius: 8px; width: fit-content; letter-spacing: 0.3rem;
    font-family: 'Roboto Mono', monospace; box-shadow: 0 6px 12px rgba(0,0,0,0.4);
    font-weight: bold; text-transform: uppercase; position: relative; padding-bottom: 1.5rem;
    display: flex; justify-content: center;
}
.patente::after {
    content: "ARGENTINA"; position: absolute; bottom: 5px; left: 0; right: 0;
    text-align: center; font-size: 0.8rem; color: #fff; font-weight: normal; letter-spacing: 0.1rem;
}

/* INFO Y PANEL DE JUEGO */
.info-centro { display: flex; justify-content: space-around; width: 100%; margin-top: 1rem; }
.timer, .puntaje { font-size: 1.5rem; font-weight: 700; text-shadow: 1px 1px 2px rgba(0,0,0,0.5); }
.timer { color: #4dabf7; } .puntaje { color: #51cf66; }
.parpadeo { animation: parpadeo 1s infinite; color: #ff6b6b; }

.panel-juego {
    margin-top: 2rem; width: 100%; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px;
}
input, button { font-family: 'Roboto Mono'; font-size: 1.2rem; padding: 0.6rem 1rem; border-radius: 10px; border: none; outline: none; box-sizing: border-box; }

#inputPalabra { width: 100%; background: #fff; border-bottom: 5px solid #ccc; color: #333; text-align: center; font-weight: bold; }
#inputPalabra:focus { border-bottom: 5px solid #007bff; transform: translateY(2px); }

#btnConfirmar { width: 100%; background: #28a745; border-bottom: 5px solid #1e7e34; color: white; font-weight: bold; cursor: pointer; order: 2; }
#btnConfirmar:active { transform: translateY(3px); border-bottom-width: 2px; }

#btnCambiarLetras { flex: 1; background: #fd7e14; border-bottom: 5px solid #c65f0a; color: white; font-weight: bold; cursor: pointer; order: 3; }
#btnCambiarLetras:active { transform: translateY(3px); border-bottom-width: 2px; }

#btnReiniciar {flex: 1; background: #dc3545; border-bottom: 5px solid #a71d2a; color: white; font-weight: bold; cursor: pointer; order: 4; }
#btnReiniciar:active { transform: translateY(3px); border-bottom-width: 2px; }
/* EXTRAS */
.mensaje-flotante {
    font-size: 1.5rem; font-weight: 700; position: absolute; top: 50%; left: 50%; transform: translateX(-50%);
    padding: .5rem 1rem; border-radius: 8px; z-index: 10; opacity: 0; transition: opacity .5s ease; pointer-events: none;
    background: rgba(255,255,255,0.9); box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}
.mensaje-verde { color: #155724; border: 2px solid #155724; }
.mensaje-rojo { color: #721c24; border: 2px solid #721c24; }

.lista-palabras h2 { margin-top: 0; border-bottom: 1px solid #ccc; padding-bottom: 0.5rem; margin-bottom: 1rem; font-size: 1.2rem; text-align: center; }
.palabra-item { font-size: 1.1rem; color: #333; margin-bottom: .5rem; }

.sugerencias-palabras {
    position: fixed; bottom: 2rem; right: 2rem; width: 250px; background: #fff; border: 1px solid #add8e6;
    border-radius: 8px; padding: 1rem; box-shadow: 0 4px 10px rgba(0,0,0,0.2); z-index: 100;
    opacity: 0; transition: opacity .5s ease-in-out; display: none; font-size: .9rem;
}
.sugerencias-palabras h3 { margin-top: 0; color: #0056b3; border-bottom: 1px solid #add8e6; padding-bottom: .5rem; }
.sugerencias-palabras ul { list-style: none; padding: 0; margin: 0; }

.como-jugar-seccion { width: 100%; max-width: 600px; margin: 2rem auto; text-align: center; }
.btn-toggle-instrucciones { background: #17a2b8; border-bottom: 5px solid #117a8b; color: white; font-weight: bold; cursor: pointer; padding: 0.8rem 2rem; border-radius: 10px; transition: all 0.1s; }
.btn-toggle-instrucciones:active { transform: translateY(3px); border-bottom-width: 2px; }
.instrucciones-ocultas { background: #fff; padding: 1rem; border-radius: 10px; text-align: left; max-height: 0; overflow: hidden; transition: max-height .5s ease-out; margin-top: 1rem; }
.instrucciones-ocultas.visible { max-height: 500px; }

.btn-sonido {
    position: fixed; bottom: 20px; right: 20px; background: rgba(255,255,255,0.8); border: 1px solid #ccc;
    border-radius: 50%; width: 50px; height: 50px; display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; cursor: pointer; box-shadow: 0 2px 5px rgba(0,0,0,0.2); z-index: 1000; transition: all 0.2s;
}
.btn-sonido:hover { background: #fff; transform: translateY(-2px); }

/* ANIMACIONES */
@keyframes shake { 0%, 100% {transform: translateX(0);} 20% {transform: translateX(-10px);} 40% {transform: translateX(10px);} 60% {transform: translateX(-10px);} 80% {transform: translateX(10px);} }
.error-shake { animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both; border-bottom-color: red !important; }
@keyframes pop { 0% {transform: scale(1);} 50% {transform: scale(1.1);} 100% {transform: scale(1);} }
.success-pop { animation: pop 0.3s ease-in-out; color: #28a745 !important; }

/* --- ESTILOS MOBILE (CORREGIDOS) --- */
@media (max-width: 900px) {
    body { padding: 1rem; }
    
    .main-container {
        flex-direction: column; /* Apilar todo */
        align-items: center;
        gap: 2rem;
    }

    /* ORDENAMIENTO MÓVIL */
    /* 1. JUEGO ARRIBA */
    .contenedor-juego {
        order: 1;
        width: 100%;
        /* Importante: No usamos display:contents para no romper el orden interno */
    }

    /* 2. RANKING AL MEDIO */
    .ranking-container {
        order: 2;
        width: 100%;
        max-width: 500px;
        margin: 0;
    }

    /* 3. LISTA ABAJO */
    .lista-palabras {
        order: 3;
        width: 100%;
        max-width: 500px;
        margin: 0;
        text-align: center;
    }

    /* Ajustes de elementos internos en móvil */
    h1 { font-size: 2rem; margin-bottom: 1rem; }
    
    .dificultad-selector button {
        padding: 0.6rem 0.8rem;
        flex: 1; /* Que ocupen espacio parejo */
        font-size: 0.9rem;
    }

    .patente { font-size: 2.5rem; padding: 0.5rem 1.5rem; }
    
    /* Panel de botones: Mantenemos la estructura visual pero ajustamos tamaños si hace falta */
    #inputPalabra { margin-bottom: 0.8rem; }


    /* Elementos que pasan a flujo normal en móvil */
    .sugerencias-palabras {
        position: static; /* Deja de flotar */
        margin: 2rem auto;
        width: 100%;
        max-width: 500px;
        opacity: 0;
    }
    .sugerencias-palabras.mostrar-mobile { display: block; opacity: 1; }

    .como-jugar-seccion { order: 4; margin-top: 2rem; }
    
    .btn-sonido { bottom: 10px; right: 10px; width: 45px; height: 45px; font-size: 1.2rem; }
}