/* Area partecipante: sfondo blu animato, card a vetro, coerente con il pannello admin */
:root {
    --navy-950: #0f1a3f;
    --navy-800: #1e3a7a;
    --navy-700: #1e4d99;
    --blue-600: #1e5fb4;
    --blue-500: #3b82f6;

    --surface: rgba(255, 255, 255, 0.94);
    --ink: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --bg: #f1f5fb;
    --accent: var(--blue-600);
    --accent-ink: #ffffff;
    --accent-soft: #e8f0fc;
    --ok: #059669;
    --ok-soft: #e6f6f0;
    --bad: #dc2626;
    --bad-soft: #fdecec;
    --warn: #b45309;
    --radius: 18px;
    --shadow: 0 20px 60px rgba(15, 26, 63, 0.35);
    --on-dark: #ffffff;
    --on-dark-muted: rgba(255, 255, 255, 0.78);
    color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html { min-height: 100%; }

/* Sfondo animato blu con due bolle sfocate (blu e rossa), come il login admin */
body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    font: 16px/1.55 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    background: linear-gradient(-45deg, #0f1a3f, #1e3a7a, #1e5fb4, #3b82f6, #1e4d99, #0f1a3f) fixed;
    background-size: 400% 400%;
    animation: bgShift 18s ease infinite;
    position: relative;
    overflow-x: hidden;
}
body::before,
body::after {
    content: "";
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.5;
    pointer-events: none;
    z-index: 0;
}
body::before {
    width: 520px; height: 520px;
    background: radial-gradient(circle, #60a5fa 0%, transparent 70%);
    top: -120px; left: -120px;
    animation: blob1 22s ease-in-out infinite;
}
body::after {
    width: 620px; height: 620px;
    background: radial-gradient(circle, #ef4444 0%, transparent 70%);
    bottom: -160px; right: -160px;
    animation: blob2 26s ease-in-out infinite;
}
@keyframes bgShift {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
@keyframes blob1 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50%      { transform: translate(180px, 120px) scale(1.25); }
}
@keyframes blob2 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50%      { transform: translate(-160px, -100px) scale(1.15); }
}
@media (prefers-reduced-motion: reduce) {
    body, body::before, body::after { animation: none !important; }
}

body > * { position: relative; z-index: 1; }

a { color: var(--accent); }

.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }

.topbar {
    position: sticky; top: 0; z-index: 10;
    background: linear-gradient(90deg, #ffffff 0%, #f5f8ff 100%);
    border-bottom: 1px solid #e5e7eb;
    box-shadow: 0 4px 12px rgba(15, 26, 63, 0.12);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; min-height: 60px; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--navy-800); font-weight: 700; }
.brand-name { font-size: 19px; font-weight: 800; letter-spacing: -.01em; color: var(--navy-800); }
.brand-sub { font-size: 13px; font-weight: 600; color: var(--muted); padding-left: 10px; border-left: 1px solid var(--line); }
@media (max-width: 480px) { .brand-name { font-size: 17px; } }

main.wrap { padding-top: 32px; padding-bottom: 32px; }

.footer { padding-bottom: 32px; font-size: 14px; color: var(--on-dark-muted); display: flex; gap: 16px; flex-wrap: wrap; }
.footer a { color: var(--on-dark-muted); }
.footer a:hover { color: var(--on-dark); }

h1 { font-size: clamp(24px, 4vw, 30px); line-height: 1.2; letter-spacing: -.02em; margin: 4px 0 12px; }
h2 { font-size: 18px; margin: 24px 0 6px; }

.eyebrow { margin: 0; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.lead { color: var(--muted); margin: 0 0 16px; }
.hint { font-size: 14px; color: var(--muted); margin: 0; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: .08em; text-transform: uppercase; }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
}
.card.narrow { max-width: 520px; margin: 0 auto; }

.meta { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0 0 20px; }
.meta li { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--ink); }

.alert { background: var(--bad-soft); color: var(--bad); border-radius: 10px; padding: 10px 14px; margin: 0 0 16px; font-size: 14px; }
.alert p { margin: 0; }
.alert.soft { background: var(--accent-soft); color: var(--ink); }

.form { display: grid; gap: 14px; }
.row-2 { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
@media (max-width: 520px) { .row-2 { grid-template-columns: 1fr; } }

.field { display: grid; gap: 6px; font-size: 14px; font-weight: 600; }
.field input {
    font: inherit; font-weight: 400;
    padding: 11px 12px;
    border: 1px solid var(--line); border-radius: 10px;
    background: var(--bg); color: var(--ink);
    width: 100%;
}
.field input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

.or { text-align: center; color: var(--muted); font-size: 13px; margin: -4px 0; }

.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--muted); }
.check input { margin-top: 3px; }

