/* =========================================================================
   QUIZ LIVE — FOGLIO DI STILE UNICO
   Personalizza tutto da qui. I :root qui sotto sono la "plancia comandi":
   cambia colori, font e raggi e l'intera app si adegua.
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,400;12..96,700;12..96,800&family=Plus+Jakarta+Sans:wght@400;600;700;800&display=swap');

:root {
  /* --- COLORI BASE --- */
  --bg:        #1a0640;   /* sfondo profondo */
  --bg-2:      #2a0a66;   /* sfondo secondario per il mesh */
  --surface:   #2c1270;   /* card / pannelli */
  --surface-2: #3a1a8c;   /* card più chiare / hover */
  --line:      #5a37b8;   /* bordi sottili */
  --text:      #f3f0ff;   /* testo principale */
  --muted:     #c4b8f2;   /* testo secondario */

  /* --- ACCENTO DEL BRAND (schermate join / pulsanti) --- */
  --accent:    #ffe14d;   /* ciano elettrico */
  --accent-2:  #ff2e9a;   /* magenta */

  /* --- I 4 COLORI DELLE RISPOSTE (A B C D) --- */
  --c-a: #ff2e63;  /* rosso  - triangolo */
  --c-b: #1f9dff;  /* blu    - rombo */
  --c-c: #ffc400;  /* ambra  - cerchio */
  --c-d: #12d873;  /* verde  - quadrato */

  --ok:   #1fd65f;
  --ko:   #ff3b5c;

  /* --- FORMA --- */
  --radius:   22px;
  --radius-s: 14px;
  --shadow:   0 18px 50px -12px rgba(0,0,0,.7);

  /* --- FONT --- */
  --font-display: 'Bricolage Grotesque', 'Trebuchet MS', sans-serif;
  --font-body:    'Plus Jakarta Sans', system-ui, sans-serif;
}

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

