/* ===== Palette del deck ===== */
:root {
  --navy: #1E2761;
  --navy-2: #2b357e;
  --ice: #CADCFC;
  --amber: #F2A104;
  --ink: #14183a;
  --paper: #f4f6fc;
  --white: #ffffff;
  --green: #1f9d63;
  --red: #d1495b;
  --muted: #6a7194;
  --shadow: 0 8px 30px rgba(30, 39, 97, .12);
  --radius: 16px;
  font-family: Calibri, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .kicker { font-family: Cambria, Georgia, serif; }

#app {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100vh;
  padding: clamp(1rem, 4vw, 2rem);
  display: flex;
  flex-direction: column;
}

.view { flex: 1; display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* ===== Hero (schermate scure) ===== */
.hero {
  background: linear-gradient(160deg, var(--navy), var(--navy-2));
  color: var(--white);
  border-radius: var(--radius);
  padding: clamp(1.5rem, 6vw, 2.75rem);
  text-align: center;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}
.hero.tight { padding-bottom: 1.5rem; }
.kicker {
  text-transform: uppercase;
  letter-spacing: .18em;
  font-size: .72rem;
  color: var(--amber);
  font-weight: 700;
  margin-bottom: .6rem;
}
.hero h1 { font-size: clamp(1.6rem, 6vw, 2.3rem); line-height: 1.15; }
.subtitle { color: var(--ice); margin-top: .6rem; font-size: 1.02rem; }

/* ===== Griglia blocchi (home) ===== */
.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .85rem;
  margin-bottom: 1.25rem;
}
.block-card {
  background: var(--white);
  border: 2px solid transparent;
  border-radius: var(--radius);
  padding: 1.1rem;
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .12s ease, border-color .12s ease;
  font-family: inherit;
  color: inherit;
}
.block-card:hover { transform: translateY(-3px); border-color: var(--ice); }
.block-card:active { transform: translateY(0); }
.block-card.full { grid-column: 1 / -1; background: var(--navy); color: var(--white); }
.block-card.full .bc-count { color: var(--ice); }
.block-num {
  display: inline-block;
  background: var(--amber);
  color: var(--navy);
  font-weight: 800;
  font-family: Cambria, serif;
  border-radius: 8px;
  padding: .05rem .5rem;
  font-size: .85rem;
  margin-bottom: .5rem;
}
.block-card.full .block-num { background: var(--amber); }
.bc-title { font-weight: 700; font-size: 1.02rem; display: block; }
.bc-count { color: var(--muted); font-size: .85rem; margin-top: .25rem; }

