/* ─────────────────────────────────────────────────────────────
   Módulo de Gamificación QWiZ
   Todo el color, la tipografía y el radio salen de variables que
   game-loader.js escribe desde los tokens del tema, para que el
   mismo motor sirva en cualquier temporada sin tocar este archivo.
   ───────────────────────────────────────────────────────────── */

.qwiz-game-root {
    --qg-primary: #B68A35;
    --qg-secondary: #2B2B2B;
    --qg-bg: #FFFFFF;
    --qg-text: #2B2B2B;
    --qg-button: #B68A35;
    --qg-button-text: #FFFFFF;
    --qg-button-hover: #96712A;
    --qg-accent: #F6EFE2;
    --qg-font: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --qg-scale: 1;
    --qg-weight: 600;
    --qg-radius: 8px;
    --qg-overlay: rgba(0, 0, 0, .6);
    --qg-surface: #FFFFFF;
    font-family: var(--qg-font);
}

/* ── Overlay y diálogo ─────────────────────────────────────── */

.qwiz-game-overlay {
    position: fixed;
    inset: 0;
    z-index: 20000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: var(--qg-overlay);
    overflow-y: auto;
}

.qwiz-game-overlay[hidden] {
    display: none !important;
}

.qwiz-game-dialog {
    position: relative;
    width: 100%;
    max-width: 560px;
    background: var(--qg-surface);
    background-size: cover;
    background-position: center;
    color: var(--qg-text);
    border-radius: calc(var(--qg-radius) * 2);
    box-shadow: 0 24px 70px rgba(0, 0, 0, .35);
    padding: 32px 28px;
    text-align: center;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
}

.qwiz-game-overlay--full .qwiz-game-dialog {
    max-width: 720px;
    min-height: min(560px, calc(100vh - 32px));
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.qwiz-game-overlay--small .qwiz-game-dialog {
    max-width: 400px;
    padding: 24px 20px;
}

.qwiz-game-close {
    position: absolute;
    top: 10px;
    right: 12px;
    background: transparent;
    border: 0;
    font-size: 26px;
    line-height: 1;
    color: currentColor;
    opacity: .55;
    cursor: pointer;
    padding: 4px 8px;
}

.qwiz-game-close:hover {
    opacity: 1;
}

/* ── Tipografía interna ────────────────────────────────────── */

.qwiz-game-logo {
    max-height: 56px;
    margin: 0 auto 14px;
    display: block;
}

.qwiz-game-title {
    font-size: calc(1.6rem * var(--qg-scale));
    font-weight: var(--qg-weight);
    color: var(--qg-primary);
    margin: 0 0 6px;
    line-height: 1.2;
}

.qwiz-game-subtitle {
    font-size: calc(1.05rem * var(--qg-scale));
    margin: 0 0 6px;
    opacity: .9;
}

.qwiz-game-text {
    font-size: calc(.95rem * var(--qg-scale));
    margin: 0 0 18px;
    opacity: .8;
}

/* ── Botones ───────────────────────────────────────────────── */

.qwiz-game-btn {
    display: inline-block;
    background: var(--qg-button);
    color: var(--qg-button-text);
    border: 0;
    border-radius: var(--qg-radius);
    font-family: inherit;
    font-weight: var(--qg-weight);
    font-size: calc(1rem * var(--qg-scale));
    padding: 13px 30px;
    cursor: pointer;
    transition: background .2s ease, transform .15s ease;
    text-decoration: none;
}

.qwiz-game-btn:hover {
    background: var(--qg-button-hover);
    color: var(--qg-button-text);
    transform: translateY(-1px);
}

.qwiz-game-btn:disabled {
    opacity: .55;
    cursor: not-allowed;
    transform: none;
}

.qwiz-game-dismiss {
    display: block;
    margin: 14px auto 0;
    background: transparent;
    border: 0;
    color: currentColor;
    opacity: .6;
    font-size: calc(.88rem * var(--qg-scale));
    text-decoration: underline;
    cursor: pointer;
}

.qwiz-game-dismiss:hover {
    opacity: 1;
}

/* ── Formulario de captura ─────────────────────────────────── */

.qwiz-game-form {
    max-width: 340px;
    margin: 0 auto;
    text-align: left;
}

.qwiz-game-form label {
    display: block;
    font-size: calc(.82rem * var(--qg-scale));
    margin: 0 0 4px;
    opacity: .75;
}

.qwiz-game-form input {
    width: 100%;
    padding: 11px 13px;
    margin-bottom: 12px;
    border: 1px solid rgba(0, 0, 0, .18);
    border-radius: var(--qg-radius);
    font-family: inherit;
    font-size: calc(.95rem * var(--qg-scale));
    background: #fff;
    color: #2B2B2B;
}

.qwiz-game-form input:focus {
    outline: none;
    border-color: var(--qg-primary);
}

.qwiz-game-privacy {
    font-size: calc(.75rem * var(--qg-scale));
    opacity: .6;
    margin-top: 10px;
    text-align: center;
}

.qwiz-game-error {
    color: #C62828;
    font-size: calc(.85rem * var(--qg-scale));
    margin: 10px 0 0;
    min-height: 1em;
}

/* ── Área de la mecánica ───────────────────────────────────── */

.qwiz-game-stage {
    margin: 20px 0 8px;
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Regalo sorpresa / sobres / elige tu regalo */

.qwiz-game-items {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: center;
}

.qwiz-game-item {
    width: 104px;
    min-height: 104px;
    border: 2px solid transparent;
    border-radius: calc(var(--qg-radius) * 1.5);
    background: var(--qg-accent);
    font-size: 44px;
    line-height: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    transition: transform .18s ease, border-color .18s ease;
    padding: 10px;
}

.qwiz-game-item img {
    max-width: 72px;
    max-height: 72px;
}

.qwiz-game-item span {
    font-size: calc(.78rem * var(--qg-scale));
    font-weight: var(--qg-weight);
    color: var(--qg-text);
}

.qwiz-game-item:hover:not(:disabled) {
    transform: translateY(-6px) scale(1.04);
    border-color: var(--qg-primary);
}

.qwiz-game-item:disabled {
    cursor: default;
    opacity: .45;
}

.qwiz-game-item.is-chosen {
    opacity: 1;
    border-color: var(--qg-primary);
    animation: qwiz-game-pop .5s ease;
}

@keyframes qwiz-game-pop {
    0% { transform: scale(1); }
    45% { transform: scale(1.22) rotate(-4deg); }
    100% { transform: scale(1); }
}

/* Ruleta */

.qwiz-wheel-wrap {
    position: relative;
    width: min(320px, 78vw);
    aspect-ratio: 1;
    margin: 0 auto;
}

.qwiz-wheel {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 8px solid var(--qg-primary);
    box-shadow: 0 8px 30px rgba(0, 0, 0, .22);
    transition: transform var(--qg-spin-duration, 4s) cubic-bezier(.17, .67, .18, 1);
}

.qwiz-wheel-pointer {
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 14px solid transparent;
    border-right: 14px solid transparent;
    border-top: 26px solid var(--qg-primary);
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .3));
    z-index: 2;
}

