/* =========================================================================
   Biblical Kings Quiz — Design system público (landing, auth, juego)
   Estilo inspirado en Wayground: claro, vibrante, tarjetas redondeadas.
   ========================================================================= */

:root {
    /* Marca: se sobreescribe por espacio de trabajo (--brand desde JS) */
    --brand: #6d28d9;
    --brand-ink: #ffffff;

    --bg: #f4f5fb;
    --bg-grad-a: rgba(109, 40, 217, 0.10);
    --bg-grad-b: rgba(255, 77, 141, 0.08);
    --surface: #ffffff;
    --surface-2: #f8f9fe;
    --ink: #1b1e3d;
    --muted: #6a7194;
    --line: #e6e8f3;
    --line-strong: #d5d8ea;

    --success: #10b981;
    --success-soft: #e7f8f1;
    --danger: #ef4444;
    --danger-soft: #fdecec;
    --warning: #f59e0b;
    --warning-soft: #fef3e2;
    --info: #3b82f6;
    --info-soft: #e9f1fe;

    --opt-1: #6366f1;
    --opt-2: #ec4899;
    --opt-3: #f59e0b;
    --opt-4: #14b8a6;
    --opt-5: #8b5cf6;
    --opt-6: #ef4444;

    --radius: 20px;
    --radius-sm: 12px;
    --shadow: 0 12px 34px rgba(27, 30, 61, 0.09);
    --shadow-lg: 0 26px 60px rgba(27, 30, 61, 0.16);
    --font: 'Outfit', system-ui, -apple-system, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    background: var(--bg);
    background-image:
        radial-gradient(at 5% 0%, var(--bg-grad-a) 0, transparent 55%),
        radial-gradient(at 95% 100%, var(--bg-grad-b) 0, transparent 55%);
    background-attachment: fixed;
    color: var(--ink);
    min-height: 100vh;
    line-height: 1.5;
}

img { max-width: 100%; display: block; }
a { color: var(--brand); }
button { font-family: inherit; }

.hidden { display: none !important; }

