/* Variables Globales y Estética Institucional */
:root {
    /* Paleta Institucional (extraída de layout.css) */
    --inst-red: #9D0603;
    --inst-red-hover: #7A0502;
    --inst-black: #1A1A1A;
    --inst-white: #FAF7E8; /* Crema */
    --bg-white-solid: #FFFFFF;

    /* Grises derivados */
    --text-main: #2E2E2E;
    --text-secondary: #595959;
    --border-color: #D1CDBB;
    --bg-light: var(--inst-white);
    --bg-light-darker: #F0EDDE;

    /* Trama de fondo */
    --bg-trama: var(--bg-white-solid) radial-gradient(circle, var(--inst-white) 1.5px, transparent 1.5px) 0 0 / 18px 18px;

    /* Estados de Validación */
    --estado-correcto-bg: #dcfce7;
    --estado-correcto-border: #22c55e;
    --estado-correcto-text: #166534;
    
    --estado-incorrecto-bg: #fee2e2;
    --estado-incorrecto-border: #ef4444;
    --estado-incorrecto-text: #7A0502;

    /* Estados de Palabra del Día */
    --palabra-correcta-bg: #6aaa64;
    --palabra-presente-bg: #c9b458;
    --palabra-ausente-bg: #787c7e;
    --palabra-texto: #ffffff;
    --teclado-bg: #d3d6da;
    --teclado-text: #1A1A1A;
    
    --fuente-principal: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* --- Dark Mode Palette --- */
body.dark-mode {
    --inst-white: #2E2E2E;
    --bg-white-solid: #1A1A1A;
    --text-main: #EAEAEA;
    --text-secondary: #9E9E9E;
    --border-color: #424242;
    --bg-light: #252525;
    --bg-light-darker: #333333;

    --bg-trama: var(--bg-white-solid) radial-gradient(circle, #252525 1px, transparent 1px) 0 0 / 18px 18px;

    --estado-correcto-bg: #143d26;
    --estado-correcto-text: #6ee7b7;

    --estado-incorrecto-bg: #450a0a;
    --estado-incorrecto-text: #fca5a5;

    --teclado-bg: #818384;
    --teclado-text: #FFFFFF;
}

/* Reset y Trama de Puntos */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--fuente-principal);
    background: var(--bg-trama);
    color: var(--text-main);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

body.dark-mode input {
    background-color: var(--bg-light-darker);
    border-color: var(--border-color);
    color: var(--text-main);
}

/* Barra de Navegación Superior */
.navbar {
    background-color: var(--inst-black);
    color: #FAF7E8; /* Color claro fijo para el texto de la navbar */
    padding: 0 2rem; 
    display: flex;
    align-items: center;
    justify-content: space-between; /* Modificado para espaciar los elementos */
    height: 60px;
    width: 100%;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    border-bottom: 1px solid #454545; /* Usando un color directamente */
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 15px;
}

.navbar-logo {
    height: 40px;
}

.navbar-title-container {
    display: flex;
    flex-direction: column;
    line-height: 1;
}

.navbar-title {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.navbar-powered-by {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.navbar-timer {
    font-family: monospace;
    font-size: 1.4rem;
    font-weight: bold;
    /* El color se hereda de .navbar */
    background-color: rgba(250, 247, 232, 0.1);
    padding: 5px 15px;
    border-radius: 4px;
}

.navbar-user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    /* El color se hereda de .navbar */
}

.btn-theme-toggle {
    background: none;
    border: none;
    color: inherit; /* Hereda el color de .navbar */
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 0.5rem;
    line-height: 1;
}

.btn-logout {
    background-color: var(--inst-red);
    color: white;
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
}

/* Control de Visibilidad de Pantallas */
.pantalla-oculta {
    display: none !important;
}

.pantalla-activa, .screen { /* Aplicamos estilos base a ambas clases por seguridad */
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    /* min-height: 100vh; */ /* Se maneja con flexbox en el body */
    padding: 90px 10px 30px;
    width: 100%;
    flex-grow: 1; /* Hace que la pantalla activa ocupe el espacio disponible */
}

/* Pantalla de Inicio */
#pantalla-inicial.pantalla-activa {
    padding: 0; /* El wrapper se encargará del padding */
    align-items: stretch; /* Para que los paneles laterales ocupen toda la altura */
}

.inicio-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 1400px; /* Aumentamos el ancho máximo para dar espacio a los anuncios */
    gap: 2rem;
    padding: 90px 10px 30px;;
}

