/* Quiz as a game round (Features/Quiz): intro, round bar, answer tiles, order and match rows, feedback, new level and result.
   Classes start with .qz- (and .lvl-up). Tokens only (base.css). Motion: transform and opacity; base.css stops it for
   reduced motion, and every animation ends on a state that still shows the information. Sound and taps: js/quiz.js. */

tbm-quiz-question, tbm-quiz-feedback, tbm-quiz-result { display: block; }
.qz { max-width: 720px; margin: 0 auto; overflow-wrap: break-word; }
.qz-lesson { margin: 0 0 var(--space-2); font-size: var(--fs-sm); }
.qz-lesson a { display: inline-block; padding: 10px 0; color: var(--text-muted); text-decoration: none; }
.qz-lesson a:hover { color: var(--link); text-decoration: underline; }

/* ---------- Focus mode: a question and its feedback fill the screen like a game level ---------- */
body:has(tbm-quiz-question, tbm-quiz-feedback) :is(.site-header, .site-footer, .tabbar) { display: none; }
body:has(tbm-quiz-question, tbm-quiz-feedback) .main { padding-top: 10px; padding-bottom: 24px; }
body:has(tbm-quiz-question, tbm-quiz-feedback) :is(.qz-submit-bar, .qz-next) { bottom: calc(10px + env(safe-area-inset-bottom)); }

/* ---------- Round bar: a small console that stays on top ---------- */
.qz-bar {
    position: sticky;
    top: 0;
    z-index: 10;
    margin: 0 -6px var(--space-4);
    padding: 4px 8px;
    border-radius: 0 0 var(--radius) var(--radius);
    background: var(--console);
    color: var(--on-console);
    box-shadow: 0 4px 0 var(--edge), 0 10px 24px -14px rgba(0, 0, 0, .6);
}
.qz-bar-row { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.qz-exit {
    flex: none;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    color: var(--on-console-muted);
    transition: transform .12s var(--ease-out);
}
.qz-exit:hover { color: var(--on-console); background: color-mix(in srgb, var(--on-console) 10%, transparent); }
.qz-exit:active { transform: scale(.9); }
.qz-segments { flex: 1; display: flex; gap: 4px; margin: 0; padding: 0; list-style: none; }
.qz-seg {
    flex: 1;
    height: 10px;
    border-radius: var(--radius-pill);
    background: color-mix(in srgb, var(--on-console) 16%, transparent);
}
.qz-seg.is-right { background: var(--primary); box-shadow: 0 0 8px color-mix(in srgb, var(--primary) 70%, transparent); }
.qz-seg.is-wrong { background: var(--danger); }
.qz-seg.is-now { transform: scaleY(1.4); box-shadow: 0 0 0 2px var(--console), 0 0 0 4px var(--accent); }
.qz-seg.is-now.is-todo { background: var(--on-console); animation: qz-blink 1.4s ease-in-out infinite; }
.qz-count { font-size: 1.05rem; color: var(--on-console-muted); white-space: nowrap; }
.qz-count b { font-size: 1.45rem; color: var(--amber); }
.qz-diff { border-color: var(--border-strong); background: var(--console-2); color: var(--on-console); }
.qz-diff-1 { border-color: var(--primary); }
.qz-diff-2 { border-color: var(--accent); }
.qz-diff-3 { border-color: var(--danger); }
.qz-level { flex: none; display: grid; place-items: center; width: 44px; }
.qz-level .level-badge { --size: 34px; }
.level-badge.is-pulse { animation: qz-badge 0.6s var(--ease-spring); }
.qz-sound { min-width: 44px; min-height: 44px; margin-inline-start: auto; padding: 0; --btn-fg: var(--on-console); }
.qz-sound:hover { background: color-mix(in srgb, var(--on-console) 12%, transparent); }
.qz-sound[aria-pressed="true"] .qz-sound-off, .qz-sound[aria-pressed="false"] .qz-sound-on { display: none; }
.qz-sound[aria-pressed="false"] { --btn-fg: var(--on-console-muted); }

/* ---------- The question: the character asks it ---------- */
.qz-ask { display: flex; align-items: flex-start; gap: 10px; margin-bottom: var(--space-4); }
.qz-ask-mascot { width: 64px; height: auto; margin-top: 4px; }
.qz-stem { margin: 0; font-family: var(--font-text); font-weight: 700; white-space: pre-line; }
.qz-ask .qz-stem {
    position: relative;
    flex: 1;
    min-width: 0;
    padding: 14px 16px;
    border: 2px solid var(--border-strong);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-1);
    font-size: clamp(1.1rem, 3.6vw, 1.4rem);
    line-height: 1.65;
    animation: qz-rise .4s var(--ease-out) both;
}
.qz-ask .qz-stem::before {
    content: "";
    position: absolute;
    top: 22px;
    inset-inline-start: -9px;
    width: 14px;
    height: 14px;
    border: 2px solid var(--border-strong);
    border-top: 0;
    border-inline-end: 0;
    background: var(--surface);
    transform: rotate(45deg);
}
.qz-error { margin-bottom: var(--space-4); animation: qz-shake .45s ease both; }

