:root {
    color-scheme: light;
    --ink: #3a3350;
    --muted: #8a8299;
    --navy: #6a45f0;
    --purple: #7c5cff;
    --teal: #22c3b0;
    --yellow: #ffc94d;
    --accent: #ff6fa5;
    --accent-deep: #7c5cff;
    --surface: #fff;
    --line: rgba(58, 51, 80, 0.12);
    --ok: #16a34a;
    --bad: #e5484d;
    --font-sans: "Nunito", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-brand: "Baloo 2", "Nunito", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.6;
    color: var(--ink);
    background: linear-gradient(180deg, #fef8ee 0%, #f6f2ff 55%, #eef2ff 100%);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-deep); font-weight: 700; }
a:hover { color: var(--navy); }

.site-header {
    background: linear-gradient(135deg, var(--purple) 0%, #a78bff 100%);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 20;
    box-shadow: 0 6px 18px rgba(124, 92, 255, 0.25);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    padding: 12px 16px;
    flex-wrap: wrap;
}

.brand {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1 1 auto;
    min-width: 0;
    color: inherit;
    text-decoration: none;
}

.header-tagline {
    margin: 0;
    font-size: .95rem;
    font-weight: 600;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.92);
    max-width: 42rem;
}

.nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
}

.nav-toggle-bars {
    display: block;
    width: 20px;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
    box-shadow: 0 -6px 0 currentColor, 0 6px 0 currentColor;
}

.site-nav {
    flex: 1 1 auto;
    min-width: 0;
}

.site-nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 4px 6px;
}

.site-nav-list a {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 6px 10px;
    border-radius: 999px;
    color: #fff;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1.3;
    white-space: nowrap;
}

.site-nav-list a:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.site-nav-list .bi {
    font-size: 0.95rem;
    opacity: 0.9;
}

.header-install {
    flex-shrink: 0;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}

.header-help {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.header-help:hover {
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
}

.header-profile {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 1.15rem;
    text-decoration: none;
    cursor: pointer;
}

.header-profile:hover {
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
}

.header-profile-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.brand-title {
    display: block;
    font-family: var(--font-brand);
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: 0.01em;
    line-height: 1.15;
}


.site-main {
    flex: 1;
    padding: 24px 16px 48px;
    max-width: 920px;
}

.card-panel {
    background: var(--surface);
    border: none;
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 12px 32px rgba(124, 92, 255, 0.14);
    margin-bottom: 28px;
}

.section-title {
    font-family: var(--font-brand);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--navy);
    letter-spacing: -0.01em;
    margin: 0 0 16px;
}

.quiz-form .form-row {
    margin-bottom: 16px;
}

.quiz-form .form-row > label {
    display: block;
    font-weight: 800;
    margin-bottom: 6px;
}

.quiz-form select {
    width: 100%;
    max-width: 420px;
    min-height: 44px;
    padding: 10px 14px;
    border-radius: 14px;
    border: 2px solid var(--line);
    background: #fffdf8;
    font: inherit;
    font-weight: 600;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.quiz-form select:focus {
    outline: none;
    border-color: var(--navy);
    box-shadow: 0 0 0 4px rgba(124, 92, 255, 0.15);
}

.timed-fieldset,
.difficulty-fieldset,
.share-protect-fieldset {
    border: 2px dashed var(--yellow);
    border-radius: 16px;
    background: #fff9ea;
    padding: 14px 16px;
    margin: 16px 0;
}

.difficulty-fieldset {
    border-color: var(--teal);
    background: #edfaf7;
}

.share-protect-fieldset {
    border-color: var(--accent);
    background: #fff0f6;
}

.timed-fieldset legend,
.difficulty-fieldset legend,
.share-protect-fieldset legend {
    padding: 0 8px;
    font-size: .8rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
}

.difficulty-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 20px;
}

.checkbox-row {
    display: flex;
    gap: 8px;
    align-items: center;
    font-weight: 700;
}

input[type="checkbox"],
input[type="radio"] {
    accent-color: var(--navy);
    width: 1.15rem;
    height: 1.15rem;
}

.timed-options,
.share-expiry-options {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.time-unit-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.time-unit-choice {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    margin: 0;
}

.timed-limit-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.timed-limit-label {
    margin: 0;
    font-weight: 600;
}

.form-hint {
    font-size: .9rem;
    color: var(--muted);
}

.field-hint {
    font-size: .85rem;
    color: var(--muted);
    margin: 6px 0 0;
}

.field-label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
}