html, body {
  height: 100%;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Mesh / aurora animata di sfondo (atmosfera, non solido piatto) */
body::before {
  content: "";
  position: fixed; inset: -40%;
  z-index: -2;
  background:
    radial-gradient(40% 40% at 20% 25%, color-mix(in srgb, var(--accent) 30%, transparent), transparent 70%),
    radial-gradient(45% 45% at 85% 20%, color-mix(in srgb, var(--accent-2) 28%, transparent), transparent 70%),
    radial-gradient(50% 50% at 50% 95%, color-mix(in srgb, var(--c-b) 25%, transparent), transparent 70%);
  filter: blur(40px) saturate(140%);
  animation: drift 22s ease-in-out infinite alternate;
}
body::after {
  content: "";
  position: fixed; inset: 0; z-index: -1;
  background:
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  opacity: .82;
}
@keyframes drift {
  0%   { transform: translate(0,0) rotate(0deg) scale(1); }
  100% { transform: translate(3%, -3%) rotate(8deg) scale(1.12); }
}

/* griglia "arcade" leggerissima sopra al mesh */
.grid-overlay {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    linear-gradient(color-mix(in srgb, var(--accent) 8%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--accent) 8%, transparent) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at 50% 40%, #000 0%, transparent 75%);
}

/* ---------- TIPOGRAFIA ---------- */
h1, h2, h3, .display { font-family: var(--font-display); font-weight: 800; line-height: 1.02; letter-spacing: -.02em; }
.muted { color: var(--muted); }

/* ---------- PULSANTI GENERICI ---------- */
.btn {
  font-family: var(--font-body);
  font-weight: 800;
  border: none; cursor: pointer;
  border-radius: var(--radius-s);
  padding: 16px 26px;
  font-size: 1.05rem;
  color: #08121f;
  background: var(--accent);
  transition: transform .12s ease, filter .12s ease, box-shadow .12s ease;
  box-shadow: 0 8px 0 color-mix(in srgb, var(--accent) 55%, #000);
}
.btn:hover   { filter: brightness(1.06); transform: translateY(-2px); }
.btn:active  { transform: translateY(4px); box-shadow: 0 4px 0 color-mix(in srgb, var(--accent) 55%, #000); }
.btn.secondary { background: var(--surface-2); color: var(--text); box-shadow: 0 8px 0 #0c0820; }
.btn.danger    { background: var(--ko); color: #fff; box-shadow: 0 8px 0 #7a1424; }
.btn:disabled  { opacity: .45; cursor: not-allowed; transform: none; }

/* ---------- INPUT ---------- */
.input {
  width: 100%;
  font-family: var(--font-body);
  font-size: 1.1rem; font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius-s);
  padding: 16px 18px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent); }
.input::placeholder { color: var(--muted); }

/* ---------- LAYOUT CENTRATO (player / join) ---------- */
.wrap {
  min-height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 22px;
  gap: 18px;
}
.card {
  width: 100%; max-width: 460px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

/* =========================================================================
   FORME RISPOSTE (triangolo, rombo, cerchio, quadrato)
   ========================================================================= */
.shape { width: 34px; height: 34px; flex: 0 0 auto; display: inline-block; }
.shape.tri  { clip-path: polygon(50% 0, 100% 100%, 0 100%); background: currentColor; }
.shape.dia  { clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); background: currentColor; }
.shape.cir  { border-radius: 50%; background: currentColor; }
.shape.sqr  { border-radius: 6px; background: currentColor; }

/* mappa colore per indice risposta: aggiungi classe .a .b .c .d */
.a { color: var(--c-a); } .b { color: var(--c-b); } .c { color: var(--c-c); } .d { color: var(--c-d); }
.bg-a { background: var(--c-a); } .bg-b { background: var(--c-b); } .bg-c { background: var(--c-c); } .bg-d { background: var(--c-d); }

/* =========================================================================
   PULSANTI RISPOSTA (player) — grandi e tattili
   ========================================================================= */
.answers {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
  width: 100%;
}
.answer {
  position: relative;
  display: flex; align-items: center; gap: 14px;
  border: none; cursor: pointer;
  border-radius: var(--radius-s);
  padding: 22px 18px;
  min-height: 110px;
  color: #08121f;
  font-family: var(--font-body); font-weight: 800; font-size: 1.15rem;
  text-align: left;
  box-shadow: 0 9px 0 rgba(0,0,0,.35);
  transition: transform .1s ease, filter .12s ease, opacity .2s ease;
}
.answer .shape { filter: drop-shadow(0 2px 4px rgba(0,0,0,.25)); }
.answer:active { transform: translateY(5px); box-shadow: 0 4px 0 rgba(0,0,0,.35); }
.answer.dim    { opacity: .25; filter: grayscale(.6); }
.answer.picked { outline: 5px solid #fff; outline-offset: -5px; transform: scale(.98); }
.answer.correct-pulse { animation: pulseOk .6s ease 2; }
@keyframes pulseOk { 50% { filter: brightness(1.35); transform: scale(1.04); } }

/* =========================================================================
   SCHERMO HOST (gigante)
   ========================================================================= */
.host {
  min-height: 100%;
  display: flex; flex-direction: column;
  padding: clamp(20px, 3vw, 48px);
  gap: clamp(16px, 2.5vh, 34px);
}
.host-top {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
}
.host-title { font-size: clamp(1.6rem, 4vw, 3rem); }
.pill {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 999px; font-weight: 700;
}
.pin-big { font-family: var(--font-display); font-weight: 800; letter-spacing: .12em; color: var(--accent); }

/* lobby host */
.lobby { display: grid; grid-template-columns: 360px 1fr; gap: clamp(20px, 3vw, 48px); flex: 1; align-items: stretch; }
.join-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; display: flex; flex-direction: column; align-items: center; gap: 16px; box-shadow: var(--shadow); }
.qr-frame { background: #fff; padding: 14px; border-radius: 18px; }
.qr-frame img { display: block; width: 230px; height: 230px; image-rendering: pixelated; }
.join-url { font-weight: 700; color: var(--accent); word-break: break-all; text-align: center; }
.huge-pin { font-family: var(--font-display); font-size: clamp(2.4rem, 6vw, 4.4rem); font-weight: 800; letter-spacing: .14em; color: var(--accent); }

.players-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; display: flex; flex-direction: column; gap: 18px; box-shadow: var(--shadow); }
.players-grid { display: flex; flex-wrap: wrap; gap: 12px; align-content: flex-start; flex: 1; }
.player-chip {
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 12px 18px; border-radius: 999px; font-weight: 800; font-size: 1.1rem;
  animation: pop .35s cubic-bezier(.2,1.4,.4,1) both;
}
@keyframes pop { from { transform: scale(.3); opacity: 0; } }
.count-bubble { font-family: var(--font-display); font-size: 2.4rem; font-weight: 800; color: var(--accent); }

/* domanda host */
.q-stage { flex: 1; display: flex; flex-direction: column; gap: clamp(16px, 2.5vh, 30px); }
.q-meta  { display: flex; align-items: center; justify-content: space-between; }
.q-index { font-weight: 800; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.q-text  { font-family: var(--font-display); font-size: clamp(1.8rem, 4.6vw, 3.6rem); font-weight: 800; text-align: center; margin: auto 0; max-width: 1100px; align-self: center; }
.host-answers { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(12px, 1.6vw, 22px); }
.host-answer {
  display: flex; align-items: center; gap: 18px;
  border-radius: var(--radius-s); padding: clamp(18px, 2.4vh, 30px) 26px;
  color: #08121f; font-weight: 800; font-size: clamp(1.1rem, 2.4vw, 1.9rem);
  position: relative; transition: opacity .3s ease, filter .3s ease, transform .3s ease;
}
.host-answer .shape { width: clamp(34px, 4vw, 56px); height: clamp(34px, 4vw, 56px); }
.host-answer.dim { opacity: .28; filter: grayscale(.5); }
.host-answer.win { transform: scale(1.03); box-shadow: 0 0 0 6px #fff, 0 0 50px color-mix(in srgb, var(--ok) 70%, transparent); }
.host-answer .dist {
  position: absolute; right: 18px; top: 50%; transform: translateY(-50%);
  background: rgba(0,0,0,.35); color: #fff; border-radius: 999px;
  padding: 6px 14px; font-size: clamp(.9rem, 1.6vw, 1.3rem); font-weight: 800;
  opacity: 0; transition: opacity .3s ease;
}
.host-answer .dist.show { opacity: 1; }

/* timer ad anello */
.timer-ring { position: relative; width: clamp(64px, 8vw, 110px); height: clamp(64px, 8vw, 110px); }
.timer-ring svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.timer-ring .track { stroke: var(--line); }
.timer-ring .bar   { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset 1s linear, stroke .3s; }
.timer-ring .num {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 800; font-size: clamp(1.4rem, 3vw, 2.4rem);
}
.answered-count { font-weight: 800; font-size: clamp(1rem, 2vw, 1.5rem); color: var(--muted); }
.answered-count b { color: var(--accent); }

/* =========================================================================
   CLASSIFICA
   ========================================================================= */
.board { display: flex; flex-direction: column; gap: 12px; width: min(900px, 100%); margin: auto; }
.board-row {
  display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 16px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-s); padding: 16px 20px;
  font-weight: 800; font-size: clamp(1.1rem, 2.4vw, 1.7rem);
  animation: slideIn .5s cubic-bezier(.2,.9,.3,1) both;
}
.board-row .rank { font-family: var(--font-display); color: var(--accent); }
.board-row .gain { color: var(--ok); font-size: .8em; }
.board-row.you { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 40%, transparent); }
@keyframes slideIn { from { transform: translateX(-30px); opacity: 0; } }

/* =========================================================================
   PODIO FINALE
   ========================================================================= */
.podium-stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 30px; padding-bottom: 4vh; }
.podium { display: flex; align-items: flex-end; gap: clamp(12px, 2vw, 30px); }
.pod-col { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.pod-name { font-family: var(--font-display); font-weight: 800; font-size: clamp(1.1rem, 2.6vw, 2rem); }
.pod-score { color: var(--muted); font-weight: 800; }
.pod-bar {
  width: clamp(110px, 16vw, 220px);
  border-radius: 16px 16px 0 0;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line); border-bottom: none;
  display: grid; place-items: start center; padding-top: 14px;
  font-family: var(--font-display); font-weight: 800; font-size: clamp(2rem, 5vw, 4rem);
  transform-origin: bottom; animation: rise .9s cubic-bezier(.2,1,.3,1) both;
}
@keyframes rise { from { transform: scaleY(0); } }
.pod-1 .pod-bar { height: clamp(180px, 26vh, 320px); background: linear-gradient(180deg, #ffd54a, #f0a500); color: #3a2600; box-shadow: 0 0 60px rgba(255,184,0,.4); }
.pod-2 .pod-bar { height: clamp(130px, 19vh, 240px); background: linear-gradient(180deg, #e6e9ef, #aab2c5); color: #2a2f3a; animation-delay: .12s; }
.pod-3 .pod-bar { height: clamp(100px, 15vh, 190px); background: linear-gradient(180deg, #f0a979, #c9763e); color: #3a1f0c; animation-delay: .24s; }
.crown { font-size: clamp(1.6rem, 4vw, 3rem); animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px); } }

/* canvas coriandoli a tutto schermo */
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; }

/* =========================================================================
   FEEDBACK PLAYER (esatto / sbagliato a tutto schermo)
   ========================================================================= */
.feedback { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; animation: fbIn .35s cubic-bezier(.2,1.3,.4,1) both; }
@keyframes fbIn { from { transform: scale(.6); opacity: 0; } }
.feedback .emoji { font-size: 4.5rem; }
.feedback h2 { font-size: 2.4rem; }
.feedback .pts { font-family: var(--font-display); font-size: 3rem; font-weight: 800; color: var(--ok); }
.full-ok { background: radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--ok) 35%, transparent), transparent 70%); }
.full-ko { background: radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--ko) 35%, transparent), transparent 70%); }
.rank-line { font-weight: 800; color: var(--muted); font-size: 1.2rem; }
.rank-line b { color: var(--accent); }