/* ---------- Answer tiles (mcq, truefalse) ---------- */
.qz-form { margin: 0; }
.qz-tiles { display: grid; gap: 10px; min-width: 0; margin: 0 0 var(--space-4); padding: 0; border: 0; }
.qz-tile {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 60px;
    padding: 10px 14px;
    border: 2px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 4px 0 var(--edge);
    font-weight: 500;
    line-height: 1.5;
    cursor: pointer;
    user-select: none;
    transition: transform .12s var(--ease-out);
    animation: qz-rise .4s var(--ease-out) both;
}
.qz-tile:nth-of-type(2) { animation-delay: .05s; }
.qz-tile:nth-of-type(3) { animation-delay: .1s; }
.qz-tile:nth-of-type(4) { animation-delay: .15s; }
.qz-tile:nth-of-type(n + 5) { animation-delay: .2s; }
.qz-tile:hover { transform: translateY(-2px); border-color: var(--primary); }
.qz-tile:active { transform: translateY(4px); box-shadow: 0 0 0 var(--edge); transition-duration: .04s; }
.qz-radio { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.qz-tile:has(.qz-radio:focus-visible) { box-shadow: 0 4px 0 var(--edge), var(--focus-ring); }
/* Picked: the same turquoise for every tile (true and false too). Green and red mean right and wrong, after grading only. */
.qz-tile:has(.qz-radio:checked) {
    border-color: var(--primary);
    background: var(--primary-soft);
    box-shadow: var(--glow), 0 4px 0 var(--primary-edge);
}
.qz-tile:has(.qz-radio:checked:focus-visible) { box-shadow: var(--glow), 0 4px 0 var(--primary-edge), var(--focus-ring); }
.qz-key {
    flex: none;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--surface-3);
    box-shadow: inset 0 -3px 0 var(--edge);
    color: var(--text);
    font-family: var(--font-title);
    font-size: 1.2rem;
    line-height: 1;
}
.qz-tile:has(.qz-radio:checked) .qz-key {
    background: var(--primary);
    box-shadow: inset 0 -3px 0 var(--primary-edge);
    color: var(--on-primary);
    animation: qz-pop .35s var(--ease-spring) both;
}
.qz-text { flex: 1; min-width: 0; }
.qz-tick { flex: none; color: var(--link); opacity: 0; transform: scale(.4); transition: transform .2s var(--ease-spring), opacity .15s; }
.qz-tile:has(.qz-radio:checked) .qz-tick { opacity: 1; transform: scale(1); }

/* True or false: two big tiles */
.qz-tf { grid-template-columns: 1fr 1fr; }
.qz-tf .qz-tile { flex-direction: column; justify-content: center; gap: 6px; min-height: 128px; font-family: var(--font-title); font-size: 1.5rem; }
.qz-tf .qz-text { flex: none; }
.qz-tf-icon { display: grid; place-items: center; width: 58px; height: 58px; border-radius: 50%; background: var(--surface-3); color: var(--text-muted); }
.qz-tf .qz-tile:has(.qz-radio:checked) .qz-tf-icon { background: var(--primary); color: var(--on-primary); animation: qz-pop .35s var(--ease-spring) both; }

@media (min-width: 700px) {
    .qz-tiles:not(.qz-tf) { grid-template-columns: 1fr 1fr; }
    .qz-ask-mascot { width: 92px; }
    .qz-verdict-art .mascot { width: 120px; height: auto; }
}

