/* ===== Variabili tema ===== */
:root {
  --main: #FF13F0;
  --main-rgb: 255, 19, 240;      /* stesso colore di --main, per usarlo con rgba() */
  --main-2: #ff9af8;             /* tinta chiara per i gradienti */
  --main-3: #9d1fd1;             /* tinta scura per i gradienti */
  --glow: rgba(var(--main-rgb), .45);
  --bg: #0d0f12;
  --bg-glow: #2a0c28;
  --card: #1a1e24;
  --card2: #252b33;
  --text: #f2f5f7;
  --muted: #9aa5b1;
  --ok: #7FFF00;
  --ko: #ff4d4d;
}
* { box-sizing: border-box; margin: 0; }
/* Sfondo scuro anche sotto/oltre la pagina (barre del telefono, overscroll): evita la striscia bianca */
html { background: var(--bg); color-scheme: dark; }
body {
  font-family: 'Blinker', system-ui, sans-serif;
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  font-size: 18px;
}
/* Il gradiente sta su un livello fisso: 'background-attachment: fixed' sul body è inaffidabile sui telefoni */
body::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(circle at top, var(--bg-glow) 0%, var(--bg) 55%);
}
body.menu-open { overflow: hidden; }
[hidden] { display: none !important; }   /* l'attributo hidden vince sempre, anche su .btn */
#app { max-width: 760px; margin: 0 auto; padding: 20px 16px 40px; }
:focus-visible { outline: 2px solid var(--main); outline-offset: 3px; }

/* ===== Header ===== */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(13, 15, 18, .85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--card2);
}
.site-header .bar {
  max-width: 760px; margin: 0 auto; padding: 8px 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-size: 1.6rem; font-weight: 800; }
.brand img { width: 36px; height: 36px; border-radius: 10px; }
.brand b { color: var(--main); }

/* Pulsante hamburger */
.burger {
  width: 46px; height: 46px; border: none; border-radius: 14px; background: var(--card2);
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 5px; cursor: pointer;
  transition: background .15s;
}
.burger:hover { background: var(--card); box-shadow: inset 0 0 0 2px var(--main); }
.burger span { display: block; width: 22px; height: 3px; border-radius: 3px; background: var(--text); }

/* Menu laterale */
.nav-overlay {
  position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, .65);
  opacity: 0; visibility: hidden; transition: opacity .25s, visibility .25s;
}
.nav-overlay.open { opacity: 1; visibility: visible; }
.nav-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 40; width: min(320px, 85vw);
  background: var(--card); border-left: 2px solid var(--main);
  padding: 16px; display: flex; flex-direction: column; gap: 6px; overflow-y: auto;
  transform: translateX(100%); visibility: hidden; transition: transform .25s ease, visibility .25s;
}
.nav-drawer.open { transform: none; visibility: visible; }
.nav-close { align-self: flex-end; width: 44px; height: 44px; border: none; background: none; color: var(--muted); font-size: 1.5rem; cursor: pointer; }
.nav-close:hover { color: var(--main); }
.nav-drawer a {
  display: block; padding: 14px 16px; border-radius: 14px; color: var(--text); text-decoration: none;
  font-size: 1.4rem; font-weight: 600; border: 2px solid transparent; transition: background .15s, border-color .15s;
}
.nav-drawer a:hover { background: var(--card2); border-color: var(--main); }
.nav-drawer a[aria-current="page"] { background: var(--card2); color: var(--main); font-weight: 800; }
.nav-drawer hr { border: none; border-top: 1px solid var(--card2); margin: 8px 0; }
.nav-drawer a.report { color: var(--muted); font-size: 1.15rem; }