/* =========================================================================
   PANNELLO ADMIN
   ========================================================================= */
.admin { max-width: 880px; margin: 0 auto; padding: 32px 22px 80px; }
.admin h1 { font-size: 2.4rem; margin-bottom: 6px; }
.admin .sub { color: var(--muted); margin-bottom: 28px; }
.settings-row { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 26px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 700; font-size: .85rem; color: var(--muted); }
.field .input { min-width: 140px; }
.q-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 16px; }
.q-card .q-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.q-num { font-family: var(--font-display); font-weight: 800; color: var(--accent); font-size: 1.3rem; }
.q-card .opt { display: grid; grid-template-columns: 40px 1fr; gap: 10px; align-items: center; margin-bottom: 8px; }
.q-card .opt .pick { display: grid; place-items: center; }
.q-card .opt input[type=radio] { width: 22px; height: 22px; accent-color: var(--ok); }
.q-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.btn.small { padding: 9px 16px; font-size: .9rem; box-shadow: 0 5px 0 rgba(0,0,0,.35); }
.toolbar { position: sticky; bottom: 0; display: flex; gap: 12px; justify-content: flex-end; padding: 16px; margin-top: 24px; background: linear-gradient(180deg, transparent, var(--bg) 40%); }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(calc(100% + 40px)); background: var(--ok); color: #04210f; font-weight: 800; padding: 14px 24px; border-radius: 999px; transition: transform .3s cubic-bezier(.2,1.3,.4,1); z-index: 80; }
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--ko); color: #fff; }