/* ---------- Order and match rows ---------- */
.qz-howto { margin: 0 0 var(--space-2); color: var(--text-muted); font-size: var(--fs-sm); }
.qz-howto-tap { font-weight: 500; color: var(--link); }
.qz-rows { display: grid; gap: 10px; margin: 0 0 var(--space-4); padding: 0; list-style: none; }
.qz-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 12px;
    min-height: 64px;
    padding: 8px 12px;
    border: 2px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 4px 0 var(--edge);
    font-weight: 500;
    animation: qz-rise .4s var(--ease-out) both;
}
.qz-row:nth-child(2) { animation-delay: .05s; }
.qz-row:nth-child(3) { animation-delay: .1s; }
.qz-row:nth-child(n + 4) { animation-delay: .15s; }
.qz-row select { font: inherit; color: var(--text); cursor: pointer; }
.qz-row .qz-num {
    flex: none;
    width: 52px;
    height: 52px;
    padding: 0;
    border: 2px dashed var(--border-strong);
    border-radius: 50%;
    background: var(--surface-2);
    font-family: var(--font-title);
    font-size: 1.35rem;
    text-align: center;
    text-align-last: center;
    appearance: none;
}
.qz-num:focus-visible, .qz-pick:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.qz-row:has(.qz-num option:checked:not([value=""])) { border-color: var(--primary); }
.qz-row:has(.qz-num option:checked:not([value=""])) .qz-num {
    border: 2px solid var(--primary-edge);
    background: var(--primary);
    color: var(--on-primary);
    animation: qz-pop .3s var(--ease-spring) both;
}
.qz-row .qz-num.is-dup { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.qz-order-row.is-tappable { cursor: pointer; user-select: none; transition: transform .12s var(--ease-out); }
.qz-order-row.is-tappable:active { transform: translateY(3px); }
.qz-match-row .qz-left { flex: 1 1 180px; font-weight: 700; }
.qz-pick {
    flex: 1 1 200px;
    min-width: 0;
    width: 100%;
    min-height: 48px;
    padding: 6px 10px;
    border: 2px solid var(--border-strong);
    border-radius: 12px;
    background: var(--surface-2);
}
.qz-row:has(.qz-pick option:checked:not([value=""])) { border-color: var(--primary); }
.qz-row:has(.qz-pick option:checked:not([value=""])) .qz-pick { border-color: var(--primary); background: var(--primary-soft); }

/* Match by taps: two columns of chips; a pair shares a colour (--k) and a number. */
.qz-pairs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: var(--space-4); }
.qz-pair-col { display: grid; align-content: start; gap: 8px; margin: 0; padding: 0; list-style: none; }
.qz-chip {
    --c: var(--border-strong);
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 56px;
    padding: 8px 10px;
    border: 2px solid var(--c);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 4px 0 var(--edge);
    color: var(--text);
    font: 500 .95rem/1.4 var(--font-text);
    text-align: start;
    cursor: pointer;
    transition: transform .12s var(--ease-out);
}
.qz-pair-col:last-child .qz-chip { background: var(--surface-2); }
.qz-chip:hover { transform: translateY(-2px); }
.qz-chip:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--edge); }
.qz-chip-tag {
    flex: none;
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border: 2px dashed var(--border-strong);
    border-radius: 50%;
    font-size: 1.05rem;
}
.qz-chip.is-picked { --c: var(--accent); box-shadow: var(--glow-accent), 0 4px 0 var(--accent-edge); transform: translateY(-3px); }
.qz-chip.is-picked .qz-chip-tag { border-color: var(--accent); background: var(--accent-soft); }
.qz-chip.is-paired { --c: var(--pair); background: color-mix(in srgb, var(--pair) 16%, var(--surface)); animation: qz-pop .3s var(--ease-spring); }
.qz-chip.is-paired .qz-chip-tag { border: 0; background: var(--pair); color: var(--navy); }
.qz-chip[data-k="1"] { --pair: var(--primary); }
.qz-chip[data-k="2"] { --pair: var(--accent); }
.qz-chip[data-k="3"] { --pair: var(--candy-blue); }
.qz-chip[data-k="4"] { --pair: var(--candy-pink); }
.qz-chip[data-k="5"] { --pair: var(--candy-green); }
.qz-chip[data-k="6"] { --pair: var(--bronze); }

