:root {
  --red: #e10600; --gold: #ffd400; --cyan: #00f0ff; --pink: #ff2bd6; --lime: #39ff14;
  --ink: #111; --paper: #fffbe6;
}
* { box-sizing: border-box; }
body {
  margin: 0; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; color: var(--ink);
  font-family: "Comic Sans MS", "Comic Neue", "Chalkboard SE", cursive;
  background: #5b1a8c radial-gradient(#fff 1px, transparent 1.5px) 0 0 / 24px 24px;
}
main { flex: 1; min-height: 0; width: 100%; max-width: 480px; margin: 0 auto; padding: 16px 16px 170px; display: flex; flex-direction: column; justify-content: safe center; overflow: hidden; }
main.wide { max-width: 960px; overflow-y: auto; justify-content: flex-start; }

.ticker { flex: none; background: var(--red); color: var(--gold); font-weight: bold; overflow: hidden; white-space: nowrap; border-bottom: 3px ridge var(--gold); }
.ticker span { display: inline-block; padding: 4px 0; animation: scroll 32s linear infinite; }
@keyframes scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }

.card {
  background: var(--paper); border: 4px outset var(--gold); padding: 16px; margin: 16px 0;
  box-shadow: 6px 6px 0 var(--pink);
}
h1, h2 { margin: 0 0 12px; line-height: 1.15; }
h1 {
  font-size: 1.8rem; text-align: center; color: var(--gold);
  text-shadow: 3px 3px 0 var(--red), 5px 5px 0 #000;
}
.blink { animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.bounce { display: inline-block; animation: bounce .8s ease-in-out infinite alternate; }
@keyframes bounce { to { transform: translateY(-8px) rotate(-4deg); } }

.progress { position: fixed; left: 0; right: 0; bottom: 0; height: 40px; z-index: 6; border-top: 3px ridge var(--gold); background: #000; }
.progress div { height: 100%; background: linear-gradient(45deg, var(--lime) 25%, #0a0 25% 50%, var(--lime) 50% 75%, #0a0 75%) 0 0 / 40px 40px; animation: grow .6s ease-out, stripes 1s linear infinite; }
@keyframes grow { from { width: var(--from, 0); } }
@keyframes stripes { to { background-position: 40px 0; } }
.progress span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: bold; font-size: 1.25rem; text-shadow: 2px 2px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000; }

button, input {
  font: inherit; font-size: 1.1rem; width: 100%; padding: 14px; margin: 6px 0;
  border: 4px outset #ccc; background: #e0e0e0; color: var(--ink); cursor: pointer;
}
button:active { border-style: inset; }
input { border-style: inset; background: #fff; cursor: text; }
button.big { background: var(--red); color: var(--gold); font-weight: bold; font-size: 1.3rem; border-color: #ff6b6b; }
button:disabled { opacity: .45; cursor: default; }
button.opt.on { background: var(--cyan); border-color: var(--cyan); font-weight: bold; }
button.ghost { background: transparent; border: none; color: #fff; text-decoration: underline; font-size: .95rem; }
button.opt.duel {
  height: clamp(90px, 22dvh, 180px); display: flex; align-items: flex-end; justify-content: center; padding: 8px;
  font-size: 1.4rem; font-weight: bold; color: #fff; text-shadow: 2px 2px 0 #000, -1px -1px 0 #000;
  background: #333 center / cover;
}
button.opt.duel.on { background-size: cover; background-position: center; outline: 5px solid var(--lime); outline-offset: -5px; }
.dragl { margin: 0; padding-left: 1.8em; }
.dragl li { touch-action: none; user-select: none; cursor: grab; margin: 6px 0; padding: 10px 14px; background: #e0e0e0; border: 4px outset #ccc; }
.dragl li::marker { font-weight: bold; color: var(--red); }
.dragl li.on { background: var(--cyan); box-shadow: 4px 4px 0 var(--pink); }
.vs, .round, .champ { text-align: center; font-weight: bold; margin: 4px 0; }
.vs { font: 2rem Impact, "Arial Black", sans-serif; color: var(--red); text-shadow: 2px 2px 0 var(--gold); }
.round { color: #0033ff; }
.champ { font-size: 1.6rem; }
.opt .num { display: inline-block; min-width: 1.8em; background: var(--red); color: var(--gold); margin-right: 8px; }

/* miccia che si consuma, dinamite in punta */
.timer { height: 16px; margin: 18px 28px 18px 0; background: #000; border: 2px inset #888; }
.timer div { position: relative; height: 100%; background: linear-gradient(var(--gold), var(--red)); animation: burn linear forwards; }
.tnt { position: absolute; right: -25px; top: 50%; translate: 0 -50%; width: 50px; height: 50px; }
@keyframes burn { from { width: 100%; } to { width: 0; } }
.err { color: var(--red); font-weight: bold; }
.gif { display: block; max-width: 100%; margin: 0 auto 12px; image-rendering: pixelated; }

/* golden buzz stile pop-art: esplosione, base argento, cilindro dorato */
.buzz {
  position: fixed; left: 50%; bottom: 20px; translate: -50% 0; scale: 1.3; transform-origin: 50% 100%; z-index: 5; isolation: isolate;
  width: 124px; height: 112px; padding: 0; margin: 0; border: 0; background: none; box-shadow: none;
}
.buzz::before {
  content: ""; position: absolute; inset: 0; z-index: -2;
  background: radial-gradient(#0005 1px, transparent 1.6px) 0 0 / 5px 5px, var(--red);
  clip-path: polygon(50.0% 0.0%,57.3% 17.8%,71.7% 5.0%,70.6% 24.2%,89.1% 18.8%,79.7% 35.7%,98.7% 38.9%,83.0% 50.0%,98.7% 61.1%,79.7% 64.3%,89.1% 81.2%,70.6% 75.8%,71.7% 95.0%,57.3% 82.2%,50.0% 100.0%,42.7% 82.2%,28.3% 95.0%,29.4% 75.8%,10.9% 81.2%,20.3% 64.3%,1.3% 61.1%,17.0% 50.0%,1.3% 38.9%,20.3% 35.7%,10.9% 18.8%,29.4% 24.2%,28.3% 5.0%,42.7% 17.8%);
}
.buzz::after {
  content: ""; position: absolute; left: 18px; right: 18px; top: 50px; height: 38px; z-index: -1; border-radius: 50%;
  background: linear-gradient(#fafafa, #9a9a9a 60%, #d8d8d8); box-shadow: 0 5px 0 #555, 0 0 0 2px #000;
}
.buzz span {
  position: absolute; left: 26px; right: 26px; top: 28px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; text-align: center;
  font: bold .72rem/1 Impact, "Arial Black", sans-serif; color: #000; letter-spacing: .5px;
  background: radial-gradient(ellipse at 38% 30%, #fff8c4, #ffd400 38%, #e0a800 75%, #b07d00);
  box-shadow: 0 14px 0 #a87400, 0 14px 0 2px #000, 0 0 0 2px #000;
  transition: transform .08s, box-shadow .08s;
}
.buzz:active span, .buzz.here span { transform: translateY(10px); box-shadow: 0 4px 0 #a87400, 0 4px 0 2px #000, 0 0 0 2px #000; }
.buzz.here::before { background: radial-gradient(#0005 1px, transparent 1.6px) 0 0 / 5px 5px, var(--lime); animation: spin 6s linear infinite; }
@keyframes spin { to { rotate: 1turn; } }

.confetti { position: fixed; top: -20px; width: 10px; height: 14px; z-index: 10; pointer-events: none; animation: fall 2.2s ease-in infinite backwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* statistiche */
.grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .grid { grid-template-columns: 1fr 1fr; } }
.grid .card { margin: 0; }
.bar { margin: 6px 0; font-size: .95rem; }
.bar .track { background: #000; border: 2px inset #999; height: 20px; }
.bar .fill { height: 100%; }
.pie { width: 180px; height: 180px; border-radius: 50%; margin: 8px auto; border: 4px outset var(--gold); }
.legend { list-style: none; padding: 0; margin: 0; }
.legend i { display: inline-block; width: 14px; height: 14px; margin-right: 6px; border: 1px solid #000; vertical-align: middle; }
.stack { display: flex; height: 26px; border: 2px inset #999; background: #000; }
.stack div { color: #000; font-size: .8rem; display: flex; align-items: center; justify-content: center; overflow: hidden; white-space: nowrap; }
.buzzlist li { margin: 8px 0; }

.otp { display: flex; gap: 6px; }
.otp input { text-align: center; padding: 10px 0; font-size: 1.6rem; }

main.login h1 { white-space: nowrap; font-size: clamp(1.1rem, 6.5vw, 1.8rem); }

.rules { padding-left: 1.6em; }
.rules li { margin: 8px 0; }
.rules li::marker { color: #0033ff; font-weight: bold; }

.card h1 { animation: bob .8s ease-in-out infinite alternate; }
@keyframes bob { to { transform: translateY(-6px) rotate(-1deg); } }
.card h1.still { animation: none; }
.side { flex: 0 1 auto; min-height: 0; height: 110px; width: auto; align-self: center; transform: rotate(-6deg); border: 3px ridge var(--gold); }
.sides { display: flex; justify-content: space-between; align-items: flex-start; min-height: 0; }
.sides .side:first-child { transform: rotate(5deg); }
.sides .side:last-child { transform: rotate(-4deg); margin-top: 16px; }
.card p { white-space: pre-line; }

.devnav { position: fixed; top: 44px; right: 8px; z-index: 20; display: flex; gap: 4px; }
.devnav span { align-self: center; padding: 2px 6px; background: #000; color: #0f0; font: 12px monospace; opacity: .8; }
.devnav button { width: auto; margin: 0; padding: 4px 10px; font-size: 1rem; opacity: .8; }

.card h1 + p { text-align: center; }
.rules-h { color: #0033ff; font-weight: bold; margin-bottom: 0; }

.gif.small { height: 128px; width: auto; max-width: 100%; }
.trophy { height: clamp(100px, 25dvh, 220px); width: auto; }

/* intro col logo: si accende tipo tubo catodico, resta, sfuma; tap per saltare */
#splash { position: fixed; inset: 0; z-index: 100; background: #000; display: flex; align-items: center; justify-content: center; animation: splash-out .5s ease-in 2.2s forwards; }
#splash img { width: min(70vw, 340px); animation: crt-on .7s ease-out both; }
@keyframes crt-on {
  0% { transform: scale(1, .01); filter: brightness(4); opacity: 0; }
  40% { transform: scale(1, .01); filter: brightness(4); opacity: 1; }
  70% { transform: scale(1, 1.15); filter: brightness(2); }
  100% { transform: none; filter: none; }
}
@keyframes splash-out { to { opacity: 0; visibility: hidden; } }

/* pagina 0: le parti compaiono in ordine; in pausa finché c'è la splash */
main.seq .card { animation: pop .45s both; }
main.seq .card h1 { animation: pop .4s .45s both, bob .8s 1s ease-in-out infinite alternate; }
main.seq .card h1 + p { animation: pop .4s .85s both; }
main.seq #body > :not(#next) { animation: pop .4s 1.25s both; }
main.seq #next { animation: pop .4s 1.75s both; }
#splash ~ main.seq, #splash ~ main.seq * { animation-play-state: paused; }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.9); } }
.ps { font-size: .8rem; font-style: italic; opacity: .75; text-align: center; }
