/* ===== APIGAME · Simuladores gratuitos ===== */
.apigame {
    --ag-azul: #0b1c2d;
    --ag-azul-2: #16365a;
    --ag-amarillo: #f5c400;
    --ag-verde: #1e9e5a;
    --ag-rojo: #d93a3a;
    background: #f4f6fa;
}

/* Hero */
.ag-hero {
    background: radial-gradient(circle at 20% 20%, #23507f 0%, var(--ag-azul) 60%);
    color: #fff;
    text-align: center;
    padding: 140px 0 70px;
}
.ag-hero h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); font-weight: 800; }
.ag-hero h1 span { color: var(--ag-amarillo); }
.ag-hero .lead { opacity: .9; max-width: 680px; margin: .75rem auto 0; }
.ag-sello {
    display: inline-block;
    background: var(--ag-amarillo);
    color: var(--ag-azul);
    font-weight: 800;
    letter-spacing: 2px;
    padding: 6px 18px;
    border-radius: 30px;
    margin-bottom: 1rem;
}
.ag-cifras {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem 2.5rem;
    margin-top: 2rem;
}
.ag-cifras div { display: flex; flex-direction: column; }
.ag-cifras strong { font-size: 2rem; color: var(--ag-amarillo); line-height: 1; }
.ag-cifras span { font-size: .85rem; opacity: .85; }