/* =========================================================================
   RESPONSIVE
   ========================================================================= */
@media (max-width: 820px) {
  .lobby { grid-template-columns: 1fr; }
  .host-answers, .q-text { font-size: 1.3rem; }
}
@media (max-width: 380px) {
  .answer { min-height: 96px; padding: 16px 12px; font-size: 1.02rem; }
  .answers { gap: 10px; }
}

/* =========================================================================
   MODALITÀ FOTO + CONTROLLO MUSICA  (aggiunti)
   ========================================================================= */
/* immagine della domanda sullo schermo host */
.q-image { display: flex; justify-content: center; }
.q-image img {
  max-height: 38vh; max-width: 90%;
  border-radius: var(--radius-s);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  object-fit: contain;
}

/* controllo musica fisso in alto a destra (host) */
.music-ctl {
  position: fixed; bottom: 12px; left: 16px; z-index: 60;
  display: flex; align-items: center; gap: 10px;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 999px; padding: 8px 14px;
}
.music-ctl button {
  background: none; border: none; cursor: pointer;
  font-size: 1.4rem; line-height: 1;
}
.music-ctl input[type=range] { width: 90px; accent-color: var(--accent); cursor: pointer; }

/* anteprima immagine nel pannello admin */
.img-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.img-prev {
  width: 84px; height: 84px; object-fit: cover;
  border-radius: 12px; border: 1px solid var(--line);
}

