/* ==========================================================================
   VARIABLES GLOBALES Y TEMA ACCESIBLE PARA PERSONAS MAYORES
   ========================================================================== */
:root {
    /* Paleta de Colores de Alto Contraste */
    --color-primary: #0d47a1;         /* Azul oscuro profundo */
    --color-primary-hover: #002171;   /* Azul aún más oscuro */
    --color-secondary: #37474f;       /* Gris pizarra oscuro */
    --color-secondary-hover: #263238;
    --color-accent: #2e7d32;          /* Verde positivo accesible */
    --color-accent-hover: #1b5e20;
    --color-background: #f4f6f8;      /* Fondo suave muy claro */
    --color-surface: #ffffff;         /* Superficie blanca */
    --color-text: #1a1a1a;            /* Texto casi negro para máximo contraste */
    --color-text-muted: #424242;      /* Gris para texto secundario */
    --color-border: #cfd8dc;          /* Borde claro */
    --color-error: #c62828;           /* Rojo claro de error */
    --color-error-bg: #ffebee;
    --color-success-bg: #e8f5e9;

    /* Tipografía Legible y Generosa */
    --font-family-base: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    --font-size-base: 1.25rem;       /* 20px base */
    --line-height-base: 1.6;

    /* Sombras y Espaciado */
    --radius-lg: 16px;
    --radius-md: 10px;
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-focus: 0 0 0 4px #ffb300; /* Enfoque amarillo alta visibilidad */
    
    /* Dimensiones de Botones para Facilidad Táctil */
    --btn-min-height: 56px;
}

/* ==========================================================================
   RESET BÁSICO Y ESTILOS BASE
   ========================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family-base);
    font-size: var(--font-size-base);
    line-height: var(--line-height-base);
    background-color: var(--color-background);
    color: var(--color-text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Accesibilidad: Enlace directo al contenido */
.skip-link {
    position: absolute;
    top: -100px;
    left: 10px;
    background: #000000;
    color: #ffffff;
    padding: 12px 20px;
    z-index: 1000;
    border-radius: var(--radius-md);
    text-decoration: none;
    font-weight: bold;
}
.skip-link:focus {
    top: 10px;
}

/* Enfoque accesible visible */
:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
}

/* Layout Contenedor */
.container {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ==========================================================================
   ENCABEZADO Y NAVEGACIÓN
   ========================================================================== */
.main-header {
    background-color: var(--color-primary);
    color: #ffffff;
    padding: 16px 0;
    box-shadow: var(--shadow-md);
}

.header-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

@media (min-width: 640px) {
    .header-container {
        flex-direction: row;
        justify-content: space-between;
    }
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 2.5rem;
}

.brand-title {
    display: block;
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1.1;
}

.brand-tagline {
    display: block;
    font-size: 0.95rem;
    opacity: 0.9;
}

.main-nav ul {
    display: flex;
    list-style: none;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.nav-btn {
    background: transparent;
    border: 2px solid transparent;
    color: #ffffff;
    padding: 10px 16px;
    font-size: 1.1rem;
    font-weight: bold;
    border-radius: var(--radius-md);
    cursor: pointer;
    min-height: 48px;
}

.nav-btn:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

.nav-btn.active {
    background-color: #ffffff;
    color: var(--color-primary);
}

/* ==========================================================================
   COMPONENTES TARJETA Y BOTONES ACCESIBLES
   ========================================================================== */
main {
    flex: 1;
    padding-top: 24px;
    padding-bottom: 40px;
}

.card {
    background-color: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--color-border);
    margin-bottom: 24px;
}

h1 {
    font-size: 1.9rem;
    color: var(--color-primary);
    margin-bottom: 12px;
    line-height: 1.25;
}

h2 {
    font-size: 1.5rem;
    color: var(--color-secondary);
    margin-top: 24px;
    margin-bottom: 16px;
}

.lead-text {
    font-size: 1.25rem;
    color: var(--color-text-muted);
    margin-bottom: 20px;
}

/* Botones amplios */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    text-decoration: none;
    padding: 12px 24px;
    min-height: var(--btn-min-height);
    transition: background-color 0.15s ease-in-out, transform 0.1s ease;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background-color: var(--color-primary);
    color: #ffffff;
}
.btn-primary:hover {
    background-color: var(--color-primary-hover);
}

.btn-secondary {
    background-color: var(--color-secondary);
    color: #ffffff;
}
.btn-secondary:hover {
    background-color: var(--color-secondary-hover);
}

.btn-danger {
    background-color: var(--color-error);
    color: #ffffff;
}
.btn-danger:hover {
    background-color: #b71c1c;
}

.btn-xl {
    font-size: 1.35rem;
    padding: 16px 32px;
    min-height: 64px;
}

.btn-block {
    width: 100%;
}

.btn-actions {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 24px;
}

/* ==========================================================================
   ESTILOS DE VISTAS Y SECCIONES
   ========================================================================== */
.view-section {
    display: none;
}
.view-section.active {
    display: block;
}

/* Banner Actividad del Día */
.daily-banner {
    background-color: #e3f2fd;
    border: 2px solid #90caf9;
    border-radius: var(--radius-md);
    padding: 20px;
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: flex-start;
}

@media (min-width: 640px) {
    .daily-banner {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

/* Grid de Estadísticas Rápidas */
.quick-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-md);
}

.stat-icon {
    font-size: 2.2rem;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--color-primary);
}

.stat-label {
    font-size: 1rem;
    color: var(--color-text-muted);
}

/* Grid de Categorías */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
}

