/* ============================================================================
   Ferragosto Quiz — direzione visiva "Notte di Ferragosto".
   Cielo indaco→prugna, luminarie calde, superfici in vetro, luce e profondità.
   Tutto self-contained: nessun font o asset remoto.
   ========================================================================== */

:root {
  /* cielo notturno */
  --sky-0: #0a1030;
  --sky-1: #131a44;
  --sky-2: #241350;
  --sky-3: #3a1a4e;

  /* superfici in vetro */
  --glass: rgba(255, 255, 255, 0.055);
  --glass-2: rgba(255, 255, 255, 0.09);
  --stroke: rgba(255, 255, 255, 0.14);
  --stroke-soft: rgba(255, 255, 255, 0.08);

  /* accenti festa */
  --oro: #ffcf4a;
  --oro-2: #ff9e2c;
  --anguria: #ff466e;
  --anguria-2: #ff7aa0;
  --mare: #35d6c8;
  --cielo: #49a9ff;
  --uva: #a678ff;
  --lime: #a6e05a;

  /* testo */
  --panna: #fff5e6;
  --panna-soft: #c3c8ee;
  --panna-dim: #8b92c4;
  --scuro: #0a1030;

  /* legacy (compat con vecchi riferimenti) */
  --notte: var(--sky-0);
  --notte-2: var(--glass);
  --notte-3: var(--stroke);
  --limone: var(--oro);
  --pistacchio: var(--mare);
  --azzurro: var(--cielo);

  --r: 16px;
  --r-lg: 22px;
  --gap: clamp(12px, 3vw, 24px);

  /* profondità: ombra ambientale + chiave */
  --shadow: 0 2px 4px rgba(0, 0, 0, 0.3), 0 18px 40px -18px rgba(0, 0, 0, 0.65);
  --shadow-glow: 0 10px 40px -12px rgba(120, 90, 255, 0.5);

  --font-body: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-num: ui-monospace, "SF Mono", "Roboto Mono", Menlo, monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--sky-0);
  color: var(--panna);
  font-family: var(--font-body);
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

/* Cielo stratificato: gradiente notte + bagliori di luminarie che respirano. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(120% 90% at 8% -10%, rgba(255, 207, 74, 0.20), transparent 45%),
    radial-gradient(120% 90% at 100% -8%, rgba(255, 70, 110, 0.20), transparent 46%),
    radial-gradient(140% 120% at 50% 120%, rgba(73, 169, 255, 0.16), transparent 55%),
    linear-gradient(160deg, var(--sky-1) 0%, var(--sky-2) 46%, var(--sky-3) 78%, var(--sky-0) 100%);
  animation: respiro 9s ease-in-out infinite;
}
@keyframes respiro { 0%, 100% { opacity: 1; } 50% { opacity: 0.82; } }

/* Grana filmica sottile: toglie la piattezza da "template". */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.wrap {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: var(--gap);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

/* --- tipografia ---------------------------------------------------------- */

.eyebrow {
  font-size: clamp(11px, 2.6vw, 13px);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  font-weight: 800;
  color: var(--oro);
  margin: 0;
}

.titolo {
  font-size: clamp(28px, 7.5vw, 48px);
  line-height: 1.02;
  letter-spacing: -0.03em;
  font-weight: 850;
  margin: 0;
  text-wrap: balance;
  background: linear-gradient(180deg, #fff 8%, #ffe6b8 55%, #ffbf6a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 14px rgba(255, 180, 90, 0.22));
}

.sottotitolo { color: var(--panna-soft); margin: 0; line-height: 1.55; }

.numerone {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--oro);
}

/* --- controlli ----------------------------------------------------------- */

.campo {
  width: 100%;
  padding: 18px;
  font-size: 20px;
  font-family: inherit;
  color: var(--panna);
  background: var(--glass);
  border: 1px solid var(--stroke);
  border-radius: var(--r);
  backdrop-filter: blur(8px);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.campo::placeholder { color: var(--panna-dim); }
.campo:focus-visible {
  outline: none;
  border-color: var(--oro);
  box-shadow: 0 0 0 3px rgba(255, 207, 74, 0.28);
}

/* Pulsante "caramella": gradiente, bordo luminoso, spessore 3D, gloss. */
.bottone {
  position: relative;
  width: 100%;
  padding: 19px;
  font-size: 19px;
  font-weight: 850;
  font-family: inherit;
  letter-spacing: 0.01em;
  color: var(--scuro);
  background: linear-gradient(180deg, #ffe27a 0%, var(--oro) 55%, var(--oro-2) 100%);
  border: 0;
  border-radius: var(--r);
  box-shadow: 0 6px 0 #b9701a, 0 14px 26px -10px rgba(255, 158, 44, 0.7);
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.07s ease, box-shadow 0.07s ease, filter 0.15s ease;
}
.bottone::after { /* riflesso lucido in alto */
  content: "";
  position: absolute;
  inset: 1px 1px auto 1px;
  height: 42%;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.55), transparent);
  pointer-events: none;
}
.bottone:active { transform: translateY(4px); box-shadow: 0 2px 0 #b9701a, 0 8px 16px -10px rgba(255, 158, 44, 0.7); }
.bottone:disabled { filter: saturate(0.5) brightness(0.8); opacity: 0.6; cursor: not-allowed; }
.bottone:focus-visible { outline: 3px solid var(--panna); outline-offset: 3px; }

.bottone.secondario {
  color: var(--panna);
  background: linear-gradient(180deg, var(--glass-2), var(--glass));
  border: 1px solid var(--stroke);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35), 0 12px 24px -14px rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
}
.bottone.secondario::after { opacity: 0.25; }
.bottone.secondario:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35); }