.picker-actions {
    display: flex;
    gap: 8px;
    margin: 8px 0 10px;
}

.picker-btn {
    padding: 8px 14px;
    min-height: 40px;
    font: inherit;
    font-size: .85rem;
    font-weight: 700;
    border-radius: 999px;
    border: 2px solid var(--line);
    background: #fff;
    color: var(--navy);
    cursor: pointer;
}

.picker-btn:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
}

.picker-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
    gap: 10px 14px;
    max-height: 260px;
    overflow-y: auto;
    padding: 12px 14px;
    border: 2px solid var(--line);
    border-radius: 14px;
    background: #fafbfc;
}

.checkbox-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: .9rem;
    font-weight: 500;
    margin: 0;
    cursor: pointer;
    line-height: 1.4;
}

.checkbox-item input[type="checkbox"] {
    width: 1.05rem;
    height: 1.05rem;
    margin: 0.15rem 0 0;
    flex-shrink: 0;
    cursor: pointer;
}

.checkbox-item-text {
    flex: 1;
    min-width: 0;
    word-break: break-word;
}

.qty-stepper {
    display: inline-flex;
    align-items: stretch;
    border-radius: 999px;
    overflow: hidden;
    background: #f6f2ff;
    padding: 4px;
    gap: 4px;
    user-select: none;
}

.qty-stepper.is-disabled {
    opacity: 0.55;
    pointer-events: none;
}

.qty-stepper-input {
    width: 3.5rem;
    padding: 8px 6px;
    border: none;
    border-radius: 999px;
    text-align: center;
    font: inherit;
    font-weight: 800;
    color: var(--navy);
    background: transparent;
    -moz-appearance: textfield;
}

.qty-stepper-input:disabled {
    color: var(--muted);
}

.qty-stepper-input::-webkit-outer-spin-button,
.qty-stepper-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.qty-stepper-btn {
    width: 2.5rem;
    min-width: 40px;
    min-height: 40px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--navy);
    color: #fff;
    font-size: 1.15rem;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
    touch-action: manipulation;
}

.qty-stepper-btn:hover:not(:disabled) {
    background: var(--purple);
}

.qty-stepper-btn:active:not(:disabled) {
    background: #5a3adb;
}

.qty-stepper-btn:disabled {
    background: #c7bfe0;
    cursor: not-allowed;
}

.type-grid {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

.type-grid a {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 64px;
    padding: 14px;
    background: var(--purple);
    border-radius: 18px;
    text-decoration: none;
    color: #fff;
    font-weight: 800;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
    transition: transform .15s ease, box-shadow .15s ease;
}

.type-grid a:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.12);
}

.type-grid li:nth-child(5n+2) a { background: var(--teal); }
.type-grid li:nth-child(5n+3) a { background: var(--accent); }
.type-grid li:nth-child(5n+4) a { background: var(--yellow); color: var(--ink); }
.type-grid li:nth-child(5n+5) a { background: #4fb0ff; }

.quiz-items-overview {
    margin-top: 32px;
}

.item-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.item-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 999px;
    background: var(--surface);
    border: 2px solid var(--line);
    color: var(--navy);
    font-weight: 700;
    font-size: .85rem;
    text-decoration: none;
    transition: border-color .15s ease, transform .15s ease, background .15s ease;
}

.item-chip:hover {
    border-color: var(--accent);
    background: #fdf1f6;
    color: var(--navy);
    transform: translateY(-1px);
}

.item-chip .count {
    color: var(--muted);
    font-weight: 600;
    font-size: .8rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    min-height: 44px;
    padding: 12px 22px;
    border: 2px solid transparent;
    border-radius: 999px;
    font: inherit;
    font-weight: 800;
    font-size: .95rem;
    text-decoration: none;
    cursor: pointer;
    touch-action: manipulation;
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-deep));
    color: #fff;
    box-shadow: 0 8px 20px rgba(255, 111, 165, 0.35);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(255, 111, 165, 0.45);
    color: #fff;
}

.btn:disabled {
    opacity: .55;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
    outline: none;
    border-color: transparent;
}

.btn-outline-primary {
    background: #fff;
    border-color: var(--navy);
    color: var(--navy);
}

.btn-outline-primary:hover {
    background: var(--navy);
    color: #fff;
}

.btn-link {
    background: transparent;
    border: none;
    color: var(--navy);
    padding: 8px 4px;
    box-shadow: none;
}

.btn-link:hover {
    color: var(--accent);
}

.btn-lg {
    padding: 16px 28px;
    font-size: 1.05rem;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 4px;
}