.inicio-container {
    text-align: center;
    background-color: var(--bg-white-solid);
    padding: 4rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 24px rgba(26, 26, 26, 0.1);
    max-width: 700px;
    width: 100%;
}

.inicio-logo {
    height: 100px;
    margin-bottom: 1rem;
}

.inicio-titulo-main {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--text-main);
}

.inicio-subtitulo {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 2.5rem;
}

.modo-juego-container {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap; /* Permite que las tarjetas se ajusten en pantallas pequeñas */
    justify-content: center;
    margin-bottom: 2.5rem;
}

.modo-juego-card {
    background-color: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    width: 250px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.modo-juego-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 15px rgba(26, 26, 26, 0.1);
    border-color: var(--inst-red);
}

.card-titulo {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--inst-red);
    margin-bottom: 0.5rem;
}

.card-descripcion {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.btn-modo-completo-visible {
    display: block;
    margin: 0 auto 1.5rem auto;
    width: fit-content;
}

.admin-titulo {
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--bg-light-darker);
    padding-bottom: 0.5rem;
}

/* Contenedor de admin y centrado de su botón */
#admin-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.side-panel {
    background-color: var(--bg-white-solid);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    width: 280px;
    align-self: center; /* Centra verticalmente respecto al contenedor principal */
    box-shadow: 0 4px 12px rgba(26, 26, 26, 0.08);
    animation: fadeIn 0.5s ease-out;
}

/* Estilos para el panel de Racha */
.streak-box {
    text-align: center;
}

.streak-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 1rem;
}

.streak-icon {
    font-size: 4rem;
    line-height: 1;
}

.streak-number {
    font-size: 3.5rem;
    font-weight: 800;
    color: var(--inst-red);
    line-height: 1.1;
}

.streak-text {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 600;
}

/* Estilos para el panel de Ranking */
.home-ranking-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 1rem;
    text-align: center;
}

.home-ranking-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.home-ranking-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: 4px;
    background-color: var(--bg-light);
    font-size: 0.9rem;
}

.home-ranking-item.current-user {
    background-color: var(--estado-correcto-bg);
    border-left-color: var(--estado-correcto-border);
    font-weight: 700;
    margin-top: 0.5rem;
}

.link-modo-completo {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-bottom: 1px dashed var(--border-color);
    transition: color 0.2s;
}

.link-modo-completo:hover {
    color: var(--inst-red);
}

/* Contenedor Principal */
.simulador-container {
    background-color: var(--bg-white-solid);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(26, 26, 26, 0.08);
    max-width: 800px;
    width: 100%;
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Encabezado y Estadísticas */
.header-simulador {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--bg-light-darker);
    padding-bottom: 1rem;
    margin-bottom: 1rem;
}
.header-titulo-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-titulo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
}



.estadisticas {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    background-color: var(--bg-light-darker);
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
}

/* Viñeta Clínica */
.vineta-clinica {
    font-size: 1.05rem;
    text-align: justify;
    color: var(--text-main);
}

