/* ==========================================================================
   juegos/assets/css/memorama.css
   Estilos extraídos y modularizados para el Memorama Mágico
   ========================================================================== */

.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 {
    /* El max-width ahora se inyecta dinámicamente en el HTML según el nivel */
    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;
    box-shadow: var(--glass-shine), 0 20px 40px rgba(10, 132, 255, 0.15);
    transition: max-width 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(10, 132, 255, 0.15);
}

/* Selector de Dificultad (Pills) */
.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;
}

/* Colores dinámicos por nivel */
.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: 20px;
    padding: 10px 20px;
    background: rgba(10, 132, 255, 0.1);
    border-radius: 15px;
    border: 1px solid rgba(10, 132, 255, 0.3);
    visibility: hidden;
}

.status-item {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-main);
}

.status-item span {
    font-weight: 900;
}

.btn-group-status {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* Adaptación para móviles de la barra de estado */
@media (max-width: 600px) {
    .status-bar {
        flex-wrap: wrap;
        justify-content: space-around;
        gap: 15px;
        padding: 15px;
    }

    .status-item {
        font-size: 1.1rem;
    }

    .status-item:nth-child(2) {
        order: 3;
        width: 100%;
        text-align: center;
    }
}

.game-wrapper {
    position: relative;
    border-radius: 15px;
    min-height: 400px;
    overflow: hidden;
    padding: 10px;
}

/* TABLERO DE CARTAS DINÁMICO */
.memory-game {
    display: grid;
    gap: 12px;
    perspective: 1000px;
    filter: blur(8px);
    pointer-events: none;
    transition: filter 0.5s ease;
    border-radius: 15px;
}

/* Responsive Grid por Nivel */
.grid-facil,
.grid-medio,
.grid-dificil {
    grid-template-columns: repeat(4, 1fr);
}

.grid-muy_dificil,
.grid-caxcan {
    grid-template-columns: repeat(6, 1fr);
}

@media (max-width: 768px) {
    .grid-facil,
    .grid-medio {
        grid-template-columns: repeat(4, 1fr);
    }

    .grid-dificil,
    .grid-muy_dificil {
        grid-template-columns: repeat(4, 1fr);
    }

    .grid-caxcan {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .grid-facil,
    .grid-medio {
        grid-template-columns: repeat(3, 1fr);
    }
}

.memory-card {
    width: 100%;
    aspect-ratio: 3/4;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), box-shadow 0.3s;
    cursor: pointer;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.memory-card:active {
    transform: scale(0.95);
}

.memory-card.flip {
    transform: rotateY(180deg);
}

.memory-card.matched {
    animation: lucesEncendidas 1.2s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
    pointer-events: none;
}

@keyframes lucesEncendidas {
    0% {
        transform: rotateY(180deg) scale(1);
        box-shadow: 0 0 0 transparent;
    }

    40% {
        transform: rotateY(180deg) scale(1.1);
        box-shadow: 0 0 40px #FFD700, 0 0 80px #FFA500;
        border-color: #FFD700;
        z-index: 10;
    }

    100% {
        transform: rotateY(180deg) scale(1);
        box-shadow: 0 0 15px rgba(52, 199, 89, 0.8);
        border-color: rgba(52, 199, 89, 0.5);
    }
}

.flash-light {
    animation: flashBoard 0.8s ease-out;
}

@keyframes flashBoard {
    0% {
        background: transparent;
    }

    30% {
        background: rgba(255, 215, 0, 0.15);
        box-shadow: inset 0 0 50px rgba(255, 215, 0, 0.3);
    }

    100% {
        background: transparent;
    }
}

.front-face,
.back-face {
    width: 100%;
    height: 100%;
    position: absolute;
    border-radius: 12px;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--glass-border);
    overflow: hidden;
}

.front-face {
    transform: rotateY(180deg);
    background: #fff;
}

.front-face img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.back-face {
    /* El gradiente de fondo dinámico se inyecta en HTML */
    color: white;
    font-size: 2.5rem;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .back-face {
    border-color: rgba(255, 255, 255, 0.1);
}

.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;
}

[data-theme="dark"] .game-overlay {
    background: rgba(20, 25, 38, 0.9);
}

.game-overlay h2 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 800;
}

/* ==========================================================================
   Botones Globales y Específicos del Memorama
   ========================================================================== */
.btn-game {
    background: var(--primary, #0A84FF); /* Color base (fallback) */
    color: white;
    border: none;
    padding: 14px 30px;
    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: 15px;
    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-reiniciar {
    margin-top: 0;
    padding: 6px 15px;
    font-size: 0.9rem;
    background: linear-gradient(135deg, #FF3B30, #C0392B);
    box-shadow: 0 4px 10px rgba(255, 59, 48, 0.3);
}

.btn-top3 {
    margin-top: 0;
    padding: 6px 15px;
    font-size: 0.9rem;
    background: linear-gradient(135deg, #FFD700, #F39C12);
    box-shadow: 0 4px 10px rgba(243, 156, 18, 0.3);
}

.btn-guardar {
    padding: 10px 20px;
    font-size: 1rem;
    width: 100%;
    margin-top: 0;
    background: linear-gradient(135deg, #34C759, #28A745);
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.4);
}

.btn-reintentar {
    background: var(--bg-main);
    color: var(--text-main);
    border: 2px solid var(--glass-border);
    box-shadow: none;
}

.btn-ver-top3 {
    background: linear-gradient(135deg, #FFD700, #F39C12);
}

.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);
}

.footer-btn-container {
    text-align: center;
    margin-top: 25px;
    position: relative;
    z-index: 20;
}

/* ==========================================================================
   Textos, Grupos y Estados Extraídos
   ========================================================================== */
.txt-multiplicador,
.txt-victoria {
    color: var(--text-main);
    font-size: 1.1rem;
    max-width: 400px;
}

.txt-victoria {
    margin-bottom: 15px;
}

.txt-score-dorado {
    color: #FFD700;
    font-size: 2.2rem;
}

.record-prompt {
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid #FFD700;
    padding: 15px;
    border-radius: 15px;
    margin-bottom: 20px;
    width: 90%;
    max-width: 350px;
}

.record-prompt h3 {
    color: #FF9500;
    margin-top: 0;
    font-size: 1.3rem;
}

.record-prompt input {
    padding: 12px;
    border-radius: 10px;
    border: 1px solid #FFD700;
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 10px;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
}

.btn-group-gameover {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.loading-estado {
    text-align: center;
    color: var(--text-muted);
    padding: 20px;
}

/* ==========================================================================
   Estilos del Modal Top 3 (Leaderboard)
   ========================================================================== */
.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);
}