/* =========================================================================
   AVATAR  (aggiunti)
   ========================================================================= */
/* rappresentazione base: emoji o foto ritagliata a cerchio */
.av-emoji { line-height: 1; display: inline-block; }
.av-img { border-radius: 50%; object-fit: cover; border: 2px solid var(--line); vertical-align: middle; }

/* anteprima della scelta nel join */
.av-select { display: flex; align-items: center; gap: 14px; margin-top: 4px; }
.av-preview {
  width: 72px; height: 72px; flex: 0 0 auto;
  display: grid; place-items: center;
  background: var(--surface); border: 2px solid var(--line); border-radius: 50%;
}
.av-preview.big { width: 96px; height: 96px; }

/* griglia di avatar */
.av-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-top: 4px; }
.av-btn {
  aspect-ratio: 1; display: grid; place-items: center;
  background: var(--surface); border: 2px solid var(--line); border-radius: 14px;
  cursor: pointer; transition: transform .1s ease, border-color .12s ease, opacity .15s ease;
}
.av-btn:active { transform: scale(.9); }
.av-btn.sel { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); background: var(--surface-2); }
.av-btn.taken { opacity: .28; cursor: not-allowed; filter: grayscale(1); position: relative; }
.av-btn.taken::after { content: "🔒"; position: absolute; font-size: 13px; right: 2px; bottom: 2px; }

.av-or { text-align: center; color: var(--muted); font-weight: 700; margin: 6px 0 2px; }
.photo-row { display: flex; gap: 10px; }
.photo-btn { flex: 1; text-align: center; font-size: .95rem; padding: 14px 10px; }
.photo-btn input { display: none; }

/* chip giocatore (lobby host) con avatar */
.player-chip { display: inline-flex; align-items: center; gap: 8px; }
.player-chip .av-img { width: 30px; height: 30px; }

/* riga classifica con avatar */
.row-name { display: flex; align-items: center; gap: 12px; min-width: 0; }
.row-name > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* avatar sul podio */
.pod-av { display: grid; place-items: center; }
@media (max-width: 380px) {
  .av-grid { grid-template-columns: repeat(5, 1fr); }
}

/* =========================================================================
   MODALITÀ PUNTEGGIO  (aggiunti)
   ========================================================================= */