/* Opciones de Respuesta */
.opciones-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.btn-opcion {
    background-color: var(--bg-white-solid);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1rem;
    text-align: left;
    font-family: inherit;
    font-size: 1rem;
    color: var(--text-main);
    cursor: pointer;
       transition: all 0.2s ease-in-out, transform 0.15s ease;
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.btn-opcion.animate-correct { animation: pulse-correct 0.5s ease; }
.btn-opcion.animate-incorrect { animation: shake 0.5s ease; }

.btn-opcion:hover:not(:disabled) {
    background-color: var(--bg-light-darker);
      transform: translateY(-2px);
    border-color: var(--border-color);
}

.btn-opcion:disabled {
    cursor: not-allowed;
    opacity: 0.8;
}

.opcion-letra {
    font-weight: 700;
    color: var(--text-secondary);
    min-width: 24px;
}

/* Estados de Validación */
.opcion-correcta {
    background-color: var(--estado-correcto-bg) !important;
    border-color: var(--estado-correcto-border) !important;
    color: var(--estado-correcto-text) !important;
}

.opcion-incorrecta {
    background-color: var(--estado-incorrecto-bg) !important;
    border-color: var(--estado-incorrecto-border) !important;
    color: var(--estado-incorrecto-text) !important;
}

/* Panel de Justificación */
.justificacion-container {
    display: none;
    background-color: var(--bg-light-darker);
    border-left: 4px solid var(--inst-red);
    padding: 1.5rem;
    border-radius: 0 6px 6px 0;
    margin-top: 1rem;
    animation: fadeIn 0.3s ease-in;
}

.justificacion-titulo {
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.justificacion-texto {
    font-size: 0.95rem;
    color: var(--text-secondary);
    text-align: justify;
}

/* Controles de Navegación */
.controles {
    display: flex;
    justify-content: space-between; /* Alinea los botones a los extremos */
    margin-top: 1rem;
}

.btn-siguiente {
    display: block; /* Cambiado de 'none' a 'block' para que el botón de temas premium sea visible */
    background-color: var(--inst-red);
    color: #ffffff;
    border: none;
    border-radius: 6px;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.15s ease;
}

.btn-siguiente:hover {
    background-color: var(--inst-red-hover);
    transform: scale(1.03);
}

.btn-siguiente.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: var(--text-secondary); /* Estilo para botón deshabilitado */
}

.btn-secundario {
    background-color: var(--bg-light-darker);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.15s ease;
    display: none; /* Oculto por defecto */
}

.btn-secundario:hover {
    background-color: #e2e0d3;
    transform: scale(1.03);
    border-color: #c2c0b3;
}

.premium-topics-accordion {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
    max-height: 60vh;
    overflow-y: auto;
}

.topic-area {
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.topic-area-summary {
    padding: 0.75rem 1rem;
    font-weight: 700;
    cursor: pointer;
    background-color: var(--bg-light);
    list-style: none; /* Oculta el marcador por defecto */
}
.topic-area-summary::-webkit-details-marker { display: none; }

.subtopics-container {
    padding: 0.5rem 1rem 1rem 1rem;
    background-color: var(--bg-white-solid);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.subtopic-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--bg-light-darker);
}
.subtopic-item:last-child {
    border-bottom: none;
}

/* Manejo de Errores */
.error-carga {
    color: var(--inst-red);
    font-weight: bold;
    text-align: center;
    padding: 2rem;
    background-color: var(--estado-incorrecto-bg);
    border: 1px solid var(--estado-incorrecto-border);
    border-radius: 6px;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Pantalla de Resultados */
.estadisticas-finales {
    font-size: 1.1rem;
    background-color: var(--bg-light-darker);
    padding: 0.8rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    margin-bottom: 1rem;
    font-weight: 600;
}

.subtitulo-revision {
    margin-top: 2rem;
    border-top: 2px solid var(--bg-light-darker);
    padding-top: 1.5rem;
}

.lista-revision details {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 1rem;
}

.lista-revision summary {
    padding: 1rem;
    font-weight: bold;
    cursor: pointer;
    background-color: var(--bg-light);
    border-radius: 6px;
    list-style: none; /* Oculta el marcador por defecto */
}

.lista-revision summary::-webkit-details-marker { display: none; } /* Para Chrome/Safari */

.lista-revision .contenido-pregunta-revision {
    padding: 1.5rem;
    background-color: var(--bg-white-solid);
}

/* Pantalla Palabra del Día */
#pantalla-palabra {
    padding: 2rem 1rem;
    flex-direction: column;
}

.palabra-container {
    background-color: var(--bg-white-solid);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(26, 26, 26, 0.08);
    max-width: 600px;
    width: 100%;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    margin-top: 60px;
}
.crucigrama-container {
    background-color: var(--bg-white-solid);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(26, 26, 26, 0.08);
    max-width: 700px;
    max-height: 900px;
    width: 100%;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    margin-top: 20px;
}
.header-palabra {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--bg-light-darker);
    padding-bottom: 1rem;
}