/* ---------- Answer and next: stay in reach of the thumb ---------- */
.qz-submit-bar, .qz-next {
    position: sticky;
    bottom: calc(var(--tabbar-h) + 10px + env(safe-area-inset-bottom));
    z-index: 5;
}
.qz-submit { box-shadow: 0 4px 0 var(--btn-edge), var(--shadow-2); }
.qz-form:has(.qz-radio):not(:has(.qz-radio:checked)) .qz-submit { opacity: .75; }
.qz-form:has(.qz-radio:checked) .qz-submit { animation: qz-pop .4s var(--ease-spring) both; }
.qz-submit.is-sending { opacity: .75; }
@media (min-width: 900px) {
    .qz-submit-bar, .qz-next { bottom: 16px; }
}
@media (max-width: 400px) {
    .qz-ask .qz-stem { font-size: 1.05rem; padding: 12px 14px; }
    .qz-ask-mascot { width: 48px; }
    .qz-tile { min-height: 54px; }
    .qz-tf .qz-tile { min-height: 108px; }
    .qz-pairs { gap: 8px; }
    .qz-chip { gap: 6px; padding: 6px 8px; font-size: .88rem; }
    .qz-chip-tag { width: 24px; height: 24px; font-size: .9rem; }
}

/* ---------- Feedback: the verdict ---------- */
.qz-verdict {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: var(--space-4);
    padding: 12px 16px 12px 12px;
    border: 2px solid var(--primary);
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--primary-soft), var(--surface) 75%);
    box-shadow: var(--glow), 0 4px 0 var(--primary-edge);
    animation: qz-verdict-in .5s var(--ease-spring) both;
}
.qz-verdict.is-wrong {
    border-color: var(--danger-edge);
    background: linear-gradient(135deg, var(--danger-soft), var(--surface) 75%);
    box-shadow: 0 4px 0 var(--danger-edge);
    animation: qz-shake .5s ease both;
}
.qz-verdict-art { position: relative; flex: none; }
.qz-verdict-body { flex: 1; min-width: 0; }
.qz-verdict-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    color: var(--success);
    font-family: var(--font-title);
    font-size: var(--fs-2xl);
    line-height: 1.15;
}
.is-wrong .qz-verdict-title { color: var(--danger); font-size: var(--fs-xl); }
.qz-verdict-icon {
    display: grid;
    place-items: center;
    flex: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--success);
    color: var(--surface);
    animation: qz-pop .45s var(--ease-spring) .15s both;
}
.is-wrong .qz-verdict-icon { background: var(--danger); }
.qz-cheer { margin: 4px 0 0; font-family: var(--font-title); font-size: var(--fs-md); line-height: 1.4; }
.qz-right-is {
    margin: 8px 0 0;
    padding: 6px 12px;
    border: 2px solid var(--success-edge);
    border-radius: 12px;
    background: var(--surface);
    line-height: 1.5;
}
.qz-right-label { color: var(--success); font-family: var(--font-title); }
.qz-gains { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0 0; }
.qz-xp {
    display: inline-flex;
    align-items: center;
    padding: 2px 12px;
    border-radius: var(--radius-pill);
    background: var(--accent);
    color: var(--on-accent);
    box-shadow: 0 3px 0 var(--accent-edge);
    font-size: 1.25rem;
    animation: qz-xp-in .7s var(--ease-spring) .25s both;
}
.qz-xp-ghost { position: fixed; z-index: 80; margin: 0; pointer-events: none; animation: none; }
.qz-combo {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 12px;
    border-radius: var(--radius-pill);
    background: var(--console);
    color: var(--on-console);
    box-shadow: 0 3px 0 var(--edge);
    font-family: var(--font-title);
    font-size: 1.05rem;
    animation: qz-xp-in .7s var(--ease-spring) .45s both;
}
.qz-combo b { color: var(--amber); }
.qz-flame { color: var(--flame); }
.qz-combo.is-hot {
    font-size: 1.25rem;
    box-shadow: 0 3px 0 var(--edge), 0 0 18px -2px var(--flame);
    animation: qz-xp-in .7s var(--ease-spring) .45s both, qz-hot .5s ease-in-out 1.2s 2;
}
.qz-verdict .hint { margin: 6px 0 0; }

