/* Hub */
.quiz-hero {
    margin: 0 auto;
    padding: 48px var(--gutter) 28px;
    text-align: center;
}

.quiz-hero h1 {
    margin: 0 0 14px;
    font-family: var(--serif);
    font-size: clamp(38px, 5vw, 60px);
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.08;
}

.quiz-hero h1 em { color: var(--accent); font-style: italic; }

.quiz-hero .hero-lead { margin: 0 auto; }

.quiz-setup {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
    gap: 18px;
    align-items: stretch;
    margin: 0 auto;
    padding: 0 var(--gutter);
}

.quiz-step {
    margin: 0;
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.quiz-step legend {
    display: flex;
    align-items: center;
    gap: 12px;
    float: left;
    width: 100%;
    margin-bottom: 18px;
    padding: 0;
    font-family: var(--serif);
    font-size: 23px;
    font-weight: 600;
    line-height: 1.3;
}

.quiz-step legend span {
    display: grid;
    place-items: center;
    flex: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--on-accent);
    font-family: var(--sans);
    font-size: 15px;
    font-weight: 700;
}

.scope-grid {
    clear: both;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.scope-card, .count-card { position: relative; cursor: pointer; }

.scope-card input, .count-card input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.scope-card-body {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    height: 100%;
    padding: 14px 16px;
    border: 1.5px solid var(--line);
    border-radius: 14px;
    line-height: 1.35;
    transition: border-color .15s, background .15s;
}

.scope-card-body strong { font-weight: 600; }

.scope-card-body small { color: var(--muted); font-size: 14px; }

.scope-card-all .scope-card-body {
    justify-content: center;
    background: color-mix(in srgb, var(--accent) 7%, transparent);
}

.scope-card:hover .scope-card-body, .count-card:hover span { border-color: var(--accent); }

.scope-card input:checked + .scope-card-body {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 11%, transparent);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.scope-card input:focus-visible + .scope-card-body, .count-card input:focus-visible + span {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.scope-card.is-muted { opacity: .5; }

.scope-card.is-muted input:checked + .scope-card-body {
    border-color: var(--line);
    background: transparent;
    box-shadow: none;
}

.topic-picker { display: block; margin-top: 16px; }

.topic-picker > span {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 15px;
}

.topic-picker select {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    background: var(--bg);
    color: var(--ink);
    font: inherit;
}

.count-grid {
    clear: both;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.count-card span {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 8px;
    border: 1.5px solid var(--line);
    border-radius: 14px;
    transition: border-color .15s, background .15s;
}

.count-card strong {
    font-family: var(--serif);
    font-size: 36px;
    font-weight: 600;
    line-height: 1.15;
}

.count-card small { color: var(--muted); font-size: 14px; text-align: center; }

.count-card input:checked + span {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 11%, transparent);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.count-card.is-disabled { opacity: .4; cursor: not-allowed; }

.quiz-note { margin: 12px 0 0; color: var(--muted); font-size: 15px; text-align: center; }

.quiz-start {
    grid-column: 1 / -1;
    justify-content: center;
    width: 100%;
    padding: 17px;
    font-size: 18px;
    cursor: pointer;
    font-family: inherit;
}

.quiz-history {
    margin: 44px auto 0;
    padding: 0 var(--gutter);
}

.quiz-history h2 {
    margin: 0 0 12px;
    font-family: var(--serif);
    font-size: 26px;
    font-weight: 600;
}

.quiz-history ul {
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
    list-style: none;
}

.quiz-history li {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 11px 18px;
}

.quiz-history li + li { border-top: 1px solid var(--line); }

.history-name { flex: 1; min-width: 0; font-weight: 500; }

.history-detail { color: var(--muted); font-size: 15px; white-space: nowrap; }

.history-pass { color: var(--good); }

.history-fail { color: var(--bad); }

/* Player */
.quiz-player {
    min-height: calc(100vh - var(--header-height) - 110px);
    margin: 0 auto;
    padding: 24px var(--gutter) 0;
    display: flex;
    flex-direction: column;
}

.quiz-stage {
    flex: 1;
    display: grid;
    align-content: center;
}

.quiz-player.is-finished .quiz-stage { align-content: start; }

.quiz-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px 16px;
    align-items: center;
    margin-bottom: 26px;
}

.quiz-bar-title { min-width: 0; line-height: 1.3; }

.quiz-bar-title strong { display: block; font-weight: 600; }

.quiz-bar-title span { color: var(--muted); font-size: 14px; }

.quiz-bar-stats {
    display: flex;
    align-items: center;
    gap: 16px;
    font-variant-numeric: tabular-nums;
}

.quiz-timer { color: var(--muted); font-size: 15px; }

.quiz-counter { font-size: 15px; color: var(--muted); }

.quiz-counter b { color: var(--ink); font-size: 20px; }

.quiz-progress {
    grid-column: 1 / -1;
    height: 8px;
    overflow: hidden;
    border-radius: 99px;
    background: var(--surface-2);
}

.quiz-progress span {
    display: block;
    height: 100%;
    border-radius: 99px;
    background: var(--accent);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform .35s ease;
}

.quiz-card {
    padding: clamp(22px, 3.4vw, 56px);
    border: 1px solid var(--line);
    border-radius: 24px;
    background: var(--surface);
    box-shadow: var(--shadow);
    animation: quiz-in .28s ease both;
}

@keyframes quiz-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
}

.quiz-topic {
    margin: 0 0 12px;
    color: var(--accent);
    font-size: 14px;
    font-weight: 600;
}

.quiz-question {
    margin: 0 0 26px;
    font-family: var(--serif);
    font-size: clamp(24px, 3vw, 46px);
    font-weight: 500;
    line-height: 1.35;
}

.quiz-blank {
    display: inline-block;
    min-width: 3.2em;
    margin: 0 2px;
    border-bottom: 3px solid var(--accent);
    color: var(--accent);
    font-weight: 600;
    text-align: center;
    line-height: 1.1;
}

.quiz-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.quiz-option {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: clamp(12px, 1.2vw, 20px) clamp(14px, 1.3vw, 22px);
    border: 1.5px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: clamp(17px, 1.2vw, 21px);
    line-height: 1.35;
    text-align: left;
    cursor: pointer;
    transition: border-color .12s, background .12s, transform .12s;
}

.quiz-option:hover:not(:disabled) {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 6%, transparent);
    transform: translateY(-1px);
}

