/* Stile "a pomodoro": colori pieni, bordi spessi, pulsanti in rilievo. */
:root {
  --bg: #fffdfb;
  --card: #ffffff;
  --ink: #3c3c3c;
  --muted: #7a7a7a;
  --line: #e8e5e1;
  --brand: #ff4b4b;
  --brand-dark: #d33131;
  --brand-soft: #ffe8e6;
  --ok: #58b026;
  --ok-dark: #43901a;
  --ok-soft: #dcf8c6;
  --ok-ink: #3f7d14;
  --ko: #ea2b2b;
  --ko-dark: #b81d1d;
  --ko-soft: #ffe0e0;
  --ko-ink: #c42020;
  --sel: #1cb0f6;
  --sel-soft: #ddf4ff;
  --gold: #ff9600;
  --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131f24;
    --card: #1b2a31;
    --ink: #f1f7fb;
    --muted: #8fa3ad;
    --line: #37464f;
    --brand: #ff5c5c;
    --brand-dark: #c23b3b;
    --brand-soft: #3a2427;
    --ok: #5fc22a;
    --ok-dark: #3f8f17;
    --ok-soft: #1f3a1d;
    --ok-ink: #8fe05b;
    --ko: #ff5c5c;
    --ko-dark: #c23b3b;
    --ko-soft: #3c2226;
    --ko-ink: #ff8a8a;
    --sel: #3fbcf7;
    --sel-soft: #183846;
    --gold: #ffab3d;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 600 17px/1.5 "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
}
main {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px 24px;
}
h1 { font-size: 27px; line-height: 1.2; margin: 8px 0 6px; font-weight: 900; }
h2 { font-size: 20px; margin: 26px 0 12px; font-weight: 800; }
h3 { font-size: 18px; margin: 0 0 6px; font-weight: 800; }
p { margin: 0 0 12px; }
b { font-weight: 800; }
.muted { color: var(--muted); }
.small { font-size: 15px; }
.center { text-align: center; }

.card {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}

/* Pulsanti in rilievo: si "abbassano" quando li tocchi */
.btn {
  display: block;
  width: 100%;
  border: 0;
  border-radius: var(--radius);
  padding: 15px 18px;
  font: inherit;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: .04em;
  text-transform: uppercase;
  background: var(--brand);
  color: #fff;
  box-shadow: 0 4px 0 var(--brand-dark);
  cursor: pointer;
  text-align: center;
  transition: transform .06s, box-shadow .06s;
}
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 0 0 transparent; }
.btn + .btn { margin-top: 12px; }
.btn.light { background: var(--card); color: var(--brand); border: 2px solid var(--line); box-shadow: 0 4px 0 var(--line); }
.btn.verde { background: var(--ok); box-shadow: 0 4px 0 var(--ok-dark); }
.btn.rosso { background: var(--ko); box-shadow: 0 4px 0 var(--ko-dark); }
.btn.ghost { background: transparent; color: var(--muted); box-shadow: none; text-transform: none; letter-spacing: 0; font-weight: 700; }
.btn:disabled { background: var(--line); color: var(--muted); box-shadow: none; cursor: default; }