/* Stars that fly out of the character on a right answer (decoration; they end hidden). */
.qz-burst { position: absolute; inset: 0; pointer-events: none; }
.qz-spark {
    position: absolute;
    top: 50%;
    left: 50%;
    margin: -9px;
    color: var(--amber);
    opacity: 0;
    animation: qz-spark 1.1s var(--ease-out) .12s both;
}
.qz-spark:nth-child(1) { --x: -70px; --y: -54px; }
.qz-spark:nth-child(2) { --x: 0; --y: -80px; animation-delay: .16s; }
.qz-spark:nth-child(3) { --x: 70px; --y: -54px; }
.qz-spark:nth-child(4) { --x: 84px; --y: 6px; animation-delay: .2s; }
.qz-spark:nth-child(5) { --x: 54px; --y: 62px; }
.qz-spark:nth-child(6) { --x: -54px; --y: 62px; animation-delay: .18s; }
.qz-spark:nth-child(7) { --x: -84px; --y: 6px; }
.qz-spark:nth-child(8) { --x: 26px; --y: -74px; animation-delay: .24s; }

/* ---------- Feedback: the right answer and the explanation ---------- */
.qz-review-card {
    margin-bottom: var(--space-4);
    padding: 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-1);
    animation: qz-rise .45s var(--ease-out) .1s both;
}
.qz-stem-small { margin-bottom: var(--space-3); font-size: var(--fs-md); line-height: 1.6; }
.qz-review-title { margin: var(--space-3) 0 var(--space-2); font-size: var(--fs-base); color: var(--text-muted); }
.qz-review { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.qz-review-tf { grid-template-columns: 1fr 1fr; }
.qz-review-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
    min-height: 48px;
    margin: 0;
    padding: 8px 12px;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: var(--surface-2);
    color: var(--text-muted);
}
.qz-review-item.is-right { border-color: var(--success-edge); background: var(--success-soft); color: var(--text); font-weight: 500; }
.qz-review-item.is-wrong { border-color: var(--danger-edge); background: var(--danger-soft); color: var(--text); }
.qz-review-icon { flex: none; }
.qz-review-item .qz-text { flex: 1 1 14em; }
.is-right > .qz-review-icon { color: var(--success); }
.is-wrong > .qz-review-icon { color: var(--danger); }
.qz-review-order { counter-reset: qz-step; }
.qz-review-order .qz-review-item { counter-increment: qz-step; }
.qz-review-order .qz-review-item::before {
    content: counter(qz-step);
    display: grid;
    place-items: center;
    flex: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--surface-3);
    color: var(--text);
    font-family: var(--font-title);
}
.qz-review-order .is-right::before { background: var(--success); color: var(--surface); }
.qz-all { margin-top: var(--space-3); }
.qz-all summary, .qz-intro-rules-box summary {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    color: var(--link);
    font-family: var(--font-title);
    cursor: pointer;
}
.qz-all[open] summary { margin-bottom: var(--space-2); }

.qz-explain {
    margin-bottom: var(--space-5);
    padding: 14px 16px;
    border: 2px solid color-mix(in srgb, var(--primary) 40%, var(--border));
    border-inline-start-width: 6px;
    border-radius: var(--radius);
    background: var(--surface-2);
    animation: qz-rise .45s var(--ease-out) .2s both;
}
.qz-explain p { margin: 0 0 var(--space-2); }
.qz-explain-title { display: flex; align-items: center; gap: 6px; color: var(--link); font-family: var(--font-title); font-size: var(--fs-md); }
.qz-explain .qz-page {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin: 0;
    padding: 2px 12px;
    border-radius: var(--radius-pill);
    background: var(--accent-soft);
    color: var(--accent-text);
    font-size: var(--fs-sm);
    font-weight: 500;
}
.qz-next { box-shadow: 0 4px 0 var(--btn-edge), var(--shadow-2); animation: qz-rise .4s var(--ease-out) .3s both; }
.qz-next:active { box-shadow: 0 0 0 var(--btn-edge), var(--shadow-2); }