.bottone.pericolo {
  color: #fff;
  background: linear-gradient(180deg, #ff6f8d, var(--anguria) 60%, #e02d55);
  box-shadow: 0 6px 0 #a41638, 0 14px 26px -10px rgba(255, 70, 110, 0.6);
}

.bottone.piccolo { padding: 11px 14px; font-size: 14px; width: auto; box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35); }

/* --- superfici in vetro (pill, tessere, pannelli) ------------------------ */

.pill {
  display: inline-block;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(8px);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--panna);
}

/* --- risposte: caramelle colorate, badge tondo, bagliore ----------------- */

.risposte { display: grid; grid-template-columns: 1fr; gap: 12px; }
.risposte.grande { grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) { .risposte.grande { grid-template-columns: 1fr; } }

.risposta {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 88px;
  padding: 16px 18px;
  font-size: 18px;
  font-weight: 800;
  font-family: inherit;
  text-align: left;
  color: var(--scuro);
  border: 0;
  border-radius: var(--r);
  background: linear-gradient(165deg, var(--c1, #5566aa), var(--c2, #33447f));
  box-shadow: 0 5px 0 var(--edge, rgba(0, 0, 0, 0.35)),
              0 16px 30px -14px var(--c1, #000),
              inset 0 1px 0 rgba(255, 255, 255, 0.4);
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.08s ease, box-shadow 0.2s ease, opacity 0.25s ease, filter 0.2s ease;
}
.risposta::after { /* gloss */
  content: "";
  position: absolute;
  inset: 1px 1px 55% 1px;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.4), transparent);
  pointer-events: none;
}
.risposta:hover { filter: brightness(1.05); }
.risposta:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--edge, rgba(0, 0, 0, 0.35)), inset 0 1px 0 rgba(255, 255, 255, 0.4); }
.risposta:focus-visible { outline: 3px solid var(--panna); outline-offset: 3px; }

/* badge tondo con la forma/lettera */
.risposta .forma {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.18);
  color: var(--panna);
  font-size: 20px; line-height: 1;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