/* selettore modalità nel pannello admin */
.q-mode { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.q-mode-lbl { font-weight: 700; color: var(--muted); font-size: .9rem; }
select.input { cursor: pointer; }
.mode-sel { width: auto; min-width: 210px; padding-right: 14px; }

/* badge della modalità sullo schermo host */
.mode-badge { font-size: .62em; padding: 4px 12px; border-radius: 999px; font-weight: 800; white-space: nowrap; vertical-align: middle; }
.mode-badge.speed { background: color-mix(in srgb, var(--c-c) 22%, transparent); color: var(--c-c); }
.mode-badge.base  { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); }

/* riga informativa sul cellulare */
.mode-hint { text-align: center; font-weight: 800; color: var(--muted); font-size: .95rem; padding: 2px 0; }

/* punti negativi (penalità) in classifica: rosso invece del verde */
.gain.neg { color: var(--ko); }

/* =========================================================================
   COUNTDOWN 3-2-1-VIA  (aggiunto)
   ========================================================================= */
.countdown {
  flex: 1; min-height: 60vh;
  display: flex; align-items: center; justify-content: center;
}
.cd-num {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(7rem, 30vw, 20rem); line-height: 1;
  color: var(--accent);
  text-shadow: 0 0 60px color-mix(in srgb, var(--accent) 60%, transparent);
}
.cd-pulse { animation: cdPulse .9s cubic-bezier(.2,1.2,.3,1); }
@keyframes cdPulse {
  0%   { transform: scale(.3); opacity: 0; }
  40%  { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
.cd-go {
  color: var(--ok);
  text-shadow: 0 0 70px color-mix(in srgb, var(--ok) 70%, transparent);
  animation: cdGo .7s cubic-bezier(.2,1.4,.3,1);
}
@keyframes cdGo {
  0%   { transform: scale(.4) rotate(-6deg); opacity: 0; }
  50%  { transform: scale(1.25) rotate(3deg); }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

/* =========================================================================
   PANNELLO GENERAZIONE AI  (aggiunto)
   ========================================================================= */
.ai-box {
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 12%, var(--surface)), var(--surface));
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 22px; margin-bottom: 22px;
  box-shadow: var(--shadow);
}
.ai-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 14px; font-weight: 700; font-size: .85rem; cursor: pointer;
  font-family: var(--font-body); transition: border-color .12s ease, color .12s ease;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }

/* la toolbar admin va a capo se i pulsanti non ci stanno (mobile) */
.toolbar { flex-wrap: wrap; }

/* =========================================================================
   SELETTORE LINGUA (pillola fissa, uguale su tutte le pagine)
   ========================================================================= */
