/* MediGames — giocatore del partecipante. Nessuna libreria esterna. */
:root {
  --accent: #0c4a60;
  --accent-hover: #093a4c;
  --accent-ink: #0c4a60;
  --accent-soft: #e4eef3;
  --accent-2: #6d99b0;
  --on-accent: #ffffff;
  --bg: #f2f6f8;
  --surface: #ffffff;
  --surface-2: #f5f8fa;
  --text: #15232b;
  --muted: #52616a;
  --border: #d3dee4;
  --focus: #3f7f99;
  --warn-bg: #fff1cc;
  --warn-ink: #6e4b00;
  --danger: #b3261e;
  --danger-bg: #fdecea;
  --ok: #1e7a3c;
  --ok-bg: #e7f4ec;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 4px 16px rgb(0 0 0 / .06);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #2c7491;
    --accent-hover: #3683a2;
    --accent-ink: #9cc3d8;
    --accent-soft: #142e39;
    --accent-2: #6d99b0;
    --bg: #0e1417;
    --surface: #162026;
    --surface-2: #1c282e;
    --text: #e7eef1;
    --muted: #a0b1ba;
    --border: #2c3c44;
    --focus: #8fc3d9;
    --warn-bg: #3d3112;
    --warn-ink: #f2d27a;
    --danger: #f2948c;
    --danger-bg: #3a1d1b;
    --ok: #7fd49a;
    --ok-bg: #15291d;
    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 4px 16px rgb(0 0 0 / .3);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3, p, ul, ol { margin: 0; }
h1 { font-size: 1.5rem; line-height: 1.25; }
h1:focus { outline: none; }
h1:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; border-radius: 4px; }
h2 { font-size: 1.05rem; }
h3 { font-size: 1rem; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[aria-busy="true"] { cursor: progress; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.nojs { padding: 16px; }
.ico { flex: none; width: 20px; height: 20px; }

/* Pulsanti: almeno 44 px */
.btn {
  min-height: 44px; padding: 10px 16px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:hover:not(:disabled) { border-color: var(--accent-ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.wide { min-height: 48px; padding-inline: 28px; align-self: flex-start; }

/* Pagine */
.page, .notice {
  min-height: 100vh; min-height: 100dvh; padding: 24px 16px;
  display: flex; justify-content: center; align-items: flex-start;
}
.notice { align-items: center; text-align: center; }
.card-panel {
  width: 100%; max-width: 680px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 24px; display: flex; flex-direction: column; gap: 16px;
}
.card-panel.play { max-width: 780px; }
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--accent-ink); font-weight: 700; font-size: .78rem; letter-spacing: .06em; text-transform: uppercase;
}
.logo { flex: none; width: 22px; height: 22px; border-radius: 5px; }
.lead { font-size: 1.05rem; }
section { display: grid; gap: 10px; }
.form-err { color: var(--danger); }
.form-err:empty { display: none; }
.alert {
  background: var(--danger-bg); color: var(--danger); border: 1px solid currentColor;
  border-radius: 10px; padding: 10px 14px; font-size: .95rem;
}
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; line-height: 1.5; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.ko { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.source { display: grid; gap: 2px; font-size: .82rem; color: var(--muted); }
.source .quote { font-style: italic; overflow-wrap: anywhere; }

/* Avvio */
.rules { padding-left: 1.2em; display: grid; gap: 6px; }
.meta { font-weight: 600; color: var(--accent-ink); }

/* Partita */
.play-head { display: flex; justify-content: space-between; align-items: center; gap: 8px 16px; flex-wrap: wrap; }
.progress { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: .9rem; color: var(--muted); }
.dots { list-style: none; padding: 0; display: flex; gap: 6px; }
.dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--border); }
.dot.done { background: var(--accent-ink); border-color: var(--accent-ink); }
.dot.cur { border-color: var(--accent-ink); box-shadow: 0 0 0 3px var(--accent-soft); }
#case { display: grid; gap: 16px; }

.clues { list-style: none; padding: 0; counter-reset: clue; display: grid; gap: 8px; }
.clues li {
  counter-increment: clue; display: grid; grid-template-columns: 28px 1fr; gap: 2px 12px; align-items: start;
  padding: 10px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
}
.clues li::before {
  content: counter(clue); grid-row: span 2; width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-ink); display: grid; place-items: center;
  font-weight: 700; font-size: .85rem; font-variant-numeric: tabular-nums;
}
.clues li.new { border-color: var(--accent-2); animation: clue-in .3s ease-out; }
@keyframes clue-in { from { opacity: 0; transform: translateY(-4px); } }
@media (prefers-reduced-motion: reduce) { .clues li.new { animation: none; } }
.kind { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--accent-ink); }
.clue-text { overflow-wrap: anywhere; }
.clue-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px 16px; flex-wrap: wrap; }
.counter { font-weight: 600; font-variant-numeric: tabular-nums; }

.feedback:empty { display: none; }
.warn {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: 10px;
  background: var(--warn-bg); color: var(--warn-ink); font-weight: 600;
}
.warn .ico { margin-top: 2px; }

.options { display: grid; gap: 8px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .options { grid-template-columns: 1fr 1fr; } }
.opt {
  width: 100%; min-height: 52px; padding: 10px 14px; text-align: left; cursor: pointer;
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit;
}
.opt:hover:not(:disabled) { border-color: var(--accent-ink); background: var(--accent-soft); }
.opt .key {
  flex: none; width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--border);
  display: grid; place-items: center; font-size: .8rem; font-weight: 700; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.opt .key:empty { visibility: hidden; }
@media (hover: none) { .opt .key { display: none; } }
.opt-label { flex: 1; overflow-wrap: anywhere; }
.opt.wrong { cursor: not-allowed; color: var(--muted); background: var(--surface-2); border-style: dashed; }
.opt.wrong .opt-label { text-decoration: line-through; text-decoration-thickness: 2px; }

/* Fine del caso */
.result { display: grid; gap: 10px; padding: 16px 18px; border-radius: 12px; border: 1px solid var(--border); }
.result.ok { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.result.ko { background: var(--surface-2); }
.result-head { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.15rem; }
.result.ok .result-head { color: var(--ok); }
.result.ko .result-head { color: var(--muted); }

/* Fine della partita */
.total {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap;
  padding: 14px 18px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-ink);
}
.total-label { font-weight: 700; }
.total-num { font-size: 2.4rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.total-max { font-size: 1rem; font-weight: 600; margin-left: 2px; }
.cases { list-style: none; padding: 0; display: grid; gap: 10px; }
.case-sum {
  display: grid; gap: 6px; padding: 12px 14px; border: 1px solid var(--border); border-left-width: 4px; border-radius: 10px;
}
.case-sum.ok { border-left-color: var(--ok); }
.case-sum.ko { border-left-color: var(--muted); }
.cs-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px 12px; flex-wrap: wrap; }

/* Storico delle partite e «Gioca di nuovo» */
.again { display: grid; gap: 10px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.again-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.history { list-style: none; padding: 0; margin: 0; display: grid; }
.history li { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: baseline; padding: 8px 0; border-top: 1px solid var(--border); font-size: .9375rem; }
.history li:first-child { border-top: none; }
.history li.current .h-when { font-weight: 700; }
.h-this { color: var(--accent-ink); }
.h-score { font-variant-numeric: tabular-nums; }

@media (max-width: 480px) {
  .page { padding: 12px; }
  .card-panel { padding: 18px 16px; gap: 14px; }
  h1 { font-size: 1.3rem; }
  .btn.wide, .again-head .btn, .clue-bar .btn { width: 100%; }
}