.quiz-letter {
    display: grid;
    place-items: center;
    flex: none;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 15px;
    font-weight: 700;
}

.quiz-option:disabled { cursor: default; opacity: .62; }

.quiz-option.is-correct {
    border-color: var(--good);
    background: var(--good-soft);
    color: var(--good);
    font-weight: 600;
    opacity: 1;
}

.quiz-option.is-correct .quiz-letter { background: var(--good); color: var(--surface); }

.quiz-option.is-wrong {
    border-color: var(--bad);
    background: var(--bad-soft);
    color: var(--bad);
    opacity: 1;
}

.quiz-option.is-wrong .quiz-letter { background: var(--bad); color: var(--surface); }

.quiz-feedback {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-top: 20px;
    animation: quiz-in .2s ease both;
}

.quiz-feedback strong { font-size: 19px; }

.quiz-feedback.is-good strong { color: var(--good); }

.quiz-feedback.is-bad strong { color: var(--bad); }

.quiz-next { cursor: pointer; font-family: inherit; font-size: 16px; }

.quiz-loading, .quiz-error {
    padding: 80px 20px;
    color: var(--muted);
    text-align: center;
}

.quiz-loading span {
    display: block;
    width: 36px;
    height: 36px;
    margin: 0 auto 14px;
    border: 3px solid var(--line);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: quiz-spin .8s linear infinite;
}

@keyframes quiz-spin { to { transform: rotate(360deg); } }

.quiz-error h2 { color: var(--ink); font-family: var(--serif); }

.quiz-error .button { cursor: pointer; font-family: inherit; }

/* Result */
.quiz-player.is-finished .quiz-bar-stats, .quiz-player.is-finished .quiz-progress { display: none; }

.quiz-result { animation: quiz-in .3s ease both; }

.result-summary {
    display: flex;
    align-items: center;
    gap: 34px;
    padding: 30px;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.score-ring { position: relative; flex: none; width: 170px; height: 170px; }

.score-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); stroke-width: 10; }

.score-ring-track { stroke: var(--surface-2); }

.score-ring-arc {
    stroke: var(--good);
    stroke-linecap: round;
    transition: stroke-dashoffset 1s ease;
}

.score-ring.is-fail .score-ring-arc { stroke: var(--tip-line); }

.score-ring-label {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
}

.score-ring-label strong {
    font-family: var(--serif);
    font-size: 42px;
    font-weight: 600;
}

.result-copy { flex: 1; min-width: 0; }

