/* =========================================
   1. VARIABLES Y TEMA
   ========================================= */
:root {
    /* Colores Base */
    --primary: #1a1a1a;
    --accent: #3b82f6;
    /* Azul moderno */
    --accent-light: #e3f2fd;
    /* Fondo selección */
    --accent-hover: #2563eb;
    --bg-color: #f8f9fa;

    /* Colores del Grid */
    --grid-border: #1a1a1a;
    --cell-bg: #ffffff;
    --cell-text: #000000;
    --black-cell-bg: #222;

    /* UI General */
    --header-bg: #ffffff;
    --footer-bg: #f1f2f6;
    --border-light: #e5e7eb;
    --input-focus: #bbdefb;
    --input-bg: #ffffff;

    /* Teclado Virtual */
    --keyboard-bg: #d1d5db;
    --key-bg: #ffffff;

    /* Dimensiones Default (Escritorio) */
    --cell-size: 44px;
    --rows: 12;
    --cols: 12;
}

/* MODO OSCURO */
body.dark-mode {
    --primary: #f0f0f0;
    --bg-color: #121212;

    --grid-border: #555;
    --cell-bg: #2c2c2c;
    --cell-text: #ffffff;
    --black-cell-bg: #a0a0a0;

    --accent: #60a5fa;
    --accent-light: #1e3a8a;
    --accent-hover: #3b82f6;

    --input-focus: #1e40af;
    --header-bg: #1f2937;
    --footer-bg: #111827;
    --border-light: #374151;
    --input-bg: #2f3640;

    --keyboard-bg: #374151;
    --key-bg: #4b5563;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    margin: 0;
    color: var(--primary);
    display: flex;
    flex-direction: column;
    height: 100vh;
    /* Altura fija para que funcione como app */
    overflow: hidden;
    /* Scroll controlado internamente */
    transition: background-color 0.3s, color 0.3s;
}

/* =========================================
   2. HEADER
   ========================================= */
.main-nav {
    background: var(--header-bg);
    border-bottom: 1px solid var(--border-light);
    padding: 0 15px;
    height: 50px;
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    z-index: 100;
}

.nav-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-family: 'Merriweather', serif;
    font-weight: 900;
    font-size: 1.2rem;
    color: var(--primary);
}

.logo span {
    color: #ef4444;
}

.timers-area {
    display: flex;
    gap: 15px;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.9rem;
}

.timer-box {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: bold;
}

#countdown-timer {
    color: #ef4444;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.menu-links {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    gap: 15px;
}

.menu-links a {
    text-decoration: none;
    color: var(--primary);
    font-weight: 600;
    opacity: 0.7;
    font-size: 0.9rem;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--primary);
    opacity: 0.8;
}

/* =========================================
   3. ÁREA PRINCIPAL (Scrollable)
   ========================================= */
main {
    flex: 1;
    overflow-y: auto;
    /* El scroll ocurre aquí, no en todo el body */
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding-bottom: 240px;
    /* Espacio reservado para el teclado virtual */
}

/* Barra de Controles */
.game-controls-bar {
    background: var(--header-bg);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 8px 15px;
    margin-bottom: 15px;
    display: flex;
    justify-content: center;
    gap: 20px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    width: 100%;
    max-width: 800px;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.label {
    font-size: 0.75rem;
    font-weight: bold;
    opacity: 0.6;
}

.code-display {
    font-family: 'Roboto Mono';
    font-size: 1.1rem;
    color: var(--accent);
    cursor: pointer;
    letter-spacing: 1px;
}

/* Input Unirse */
.join-wrapper {
    display: flex;
    gap: 5px;
}

#input-join-code {
    width: 60px;
    padding: 4px;
    text-align: center;
    text-transform: uppercase;
    font-family: 'Roboto Mono';
    border: 1px solid var(--border-light);
    border-radius: 4px;
    background: var(--input-bg);
    color: var(--primary);
}

.icon-btn-small {
    background: var(--primary);
    color: var(--bg-color);
    border: none;
    border-radius: 4px;
    width: 70px;
    height: 30px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Botón Comprobar */
.check-dropdown {
    position: relative;
}

.action-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}