/* ===== Options bar ===== */
.options-bar {
  display: flex;
  flex-direction: column;
  gap: .6rem;
  background: var(--white);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.switch { display: flex; align-items: center; gap: .6rem; cursor: pointer; font-size: .95rem; }
.switch input { width: 1.15rem; height: 1.15rem; accent-color: var(--navy); cursor: pointer; }

.home-footer { text-align: center; margin-top: auto; padding-top: 1rem; }
.link-btn {
  background: none; border: none; color: var(--navy);
  font-family: inherit; font-size: .95rem; font-weight: 600;
  cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}

/* ===== Quiz topbar / progress ===== */
.quiz-topbar { display: flex; align-items: center; gap: .8rem; margin-bottom: 1.5rem; }
.progress { flex: 1; height: 8px; background: var(--ice); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: var(--amber); border-radius: 99px; transition: width .3s ease; }
.counter { font-size: .85rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
.ghost-btn {
  background: none; border: none; font-size: 1.2rem; color: var(--muted);
  cursor: pointer; width: 2.5rem; height: 2.5rem; border-radius: 50%;
  display: grid; place-items: center; font-family: inherit;
}
.ghost-btn:hover { background: var(--ice); color: var(--navy); }
.ghost-btn.wide { width: auto; height: auto; padding: .7rem 1.2rem; border-radius: 12px; font-size: 1rem; }

/* ===== Quiz body ===== */
.quiz-body { flex: 1; }
.q-block { color: var(--amber); font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; margin-bottom: .5rem; }
.q-text { font-size: clamp(1.25rem, 4.5vw, 1.6rem); line-height: 1.3; margin-bottom: 1.4rem; }

.answers { display: flex; flex-direction: column; gap: .7rem; }
.answer {
  display: flex; align-items: flex-start; gap: .8rem;
  background: var(--white); border: 2px solid #e2e7f5; border-radius: 14px;
  padding: 1rem 1.1rem; text-align: left; cursor: pointer;
  font-family: inherit; font-size: 1rem; color: var(--ink);
  transition: border-color .12s, background .12s;
  width: 100%;
}
.answer:hover:not(:disabled) { border-color: var(--navy); }
.answer:disabled { cursor: default; }
.answer .letter {
  flex-shrink: 0; width: 1.9rem; height: 1.9rem; border-radius: 50%;
  background: var(--ice); color: var(--navy); font-weight: 800;
  display: grid; place-items: center; font-family: Cambria, serif; font-size: .95rem;
}
.answer.correct { border-color: var(--green); background: #eafaf1; }
.answer.correct .letter { background: var(--green); color: #fff; }
.answer.wrong { border-color: var(--red); background: #fdecef; }
.answer.wrong .letter { background: var(--red); color: #fff; }
.answer.dim { opacity: .55; }

/* ===== Spiegazione ===== */
.explain {
  margin-top: 1.2rem; background: var(--white); border-left: 5px solid var(--amber);
  border-radius: 12px; padding: 1rem 1.15rem; box-shadow: var(--shadow);
}
.explain-verdict { font-weight: 800; font-family: Cambria, serif; margin-bottom: .35rem; }
.explain-verdict.ok { color: var(--green); }
.explain-verdict.no { color: var(--red); }
.explain-text { color: var(--ink); font-size: .98rem; }

/* ===== Footer / bottoni ===== */
.quiz-footer { padding-top: 1.5rem; }
.primary-btn {
  background: var(--navy); color: #fff; border: none; border-radius: 12px;
  padding: .95rem 1.5rem; font-size: 1.05rem; font-weight: 700; font-family: inherit;
  cursor: pointer; width: 100%; transition: background .12s, transform .1s;
}
.primary-btn:hover { background: var(--navy-2); }
.primary-btn:active { transform: scale(.99); }

/* ===== Risultati ===== */
.score-ring {
  width: 130px; height: 130px; border-radius: 50%; margin: .5rem auto 1rem;
  display: grid; place-items: center;
  background: conic-gradient(var(--amber) var(--pct, 0%), rgba(202,220,252,.25) 0);
}
.score-ring span {
  width: 104px; height: 104px; border-radius: 50%; background: var(--navy);
  display: grid; place-items: center; font-family: Cambria, serif;
  font-size: 1.8rem; font-weight: 800; color: #fff;
}
.block-breakdown { display: flex; flex-direction: column; gap: .6rem; margin-bottom: 1.5rem; }
.bd-row { display: flex; align-items: center; gap: .8rem; background: var(--white); border-radius: 12px; padding: .8rem 1rem; box-shadow: var(--shadow); }
.bd-label { flex: 1; font-weight: 600; font-size: .95rem; }
.bd-bar { flex: 1.2; height: 8px; background: var(--ice); border-radius: 99px; overflow: hidden; }
.bd-bar-fill { height: 100%; background: var(--green); border-radius: 99px; }
.bd-score { font-weight: 700; font-size: .9rem; color: var(--muted); width: 3rem; text-align: right; }

.review { display: flex; flex-direction: column; gap: .8rem; margin-bottom: 1.5rem; }
.review-title { font-family: Cambria, serif; font-weight: 700; margin-bottom: .3rem; }
.review-item { background: var(--white); border-radius: 12px; padding: 1rem 1.15rem; box-shadow: var(--shadow); border-left: 5px solid var(--red); }
.review-item .rq { font-weight: 700; margin-bottom: .5rem; }
.review-item .ra { font-size: .92rem; margin-bottom: .2rem; }
.review-item .ra .tag { font-weight: 700; }
.review-item .ra.your { color: var(--red); }
.review-item .ra.right { color: var(--green); }
.review-item .rexp { font-size: .9rem; color: var(--muted); margin-top: .5rem; }

.results-actions { display: flex; flex-direction: column; gap: .6rem; margin-top: auto; padding-top: 1rem; }

/* ===== Meta ===== */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .85rem; margin-bottom: 1.5rem; }
.stat {
  background: var(--white); border-radius: var(--radius); padding: 1.1rem;
  box-shadow: var(--shadow); border-top: 4px solid var(--amber);
}
.stat-value { font-family: Cambria, serif; font-size: 1.75rem; font-weight: 800; color: var(--navy); line-height: 1.1; }
.stat-label { font-weight: 700; font-size: .9rem; margin-top: .3rem; }
.stat-link { color: var(--navy); font-size: .8rem; margin-top: .35rem; display: block; }
.meta-narrative { display: flex; flex-direction: column; gap: .9rem; margin-bottom: 1.5rem; }
.mn-item { background: var(--white); border-radius: 12px; padding: 1rem 1.15rem; box-shadow: var(--shadow); }
.mn-item h3 { font-size: 1rem; color: var(--navy); margin-bottom: .3rem; }
.mn-item p { font-size: .94rem; color: var(--ink); }
.mn-item .link { color: var(--muted); font-size: .82rem; font-style: italic; }

/* ===== Desktop ===== */
@media (min-width: 620px) {
  .options-bar { flex-direction: row; justify-content: space-between; }
}
