:root {
  --primary: #c0392b;
  --primary-dark: #a93226;
  --primary-light: #fef2f2;
  --primary-light-hover: #fecaca;
  --teoria-primary: #2563eb;
  --teoria-primary-light: #eff6ff;
}

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

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f1f5f9;
  color: #334155;
  min-height: 100vh;
  width: 100%;
}

/* ── SCREENS ────────────────────────────────────────────────────────────── */
.screen { display: none; width: 100%; }
.screen.active {
  display: flex; align-items: flex-start; justify-content: center;
  min-height: 100vh; padding: 16px;
  animation: screenIn .3s ease-out;
}
#screen-quiz.active, #screen-riepilogo.active {
  display: block; max-width: 1100px; margin: 0 auto;
  padding: 8px; min-height: unset;
}
#screen-result.active {
  display: flex; align-items: center; justify-content: center;
}
@keyframes screenIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── START SCREEN ───────────────────────────────────────────────────────── */
.start-box {
  padding: 28px 24px; text-align: center;
  width: 100%; max-width: 1000px; margin: auto;
  position: relative;
}
.start-box h1 { color: var(--primary); font-size: 1.8rem; margin-bottom: 8px; }
.top-bar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px;
}
.back-hub {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600; color: var(--primary);
  text-decoration: none;
  background: var(--primary-light); border-radius: 20px; padding: 5px 14px;
  transition: background .2s;
}
.back-hub:hover { background: var(--primary-light-hover); }
.start-sub { color: #555; margin-bottom: 24px; font-size: .95rem; }

.mode-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
@media (max-width: 480px) {
  .mode-cards { grid-template-columns: 1fr; }
  .mode-card { padding: 18px 16px; gap: 10px; }
  .mode-icon { font-size: 1.6rem; }
}
.mode-card {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
  padding: 24px 20px; text-align: center;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.mode-card:hover { 
  transform: translateY(-3px);
  border-color: var(--primary); 
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.08);
}
.mode-icon { font-size: 2rem; }
.mode-title { font-size: 1.05rem; font-weight: bold; color: #1a1a2e; }
.mode-desc { font-size: .8rem; color: #666; line-height: 1.5; }
.mode-card > *:last-child { margin-top: auto; }

.form-row { text-align: left; }
.form-row label { display: block; font-weight: bold; font-size: .82rem; color: #333; margin-bottom: 3px; }
.form-row input {
  width: 100%; padding: 7px 10px; border: 1px solid #ccc;
  border-radius: 6px; font-size: .95rem;
}
.category-select {
  width: 100%; padding: 7px 8px; border: 1px solid #e2e8f0;
  border-radius: 8px; font-size: .85rem; color: #333; background: #fff;
  transition: border-color .2s;
}
.category-select:focus { border-color: var(--primary); outline: none; }

/* ── BUTTONS ────────────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--primary); color: #fff; border: none;
  padding: 10px 22px; border-radius: 8px; font-size: .95rem;
  cursor: pointer; width: 100%; transition: background .2s, transform .15s;
}
.btn-primary:hover { background: var(--primary-dark); }
/* Stats strip */
.stats-strip {
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: center;
  margin-bottom: 20px;
}
.stat-chip {
  border-radius: 10px; padding: 8px 14px;
  font-size: .85rem; color: #334; font-weight: 500;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  opacity: 0; animation: chipIn .3s ease forwards;
  white-space: nowrap;
}
.stat-chip:nth-child(2) { animation-delay: .05s; }
.stat-chip:nth-child(3) { animation-delay: .1s; }
.stat-chip:nth-child(4) { animation-delay: .15s; }
.stat-chip:nth-child(5) { animation-delay: .2s; }
@keyframes chipIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (max-width: 480px) {
  .stats-strip { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 6px; justify-items: stretch; }
  .stat-chip {
    width: 100%; max-width: 100%; box-sizing: border-box;
    text-align: center; justify-content: center; display: flex;
    padding: 7px 8px; font-size: .78rem;
  }
  .stat-chip--debole, .stat-chip--sfide, .stat-chip--verdetto { grid-column: 1 / -1; }
  .stat-chip--full { grid-column: 1 / -1; width: fit-content; max-width: fit-content; margin: 0 auto; }
}
.stat-chip--prove  { background: #e8f4fd; border: 1px solid #b3d9f2; }
.stat-chip--prove strong  { color: #2563eb; }
.stat-chip--media  { background: #e8fde8; border: 1px solid #a3d9a3; }
.stat-chip--serie  { background: #fff3e0; border: 1px solid #f0c080; }
.stat-chip--serie strong  { color: #c2410c; }
.stat-chip--debole { background: #fde8e8; border: 1px solid #f0b3b3; transition: all .2s; }
.stat-chip--debole strong { color: var(--primary); }
.stat-chip--debole:hover  { background: #f5c6c6; transform: scale(1.03); }
.stat-chip--sfide  { background: linear-gradient(135deg, #f3e8fd, #e8f0fd); border: 1px solid #c5b3e6; }
.stat-chip--sfide strong  { color: #047857; }
.stat-chip--full   { background: #eef1ff; border: 1px solid #c9d2f5; cursor: pointer; transition: all .2s; }
.stat-chip--full:hover { background: #dde4fb; transform: scale(1.03); }
/* Verdetto: chip a contenuto lungo, quindi riga intera su mobile (stessa
   regola di Debole e Sfide, vedi media query qui sopra) */
.stat-chip--verdetto { background: #f4f1ff; border: 1px solid #c9bdf0; cursor: pointer; transition: all .2s; }
.stat-chip--verdetto:hover { background: #e9e2fd; transform: scale(1.03); }

/* ── Modale statistiche complete ───────────────────────────────────────── */
.stats-modal-h { margin: 0 0 8px; font-size: .9rem; color: #2563eb; }
.stats-modal-h:not(:first-child) { margin-top: 20px; }
.cat-stat-list { display: flex; flex-direction: column; gap: 6px; }
.cat-stat-row { display: grid; grid-template-columns: 1fr 90px 70px; align-items: center; gap: 8px; font-size: .8rem; }
.cat-stat-label { color: #334; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-stat-bar-wrap { background: #eee; border-radius: 6px; height: 10px; overflow: hidden; }
.cat-stat-bar { height: 100%; border-radius: 6px; transition: width .3s; }
.cat-stat-pct { text-align: right; font-weight: 600; color: #334; white-space: nowrap; }
.cat-stat-n { font-weight: 400; opacity: .6; font-size: .82em; }
.hist-list { display: flex; flex-direction: column; gap: 4px; }
.hist-row { display: grid; grid-template-columns: 1fr 70px 55px 50px; align-items: center; gap: 8px; font-size: .78rem; padding: 6px 8px; border-radius: 6px; background: #f8f9fb; border-left: 3px solid transparent; }
.hist-row.hist-pass { border-left-color: #10b981; }
.hist-row.hist-fail { border-left-color: #ef4444; }
.hist-date { color: #888; }
.hist-mode { color: #556; }
.hist-score { font-weight: 600; text-align: right; }
.hist-pct { text-align: right; color: #666; }
@media (max-width: 480px) {
  .cat-stat-row { grid-template-columns: 1fr 50px 75px; }
  .cat-stat-n { font-size: .7rem; }
  .hist-row { grid-template-columns: 1fr 50px 45px; }
  .hist-mode { display: none; }
}

/* ── Verdetto (blocco in cima alla modale statistiche) ──────────────────── */
.verdetto-box {
  border: 1px solid #e2e8f0; border-left: 5px solid #94a3b8;
  border-radius: 12px; padding: 14px 16px; margin-bottom: 6px; background: #f8fafc;
}
.verdetto-verde  { border-left-color: #10b981; background: #ecfdf5; }
.verdetto-giallo { border-left-color: #f59e0b; background: #fffbeb; }
.verdetto-rosso  { border-left-color: #ef4444; background: #fef2f2; }
.verdetto-attesa { border-left-color: #94a3b8; }
.verdetto-k { font-size: .72rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: #64748b; }
.verdetto-n { font-size: 2.2rem; font-weight: 800; line-height: 1.1; margin: 4px 0 2px; color: #1a1a2e; }
/* Il numero è il messaggio: l'unità va accanto, piccola, non sopra */
.verdetto-n span { display: block; font-size: .78rem; font-weight: 600; color: #64748b; letter-spacing: 0; }
.verdetto-msg { font-size: .92rem; color: #334; margin-top: 6px; }
.verdetto-nota { font-size: .74rem; line-height: 1.5; color: #64748b; margin-top: 8px; }
.verdetto-come { border-top: 1px dashed #cbd5e1; padding-top: 8px; }
.verdetto-costi-t { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: #64748b; margin: 12px 0 5px; }
/* minmax(0,1fr) e non 1fr: col nome lungo la colonna non si restringerebbe e
   uscirebbe dallo schermo sul telefono */
.verdetto-costo {
  display: grid; grid-template-columns: minmax(0,1fr) auto auto auto;
  gap: 8px; align-items: center;
  background: #fff; border: 1px solid #e2e8f0; border-radius: 8px;
  padding: 7px 10px; margin-bottom: 5px; font-size: .8rem; cursor: pointer;
  transition: all .15s;
}
.verdetto-costo:hover { border-color: #2563eb; background: #f5f8ff; }
.vc-nome { font-weight: 600; color: #334; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vc-x2 { font-size: .68rem; font-weight: 700; color: #b45309; background: #fef3c7; border-radius: 10px; padding: 1px 5px; }
.vc-pct { color: #64748b; font-variant-numeric: tabular-nums; }
.vc-costo { font-weight: 700; color: #c0392b; font-variant-numeric: tabular-nums; }
.vc-go { font-size: .68rem; font-weight: 700; color: #2563eb; white-space: nowrap; }
.verdetto-cta { margin-top: 14px; padding: 13px 14px; border-radius: 10px; background: linear-gradient(135deg, #eef2ff, #f5f3ff); border: 1px solid #c7d2fe; }
.vcta-t { font-weight: 700; font-size: .9rem; color: #1e3a8a; }
.verdetto-cta p { font-size: .8rem; line-height: 1.55; color: #475569; margin: 5px 0 10px; }
.vcta-btn { display: inline-block; background: #2563eb; color: #fff; text-decoration: none; font-weight: 700; font-size: .85rem; border-radius: 8px; padding: 9px 16px; }
.vcta-btn:hover { background: #1d4ed8; }
@media (max-width: 480px) {
  .verdetto-n { font-size: 1.9rem; }
  .verdetto-costo { grid-template-columns: minmax(0,1fr) auto auto; font-size: .76rem; }
  /* su schermo stretto la riga è già cliccabile tutta: l'invito si toglie
     invece di spingere fuori il nome del capitolo */
  .vc-go { display: none; }
  .vcta-btn { display: block; text-align: center; }
}

/* Ripasso btn */
.btn-ripasso {
  background: #8e44ad; color: #fff; border: none;
  padding: 10px 22px; border-radius: 8px; font-size: .95rem;
  cursor: pointer; width: 100%; transition: background .2s, transform .15s;
}
.btn-ripasso:hover { background: #7d3c98; }
.btn-ripasso:disabled { background: #bbb; cursor: default; }

.btn-secondary {
  background: #7f8c8d; color: #fff; border: none;
  padding: 8px 18px; border-radius: 8px; font-size: .9rem; cursor: pointer;
  transition: background .2s, transform .15s;
}
.btn-secondary:hover { background: #626c6d; }
.btn-secondary-green {
  background: #10b981; color: #fff; border: none;
  padding: 10px 22px; border-radius: 8px; font-size: .95rem;
  cursor: pointer; width: 100%; transition: background .2s, transform .15s;
}
.btn-secondary-green:hover { background: #059669; }

/* ── QUIZ MODE BAR ──────────────────────────────────────────────────────── */
.quiz-mode-bar {
  padding: 8px 16px; margin-bottom: 8px;
  font-size: .85rem; font-weight: bold;
  border-radius: 8px; text-align: center;
  border: 1px solid transparent;
}
.mode-exam     { background: var(--primary-light); color: var(--primary); border-color: var(--primary-light-hover); }
.mode-trainer  { background: #f0fdf4; color: #166534; border-color: #dcfce7; }
.mode-training { background: #eff6ff; color: #1e40af; border-color: #dbeafe; }

/* ── TAB ROW ────────────────────────────────────────────────────────────── */
.tab-row {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 6px; margin-bottom: 8px;
  background: #f1f5f9; padding: 4px; border-radius: 8px;
}
.tab-btn {
  background: transparent; border: none; border-radius: 6px;
  padding: 8px 4px; font-size: .82rem; text-align: center;
  cursor: pointer; line-height: 1.3; color: #64748b;
  transition: all .2s ease;
}
.tab-btn:hover { color: #334155; background: rgba(255,255,255,0.5); }
.tab-btn.active {
  background: #ffffff; color: var(--primary);
  font-weight: bold;
  box-shadow: 0 1px 3px 0 rgba(0,0,0,0.05), 0 1px 2px -1px rgba(0,0,0,0.05);
}

/* ── NUM ROW ────────────────────────────────────────────────────────────── */
.num-row {
  display: grid; grid-template-columns: repeat(10, 1fr);
  gap: 6px; margin-bottom: 8px;
}
.num-cell {
  text-align: center; padding: 8px 2px;
  border: 1px solid #e2e8f0; border-radius: 8px;
  font-size: .85rem; font-weight: bold;
  cursor: pointer; background: #ffffff; color: #64748b; user-select: none;
  transition: all .15s ease;
}
.num-cell:hover { background: #f8fafc; color: #1e293b; border-color: #cbd5e1; }
.num-cell.current  { background: var(--primary); color: #fff; border-color: var(--primary); }
.num-cell.correct  { background: #10b981; color: #fff; border-color: #10b981; }
.num-cell.wrong    { background: #ef4444; color: #fff; border-color: #ef4444; }
.num-cell.answered { background: #3b82f6; color: #fff; border-color: #3b82f6; }

/* ── STRIP ROW ──────────────────────────────────────────────────────────── */
.strip-row {
  display: flex; gap: 2px; margin-bottom: 5px; flex-wrap: wrap;
}
.strip-cell {
  width: 22px; height: 18px; line-height: 18px;
  text-align: center; font-size: .62rem;
  border: 1px solid #e2e8f0; border-radius: 4px;
  cursor: pointer; background: #f8fafc; color: #64748b; user-select: none;
  transition: all .15s ease;
}
.strip-cell.current  { background: var(--primary); color: #fff; border-color: var(--primary); }
.strip-cell.correct  { background: #10b981; color: #fff; }
.strip-cell.wrong    { background: #ef4444; color: #fff; }
.strip-cell.answered { background: #3b82f6; color: #fff; }

/* ── MAIN CONTENT ───────────────────────────────────────────────────────── */
.main-content {
  display: grid; grid-template-columns: 240px 1fr;
  gap: 6px; margin-bottom: 5px;
}
@media (max-width: 600px) {
  .main-content { grid-template-columns: 1fr; }
}
.img-panel {
  border: 1px solid #e2e8f0; border-radius: 12px; background: #fff;
  display: flex; align-items: center; justify-content: center;
  min-height: 150px;
  box-shadow: 0 1px 3px 0 rgba(0,0,0,0.05);
}
.img-placeholder {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%; color: #aaa; font-size: 2rem; padding: 8px;
}
.img-placeholder img { max-width: 100%; max-height: 180px; object-fit: contain; }

.q-panel { display: flex; flex-direction: column; gap: 6px; }
.q-header {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
  padding: 14px 52px 14px 16px; position: relative;
  min-height: 85px; overflow-y: auto; flex: 1;
  box-shadow: 0 1px 3px 0 rgba(0,0,0,0.05);
}
.q-text { font-size: 1.1rem; line-height: 1.6; color: #333; }
.q-num {
  position: absolute; top: 8px; right: 8px;
  border: 1px solid #e2e8f0; border-radius: 8px;
  padding: 3px 9px; font-size: .82rem; font-weight: bold;
  color: #475569; background: #f8fafc; white-space: nowrap;
}
.btn-tts-q {
  position: absolute; bottom: 8px; right: 8px;
  background: none; border: none; font-size: 1.2rem;
  cursor: pointer; padding: 4px; line-height: 1;
  opacity: .5; transition: opacity .2s;
}
.btn-tts-q:hover, .btn-tts-q.tts-playing { opacity: 1; }

/* V/F */
.vf-row {
  display: flex; gap: 20px; justify-content: center;
  background: #fff; border: 1px solid #e2e8f0;
  border-radius: 12px; padding: 12px;
  box-shadow: 0 1px 3px 0 rgba(0,0,0,0.05);
}
.btn-vf {
  width: 66px; height: 66px; border-radius: 50%;
  border: 2px solid #cbd5e1; background: #fff;
  font-size: 1.6rem; font-weight: bold;
  cursor: pointer; color: #475569; transition: all .2s ease;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 1px 3px 0 rgba(0,0,0,0.05);
}
@media (hover: hover) {
  #btn-V:hover:not(:disabled) { border-color: #10b981; color: #047857; background: #f0fdf4; transform: scale(1.05); }
  #btn-F:hover:not(:disabled) { border-color: #ef4444; color: #ef4444; background: #fef2f2; transform: scale(1.05); }
}
#btn-V:active:not(:disabled) { border-color: #10b981; color: #047857; background: #f0fdf4; transform: scale(0.95); }
#btn-F:active:not(:disabled) { border-color: #ef4444; color: #ef4444; background: #fef2f2; transform: scale(0.95); }
.btn-vf.selected-correct { background: #10b981 !important; border-color: #10b981 !important; color: #fff !important; }
.btn-vf.selected-wrong   { background: #ef4444 !important; border-color: #ef4444 !important; color: #fff !important; }
.btn-vf.selected-pending { background: #3b82f6 !important; border-color: #3b82f6 !important; color: #fff !important; }
.btn-vf.unselected       { opacity: .35; transform: scale(0.95); }
.btn-vf:disabled         { cursor: default; }

/* Feedback risposta */
.answer-feedback {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: #fff; border: 1px solid #e2e8f0;
  border-radius: 12px; padding: 10px 14px;
  box-shadow: 0 1px 3px 0 rgba(0,0,0,0.05);
}
.answer-feedback.feedback-correct { border-color: #10b981; background: #f0faf4; }
.answer-feedback.feedback-wrong   { border-color: #ef4444; background: #fdf3f2; }
#feedback-icon { font-size: 1.4rem; }
#feedback-text { font-size: .88rem; font-weight: bold; flex: 1; }
.btn-teoria {
  background: #2563eb; color: #fff; border: none;
  padding: 6px 14px; border-radius: 8px; font-size: .8rem;
  cursor: pointer; white-space: nowrap; transition: background .2s, transform .15s;
}
.btn-teoria:hover { background: #1d4ed8; }
.btn-avanti {
  background: #475569; color: #fff; border: none;
  padding: 6px 14px; border-radius: 8px; font-size: .8rem;
  cursor: pointer; white-space: nowrap; margin-left: auto; transition: background .2s, transform .15s;
}
.btn-avanti:hover { background: #333; }

/* Matrix hint inline (solo trainer) */
.matrix-hint-inline {
  background: #fffbea; color: #78350f;
  border-radius: 5px; padding: 7px 12px;
  font-size: .78rem; line-height: 1.6;
  border-left: 4px solid #f59e0b;
  border: 1px solid #fcd34d;
  border-left: 4px solid #f59e0b;
}
.matrix-hint-inline .hint-label {
  font-size: .7rem; color: #b45309; font-weight: bold;
  letter-spacing: .3px;
}
.hint-toggle {
  cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: 6px;
}
.hint-toggle:hover { color: #92400e; }
.hint-arrow { font-size: .6rem; }
.hint-content { margin-top: 6px; }

/* Regole & Mnemoniche button */
.btn-matrix {
  background: #d35400; color: #fff; border: none;
  padding: 12px 24px; border-radius: 24px; font-size: 1rem;
  font-weight: 700; cursor: pointer;
  letter-spacing: .01em; transition: background .2s;
  box-shadow: 0 2px 8px rgba(211,84,0,.35);
}
.btn-matrix:hover { background: #ba4a00; }

/* Tasto Manuale di Teoria — colore dedicato (blu manuale) */
.btn-manuale {
  background: #1d4ed8; text-decoration: none; display: inline-block;
  box-shadow: 0 2px 8px rgba(29,78,216,.35);
}
.btn-manuale:hover { background: #1e3a8a; }

/* Modale wide per Matrix */
.modal-box-wide { max-width: 720px; }

/* ── Decoder cards (nel modale) ──────────────────────────────────────────── */
.decoder-card {
  border-radius: 8px; padding: 12px 14px; margin-bottom: 12px;
  border-left: 4px solid;
}
.decoder-false { background: #fff5f5; border-color: #ef4444; }
.decoder-true  { background: #f0faf4; border-color: #10b981; }
.decoder-header {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap; margin-bottom: 6px;
}
.decoder-word {
  font-weight: bold; font-size: .9rem; color: #222;
}
.decoder-verdict {
  font-size: .75rem; font-weight: bold; padding: 2px 8px;
  border-radius: 10px;
}
.decoder-false .decoder-verdict { background: #fde; color: var(--primary); }
.decoder-true  .decoder-verdict { background: #d5f5e3; color: #059669; }
.decoder-prob {
  margin-left: auto; font-size: .82rem; font-weight: bold;
}
.decoder-prob-false { color: #ef4444; }
.decoder-prob-true  { color: #047857; }
.decoder-bar-bg {
  height: 5px; background: #e0e0e0; border-radius: 3px; margin-bottom: 8px;
}
.decoder-bar { height: 5px; border-radius: 3px; transition: width .3s; }
.decoder-bar-false { background: #ef4444; }
.decoder-bar-true  { background: #10b981; }
.decoder-desc { font-size: .82rem; color: #444; margin-bottom: 6px; line-height: 1.5; }
.decoder-examples { font-size: .78rem; }
.decoder-ex-label { color: #888; display: block; margin-bottom: 3px; }
.decoder-ex { color: #555; font-style: italic; margin-bottom: 2px; }
.decoder-ex::before { content: '• '; }

/* ── Keyword highlight nel testo domanda ─────────────────────────────────── */
.kw-highlight {
  font-weight: bold; cursor: pointer;
  border-radius: 3px; padding: 0 2px;
  border-bottom: 2px dashed;
}
.kw-false { background: #fde8e8; color: var(--primary); border-color: #ef4444; }
.kw-true  { background: #e8f8ee; color: #059669; border-color: #10b981; }
.kw-highlight:hover { opacity: .8; }

/* Tooltip keyword */
.kw-tooltip {
  position: relative; margin-top: 8px;
  border-radius: 8px; padding: 10px 12px;
  font-size: .8rem; line-height: 1.5;
  border-left: 4px solid;
}
.kw-tooltip-false { background: #fff5f5; border-color: #ef4444; }
.kw-tooltip-true  { background: #f0faf4; border-color: #10b981; }
.kw-tip-close {
  float: right; background: none; border: none;
  cursor: pointer; font-size: .85rem; color: #999; padding: 0;
}
.kw-tip-label   { font-weight: bold; font-size: .88rem; color: #222; margin-bottom: 2px; }
.kw-tip-verdict { font-size: .75rem; font-weight: bold; margin-bottom: 5px; }
.kw-tooltip-false .kw-tip-verdict { color: var(--primary); }
.kw-tooltip-true  .kw-tip-verdict { color: #059669; }
.kw-tip-bar-bg  { height: 5px; background: #e0e0e0; border-radius: 3px; margin-bottom: 5px; }
.kw-tip-bar     { height: 5px; border-radius: 3px; }
.kw-tip-bar-false { background: #ef4444; }
.kw-tip-bar-true  { background: #10b981; }
.kw-tip-prob    { font-size: .78rem; font-weight: bold; margin-bottom: 4px; }
.kw-tooltip-false .kw-tip-prob { color: #ef4444; }
.kw-tooltip-true  .kw-tip-prob { color: #047857; }
.kw-tip-desc    { font-size: .75rem; color: #555; }

/* Tab bar nel modale */
.matrix-tab-bar {
  display: flex; gap: 6px; padding: 12px 18px 0;
  border-bottom: 2px solid #eee; background: #fff;
  position: sticky; top: 0; z-index: 1;
}
.matrix-tab-btn {
  padding: 7px 14px; border: none; border-radius: 6px 6px 0 0;
  font-size: .82rem; cursor: pointer; font-weight: bold;
  background: #f1f5f9; color: #64748b; border-bottom: 2px solid transparent;
  transition: all .15s;
}
.matrix-tab-btn:hover { background: #e0e0e0; color: #333; }
.matrix-tab-btn.active {
  background: #fff; color: #d35400;
  border: 2px solid #eee; border-bottom: 2px solid #fff;
  margin-bottom: -2px;
}
.matrix-tab-content { padding: 16px 18px; }

/* Associazioni cards */
.assoc-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px,1fr));
  gap: 10px;
}
.assoc-card {
  background: #f8fafc; border: 1px solid #e2e8f0;
  border-radius: 8px; padding: 12px 14px;
  border-left: 4px solid #d35400;
}
.assoc-trigger {
  font-weight: bold; font-size: .9rem; color: #d35400; margin-bottom: 2px;
}
.assoc-arrow { font-size: .8rem; color: #aaa; margin-bottom: 2px; }
.assoc-label { font-size: .78rem; color: #888; margin-bottom: 4px; }
.assoc-value {
  font-size: .85rem; color: #222; font-weight: 600; line-height: 1.5;
}

/* Matrix content styles */
.matrix-section {
  margin-bottom: 22px; border-left: 3px solid #00d4aa;
  padding-left: 12px;
}
.matrix-section h4 {
  color: #1a1a2e; font-size: .95rem; margin-bottom: 8px;
  background: #e8faf7; padding: 4px 8px; border-radius: 4px;
}
.matrix-rule {
  display: flex; gap: 10px; align-items: flex-start;
  margin-bottom: 6px; font-size: .85rem; line-height: 1.5;
}
.matrix-rule .rule-key {
  background: #1a1a2e; color: #00d4aa; font-weight: bold;
  padding: 1px 7px; border-radius: 4px; white-space: nowrap;
  font-size: .78rem; margin-top: 2px;
}
.matrix-mnemonic {
  background: #fffbea; border: 1px dashed #f39c12;
  padding: 6px 10px; border-radius: 4px; font-style: italic;
  font-size: .83rem; margin: 6px 0; color: #7d5a00;
}
.matrix-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr));
  gap: 6px; margin: 6px 0;
}
.matrix-grid-cell {
  background: #f0faf8; border: 1px solid #b2e0d8;
  border-radius: 5px; padding: 6px 9px; font-size: .82rem;
}
.matrix-grid-cell strong { color: #1a1a2e; display: block; font-size: .78rem; }

/* ── BOTTOM BAR ─────────────────────────────────────────────────────────── */
.bottom-bar {
  display: flex; align-items: center; gap: 6px;
  background: #fff; border: 1px solid #e2e8f0;
  border-radius: 12px; padding: 8px 12px;
  flex-wrap: wrap;
  box-shadow: 0 1px 3px 0 rgba(0,0,0,0.05);
}
.timer-box { min-width: 100px; }
.timer-label { font-size: .68rem; color: #333; }
.timer-value { font-size: 1.3rem; font-weight: bold; color: var(--primary); }
.timer-value.warning { color: #c2410c; }
.timer-value.danger  { color: #ef4444; animation: blink .8s step-start infinite; }
@keyframes blink { 50% { opacity: 0; } }

.info-box { flex: 1; font-size: .76rem; min-width: 80px; }
.info-label { font-weight: bold; color: #555; }

.nav-box { display: flex; gap: 5px; }
.btn-nav {
  width: 44px; height: 44px; border-radius: 50%;
  border: 2px solid #cbd5e1; background: #f1f5f9;
  font-size: 1.2rem; cursor: pointer; color: #475569;
  display: flex; align-items: center; justify-content: center;
  transition: all .2s ease;
}
.btn-nav:hover { background: #e2e8f0; border-color: #94a3b8; }
.btn-nav:disabled { opacity: .3; cursor: default; }

.vocal-box { display: flex; align-items: center; }
.btn-vocal {
  border-radius: 20px;
  border: 2px solid #cbd5e1; background: #fff;
  font-size: .85rem; cursor: pointer; transition: all .2s;
  display: flex; align-items: center; gap: 4px;
  padding: 6px 14px; white-space: nowrap;
  color: #475569;
}
.vocal-label { font-size: .75rem; font-weight: 600; }
.btn-vocal.vocal-active {
  border-color: #ef4444; background: #fef2f2;
  animation: vocalPulse 1.5s infinite;
}
@keyframes vocalPulse { 0%,100%{box-shadow:0 0 0 0 rgba(239,68,68,.4)} 50%{box-shadow:0 0 0 8px rgba(239,68,68,0)} }

.btn-riepilogo {
  background: #f8fafc; border: 1px solid #e2e8f0;
  border-radius: 8px; padding: 4px 8px;
  cursor: pointer; font-size: .68rem; text-align: center;
  transition: all .2s;
}
.btn-riepilogo:hover { background: #e2e8f0; }
.riepilogo-icon { font-size: .72rem; line-height: 1.4; }
.ri-check { color: #047857; }
.riepilogo-label { font-size: .62rem; color: #555; margin-top: 1px; }

/* ── RIEPILOGO ──────────────────────────────────────────────────────────── */
.riepilogo-header {
  background: #fff; border-radius: 8px; padding: 14px;
  margin-bottom: 10px; display: flex;
  align-items: center; gap: 10px; flex-wrap: wrap;
}
.riepilogo-header h2 { flex: 1; color: #333; font-size: 1.1rem; }
#riepilogo-result { font-size: .95rem; font-weight: bold; }
.riepilogo-btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn-hub { display: inline-flex; align-items: center; padding: 6px 14px; border-radius: 8px; border: 1.5px solid #e2e8f0; background: #f8fafc; font-size: .76rem; font-weight: 600; color: #475569; text-decoration: none; cursor: pointer; user-select: none; transition: all .2s; }
.btn-hub:hover { background: #e2e8f0; border-color: #cbd5e1; }

.riepilogo-table { display: flex; flex-direction: column; gap: 5px; }
.riepilogo-row {
  display: grid;
  grid-template-columns: 30px 1fr 80px 60px 65px;
  align-items: center; gap: 6px;
  background: #fff; border-radius: 6px;
  padding: 9px 10px; border-left: 4px solid #ccc; cursor: pointer;
}
@media (max-width: 600px) {
  .riepilogo-row { grid-template-columns: 24px 1fr 60px; }
  .riepilogo-row .ra-correct,
  .riepilogo-row .ru { display: none; }
}
.riepilogo-row.correct { border-left-color: #10b981; }
.riepilogo-row.wrong   { border-left-color: #ef4444; }
.riepilogo-row.skipped { border-left-color: #f39c12; }
.riepilogo-row:hover   { background: #f8f8f8; }
.riepilogo-row .rn { font-weight: bold; color: #555; font-size: .85rem; }
.riepilogo-row .rt { font-size: .85rem; color: #333; }
.riepilogo-row .ra-correct { color: #047857; font-weight: bold; font-size: .82rem; }
.riepilogo-row .ru { font-size: .82rem; color: #888; }
.badge {
  padding: 2px 7px; border-radius: 10px;
  font-size: .72rem; font-weight: bold; text-align: center;
}
.badge-ok   { background: #d5f5e3; color: #059669; }
.badge-err  { background: #fadbd8; color: #922b21; }
.badge-skip { background: #fef9e7; color: #9a7d0a; }

/* ── RESULT ─────────────────────────────────────────────────────────────── */
.result-box {
  background: #fff; border-radius: 12px;
  padding: 40px 32px; text-align: center;
  box-shadow: 0 4px 20px rgba(0,0,0,.2);
  max-width: 380px; width: 90%;
}
#result-icon { font-size: 3.5rem; margin-bottom: 10px; }
#result-title { font-size: 1.6rem; margin-bottom: 6px; }
#result-msg { color: #555; margin-bottom: 18px; font-size: .9rem; }
#result-stats { margin-bottom: 20px; }
.stat-row { font-size: .95rem; margin: 5px 0; }
.stat-row span { font-weight: bold; }

/* Invito al metodo dopo una bocciatura: dorato come tutto ciò che è Premium,
   sotto il punteggio e sopra la lista degli errori. */
.premium-invite {
  max-width: 380px; margin: 4px auto 16px; padding: 14px 16px;
  background: #fffbeb; border: 1.5px solid #fbbf24; border-radius: 12px;
  text-align: center;
}
.premium-invite .pi-testo { font-size: .88rem; color: #78350f; line-height: 1.45; }
.premium-invite .pi-dato { display: block; margin-top: 7px; font-size: .78rem; color: #92400e; opacity: .9; }
/* Ambra scura e non #f59e0b: il bianco su #f59e0b fa 2,1:1, cioè l'etichetta
   del bottone più importante del funnel era la meno leggibile della pagina.
   #b45309 fa 5,0:1 e resta dorato dentro la cornice #fbbf24. */
.premium-invite .pi-btn {
  display: inline-block; margin-top: 11px; padding: 9px 20px;
  background: #b45309; color: #fff; border-radius: 999px;
  font-size: .86rem; font-weight: 700; text-decoration: none; transition: background .2s;
}
.premium-invite .pi-btn:hover { background: #92400e; }

/* Confronto con le altre prove della giornata, sotto il riepilogo punteggio.
   Blu del brand: è un'informazione, non una promozione né un allarme. */
.perc-line {
  max-width: 340px; margin: -8px auto 18px; padding: 9px 12px;
  background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 10px;
  color: #1e40af; font-size: .87rem; font-weight: 600;
  line-height: 1.35; text-align: center;
}

/* ── RESULT ─────────────────────────────────────────────────────────────── */
.result-container {
  width: 100%; max-width: 800px; margin: auto;
  display: flex; flex-direction: column; gap: 16px; padding: 16px;
}
.result-errors {
  background: #fff; border-radius: 10px; padding: 16px;
  box-shadow: 0 2px 10px rgba(0,0,0,.1);
}
.errors-title {
  font-size: 1rem; color: #ef4444; margin-bottom: 12px;
}
.error-item {
  border-left: 3px solid #ef4444; padding: 12px 14px;
  margin-bottom: 10px; background: #fff8f8; border-radius: 8px;
}
.error-item:last-child { margin-bottom: 0; }
.error-q { font-size: .88rem; color: #333; margin-bottom: 6px; line-height: 1.5; }
.error-answers {
  display: flex; gap: 10px; font-size: .8rem; margin-bottom: 6px; flex-wrap: wrap;
}
.error-wrong { color: #ef4444; font-weight: bold; }
.error-correct { color: #047857; font-weight: bold; }
.error-btn-teoria {
  background: #2563eb; color: #fff; border: none;
  padding: 4px 12px; border-radius: 6px; font-size: .75rem;
  cursor: pointer; transition: background .2s;
}
.error-btn-teoria:hover { background: #1d4ed8; }

/* ── ADSENSE ────────────────────────────────────────────────────────────── */
.adsense-box { width: 100%; min-height: 100px; }

/* ── MODALE TEORIA ──────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 16px;
}
.modal-box {
  background: #fff; border-radius: 10px;
  width: 100%; max-width: 560px;
  max-height: 80vh; display: flex; flex-direction: column;
  box-shadow: 0 8px 30px rgba(0,0,0,.3);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid #eee;
}
.modal-header h3 { color: #2563eb; font-size: 1rem; }
.modal-header-actions { display: flex; align-items: center; gap: 8px; }
.btn-tts {
  background: #f0f4ff; border: 1px solid #c5d0f0;
  border-radius: 50%; width: 34px; height: 34px;
  font-size: 1rem; cursor: pointer; transition: background .2s;
  display: flex; align-items: center; justify-content: center;
}
.btn-tts:hover { background: #dce6ff; }
.btn-tts.tts-playing { background: #e8f8ee; border-color: #10b981; }
.modal-close {
  background: none; border: none; font-size: 1.2rem;
  cursor: pointer; color: #888; padding: 2px 6px;
}
.modal-close:hover { color: #333; }
.modal-body {
  padding: 0; overflow-y: auto; flex: 1;
  font-size: .88rem; line-height: 1.7; color: #333;
}
/* Per il modale teoria (non matrix) ripristina padding */
#modal-body { padding: 16px 18px; }

/* ── Contenuto teoria importato da manuale.html ────────────────────────── */
#modal-body .intro {
  background: var(--teoria-primary-light); border-left: 4px solid var(--teoria-primary);
  border-radius: 0 6px 6px 0; padding: 10px 12px; margin-bottom: 14px;
  font-size: .85rem; color: #334155;
}
#modal-body .section-title {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: .75rem; text-transform: uppercase; letter-spacing: .05em;
  color: #64748b; margin: 16px 0 8px; font-weight: 700;
}
#modal-body .section-title:first-child { margin-top: 0; }
#modal-body .rules-list { list-style: none; }
#modal-body .rules-list li {
  padding: 6px 0 6px 22px; border-bottom: 1px solid #eee;
  font-size: .85rem; position: relative; line-height: 1.5;
}
#modal-body .rules-list li:last-child { border-bottom: none; }
#modal-body .rules-list li::before { content: "✓"; position: absolute; left: 0; color: #16a34a; font-weight: 700; }

#modal-body .warning-box {
  background: #fff7ed; border-left: 4px solid #e67e22; border-radius: 0 6px 6px 0;
  padding: 8px 12px; margin-top: 12px; font-size: .8rem; color: #7c2d12;
}
#modal-body .warning-box strong { color: #c0530a; }
#modal-body .warning-box ul { list-style: none; margin-top: 6px; }
#modal-body .warning-box li { padding: 5px 0 5px 20px; position: relative; border-bottom: 1px dashed #fcd9b0; }
#modal-body .warning-box li:last-child { border-bottom: none; }
#modal-body .warning-box li::before { content: "✗"; position: absolute; left: 0; color: #c2410c; font-weight: 700; }

#modal-body .tip-box {
  background: #ecfdf5; border-left: 4px solid #16a34a; border-radius: 0 6px 6px 0;
  padding: 8px 12px; margin-top: 12px; font-size: .8rem; color: #14532d;
}
#modal-body .tip-box strong { color: #15803d; }

#modal-body .cat-card {
  background: #f8fafc; border-radius: 8px; padding: 10px 12px;
  border: 1px solid #e2e8f0; margin-bottom: 8px;
}
#modal-body .cat-card-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
#modal-body .cat-badge {
  background: var(--teoria-primary); color: #fff; font-weight: 700; font-size: .78rem;
  border-radius: 6px; padding: 2px 8px; flex-shrink: 0;
}
#modal-body .cat-age { font-size: .74rem; color: #64748b; font-weight: 600; }
#modal-body .cat-card ul { list-style: none; }
#modal-body .cat-card li { font-size: .82rem; padding: 2px 0 2px 16px; position: relative; line-height: 1.5; }
#modal-body .cat-card li::before { content: "•"; position: absolute; left: 2px; color: var(--teoria-primary); font-weight: 700; }
#modal-body .cat-includes { font-size: .74rem; color: #0f766e; margin-top: 4px; font-weight: 600; }
#modal-body .cat-note { font-size: .74rem; color: #7c2d12; margin-top: 4px; }

#modal-body .diagram-card {
  display: flex; gap: 10px; align-items: flex-start; background: #f8fafc;
  border: 1px solid #e2e8f0; border-radius: 8px; padding: 10px 12px; margin-bottom: 8px;
}
#modal-body .diagram-card img { width: 90px; height: auto; flex-shrink: 0; background: #fff; border: 1px solid #e2e8f0; border-radius: 6px; padding: 3px; }
#modal-body .diagram-card ul { list-style: none; flex: 1; }
#modal-body .diagram-card li { font-size: .82rem; padding: 2px 0 2px 16px; position: relative; line-height: 1.5; }
#modal-body .diagram-card li::before { content: "•"; position: absolute; left: 2px; color: var(--teoria-primary); font-weight: 700; }

#modal-body .numbers-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; margin-top: 8px; }
#modal-body .number-card { background: #f8fafc; border-radius: 8px; padding: 8px 10px; border: 1px solid #e2e8f0; }
#modal-body .number-card .val { font-size: .95rem; font-weight: 700; color: var(--teoria-primary); }
#modal-body .number-card .label { font-size: .72rem; color: #64748b; margin-top: 2px; }

.section-tts-btn {
  background: #f0f4ff; border: 1px solid #c5d0f0; border-radius: 50%;
  width: 22px; height: 22px; font-size: .7rem; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  text-transform: none; letter-spacing: normal; font-weight: 400;
}
.section-tts-btn:hover { background: #dce6ff; }
.section-tts-btn.tts-playing { background: #e8f8ee; border-color: #10b981; }

/* ── MOBILE QUIZ ────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  #screen-quiz.active, #screen-riepilogo.active {
    padding: 4px;
  }
  .tab-row { display: none; }
  .strip-row { gap: 1px; }
  .strip-cell { width: 18px; height: 16px; font-size: .55rem; }
  .num-row { grid-template-columns: repeat(10, 1fr); }
  .num-cell { font-size: .72rem; padding: 4px 1px; }
  .bottom-bar { gap: 10px; padding: 8px 10px; row-gap: 12px; }
  .timer-value { font-size: 1.1rem; }
  .info-box { display: none; }
  .btn-vf { width: 54px; height: 54px; font-size: 1.3rem; }
}

/* ── BANNER ADS ─────────────────────────────────────────────────────────── */

/* TOP — orizzontale, piena larghezza */
.ad-top {
  width: 100%;
  max-width: 100%;
  background: #f8f8f8;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid #e8e8e8;
  overflow: hidden;
}
.ad-top:not(:has(iframe)), .ad-top:has(ins[data-ad-status="unfilled"]) { display: none; }
.ad-bottom:not(:has(iframe)), .ad-bottom:has(ins[data-ad-status="unfilled"]) { display: none; }

/* BOTTOM — identico al top */
.ad-bottom {
  width: 100%;
  max-width: 100%;
  background: #f8f8f8;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-top: 1px solid #e8e8e8;
  margin-top: 16px;
}

/* LATERALE — fisso ai lati, solo desktop */
.ad-side {
  display: none;
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 160px;
  z-index: 50;
}
.ad-side-right { right: 8px; }
.ad-side-left  { left: 8px; }

/* Mostra laterali solo se c'è abbastanza spazio */
@media (min-width: 1300px) {
  .ad-side { display: block; }
}

/* Su mobile: nascondi laterali, top e bottom sempre visibili */
@media (max-width: 767px) {
  .ad-top { min-height: 0; }
  .ad-side { display: none !important; }
}

/* ── TOP BUTTONS ROW ────────────────────────────────────────────────────── */
.top-btns {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
  align-items: stretch;
}
@media (max-width: 480px) {
  .top-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .top-btns .btn-matrix,
  .top-btns .btn-search { padding: 10px 12px; font-size: .85rem; }
  .top-btns .btn-search { grid-column: 1 / -1; }
}

/* ── CERCA DOMANDA button ───────────────────────────────────────────────── */
.btn-search {
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 24px;
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .2s;
  letter-spacing: .01em;
}
.btn-search:hover { background: #1d4ed8; }

/* ── SEARCH MODAL ───────────────────────────────────────────────────────── */
.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px 8px;
  border-bottom: 1px solid #eee;
}
.search-input {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 1rem;
  outline: none;
  transition: border-color .2s;
}
.search-input:focus { border-color: #2563eb; }
.search-count {
  font-size: .8rem;
  color: #888;
  white-space: nowrap;
  min-width: 80px;
  text-align: right;
}
.search-results {
  max-height: 460px;
  overflow-y: auto;
  padding: 10px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.search-item {
  background: #f9f9fb;
  border: 1px solid #e8eaf0;
  border-radius: 8px;
  padding: 10px 14px;
  transition: border-color .15s;
}
.search-item:hover { border-color: #2563eb; }
.search-item-text {
  font-size: .92rem;
  color: #333;
  line-height: 1.5;
}
.search-item-text mark {
  background: #fff3b0;
  color: #333;
  border-radius: 3px;
  padding: 0 2px;
}
.search-item-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}
.search-num { font-size: .75rem; color: #aaa; }
.search-badge {
  font-size: .75rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 12px;
}
.badge-vero  { background: #e8f8ee; color: #059669; }
.badge-falso { background: #fde8e8; color: var(--primary); }

/* ── SFIDA ─────────────────────────────────────────────────────────────── */
.mode-card-challenge { border: 2px solid #e67e22 !important; background: linear-gradient(135deg, #fff 60%, #fef5ec) !important; }
.btn-challenge {
  background: #e67e22; color: #fff; border: none; padding: 10px 20px;
  border-radius: 8px; font-size: .95rem; font-weight: 700; cursor: pointer;
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 6px;
}
.btn-challenge:hover { background: #d35400; }

/* ── AREA PREMIUM ──────────────────────────────────────────────────────── */
.mode-card-premium { border: 2px solid #fbbf24 !important; background: linear-gradient(135deg, #fff 60%, #fff7e6) !important; }
/* stesso motivo di .pi-btn: bianco su #f59e0b è 2,1:1 */
.btn-premium {
  background: #b45309; color: #fff; border: none; padding: 10px 20px;
  border-radius: 8px; font-size: .95rem; font-weight: 700; cursor: pointer;
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 6px;
  text-decoration: none; box-sizing: border-box;
}
.btn-premium:hover { background: #92400e; }

.challenge-share-box {
  background: #fef5ec; border: 2px solid #e67e22; border-radius: 12px;
  padding: 20px; margin-top: 16px; text-align: center;
}
.challenge-share-title { font-size: 1.1rem; font-weight: 700; color: #d35400; margin-bottom: 8px; }
.challenge-share-sub { font-size: .85rem; color: #666; margin-bottom: 14px; }
.challenge-link-box {
  display: flex; gap: 8px; align-items: center; margin-bottom: 12px;
  flex-wrap: wrap;
}
.challenge-link-input {
  flex: 1; min-width: 0; padding: 10px; border: 1px solid #ddd; border-radius: 8px;
  font-size: .78rem; color: #333; background: #fff; overflow: hidden; text-overflow: ellipsis;
}
.challenge-copy-btn {
  background: #e67e22; color: #fff; border: none; padding: 10px 16px;
  border-radius: 8px; font-size: .82rem; font-weight: 700; cursor: pointer;
  white-space: nowrap;
}
.challenge-copy-btn:hover { background: #d35400; }
.challenge-wa-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: #25d366; color: #fff; border: none; padding: 14px 24px;
  border-radius: 12px; font-size: .95rem; font-weight: 700; cursor: pointer;
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(37,211,102,.4), 0 2px 4px rgba(0,0,0,.1);
  transition: all .15s;
}
.challenge-wa-btn:hover { background: #1da855; transform: translateY(-1px); box-shadow: 0 6px 16px rgba(37,211,102,.5), 0 3px 6px rgba(0,0,0,.12); }
.challenge-wa-btn svg { width: 28px; height: 28px; fill: #fff; }

.challenge-vs {
  display: flex; align-items: center; justify-content: center; gap: 20px;
  margin: 16px 0; flex-wrap: wrap;
}
.challenge-player {
  text-align: center; min-width: 100px;
}
.challenge-player-label { font-size: .75rem; color: #888; margin-bottom: 4px; }
.challenge-player-score { font-size: 2rem; font-weight: 700; }
.challenge-player-score.win { color: #047857; }
.challenge-player-score.lose { color: #ef4444; }
.challenge-player-score.draw { color: #c2410c; }
.challenge-vs-icon { font-size: 1.5rem; color: #c2410c; font-weight: 700; }

.challenge-result-msg {
  text-align: center; font-size: 1.1rem; font-weight: 700;
  padding: 12px; border-radius: 8px; margin-top: 12px;
}
.challenge-result-msg.win { background: #e8f8ee; color: #059669; }
.challenge-result-msg.lose { background: #fde8e8; color: var(--primary); }
.challenge-result-msg.draw { background: #fef5ec; color: #d35400; }

.challenge-rematch {
  display: inline-flex; align-items: center; gap: 6px;
  background: #e67e22; color: #fff; border: none; padding: 10px 20px;
  border-radius: 8px; font-size: .9rem; font-weight: 700; cursor: pointer;
  margin-top: 12px;
}
.challenge-rematch:hover { background: #d35400; }

/* ── CONSEGNA ──────────────────────────────────────────────────────────── */
.btn-consegna {
  background: #10b981; color: #fff; border: none;
  padding: 8px 18px; border-radius: 8px; font-size: .9rem;
  font-weight: 700; cursor: pointer; transition: background .2s, transform .15s;
}
.btn-consegna:hover { background: #059669; }
.search-empty {
  text-align: center;
  color: #aaa;
  padding: 30px;
  font-size: .9rem;
}

/* ── SOCIAL SHARE ───────────────────────────────────────────────────────── */
.social-share { display: flex; gap: 8px; }
.social-btn {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; text-decoration: none;
  transition: transform .15s, opacity .15s;
}
.social-btn svg { width: 17px; height: 17px; }
.social-btn:hover { transform: scale(1.12); opacity: .9; }
.social-wa { background: #25d366; }
.social-fb { background: #1877f2; }
.social-tg { background: #229ed9; }

/* ── FOOTER CREDIT ──────────────────────────────────────────────────────── */
.start-footer {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid #e8eaf0;
  text-align: center;
  font-size: .78rem;
  color: #64748b;
  letter-spacing: .02em;
}
.start-footer strong {
  color: #888;
  font-weight: 600;
}
.visit-chip {
  margin-left: 14px;
  font-size: .75rem;
  color: #99a;
}

body:has(#screen-quiz.active) .ad-top,
body:has(#screen-quiz.active) #wa-float,
body:has(#screen-result.active) #wa-float,
body:has(#screen-riepilogo.active) #wa-float { display: none !important; }

.donate-link { white-space: nowrap; text-align: center; line-height: 1.3;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 700; color: #b45309; background: #fff7e6;
  border: 1.5px solid #fbbf24; padding: 9px 20px; border-radius: 999px;
  text-decoration: none; transition: all .2s;
}
.donate-link:hover { background: #fbbf24; color: #fff; border-color: #fbbf24; }
.result-donate { text-align: center; margin-top: 16px; }
.result-donate a {
  text-align: center; line-height: 1.3;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 700; color: #b45309; background: #fff7e6;
  border: 1.5px solid #fbbf24; padding: 9px 20px; border-radius: 999px;
  text-decoration: none; transition: all .2s;
}
.result-donate a:hover { background: #fbbf24; color: #fff; border-color: #fbbf24; }

/* ── CORIANDOLI PROMOZIONE ──────────────────────────────────────────────── */
.confetti-layer {
  position: fixed; inset: 0; overflow: hidden;
  pointer-events: none; z-index: 3000;
}
.confetti-piece {
  position: absolute; top: -14px;
  width: 8px; height: 14px; border-radius: 2px;
  opacity: .95;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  to { transform: translate3d(var(--drift, 0px), 105vh, 0) rotate(var(--spin, 540deg)); }
}

/* ── INDICATORE PRONTEZZA ESAME ─────────────────────────────────────────── */
.ready-banner {
  flex-basis: 100%; width: 100%;
  border-radius: 10px; padding: 9px 14px;
  font-size: .85rem; line-height: 1.5; text-align: center;
  border: 1px solid transparent;
  opacity: 0; animation: readyIn .35s ease forwards;
}
.ready-banner u { text-underline-offset: 2px; cursor: pointer; }
.ready-ok  { background: #ecfdf5; border-color: #6ee7b7; color: #065f46; }
.ready-mid { background: #fffbeb; border-color: #fcd34d; color: #92400e; }
.ready-low { background: #fef2f2; border-color: #fca5a5; color: #991b1b; }
@keyframes readyIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (max-width: 480px) { .ready-banner { grid-column: 1 / -1; } }

/* ── SCELTA ARGOMENTO (griglia) ─────────────────────────────────────────── */
.argomento-box { width: 100%; max-width: 1000px; margin: auto; }
.argomento-header { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.argomento-header h2 { font-size: 1.15rem; color: #1a1a2e; }
.argomento-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.arg-card {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
  padding: 10px 12px; cursor: pointer; display: flex; align-items: center; gap: 10px;
  transition: all .15s ease; box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.arg-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.08); }
.arg-ico { width: 42px; height: 42px; object-fit: contain; flex-shrink: 0; }
.arg-info { flex: 1; min-width: 0; }
.arg-title { font-size: .82rem; font-weight: 700; color: #1e293b; line-height: 1.3; }
.arg-count { font-size: .72rem; color: #64748b; margin-top: 2px; }
.arg-pct { font-size: .78rem; font-weight: 700; border-radius: 10px; padding: 2px 8px; flex-shrink: 0; }
.arg-pct.ok  { background: #ecfdf5; color: #059669; }
.arg-pct.mid { background: #fffbeb; color: #b45309; }
.arg-pct.low { background: #fef2f2; color: #dc2626; }
@media (max-width: 480px) {
  .argomento-grid { grid-template-columns: 1fr 1fr; }
  .arg-card { flex-direction: column; text-align: center; padding: 12px 8px; gap: 6px; }
}

.arg-pct-n { font-weight: 400; font-size: .85em; opacity: .75; }

/* ── Ritorno alla Mappa del metodo ─────────────────────────────────────────
   Compare SOLO a chi è arrivato qui dalla Mappa (?ritorno=metodo) e solo a
   scheda finita o non ancora iniziata — vedi mostraRitorno() in app.js.
   Blu #1d4ed8 e non il rosso del quiz di proposito: è il colore dell'Area
   Premium, così si legge come "torna di là" e non come un bottone del quiz.
   Col bianco fa 6,7:1. */
.barra-ritorno {
  display: block; max-width: 640px; margin: 0 auto 14px; padding: 13px 18px;
  background: #1d4ed8; color: #fff; text-decoration: none;
  border-radius: 10px; font-size: .95rem; font-weight: 700; text-align: center;
  box-shadow: 0 2px 8px rgba(29, 78, 216, .25);
}
.barra-ritorno:hover { background: #1e3a8a; }

/* ── Esito del Ripasso Errori ──────────────────────────────────────────────
   Prende il posto dell'elenco degli errori, che dopo un ripasso è un doppione:
   in modalità training le risposte giuste le hai già viste domanda per domanda.
   Vedi renderEsitoRipasso() in app.js. */
.rip-esito { text-align: left; }
.rip-riga { font-size: .95rem; padding: 11px 14px; border-radius: 10px; margin-bottom: 8px; }
.rip-riga b { font-size: 1.15rem; }
.rip-riga.ok { background: #ecfdf5; color: #065f46; }
.rip-riga.ko { background: #fef2f2; color: #991b1b; }
.rip-tot { font-size: .86rem; color: #4a5568; line-height: 1.55; margin-top: 10px; }

/* ── Abbonato attivo: via gli inviti a pagare ──────────────────────────────
   La classe la mette controllaPremium() in app.js dopo aver chiesto al server.
   Si nasconde con una regola CSS e non cancellando i nodi perché
   `.premium-invite` viene creato a fine simulazione, quindi dopo il controllo:
   così vale anche per lui senza doverlo ricontrollare ogni volta.
   La card "Area Premium" in home NON sparisce: per un abbonato è la porta
   d'ingresso, non una pubblicità. */
body.premium-attivo .donate-link,
body.premium-attivo .result-donate,
body.premium-attivo .premium-invite { display: none; }