.dropdown-content {
    position: absolute;
    top: 110%;
    right: 0;
    background: var(--header-bg);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    min-width: 130px;
    z-index: 100;
}

.dropdown-content.hidden {
    display: none;
}

.dropdown-content button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border-light);
    color: var(--primary);
    cursor: pointer;
}

/* =========================================
   4. GRID Y CELDAS
   ========================================= */
.date-display {
    font-family: 'Roboto Mono';
    font-size: 0.85rem;
    opacity: 0.5;
    margin-bottom: 10px;
}

.crossword-layout {
    display: flex;
    gap: 30px;
    justify-content: center;
    width: 100%;
    align-items: flex-start;
}

.grid-wrapper {
    background: var(--cell-bg);
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.crossword-grid {
    display: grid;
    grid-template-columns: repeat(var(--cols), var(--cell-size));
    grid-template-rows: repeat(var(--rows), var(--cell-size));
    gap: 1px;
    background-color: var(--grid-border);
    border: 2px solid var(--grid-border);
}

.cell {
    background-color: var(--cell-bg);
    width: var(--cell-size);
    height: var(--cell-size);
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.cell.black {
    background-color: var(--black-cell-bg);
}

.cell input {
    width: 100%;
    height: 100%;
    border: none;
    text-align: center;
    font-size: calc(var(--cell-size) * 0.6);
    /* Fuente escala con la celda */
    font-weight: 700;
    text-transform: uppercase;
    background: transparent;
    color: var(--cell-text);
    outline: none;
    padding: 0;
    margin: 0;
    cursor: default;
    z-index: 5;
    caret-color: transparent;
    /* Ocultar cursor nativo */
}

.cell-number {
    position: absolute;
    top: 1px;
    left: 2px;
    font-size: calc(var(--cell-size) * 0.25);
    color: var(--primary);
    opacity: 0.7;
    pointer-events: none;
    z-index: 10;
}

/* Estados de selección */
.active-cell {
    background-color: var(--input-focus) !important;
}

.active-word {
    background-color: var(--accent-light) !important;
}

.cell input:focus {
    background-color: var(--input-focus);
}

/* Correcciones */
.correct-mark input {
    color: #16a34a;
    background-color: rgba(22, 163, 74, 0.1);
}

.wrong-mark input {
    color: #dc2626;
    background-color: rgba(220, 38, 38, 0.1);
}

/* =========================================
   5. PISTAS Y BARRA MÓVIL
   ========================================= */
/* Panel de escritorio */
.clues-panel {
    width: 350px;
    height: 550px;
    background: var(--cell-bg);
    border-radius: 8px;
    border: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
}

.clues-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-light);
}

.tab-btn {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--primary);
    opacity: 0.6;
    font-weight: bold;
}

.tab-btn.active {
    opacity: 1;
    color: var(--accent);
    border-bottom: 3px solid var(--accent);
}

.clues-content {
    flex: 1;
    overflow-y: auto;
}

.clue-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.clue-item {
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    font-size: 0.9rem;
}

.clue-item.highlighted {
    background-color: var(--accent-light);
    border-left: 4px solid var(--accent);
}

.clue-number {
    font-weight: bold;
    color: var(--accent);
    margin-right: 8px;
}

/* Barra de Pista Actual (Móvil - Estilo El País) */
#current-clue-bar {
    display: none;
    /* Se activa en media query */
    width: 100%;
    background: var(--accent);
    color: white;
    padding: 12px 15px;
    border-radius: 6px;
    text-align: center;
    font-weight: 600;
    font-size: 0.95rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-top: 15px;
    min-height: 50px;
    align-items: center;
    justify-content: center;
}

/* =========================================
   6. TECLADO VIRTUAL
   ========================================= */
#virtual-keyboard {
    display: none;
    /* Se activa en media query */
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: var(--keyboard-bg);
    padding: 6px;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
    z-index: 1000;
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.2);
    user-select: none;
}

.kb-row {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-bottom: 6px;
}