/* Paneles */
.ag-panel {
    background: #fff;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 8px 24px rgba(11, 28, 45, .08);
}
.ag-titulo { font-weight: 800; color: var(--ag-azul); }
.ag-pasos { padding-left: 1.2rem; }
.ag-pasos li { margin-bottom: .6rem; }
.ag-modos-mini { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: 1.5rem; }
.ag-modos-mini div {
    background: #f4f6fa;
    border-radius: 10px;
    padding: .6rem .8rem;
    font-weight: 600;
    color: var(--ag-azul);
    font-size: .9rem;
}
.ag-modos-mini i { color: var(--ag-amarillo); margin-right: .5rem; }
.ag-consentimiento { background: #fffbea; border: 1px solid #f3e3a0; border-radius: 10px; padding: .75rem .75rem .75rem 2.2rem; }

.btn-ag {
    background: var(--ag-amarillo);
    color: var(--ag-azul);
    font-weight: 700;
    border: none;
}
.btn-ag:hover, .btn-ag:focus { background: #ffd633; color: var(--ag-azul); }

/* Selector de materia y modo */
.ag-paso-label { font-weight: 700; color: var(--ag-azul); display: flex; align-items: center; gap: .6rem; margin-bottom: 1rem; }
.ag-paso-label span {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--ag-azul); color: var(--ag-amarillo);
    display: grid; place-items: center; font-size: .9rem;
}
.ag-materias { display: flex; flex-wrap: wrap; gap: .75rem; }
.ag-materia input { position: absolute; opacity: 0; pointer-events: none; }
.ag-materia span {
    display: inline-flex; align-items: center; gap: .5rem;
    padding: .7rem 1.2rem;
    border-radius: 30px;
    background: #fff;
    border: 2px solid #dfe5ee;
    font-weight: 600;
    color: var(--ag-azul);
    cursor: pointer;
    transition: all .15s ease;
}
.ag-materia input:checked + span { background: var(--ag-azul); border-color: var(--ag-azul); color: #fff; }
.ag-materia input:checked + span i { color: var(--ag-amarillo); }
.ag-materia input:focus-visible + span { outline: 3px solid var(--ag-amarillo); }

.ag-modo {
    background: #fff;
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    box-shadow: 0 6px 18px rgba(11, 28, 45, .08);
    transition: transform .2s ease, box-shadow .2s ease;
}
.ag-modo:hover { transform: translateY(-5px); box-shadow: 0 12px 26px rgba(11, 28, 45, .14); }
.ag-modo h5 { font-weight: 800; color: var(--ag-azul); margin-top: .75rem; }
.ag-modo p { color: #555; font-size: .92rem; }
.ag-record { min-height: 1.4rem; margin-bottom: .75rem; color: var(--ag-azul); }
.ag-modo-icono {
    width: 54px; height: 54px; border-radius: 14px;
    background: linear-gradient(135deg, var(--ag-azul), var(--ag-azul-2));
    color: var(--ag-amarillo);
    display: grid; place-items: center; font-size: 1.4rem;
}
.ag-modo-icono.grande { width: 84px; height: 84px; font-size: 2.2rem; border-radius: 22px; margin: 0 auto 1rem; }

.ag-cta {
    background: linear-gradient(135deg, var(--ag-azul), var(--ag-azul-2));
    color: #fff;
    border-radius: 16px;
    padding: 1.75rem 2rem;
    display: flex; flex-wrap: wrap; gap: 1rem;
    justify-content: space-between; align-items: center;
}

/* ===== Pantalla de juego ===== */
.ag-juego-body { min-height: 100vh; }
.ag-juego { max-width: 860px; padding-top: 110px; padding-bottom: 60px; }
.ag-barra { display: flex; flex-wrap: wrap; gap: .75rem; justify-content: space-between; align-items: center; }
.ag-chip {
    display: inline-block;
    background: #fff;
    border: 1px solid #dfe5ee;
    color: var(--ag-azul);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: .85rem;
    font-weight: 600;
}
.ag-chip-modo { background: var(--ag-azul); color: #fff; border-color: var(--ag-azul); }
.ag-marcadores { display: flex; gap: 1rem; font-size: 1.05rem; color: var(--ag-azul); }
.ag-vida-perdida { opacity: .5; }
#ag-reloj.ag-urgente { color: var(--ag-rojo); animation: ag-latido 1s infinite; }
.ag-progress { height: 8px; margin: .75rem 0 1.5rem; background: #dfe5ee; }
.ag-progress .progress-bar { background: var(--ag-amarillo); transition: width .4s ease; }

.ag-pantalla {
    background: #fff;
    border-radius: 20px;
    padding: 2.5rem;
    box-shadow: 0 10px 30px rgba(11, 28, 45, .1);
    text-align: center;
    position: relative;
    overflow: hidden;
}
#ag-pregunta { text-align: left; }
.ag-entra { animation: ag-entra .35s ease; }
.ag-tema { font-size: .8rem; text-transform: uppercase; letter-spacing: 1px; color: #7a8699; font-weight: 700; }
.ag-enunciado { font-size: clamp(1.15rem, 2.6vw, 1.5rem); font-weight: 700; color: var(--ag-azul); margin: .5rem 0 1.5rem; line-height: 1.4; }

.ag-opciones { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
@media (max-width: 576px) { .ag-opciones { grid-template-columns: 1fr; } .ag-pantalla { padding: 1.5rem; } }
.ag-opcion {
    display: flex; align-items: center; gap: .9rem;
    text-align: left;
    background: #f4f6fa;
    border: 2px solid transparent;
    border-radius: 14px;
    padding: .9rem 1rem;
    font-size: 1.05rem;
    color: var(--ag-azul);
    transition: transform .12s ease, border-color .12s ease, background .12s ease;
}
.ag-opcion:not(:disabled):hover { border-color: var(--ag-amarillo); transform: translateY(-2px); background: #fffbea; }
.ag-letra {
    flex: 0 0 34px; height: 34px; border-radius: 10px;
    background: var(--ag-azul); color: #fff;
    display: grid; place-items: center; font-weight: 800; font-size: .9rem;
}
.ag-opcion.ag-correcta { background: #e6f6ed; border-color: var(--ag-verde); }
.ag-opcion.ag-correcta .ag-letra { background: var(--ag-verde); }
.ag-opcion.ag-incorrecta { background: #fdeaea; border-color: var(--ag-rojo); animation: ag-sacudir .35s ease; }
.ag-opcion.ag-incorrecta .ag-letra { background: var(--ag-rojo); }
.ag-opcion.ag-elegida { border-color: var(--ag-azul); }
.ag-opcion:disabled { cursor: default; }

.ag-feedback { margin-top: 1.25rem; padding: 1rem 1.2rem; border-radius: 12px; }
.ag-feedback.ok { background: #e6f6ed; border-left: 5px solid var(--ag-verde); }
.ag-feedback.error { background: #fdeaea; border-left: 5px solid var(--ag-rojo); }

.ag-flash-ok { box-shadow: 0 0 0 4px var(--ag-verde), 0 10px 30px rgba(11, 28, 45, .1); }
.ag-flash-error { box-shadow: 0 0 0 4px var(--ag-rojo), 0 10px 30px rgba(11, 28, 45, .1); }

/* Resultados */
.ag-res-cifras { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin: 1.5rem 0; }
@media (max-width: 576px) { .ag-res-cifras { grid-template-columns: repeat(2, 1fr); } }
.ag-res-cifras div { background: #f4f6fa; border-radius: 14px; padding: 1rem; display: flex; flex-direction: column; }
.ag-res-cifras strong { font-size: 1.8rem; color: var(--ag-azul); }
.ag-res-cifras span { font-size: .8rem; color: #7a8699; text-transform: uppercase; letter-spacing: 1px; }
.ag-rev { border-left: 4px solid; border-radius: 8px; background: #f9fafc; padding: .8rem 1rem; margin-bottom: .75rem; }
.ag-rev.ok { border-color: var(--ag-verde); }
.ag-rev.error { border-color: var(--ag-rojo); }

.ag-celebracion { position: absolute; inset: 0; pointer-events: none; }
.ag-celebracion span { position: absolute; top: -40px; font-size: 1.6rem; animation: ag-confeti 2.4s ease-in forwards; }

@keyframes ag-entra { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes ag-sacudir { 0%, 100% { transform: none; } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@keyframes ag-latido { 50% { opacity: .5; } }
@keyframes ag-confeti { to { transform: translateY(520px) rotate(540deg); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
    .ag-entra, .ag-opcion.ag-incorrecta, #ag-reloj.ag-urgente, .ag-celebracion span { animation: none; }
}

/* Enlace de vuelta a Recursos Gratuitos */
.ag-miga { display: block; width: fit-content; margin: 0 auto .75rem; color: rgba(255,255,255,.8); font-size: .9rem; text-decoration: none; }
.ag-miga:hover { color: var(--ag-amarillo); }
