/* ============ Interial Academy — design system ============ */
:root {
  --bg: #0b1020; --bg-2: #0f1630; --surface: #141c33; --surface-2: #1b2544; --line: #26304f; --line-2: #33407a;
  --text: #e8ecf7; --muted: #94a0bd; --accent: #3a86ff; --accent-2: #5da0ff; --ok: #2ec4b6; --warn: #ffbe0b; --danger: #ef476f; --gold: #ffd166; --purple: #8338ec; --orange: #ff7a45;
  --shadow: 0 10px 30px rgba(0,0,0,.35); --radius: 14px; --radius-sm: 9px;
  --font: "Segoe UI Variable Text", "Segoe UI", Inter, system-ui, -apple-system, sans-serif; --mono: "Cascadia Code", Consolas, "JetBrains Mono", monospace;
}
[data-theme="light"] {
  --bg: #f3f5fb; --bg-2: #e9edf7; --surface: #ffffff; --surface-2: #f4f6fc; --line: #dde3f0; --line-2: #c9d2e8;
  --text: #141a2e; --muted: #5b6684; --accent: #0855b5; --accent-2: #2f74d0; --shadow: 0 10px 30px rgba(20,30,60,.10);
}
* { box-sizing: border-box; }
html { color-scheme: dark; }
[data-theme="light"] { color-scheme: light; }
body { margin: 0; font-family: var(--font); background: radial-gradient(1200px 600px at 10% -10%, rgba(58,134,255,.12), transparent 60%), radial-gradient(900px 500px at 100% 0%, rgba(131,56,236,.10), transparent 55%), var(--bg); color: var(--text); line-height: 1.55; min-height: 100vh; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .4em; letter-spacing: -.01em; }
h1 { font-size: 1.9rem; } h2 { font-size: 1.4rem; } h3 { font-size: 1.08rem; }
p { margin: 0 0 .8em; }
code, pre { font-family: var(--mono); }
pre { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .8rem 1rem; overflow-x: auto; font-size: .88rem; }
code { background: rgba(127,140,190,.15); padding: .05em .35em; border-radius: 4px; font-size: .92em; }
pre code { background: none; padding: 0; }
table { border-collapse: collapse; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 8px; top: 8px; background: var(--accent); color: #fff; padding: .5rem; z-index: 100; }
[hidden] { display: none !important; }
.muted { color: var(--muted); } .small { font-size: .86rem; } .center { text-align: center; } .spacer { flex: 1; } .mono { font-family: var(--mono); }
.lead { font-size: 1.08rem; color: var(--muted); }

/* ---- topbar ---- */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 1.2rem; padding: .55rem 1.2rem; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: .55rem; color: var(--text); font-weight: 600; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, #0855b5, #3a86ff); color: #fff; display: grid; place-items: center; font-weight: 800; letter-spacing: -.03em; }
.brand-text b { color: var(--accent-2); }
.mainnav { display: flex; gap: .2rem; flex: 1; }
.mainnav a { padding: .4rem .7rem; border-radius: 8px; color: var(--muted); font-weight: 500; position: relative; }
.mainnav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.mainnav a.active { color: var(--text); background: var(--surface-2); }
.pill { display: inline-block; min-width: 1.3em; padding: .05em .45em; border-radius: 999px; background: var(--danger); color: #fff; font-size: .72rem; font-weight: 700; text-align: center; margin-left: .3em; }
.pill.warn { background: var(--warn); color: #222; }
.topbar-right { display: flex; align-items: center; gap: .6rem; }
.xp-widget { display: flex; align-items: center; gap: .5rem; }
.xp-level { width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(135deg, var(--gold), var(--orange)); color: #222; display: grid; place-items: center; font-weight: 800; font-size: .85rem; }
.xp-bar { width: 120px; height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.xp-bar.big { width: 100%; height: 12px; margin: .5rem 0 .2rem; }
.xp-fill { height: 100%; background: linear-gradient(90deg, var(--gold), var(--orange)); border-radius: 999px; transition: width .8s cubic-bezier(.2,.8,.2,1); }
.xp-text { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.streak-widget { font-weight: 700; }
.icon-btn { background: var(--surface-2); border: 1px solid var(--line); color: var(--text); width: 34px; height: 34px; border-radius: 9px; cursor: pointer; font-size: 1rem; }
.icon-btn:hover { border-color: var(--line-2); }

/* ---- layout ---- */
.main { max-width: 1200px; margin: 0 auto; padding: 1.4rem 1.2rem 4rem; }
.layout-2 { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.4rem; align-items: start; }
.sidebar { position: sticky; top: 70px; display: flex; flex-direction: column; gap: 1rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.loading { display: flex; gap: .8rem; align-items: center; color: var(--muted); padding: 2rem; }
.spinner { width: 20px; height: 20px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-card { border-color: var(--danger); }
.btn-row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

/* ---- bottoni & form ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .6rem 1.1rem; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text); font-weight: 600; font-size: .95rem; cursor: pointer; transition: transform .08s ease, background .15s, border-color .15s; font-family: inherit; }
.btn:hover { background: var(--line); text-decoration: none; }
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: linear-gradient(135deg, var(--accent), #5b6cff); border-color: transparent; color: #fff; box-shadow: 0 6px 18px rgba(58,134,255,.35); }
.btn-primary:hover { filter: brightness(1.08); background: linear-gradient(135deg, var(--accent), #5b6cff); }
.btn-danger { background: linear-gradient(135deg, var(--danger), #ff7a45); border-color: transparent; color: #fff; box-shadow: 0 6px 18px rgba(239,71,111,.3); }
.btn-danger:hover { filter: brightness(1.08); background: linear-gradient(135deg, var(--danger), #ff7a45); }
.btn-ghost { background: transparent; }
.btn-sm { padding: .35rem .7rem; font-size: .85rem; }
.btn-lg { padding: .8rem 1.4rem; font-size: 1.05rem; }
.link { color: var(--accent-2); }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 9px; padding: .55rem .7rem; width: 100%; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { resize: vertical; min-height: 90px; margin-bottom: .6rem; }
label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: .8rem; }
label input, label select, label textarea { margin-top: .3rem; }
label.check { display: flex; align-items: center; gap: .5rem; } label.check input { width: auto; margin: 0; }
.form-error { color: var(--danger); font-weight: 600; margin: .5rem 0; }
.search { max-width: 340px; }

/* ---- login ---- */
.login-wrap { display: grid; grid-template-columns: 1.2fr 1fr; gap: 3rem; align-items: center; min-height: 70vh; }
.login-hero h1 { font-size: 2.6rem; margin-top: .8rem; } .login-hero h1 b { color: var(--accent-2); }
.login-mark { width: 64px; height: 64px; border-radius: 16px; background: linear-gradient(135deg, #0855b5, #3a86ff); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 1.6rem; }
.login-points { list-style: none; padding: 0; margin: 1rem 0; display: grid; gap: .4rem; color: var(--muted); }
.login-card { max-width: 420px; justify-self: end; width: 100%; }
.login-form .btn { width: 100%; margin-top: .4rem; }

.btn-ms { width: 100%; background: #fff; color: #1f2430; border-color: #d0d5e0; margin: .4rem 0 .6rem; }
.btn-ms:hover { background: #f1f3f8; }
.ms-logo { display: inline-flex; margin-right: .2rem; }
.local-login { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: .8rem; }
.local-login summary { cursor: pointer; color: var(--muted); font-size: .9rem; margin-bottom: .6rem; }

/* ---- percorso (home) ---- */
.journey-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; gap: 1rem; }
.next-card { display: block; padding: 1rem 1.2rem; border-radius: var(--radius); background: linear-gradient(135deg, color-mix(in srgb, var(--mc, var(--accent)) 35%, var(--surface)), var(--surface)); border: 1px solid color-mix(in srgb, var(--mc, var(--accent)) 50%, var(--line)); color: var(--text); margin-bottom: 1.2rem; transition: transform .12s; }
.next-card:hover { transform: translateY(-2px); text-decoration: none; }
.next-card.done { --mc: var(--gold); }
.next-kicker { font-size: .78rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 700; }
.next-title { font-size: 1.25rem; font-weight: 700; margin: .15rem 0; }
.next-sub { color: var(--muted); font-size: .9rem; }
.module { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 1rem; overflow: hidden; }
.module.locked { opacity: .72; }
.module-head { display: flex; align-items: center; gap: .9rem; padding: .9rem 1.1rem; border-left: 5px solid var(--mc); background: linear-gradient(90deg, color-mix(in srgb, var(--mc) 14%, transparent), transparent 60%); }
.module-emoji { font-size: 1.7rem; width: 44px; text-align: center; }
.module-titles { flex: 1; } .module-titles h2 { margin: 0; font-size: 1.15rem; } .module-titles p { margin: 0; font-size: .88rem; }
.module-progress { font-weight: 700; color: var(--muted); display: flex; gap: .4rem; align-items: center; }
.chapters { list-style: none; margin: 0; padding: .3rem .6rem .6rem; }
.chapter { position: relative; padding: 0; }
.chapter a, .chapter.locked, .chapter.coming_soon { display: flex; gap: .8rem; align-items: flex-start; padding: .6rem .6rem; border-radius: 10px; color: var(--text); }
.chapter a:hover { background: var(--surface-2); text-decoration: none; }
.chapter.locked, .chapter.coming_soon { color: var(--muted); cursor: not-allowed; }
.node { flex: none; width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line-2); display: grid; place-items: center; font-size: .85rem; font-weight: 800; background: var(--bg-2); margin-top: .1rem; }
.node-done { background: var(--ok); border-color: var(--ok); color: #062; }
.node-available { border-color: var(--mc); box-shadow: 0 0 0 4px color-mix(in srgb, var(--mc) 30%, transparent); animation: pulse 1.8s ease-in-out infinite; }
.node-reading, .node-quiz, .node-boss { border-color: var(--mc); background: color-mix(in srgb, var(--mc) 30%, var(--bg-2)); color: var(--text); }
.node-locked, .node-coming_soon { font-size: .75rem; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--mc) 35%, transparent); } 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--mc) 12%, transparent); } }
.ch-body { display: flex; flex-direction: column; min-width: 0; }
.ch-title { font-weight: 600; } .ch-tagline { font-size: .84rem; color: var(--muted); } .ch-meta { font-size: .78rem; color: var(--muted); margin-top: .1rem; }
.chapter.done .ch-title { color: var(--muted); }
.player-card { text-align: center; } .player-card.wide { display: grid; grid-template-columns: auto 1fr; gap: 1rem; text-align: left; align-items: center; }
.player-card.wide .stat-row { grid-column: 1 / -1; }
.avatar { width: 64px; height: 64px; border-radius: 50%; margin: 0 auto .5rem; background: linear-gradient(135deg, var(--purple), var(--accent)); display: grid; place-items: center; font-weight: 800; font-size: 1.4rem; color: #fff; }
.avatar.big { width: 84px; height: 84px; font-size: 1.8rem; margin: 0; }
.player-name { font-weight: 700; font-size: 1.1rem; } .player-title { color: var(--gold); font-weight: 600; font-size: .9rem; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(70px, 1fr)); gap: .5rem; margin-top: .8rem; }
.stat { background: var(--bg-2); border-radius: 10px; padding: .5rem .4rem; text-align: center; }
.stat-val { font-weight: 800; font-size: 1.05rem; } .stat-label { font-size: .72rem; color: var(--muted); }
.goal-line { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .6rem; font-size: .9rem; }
.mini-bar { height: 7px; background: var(--line); border-radius: 999px; overflow: hidden; } .mini-fill { height: 100%; background: var(--ok); border-radius: 999px; transition: width .6s; }
.badge-row { display: flex; flex-wrap: wrap; gap: .4rem; margin: .4rem 0; }
.badge-chip { background: var(--bg-2); border: 1px solid var(--line-2); padding: .25rem .6rem; border-radius: 999px; font-size: .82rem; }
.badge-chip.earned { background: linear-gradient(135deg, color-mix(in srgb, var(--gold) 30%, var(--surface)), var(--surface)); border-color: var(--gold); font-weight: 600; }
.badge-row.big .badge-chip { font-size: 1rem; padding: .45rem .9rem; }
.ring-wrap { position: relative; display: grid; place-items: center; flex: none; }
.ring { position: absolute; inset: 0; } .ring-label { font-weight: 800; font-size: .95rem; }

/* ---- capitolo ---- */
.chapter { max-width: 860px; margin: 0 auto; }
.ch-header { padding-bottom: 1rem; border-bottom: 1px solid var(--line); margin-bottom: 1.2rem; }
.crumb { color: var(--muted); font-size: .9rem; }
.ch-title-row { display: flex; gap: 1rem; align-items: center; margin: .6rem 0; }
.ch-emoji { font-size: 2.6rem; line-height: 1; }
.ch-title-row h1 { margin: 0; } .tagline { color: var(--muted); font-size: 1.05rem; margin: .2rem 0 0; font-style: italic; }
.ch-meta-row { display: flex; gap: 1.2rem; flex-wrap: wrap; color: var(--muted); font-size: .9rem; margin-bottom: .8rem; }
.stages { list-style: none; padding: 0; margin: .6rem 0 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; }
.stage { display: flex; align-items: center; gap: .5rem; padding: .5rem .6rem; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.stage.done { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, var(--surface)); }
.stage-n { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line-2); display: grid; place-items: center; font-size: .75rem; font-weight: 800; flex: none; }
.stage.done .stage-n { background: var(--ok); border-color: var(--ok); color: #062; }
.stage-label { font-weight: 700; font-size: .9rem; } .stage-info { font-size: .75rem; color: var(--muted); margin-left: auto; text-align: right; }
.ch-done-banner { margin-top: .8rem; padding: .6rem .9rem; border-radius: 10px; background: color-mix(in srgb, var(--gold) 15%, var(--surface)); border: 1px solid var(--gold); font-size: .92rem; }
.objectives ul { margin: .3rem 0 0; padding-left: 1.2rem; }
.intro { margin: 1.2rem 0; }
.lead-md { font-size: 1.08rem; }
.md h1, .md h2, .md h3 { margin-top: 1.2em; } .md h3 { font-size: 1.05rem; color: var(--accent-2); }
.md table { width: 100%; margin: .8rem 0; font-size: .92rem; } .md th, .md td { border: 1px solid var(--line); padding: .4rem .6rem; text-align: left; vertical-align: top; } .md th { background: var(--bg-2); }
.md blockquote { border-left: 3px solid var(--accent); margin: .8rem 0; padding: .3rem .9rem; color: var(--muted); background: var(--bg-2); border-radius: 0 8px 8px 0; }
.md img { max-width: 100%; }
.sec { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 1rem; overflow: hidden; }
.sec-head { display: flex; align-items: center; gap: .8rem; padding: .8rem 1.1rem; cursor: default; }
.sec.done .sec-head { cursor: pointer; }
.sec-head h2 { margin: 0; font-size: 1.2rem; flex: 1; }
.sec-n { width: 30px; height: 30px; border-radius: 50%; background: var(--mc, var(--accent)); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: .9rem; flex: none; }
.sec.done .sec-n { background: var(--ok); color: #062; }
.sec.done .sec-state::after { content: '✓ letta'; color: var(--ok); font-size: .85rem; font-weight: 600; }
.sec.done .sec-body { display: none; } .sec.done.open .sec-body { display: block; }
.sec-body { padding: .2rem 1.2rem 1.2rem; }
.sec.future { display: none; }
details.funfact, details.interial-note { margin: 1rem 0; border-radius: 10px; padding: .6rem .9rem; border: 1px dashed var(--line-2); }
details.funfact { background: color-mix(in srgb, var(--gold) 8%, transparent); } details.interial-note { background: color-mix(in srgb, var(--accent) 10%, transparent); border-style: solid; }
details summary { cursor: pointer; font-weight: 700; }
details .md { margin-top: .5rem; }
.checkpoint { margin-top: 1.2rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.cp-title { font-weight: 700; color: var(--purple); margin-bottom: .6rem; }
[data-theme="dark"] .cp-title { color: #b18cff; }
.after-lesson { margin-top: 1.5rem; display: grid; gap: 1rem; }
.takeaways ul { padding-left: 1.2rem; margin: .3rem 0 0; } .takeaways li { margin-bottom: .3rem; }
.glossary dl { margin: .8rem 0 0; } .glossary dt { font-weight: 700; margin-top: .6rem; } .glossary dd { margin: 0 0 .2rem; color: var(--muted); }
.stage-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.stage-card h3 { font-size: 1.2rem; } .stage-stat { font-weight: 600; color: var(--gold); }
.quiz-card { border-top: 4px solid var(--accent); } .boss-card { border-top: 4px solid var(--danger); } .refl-card { border-top: 4px solid var(--purple); }
.refl-prompt { font-size: 1.02rem; }
.prev-refl blockquote { margin: .5rem 0; padding: .5rem .8rem; background: var(--bg-2); border-left: 3px solid var(--purple); border-radius: 0 8px 8px 0; font-size: .92rem; }

/* ---- domande ---- */
.player { display: grid; gap: .9rem; }
.q-head { display: flex; gap: .6rem; align-items: center; font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.q-type { color: var(--accent-2); } .q-bloom { padding: .1rem .5rem; border: 1px solid var(--line-2); border-radius: 999px; text-transform: none; letter-spacing: 0; }
.diff { margin-left: auto; letter-spacing: .1em; color: var(--gold); }
.q-context { background: var(--bg-2); border-left: 3px solid var(--warn); padding: .5rem .9rem; border-radius: 0 8px 8px 0; margin-bottom: .7rem; font-size: .95rem; }
.q-text { font-size: 1.12rem; font-weight: 600; } .q-text p { margin: 0 0 .4em; }
.q-code { margin: .6rem 0 0; }
.q-help { font-size: .85rem; color: var(--muted); margin: 0 0 .5rem; }
.opts { display: grid; gap: .5rem; }
.opt { display: flex; align-items: flex-start; gap: .7rem; text-align: left; padding: .7rem .9rem; border-radius: 10px; border: 1.5px solid var(--line-2); background: var(--bg-2); color: var(--text); font: inherit; cursor: pointer; transition: border-color .12s, background .12s, transform .06s; }
.opt:hover:not(:disabled) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--bg-2)); }
.opt:active:not(:disabled) { transform: scale(.995); }
.opt.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, var(--bg-2)); }
.opt.correct { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 18%, var(--bg-2)); }
.opt.wrong { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 16%, var(--bg-2)); }
.opt:disabled { cursor: default; opacity: .9; }
.opt-key { flex: none; width: 26px; height: 26px; border-radius: 7px; background: var(--surface-2); display: grid; place-items: center; font-weight: 800; font-size: .8rem; }
.opt.selected .opt-key { background: var(--accent); color: #fff; } .opt.correct .opt-key { background: var(--ok); color: #062; } .opt.wrong .opt-key { background: var(--danger); color: #fff; }
.opt-check.selected .opt-key::before { content: '☑'; } .opt-check .opt-key { font-size: 1rem; }
.opt-check.selected .opt-key { font-size: 0; } .opt-check.selected .opt-key::before { font-size: 1rem; }
.opts-tf { grid-template-columns: 1fr 1fr; } .opt-tf { justify-content: center; font-weight: 700; font-size: 1.05rem; }
.sortable { list-style: none; padding: 0; margin: 0; display: grid; gap: .4rem; counter-reset: pos; }
.sort-item { display: flex; align-items: center; gap: .6rem; padding: .6rem .8rem; background: var(--bg-2); border: 1.5px solid var(--line-2); border-radius: 10px; counter-increment: pos; }
.sort-item::before { content: counter(pos); width: 24px; height: 24px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-size: .75rem; font-weight: 800; flex: none; }
.grip { cursor: grab; color: var(--muted); user-select: none; } .sort-text { flex: 1; }
.sort-btns { display: flex; gap: .2rem; } .mini { background: var(--surface-2); border: 1px solid var(--line-2); color: var(--text); border-radius: 6px; width: 26px; height: 24px; cursor: pointer; font-size: .7rem; }
.sort-item.correct { border-color: var(--ok); } .sort-item.wrong { border-color: var(--danger); }
.pos-tag { font-size: .75rem; color: var(--muted); }
.sortable-ghost { opacity: .4; } .sortable-chosen { box-shadow: var(--shadow); }
.matching { display: grid; gap: .5rem; }
.match-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: .6rem; align-items: center; padding: .5rem .7rem; background: var(--bg-2); border: 1.5px solid var(--line-2); border-radius: 10px; }
.match-row.correct { border-color: var(--ok); } .match-row.wrong { border-color: var(--danger); }
.match-left { font-weight: 600; } .match-arrow { color: var(--muted); } .match-select { margin: 0; }
.match-fix { grid-column: 1 / -1; font-size: .85rem; color: var(--ok); }
.classify { display: grid; gap: .8rem; }
.bucket { min-height: 64px; padding: .5rem; border: 1.5px dashed var(--line-2); border-radius: 10px; background: var(--bg-2); display: flex; flex-wrap: wrap; gap: .4rem; align-content: flex-start; }
.bucket.pool { border-style: solid; }
.bucket-title { width: 100%; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.buckets { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .6rem; }
.chip { padding: .35rem .7rem; border-radius: 999px; background: var(--surface-2); border: 1.5px solid var(--line-2); cursor: grab; font-size: .92rem; user-select: none; }
.chip.correct { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 18%, var(--surface-2)); } .chip.wrong { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 16%, var(--surface-2)); }
.chip-fix { font-size: .8rem; color: var(--ok); margin-left: .3rem; }
.fill-text { font-size: 1.05rem; line-height: 2.2; }
.fill-select { width: auto; display: inline-block; padding: .25rem .5rem; margin: 0 .2rem; }
.fill-select.correct { border-color: var(--ok); } .fill-select.wrong { border-color: var(--danger); } .fill-fix { color: var(--ok); font-size: .9rem; }
.num-row { display: flex; align-items: center; gap: .6rem; margin: 0; } .num-input { max-width: 220px; font-size: 1.15rem; font-family: var(--mono); }
.num-input.correct { border-color: var(--ok); } .num-input.wrong { border-color: var(--danger); } .num-unit { font-weight: 700; color: var(--muted); } .num-fix { color: var(--ok); margin-top: .4rem; font-size: .9rem; }
.conf-row { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; padding: .6rem .8rem; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line); }
.conf-label { font-size: .85rem; color: var(--muted); margin-right: .3rem; font-weight: 600; }
.conf-btn { display: inline-flex; gap: .4rem; align-items: center; padding: .4rem .7rem; border-radius: 999px; border: 1.5px solid var(--line-2); background: var(--surface); color: var(--text); font: inherit; font-size: .88rem; cursor: pointer; }
.conf-btn.selected { border-color: var(--purple); background: color-mix(in srgb, var(--purple) 22%, var(--surface)); }
.conf-btn:disabled { opacity: .6; cursor: default; }
.hint-box { padding: .6rem .9rem; border-radius: 10px; background: color-mix(in srgb, var(--warn) 12%, var(--surface)); border: 1px solid var(--warn); }
.q-actions { display: flex; gap: .6rem; align-items: center; }
.feedback { border-radius: var(--radius); padding: 1rem 1.1rem; border: 1.5px solid var(--line-2); animation: pop .25s ease; }
.fb-ok { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, var(--surface)); }
.fb-ko { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, var(--surface)); }
.fb-partial { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 8%, var(--surface)); }
.fb-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .5rem; }
.fb-title { font-weight: 800; font-size: 1.1rem; } .fb-xp { font-weight: 800; color: var(--gold); font-size: 1.1rem; animation: pop .4s ease; }
.fb-hyper { padding: .5rem .8rem; border-radius: 8px; background: color-mix(in srgb, var(--purple) 18%, var(--surface)); margin-bottom: .6rem; font-size: .92rem; }
.fb-expl { font-size: .98rem; }
.fb-actions { display: flex; gap: .6rem; justify-content: flex-end; margin-top: .6rem; }
@keyframes pop { from { transform: scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- play (quiz/boss) ---- */
.play { max-width: 820px; margin: 0 auto; }
.hud { position: sticky; top: 58px; z-index: 5; display: flex; align-items: center; gap: 1rem; padding: .6rem .9rem; background: color-mix(in srgb, var(--surface) 92%, transparent); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 1rem; backdrop-filter: blur(8px); }
.hud-boss { border-color: var(--danger); }
.hud-back { color: var(--muted); font-weight: 700; font-size: 1.1rem; }
.hud-progress { flex: 1; display: flex; align-items: center; gap: .6rem; }
.hud-bar { flex: 1; height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; } .hud-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--purple)); transition: width .5s; }
.hud-count { font-weight: 700; font-size: .9rem; color: var(--muted); }
.combo { display: flex; align-items: center; gap: .3rem; padding: .25rem .6rem; border-radius: 999px; background: var(--bg-2); font-size: .9rem; opacity: .6; transition: all .2s; }
.combo.hot { opacity: 1; background: color-mix(in srgb, var(--orange) 25%, var(--bg-2)); transform: scale(1.05); }
.combo.blazing { background: linear-gradient(135deg, var(--orange), var(--danger)); color: #fff; animation: pulse-hot 1s infinite; }
@keyframes pulse-hot { 50% { transform: scale(1.12); } }
.run-xp { font-weight: 800; color: var(--gold); }
.lives { display: flex; gap: .15rem; font-size: 1.15rem; } .heart.on { color: var(--danger); } .heart.off { color: var(--line-2); }
.xp-float { position: absolute; right: 1rem; top: -10px; color: var(--gold); font-weight: 800; animation: floatUp 1.3s ease forwards; pointer-events: none; }
@keyframes floatUp { from { transform: translateY(10px); opacity: 0; } 30% { opacity: 1; } to { transform: translateY(-40px); opacity: 0; } }
.q-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem 1.3rem; box-shadow: var(--shadow); animation: pop .25s ease; }
.boss-banner { display: flex; align-items: center; gap: 1rem; padding: .8rem 1.2rem; border-radius: var(--radius); background: linear-gradient(135deg, color-mix(in srgb, var(--danger) 35%, var(--surface)), var(--surface)); border: 1px solid var(--danger); margin-bottom: 1rem; }
.boss-skull { font-size: 2.2rem; } .boss-title { font-weight: 900; letter-spacing: .2em; color: var(--danger); } .boss-sub { color: var(--muted); }
.shake { animation: shake .5s; } @keyframes shake { 10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(4px); } 30%, 50%, 70% { transform: translateX(-6px); } 40%, 60% { transform: translateX(6px); } }
.summary { max-width: 760px; margin: 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); display: grid; gap: 1rem; }
.summary.passed { border-color: var(--ok); } .summary.failed { border-color: var(--danger); }
.summary-head { display: flex; gap: 1.4rem; align-items: center; } .summary-head h1 { margin: 0 0 .3rem; }
.summary-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; }
.sstat { background: var(--bg-2); border-radius: 10px; padding: .6rem; text-align: center; } .sstat-val { font-weight: 800; font-size: 1.2rem; } .sstat-label { font-size: .75rem; color: var(--muted); }
.bonuses { display: grid; gap: .3rem; } .bonus { display: flex; justify-content: space-between; padding: .4rem .8rem; background: color-mix(in srgb, var(--gold) 12%, var(--surface)); border-radius: 8px; } .bonus b { color: var(--gold); }
.completion-note { padding: .7rem 1rem; border-radius: 10px; background: color-mix(in srgb, var(--ok) 15%, var(--surface)); font-weight: 700; }
.per-q { list-style: none; padding: 0; margin: .5rem 0 0; display: grid; gap: .25rem; }
.per-q li { display: grid; grid-template-columns: 28px 24px 1fr auto auto; gap: .6rem; align-items: center; padding: .35rem .6rem; border-radius: 8px; background: var(--bg-2); font-size: .88rem; }
.per-q li.ok .pq-res { color: var(--ok); } .per-q li.ko .pq-res { color: var(--danger); } .per-q li.partial .pq-res { color: var(--warn); }
.pq-i { color: var(--muted); } .pq-res { font-weight: 800; } .pq-tags { color: var(--muted); } .pq-diff { color: var(--gold); font-size: .7rem; letter-spacing: .1em; } .pq-xp { color: var(--gold); font-weight: 700; }
.summary-actions { display: flex; gap: .6rem; flex-wrap: wrap; justify-content: flex-end; }
.loot { display: grid; place-items: center; padding: .5rem; }
.loot-card { width: 220px; height: 130px; perspective: 900px; cursor: pointer; position: relative; }
.loot-front, .loot-back { position: absolute; inset: 0; border-radius: 14px; display: grid; place-items: center; backface-visibility: hidden; transition: transform .7s cubic-bezier(.2,.8,.2,1); padding: .8rem; text-align: center; }
.loot-front { background: linear-gradient(135deg, var(--purple), var(--accent)); color: #fff; font-size: 2rem; } .loot-front span { font-size: .85rem; }
.loot-back { background: linear-gradient(135deg, var(--gold), var(--orange)); color: #222; transform: rotateY(180deg); font-size: .9rem; } .loot-back p { margin: .3rem 0 0; font-size: .82rem; }
.loot-card.flipped .loot-front { transform: rotateY(180deg); } .loot-card.flipped .loot-back { transform: rotateY(360deg); }
.loot-card:not(.flipped) .loot-front { animation: wiggle 2s infinite; } @keyframes wiggle { 0%, 100% { transform: rotate(0); } 90% { transform: rotate(0); } 93% { transform: rotate(-3deg); } 96% { transform: rotate(3deg); } }

/* ---- ripasso ---- */
.review-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.review-info { display: flex; gap: .5rem; align-items: center; margin-bottom: .8rem; }
.review-info .pill { background: var(--surface-2); color: var(--text); font-size: .8rem; }

/* ---- statistiche ---- */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.span-2 { grid-column: 1 / -1; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; }
.kpi { background: var(--bg-2); border-radius: 10px; padding: .7rem .8rem; } .kpi-val { font-size: 1.5rem; font-weight: 800; } .kpi-label { font-weight: 600; font-size: .85rem; } .kpi-sub { font-size: .75rem; color: var(--muted); }
.chart-wrap { position: relative; height: 240px; }
.tag-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .3rem; font-size: .92rem; }
.tag { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-weight: 700; font-size: .82rem; }
.tag.ok { background: color-mix(in srgb, var(--ok) 25%, var(--surface)); color: var(--ok); } .tag.ko { background: color-mix(in srgb, var(--danger) 22%, var(--surface)); color: var(--danger); }
.plain { list-style: none; padding: 0; margin: 0; } .plain li { padding: .25rem 0; border-bottom: 1px solid var(--line); } .plain li:last-child { border: 0; }
.table { width: 100%; font-size: .92rem; } .table th, .table td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; } .table th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; }
.table.small { font-size: .84rem; } .table-wrap { overflow-x: auto; } .table tr.inactive { opacity: .5; }
.ev-data { font-family: var(--mono); font-size: .75rem; color: var(--muted); max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.narrative p { font-size: 1.02rem; }
.refl-list blockquote { margin: 0 0 .8rem; padding: .6rem .9rem; background: var(--bg-2); border-left: 3px solid var(--purple); border-radius: 0 8px 8px 0; }
.notes li p { margin: .1rem 0 .4rem; }
.levels { list-style: none; padding: 0; margin: 0; display: grid; gap: .25rem; }
.levels li { display: grid; grid-template-columns: 28px 1fr auto; gap: .6rem; padding: .35rem .6rem; border-radius: 8px; font-size: .9rem; }
.levels li.done { color: var(--muted); } .levels li.current { background: color-mix(in srgb, var(--gold) 18%, var(--surface)); font-weight: 700; }
.lv-n { font-weight: 800; } .lv-xp { color: var(--muted); }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; margin-top: .6rem; }
.badge-tile { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: .7rem; text-align: center; }
.badge-tile.earned { border-color: var(--gold); background: linear-gradient(160deg, color-mix(in srgb, var(--gold) 18%, var(--surface)), var(--surface)); }
.badge-tile.locked { opacity: .55; } .badge-emoji { font-size: 1.8rem; } .badge-name { font-weight: 700; font-size: .9rem; } .badge-desc { font-size: .75rem; color: var(--muted); }
.glossary-all dt { font-weight: 700; margin-top: .8rem; } .glossary-all dd { margin: 0; color: var(--muted); } .gl-ch { font-size: .75rem; font-weight: 400; }
.content-mods details { margin: .3rem 0; }