/* Barra in alto con fiamma, pomodori e preparazione */
.topbar { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.pill { display: flex; align-items: center; gap: 6px; font-weight: 900; font-size: 18px; padding: 6px 4px; }
.pill.fuoco { color: var(--gold); }
.pill.pomo { color: var(--brand); }
.pill.prep { color: var(--sel); }

/* Pomodorino e il suo fumetto */
.mascotte { display: flex; align-items: flex-end; gap: 10px; margin: 6px 0 18px; }
.mascotte svg { flex: none; }
.fumetto {
  position: relative; flex: 1;
  background: var(--card); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; font-weight: 700;
}
.fumetto::before {
  content: ""; position: absolute; left: -10px; bottom: 18px;
  border: 8px solid transparent; border-right: 10px solid var(--line); border-left: 0;
}
.fumetto::after {
  content: ""; position: absolute; left: -6px; bottom: 20px;
  border: 6px solid transparent; border-right: 8px solid var(--card); border-left: 0;
}
.saltella { animation: saltella 2.4s ease-in-out infinite; }
@keyframes saltella { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

.obiettivo { display: flex; align-items: center; gap: 14px; }
.obiettivo .grow { flex: 1; }
.bar { height: 14px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--brand); border-radius: 99px; transition: width .4s; }
.bar.verde i { background: var(--ok); }
.bar.sottile { height: 10px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { border: 2px solid var(--line); border-radius: var(--radius); padding: 10px 6px; text-align: center; background: var(--card); }
.stat b { display: block; font-size: 22px; font-weight: 900; }
.stat span { font-size: 13px; color: var(--muted); font-weight: 700; }
.stat.fuoco { border-color: var(--gold); } .stat.fuoco b { color: var(--gold); }
.stat.pomo { border-color: var(--brand); } .stat.pomo b { color: var(--brand); }
.stat.ok { border-color: var(--ok); } .stat.ok b { color: var(--ok); }

.list { display: flex; flex-direction: column; gap: 12px; }
.row {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 2px solid var(--line); border-bottom-width: 4px; border-radius: var(--radius);
  padding: 14px; cursor: pointer; text-align: left; font: inherit; color: inherit; width: 100%;
}
.row:active { transform: translateY(2px); border-bottom-width: 2px; margin-bottom: 2px; }
.row .em {
  font-size: 26px; width: 52px; height: 52px; flex: none; border-radius: 50%;
  display: grid; place-items: center; background: var(--brand-soft);
}
.row .grow { flex: 1; min-width: 0; }
.row .nome { font-weight: 800; line-height: 1.3; margin-bottom: 8px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 2px solid var(--line); border-bottom-width: 4px; background: var(--card); color: var(--ink);
  border-radius: 12px; padding: 8px 14px; font: inherit; font-size: 15px; font-weight: 800; cursor: pointer;
}
.chip.on { background: var(--sel-soft); border-color: var(--sel); color: var(--sel); }

/* Quiz */
.quiz-top { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.quiz-top .bar { flex: 1; height: 16px; }
.quiz-top .bar i { background: var(--ok); }
.x { border: 0; background: none; color: var(--muted); font-size: 26px; font-weight: 800; cursor: pointer; flex: none; padding: 0 4px; }
.timer { font-variant-numeric: tabular-nums; font-weight: 900; color: var(--muted); }
.timer.low { color: var(--ko); }
.raccolti { font-weight: 900; color: var(--brand); white-space: nowrap; }
.tag { display: inline-block; font-size: 14px; font-weight: 800; color: var(--brand); background: var(--brand-soft); border-radius: 10px; padding: 4px 10px; margin-bottom: 12px; }
.domanda { font-size: 22px; font-weight: 800; line-height: 1.35; margin-bottom: 20px; }
.opts { display: flex; flex-direction: column; gap: 12px; }
.opt {
  display: flex; gap: 12px; align-items: center; text-align: left;
  background: var(--card); color: var(--ink); border: 2px solid var(--line); border-bottom-width: 4px; border-radius: var(--radius);
  padding: 14px; font: inherit; cursor: pointer; width: 100%;
}
.opt:active:not(:disabled) { transform: translateY(2px); border-bottom-width: 2px; margin-bottom: 2px; }
.opt .l {
  flex: none; width: 30px; height: 30px; border-radius: 9px; border: 2px solid var(--line);
  color: var(--muted); font-weight: 900; display: grid; place-items: center; font-size: 14px;
}
.opt.sel { border-color: var(--sel); background: var(--sel-soft); color: var(--sel); }
.opt.sel .l { border-color: var(--sel); color: var(--sel); }
.opt.giusta { border-color: var(--ok); background: var(--ok-soft); color: var(--ok-ink); }
.opt.giusta .l { border-color: var(--ok); background: var(--ok); color: #fff; }
.opt.sbagliata { border-color: var(--ko); background: var(--ko-soft); color: var(--ko-ink); }
.opt.sbagliata .l { border-color: var(--ko); background: var(--ko); color: #fff; }
.opt:disabled { cursor: default; }

/* Barra fissa in basso nel quiz (Controlla / Avanti) e pannello del risultato */
.fondo {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--bg); border-top: 2px solid var(--line);
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
}
.fondo > div { max-width: 560px; margin: 0 auto; }
.esito-sheet { border-top: 0; animation: sali .22s ease-out; max-height: 70vh; overflow-y: auto; }
.esito-sheet.ok { background: var(--ok-soft); }
.esito-sheet.ko { background: var(--ko-soft); }
@keyframes sali { from { transform: translateY(100%); } to { transform: translateY(0); } }
.esito-testa { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.esito { font-weight: 900; font-size: 22px; }
.esito-sheet.ok .esito, .esito-sheet.ok p { color: var(--ok-ink); }
.esito-sheet.ko .esito, .esito-sheet.ko p { color: var(--ko-ink); }
.esito-sheet p { font-weight: 700; }
.rif { font-size: 14px; opacity: .85; margin: -4px 0 14px; }
body.in-quiz { padding-bottom: 120px; }
body.con-esito { padding-bottom: 360px; }

/* Pillole */
.pillola h3 { font-size: 18px; color: var(--brand); }
.pillola p:last-child { margin-bottom: 0; }
.pillola ul { margin: 0 0 12px; padding-left: 22px; }
.pillola li { margin-bottom: 6px; }
.pillola .ricorda { background: var(--brand-soft); border-radius: 12px; padding: 10px 12px; font-size: 15px; }

.big { font-size: 52px; font-weight: 900; text-align: center; line-height: 1; margin: 10px 0; }
.rev { padding: 12px 0; border-top: 2px solid var(--line); font-size: 15px; }
.rev:first-child { border-top: 0; }
.rev .q { font-weight: 800; margin-bottom: 4px; }
.ok-t { color: var(--ok); font-weight: 800; } .ko-t { color: var(--ko); font-weight: 800; }

.festa { text-align: center; padding-top: 10px; }
.festa h1 { font-size: 30px; color: var(--gold); }

input.campo { width: 100%; border-radius: 12px; border: 2px solid var(--line); background: var(--bg); color: var(--ink); padding: 13px 12px; font: inherit; margin-bottom: 12px; }
textarea { width: 100%; min-height: 90px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg); color: var(--ink); padding: 10px; font: 13px/1.4 ui-monospace, monospace; }

/* Coriandoli di fine giro */
.coriandolo { position: fixed; top: -12px; width: 10px; height: 14px; border-radius: 3px; z-index: 50; pointer-events: none; animation: cadi linear forwards; }
@keyframes cadi { to { transform: translateY(105vh) rotate(720deg); } }

/* Barra delle schede */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  background: var(--bg); border-top: 2px solid var(--line);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
}
.tabbar button {
  border: 2px solid transparent; border-radius: 14px; background: none; font: inherit; font-size: 12px; font-weight: 800; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 5px 2px; cursor: pointer;
}
.tabbar .ico { font-size: 24px; filter: grayscale(1); opacity: .6; }
.tabbar button.on { color: var(--brand); border-color: var(--brand); background: var(--brand-soft); }
.tabbar button.on .ico { filter: none; opacity: 1; }
body.in-quiz .tabbar { display: none; }