.btn-volver {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    font-size: 0.9rem;
}

.palabra-grilla {
    display: grid;
    grid-template-rows: repeat(6, 1fr);
    gap: 5px;
}

.fila-grilla {
    display: grid;
    gap: 5px;
}

.casilla-grilla {
    width: 100%;
    height: 100%;
    aspect-ratio: 1 / 1;
    border: 2px solid var(--border-color);
    display: inline-flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    font-weight: bold;
    text-transform: uppercase;
    color: var(--text-main);
    transition: all 0.3s ease;
}

.casilla-grilla.casilla-pista {
    color: var(--text-secondary);
    opacity: 0.7;
    border-style: dashed;
}

.fila-grilla.shake {
    animation: shake 0.6s cubic-bezier(.36,.07,.19,.97);
}

.casilla-grilla.correcta {
    background-color: var(--palabra-correcta-bg);
    border-color: var(--palabra-correcta-bg);
    color: var(--palabra-texto);
}

.casilla-grilla.presente {
    background-color: var(--palabra-presente-bg);
    border-color: var(--palabra-presente-bg);
    color: var(--palabra-texto);
}

.casilla-grilla.ausente {
    background-color: var(--palabra-ausente-bg);
    border-color: var(--palabra-ausente-bg);
    color: var(--palabra-texto);
}

.palabra-teclado {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.fila-teclado {
    display: flex;
    justify-content: center;
    gap: 6px;
}

.tecla {
    font-family: inherit;
    font-weight: bold;
    border: 0;
    padding: 0;
    height: 58px;
    flex: 1;
    border-radius: 4px;
    background-color: var(--teclado-bg);
    color: var(--teclado-text);
    text-transform: uppercase;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s, transform 0.1s ease;
}
.btn-choose-topic {
    background-color: var(--inst-red);
    color: white;
    border: none;
    padding: 0.3rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.8rem;
    transition: background-color 0.2s
}
.btn-choose-topic:hover {
    background-color: var(--inst-red-hover);
}

.tecla:hover {
    background-color: #c0c3c7;
    transform: translateY(-2px);
}

.tecla.grande {
    flex: 1.5;
}

.palabra-pista {
    text-align: center;
    font-style: italic;
    color: var(--text-secondary);
    padding: 0.5rem;
    background-color: var(--bg-light-darker);
        border-radius: 4px;
}

@keyframes flip-reveal {
    0% { transform: rotateX(0deg); }
    50% { transform: rotateX(-90deg); }
    100% { transform: rotateX(0deg); }
}

.casilla-grilla.flip {
    animation-name: flip-reveal;
    animation-duration: 0.6s;
    animation-timing-function: ease-in-out;
}

/* Modal de Login */
.modal-overlay {
    position: fixed;

    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal-content {
    background-color: var(--bg-white-solid);
    padding: 2.5rem;
    border-radius: 8px;
    width: 90%;
    max-width: 400px;
    position: relative;
    animation: fadeIn 0.3s ease-out;
}

.modal-content h2 {
    margin-bottom: 0.5rem;
}

.modal-content p {
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
}

.modal-close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-secondary);
    cursor: pointer;
}

#form-login {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.login-error {
    color: var(--inst-red);
    font-size: 0.9rem;
}