.qwiz-wheel-labels {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

/* Raspa y gana */

.qwiz-scratch-wrap {
    position: relative;
    width: min(340px, 84vw);
    height: 190px;
    margin: 0 auto;
    border-radius: calc(var(--qg-radius) * 1.5);
    overflow: hidden;
    background: var(--qg-accent);
}

.qwiz-scratch-prize {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(1.5rem * var(--qg-scale));
    font-weight: var(--qg-weight);
    color: var(--qg-primary);
    text-align: center;
    padding: 16px;
}

.qwiz-scratch-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    touch-action: none;
}

/* Quiz */

.qwiz-quiz {
    width: 100%;
    text-align: left;
}

.qwiz-quiz-progress {
    font-size: calc(.78rem * var(--qg-scale));
    opacity: .6;
    margin-bottom: 8px;
    text-align: center;
}

.qwiz-quiz-question {
    font-size: calc(1.1rem * var(--qg-scale));
    font-weight: var(--qg-weight);
    margin: 0 0 14px;
    text-align: center;
}

.qwiz-quiz-options {
    display: grid;
    gap: 10px;
}

.qwiz-quiz-option {
    background: var(--qg-accent);
    border: 2px solid transparent;
    border-radius: var(--qg-radius);
    padding: 13px 16px;
    font-family: inherit;
    font-size: calc(.95rem * var(--qg-scale));
    color: var(--qg-text);
    cursor: pointer;
    text-align: left;
    transition: border-color .15s ease, transform .15s ease;
}

.qwiz-quiz-option:hover {
    border-color: var(--qg-primary);
    transform: translateX(3px);
}

/* Memoria */

.qwiz-memory-board {
    display: grid;
    grid-template-columns: repeat(var(--qg-memory-cols, 4), 1fr);
    gap: 8px;
    max-width: 340px;
    margin: 0 auto;
}

.qwiz-memory-card {
    aspect-ratio: 3 / 4;
    border: 2px solid transparent;
    border-radius: var(--qg-radius);
    background: var(--qg-primary);
    font-size: 26px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: background .2s ease, transform .15s ease;
}