.lang-switch {
  position: fixed; top: 16px; left: 16px; z-index: 60;
  display: flex; gap: 2px; padding: 4px;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.lang-switch button {
  background: none; border: none; cursor: pointer;
  font-family: var(--font-body); font-weight: 800; font-size: .78rem;
  letter-spacing: .06em; color: var(--muted);
  padding: 6px 12px; border-radius: 999px; line-height: 1;
  transition: background .12s ease, color .12s ease;
}
.lang-switch button:hover { color: var(--text); }
.lang-switch button.on { background: var(--accent); color: #04211c; }

/* =========================================================================
   PAGINA DI SCELTA (organizzatore / partecipante)
   ========================================================================= */
.home { width: 100%; max-width: 900px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.home-title {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(2.6rem, 9vw, 5rem); line-height: 1;
  background: linear-gradient(100deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.home-tagline { color: var(--muted); font-weight: 600; font-size: clamp(.95rem, 2.4vw, 1.15rem); }
.home-pick { font-size: clamp(1.1rem, 3vw, 1.5rem); font-weight: 800; margin-top: 18px; }

.home-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; width: 100%; margin-top: 6px; }
.role-card {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 30px 24px 26px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-decoration: none; color: var(--text);
  transition: transform .14s ease, border-color .14s ease, box-shadow .14s ease;
}
.role-card:hover { transform: translateY(-4px); }
.role-host:hover { border-color: var(--accent-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-2) 30%, transparent), var(--shadow); }
.role-play:hover { border-color: var(--accent);   box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent),   var(--shadow); }
.role-emoji { font-size: clamp(2.4rem, 7vw, 3.4rem); line-height: 1; }
.role-name  { font-family: var(--font-display); font-weight: 800; font-size: clamp(1.3rem, 3.4vw, 1.9rem); }
.role-desc  { color: var(--muted); font-weight: 600; font-size: .93rem; line-height: 1.45; max-width: 30ch; }
.role-cta   { margin-top: 8px; pointer-events: none; font-size: 1rem; padding: 12px 22px; }

.home-hint { color: var(--muted); font-size: .85rem; margin-top: 20px; max-width: 52ch; line-height: 1.5; }
.home-admin { color: var(--muted); font-weight: 700; font-size: .85rem; text-decoration: none; margin-top: 4px; }
.home-admin:hover { color: var(--accent); }

@media (max-width: 640px) {
  .home-choice { grid-template-columns: 1fr; }
  .role-card { padding: 24px 20px 22px; }
}

/* =========================================================================
   PANNELLO DOMANDE DELL'HOST (modifica la partita in corso)
   ========================================================================= */
.host-top-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.room-note { font-size: .8rem; line-height: 1.45; text-align: center; margin-top: 6px; }

.host-editor {
  position: fixed; inset: 0; z-index: 70;
  display: flex; flex-direction: column;
  background: color-mix(in srgb, var(--bg) 96%, transparent);
  backdrop-filter: blur(10px);
}
.host-editor[hidden] { display: none; }
.host-editor-bar {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 18px; flex-wrap: wrap;
  padding: 18px clamp(16px, 3vw, 34px);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
}
.host-editor-bar h2 { font-size: clamp(1.2rem, 2.6vw, 1.7rem); }
.host-editor-bar .muted { font-size: .85rem; max-width: 70ch; margin-top: 4px; line-height: 1.45; }
.host-editor-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.host-editor-body {
  flex: 1; overflow-y: auto;
  padding: 22px clamp(16px, 3vw, 34px) 80px;
}
.host-editor-body > div { max-width: 880px; margin: 0 auto; }

/* un pulsante-etichetta disabilitato (le <label> non hanno :disabled) */
.btn.off { opacity: .45; pointer-events: none; }

/* riga dei pulsanti sotto la lista domande (aggiungi / svuota) */
.ed-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

/* =========================================================================
   MOTIVAZIONE DELLA RISPOSTA GIUSTA
   ========================================================================= */
/* campo nell'editor */
.q-why { margin: 4px 0 14px; }
.q-why textarea.input { width: 100%; resize: vertical; min-height: 62px; line-height: 1.45; font-family: var(--font-body); }
.q-why .q-why-flag { display: none; color: var(--c-c); font-weight: 800; margin-left: 8px; }
.q-why.missing .q-why-flag { display: inline; }
.q-why.missing textarea.input { border-color: var(--c-c); }

/* riquadro mostrato a fine domanda (giocatore e schermo host) */
.why-box {
  margin-top: 16px; text-align: left;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: var(--radius-s); padding: 14px 16px;
}
.why-answer { font-weight: 800; margin-bottom: 8px; color: var(--ok); }
.why-label {
  font-weight: 800; font-size: .75rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 4px;
}
.why-text { line-height: 1.5; }
.host-why {
  align-self: center; max-width: 1000px; width: 100%;
  animation: whyIn .4s ease both;
}
.host-why .why-text { font-size: clamp(1rem, 1.9vw, 1.5rem); }

@keyframes whyIn { from { transform: translateY(14px); opacity: 0; } }


/* =========================================================================
   STUDIO TV — fari, tessere in rilievo, numeri che si fanno vedere
   ========================================================================= */
body::after {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    conic-gradient(from 168deg at 12% -8%, transparent 0 8deg, rgba(255,46,154,.2) 12deg 18deg, transparent 24deg),
    conic-gradient(from 172deg at 88% -8%, transparent 0 6deg, rgba(255,225,77,.16) 11deg 17deg, transparent 23deg);
  animation: fari 9s ease-in-out infinite alternate;
  transform-origin: 50% 0;
}
@keyframes fari { from { transform: skewX(-6deg); } to { transform: skewX(6deg); } }

.btn {
  background: linear-gradient(180deg, #fff07a, var(--accent)); color: #2c1270; font-family: var(--font-display); font-weight: 800;
  box-shadow: 0 6px 0 #b98f00, 0 18px 30px -14px rgba(255,225,77,.7); border: 0;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #b98f00; }
.btn.secondary { background: var(--surface-2); color: var(--text); box-shadow: 0 5px 0 #1f0b56; }
.btn.secondary:active { box-shadow: 0 1px 0 #1f0b56; }
.btn:disabled { filter: grayscale(.7); opacity: .55; box-shadow: none; }

.card { border: 2px solid var(--line); background: linear-gradient(170deg, rgba(58,26,140,.92), rgba(44,18,112,.92)); }
.input:focus { outline: 3px solid var(--accent); outline-offset: 1px; }

.answer, .host-answer {
  border: 0; border-radius: 18px; color: #fff; font-weight: 800; text-shadow: 0 2px 0 rgba(0,0,0,.22);
  box-shadow: inset 0 -7px 0 rgba(0,0,0,.2), 0 12px 22px -14px #000;
  transition: transform .1s, opacity .2s, filter .2s;
}
.answer:active:not(:disabled) { transform: translateY(3px) scale(.985); box-shadow: inset 0 -3px 0 rgba(0,0,0,.2); }
.answer.picked { outline: 4px solid #fff; outline-offset: 2px; }
.host-answer.win { outline: 6px solid #fff; animation: vincente .7s cubic-bezier(.2,1.5,.4,1) both; }
@keyframes vincente { 40% { transform: scale(1.05); } }

.q-text { font-family: var(--font-display); font-weight: 800; letter-spacing: -.02em; text-shadow: 0 4px 22px rgba(0,0,0,.45); }
.huge-pin { color: var(--accent); text-shadow: 0 6px 0 #b98f00, 0 0 40px rgba(255,225,77,.45); }
.host-title, .home-title { color: #fff; text-shadow: 0 5px 0 var(--accent-2), 0 0 44px rgba(255,46,154,.55); }
.cd-num { color: var(--accent); text-shadow: 0 10px 0 var(--accent-2); }

.streak {
  display: inline-block; margin: 8px 0 2px; padding: 7px 16px; border-radius: 999px;
  background: linear-gradient(90deg, #ff7a1a, #ff2e63); color: #fff;
  font-family: var(--font-display); font-weight: 800; font-size: 1.15rem;
  animation: fiamma .55s cubic-bezier(.2,1.6,.4,1) both;
}
@keyframes fiamma { from { transform: scale(.4) rotate(-6deg); opacity: 0; } }
.fire { color: #ffb066; font-weight: 800; font-size: .85em; }
.board-row { border-radius: 16px; }
.board-row:first-child { background: linear-gradient(90deg, rgba(255,225,77,.3), transparent); }
.tnj { color: var(--accent); }
@media (prefers-reduced-motion: reduce) { body::after, .streak, .host-answer.win { animation: none; } }

/* Sul telefono le pillole fisse coprivano logo e contenuti: la lingua scorre
   con la pagina, la musica resta solo col suo bottone, e in fondo c'è spazio. */
@media (max-width: 720px) {
  .lang-switch { position: absolute; top: 8px; left: 12px; }
  body { padding-top: 46px; }
  .music-ctl { padding: 6px 10px; }
  .music-ctl input[type=range] { display: none; }
  body { padding-bottom: 72px; }
}