/* ---- toast, modal, confetti ---- */
.toasts { position: fixed; right: 1rem; bottom: 1rem; display: grid; gap: .5rem; z-index: 60; max-width: 360px; }
.toast { background: var(--surface-2); border: 1px solid var(--line-2); padding: .7rem 1rem; border-radius: 12px; box-shadow: var(--shadow); transform: translateY(12px); opacity: 0; transition: all .25s; font-weight: 600; }
.toast.show { transform: none; opacity: 1; }
.toast-success { border-color: var(--ok); } .toast-error { border-color: var(--danger); }
.modal-overlay { position: fixed; inset: 0; background: rgba(5,8,20,.6); display: grid; place-items: center; z-index: 50; opacity: 0; transition: opacity .2s; padding: 1rem; }
.modal-overlay.show { opacity: 1; }
.modal { position: relative; background: var(--surface); border: 1px solid var(--line-2); border-radius: 16px; padding: 1.4rem 1.5rem; width: min(560px, 100%); box-shadow: var(--shadow); transform: scale(.96); transition: transform .2s; }
.modal-overlay.show .modal { transform: none; }
.modal-title { margin-bottom: .6rem; } .modal-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1rem; }
.modal-x { position: absolute; top: .6rem; right: .8rem; background: none; border: 0; color: var(--muted); font-size: 1.4rem; cursor: pointer; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; display: none; }
.form label { margin-bottom: .7rem; }

/* ---- responsive ---- */
@media (max-width: 960px) {
  .layout-2 { grid-template-columns: 1fr; } .sidebar { position: static; }
  .login-wrap { grid-template-columns: 1fr; gap: 1.5rem; } .login-card { justify-self: stretch; max-width: none; }
  .stats-grid { grid-template-columns: 1fr; }
  .stages { grid-template-columns: 1fr 1fr; } .stage-grid { grid-template-columns: 1fr; }
  .mainnav { overflow-x: auto; } .xp-text { display: none; } .xp-bar { width: 70px; }
  .summary-stats { grid-template-columns: 1fr 1fr; } .summary-head { flex-direction: column; text-align: center; }
}
@media (max-width: 600px) {
  .main { padding: 1rem .8rem 3rem; } .topbar { gap: .6rem; padding: .5rem .8rem; } .brand-text { display: none; }
  .match-row { grid-template-columns: 1fr; } .match-arrow { display: none; } .opts-tf { grid-template-columns: 1fr; }
  .ch-title-row { flex-direction: column; align-items: flex-start; } .conf-text { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
