/* ==========================================================================
   juegos/assets/css/sopa.css
   Estilos extraídos y modularizados para la Sopa de Letras
   ========================================================================== */

.game-header {
    text-align: center;
    padding: 40px 20px 20px;
    position: relative;
    z-index: 2;
}

.game-header h1 {
    font-size: 2.8rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 10px;
    letter-spacing: -1px;
}

.game-header p {
    color: var(--text-muted);
    font-size: 1.1rem;
    max-width: 600px;
    margin: 0 auto;
}

.game-container {
    max-width: 850px;
    margin: 20px auto 60px;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: 30px;
    padding: 25px;
    /* Sombra neutra/base */
    box-shadow: var(--glass-shine), 0 20px 40px rgba(0, 0, 0, 0.15);
    transition: box-shadow 0.3s, border-color 0.3s;
}

[data-theme="dark"] .game-container {
    box-shadow: var(--glass-shine), 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 30px rgba(0, 0, 0, 0.2);
    /* Borde inferior del color del nivel activo (inyectado via CSS variable) */
    border-bottom: 2px solid var(--theme-color, #AF52DE);
}

/* Selector de Dificultad */
.level-selector {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-bottom: 25px;
}

.level-btn {
    padding: 10px 20px;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-main);
    background: var(--bg-main);
    border: 2px solid var(--glass-border);
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.level-btn:hover {
    transform: translateY(-2px);
}

.level-btn.active {
    color: white;
    border-color: transparent;
}

.level-btn.facil.active { background: #34C759; box-shadow: 0 8px 20px rgba(52, 199, 89, 0.4); }
.level-btn.medio.active { background: #0A84FF; box-shadow: 0 8px 20px rgba(10, 132, 255, 0.4); }
.level-btn.dificil.active { background: #FF9500; box-shadow: 0 8px 20px rgba(255, 149, 0, 0.4); }
.level-btn.muy_dificil.active { background: #FF3B30; box-shadow: 0 8px 20px rgba(255, 59, 48, 0.4); }
.level-btn.caxcan.active { background: linear-gradient(135deg, #AF52DE, #5856D6); box-shadow: 0 8px 20px rgba(175, 82, 222, 0.4); }

.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px; 
    padding: 10px 20px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 15px;
    border: 1px solid var(--glass-border);
    visibility: hidden;
    flex-wrap: wrap;
    gap: 10px;
}

[data-theme="dark"] .status-bar {
    background: rgba(255, 255, 255, 0.05);
}

.status-item {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-item span {
    color: var(--theme-color, #AF52DE);
}

.timer-danger {
    color: #FF3B30 !important;
    animation: pulseTimer 0.5s infinite alternate;
}

@keyframes pulseTimer {
    0% { transform: scale(1); }
    100% { transform: scale(1.15); }
}

/* BARRA DE TIEMPO VISUAL */
.time-bar-container {
    width: 100%;
    height: 12px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    margin-bottom: 20px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
    display: none;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.05);
}

[data-theme="dark"] .time-bar-container {
    background: rgba(255, 255, 255, 0.1);
}

.time-bar-fill {
    height: 100%;
    width: 100%;
    background: var(--theme-color, #AF52DE);
    transition: width 1s linear, background-color 0.3s ease;
}

.game-wrapper {
    position: relative;
    border-radius: 15px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    min-height: 450px;
}

/* CUADRÍCULA DE LETRAS DINÁMICA */
#word-grid {
    display: grid;
    grid-template-columns: repeat(var(--grid-size), 1fr);
    gap: 2px;
    width: 100%;
    max-width: 500px;
    aspect-ratio: 1 / 1;
    background: rgba(0, 0, 0, 0.05);
    border: 2px solid var(--glass-border);
    border-radius: 15px;
    padding: 5px;
    filter: blur(8px);
    pointer-events: none;
    transition: filter 0.5s ease;
    box-shadow: inset 0 5px 15px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] #word-grid {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

.letter-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(0.7rem, 4vw, 1.2rem);
    font-weight: 700;
    color: var(--text-main);
    background: var(--glass-bg);
    border-radius: 6px;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.letter-cell:active {
    transform: scale(0.9);
}

.letter-cell.selected {
    background: var(--theme-color, #AF52DE);
    color: white;
    box-shadow: 0 0 10px var(--theme-color, #AF52DE);
    transform: scale(1.1);
    z-index: 2;
}

.letter-cell.found {
    background: #34C759;
    color: white;
    box-shadow: 0 0 10px rgba(52, 199, 89, 0.5);
    animation: popFound 0.4s ease-out;
}

@keyframes popFound {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); background: #FFD700; }
    100% { transform: scale(1); }
}

/* LISTA DE PALABRAS MÁS VISIBLE */
.word-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin-top: 25px;
    width: 100%;
    max-width: 600px;
    visibility: hidden;
}

.word-item {
    padding: 8px 18px;
    background: rgba(255, 255, 255, 0.8);
    border: 2px solid var(--theme-color, #AF52DE);
    border-radius: 50px;
    font-weight: 800;
    color: var(--text-main);
    font-size: 1.1rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .word-item {
    background: rgba(0, 0, 0, 0.6);
    color: #ffffff;
}

.word-item.found {
    text-decoration: line-through;
    background: #34C759;
    color: white;
    border-color: #34C759;
    box-shadow: 0 4px 10px rgba(52, 199, 89, 0.4);
    opacity: 0.8;
    transform: scale(0.95);
}

/* Overlays (Menús) */
.game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    z-index: 10;
    text-align: center;
    padding: 20px;
    border-radius: 15px;
}

[data-theme="dark"] .game-overlay {
    background: rgba(20, 25, 38, 0.9);
}

.game-overlay h2 {
    font-size: 2.5rem;
    color: var(--theme-color, #AF52DE);
    margin-bottom: 10px;
    font-weight: 800;
}

.btn-game {
    background: var(--theme-color, #AF52DE);
    color: white;
    border: none;
    padding: 14px 40px;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    transition: all 0.3s;
    margin-top: 20px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-game:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.3);
}

.btn-volver-juegos {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s;
    padding: 10px 20px;
}

.btn-volver-juegos:hover {
    color: var(--primary);
}

/* Modal Top 3 */
.modal-top3-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-top3-content {
    background: var(--bg-main);
    border: 1px solid var(--glass-border);
    border-radius: 25px;
    width: 100%;
    max-width: 450px;
    padding: 30px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    position: relative;
    animation: popIn 0.3s ease;
    text-align: center;
}

@keyframes popIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.btn-cerrar-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
}

.btn-cerrar-modal:hover {
    color: #FF3B30;
}

.modal-top3-icon {
    font-size: 4rem;
    margin-bottom: 15px;
    filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.2));
    color: #FFD700;
}

.modal-top3-title {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 5px;
}

.ranking-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
    text-align: left;
}

.ranking-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 15px;
}

.ranking-item .rank-pos {
    font-size: 1.5rem;
    font-weight: 800;
    width: 30px;
}

.ranking-item.pos-1 { border-color: #FFD700; background: rgba(255, 215, 0, 0.1); }
.ranking-item.pos-1 .rank-pos { color: #FFD700; }
.ranking-item.pos-2 { border-color: #C0C0C0; background: rgba(192, 192, 192, 0.1); }
.ranking-item.pos-2 .rank-pos { color: #C0C0C0; }
.ranking-item.pos-3 { border-color: #CD7F32; background: rgba(205, 127, 50, 0.1); }
.ranking-item.pos-3 .rank-pos { color: #CD7F32; }

.rank-info {
    flex-grow: 1;
    padding-left: 15px;
}

.rank-name {
    font-weight: 700;
    color: var(--text-main);
    font-size: 1.1rem;
}

.rank-score {
    font-weight: 900;
    font-size: 1.2rem;
    color: var(--text-main);
}

@media (max-width: 768px) {
    .game-header h1 { font-size: 2.2rem; }
    .game-container { padding: 15px; margin: 10px 15px 40px; }
    .status-bar { justify-content: center; }
    .letter-cell { font-size: clamp(0.6rem, 3.5vw, 1.1rem); }
}