.kb-key {
    background: var(--key-bg);
    color: var(--primary);
    border: none;
    border-radius: 5px;
    height: 44px;
    flex: 1;
    max-width: 42px;
    /* Teclas más anchas */
    font-weight: bold;
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

.kb-key:active {
    transform: translateY(1px);
    box-shadow: none;
    opacity: 0.8;
}

.kb-key.wide {
    flex: 1.5;
    max-width: 65px;
    background: #9ca3af;
    color: white;
    font-size: 1rem;
}

/* =========================================
   7. FOOTER Y MODAL
   ========================================= */
.footer-mini {
    background: var(--footer-bg);
    padding: 10px;
    text-align: center;
    font-size: 0.8rem;
    color: #888;
    border-top: 1px solid var(--border-light);
    margin-top: auto;
}

.footer-content {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.footer-mini a {
    color: #666;
    text-decoration: none;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-dot.connected {
    background: #2ecc71;
    box-shadow: 0 0 4px #2ecc71;
}

.status-dot.disconnected {
    background: #ef4444;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal-overlay.hidden {
    display: none;
}

.modal-content {
    background: var(--header-bg);
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    color: var(--primary);
}

/* =========================================
   8. MEDIA QUERIES (RESPONSIVE TOTAL)
   ========================================= */
@media (max-width: 768px) {
    :root {
        /* Cálculo dinámico: Ancho pantalla - margen (20px) / Columnas */
        --cell-size: calc((100vw - 20px) / var(--cols));
    }

    /* Layout vertical */
    .crossword-layout {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }

    /* Grid ocupa todo el ancho posible */
    .grid-wrapper {
        padding: 0;
        background: transparent;
        box-shadow: none;
    }

    /* Ocultar panel de pistas lateral */
    .clues-panel {
        display: none;
    }

    /* Mostrar barra azul y teclado */
    #current-clue-bar {
        display: flex;
    }

    #virtual-keyboard {
        display: block;
    }

    /* Ajuste de main para que el teclado no tape el contenido */
    main {
        padding-bottom: 230px;
        /* Altura aprox teclado + barra */
        padding-top: 10px;
    }

    /* Simplificar Header */
    .nav-right {
        display: none;
    }

    .logo {
        font-size: 1rem;
    }

    /* Simplificar controles */
    .game-controls-bar {
        justify-content: space-between;
        padding: 5px;
        background: transparent;
        border: none;
        box-shadow: none;
    }
}

/* =========================================
   8. OCULTAR BARRA DE SCROLL (Estética App)
   ========================================= */

/* Para Chrome, Safari y Opera */
main::-webkit-scrollbar {
    display: none;
}

/* Para Firefox, IE y Edge */
main {
    -ms-overflow-style: none;
    /* IE y Edge */
    scrollbar-width: none;
    /* Firefox */
}

/* =========================================
   9. SECCIÓN MÁS JUEGOS
   ========================================= */
.more-games-container {
    width: 100%;
    max-width: 800px;
    margin: 40px auto 20px;
    padding: 0 10px;
}

.section-title {
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.1rem;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.7;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 10px;
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 15px;
}

.game-card {
    display: flex;
    align-items: center;
    background-color: var(--cell-bg);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: 15px;
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.game-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    border-color: var(--accent);
}

.game-icon {
    font-size: 2rem;
    margin-right: 15px;
}

.game-info h4 {
    margin: 0;
    font-size: 1rem;
    color: var(--primary);
}

.game-info p {
    margin: 3px 0 0 0;
    font-size: 0.8rem;
    color: #777;
}

/* Añadir en styles/game.css */

.clue-completed {
    text-decoration: line-through;
    opacity: 0.5;
    color: #888;
    transition: opacity 0.3s;
}

/* styles/game.css */

body {
    overflow-y: auto;
    /* Permitir scroll vertical siempre */
    overflow-x: hidden;
    /* Evitar scroll horizontal indeseado */
}

/* Ajuste para el texto SEO que añadimos */
.seo-content {
    width: 100%;
    max-width: 800px;
    margin: 20px auto;
    padding: 20px;
    background: rgba(255, 255, 255, 0.5);
    /* Fondo semitransparente sutil */
    border-radius: 12px;
}