/* =========================================================
   LETRATROS CSS - VERSIÓN FINAL UNIFICADA (GLASSMORPHISM)
   ========================================================= */

* {
    box-sizing: border-box;
}

/* 1. CONTENEDOR PRINCIPAL */
.lt-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 30px 15px;
    min-height: calc(100vh - 120px);
    font-family: 'Inter', sans-serif;
    background: transparent !important;
    /* Deja ver el bosque */
}

.lt-game-container {
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    gap: 15px;

    /* Efecto Cristal */
    background: rgba(255, 255, 255, 0.05) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3) !important;
    border-radius: 16px;
    padding: 20px;
}

/* ESCRITORIO */
@media (min-width: 900px) {
    .lt-game-container {
        max-width: 1000px;
        flex-direction: row;
        align-items: flex-start;
        gap: 40px;
    }

    .lt-col-board {
        flex: 1;
        max-width: 500px;
        position: relative;
    }

    .lt-col-controls {
        flex: 1;
        max-width: 450px;
        display: flex;
        flex-direction: column;
        gap: 20px;
        position: relative;
    }
}

.lt-col-board {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* 2. MARCADORES */
.lt-scoreboard {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.lt-score-box,
.lt-reroll-box,
.lt-level-box {
    flex: 1;
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: #cbd5e1 !important;
    padding: 10px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.9rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.lt-score-val,
.lt-reroll-val,
.lt-level-val {
    font-size: 1.5rem;
    font-weight: 800;
    margin-top: 5px;
    color: #fff !important;
}

/* 3. TABLERO (ESTILO SUDOKU) */
.lt-board-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: repeat(7, 1fr);
    gap: 5px;
    width: 100%;
    max-width: 500px;
    aspect-ratio: 1;
    /* Cuadrado perfecto */
    margin: 0 auto;

    /* Fondo oscuro para que resalten las líneas */
    background: rgba(0, 0, 0, 0.5) !important;
    border: 2px solid rgba(255, 255, 255, 0.2) !important;
    padding: 5px;
    border-radius: 8px;
}

/* Casillas Blancas */
.lt-cell {
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95) !important;
    border: 1px solid #94a3b8 !important;
    /* Borde gris */
    color: #0f172a !important;
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

/* EL FIX DEFINITIVO: Casilla Activa conectada a tu JS (.active-input) */
.lt-cell.active-input {
    background: #e0f2fe !important;
    border: 3px solid #3b82f6 !important;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.6) !important;
    transform: scale(1.05) !important;
    z-index: 10 !important;
}

/* 4. FICHAS (LAS LETRAS) */
.lt-tile {
    width: 90%;
    height: 90%;
    background: rgba(255, 255, 255, 0.95) !important;
    color: #0f172a !important;
    border: 1px solid #94a3b8 !important;
    border-radius: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 700;
    font-size: 1.2rem;
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.1);
    position: relative;
    user-select: none;
}

.lt-tile.rare {
    background: #ffe3e3 !important;
    border-color: #ffa8a8 !important;
    color: #c92a2a !important;
}

.lt-tile-points {
    position: absolute;
    bottom: 2px;
    right: 3px;
    font-size: 0.6rem;
    font-weight: 600;
    color: #868e96;
}

.lt-cell.locked .lt-tile {
    background: #e9ecef !important;
    border-color: #dee2e6 !important;
    color: #868e96 !important;
    box-shadow: none;
}

.lt-cell.temp .lt-tile {
    border-color: #3b82f6 !important;
    transform: scale(1.05);
}

/* 5. ZONA DE LA MANO Y TECLADO */
.lt-hand-area {
    background: rgba(255, 255, 255, 0.05) !important;
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    padding: 10px;
    border-radius: 10px;
}

.lt-hand-grid {
    display: flex;
    justify-content: center;
    gap: 5px;
    height: 50px;
}

.lt-hand-slot {
    width: 11%;
    aspect-ratio: 1;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: transform 0.1s;
}

.lt-hand-slot.selected .lt-tile {
    transform: translateY(-8px);
    border-color: #3b82f6 !important;
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.2);
}