.result-copy h2 {
    margin: 0 0 4px;
    font-family: var(--serif);
    font-size: 32px;
    font-weight: 600;
    line-height: 1.2;
}

.result-copy > p { margin: 0 0 16px; color: var(--muted); }

.result-stats { display: flex; gap: 28px; margin: 0; }

.result-stats div { display: flex; flex-direction: column-reverse; }

.result-stats dt { color: var(--muted); font-size: 14px; }

.result-stats dd {
    margin: 0;
    font-family: var(--serif);
    font-size: 26px;
    font-weight: 600;
    line-height: 1.25;
}

.result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 18px 0 0;
}

.result-actions .button { cursor: pointer; font-family: inherit; font-size: 16px; }

.result-block { margin-top: 34px; }

.result-block h3 {
    margin: 0 0 12px;
    font-family: var(--serif);
    font-size: 24px;
    font-weight: 600;
}

.result-topics {
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
    list-style: none;
}

.result-topics li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 18px;
}

.result-topics li + li { border-top: 1px solid var(--line); }

.result-topics span { color: var(--muted); font-size: 15px; white-space: nowrap; }

.review-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.review-item {
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
}

.review-item p { margin: 0; line-height: 1.5; }

.review-question { margin-bottom: 8px !important; font-weight: 500; }

.review-wrong { color: var(--bad); text-decoration: line-through; }

.review-right { color: var(--good); font-weight: 600; }

.review-wrong::before { content: "✗ "; }

.review-right::before { content: "✓ "; }

.review-link { display: inline-block; margin-top: 6px; font-size: 14px; }

/* Invitations under lessons */
.quiz-cta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 22px;
    margin-top: 40px;
    padding: 24px 26px;
    border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line));
    border-radius: 20px;
    background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}

.quiz-cta + .quiz-cta { margin-top: 14px; }

.quiz-cta-level {
    border-color: color-mix(in srgb, var(--level) 40%, var(--line));
    background: color-mix(in srgb, var(--level) 9%, var(--surface));
}

.quiz-cta h2 {
    margin: 0 0 2px;
    font-family: var(--serif);
    font-size: 25px;
    font-weight: 600;
    line-height: 1.25;
}

.quiz-cta p { margin: 0; color: var(--muted); font-size: 15px; }

.quiz-cta .quiz-cta-eyebrow { color: var(--accent); font-size: 13px; font-weight: 700; }

.quiz-cta .quiz-cta-best { margin-top: 4px; color: var(--ink); font-weight: 600; }

.quiz-cta .button { flex: none; }

@media (min-width: 1001px) {
    .count-grid {
        grid-template-columns: minmax(0, 1fr);
        grid-auto-rows: 1fr;
    }

    .count-card span { height: 100%; justify-content: center; }
}

@media (max-width: 1000px) {
    .quiz-setup { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 760px) {
    .quiz-options { grid-template-columns: minmax(0, 1fr); }

    .quiz-stage { align-content: start; }
}

@media (max-width: 620px) {
    .quiz-hero { padding: 40px 16px 26px; }

    .quiz-step { padding: 18px; }

    .scope-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

    .quiz-player { padding-top: 16px; }

    .quiz-card { padding: 22px 18px; border-radius: 20px; }

    .quiz-option { font-size: 17px; }

    .result-summary { flex-direction: column; gap: 18px; padding: 22px; text-align: center; }

    .score-ring { width: 150px; height: 150px; }

    .result-stats { justify-content: center; }

    .quiz-cta { flex-direction: column; align-items: stretch; text-align: center; }

    .quiz-cta .button { justify-content: center; }

    .count-card strong { font-size: 30px; }
}

@media (prefers-reduced-motion: reduce) {
    .quiz-card, .quiz-feedback, .quiz-result { animation: none; }

    .score-ring-arc { transition: none; }
}

/* Level exam result */
.exam-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px 18px;
    margin: 18px 0 22px;
    padding: 18px 20px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: var(--surface-2);
    font-weight: 600;
    line-height: 1.5;
}

.exam-banner p { flex: 1 1 280px; margin: 0; }

.exam-banner.is-pass { border-color: color-mix(in srgb, var(--good) 40%, transparent); background: var(--good-soft); color: var(--good); }

.exam-banner.is-fail { border-color: color-mix(in srgb, var(--bad) 35%, transparent); background: var(--bad-soft); color: var(--bad); }

.exam-banner .button { flex: none; }
