/* Kwizzy: mobile-first, one column on phones, ad rail on wide screens. */

:root {
    --brand: #6C3CE9;
    --brand-2: #FF4D8D;
    --accent: var(--brand);
    --bg: #F5F3FB;
    --surface: #FFFFFF;
    --surface-2: #F0ECFA;
    --text: #1C1530;
    --muted: #6B6480;
    --line: #E6E0F3;
    --good: #16A34A;
    --good-bg: #E8F8EE;
    --bad: #E11D48;
    --bad-bg: #FDEBEF;
    --gold: #FFC93C;
    --radius: 18px;
    --shadow: 0 8px 28px rgba(40, 20, 90, .08);
    --font: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #110D1D;
        --surface: #1C1630;
        --surface-2: #261E3F;
        --text: #F3F0FA;
        --muted: #A9A1C2;
        --line: #2F2748;
        --good-bg: #0F2E1D;
        --bad-bg: #3A1220;
        --shadow: none;
        color-scheme: dark;
    }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: clamp(1.5rem, 4.5vw, 2.1rem); font-weight: 800; }
h2 { font-size: 1.15rem; font-weight: 700; }
p { margin: 0 0 .75rem; }
h1:focus { outline: none; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.mt { margin-top: .75rem; }
.center { text-align: center; }
.big-emoji { font-size: 3rem; line-height: 1; margin-bottom: .5rem; }
.error { color: var(--bad); font-weight: 600; }

/* ---------- Shell ---------- */

.shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 16px;
    padding-top: max(10px, env(safe-area-inset-top));
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 800; font-size: 1.25rem; }
.brand:hover { text-decoration: none; }
.brand-mark {
    display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
    background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; font-size: 1.1rem;
}