.qwiz-memory-card.is-open {
    background: var(--qg-accent);
}

.qwiz-memory-card.is-matched {
    background: var(--qg-accent);
    border-color: var(--qg-primary);
    cursor: default;
}

/* Atrapa el descuento */

.qwiz-catch-arena {
    position: relative;
    width: 100%;
    height: 230px;
    background: var(--qg-accent);
    border-radius: calc(var(--qg-radius) * 1.5);
    overflow: hidden;
}

.qwiz-catch-item {
    position: absolute;
    border: 0;
    background: transparent;
    font-size: 34px;
    line-height: 1;
    padding: 4px;
    cursor: pointer;
    animation: qwiz-catch-in .2s ease;
}

.qwiz-catch-item.is-bad {
    filter: grayscale(.2);
}

.qwiz-catch-item.is-taken {
    transform: scale(1.5);
    opacity: 0;
    transition: transform .18s ease, opacity .18s ease;
}

@keyframes qwiz-catch-in {
    from { transform: scale(.4); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* ── Resultado ─────────────────────────────────────────────── */

.qwiz-game-result {
    animation: qwiz-game-reveal .45s ease;
}

@keyframes qwiz-game-reveal {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: none; }
}

.qwiz-game-prize-label {
    font-size: calc(2.1rem * var(--qg-scale));
    font-weight: 800;
    color: var(--qg-primary);
    margin: 10px 0;
    line-height: 1.1;
}

.qwiz-game-coupon {
    display: inline-block;
    border: 2px dashed var(--qg-primary);
    border-radius: var(--qg-radius);
    padding: 10px 22px;
    margin: 6px 0 16px;
    font-size: calc(1.25rem * var(--qg-scale));
    font-weight: 800;
    letter-spacing: .1em;
    cursor: pointer;
    background: transparent;
    color: var(--qg-primary);
    font-family: inherit;
}

.qwiz-game-meta {
    font-size: calc(.82rem * var(--qg-scale));
    opacity: .7;
    margin: 0 0 14px;
}

/* ── Widget flotante ───────────────────────────────────────── */

.qwiz-game-widget {
    position: fixed;
    right: 18px;
    bottom: 96px;
    z-index: 19000;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--qg-button);
    color: var(--qg-button-text);
    border: 0;
    border-radius: 999px;
    padding: 12px 20px 12px 16px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .25);
    cursor: pointer;
    font-family: var(--qg-font);
    font-weight: var(--qg-weight);
    font-size: .9rem;
    animation: qwiz-game-widget-in .4s ease;
}

@keyframes qwiz-game-widget-in {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: none; }
}

.qwiz-game-widget:hover {
    background: var(--qg-button-hover);
}

.qwiz-game-widget-icon {
    font-size: 1.35rem;
}

/* ── Banner en Home ────────────────────────────────────────── */

.qwiz-game-banner {
    text-align: center;
    padding: 34px 20px;
    margin: 26px 0;
    border-radius: calc(var(--qg-radius) * 2);
    background: var(--qg-accent);
    font-family: var(--qg-font);
    color: var(--qg-text);
}

.qwiz-game-banner h3 {
    font-size: calc(1.4rem * var(--qg-scale));
    font-weight: var(--qg-weight);
    color: var(--qg-primary);
    margin: 0 0 6px;
}

.qwiz-game-banner p {
    margin: 0 0 16px;
    opacity: .8;
}

/* ── Confeti ───────────────────────────────────────────────── */

.qwiz-confetti {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 20001;
    overflow: hidden;
}

.qwiz-confetti i {
    position: absolute;
    top: -12px;
    width: 9px;
    height: 15px;
    opacity: .9;
    animation: qwiz-confetti-fall linear forwards;
}

@keyframes qwiz-confetti-fall {
    to {
        transform: translateY(105vh) rotate(640deg);
        opacity: 0;
    }
}

/* ── Móvil ─────────────────────────────────────────────────── */

@media (max-width: 576px) {
    .qwiz-game-overlay {
        padding: 10px;
        align-items: flex-start;
    }

    .qwiz-game-dialog,
    .qwiz-game-overlay--full .qwiz-game-dialog {
        max-width: 100%;
        padding: 26px 18px;
        min-height: auto;
    }

    .qwiz-game-item {
        width: 86px;
        min-height: 86px;
        font-size: 36px;
    }

    .qwiz-game-prize-label {
        font-size: calc(1.7rem * var(--qg-scale));
    }

    .qwiz-game-widget {
        bottom: 80px;
        right: 12px;
        padding: 10px 16px 10px 14px;
        font-size: .82rem;
    }
}