.btn {
    font: inherit; font-weight: 600;
    padding: 11px 18px; border-radius: 10px;
    border: 1px solid var(--line); background: var(--surface); color: var(--ink);
    cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Svolgimento */
.play-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.play-head h1 { margin-bottom: 0; }
.progress { margin: 0; font-size: 14px; color: var(--muted); }
.progress span { color: var(--ink); font-weight: 700; }

.question { margin: 0 0 16px; padding: 20px 20px 14px; }
.question legend { display: flex; gap: 12px; align-items: flex-start; padding: 0; font-weight: 600; float: left; width: 100%; margin-bottom: 10px; }
.question legend + * { clear: both; }
.qnum {
    flex: none; display: inline-grid; place-items: center;
    width: 28px; height: 28px; border-radius: 8px;
    background: var(--accent-soft); color: var(--accent); font-size: 14px;
}
.qtext { padding-top: 2px; }
.question .hint { margin: 0 0 8px 40px; }

.answers { display: grid; gap: 8px; clear: both; }
.answer {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px;
    cursor: pointer; transition: border-color .15s, background .15s;
}
.answer:hover { border-color: var(--accent); }
.answer input { margin-top: 4px; accent-color: var(--accent); }
.answer:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

.save-state { min-height: 18px; margin: 8px 0 0; font-size: 12px; color: var(--muted); text-align: right; }
.save-state.ok { color: var(--ok); }
.save-state.warn { color: var(--warn); }

.submit-bar { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 24px; }

.timer { display: flex; align-items: baseline; gap: 8px; padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
.timer-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.timer-value { font-variant-numeric: tabular-nums; font-weight: 700; }
.timer.urgent { border-color: var(--bad); color: var(--bad); }

/* Risultato */
.result { text-align: center; }
.score {
    --size: 168px;
    width: var(--size); height: var(--size); margin: 20px auto;
    border-radius: 50%;
    display: grid; place-content: center;
    background:
        radial-gradient(closest-side, var(--surface) 80%, transparent 81%),
        conic-gradient(var(--ring) calc(var(--pct) * 1%), var(--line) 0);
}
.is-pass { --ring: var(--ok); }
.is-fail { --ring: var(--bad); }
.score-pct { font-size: 40px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.score-pts { font-size: 13px; color: var(--muted); margin-top: 6px; }

.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 20px; text-align: left; }
.facts div { background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.facts dt { font-size: 12px; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
@media (max-width: 520px) { .facts { grid-template-columns: 1fr; } }

.actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.actions form { margin: 0; }

.prose p { margin: 0 0 10px; }

/* Passi 1-2-3 */
.steps {
    display: flex; gap: 8px; justify-content: center;
    list-style: none; padding: 0; margin: 0 auto 20px; max-width: 520px;
    counter-reset: step;
}
.steps li {
    flex: 1; display: flex; align-items: center; gap: 8px;
    font-size: 13px; color: var(--muted);
}
.steps li:not(:last-child)::after { content: ""; flex: 1; height: 2px; border-radius: 2px; background: var(--line); }
.steps li.done:not(:last-child)::after { background: var(--accent); }
.step-num {
    flex: none; display: inline-grid; place-items: center;
    width: 24px; height: 24px; border-radius: 50%;
    border: 2px solid var(--line); font-weight: 700; font-size: 12px;
}
.steps li.current { color: var(--ink); font-weight: 600; }
.steps li.current .step-num { border-color: var(--accent); color: var(--accent); }
.steps li.done .step-num { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
@media (max-width: 420px) { .step-label { display: none; } .steps li.current .step-label { display: inline; } }

.back-form { margin: 14px 0 0; text-align: center; }
.link-btn { font: inherit; font-size: 14px; background: none; border: 0; color: var(--muted); cursor: pointer; text-decoration: underline; }
.link-btn:hover { color: var(--ink); }

/* Revisione risposte a fine quiz */
.review { max-width: 760px; margin: 28px auto 0; }
.review-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.review-head h2 { margin: 0; font-size: 20px; }
.review-count { margin: 0; display: flex; gap: 6px; }
.pill { font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.review .hint { margin-bottom: 12px; }
.review-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.review-item { padding: 16px 18px; border-left: 4px solid var(--line); }
.review-item.is-right { border-left-color: var(--ok); }
.review-item.is-wrong { border-left-color: var(--bad); }
.review-q { display: flex; gap: 10px; align-items: flex-start; font-weight: 600; }
.review-mark {
    flex: none; display: inline-grid; place-items: center;
    width: 24px; height: 24px; border-radius: 50%; font-size: 14px;
}
.is-right .review-mark { background: var(--ok-soft); color: var(--ok); }
.is-wrong .review-mark { background: var(--bad-soft); color: var(--bad); }
.review-line { margin: 8px 0 0 34px; font-size: 15px; }
.review-label { color: var(--muted); font-size: 13px; margin-right: 4px; }
.is-wrong .review-line:not(.solution) { color: var(--bad); }
.review-line.solution { color: var(--ok); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ===== Tema: rifiniture ===== */

/* Card bianche "a vetro" sopra lo sfondo blu, come il login admin */
.card {
    background: var(--surface);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.45);
    box-shadow: var(--shadow);
}
.question, .review-item { box-shadow: 0 8px 30px rgba(15, 26, 63, 0.22); }

.eyebrow { color: var(--blue-600); }
h1 { color: var(--navy-800); }

.btn.primary {
    background: linear-gradient(135deg, var(--blue-600) 0%, var(--navy-800) 100%);
    border-color: transparent;
    box-shadow: 0 6px 18px rgba(30, 95, 180, 0.35);
    transition: transform .15s ease, box-shadow .15s ease;
}
.btn.primary:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(30, 95, 180, 0.45); }
.btn:not(.primary) { background: #ffffff; }

.meta li { background: var(--accent-soft); color: var(--navy-800); font-weight: 600; }
.field input { background: #f8fafc; }
.field input:focus { outline-color: var(--blue-600); }

/* Elementi direttamente sullo sfondo blu: testo chiaro */
.play-head h1,
.play-head .eyebrow,
.review-head h2 { color: var(--on-dark); }
.play-head .eyebrow { opacity: .85; }
.progress { color: var(--on-dark-muted); }
.progress span { color: var(--on-dark); }
.submit-bar .hint,
.review > .hint { color: var(--on-dark-muted); }

.steps li { color: var(--on-dark-muted); }
.steps li:not(:last-child)::after { background: rgba(255, 255, 255, 0.3); }
.steps li.done:not(:last-child)::after { background: #ffffff; }
.step-num { border-color: rgba(255, 255, 255, 0.5); background: transparent; }
.steps li.current { color: var(--on-dark); }
.steps li.current .step-num { border-color: #ffffff; color: var(--navy-800); background: #ffffff; }
.steps li.done .step-num { background: #ffffff; border-color: #ffffff; color: var(--navy-800); }

.timer { background: #ffffff; }
.qnum { background: linear-gradient(135deg, var(--blue-600), var(--navy-800)); color: #ffffff; }
.answer:has(input:checked) { border-color: var(--blue-600); background: var(--accent-soft); }

.score { box-shadow: 0 10px 30px rgba(15, 26, 63, 0.15); }
.facts div { background: #f1f5fb; }

/* Testi personalizzati dall'admin (Markdown) */
.custom-text {
    margin: 4px 0 18px;
    padding: 14px 16px;
    border-radius: 12px;
    background: var(--accent-soft);
    border-left: 4px solid var(--blue-600);
    text-align: left;
    font-size: 15px;
}
.custom-text > :first-child { margin-top: 0; }
.custom-text > :last-child { margin-bottom: 0; }
.custom-text p { margin: 0 0 8px; }
.custom-text ul, .custom-text ol { margin: 0 0 8px; padding-left: 20px; }
.result .custom-text { margin-top: 0; }

/* Immagini delle domande */
.q-image { margin: 0 0 12px; clear: both; }
.q-image img,
.review-image {
    display: block;
    max-width: 100%;
    max-height: 420px;
    height: auto;
    margin: 0 auto;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: #ffffff;
}
.review-image { max-height: 200px; margin: 10px 0 0 34px; }

/* Errori sul singolo campo */
.field.has-error input { border-color: var(--bad); background: var(--bad-soft); }
.field.has-error input:focus { outline-color: var(--bad); }
.field-error { color: var(--bad); font-weight: 500; font-size: 13px; }
.check.has-error { color: var(--bad); }

/* Pagine di errore */
.error-page { text-align: center; }
.error-page .btn { display: inline-block; text-decoration: none; margin-top: 4px; }

/* Pallini e caselle più grandi, comodi da toccare */
.answer input[type=radio], .answer input[type=checkbox], .check input[type=checkbox] { width: 20px; height: 20px; flex: none; margin-top: 2px; }

/* Domanda senza risposta segnalata alla consegna */
.question.is-missing { outline: 3px solid #f59e0b; outline-offset: 2px; }