/* 10 tinte coese; --edge = versione scura per lo spessore 3D */
.risposta[data-i="0"] { --c1: #ff6f8d; --c2: #e63a63; --edge: #a41d40; color: #fff; }
.risposta[data-i="1"] { --c1: #63b8ff; --c2: #2f86e6; --edge: #1a5aa8; color: #04122e; }
.risposta[data-i="2"] { --c1: #ffd95e; --c2: #ffab24; --edge: #c07a12; }
.risposta[data-i="3"] { --c1: #55e0cf; --c2: #22b6a4; --edge: #147d70; color: #04231f; }
.risposta[data-i="4"] { --c1: #c39bff; --c2: #9a68f0; --edge: #6a3fb0; color: #fff; }
.risposta[data-i="5"] { --c1: #ffb060; --c2: #ff8a2a; --edge: #c25e0f; }
.risposta[data-i="6"] { --c1: #6fe0d0; --c2: #34b7c4; --edge: #1c7f8c; color: #04231f; }
.risposta[data-i="7"] { --c1: #ff86b6; --c2: #f0589a; --edge: #b12c66; color: #fff; }
.risposta[data-i="8"] { --c1: #bfe36a; --c2: #93c93f; --edge: #5f8e18; color: #10230a; }
.risposta[data-i="9"] { --c1: #ffe07a; --c2: #ffc23e; --edge: #c68a12; }

.risposta.spenta { opacity: 0.28; filter: grayscale(0.4); }
.risposta.giusta {
  opacity: 1;
  outline: 4px solid var(--panna);
  outline-offset: 2px;
  box-shadow: 0 5px 0 var(--edge), 0 0 40px -4px var(--c1), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  animation: vinci 0.5s ease;
}
@keyframes vinci { 0% { transform: scale(1); } 40% { transform: scale(1.045); } 100% { transform: scale(1); } }

.risposte.fitta .risposta { min-height: 62px; font-size: 16px; }
.risposte.fitta .risposta .forma { width: 32px; height: 32px; font-size: 16px; }

/* percentuali di voto al reveal (anonime) */
.risposta .perc {
  margin-left: auto;
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 0.95em;
  z-index: 1;
}
.risposta .barrap {
  position: absolute;
  left: 0; bottom: 0;
  height: 9px;
  background: rgba(0, 0, 0, 0.42);
  border-radius: 0 9px 0 var(--r);
  transition: width 0.7s cubic-bezier(0.2, 0.9, 0.3, 1);
}

/* --- timer: barra luminosa che pulsa quando il tempo stringe ------------- */

.timer {
  height: 14px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--stroke-soft);
  border-radius: 999px;
  overflow: hidden;
}
.timer > i {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--mare), var(--oro) 55%, var(--anguria));
  box-shadow: 0 0 18px rgba(255, 207, 74, 0.6);
  transform-origin: left;
  transition: transform 0.25s linear;
}

/* --- tessere classifica (vetro + podio luminoso) ------------------------- */

.tabellone { display: flex; flex-direction: column; gap: 10px; }

.tessera {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 13px 16px;
  background: var(--glass);
  border: 1px solid var(--stroke);
  border-radius: var(--r);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}
.tessera .pos {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: clamp(28px, 6vw, 40px);
  font-weight: 800;
  letter-spacing: -0.05em;
  min-width: 2.2ch;
  text-align: center;
  color: var(--panna-soft);
}
.tessera .nome {
  font-weight: 800;
  font-size: clamp(16px, 3.6vw, 21px);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tessera .punti {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: clamp(17px, 3.6vw, 23px);
  color: var(--oro);
}
.tessera.podio-1 {
  border-color: rgba(255, 207, 74, 0.75);
  background: linear-gradient(100deg, rgba(255, 207, 74, 0.18), var(--glass) 60%);
  box-shadow: 0 0 34px -6px rgba(255, 207, 74, 0.55), var(--shadow);
}
.tessera.podio-1 .punti { color: #fff; }
.tessera.podio-2 { border-color: rgba(195, 200, 238, 0.6); }
.tessera.podio-3 { border-color: rgba(255, 158, 44, 0.6); }
.tessera.io { border-color: var(--mare); box-shadow: 0 0 0 1px var(--mare), var(--shadow); }
.tessera .pos.medaglia { font-size: clamp(30px, 6.4vw, 46px); filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5)); }

/* --- esiti / attesa ------------------------------------------------------ */

.esito {
  text-align: center;
  padding: clamp(26px, 8vw, 52px) var(--gap);
  border-radius: var(--r-lg);
  border: 1px solid var(--stroke);
  background: var(--glass);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}
.esito.si { border-color: rgba(53, 214, 200, 0.7); box-shadow: 0 0 34px -8px rgba(53, 214, 200, 0.5), var(--shadow); }
.esito.no { border-color: rgba(255, 70, 110, 0.7); box-shadow: 0 0 34px -8px rgba(255, 70, 110, 0.45), var(--shadow); }
.esito .verdetto { font-size: clamp(30px, 8vw, 46px); font-weight: 850; margin: 0 0 6px; letter-spacing: -0.02em; }
.esito .punti-vinti { font-size: clamp(40px, 12vw, 66px); }

.riga { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.centro { display: flex; flex-direction: column; justify-content: center; flex: 1; gap: var(--gap); }
.avviso { color: var(--anguria-2); font-weight: 800; min-height: 1.4em; margin: 0; }
[hidden] { display: none !important; }

/* --- banner identità di manche (emoji a colori + gradiente a tema) ------- */

.manche-hero {
  position: relative;
  display: flex;
  align-items: center;
  gap: clamp(12px, 2vw, 22px);
  padding: clamp(14px, 2.2vw, 22px) clamp(18px, 3vw, 34px);
  border-radius: var(--r-lg);
  color: var(--panna);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.22);
  overflow: hidden;
  animation: hero-in 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}
.manche-hero::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), transparent 60%);
  pointer-events: none;
}
.manche-hero .mh-emoji {
  font-size: clamp(42px, 6.5vw, 90px); line-height: 1;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.4));
  animation: galleggia 3.5s ease-in-out infinite;
}
.manche-hero .mh-nome {
  font-size: clamp(24px, 3.8vw, 54px); font-weight: 850; letter-spacing: -0.02em;
  text-wrap: balance; text-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}
.manche-hero .mh-tag {
  margin-left: auto; font-size: clamp(12px, 1.4vw, 16px); font-weight: 800;
  letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.9;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
}
@keyframes hero-in { from { opacity: 0; transform: translateY(-12px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes galleggia { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-6px) rotate(2deg); } }

.manche-chips { display: flex; flex-wrap: wrap; gap: 10px; }
.manche-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 15px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--stroke);
  backdrop-filter: blur(8px);
  font-weight: 800; font-size: clamp(14px, 1.5vw, 20px);
  box-shadow: var(--shadow);
}
.manche-chip .e { font-size: 1.4em; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35)); }

