:root {
    --facil: #22c55e;
    --medio: #facc15;
    --dificil: #fd3131;
    --tarjeta: #161616;
    --borde: #3a3a3a;
    --texto: #f2f2f2;
    --suave: #a8a8a8;
    --rojo-oscuro: rgb(81, 40, 40);
}

body {
    background-color: rgb(0, 0, 0);
    color: var(--texto);
    font-family: Arial, sans-serif;
}

.arriba {
    display: flex;
    justify-content: space-evenly;
    align-items: center;
    background-color: var(--rojo-oscuro);
    border-radius: 20px;
    padding: 1px;
    width: 100%;
}

.inicio {
    display: flex;
    gap: 20px;
}
.inicio a { cursor: pointer; }
.inicio a:hover { text-decoration: underline; }

.estadisticas span { margin-right: 6px; }

.botones {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
}

.filtro, #filtro-dificultad {
    padding: 6px 10px;
    background-color: #1f1f1f;
    color: var(--texto);
    border: 1px solid #555;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color .2s;
}
.filtro:hover { background-color: #2c2c2c; }
.filtro.activo {
    background-color: var(--rojo-oscuro);
    border-color: #c98a8a;
    font-weight: bold;
}

#loader {
    position: fixed;
    inset: 0;
    z-index: 50;
    background-color: rgb(0, 0, 0);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    transition: opacity .4s ease;
}
#loader.oculto { opacity: 0; pointer-events: none; }
.spinner {
    width: 46px;
    height: 46px;
    border: 4px solid #333;
    border-top-color: #c98a8a;
    border-radius: 50%;
    animation: girar .8s linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }

.cuadros {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
    margin-top: 20px;
}
.vacio { grid-column: 1 / -1; text-align: center; color: var(--suave); }

.cuadro {
    background-color: var(--tarjeta);
    border: 2px solid var(--borde);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    transition: transform .2s ease, box-shadow .2s ease, background-color .3s;
}

.cuadro.facil   { border-color: var(--facil); }
.cuadro.medio   { border-color: var(--medio); }
.cuadro.dificil { border-color: var(--dificil); }
.cuadro:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(255, 255, 255, .08);
}
.cuadro.resuelto { background-color: #10261a; }

.cuadro.animar { animation: entrada .4s ease both; }
.cuadro.animar:nth-child(2) { animation-delay: 60ms; }
.cuadro.animar:nth-child(3) { animation-delay: 120ms; }
.cuadro.animar:nth-child(4) { animation-delay: 180ms; }
.cuadro.animar:nth-child(5) { animation-delay: 240ms; }
.cuadro.animar:nth-child(6) { animation-delay: 300ms; }
.cuadro.animar:nth-child(7) { animation-delay: 360ms; }
.cuadro.animar:nth-child(8) { animation-delay: 420ms; }
@keyframes entrada {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.banner {
    position: relative;
    height: 130px;
    background-color: #2a2a2a;
    border-radius: 6px 6px 0 0;
    overflow: hidden;
}
.banner img {
    height: 100%;
    width: 100%;
    object-fit: cover;
    display: block;
}

.sello {
    display: none;
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: var(--facil);
    color: #000;
    font-size: .85rem;
    align-items: center;
    justify-content: center;
}
.cuadro.resuelto .sello { display: flex; }

.cuadro-cuerpo {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}
.encabezado {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}
.encabezado h2 { font-size: 1rem; }
.puntos { font-weight: bold; white-space: nowrap; }

.descripcion {
    font-size: .82rem;
    color: var(--suave);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    font-size: .72rem;
    padding: 2px 8px;
    border-radius: 4px;
    background-color: #2a2a2a;
    color: var(--suave);
}

.acciones { display: flex; gap: 8px; margin-top: auto; }
.btn-resolver, .btn-pendiente {
    flex: 1;
    padding: 9px 4px;
    border-radius: 6px;
    font-size: .8rem;
    font-weight: bold;
    cursor: pointer;
}
.btn-resolver {
    background-color: #1d5fd6;
    color: #fff;
    border: none;
    transition: background-color .3s;
}
.btn-resolver:hover { background-color: #2f74f0; }
.btn-resolver.completado {
    background-color: var(--facil);
    color: #000;
    cursor: default;
    animation: pulso .5s ease;
}
@keyframes pulso {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.06); }
    100% { transform: scale(1); }
}
.btn-pendiente {
    background-color: transparent;
    color: var(--texto);
    border: 1px solid #555;
}
.btn-pendiente.activo {
    border-color: var(--medio);
    color: var(--medio);
}

.nav-movil { display: none; }

@media (max-width: 700px) {
    .arriba { flex-direction: column; gap: 6px; padding: 10px 1px; }
    .inicio, .botones { display: none; }
    body { padding-bottom: 70px; }
    .nav-movil {
        display: flex;
        gap: 6px;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 8px;
        background-color: #111;
        border-top: 1px solid var(--borde);
    }
    .nav-movil .filtro { flex: 1; padding: 12px 2px; font-size: .75rem; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}