.top-actions { display: flex; align-items: center; gap: 10px; }
.lang { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.lang a { padding: 3px 9px; font-size: .75rem; font-weight: 700; color: var(--muted); }
.lang a.on { background: var(--surface-2); color: var(--text); }
.lang a:hover { text-decoration: none; }
.me-chip { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 600; font-size: .9rem; }
.me-chip:hover { text-decoration: none; }
.me-name { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 420px) { .me-name { display: none; } }

.page {
    flex: 1;
    width: 100%; max-width: 1140px; margin: 0 auto;
    display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px;
    padding: 16px 16px 40px;
}
.content, .quiz-scope { width: 100%; max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.rail { display: none; }

@media (min-width: 1100px) {
    .page { grid-template-columns: minmax(0, 1fr) 300px; }
    .rail { display: block; }
    .rail-sticky { position: sticky; top: 80px; }
}

.footer {
    display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px;
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem;
}
.footer nav { display: flex; gap: 14px; }
.footer a { color: var(--muted); }

/* ---------- Buttons & forms ---------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px; padding: 10px 18px;
    border: 1px solid transparent; border-radius: 14px;
    font: inherit; font-weight: 700; line-height: 1.2; cursor: pointer;
    color: var(--text); background: var(--surface-2);
    transition: transform .08s ease, filter .15s ease, background .15s ease;
    text-decoration: none !important;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { color: #fff; background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 65%, var(--brand-2))); box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-danger-text { background: transparent; color: var(--bad); }
.btn-lg { min-height: 54px; font-size: 1.05rem; border-radius: 16px; }
.btn-small { min-height: 34px; padding: 6px 12px; font-size: .85rem; border-radius: 10px; }
.btn-block { display: flex; width: 100%; }

.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .9rem; }
.field small { color: var(--muted); font-weight: 400; }
.field input, .field select {
    font: inherit; font-weight: 500; font-size: 1rem;
    min-height: 48px; padding: 10px 14px;
    border: 2px solid var(--line); border-radius: 12px;
    background: var(--surface); color: var(--text);
}
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); }

.play-form, .stack { display: flex; flex-direction: column; gap: 12px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .85rem; margin: 2px 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.notice { padding: 10px 14px; border-radius: 12px; font-weight: 600; margin: 0; }
.notice-good { background: var(--good-bg); color: var(--good); }
.notice-bad { background: var(--bad-bg); color: var(--bad); }

.icon { width: 1.15em; height: 1.15em; flex: none; }

/* ---------- Cards ---------- */

.card {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 18px; box-shadow: var(--shadow);
}
@media (min-width: 640px) { .card { padding: 24px; } }
a.card { display: block; color: inherit; }
a.card:hover { text-decoration: none; border-color: var(--accent); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.card-head { flex-wrap: wrap; }
.card-head h2 { margin: 0; white-space: nowrap; }
.card-head a { font-size: .9rem; font-weight: 600; white-space: nowrap; }
.card-kicker, .kicker {
    display: inline-block; font-size: .75rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
    color: var(--accent);
}
.meta { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: .9rem; margin: 6px 0 14px; }
.lead { font-size: 1.1rem; font-weight: 600; margin: 4px 0; }
.crumb { font-size: .9rem; font-weight: 600; color: var(--muted); }

.hero { padding: 12px 2px 4px; }
.hero h1 { font-size: clamp(1.7rem, 6vw, 2.6rem); background: linear-gradient(135deg, var(--brand), var(--brand-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { color: var(--muted); font-size: 1.05rem; max-width: 560px; }

.quiz-card {
    background: var(--surface); border-radius: calc(var(--radius) + 4px); overflow: hidden;
    border: 1px solid var(--line); box-shadow: var(--shadow);
}
.quiz-head {
    display: flex; align-items: center; gap: 14px; padding: 18px; color: #fff;
    background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #000));
}
.quiz-head:hover { text-decoration: none; }
.quiz-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; background: rgba(255,255,255,.18); font-size: 1.8rem; flex: none; }
.quiz-icon.big { width: 64px; height: 64px; font-size: 2.2rem; background: color-mix(in srgb, var(--accent) 15%, transparent); }
.quiz-name { display: block; font-weight: 800; font-size: 1.3rem; }
.quiz-desc { display: block; opacity: .9; font-size: .9rem; }
.challenge-strip { padding: 16px 18px 0; }
.challenge-strip h2 { font-size: 1.35rem; margin: 4px 0 0; }
.quiz-card .actions, .quiz-card > .muted { padding: 0 18px 18px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.actions .btn-primary { flex: 1 1 200px; }

.page-head { display: flex; align-items: center; gap: 14px; }
.page-head h1 { margin: 0; }
.challenge-card h2, .challenge-hero h1 { margin-top: 4px; }

.invite {
    display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-radius: var(--radius);
    background: linear-gradient(135deg, var(--gold), #FFB020); color: #2A1A00;
    box-shadow: 0 8px 24px rgba(255, 176, 32, .35);
    animation: pop .4s ease;
}
.invite strong { display: block; font-size: 1.1rem; }

.rules { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 6px; }
.rules li { background: var(--surface-2); border-radius: 12px; padding: 8px 12px; font-weight: 500; }

.link-list { list-style: none; padding: 0; margin: 0; }
.link-list li + li { border-top: 1px solid var(--line); }
.link-list a { display: flex; justify-content: space-between; gap: 12px; padding: 12px 2px; color: var(--text); }
.link-list small { color: var(--muted); }

/* ---------- Leaderboard ---------- */

.tabs { display: flex; gap: 6px; padding: 4px; border-radius: 14px; background: var(--surface-2); margin-bottom: 8px; }
.tab { flex: 1; text-align: center; padding: 8px 6px; border-radius: 10px; font-weight: 700; font-size: .9rem; color: var(--muted); }
.tab.on { background: var(--surface); color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.tab:hover { text-decoration: none; }

.board { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; gap: 10px; padding: 9px 6px; border-radius: 12px; }
.row + .row { border-top: 1px solid var(--line); }
.row.me { background: color-mix(in srgb, var(--accent) 12%, transparent); border-top-color: transparent; }
.rank { width: 2.2rem; text-align: center; font-weight: 800; color: var(--muted); flex: none; }
.rank-1, .rank-2, .rank-3 { font-size: 1.3rem; }
.row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; color: var(--text); }
.row .name em { font-style: normal; color: var(--accent); font-size: .85rem; }
.row .flag { flex: none; }
.row .value { font-weight: 800; white-space: nowrap; }
.row .value small { color: var(--muted); font-weight: 600; }
.board-gap { text-align: center; color: var(--muted); line-height: 1; padding: 4px; }
.board-note { color: var(--muted); margin: 8px 0 0; }
.board-ad { list-style: none; padding: 8px 0; }

.avatar {
    display: inline-grid; place-items: center; flex: none; border-radius: 50%; object-fit: cover;
    background: var(--avatar-bg, var(--brand)); color: #fff; font-weight: 700;
}
.avatar-sm { width: 32px; height: 32px; font-size: .8rem; }
.avatar-md { width: 44px; height: 44px; font-size: 1rem; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.4rem; }

/* ---------- Result ---------- */

.result-hero { text-align: center; display: flex; flex-direction: column; align-items: center; }
.result-hero .meta { justify-content: center; }
.score-big {
    font-size: clamp(3.5rem, 15vw, 5.5rem); font-weight: 800; line-height: 1;
    background: linear-gradient(135deg, var(--accent), var(--brand-2)); -webkit-background-clip: text; background-clip: text; color: transparent;
    animation: pop .5s ease;
}
.score-big span { font-size: 1.1rem; margin-left: 6px; -webkit-text-fill-color: var(--muted); }

.h2h-grid { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin: 10px 0; }
.h2h-side { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 6px; border-radius: 16px; text-align: center; }
.h2h-side strong { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.h2h-side.win { background: var(--good-bg); }
.h2h-score { font-size: 1.6rem; font-weight: 800; }
.h2h-vs { font-weight: 800; color: var(--muted); }
.h2h-verdict { text-align: center; font-weight: 800; font-size: 1.15rem; margin: 0; }

.cta h2 { font-size: 1.35rem; }

.responses { list-style: none; margin: 0; padding: 0; }
.responses li { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.responses li + li { border-top: 1px solid var(--line); }
.resp-name { flex: 1; min-width: 0; color: var(--text); display: flex; flex-direction: column; }
.resp-name small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.resp-score { font-weight: 800; white-space: nowrap; }
.pill { font-size: .8rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.pill-good { background: var(--good-bg); color: var(--good); }
.pill-bad { background: var(--bad-bg); color: var(--bad); }

/* ---------- Share ---------- */

.share { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.share-primary { border: 2px solid var(--accent); background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 8%, var(--surface)), var(--surface)); }
.email-gate { display: flex; flex-direction: column; gap: 12px; }
.email-gate.share-primary { border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.email-gate .share-title, .email-gate .share-hint { margin: 0; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: .875rem; color: var(--muted); line-height: 1.4; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; flex: none; accent-color: var(--accent); }
.code-input { font-size: 1.4rem !important; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }
.share-title { margin-bottom: 4px; }
.share-hint { color: var(--muted); font-size: .9rem; }
.share-buttons { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.sbtn {
    display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 8px 10px;
    border-radius: 12px; border: 0; font: inherit; font-weight: 700; font-size: .9rem; color: #fff; cursor: pointer;
    text-decoration: none !important;
}
.sbtn:active { transform: scale(.98); }
.sbtn-facebook { background: #1877F2; grid-column: span 2; font-size: 1rem; }
.sbtn-whatsapp { background: #25D366; grid-column: span 2; font-size: 1rem; }
.sbtn-messenger { background: linear-gradient(135deg, #0099FF, #A033FF, #FF5280); }
.sbtn-x { background: #000; }
.sbtn-telegram { background: #229ED9; }
.sbtn-copy, .sbtn-more { background: var(--surface-2); color: var(--text); }
.only-touch { display: none; }
@media (pointer: coarse) { .only-touch { display: flex; } .only-desktop { display: none; } }
@media (max-width: 300px) { .sbtn-facebook, .sbtn-whatsapp { grid-column: auto; } }

/* ---------- Play ---------- */

.play { display: flex; flex-direction: column; gap: 12px; }
.play-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-weight: 700; }
.play-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.play-score { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; white-space: nowrap; }
.play-progress { display: flex; justify-content: space-between; color: var(--muted); font-weight: 600; font-size: .9rem; }
.secs { font-variant-numeric: tabular-nums; }
.secs.low { color: var(--bad); animation: pulse 1s infinite; }
.timer { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.timer-fill {
    height: 100%; width: 100%; border-radius: 999px; transform-origin: left center;
    background: linear-gradient(90deg, var(--accent), var(--brand-2));
    animation-name: drain; animation-timing-function: linear; animation-fill-mode: forwards;
}
.timer-fill.stopped { animation-play-state: paused; }
@keyframes drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }

.question-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 16px; box-shadow: var(--shadow); }
.category { display: inline-block; font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); padding: 3px 10px; border-radius: 999px; }
.question { font-size: clamp(1.25rem, 4.8vw, 1.65rem); font-weight: 700; margin: 12px 0 18px; }
.options { display: grid; gap: 10px; }
.option {
    display: flex; align-items: center; gap: 12px; width: 100%; min-height: 58px; padding: 12px 14px;
    border: 2px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--text);
    font: inherit; font-weight: 600; font-size: 1.02rem; text-align: left; cursor: pointer;
    transition: border-color .15s, background .15s, transform .08s;
}
.option:not(:disabled):hover { border-color: var(--accent); }
.option:not(:disabled):active { transform: scale(.99); }
.option:disabled { cursor: default; }
.letter { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 10px; background: var(--surface-2); font-weight: 800; }
.option.picked { border-color: var(--accent); }
.option.correct { border-color: var(--good); background: var(--good-bg); }
.option.correct .letter { background: var(--good); color: #fff; }
.option.wrong { border-color: var(--bad); background: var(--bad-bg); }
.option.wrong .letter { background: var(--bad); color: #fff; }
.option.dimmed { opacity: .5; }

.feedback { border-radius: var(--radius); padding: 18px; border: 2px solid; animation: rise .25s ease; }
.feedback.good { border-color: var(--good); background: var(--good-bg); }
.feedback.bad { border-color: var(--bad); background: var(--bad-bg); }
.feedback-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.feedback-head h2 { margin: 0; font-size: 1.3rem; }
.feedback .answer { font-size: 1.05rem; }
.feedback .reference { color: var(--muted); font-style: italic; font-size: .9rem; }
.feedback .btn { margin-top: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; background: var(--gold); color: #2A1A00; font-weight: 800; font-size: .9rem; }
.play-hint { text-align: center; color: var(--muted); font-size: .8rem; margin: 0; }

.spinner { width: 42px; height: 42px; margin: 24px auto; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }

/* ---------- Profile ---------- */

.profile-head { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.profile-head h1 { margin: 0; font-size: 1.5rem; }
.connect { background: var(--surface-2); border-radius: 14px; padding: 14px; margin-bottom: 16px; }
.danger-zone { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; }

.prose h2 { margin-top: 1.2rem; }
.prose ul { padding-left: 1.2rem; }

/* ---------- Ads ---------- */

.ad { position: relative; text-align: center; margin: 4px 0; min-height: 50px; }
.ad-label { display: block; font-size: .65rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
.ad-top { width: 100%; max-width: 970px; margin: 8px auto 0; padding: 0 16px; }
.ad-top .ad { min-height: 60px; }
.ad-rail { min-height: 600px; }
.ad-play { margin-top: 12px; }
.ad-placeholder .ad-box {
    display: grid; place-items: center; min-height: 90px; border: 2px dashed var(--line); border-radius: 12px;
    color: var(--muted); font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em;
}
.ad-rail.ad-placeholder .ad-box { min-height: 600px; }

/* ---------- Motion ---------- */

@keyframes pop { 0% { transform: scale(.85); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pulse { 50% { opacity: .45; } }
@keyframes spin { to { transform: rotate(360deg); } }
/* The countdown bar is information, not decoration: it keeps animating. */
@media (prefers-reduced-motion: reduce) { :not(.timer-fill), ::before, ::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; } }

/* ---------- Blazor ---------- */

.blazor-error-boundary { background: #b32121; padding: 1rem; color: white; border-radius: 12px; }
.blazor-error-boundary::after { content: "An error has occurred."; }