/* ---------------------------------------------------------------- Botones */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--brand);
    color: var(--brand-ink);
    border: none;
    padding: 13px 26px;
    border-radius: 14px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
    box-shadow: 0 8px 18px -6px color-mix(in srgb, var(--brand) 55%, transparent);
    line-height: 1.2;
}
.btn:hover { transform: translateY(-2px); background: color-mix(in srgb, var(--brand) 86%, black); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn-lg { padding: 17px 40px; font-size: 1.12rem; border-radius: 16px; }
.btn-sm { padding: 8px 16px; font-size: .88rem; border-radius: 11px; }
.btn-block { width: 100%; }

.btn-ghost {
    background: var(--surface);
    color: var(--ink);
    border: 1.5px solid var(--line-strong);
    box-shadow: none;
}
.btn-ghost:hover { background: var(--surface-2); border-color: var(--brand); color: var(--brand); }

.btn-soft {
    background: color-mix(in srgb, var(--brand) 12%, white);
    color: var(--brand);
    box-shadow: none;
}
.btn-soft:hover { background: color-mix(in srgb, var(--brand) 20%, white); }

.btn-danger { background: var(--danger); box-shadow: 0 8px 18px -6px rgba(239,68,68,.5); }
.btn-danger:hover { background: #dc2626; }

.btn-success { background: var(--success); box-shadow: 0 8px 18px -6px rgba(16,185,129,.5); }
.btn-success:hover { background: #059669; }

.btn-dark { background: var(--ink); }
.btn-dark:hover { background: #0f1230; }

/* --------------------------------------------------------------- Controles */

.input, .textarea, .select {
    width: 100%;
    padding: 13px 16px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--line-strong);
    background: var(--surface);
    font-family: inherit;
    font-size: 1rem;
    color: var(--ink);
    transition: border-color .15s, box-shadow .15s;
}
.input:focus, .textarea:focus, .select:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 15%, transparent);
}
.input::placeholder, .textarea::placeholder { color: #9aa1c0; }
.textarea { resize: vertical; min-height: 90px; }

.label { display: block; font-weight: 600; font-size: .9rem; margin: 16px 0 7px; color: var(--ink); }
.help { font-size: .82rem; color: var(--muted); margin-top: 6px; }

/* ----------------------------------------------------------------- Badges */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
}
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-purple { background: #f1ebfe; color: #7c3aed; }
.badge-green  { background: var(--success-soft); color: #059669; }
.badge-red    { background: var(--danger-soft); color: #dc2626; }
.badge-amber  { background: var(--warning-soft); color: #d97706; }
.badge-blue   { background: var(--info-soft); color: #2563eb; }
.badge-gray   { background: #eef0f6; color: var(--muted); }

/* ------------------------------------------------------------------ Cards */

.card {
    background: var(--surface);
    border: 1.5px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 26px;
}

.alert {
    padding: 13px 17px;
    border-radius: var(--radius-sm);
    font-size: .93rem;
    font-weight: 500;
    margin: 14px 0;
    display: none;
}
.alert.show { display: block; animation: fadeUp .25s ease; }
.alert-error { background: var(--danger-soft); color: #b91c1c; border: 1px solid #fbcaca; }
.alert-ok { background: var(--success-soft); color: #047857; border: 1px solid #b7ecd9; }
.alert-info { background: var(--info-soft); color: #1d4ed8; border: 1px solid #cadcfd; }
.alert-warn { background: var(--warning-soft); color: #b45309; border: 1px solid #fcdcab; }

/* ------------------------------------------------------------------ Toast */

#toast {
    position: fixed;
    bottom: 26px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--ink);
    color: #fff;
    padding: 13px 24px;
    border-radius: 14px;
    font-weight: 600;
    font-size: .95rem;
    opacity: 0;
    pointer-events: none;
    transition: all .3s cubic-bezier(.16,1,.3,1);
    z-index: 999;
    max-width: 90vw;
    text-align: center;
    box-shadow: var(--shadow-lg);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--danger); }
#toast.ok { background: var(--success); }

/* =========================================================================
   LANDING
   ========================================================================= */

.landing-nav {
    max-width: 1160px;
    margin: 0 auto;
    padding: 22px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.logo-mark {
    display: flex;
    align-items: center;
    gap: 11px;
    font-weight: 800;
    font-size: 1.22rem;
    color: var(--ink);
    text-decoration: none;
    letter-spacing: -.4px;
}
.logo-cube {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--brand), color-mix(in srgb, var(--brand) 55%, #ff4d8d));
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 1.15rem;
    font-weight: 800;
    box-shadow: 0 8px 18px -6px color-mix(in srgb, var(--brand) 60%, transparent);
}
.landing-nav .nav-actions { display: flex; align-items: center; gap: 10px; }

.hero {
    max-width: 900px;
    margin: 0 auto;
    padding: 60px 24px 30px;
    text-align: center;
}
.hero h1 {
    font-size: clamp(2.1rem, 5.4vw, 3.6rem);
    font-weight: 800;
    letter-spacing: -1.5px;
    line-height: 1.08;
    margin-bottom: 16px;
}
.hero h1 .grad {
    background: linear-gradient(100deg, var(--brand), #ff4d8d);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.hero p.sub {
    color: var(--muted);
    font-size: 1.13rem;
    max-width: 620px;
    margin: 0 auto 36px;
}

/* Caja gigante de código */
.code-box {
    background: var(--surface);
    border: 2px solid var(--line);
    border-radius: 26px;
    padding: 30px 30px 34px;
    max-width: 560px;
    margin: 0 auto;
    box-shadow: var(--shadow-lg);
}
.code-box label {
    font-weight: 700;
    font-size: .95rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1.4px;
}
.code-input {
    width: 100%;
    border: none;
    text-align: center;
    font-family: inherit;
    font-size: clamp(2rem, 6vw, 2.9rem);
    font-weight: 800;
    letter-spacing: 10px;
    text-transform: uppercase;
    color: var(--brand);
    background: transparent;
    margin: 10px 0 22px;
    text-transform: uppercase;
}
.code-input:focus { outline: none; }
.code-input::placeholder { color: #ccd0e4; letter-spacing: 10px; }

.hero-note {
    margin-top: 26px;
    color: var(--muted);
    font-size: .95rem;
}
.hero-note a { font-weight: 700; text-decoration: none; }

/* Features */
.features {
    max-width: 1100px;
    margin: 40px auto 70px;
    padding: 0 24px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}
.feature {
    background: var(--surface);
    border: 1.5px solid var(--line);
    border-radius: var(--radius);
    padding: 28px 24px;
    transition: transform .2s ease, box-shadow .2s ease;
}
.feature:hover { transform: translateY(-5px); box-shadow: var(--shadow); }
.feature .icon {
    width: 52px;
    height: 52px;
    border-radius: 15px;
    display: grid;
    place-items: center;
    font-size: 1.5rem;
    margin-bottom: 16px;
}
.feature h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 8px; }
.feature p { color: var(--muted); font-size: .94rem; }

.landing-footer {
    border-top: 1.5px solid var(--line);
    padding: 26px 24px;
    text-align: center;
    color: var(--muted);
    font-size: .9rem;
}

/* =========================================================================
   AUTH
   ========================================================================= */

.auth-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 30px 20px;
}
.auth-card {
    width: 100%;
    max-width: 470px;
    background: var(--surface);
    border: 1.5px solid var(--line);
    border-radius: 26px;
    box-shadow: var(--shadow-lg);
    padding: 38px 34px;
}
.auth-head { text-align: center; margin-bottom: 24px; }
.auth-head h1 { font-size: 1.65rem; font-weight: 800; letter-spacing: -.5px; }
.auth-head p { color: var(--muted); margin-top: 6px; font-size: .96rem; }

.auth-tabs {
    display: flex;
    background: var(--surface-2);
    border: 1.5px solid var(--line);
    border-radius: 14px;
    padding: 5px;
    margin-bottom: 22px;
}
.auth-tabs button {
    flex: 1;
    padding: 11px;
    border: none;
    background: transparent;
    border-radius: 10px;
    font-weight: 700;
    font-size: .95rem;
    color: var(--muted);
    cursor: pointer;
    transition: all .18s;
}
.auth-tabs button.active {
    background: var(--surface);
    color: var(--brand);
    box-shadow: 0 3px 10px rgba(27,30,61,.10);
}

.color-row { display: flex; gap: 10px; align-items: center; }
.color-row input[type=color] {
    width: 54px;
    height: 46px;
    border: 1.5px solid var(--line-strong);
    border-radius: 12px;
    background: var(--surface);
    padding: 4px;
    cursor: pointer;
}
.color-presets { display: flex; gap: 8px; flex-wrap: wrap; }
.color-presets button {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2.5px solid transparent;
    cursor: pointer;
    transition: transform .15s;
}
.color-presets button:hover { transform: scale(1.18); }

.auth-foot { text-align: center; margin-top: 20px; font-size: .9rem; color: var(--muted); }
.auth-foot a { font-weight: 700; text-decoration: none; }

/* =========================================================================
   JUEGO (participante)
   ========================================================================= */

.game-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    max-width: 860px;
    margin: 0 auto;
    padding: 18px 20px 40px;
}

.game-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 22px;
}
.game-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 1.02rem;
    min-width: 0;
}
.game-brand img {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    object-fit: cover;
    border: 1.5px solid var(--line);
}
.game-brand .b-cube {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: var(--brand);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 800;
    flex-shrink: 0;
}
.game-brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game-code-pill {
    background: var(--surface);
    border: 1.5px dashed var(--line-strong);
    padding: 8px 16px;
    border-radius: 12px;
    font-weight: 800;
    letter-spacing: 2.5px;
    font-size: .95rem;
    color: var(--muted);
    white-space: nowrap;
}
.game-code-pill b { color: var(--brand); }

.game-panel {
    background: var(--surface);
    border: 1.5px solid var(--line);
    border-radius: 26px;
    box-shadow: var(--shadow);
    padding: 36px 32px;
    animation: fadeUp .35s cubic-bezier(.16,1,.3,1);
    flex: 1;
}
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}

.game-title { text-align: center; margin-bottom: 8px; }
.game-title h1 { font-size: clamp(1.5rem, 4vw, 2.1rem); font-weight: 800; letter-spacing: -.7px; }
.game-title p { color: var(--muted); margin-top: 8px; }

/* Unirse */
.join-form { max-width: 430px; margin: 26px auto 0; }
.join-form .input { text-align: center; font-size: 1.06rem; padding: 16px; }
.join-form .code-field {
    font-size: 1.7rem;
    font-weight: 800;
    letter-spacing: 7px;
    text-transform: uppercase;
    color: var(--brand);
}

/* Lobby */
.lobby { text-align: center; }
.lobby-code {
    font-size: clamp(3rem, 12vw, 5rem);
    font-weight: 800;
    letter-spacing: 14px;
    color: var(--brand);
    background: color-mix(in srgb, var(--brand) 9%, white);
    border: 2.5px dashed color-mix(in srgb, var(--brand) 40%, white);
    border-radius: 24px;
    padding: 22px 10px;
    margin: 24px 0;
    text-indent: 14px;
}
.lobby-status {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--warning-soft);
    color: #b45309;
    font-weight: 700;
    padding: 11px 22px;
    border-radius: 999px;
    margin-bottom: 24px;
}
.pulse-dot {
    width: 10px; height: 10px;
    background: var(--warning);
    border-radius: 50%;
    animation: pulse 1.3s infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1);} 50% { opacity: .4; transform: scale(.75);} }

.player-chips { display: flex; flex-wrap: wrap; gap: 9px; justify-content: center; margin-top: 18px; }
.player-chip {
    background: var(--surface-2);
    border: 1.5px solid var(--line);
    padding: 8px 17px;
    border-radius: 999px;
    font-weight: 600;
    font-size: .92rem;
    animation: fadeUp .3s ease;
}
.player-chip.me { background: color-mix(in srgb, var(--brand) 12%, white); border-color: color-mix(in srgb, var(--brand) 35%, white); color: var(--brand); }

/* Pregunta */
.q-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}
.q-counter {
    font-weight: 800;
    font-size: .92rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
}
.q-timer {
    display: flex;
    align-items: center;
    gap: 9px;
    background: var(--surface-2);
    border: 1.5px solid var(--line);
    padding: 7px 16px;
    border-radius: 999px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}
.q-timer.low { background: var(--danger-soft); border-color: #fbcaca; color: var(--danger); animation: pulse 1s infinite; }

.q-bar-bg {
    height: 9px;
    background: var(--surface-2);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 28px;
    border: 1px solid var(--line);
}
.q-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--brand), color-mix(in srgb, var(--brand) 50%, #ff4d8d));
    border-radius: 999px;
    transition: width .95s linear;
}

.q-text {
    font-size: clamp(1.3rem, 3.6vw, 1.75rem);
    font-weight: 700;
    line-height: 1.35;
    margin-bottom: 30px;
    letter-spacing: -.4px;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 15px;
}
.opt {
    display: flex;
    align-items: center;
    gap: 15px;
    background: var(--surface);
    border: 2px solid var(--line);
    border-radius: 18px;
    padding: 19px 21px;
    font-size: 1.06rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: all .16s cubic-bezier(.16,1,.3,1);
    color: var(--ink);
    line-height: 1.35;
}
.opt .opt-letter {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 11px;
    display: grid;
    place-items: center;
    font-weight: 800;
    color: #fff;
    font-size: .98rem;
}
.opt:nth-child(1) .opt-letter { background: var(--opt-1); }
.opt:nth-child(2) .opt-letter { background: var(--opt-2); }
.opt:nth-child(3) .opt-letter { background: var(--opt-3); }
.opt:nth-child(4) .opt-letter { background: var(--opt-4); }
.opt:nth-child(5) .opt-letter { background: var(--opt-5); }
.opt:nth-child(6) .opt-letter { background: var(--opt-6); }
.opt:hover:not(:disabled) {
    transform: translateY(-3px);
    border-color: color-mix(in srgb, var(--brand) 45%, white);
    box-shadow: var(--shadow);
}
.opt:disabled { cursor: default; }
.opt.dim { opacity: .45; }
.opt.correct {
    background: var(--success-soft);
    border-color: var(--success);
    color: #065f46;
    animation: pop .3s ease;
}
.opt.wrong {
    background: var(--danger-soft);
    border-color: var(--danger);
    color: #991b1b;
    animation: shake .35s ease;
}
@keyframes pop { 50% { transform: scale(1.035); } }
@keyframes shake {
    25% { transform: translateX(-7px); }
    50% { transform: translateX(6px); }
    75% { transform: translateX(-3px); }
}

/* Feedback */
.feedback-banner {
    text-align: center;
    padding: 22px;
    border-radius: 20px;
    margin-bottom: 24px;
    animation: fadeUp .3s ease;
    font-weight: 700;
    font-size: 1.15rem;
}
.feedback-banner.ok { background: var(--success-soft); color: #047857; border: 2px solid var(--success); }
.feedback-banner.bad { background: var(--danger-soft); color: #b91c1c; border: 2px solid var(--danger); }
.feedback-banner .pts {
    display: inline-block;
    margin-left: 10px;
    background: var(--success);
    color: #fff;
    padding: 3px 14px;
    border-radius: 999px;
    font-size: 1rem;
}
.feedback-banner .pts.zero { background: var(--danger); }

/* Espera / leaderboard */
.espera, .final-box { text-align: center; }
.espera h2, .final-box h2 { font-size: 1.55rem; font-weight: 800; margin-bottom: 6px; }
.espera p, .final-box p { color: var(--muted); margin-bottom: 26px; }

.leaderboard {
    max-width: 480px;
    margin: 0 auto;
    text-align: left;
}
.lb-row {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--surface-2);
    border: 1.5px solid var(--line);
    border-radius: 15px;
    padding: 13px 18px;
    margin-bottom: 9px;
    animation: fadeUp .3s ease;
}
.lb-row .rank {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--surface);
    border: 1.5px solid var(--line);
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: .9rem;
    color: var(--muted);
    flex-shrink: 0;
}
.lb-row:nth-child(1) .rank { background: #fde68a; border-color: #f59e0b; color: #92400e; }
.lb-row:nth-child(2) .rank { background: #e5e7eb; border-color: #9ca3af; color: #4b5563; }
.lb-row:nth-child(3) .rank { background: #fed7aa; border-color: #f97316; color: #9a3412; }
.lb-row .name { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-row .score { font-weight: 800; color: var(--brand); font-variant-numeric: tabular-nums; }
.lb-row.me {
    background: color-mix(in srgb, var(--brand) 10%, white);
    border-color: color-mix(in srgb, var(--brand) 40%, white);
}
.lb-row.me .name::after { content: ' (tú)'; color: var(--brand); font-size: .8rem; font-weight: 600; }

/* Resultado final */
.final-score {
    font-size: clamp(3.6rem, 14vw, 5.6rem);
    font-weight: 800;
    color: var(--brand);
    line-height: 1;
    margin: 14px 0 4px;
    text-shadow: 0 14px 34px color-mix(in srgb, var(--brand) 35%, transparent);
}
.final-sub { color: var(--muted); font-weight: 600; margin-bottom: 28px; }
.final-stats {
    display: flex;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 30px;
}
.final-stat {
    background: var(--surface-2);
    border: 1.5px solid var(--line);
    border-radius: 16px;
    padding: 15px 26px;
    text-align: center;
    min-width: 120px;
}
.final-stat b { display: block; font-size: 1.5rem; color: var(--ink); }
.final-stat span { font-size: .82rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .6px; }

/* Espera tras responder (en vivo) */
.waiting-box { text-align: center; padding: 30px 10px; }
.waiting-box .spinner {
    width: 54px;
    height: 54px;
    border: 5px solid var(--line);
    border-top-color: var(--brand);
    border-radius: 50%;
    margin: 0 auto 22px;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================================================
   RESPONSIVE
   ========================================================================= */

@media (max-width: 640px) {
    .landing-nav .nav-actions .btn { padding: 10px 16px; font-size: .9rem; }
    .code-box { padding: 24px 18px 26px; }
    .game-panel { padding: 26px 18px; border-radius: 20px; }
    .options-grid { grid-template-columns: 1fr; }
    .opt { padding: 16px; font-size: 1rem; }
    .lobby-code { letter-spacing: 8px; text-indent: 8px; }
    .auth-card { padding: 30px 22px; }
}