.lt-hand-slot.reroll-select .lt-tile {
    opacity: 0.6;
    border-color: #f59f00 !important;
}

/* Teclado Virtual */
.keyboard {
    width: 100%;
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    user-select: none;
}

.kb-row {
    display: flex;
    justify-content: center;
    gap: 4px;
    width: 100%;
}

.kb-key {
    flex: 1;
    background: rgba(255, 255, 255, 0.1) !important;
    color: #fff !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: 4px;
    height: 45px;
    font-weight: 700;
    font-size: 0.95rem;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    touch-action: manipulation;
}

.kb-key:active {
    background: rgba(255, 255, 255, 0.3) !important;
}

.kb-key.key-big {
    flex: 1.5;
    font-size: 0.8rem;
}

.kb-key.has-letter {
    background: rgba(255, 255, 255, 0.9) !important;
    color: #0f172a !important;
    border-color: #aaa !important;
    position: relative;
}

.kb-key.has-letter::after {
    content: '';
    position: absolute;
    bottom: 4px;
    width: 5px;
    height: 5px;
    background-color: #3b82f6;
    border-radius: 50%;
}

/* 6. BOTONES GENERALES */
.lt-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.lt-btn {
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s;
    font-size: 0.9rem;
}

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

.lt-btn-primary {
    background: var(--primary, #3b82f6) !important;
    color: white !important;
}

.lt-btn-warning {
    background: #f59f00 !important;
    color: #fff !important;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}

.lt-btn-secondary {
    background: rgba(255, 255, 255, 0.1) !important;
    color: #fff !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
}

/* 7. MENSAJES Y MODALES */
.lt-instructions,
.section-title {
    color: #f1f5f9 !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    text-align: center;
    margin-top: 10px;
}

.lt-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(51, 51, 51, 0.95);
    color: white;
    padding: 15px 25px;
    border-radius: 8px;
    text-align: center;
    font-size: 1rem;
    font-weight: 600;
    z-index: 100;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    width: max-content;
    pointer-events: none;
}

.lt-message.error {
    background-color: rgba(201, 42, 42, 0.95);
}

.lt-message.success {
    background-color: rgba(43, 138, 62, 0.95);
}

.lt-message.info {
    background-color: rgba(25, 113, 194, 0.95);
}

.lt-message.levelup {
    background-color: #7048e8;
    box-shadow: 0 0 20px rgba(132, 94, 247, 0.6);
    font-size: 1.2rem;
}

.hidden {
    display: none !important;
}

.lt-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.lt-modal-content {
    background: rgba(15, 23, 42, 0.95) !important;
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: white !important;
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    width: 90%;
    max-width: 400px;
}
#lt-modal-end {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.7); /* Fondo azulado muy oscuro */
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

/* El cuadro central del modal */
#lt-modal-end > div {
    background: rgba(255, 255, 255, 0.05) !important;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-radius: 24px;
    padding: 40px;
    text-align: center;
    max-width: 450px;
    width: 90%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    color: #f1f5f9; /* Texto base en blanco mate */
}

#lt-modal-end h2 {
    font-size: 2.2rem;
    margin-bottom: 10px;
    color: #fff;
    text-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
}

#lt-modal-end p {
    font-size: 1.2rem;
    color: #cbd5e1;
    margin-bottom: 20px;
}

/* EL NÚMERO DE LA PUNTUACIÓN (AZUL CLARITO BRILLANTE) */
#lt-final-score {
    font-size: 4rem;
    font-weight: 900;
    color: #60a5fa; /* Azul clarito premium */
    display: block;
    margin: 20px 0;
    text-shadow: 0 0 25px rgba(96, 165, 250, 0.4); /* Resplandor */
}

/* Botón de volver a jugar / cerrar */
#lt-modal-end button {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    margin-top: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#lt-modal-end button:hover {
    background: #2563eb;
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(59, 130, 246, 0.4);
}