.modal-switch {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.modal-switch a {
    color: var(--inst-red);
    font-weight: 600;
    text-decoration: none;
}

.signup-msg {
    font-size: 0.9rem;
}

/* Notificaciones */
#notification-container {
    position: fixed;
    top: 80px; /* Debajo de la navbar */
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.notification {
    padding: 1rem 1.5rem;
    border-radius: 6px;
    color: var(--bg-white-solid);
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: slideIn 0.3s ease-out forwards, fadeOut 0.5s ease-in-out forwards 3s;
    min-width: 250px;
    max-width: 350px;
}

.notification.success {
    background-color: var(--estado-correcto-text);
}

.notification.error {
    background-color: var(--inst-red-hover);
}

.notification.info {
    background-color: var(--text-secondary);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}

@keyframes pulse-correct {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); }
    70% { transform: scale(1.02); box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* Pantalla de Perfil */
.perfil-info-container {
    display: flex;
    align-items: center;
    gap: 2rem;
    background-color: var(--bg-light);
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.perfil-username {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-main);
}

.perfil-points {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--inst-red);
    margin-left: auto; /* Empuja los puntos a la derecha */
}

.perfil-stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.stat-card {
    background-color: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--inst-red);
}

.stat-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.modo-juego-card.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: var(--bg-light);
}
.modo-juego-card.disabled:hover {
    transform: none;
    box-shadow: none;
    border-color: var(--border-color);
}

/* Sección de Logros en Perfil */
.perfil-logros-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
}

.logro-card {
    background-color: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    width: 150px;
    text-align: center;
}

.logro-card.unlocked {
    border-color: var(--palabra-presente-bg);
}

.logro-icon {
    font-size: 3rem;
    line-height: 1;
    filter: grayscale(1);
    opacity: 0.4;
}

.logro-card.unlocked .logro-icon {
    filter: grayscale(0);
    opacity: 1;
}

.logro-nombre {
    font-weight: 700;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

/* Stats por tema (Resultados y Perfil) */
#stats-por-tema-container, #perfil-tema-stats-container {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--bg-light-darker);
}

#stats-por-tema-container h3, #perfil-tema-stats-container h3 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
    color: var(--text-main);
}

.stats-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.stat-item {
    background-color: var(--bg-light);
    padding: 0.75rem 1rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.stat-item-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background-color: var(--bg-light-darker);
    border-radius: 99px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background-color: var(--inst-red);
    border-radius: 99px;
    transition: width 0.5s ease-in-out;
}

/* --- Responsive Design for Mobile Devices --- */
@media (max-width: 768px) {
    /* --- General Adjustments --- */
    body {
        font-size: 14px; /* Reduce base font size for mobile */
    }

    .pantalla-activa {
        padding: 70px 10px 20px; /* Adjust padding for smaller screens */
    }

    /* --- Navbar --- */
    .navbar {
        padding: 0 1rem;
        height: 55px;
    }

    .navbar-logo {
        height: 35px;
    }

    .navbar-title {
        font-size: 1.2rem;
    }

    .navbar-powered-by {
        display: none; /* Hide for simplicity */
    }

    #user-welcome {
        display: none; /* Hide welcome text, keep buttons */
    }

    .navbar-user-info {
        gap: 0.5rem;
    }
    
    .navbar-user-info .btn-secundario,
    .navbar-user-info .btn-logout {
        padding: 0.3rem 0.6rem;
        font-size: 0.8rem;
    }

    .navbar-timer {
        font-size: 1.1rem;
        padding: 4px 10px;
    }

    /* --- Home Screen --- */
    #pantalla-inicial {
        padding: 0;
    }

    .inicio-wrapper {
        flex-direction: column;
        padding: 70px 10px 20px;
        gap: 1.5rem;
    }

    .side-panel {
        width: 100%;
        max-width: 500px; /* Limit width on slightly larger mobile screens */
        order: 3; /* Move ranking to the bottom */
    }

    .left-panel {
        order: 2; /* Move streak below main content */
    }

    .inicio-container {
        padding: 2rem 1.5rem;
        order: 1; /* Main content on top */
    }

    .inicio-logo {
        height: 80px;
    }

    .inicio-titulo-main {
        font-size: 2.2rem;
    }

    .inicio-subtitulo {
        font-size: 1rem;
        margin-bottom: 2rem;
    }

    .modo-juego-container {
        flex-direction: column;
        gap: 1rem;
    }

    .modo-juego-card {
        width: 100%;
    }

    /* --- Simulador & Resultados --- */
    .simulador-container {
        padding: 1.5rem;
        gap: 1rem;
    }

    .header-simulador {
        flex-wrap: wrap; /* Allow header items to wrap */
        gap: 0.5rem;
        padding-bottom: 0.75rem;
        margin-bottom: 0.5rem;
    }

    .header-titulo {
        font-size: 1.1rem;
    }

    .vineta-clinica {
        font-size: 1rem;
    }

    .btn-opcion {
        padding: 0.8rem;
        font-size: 0.9rem;
    }

    .controles {
        flex-direction: column;
        gap: 0.75rem;
    }

    .btn-siguiente, .btn-secundario {
        width: 100%;
        text-align: center;
        display: block; /* Ensure they are visible and take full width */
    }

    .lista-revision summary {
        font-size: 0.9rem;
    }

    /* --- Palabra del Día --- */
    .palabra-container {
        padding: 1.5rem;
        gap: 1.5rem;
        margin-top: 55px;
    }

    .casilla-grilla {
        font-size: 1.5rem;
    }

    .tecla {
        height: 48px;
        font-size: 0.8rem;
    }

    /* --- Modals --- */
    .modal-content {
        padding: 2rem 1.5rem;
        width: 95%;
    }

    /* --- Perfil --- */
    .perfil-info-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .perfil-username {
        font-size: 1.5rem;
    }

    .perfil-points {
        font-size: 1.1rem;
        margin-left: 0;
    }

    .perfil-stats-container {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .stat-label {
        font-size: 0.8rem;
    }
}
.legal-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--bg-trama-dark-1);
    color: var(--inst-black-light-4);
    background: var(--bg-light);
    color: var(--text-secondary);
    text-align: center;
    padding: 8px 15px;
    font-size: 0.55em;
    font-family: monospace;
    border-top: 1px solid var(--inst-white-dark-3);
    z-index: 9999;
    border-top: 1px solid var(--border-color);
    box-sizing: border-box;
    flex-shrink: 0; /* Evita que el footer se encoja si el contenido es muy grande */
}