/* --- manche puzzle: immagine coperta da tessere che si scoprono ---------- */

.puzzle {
  position: relative; width: 100%;
  max-width: min(90vw, 1100px); margin: 0 auto;
  border-radius: var(--r-lg); overflow: hidden;
  box-shadow: var(--shadow); background: var(--glass);
  border: 1px solid var(--stroke);
}
.puzzle img { display: block; width: 100%; height: auto; }
.pz-grid { position: absolute; inset: 0; display: grid; gap: 2px; background: transparent; }
.pz-tile {
  background: linear-gradient(135deg, var(--sky-2), var(--sky-1));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
  transition: opacity 0.55s ease, transform 0.55s ease;
}
.pz-tile.via { opacity: 0; transform: scale(0.82); }

/* --- manche canzone: nota che pulsa mentre suona ------------------------- */

.canzone {
  text-align: center;
  padding: clamp(22px, 6vw, 50px);
  border-radius: var(--r-lg);
  background: var(--glass);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}
.canzone .nota { font-size: clamp(72px, 18vw, 168px); line-height: 1; filter: drop-shadow(0 6px 18px rgba(166, 120, 255, 0.5)); }
.canzone.suona .nota { animation: pulsa 1.05s ease-in-out infinite; }
.canzone .audio-hint { margin-top: 12px; color: var(--panna-soft); }
@keyframes pulsa { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.14); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