/* ---------- New level: a full screen moment (js/quiz.js shows it) ---------- */
.lvl-up {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: grid;
    place-items: center;
    padding: 16px;
    overflow: hidden;
    background:
        radial-gradient(22rem 22rem at 50% 42%, color-mix(in srgb, var(--turquoise) 32%, transparent), transparent 70%),
        radial-gradient(color-mix(in srgb, var(--on-console) 8%, transparent) 1.4px, transparent 1.6px) 0 0 / 22px 22px,
        color-mix(in srgb, var(--console) 96%, transparent);
    animation: lvl-fade .3s ease-out both;
}
.lvl-up[hidden] { display: none; }
.lvl-up-card {
    position: relative;
    display: grid;
    justify-items: center;
    gap: 4px;
    width: min(360px, 100%);
    color: var(--on-console);
    text-align: center;
}
.lvl-up-mascot { width: 160px; height: auto; animation: lvl-in .7s var(--ease-spring) .1s both; }
.lvl-up-kicker { margin: 0; color: var(--amber); font-family: var(--font-title); font-size: var(--fs-2xl); line-height: 1.1; animation: qz-xp-in .6s var(--ease-spring) .35s both; }
.lvl-up-badge { --size: 140px; margin: 6px 0; filter: drop-shadow(0 0 24px color-mix(in srgb, var(--amber) 60%, transparent)); animation: lvl-in .7s var(--ease-spring) .2s both; }
.lvl-up-title { margin: 0; color: var(--on-console); font-size: var(--fs-xl); }
.lvl-up-sub { margin: 0 0 var(--space-4); color: var(--on-console-muted); }
.lvl-up-sub b { color: var(--on-console); }
.lvl-up-confetti { position: absolute; inset: 0; pointer-events: none; }
.lvl-up-confetti i {
    position: absolute;
    top: -20px;
    left: calc(var(--i) * 4.2%);
    width: 10px;
    height: 16px;
    border-radius: 3px;
    background: var(--amber);
    opacity: 0;
    animation: lvl-confetti 1.2s cubic-bezier(.3, .6, .5, 1) calc(var(--i) * 25ms) both;
}
.lvl-up-confetti i:nth-child(3n) { background: var(--turquoise); width: 8px; }
.lvl-up-confetti i:nth-child(3n + 1) { background: var(--candy-pink); height: 10px; }
.lvl-up-confetti i:nth-child(4n) { animation-duration: 1.4s; }

/* ---------- Result ---------- */
.qz-result > * { animation: qz-rise .5s var(--ease-out) both; }
.qz-result > :nth-child(3) { animation-delay: .15s; }
.qz-result > :nth-child(4) { animation-delay: .25s; }
.qz-result > :nth-child(5) { animation-delay: .35s; }
.qz-result-hero {
    display: grid;
    justify-items: center;
    gap: 2px;
    margin-bottom: var(--space-4);
    padding-top: 20px;
    overflow: hidden;
    text-align: center;
    background: radial-gradient(120% 70% at 50% 0, var(--primary-soft), var(--surface) 70%);
}
.qz-result-kicker { margin: 4px 0 0; color: var(--text-muted); font-family: var(--font-title); }
.qz-result-title { display: flex; align-items: center; gap: 8px; margin: 0; font-size: var(--fs-2xl); }
.qz-result-trophy { color: var(--amber); filter: drop-shadow(0 3px 0 var(--accent-edge)); }
.qz-stars { align-items: flex-end; margin: 4px 0 8px; }
.qz-stars .icon { width: 48px; height: 48px; }
.qz-stars .icon:nth-child(2) { width: 62px; height: 62px; transform: translateY(-6px); }
/* Stars are stamped one by one. */
.qz-stars .is-on { animation: qz-stamp .45s cubic-bezier(.3, 1.6, .5, 1) .5s both; }
.qz-stars .is-on:nth-child(2) { animation-delay: .85s; }
.qz-stars .is-on:nth-child(3) { animation-delay: 1.2s; }
.qz-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; margin: 8px 0 0; }
.qz-stat { min-width: 0; padding: 10px 4px; border: 2px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.qz-stat dt { color: var(--text-muted); font-size: var(--fs-xs); line-height: 1.4; }
.qz-stat dd { display: flex; align-items: center; justify-content: center; gap: 4px; margin: 2px 0 0; font-size: 1.3rem; line-height: 1.3; white-space: nowrap; }
.qz-stat dd b { font-size: 1.6rem; color: var(--link); }
.qz-stat-xp dd { color: var(--accent-text); }
.qz-result-hero .hint { margin: 8px 0 0; }

.qz-level-card { display: flex; align-items: center; gap: 16px; margin-bottom: var(--space-4); }
.qz-level-body { flex: 1; min-width: 0; }
.qz-level-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 var(--space-2); font-family: var(--font-title); font-size: var(--fs-lg); line-height: 1.3; }
.qz-level-body .hint { margin: var(--space-2) 0 0; }