.legal-footer p {
    margin: 3px 0;
    line-height: 1;
}


/* --- Crucigrama Médico --- */
.crucigrama-wrapper {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

.crucigrama-grilla {
    display: grid;
    gap: 4px;
    background-color: var(--border-color);
    border: 4px solid var(--border-color);
    border-radius: 6px;
    flex-shrink: 0;
    touch-action: none; /* Evita scroll en móvil al arrastrar */
}

.crucigrama-grilla.completed {
    opacity: 0.7;
    pointer-events: none;
}

.crucigrama-cell {
    width: 60px;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    font-weight: 700;
    text-transform: uppercase;
    user-select: none;
    background-color: var(--bg-light);
    color: var(--text-main);
}

.crucigrama-cell.blocked {
    background-color: var(--bg-light-darker);
    opacity: 0.5;
}

.crucigrama-cell.active {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.crucigrama-cell.active:hover {
    background-color: var(--bg-light-darker);
}

.crucigrama-cell.selected {
    background-color: var(--palabra-presente-bg);
    color: var(--palabra-texto);
    border-radius: 4px;
}

.crucigrama-cell.found {
    background-color: var(--palabra-correcta-bg);
    color: var(--palabra-texto);
    border-radius: 4px;
}

.crucigrama-cell.shake {
    animation: shake 0.6s cubic-bezier(.36,.07,.19,.97);
    background-color: var(--inst-red);
    color: var(--palabra-texto);
}

.crucigrama-pistas {
    flex-grow: 1;
}

.crucigrama-pistas h3 {
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.crucigrama-pistas ul {
    list-style: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.crucigrama-pistas li {
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: all 0.3s ease;
}

.crucigrama-pistas li.found {
    text-decoration: line-through;
    color: var(--palabra-ausente-bg);
    opacity: 0.7;
}

@media (max-width: 768px) {
    .crucigrama-wrapper {
        flex-direction: column;
    }
    .crucigrama-cell {
        width: 35px;
        height: 35px;
        font-size: 1.2rem;
    }
}