:root {
  --bg: #07070a;
  --panel: rgba(20, 18, 28, 0.72);
  --panel-solid: #141219;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.18);
  --text: #f4f2f8;
  --muted: #a29fb2;
  --brand: #e83e3b;
  --ok: #5df2a0;
  --bad: #ff6b6b;
  --font: Inter, system-ui, -apple-system, sans-serif;
  --display: Sora, Inter, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0; min-height: 100vh; font-family: var(--font); color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
button { font: inherit; }

/* ---------- sfondo ---------- */
.glow {
  position: fixed; inset: -20vmax; z-index: -2; pointer-events: none;
  background:
    radial-gradient(40vmax 30vmax at 15% 20%, rgba(232, 62, 59, 0.22), transparent 60%),
    radial-gradient(38vmax 28vmax at 85% 15%, rgba(255, 45, 149, 0.16), transparent 60%),
    radial-gradient(42vmax 32vmax at 70% 85%, rgba(38, 213, 255, 0.13), transparent 60%),
    radial-gradient(36vmax 28vmax at 20% 90%, rgba(232, 193, 112, 0.12), transparent 60%);
  animation: drift 28s ease-in-out infinite alternate;
}
.grain {
  position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: 0.06;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
@keyframes drift { to { transform: translate3d(4vmax, -3vmax, 0) rotate(6deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { opacity: 0; transform: scale(0.7); } 60% { transform: scale(1.06); } 100% { opacity: 1; transform: scale(1); } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 currentColor; } 50% { box-shadow: 0 0 0 6px transparent; } }
@keyframes beat { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@keyframes confetti { to { transform: translateY(110vh) rotate(720deg); } }

.wrap { width: min(1180px, 100%); margin: 0 auto; padding: 0 20px; }
.kicker {
  font-size: 12px; font-weight: 800; letter-spacing: 0.32em; text-transform: uppercase; color: var(--muted);
  display: inline-flex; align-items: center; gap: 10px;
}
.kicker::before, .kicker::after { content: ""; width: 28px; height: 1px; background: var(--line-strong); }
.gradient-title {
  margin: 0; font-family: var(--display); font-weight: 800; letter-spacing: -0.03em; line-height: 0.95;
  background: linear-gradient(100deg, #fff 20%, #ffb3c1 45%, #ff5d73 65%, #ffd48a 90%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.muted { color: var(--muted); }

/* ---------- portale ---------- */
.hero { padding: 48px 0 12px; display: grid; justify-items: center; text-align: center; gap: 18px; animation: rise 0.6s both; }
.hero img { width: min(220px, 55vw); height: auto; filter: drop-shadow(0 10px 30px rgba(232, 62, 59, 0.35)); }
.hero h1 { font-size: clamp(42px, 8vw, 92px); }
.lead { margin: 0; max-width: 560px; color: var(--muted); font-size: clamp(15px, 2vw, 18px); line-height: 1.5; }

.games { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; padding: 40px 0 28px; }
@media (max-width: 1100px) { .games { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.card {
  --accent: #fff; --accent-2: #fff;
  position: relative; overflow: hidden; isolation: isolate;
  display: flex; flex-direction: column; gap: 18px;
  padding: 28px; border-radius: 26px;
  background: var(--panel); border: 1px solid var(--line);
  backdrop-filter: blur(16px) saturate(1.2); -webkit-backdrop-filter: blur(16px) saturate(1.2);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.45);
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
  animation: rise 0.6s both;
}
.card:nth-child(2) { animation-delay: 0.08s; }
.card:nth-child(3) { animation-delay: 0.16s; }
.card:nth-child(4) { animation-delay: 0.24s; }
.card::before {
  content: ""; position: absolute; z-index: -1; inset: -1px; border-radius: inherit; pointer-events: none;
  background: radial-gradient(120% 90% at 100% 0%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 55%);
}
.card::after {
  content: ""; position: absolute; left: 28px; right: 28px; top: 0; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2)); opacity: 0.8;
}
.card:hover { transform: translateY(-4px); border-color: color-mix(in srgb, var(--accent) 45%, transparent); box-shadow: 0 36px 70px rgba(0, 0, 0, 0.55), 0 0 0 1px color-mix(in srgb, var(--accent) 20%, transparent); }
.card-head { display: flex; align-items: center; gap: 16px; }
.emblem {
  flex: none; width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; font-size: 32px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 30%, #111), color-mix(in srgb, var(--accent-2) 18%, #0b0b0e));
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  box-shadow: 0 12px 30px color-mix(in srgb, var(--accent) 25%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}
.title { min-width: 0; }
.title h2 { margin: 0; font-family: var(--display); font-size: 28px; letter-spacing: -0.02em; line-height: 1.05; }
.title p { margin: 4px 0 0; color: var(--accent); font-weight: 700; font-size: 14px; }
.status {
  margin-left: auto; align-self: flex-start; flex: none;
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 11px; border-radius: 999px;
  font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line);
}
.status i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status[data-state="online"] { color: var(--ok); }
.status[data-state="online"] i { animation: pulse 2s infinite; }
.status[data-state="offline"] { color: var(--bad); }
.desc { margin: 0; color: #d4d1df; line-height: 1.55; font-size: 15px; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.tags li { font-size: 12px; font-weight: 600; color: var(--muted); padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.03); }
.actions { margin-top: auto; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.actions.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 64px; padding: 10px 8px; border-radius: 16px; text-decoration: none; text-align: center; cursor: pointer;
  color: var(--text); background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line-strong);
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease;
}
.btn b { font-size: 15px; font-weight: 800; }
.btn small { font-size: 11px; color: var(--muted); font-weight: 600; }
.btn:hover:not(:disabled) { transform: translateY(-2px); background: rgba(255, 255, 255, 0.1); }
.btn:focus-visible { outline: 2px solid var(--accent, #fff); outline-offset: 3px; }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn.primary {
  --accent: #ff5d73; --accent-2: #ffb020;
  color: #0a0a0d; border-color: transparent;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  box-shadow: 0 12px 28px color-mix(in srgb, var(--accent) 35%, transparent);
}
.card .btn.primary { --accent: inherit; --accent-2: inherit; }
.btn.primary small { color: rgba(10, 10, 13, 0.7); }
.site-footer { padding: 16px 0 48px; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.6; }
.site-footer b { color: var(--text); }
.site-footer a { color: var(--muted); }

/* ---------- votazione sullo schermo (overlay) ---------- */
.poll {
  position: fixed; inset: 0; z-index: 10; display: none; overflow: hidden;
  background: radial-gradient(90vmax 60vmax at 50% 0%, rgba(232, 62, 59, 0.18), transparent 60%), rgba(7, 7, 10, 0.97);
  backdrop-filter: blur(10px);
}
.poll.show { display: grid; animation: rise 0.4s both; }
.poll-inner {
  width: min(1500px, 100%); margin: 0 auto; padding: 4vh 4vw; min-height: 0;
  display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.4fr); gap: 4vw; align-items: center;
}
.poll-left { display: grid; justify-items: center; text-align: center; gap: 2.2vh; }
.poll-left img.logo { width: min(180px, 14vw); }
.poll-left h2 { font-size: clamp(34px, 4.4vw, 76px); }
.qr-card {
  background: #fff; border-radius: 28px; padding: 18px; width: min(34vh, 30vw); aspect-ratio: 1;
  box-shadow: 0 30px 80px rgba(232, 62, 59, 0.35);
}
.qr-card img { width: 100%; height: 100%; display: block; }
.poll-url { font-size: clamp(16px, 1.6vw, 26px); font-weight: 800; letter-spacing: 0.02em; }
.poll-url span { color: var(--brand); }

.poll-right { display: grid; gap: 2.4vh; min-width: 0; }
.poll-top { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.poll-top .muted { font-size: clamp(16px, 1.5vw, 24px); font-weight: 700; }
.poll-top .total b { color: var(--text); font-family: var(--display); }
.countdown {
  font-family: var(--display); font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.03em;
  font-size: clamp(56px, 8vw, 140px); line-height: 1;
}
.countdown.hurry { color: #ff5d73; animation: beat 1s ease-in-out infinite; }
.timebar { height: 10px; border-radius: 99px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.timebar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #ff5d73, #ffb020); transition: width 0.25s linear; }

.bars { display: grid; gap: 1.8vh; }
.bar {
  --accent: #fff; --accent-2: #fff;
  position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 18px;
  padding: 1.6vh 22px; border-radius: 20px; overflow: hidden; isolation: isolate;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line);
  transition: border-color 0.3s ease, transform 0.3s ease;
}
.bar .fill {
  position: absolute; inset: 0 auto 0 0; z-index: -1; width: 0%;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 38%, transparent), color-mix(in srgb, var(--accent-2) 22%, transparent));
  transition: width 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.bar .emoji { font-size: clamp(26px, 2.6vw, 44px); }
.bar .name { font-family: var(--display); font-weight: 800; font-size: clamp(20px, 2.1vw, 36px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .name small { display: block; font-family: var(--font); font-size: clamp(12px, 1vw, 16px); font-weight: 700; color: var(--accent); }
.bar .num { text-align: right; font-family: var(--display); font-variant-numeric: tabular-nums; }
.bar .num b { display: block; font-size: clamp(22px, 2.4vw, 40px); line-height: 1; }
.bar .num small { font-size: clamp(12px, 1vw, 16px); color: var(--muted); font-weight: 700; }
.bar.lead { border-color: color-mix(in srgb, var(--accent) 60%, transparent); }

/* vincitore */
.winner { grid-column: 1 / -1; display: grid; justify-items: center; text-align: center; gap: 2vh; animation: pop 0.7s both; }
.winner .kicker { font-size: clamp(14px, 1.3vw, 20px); }
.winner-emblem {
  width: clamp(120px, 14vw, 220px); aspect-ratio: 1; border-radius: 36px; display: grid; place-items: center;
  font-size: clamp(64px, 8vw, 130px);
  background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 40%, #111), color-mix(in srgb, var(--accent-2) 25%, #0b0b0e));
  border: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
  box-shadow: 0 30px 100px color-mix(in srgb, var(--accent) 45%, transparent);
}
.winner h2 {
  margin: 0; font-family: var(--display); font-weight: 800; letter-spacing: -0.04em; line-height: 0.95;
  font-size: clamp(64px, 10vw, 180px);
  background: linear-gradient(100deg, #fff, var(--accent) 55%, var(--accent-2));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.winner p { margin: 0; font-size: clamp(18px, 1.8vw, 30px); color: var(--muted); font-weight: 700; }
.winner p b { color: var(--text); }
.confetti i { position: absolute; top: -20px; width: 12px; height: 18px; border-radius: 3px; animation: confetti 4s linear infinite; }

/* ---------- pagine telefono (voto / regia) ---------- */
.phone { width: min(520px, 100%); margin: 0 auto; padding: 24px 18px 48px; display: grid; gap: 18px; }
.phone-head { display: grid; justify-items: center; gap: 12px; text-align: center; padding-top: 8px; }
.phone-head img { width: 150px; }
.phone-head h1 { font-size: clamp(34px, 9vw, 46px); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 20px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.panel h3 { margin: 0 0 12px; font-size: 12px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
.phone-timer { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-weight: 700; color: var(--muted); }
.phone-timer b { font-family: var(--display); font-size: 34px; color: var(--text); font-variant-numeric: tabular-nums; }
.phone-timer b.hurry { color: #ff5d73; }

.choices { display: grid; gap: 12px; }
.choice {
  --accent: #fff; --accent-2: #fff;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px; width: 100%;
  padding: 16px; border-radius: 20px; text-align: left; cursor: pointer; color: var(--text);
  background: rgba(255, 255, 255, 0.04); border: 2px solid var(--line);
  transition: transform 0.15s ease, border-color 0.2s ease, background 0.2s ease;
}
.choice:active { transform: scale(0.98); }
.choice .emblem { width: 52px; height: 52px; font-size: 26px; border-radius: 15px; }
.choice b { display: block; font-family: var(--display); font-size: 21px; }
.choice small { color: var(--accent); font-weight: 700; font-size: 13px; }
.choice .check { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line-strong); display: grid; place-items: center; font-weight: 900; color: #0a0a0d; }
.choice.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.choice.selected .check { background: var(--accent); border-color: var(--accent); }
.choice:disabled { cursor: default; }
.notice { text-align: center; line-height: 1.5; }
.notice .big { font-size: 56px; margin-bottom: 8px; }
.notice h2 { margin: 0 0 6px; font-family: var(--display); font-size: 26px; }
.toast { text-align: center; font-weight: 700; color: var(--ok); min-height: 20px; }
.toast.err { color: var(--bad); }

/* regia */
.field { display: grid; gap: 8px; font-size: 13px; font-weight: 700; color: var(--muted); }
.field input, .field select {
  width: 100%; min-height: 50px; padding: 12px 14px; border-radius: 14px; font: inherit; font-size: 16px; color: var(--text);
  background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line-strong);
}
.field input:focus, .field select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px rgba(232, 62, 59, 0.18); }
.row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.checks { display: grid; gap: 8px; }
.checks label { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line); font-weight: 700; }
.checks input { width: 20px; height: 20px; accent-color: var(--brand); }
.mini-bars { display: grid; gap: 8px; }
.mini-bar { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.04); position: relative; overflow: hidden; isolation: isolate; font-weight: 700; }
.mini-bar i { position: absolute; inset: 0 auto 0 0; z-index: -1; background: color-mix(in srgb, var(--accent) 30%, transparent); transition: width 0.5s ease; }
.state-pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; font-size: 12px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); }
.state-pill.open { color: var(--ok); }
.state-pill.closed { color: #ffd48a; }
.error { color: var(--bad); font-weight: 700; text-align: center; }

@media (max-width: 860px) {
  .games { grid-template-columns: 1fr; }
  .poll-inner { grid-template-columns: 1fr; gap: 3vh; padding: 3vh 5vw; align-content: start; overflow-y: auto; max-height: 100vh; }
  .qr-card { width: min(260px, 60vw); }
  .poll-left img.logo { width: 130px; }
}
@media (max-width: 420px) {
  .card { padding: 22px; }
  .emblem { width: 54px; height: 54px; font-size: 28px; }
  .title h2 { font-size: 24px; }
  .actions, .actions.two { grid-template-columns: 1fr; }
  .btn { min-height: 54px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.winner-back { margin-top: 1vh; font-size: clamp(13px, 1.1vw, 18px); font-weight: 700; color: var(--muted); letter-spacing: 0.04em; }