.form-actions .btn {
    flex: 1 1 140px;
}

.share-error-banner {
    margin: 0 0 16px;
    padding: 12px 16px;
    border-radius: 14px;
    background: #fdecee;
    border: 2px solid var(--bad);
    color: var(--bad);
    font-weight: 700;
    font-size: .9rem;
}

.share-result {
    margin-top: 16px;
    padding: 14px 16px;
    background: #f6f2ff;
    border: 2px dashed var(--purple);
    border-radius: 16px;
}

.share-result-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.share-url-input {
    flex: 1 1 200px;
    min-width: 0;
    padding: 10px 12px;
    border-radius: 12px;
    border: 2px solid var(--line);
    font: inherit;
    font-size: .85rem;
    background: #fff;
    color: var(--ink);
}

.share-url-input:focus {
    outline: none;
    border-color: var(--navy);
    box-shadow: 0 0 0 4px rgba(124, 92, 255, 0.15);
}

.share-result-msg {
    margin: 8px 0 0;
    font-size: .85rem;
    font-weight: 700;
    color: var(--ok);
    min-height: 1.2em;
}

.share-result-msg.error {
    color: var(--bad);
}

.quiz-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 16px;
}

.quiz-mode-label {
    margin: 0;
    color: var(--muted);
    font-size: .95rem;
}

.quiz-progress-row {
    display: flex;
    align-items: center;
    gap: 16px;
}

.quiz-progress-main {
    flex: 1 1 auto;
    min-width: 0;
}

.progress-wrap {
    height: 12px;
    background: rgba(124, 92, 255, .12);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--teal), var(--navy));
    transition: width .25s ease;
}

.progress-text {
    font-size: .9rem;
    color: var(--muted);
}

.timer-ring {
    position: relative;
    width: 68px;
    height: 68px;
    flex-shrink: 0;
}

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

.timer-ring-track {
    fill: none;
    stroke: rgba(124, 92, 255, .15);
    stroke-width: 8;
}

.timer-ring-progress {
    fill: none;
    stroke: var(--navy);
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s linear, stroke .25s ease;
}

.timer-ring.is-low .timer-ring-progress {
    stroke: var(--bad);
}

.timer-ring-value {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .85rem;
    font-weight: 800;
    color: var(--navy);
}

.timer-ring.is-low .timer-ring-value {
    color: var(--bad);
}

.question-card {
    background: var(--surface);
    border: none;
    border-radius: 20px;
    padding: 22px;
    margin: 16px 0;
    box-shadow: 0 10px 26px rgba(124, 92, 255, 0.12);
}

.q-meta {
    font-size: .85rem;
    color: var(--muted);
    margin: 0 0 8px;
}

.q-text {
    font-size: 1.2rem;
    font-weight: 600;
    line-height: 1.45;
    margin: 0 0 16px;
}

.options {
    display: grid;
    gap: 10px;
}

.option-btn {
    text-align: left;
    min-height: 48px;
    padding: 13px 16px;
    border-radius: 14px;
    border: 2px solid var(--line);
    background: #fafbfc;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
}

.option-btn:hover:not(:disabled) {
    border-color: var(--accent);
}

.option-btn.is-correct {
    background: #e8f9ee;
    border-color: var(--ok);
    color: var(--ok);
}

.option-btn.is-wrong {
    background: #fdecee;
    border-color: var(--bad);
    color: var(--bad);
}

.quiz-results, .quiz-review {
    background: var(--surface);
    border: none;
    border-radius: 20px;
    padding: 22px;
    box-shadow: 0 10px 26px rgba(124, 92, 255, 0.12);
}

.quiz-results h2, .quiz-review h2 {
    font-family: var(--font-brand);
    color: var(--navy);
    margin: 0 0 16px;
}

.quiz-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0 0 18px;
    padding: 14px 16px;
    background: #f6f2ff;
    border-radius: 14px;
}

.quiz-detail-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    font-size: .9rem;
}

.quiz-detail-row dt {
    flex: 0 0 auto;
    min-width: 80px;
    font-weight: 800;
    color: var(--navy);
}

.quiz-detail-row dd {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    color: var(--ink);
}

.score-chart-wrap {
    margin: 0 0 18px;
}

.score-chart {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 20px 28px;
    padding: 16px;
    border-radius: 12px;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid var(--line);
}

.score-donut {
    position: relative;
    width: 132px;
    height: 132px;
    flex-shrink: 0;
}