.qz-result-actions { display: grid; gap: 12px; margin-bottom: var(--space-5); }
.qz-result-more { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.qz-share { background: linear-gradient(160deg, var(--accent-soft), var(--surface) 70%); border-color: var(--accent); }
.qz-share-title { display: flex; align-items: center; gap: 8px; margin: 0 0 var(--space-2); font-size: var(--fs-lg); }
.qz-share-title .icon { color: var(--accent-text); }
.qz-share-line { margin: 0 0 4px; font-family: var(--font-title); font-size: var(--fs-md); line-height: 1.5; }
.qz-share-url { margin: 0 0 var(--space-3); color: var(--text-muted); font-size: var(--fs-xs); overflow-wrap: anywhere; text-align: right; }
.qz-share-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.qz-copied { color: var(--success); font-family: var(--font-title); }

/* ---------- Intro ---------- */
.qz-intro-head { display: flex; align-items: center; gap: 12px; margin-bottom: var(--space-3); }
.qz-intro-head h1 { margin: 0; font-size: var(--fs-lg); }
.qz-intro-lead { font-size: var(--fs-md); }
@media (min-width: 700px) {
    .qz-intro-head h1 { font-size: var(--fs-xl); }
}
.qz-intro-rules { display: grid; gap: 8px; margin: var(--space-2) 0 0; padding: 0; list-style: none; }
.qz-intro-rules li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border: 2px solid var(--border);
    border-radius: 14px;
    background: var(--surface-2);
}
.qz-intro-rules .icon { flex: none; margin-top: 3px; color: var(--link); }
.qz-intro-rules li:nth-child(2n) .icon { color: var(--accent-text); }
.qz-intro-rules-box { margin-top: var(--space-3); }
.qz-intro-actions { display: grid; gap: 12px; }
.qz-intro-actions .inline-form { display: block; }
.qz-intro-actions .inline-form .btn[type="submit"] { width: 100%; }
.qz-intro-login { margin: 0; text-align: center; }
.qz-intro-login a { display: inline-flex; align-items: center; min-height: 44px; }

@keyframes qz-rise { from { opacity: 0; transform: translateY(12px); } }
@keyframes qz-pop { 0% { transform: scale(.7); } 60% { transform: scale(1.08); } }
@keyframes qz-blink { 50% { opacity: .4; } }
@keyframes qz-verdict-in { 0% { opacity: 0; transform: scale(.8); } 60% { transform: scale(1.04); } }
@keyframes qz-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-9px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(3px); }
}
@keyframes qz-xp-in { from { opacity: 0; transform: translateY(14px) scale(.6); } }
@keyframes qz-hot { 25% { transform: scale(1.12) rotate(-4deg); } 75% { transform: scale(1.12) rotate(4deg); } }
@keyframes qz-badge { 40% { transform: scale(1.35) rotate(-8deg); } }
@keyframes qz-stamp { 0% { opacity: 0; transform: scale(2.4) rotate(-30deg); } 70% { opacity: 1; transform: scale(.9); } }
@keyframes qz-spark {
    0% { opacity: 1; transform: translate(0, 0) scale(.3); }
    70% { opacity: 1; }
    100% { opacity: 0; transform: translate(var(--x), var(--y)) scale(1.2) rotate(80deg); }
}
@keyframes lvl-fade { from { opacity: 0; } }
@keyframes lvl-in { 0% { transform: scale(.2) rotate(-25deg); opacity: 0; } 60% { transform: scale(1.12) rotate(5deg); } }
@keyframes lvl-confetti {
    0% { opacity: 1; transform: translateY(0) rotate(0); }
    85% { opacity: 1; }
    100% { opacity: 0; transform: translateY(105vh) rotate(540deg); }
}
@media (prefers-reduced-motion: reduce) {
    .lvl-up-confetti { display: none; }
}