.category-card {
    background-color: var(--color-surface);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-family: inherit;
    min-height: 100px;
}

.category-card:hover {
    border-color: var(--color-primary);
    background-color: #f0f7ff;
}

.cat-icon { font-size: 2rem; }
.cat-name { font-size: 1.1rem; font-weight: bold; color: var(--color-text); }

/* Formulario de Selección */
.form-group {
    margin-bottom: 24px;
}

.form-label {
    display: block;
    font-size: 1.3rem;
    font-weight: bold;
    margin-bottom: 8px;
}

.form-control {
    width: 100%;
    font-size: 1.2rem;
    padding: 12px 16px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    background-color: #ffffff;
    min-height: 52px;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.radio-card {
    display: flex;
    align-items: center;
    padding: 14px 18px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    min-height: 56px;
}

.radio-card:hover {
    background-color: #f5f5f5;
}

.radio-card input[type="radio"] {
    width: 24px;
    height: 24px;
    margin-right: 12px;
}

/* PANTALLA DE CARGA Y SPINNER */
.loading-card {
    padding: 60px 20px;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 6px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 24px auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* JUEGO Y ACTIVIDAD */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}

.badge {
    background-color: var(--color-primary);
    color: #ffffff;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 1rem;
    font-weight: bold;
}

.badge-outline {
    background-color: transparent;
    color: var(--color-secondary);
    border: 2px solid var(--color-secondary);
}

.instructions-box {
    background-color: #eef2f5;
    padding: 16px 20px;
    border-radius: var(--radius-md);
    border-left: 6px solid var(--color-primary);
    margin-bottom: 24px;
    font-size: 1.25rem;
}

.memorize-box {
    background-color: #fffde7;
    border: 2px solid #fff59d;
    padding: 24px;
    border-radius: var(--radius-md);
    margin-bottom: 24px;
}

.content-display-area {
    margin: 24px 0;
    font-size: 1.5rem;
    text-align: center;
}

.words-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    list-style: none;
}

.word-chip {
    background-color: #ffffff;
    border: 2px solid var(--color-primary);
    color: var(--color-primary);
    font-size: 1.4rem;
    font-weight: bold;
    padding: 10px 20px;
    border-radius: 30px;
}

/* Opciones de Pregunta */
.options-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    margin-top: 20px;
}

@media (min-width: 640px) {
    .options-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.option-btn {
    background-color: #ffffff;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--color-text);
    text-align: left;
    cursor: pointer;
    min-height: 60px;
    display: flex;
    align-items: center;
}

.option-btn:hover {
    background-color: #e3f2fd;
    border-color: var(--color-primary);
}

.option-btn.selected-correct {
    background-color: var(--color-success-bg);
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.option-btn.selected-incorrect {
    background-color: var(--color-error-bg);
    border-color: var(--color-error);
    color: var(--color-error);
}

/* Feedback emergente */
.feedback-box {
    margin-top: 24px;
    padding: 20px;
    border-radius: var(--radius-md);
    background-color: #f5f5f5;
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: flex-start;
}

.feedback-text {
    font-size: 1.3rem;
    font-weight: bold;
}

/* PANTALLA DE RESULTADOS */
.score-display {
    margin: 20px 0;
}

.score-number {
    font-size: 4rem;
    font-weight: 900;
    color: var(--color-primary);
    display: block;
    line-height: 1;
}

.score-max {
    font-size: 1.2rem;
    color: var(--color-text-muted);
}

.result-badge {
    display: inline-block;
    background-color: var(--color-accent);
    color: #ffffff;
    padding: 10px 24px;
    border-radius: 30px;
    font-size: 1.3rem;
    font-weight: bold;
    margin-bottom: 20px;
}

.streak-banner {
    background-color: #fff3e0;
    border: 2px solid #ffe0b2;
    padding: 16px;
    border-radius: var(--radius-md);
    font-size: 1.25rem;
    margin: 20px 0;
}

/* ESTADÍSTICAS */
.stats-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
    margin-bottom: 30px;
}

.stat-big-card {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-big-icon { font-size: 2.8rem; }
.stat-big-number { display: block; font-size: 1.8rem; font-weight: bold; color: var(--color-primary); }
.stat-big-label { font-size: 1rem; color: var(--color-text-muted); }

/* TABLA ACCESIBLE */
.table-responsive {
    overflow-x: auto;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
    font-size: 1.1rem;
}

.history-table th, .history-table td {
    padding: 14px;
    border-bottom: 1px solid var(--color-border);
    text-align: left;
}

.history-table th {
    background-color: #e0e0e0;
    color: var(--color-text);
}

/* FAQ */
.faq-item {
    margin-bottom: 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    background-color: #ffffff;
}

.faq-item summary {
    font-size: 1.25rem;
    font-weight: bold;
    cursor: pointer;
    padding: 8px 0;
}

.faq-item p {
    margin-top: 12px;
    font-size: 1.15rem;
    color: var(--color-text-muted);
}

.data-management-block {
    margin-top: 40px;
    padding-top: 24px;
    border-top: 2px solid var(--color-border);
}

/* FOOTER */
.main-footer {
    background-color: var(--color-secondary);
    color: #ffffff;
    padding: 24px 0;
    text-align: center;
    font-size: 1rem;
    margin-top: auto;
}

.footer-disclaimer {
    font-size: 0.9rem;
    opacity: 0.8;
    margin-top: 8px;
}

/* UTILIDADES */
.text-center { text-align: center; }
.flex-center { justify-content: center; }