/* Drawn as three stacked SVG circle strokes (not a CSS conic-gradient) so it
   renders identically on screen and in the html2canvas-based PDF export,
   which doesn't reliably capture conic-gradient backgrounds. */
.score-donut-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.score-donut-track {
    fill: none;
    stroke: #d5dde8;
    stroke-width: 10;
}

.score-donut-seg {
    fill: none;
    stroke-width: 10;
}

.score-donut-seg.is-correct { stroke: var(--ok); }
.score-donut-seg.is-wrong { stroke: var(--bad); }
.score-donut-seg.is-skipped { stroke: #d5dde8; }

.score-donut-hole {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 84px;
    height: 84px;
    border-radius: 50%;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 0 1px var(--line);
}

.score-donut-fraction {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--navy);
    line-height: 1.2;
}

.score-donut-label {
    font-size: .75rem;
    color: var(--muted);
    font-weight: 600;
}

.score-summary-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex-shrink: 0;
}

.score-summary-label {
    font-size: .8rem;
    color: var(--muted);
    font-weight: 600;
}

.score-summary-value {
    font-size: 1.9rem;
    font-weight: 800;
    color: var(--navy);
    line-height: 1.1;
}

.score-bar-chart {
    flex: 1;
    min-width: min(100%, 220px);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.score-bar-row {
    display: grid;
    grid-template-columns: 5.5rem 1fr 2rem;
    align-items: center;
    gap: 10px;
    font-size: .88rem;
}

.score-bar-name {
    font-weight: 600;
    color: var(--ink-soft, var(--muted));
}

.score-bar-track {
    height: 12px;
    border-radius: 999px;
    background: #e2e8f0;
    overflow: hidden;
}

.score-bar-fill {
    height: 100%;
    border-radius: 999px;
    min-width: 0;
    transition: width .35s ease;
}

.score-bar-fill.is-correct {
    background: linear-gradient(90deg, #2d9f6a, var(--ok));
}

.score-bar-fill.is-wrong {
    background: linear-gradient(90deg, #e05252, var(--bad));
}

.score-bar-fill.is-skipped {
    background: #94a3b8;
}

.score-bar-count {
    font-weight: 700;
    text-align: right;
    color: var(--navy);
}

.score-summary {
    font-size: 1.15rem;
    font-weight: 700;
}

.encouragement {
    color: var(--muted);
}

.results-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.pdf-download-ready {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.review-list {
    margin-top: 4px;
}

.review-item {
    border-top: 1px solid var(--line);
    padding: 16px 0;
}

.review-item:first-child {
    border-top: none;
    padding-top: 8px;
}

.review-item-layout {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.review-status-icon {
    flex-shrink: 0;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.65rem;
    font-weight: 800;
    line-height: 1;
}

.review-status-icon.is-correct {
    color: #fff;
    background: linear-gradient(145deg, #2d9f6a, var(--ok));
    box-shadow: 0 4px 14px rgba(30, 125, 79, 0.35);
}

.review-status-icon.is-wrong {
    color: #fff;
    background: linear-gradient(145deg, #e05252, var(--bad));
    box-shadow: 0 4px 14px rgba(180, 35, 24, 0.3);
}

.review-item-body {
    flex: 1;
    min-width: 0;
}

.review-item-body h3 {
    margin: 4px 0 10px;
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.45;
}

.review-status-text {
    margin: 0;
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.review-correct .review-status-text {
    color: var(--ok);
}

.review-wrong .review-status-text {
    color: var(--bad);
}

.review-wrong .your-answer {
    color: var(--bad);
    font-weight: 700;
}

.review-correct .your-answer {
    color: var(--ok);
    font-weight: 700;
}

.explanation {
    color: var(--muted);
    font-size: .95rem;
}

.verse-ref {
    color: var(--accent-deep);
}

.quiz-error {
    color: var(--bad);
    font-weight: 600;
}

.site-footer {
    background: linear-gradient(135deg, #2e2846, #3d2f5c);
    color: #e3daf7;
    padding: 26px 16px 34px;
    text-align: center;
}

.footer-verse {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 12px;
}

.site-footer .footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    font-size: .9rem;
}

.site-footer .footer-link {
    color: #e3daf7;
    font-weight: 600;
    text-decoration: none;
}

.site-footer .footer-link:hover {
    color: var(--yellow);
}

.site-footer .footer-separator {
    opacity: .35;
}

.site-footer .footer-visitors {
    font-weight: 800;
    color: var(--yellow);
}

.pwa-install-banner {
    position: fixed;
    bottom: 12px;
    left: 12px;
    right: 12px;
    z-index: 50;
    max-width: 520px;
    margin: 0 auto;
}

.pwa-banner-inner {
    display: flex;
    gap: 12px;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    box-shadow: var(--shadow, 0 12px 30px rgba(0,0,0,.15));
}

.pwa-btn-install, .pwa-btn-cancel {
    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    font: inherit;
    cursor: pointer;
}

.pwa-btn-install {
    background: var(--navy);
    color: #fff;
}

.site-nav {
    flex: 1 1 100%;
    order: 10;
    padding-top: 8px;
    margin-top: 4px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.site-nav[hidden] {
    display: none !important;
}

.site-nav-list {
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
}

.site-nav-list a {
    white-space: normal;
    padding: 10px 12px;
}

@media (min-width: 768px) {
    .header-inner { padding: 14px 20px; }
    .site-main { padding: 32px 20px 56px; }
}

@media (max-width: 768px) {
    .site-header { position: static; }
}

@media (max-width: 480px) {
    .site-main { padding: 16px 12px 40px; }
    .card-panel { padding: 18px 16px; border-radius: 20px; }
    .section-title { font-size: 1.2rem; }
    .header-inner { padding: 14px 16px; }
    .brand { align-items: center; text-align: center; }
    .brand-title { font-size: 2rem; }
    .header-tagline { font-size: .85rem; }
    .quiz-form select { max-width: 100%; }
    .type-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .type-grid a { min-height: 56px; padding: 12px; font-size: .9rem; }
    .timed-limit-row { flex-direction: column; align-items: flex-start; }
    .results-actions { flex-direction: column; align-items: stretch; }
    .results-actions .btn { width: 100%; }
    .quiz-actions .btn { width: 100%; }
    .score-chart { flex-direction: column; align-items: flex-start; }
    .timer-ring { width: 56px; height: 56px; }
    .timer-ring-value { font-size: .75rem; }
}

.report-mistake {
    margin-top: 14px;
    font-size: .85rem;
}

.report-mistake .report-toggle {
    padding: 4px 0;
    color: var(--muted);
    text-decoration: underline;
    cursor: pointer;
}

.report-mistake .report-toggle:disabled {
    text-decoration: none;
    cursor: default;
}

.report-form fieldset {
    border: 0;
    margin: 8px 0;
    padding: 0;
}

.report-form legend {
    font-weight: 600;
    margin-bottom: 6px;
}

.report-option {
    display: block;
    padding: 4px 0;
    cursor: pointer;
}

.report-status {
    margin: 4px 0;
    color: var(--muted);
}

.report-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Leaderboard modal, player info, and leaderboard.php page */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(58, 51, 80, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 1000;
}

.modal-box {
    background: var(--surface);
    border-radius: 20px;
    padding: 24px;
    max-width: 440px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 16px 40px rgba(58, 51, 80, 0.25);
}

.modal-box h2 {
    font-family: var(--font-brand);
    margin-top: 0;
}

.modal-field {
    display: block;
    margin-top: 14px;
}

.modal-field span {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: .9rem;
}

.modal-field input,
.modal-field select {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 2px solid var(--line);
    border-radius: 12px;
    font-family: var(--font-sans);
    font-size: .95rem;
}

.modal-field input:focus,
.modal-field select:focus {
    border-color: var(--navy);
    outline: none;
    box-shadow: 0 0 0 4px rgba(124, 92, 255, 0.15);
}

.modal-field-row {
    display: flex;
    gap: 10px;
}


.modal-field-country {
    flex: 0 0 42%;
}

.modal-field-mobile {
    flex: 1;
}

.modal-disclaimer {
    margin-top: 14px;
    font-size: .8rem;
    color: var(--muted);
}

.modal-error {
    margin-top: 10px;
    font-size: .85rem;
    color: var(--bad);
    font-weight: 600;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
    flex-wrap: wrap;
}

.modal-actions-google {
    margin-top: 10px;
}

.btn-google {
    width: 100%;
    justify-content: center;
}

.modal-divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--muted);
    font-size: .8rem;
    margin: 14px 0;
}

.modal-divider::before,
.modal-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border, #ddd);
}

.modal-divider span {
    padding: 0 10px;
}

.leaderboard-player-info {
    margin-top: -6px;
    margin-bottom: 14px;
    font-size: .9rem;
}

.leaderboard-save-status {
    margin-top: -6px;
    margin-bottom: 14px;
    font-size: .85rem;
    font-weight: 600;
    color: var(--ok);
}

.leaderboard-save-status.is-error {
    color: var(--bad);
}

.modal-box-congrats {
    text-align: center;
    max-width: 380px;
}

.modal-congrats-text {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0 0 18px;
}

.modal-box-congrats .modal-actions {
    justify-content: center;
    margin-top: 0;
}

.pdf-footer-note {
    margin-top: 18px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--muted);
    text-align: center;
}

.player-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    vertical-align: middle;
    margin-right: 8px;
    object-fit: cover;
}

.leaderboard-name-cell {
    display: flex;
    align-items: center;
}

.player-name-edit-btn {
    margin-left: 4px;
    color: var(--navy);
    font-size: .9rem;
    vertical-align: middle;
}

.player-name-edit-input {
    font: inherit;
    font-weight: 600;
    padding: 2px 6px;
    border: 1px solid var(--border, #ddd);
    border-radius: 4px;
}

.player-name-edit-save,
.player-name-edit-cancel {
    color: var(--navy);
    text-decoration: underline;
    cursor: pointer;
    font-size: .85rem;
    margin-left: 6px;
}

.leaderboard-app {
    max-width: 720px;
}

/* Achievements section (leaderboard.php) — star tiers + mobile-number login */

.achievements-section {
    margin-top: 28px;
    padding: 20px;
    border-radius: 16px;
    background: var(--surface);
    box-shadow: 0 4px 16px rgba(58, 51, 80, 0.1);
}

.achievements-section h2 {
    font-family: var(--font-brand);
    margin: 0 0 6px;
}

.achievements-intro {
    margin: 0 0 18px;
    color: var(--muted);
    font-size: .9rem;
}

/* Split layout: a sidebar identity card (avatar/name/score/actions, or the
   sign-in prompt) next to the tier badge cards. Stacks on narrow screens. */
.achv-split {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 18px;
    align-items: flex-start;
}

.achv-sidebar {
    flex: 0 0 220px;
    width: 220px;
}

@media (max-width: 640px) {
    .achv-sidebar {
        flex: 1 1 100%;
        width: 100%;
    }
}

.achievements-identity,
.achievements-login {
    background: linear-gradient(165deg, rgba(124, 92, 255, 0.08), rgba(255, 111, 165, 0.05));
    border-radius: 16px;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
}

/* A plain class's `display` can otherwise out-cascade the `hidden`
   attribute's UA-stylesheet `display:none` in some browsers — belt and
   braces so toggling `.hidden = true/false` in JS always actually hides it. */
.achievements-identity[hidden],
.achievements-login[hidden] {
    display: none;
}

.achv-avatar {
    width: 170px;
    height: 170px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.achv-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.achv-avatar-placeholder {
    background: linear-gradient(135deg, var(--purple), var(--accent));
}

.achv-name {
    font-family: var(--font-brand);
    font-size: 1.05rem;
    color: var(--ink);
}

.achv-score {
    font-family: var(--font-brand);
    font-size: 1.9rem;
    font-weight: 700;
    color: var(--purple);
    line-height: 1;
    margin-top: 2px;
}

.achv-score-label {
    font-size: .72rem;
    font-weight: 700;
    color: var(--muted);
    margin-top: -4px;
}

.achv-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    margin-top: 10px;
}

.achv-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 8px 0;
    border-radius: 10px;
    font-size: .8rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    border: 1.5px solid transparent;
    background: #fff;
}

.achv-btn-outline {
    border-color: rgba(124, 92, 255, 0.35);
    color: var(--purple);
}

.achv-btn-outline-teal {
    border-color: rgba(34, 195, 176, 0.4);
    color: #0d8d7d;
}

.achv-btn-google {
    border-color: rgba(124, 92, 255, 0.35);
    color: var(--purple);
    margin-top: 10px;
}

.achievement-tiers {
    flex: 1 1 400px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.achievement-tier {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    background: #f0f1f4;
    background: color-mix(in srgb, var(--tier-color, var(--muted)) 7%, #fff);
    border: 1.5px solid var(--line);
    border-color: color-mix(in srgb, var(--tier-color, var(--muted)) 32%, #fff);
    border-radius: 14px;
    padding: 12px 16px;
}

.achievement-tier-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.achievement-tier-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.achievement-tier-label {
    font-weight: 700;
    font-size: .9rem;
    color: var(--tier-color, var(--muted));
}

.achievement-tier-stars {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.achievement-star-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 52px;
}

.achievement-star {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    line-height: 1;
    background: #e4e7eb;
    color: #aab2bb;
    transition: background .2s ease, color .2s ease, transform .2s ease;
}

.achievement-star.is-lit {
    background: var(--tier-color, var(--navy));
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transform: scale(1.05);
}

.achievement-star-remaining {
    font-size: .68rem;
    color: var(--muted);
    text-align: center;
    line-height: 1.2;
    min-height: 1.2em;
}

.achievements-badge-banner {
    margin: 0 0 16px;
    padding: 12px 16px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--tier-color, #ffd700), #ff9f43);
    color: #3a3350;
    font-weight: 700;
    font-size: .95rem;
}


.leaderboard-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.leaderboard-toolbar h1 {
    font-family: var(--font-brand);
    font-size: 1.4rem;
    margin: 0;
}

.leaderboard-lang-form select {
    padding: 8px 12px;
    border: 2px solid var(--line);
    border-radius: 12px;
    font-family: var(--font-sans);
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 10px 26px rgba(124, 92, 255, 0.12);
}

.leaderboard-table th,
.leaderboard-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--line);
}

.leaderboard-table th {
    font-family: var(--font-brand);
    background: rgba(124, 92, 255, 0.08);
}

.leaderboard-table tbody tr:last-child td {
    border-bottom: none;
}

.leaderboard-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
    flex-wrap: wrap;
}

.empty-state {
    text-align: center;
    padding: 40px 16px;
    color: var(--muted);
}

@media (max-width: 480px) {
    .modal-field-row { flex-direction: column; }
    .modal-field-country,
    .modal-field-mobile { flex: 1; }
    .leaderboard-table th,
    .leaderboard-table td { padding: 8px 10px; font-size: .9rem; }
}

/* Home page "Top 10 Leaderboard" widget — podium (top 3) + compact list (4-10) */

.leaderboard-widget {
    /* .card-panel only sets margin-bottom; the section right above this one
       (quiz-types-overview) has no bottom margin of its own, so without this
       the card butts straight up against it. */
    margin-top: 28px;
}

.leaderboard-widget .podium {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    align-items: end;
    gap: 10px;
    margin: 18px 0 20px;
}

.podium-step {
    position: relative;
    overflow: hidden;
    border-radius: 16px 16px 8px 8px;
    padding: 14px 10px 16px;
    text-align: center;
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

/* Rank number tag, pinned in the corner — the medal emoji alone didn't read
   clearly as "1st/2nd/3rd" at a glance, so the number takes over that job
   on its own and the medal emoji was dropped as redundant. */
.podium-step .ord-tag {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(255, 255, 255, 0.92);
    border-radius: 8px;
    padding: 3px 11px;
    font-family: var(--font-brand);
    font-weight: 800;
    font-size: 1.3rem;
    line-height: 1.3;
}

.podium-step .p-name {
    font-weight: 800;
    font-size: 1.05rem;
}

.podium-step .p-country {
    font-size: .85rem;
    opacity: .85;
}

.podium-step .p-score {
    font-family: var(--font-brand);
    font-size: 1.3rem;
    margin-top: 6px;
}

/* Brand colors (site's own yellow/teal/pink) instead of literal medal
   metals — chosen over gold/silver/bronze because the grey/brown pairing
   didn't fit the app's playful palette. */
.podium-step.gold {
    background: linear-gradient(160deg, var(--yellow), #e8922a);
    height: 150px;
    order: 2;
    color: #4a3200;
}

.podium-step.gold .p-country {
    color: #6b4a10;
    opacity: 1;
}

.podium-step.gold .ord-tag {
    color: #c9811f;
}

.podium-step.silver {
    background: linear-gradient(160deg, var(--teal), #15948a);
    height: 122px;
    order: 1;
}

.podium-step.silver .ord-tag {
    color: #15948a;
}

.podium-step.bronze {
    background: linear-gradient(160deg, var(--accent), #e14f87);
    height: 104px;
    order: 3;
}

.podium-step.bronze .ord-tag {
    color: #e14f87;
}

.rest-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rest-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 12px;
    background: rgba(124, 92, 255, 0.05);
    font-size: .88rem;
}

.rest-row .r-rank {
    font-family: var(--font-brand);
    font-weight: 700;
    color: var(--muted);
    width: 1.6em;
    flex-shrink: 0;
}

.rest-row .r-name {
    flex: 1;
    font-weight: 700;
}

.rest-row .r-country {
    color: var(--muted);
    font-size: .78rem;
    margin-right: 8px;
}

.rest-row .r-score {
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.leaderboard-widget-more {
    display: block;
    text-align: center;
    margin-top: 16px;
    font-size: .88rem;
    font-weight: 700;
    color: var(--navy);
    text-decoration: none;
}

@media (max-width: 480px) {
    /* The 3-column, uneven-height podium reads fine on a wide card but
       falls apart on a phone-width one: three slim columns leave barely
       any room for a name, so a longer display name gets cramped or
       clipped. Below this width the podium becomes a stack of full-width
       rows instead — one per rank, same tier colors, with a square rank
       chip on the left, name/country stacked next to it, and the score
       pinned to the right. A row can grow to fit a wrapped name without
       breaking the layout the way a fixed-height column would. */
    .leaderboard-widget .podium {
        display: flex;
        flex-direction: column;
        /* Desktop's .podium sets align-items: end for its 3-column grid;
           left un-overridden here, that becomes "align to the end of the
           cross axis" in a column flex container — which, with no
           stretch, shrinks each row to its content width and pushes it
           to the right edge instead of filling the row. */
        align-items: stretch;
        gap: 8px;
        margin: 18px 0 20px;
    }

    /* Grid (rather than flex) so the name and country can stack in their
       own column — both span column 2 across the two rows — without
       needing a wrapper element around them in the markup. */
    .podium-step {
        display: grid;
        grid-template-columns: 30px 1fr auto;
        grid-template-rows: auto auto;
        column-gap: 10px;
        row-gap: 0;
        align-items: center;
        height: auto;
        padding: 10px 12px;
        text-align: left;
    }

    /* DOM order is silver/gold/bronze (so the taller gold column sits
       centered on desktop); rows need rank order instead, so each tier
       gets its own explicit order here rather than inheriting the
       desktop grid's. Height is re-asserted per tier too: each tier's
       own selector (.podium-step.gold etc.) outweighs the plain
       ".podium-step { height: auto }" above on specificity alone, so
       without this the desktop column heights (150px/122px/104px) would
       still win here. */
    .podium-step.gold { order: 1; height: auto; }
    .podium-step.silver { order: 2; height: auto; }
    .podium-step.bronze { order: 3; height: auto; }

    .podium-step .ord-tag {
        position: static;
        grid-column: 1;
        grid-row: 1 / 3;
        width: 30px;
        height: 30px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        font-size: 1rem;
    }

    .podium-step .p-name {
        grid-column: 2;
        grid-row: 1;
        font-size: .92rem;
        line-height: 1.25;
        word-break: break-word;
    }

    .podium-step .p-country {
        grid-column: 2;
        grid-row: 2;
        font-size: .74rem;
    }

    .podium-step .p-score {
        grid-column: 3;
        grid-row: 1 / 3;
        margin-top: 0;
        font-size: 1.05rem;
    }

    .rest-row { font-size: .82rem; }
}

/* embed.php — bare iframe widget: no header/footer/menu chrome */
body.embed-page {
    background: var(--surface);
}

.embed-main {
    flex: 1;
    padding: 16px;
    max-width: 640px;
}

.embed-footer {
    text-align: center;
    margin: 4px 0 8px;
}

.embed-powered-by {
    margin: 0;
    font-size: .8rem;
    color: var(--muted);
}

.embed-code-input {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    resize: vertical;
}

/* help.php — step-by-step manual */
.help-intro p {
    margin: 0 0 16px;
}

.help-toc {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.help-toc a {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 8px 14px;
    border-radius: 999px;
    background: #f6f2ff;
    color: var(--navy);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 800;
}

.help-toc a:hover {
    background: var(--navy);
    color: #fff;
}

.help-section-intro {
    margin: 0 0 20px;
}

.help-steps {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.help-step {
    border-left: 4px solid var(--teal);
    padding-left: 16px;
}

.help-step h3 {
    margin: 0 0 6px;
    font-family: var(--font-brand);
    font-size: 1.05rem;
    color: var(--ink);
}

.help-step p {
    margin: 0 0 10px;
    color: var(--muted);
}

.help-mockup {
    max-width: 600px;
    border-radius: 16px;
    overflow: hidden;
}

.help-mockup-svg {
    display: block;
    width: 100%;
    height: auto;
}

.help-mockup + .help-mockup {
    margin-top: 10px;
}

.help-step-note {
    margin: 10px 0 0;
    font-size: 0.85rem;
    color: var(--muted);
    font-style: italic;
}

@media (max-width: 480px) {
    .help-toc a { font-size: 0.82rem; padding: 7px 12px; }
    .help-step { padding-left: 12px; }
}