/* ===== Schermate e transizioni ===== */
.screen { display: none; flex-direction: column; align-items: center; gap: 16px; animation: fade .4s ease; }
.screen.active { display: flex; }
@keyframes fade { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

h1 { font-size: clamp(2.6rem, 10vw, 4.5rem); font-weight: 800; }
h1 span, h2 { color: var(--main); }
h2 { font-size: 2.2rem; font-weight: 800; }
.sub { color: var(--muted); }
.claim { font-size: 1.4rem; font-weight: 600; text-align: center; }
.claim b { color: var(--main); font-size: 2rem; }
.error { color: var(--ko); min-height: 1.2em; }
.success { color: var(--ok); min-height: 1.2em; }
.logo {
  width: 110px; height: 110px; border-radius: 28px; color: #000;
  background: linear-gradient(135deg, var(--main-2) 0%, var(--main) 55%, var(--main-3) 100%);
  font-size: 4.5rem; font-weight: 800; display: grid; place-items: center;
  box-shadow: 0 0 40px var(--glow); margin-top: 4vh; animation: pulse 2.5s infinite;
}
@keyframes pulse { 50% { transform: scale(1.06) rotate(-3deg); } }
/* Sottotitolo della home: stessa dimensione del testo normale, con l'effetto del logo (gradiente, alone, pulsazione) */
.tagline {
  font-weight: 600;
  background: linear-gradient(135deg, var(--main-2) 0%, var(--main) 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  filter: drop-shadow(0 0 10px var(--glow));
  animation: pulse 2.5s infinite;
}
.stack { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 420px; }

/* ===== Pulsanti (anche link) ===== */
.btn {
  display: inline-block; text-align: center; text-decoration: none;
  font: inherit; font-weight: 800; letter-spacing: .5px; cursor: pointer;
  background: var(--card2); color: var(--text); border: 2px solid transparent;
  border-radius: 16px; padding: 14px 20px; transition: transform .15s, box-shadow .15s;
}
.btn:hover { transform: translateY(-2px); border-color: var(--main); }
.btn.primary { background: var(--main); color: #000; }
.btn.big { font-size: 1.5rem; padding: 18px; }
.btn.ghost { font-size: 1.5rem; padding: 18px; }

/* ===== Setup giocatori ===== */
.prow { display: flex; gap: 8px; }
.prow input {
  flex: 1; font: inherit; font-size: 1.2rem; padding: 12px 16px; border-radius: 14px;
  border: 2px solid var(--card2); background: var(--card); color: var(--text);
}
.prow input:focus { outline: none; border-color: var(--main); }
.prow button { width: 52px; font-size: 1.3rem; }

/* ===== Gioco ===== */
.topbar { display: flex; justify-content: space-between; width: 100%; font-weight: 600; color: var(--muted); }
.turn { font-size: 1.6rem; background: var(--card); padding: 10px 24px; border-radius: 50px; border: 2px solid var(--main); }
.turn b { color: var(--main); text-transform: uppercase; }
.card { width: 100%; background: var(--card); border-radius: 22px; padding: 20px; }
#question { font-size: clamp(1.3rem, 4.5vw, 1.9rem); margin-bottom: 16px; line-height: 1.25; }
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ans {
  font: inherit; font-size: 1.15rem; font-weight: 600; text-align: center; cursor: pointer;
  background: var(--card2); color: var(--text); border: 2px solid transparent;
  border-radius: 16px; padding: 16px; min-height: 70px; transition: .15s;
}
.ans:hover:not(:disabled) { border-color: var(--main); transform: translateY(-2px); }
.ans:disabled { cursor: default; }
.ans.correct { background: rgba(127,255,0,.2); border-color: var(--ok); animation: pop .4s; }
.ans.wrong { background: rgba(255,77,77,.2); border-color: var(--ko); animation: shake .4s; }
@keyframes pop { 50% { transform: scale(1.04); } }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.feedback { min-height: 1.5em; margin-top: 14px; font-size: 1.3rem; font-weight: 800; text-align: center; }
.feedback.ok { color: var(--ok); } .feedback.ko { color: var(--ko); }

/* ===== Classifica ===== */
.live h4 { color: var(--main); margin-bottom: 8px; }
.row {
  display: grid; grid-template-columns: 36px 1fr 60px; gap: 8px; align-items: center;
  padding: 8px 10px; border-radius: 10px; font-size: 1rem;
}
.row:nth-child(odd) { background: var(--card2); }
.row .pos { font-weight: 800; color: var(--main); }
.row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .pts { text-align: right; font-weight: 800; }
.row.head { background: none !important; color: var(--muted); font-size: .85rem; }
.row.current { outline: 2px solid var(--main); }

/* Finale */
#final-board { width: 100%; }
#final-board .row { font-size: 1.25rem; padding: 14px; background: var(--card); margin-bottom: 8px; border-radius: 14px; }
#final-board .row.winner {
  background: linear-gradient(135deg, var(--main) 0%, var(--main-2) 100%); color: #000; font-size: 1.6rem;
  box-shadow: 0 0 36px var(--glow); animation: pop 1s infinite;
}
#final-board .row.winner .pos { color: #000; }


/* ===== Pagine di testo (Regole, Changelog, About) ===== */
.page { width: 100%; display: flex; flex-direction: column; gap: 16px; animation: fade .4s ease; }
.page .lead { color: var(--muted); }
.page .card h3 { font-size: 1.35rem; margin-bottom: 10px; }
.page .card p + p { margin-top: 10px; }
.page ul { padding-left: 20px; display: flex; flex-direction: column; gap: 8px; line-height: 1.35; }
.page b { color: var(--main); }
.page a:not(.btn) { color: var(--main); }
.page .btn { align-self: flex-start; }
.page .stack .btn { align-self: stretch; }   /* dentro .stack i tasti riempiono la colonna (centrata) */

/* Changelog */
.entry-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.entry-head h3 { margin: 0 !important; }
.version {
  background: linear-gradient(135deg, var(--main), var(--main-2)); color: #000;
  font-weight: 800; padding: 2px 14px; border-radius: 50px;
}
.entry-head time { color: var(--muted); margin-left: auto; font-size: 1rem; }

/* Form segnalazioni */
#segnala { scroll-margin-top: 84px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-weight: 600; }
.field small { color: var(--muted); font-weight: 400; }
.field input, .field select, .field textarea {
  font: inherit; font-size: 1.1rem; font-weight: 400; padding: 12px 16px; border-radius: 14px;
  border: 2px solid var(--card2); background: var(--bg); color: var(--text); width: 100%;
}
.field textarea { resize: vertical; min-height: 120px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--main); }
.hint { color: var(--muted); font-size: 1rem; margin-top: 12px; }
#report-form .btn { display: block; margin: 4px auto 0; }   /* bottone Scrivi email centrato */
#report-form .hint, #rf-msg { text-align: center; }

@media (max-width: 768px) {
  .answers { grid-template-columns: 1fr; }
  .row { grid-template-columns: 28px 1fr 44px; font-size: .9rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ===== Record ===== */
#record-box { display: flex; flex-direction: column; gap: 12px; }
#record-box[hidden] { display: none; }
#rec-board { display: flex; flex-direction: column; gap: 8px; }
.rec {
  display: grid; grid-template-columns: 36px 1fr 60px 170px; gap: 8px; align-items: center;
  padding: 12px 14px; border-radius: 14px; background: var(--card);
}
.rec.head { background: none; color: var(--muted); font-size: .85rem; padding-top: 0; padding-bottom: 0; }
.rec .pos { font-weight: 800; color: var(--main); }
.rec .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.rec .pts { text-align: right; font-weight: 800; }
.rec .when { color: var(--muted); font-size: .95rem; text-align: right; }
.rec.first { background: linear-gradient(135deg, var(--main) 0%, var(--main-2) 100%); color: #000; box-shadow: 0 0 28px var(--glow); }
.rec.first .pos, .rec.first .when { color: #000; }
@media (max-width: 768px) {
  .rec { grid-template-columns: 28px 1fr 44px; }
  .rec .when { grid-column: 2 / -1; text-align: left; font-size: .85rem; }
  .rec.head .when { display: none; }
}

/* ===== Strumenti in partita (suoni, segnala) ===== */
.report-link {
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: .95rem;
  border: 1px solid var(--card2); border-radius: 50px; padding: 2px 14px; transition: .15s;
}
.report-link:hover { color: var(--main); border-color: var(--main); }

.tools { display: flex; align-items: center; gap: 8px; }
.tool-btn {
  font: inherit; font-size: .95rem; cursor: pointer; background: none; color: var(--muted);
  border: 1px solid var(--card2); border-radius: 50px; padding: 2px 12px; transition: .15s;
}
.tool-btn:hover { border-color: var(--main); }
.tool-btn { display: inline-flex; align-items: center; padding: 3px 10px; }
.tool-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tool-btn .mute { display: none; }
.tool-btn.muted .mute { display: inline; }
.tool-btn.muted .waves { display: none; }
.after { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; min-height: 52px; }
.after .feedback { margin: 0; flex: 1; text-align: left; min-height: 0; }
#btn-next { padding: 12px 22px; white-space: nowrap; }

/* Classifica finale e salvataggio record */
#record-box { align-items: center; text-align: center; }
.save-row { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; }
.save-row input {
  width: 100%; max-width: 320px; font: inherit; font-size: 1.2rem; text-align: center; padding: 12px 16px;
  border-radius: 14px; border: 2px solid var(--card2); background: var(--card2); color: var(--text);
}
.save-row input:focus { outline: none; border-color: var(--main); }
.save-row .btn { min-width: 160px; }
@media (max-width: 768px) {
  #final-board .row { grid-template-columns: 40px 1fr 54px; font-size: 1.1rem; padding: 12px; }
  #final-board .row.winner { font-size: 1.3rem; }
}

/* Pagina record */
.page .stack { align-self: center; }
.rec.latest { outline: 2px solid var(--main); outline-offset: 2px; }
.rec.first.latest { outline-color: var(--text); }

/* Barra bonus sotto la domanda */
.bonus { margin-bottom: 16px; }
.bonus-bar { display: flex; gap: 4px; }
.bonus-bar i { flex: 1; height: 8px; border-radius: 8px; background: var(--card2); transition: background .3s, box-shadow .3s; }
.bonus-bar i.on { background: linear-gradient(90deg, var(--main), var(--main-2)); box-shadow: 0 0 10px var(--glow); }
.bonus-txt { display: block; margin-top: 6px; font-size: .9rem; color: var(--muted); }
.bonus.full .bonus-txt { color: var(--main); font-weight: 600; }

/* ===== Sito compatto su smartphone (testi e bottoni un po' più piccoli) ===== */
@media (max-width: 768px) {
  /* header e menu */
  .site-header .bar { padding: 6px 12px; }
  .brand { font-size: 1.4rem; gap: 8px; }
  .brand img { width: 32px; height: 32px; border-radius: 9px; }
  .burger { width: 42px; height: 42px; border-radius: 12px; gap: 4px; }
  .burger span { width: 20px; }
  .nav-drawer { padding: 12px; }
  .nav-drawer a { font-size: 1.2rem; padding: 12px 14px; }
  .nav-drawer a.report { font-size: 1.05rem; }
  /* titoli, testi, logo */
  h1 { font-size: clamp(2.2rem, 9.5vw, 3.2rem); }
  h2 { font-size: 1.75rem; }
  .claim { font-size: 1.15rem; }
  .claim b { font-size: 1.6rem; }
  .screen { gap: 12px; }
  .logo { width: 88px; height: 88px; border-radius: 22px; font-size: 3.4rem; margin-top: 2vh; }
  /* bottoni e campi */
  .stack { gap: 10px; }
  .btn { padding: 11px 18px; }
  .btn.big, .btn.ghost { font-size: 1.2rem; padding: 13px; }
  .prow input { font-size: 1.05rem; padding: 10px 14px; border-radius: 12px; }
  .prow button { width: 46px; font-size: 1.1rem; }
  .card { padding: 16px; border-radius: 18px; }
  .save-row input { font-size: 1.05rem; padding: 10px 14px; }
  /* pagine di testo */
  .page { gap: 12px; }
  .page .card h3 { font-size: 1.2rem; margin-bottom: 8px; }
  .page ul { gap: 6px; }
  .entry-head { flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
  .version { font-size: .95rem; padding: 1px 12px; }
  .entry-head time { font-size: .9rem; }
  /* form segnalazioni e record */
  .field { margin-bottom: 12px; }
  .field input, .field select, .field textarea { font-size: 1rem; padding: 10px 14px; border-radius: 12px; }
  .field textarea { min-height: 100px; }
  .hint { font-size: .9rem; }
  .rec { padding: 10px 12px; font-size: .95rem; }
}

/* ===== Gameplay compatto su smartphone ===== */
@media (max-width: 768px) {
  body { font-size: 16px; }
  #app { padding: 10px 12px 20px; }
  #game { gap: 8px; }
  .topbar { font-size: .95rem; }
  .turn { font-size: 1.05rem; padding: 4px 16px; }
  #game .card { padding: 14px; border-radius: 18px; }
  #question { font-size: clamp(1.05rem, 4.4vw, 1.3rem); margin-bottom: 10px; line-height: 1.2; }
  .bonus { margin-bottom: 10px; }
  .bonus-bar i { height: 6px; }
  .bonus-txt { font-size: .8rem; margin-top: 4px; }
  .answers { gap: 8px; }
  .ans { font-size: 1rem; padding: 10px 12px; min-height: 46px; border-radius: 12px; }
  .after { margin-top: 10px; min-height: 46px; }
  .feedback { font-size: 1.1rem; }
  #btn-next { padding: 10px 18px; font-size: 1rem; }
  .live { padding: 10px 12px !important; }
  .live h4 { display: none; }
  #live .row.head { display: none; }
  #live { max-height: 7.5rem; overflow-y: auto; }
  #live .row { padding: 4px 8px; font-size: .9rem; }
}