:root {
  --bg: #160d2b;
  --surface: #2a1a52;
  --surface-2: #3d2a75;
  --line: #4b3590;
  --line-strong: #8a74c4;
  --text: #ffffff;
  --muted: #d9cff2;
  --faint: #cbbfe8;
  --purple: #7c3aed;
  --orange: #ff8a1f;
  --orange-deep: #b85a00;
  --yellow: #ffd23f;
  --ink: #2a1200;
  --danger: #ff9b8f;
  --ok: #8fe3b0;
  --font-head: "Fredoka", ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Nunito", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
}
h1, h2, h3 { font-family: var(--font-head); margin: 0; line-height: 1.15; }
h1 { font-size: clamp(1.9rem, 4.5vw, 2.6rem); font-weight: 700; }
h2 { font-size: 1.3rem; font-weight: 700; }
h3 { font-size: 1.05rem; margin: 18px 0 8px; }
h1:focus { outline: none; }
p { margin: 0; }
a { color: var(--yellow); }
code { font-size: .85em; word-break: break-all; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
[hidden] { display: none !important; }

/* Forme decorative di sfondo */
.bg-shape { position: fixed; border-radius: 50%; pointer-events: none; z-index: 0; }
.bg-a { top: -140px; right: -90px; width: 380px; height: 380px; background: var(--purple); opacity: .35; }
.bg-b { bottom: -150px; left: -110px; width: 400px; height: 400px; background: var(--orange); opacity: .18; }

.app { position: relative; z-index: 1; max-width: 1120px; margin: 0 auto; padding: 24px 24px 56px; }
main { display: block; }
.view { display: flex; flex-direction: column; gap: 24px; }

/* Header */
.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.logo { width: 48px; height: 48px; display: block; flex: none; }
.logo .mlogo { width: 100%; height: 100%; display: block; overflow: visible; }
.wordmark { height: 42px; width: auto; display: block; }
.nav { display: flex; flex-wrap: wrap; gap: 8px; }
.nav-link {
  display: flex; align-items: center; min-height: 44px; padding: 10px 20px; border-radius: 999px;
  background: var(--surface); color: var(--text); font-weight: 700; text-decoration: none;
}
.nav-link[aria-current="page"] { background: var(--yellow); color: var(--ink); }
.top-right { display: flex; align-items: center; gap: 12px; }

/* Bandierine rotonde */
.flags { display: flex; align-items: center; gap: 2px; }
.flag { width: 48px; height: 48px; border: 0; background: none; padding: 0; display: grid; place-items: center; cursor: pointer; }
.flag .disc {
  width: 36px; height: 36px; border-radius: 50%; overflow: hidden; display: flex;
  box-shadow: 0 0 0 2px var(--line); opacity: .85; transition: transform .15s ease, box-shadow .15s ease;
}
.flag[aria-pressed="true"] .disc { box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--yellow); transform: scale(1.12); opacity: 1; }
.flag .disc > span { flex: 1; }
.flag .disc svg { width: 100%; height: 100%; display: block; }
.flag-it .disc > span:nth-child(1) { background: #009246; }
.flag-it .disc > span:nth-child(2) { background: #ffffff; }
.flag-it .disc > span:nth-child(3) { background: #ce2b37; }
.flag-fr .disc > span:nth-child(1) { background: #0055a4; }
.flag-fr .disc > span:nth-child(2) { background: #ffffff; }
.flag-fr .disc > span:nth-child(3) { background: #ef4135; }
.flag-de .disc { flex-direction: column; }
.flag-de .disc > span:nth-child(1) { background: #000000; }
.flag-de .disc > span:nth-child(2) { background: #dd0000; }
.flag-de .disc > span:nth-child(3) { background: #ffce00; }

/* Stelle */
.star { width: 44px; height: 44px; fill: none; stroke: var(--line-strong); }
.star.on, .star.yellow { fill: var(--yellow); stroke: var(--yellow); }
.star.orange { fill: var(--orange); stroke: var(--orange); }
.star.dark { width: 26px; height: 26px; fill: var(--ink); stroke: var(--ink); }
.star.pop { animation: pop .5s ease; }
@keyframes pop { 0% { transform: scale(.3) rotate(-30deg); } 60% { transform: scale(1.35) rotate(8deg); } 100% { transform: scale(1) rotate(0); } }

/* Card, testo, form */
.card { background: var(--surface); border: 2px solid var(--line); border-radius: 28px; padding: 28px; }
.muted { color: var(--muted); font-size: .95rem; }
.center { text-align: center; }
.label { color: var(--faint); font-size: .95rem; }
.label.strong { color: var(--text); font-weight: 700; }
.lead { color: var(--muted); font-size: 1.1rem; max-width: 560px; }
.error { color: var(--danger); font-weight: 700; }
.banner { background: var(--surface-2); border: 2px solid var(--ok); color: var(--ok); border-radius: 14px; padding: 10px 14px; font-weight: 700; }
.hint { color: var(--faint); font-size: .85rem; font-weight: 400; }
.pill { align-self: flex-start; background: var(--surface-2); color: var(--yellow); font-weight: 700; padding: 6px 16px; border-radius: 999px; font-size: .95rem; }

.auth-head { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.deco-stars { display: flex; gap: 6px; justify-content: center; }
.tagline { font-family: var(--font-head); font-weight: 700; font-size: clamp(1.9rem, 5vw, 2.8rem); line-height: 1.1; text-align: center; }
.auth-card { width: 100%; max-width: 480px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.center-card { align-items: center; text-align: center; }

.field { display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: .95rem; }
.draw-month { max-width: 240px; margin: 14px 0; }
input[type=email], input[type=password], input[type=text], input[type=search], input[type=month], textarea {
  width: 100%; min-height: 48px; padding: 10px 14px; font: inherit; font-size: 1rem; font-weight: 400;
  color: var(--text); background: var(--bg); border: 2px solid var(--line-strong); border-radius: 14px;
}
.check { display: flex; align-items: flex-start; gap: 12px; min-height: 44px; font-size: .95rem; line-height: 1.4; }
.check input { width: 24px; height: 24px; margin: 0; flex: none; accent-color: var(--orange); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.captcha { min-height: 65px; display: flex; justify-content: center; }

a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }

/* Pulsanti */
.btn {
  font-family: var(--font-head); font-weight: 700; font-size: 1.2rem; line-height: 1.1;
  display: inline-flex; align-items: center; justify-content: center; text-align: center;
  min-height: 52px; padding: 12px 36px; border-radius: 999px; border: 2px solid transparent; cursor: pointer; text-decoration: none;
}
.btn.primary { background: var(--orange); color: var(--ink); box-shadow: 0 6px 0 var(--orange-deep); transition: transform .08s ease, box-shadow .08s ease; }
.btn.primary:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 var(--orange-deep); }
.btn.ghost { background: none; color: var(--yellow); border-color: var(--yellow); }
.btn.small { min-height: 44px; padding: 8px 20px; font-size: 1rem; }
.btn.big { font-size: 1.4rem; min-height: 60px; padding: 14px 44px; }
.btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }

/* Gioca */
.split { display: flex; flex-wrap: wrap; gap: 24px; align-items: stretch; }
.hero { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 18px; padding: 32px; }
.side { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 24px; }
.stars { display: flex; flex-wrap: wrap; gap: 6px; }
.counter { font-family: var(--font-head); font-weight: 500; font-size: 1.4rem; color: var(--yellow); }
.done-pill {
  display: inline-flex; align-items: center; min-height: 56px; padding: 12px 28px; border-radius: 999px;
  background: var(--yellow); color: var(--ink); font-family: var(--font-head); font-weight: 700; font-size: 1.3rem;
}
.ad-slot {
  min-height: 150px; border: 2px dashed var(--line-strong); border-radius: 18px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 4px;
}
.ad-demo-label { font-size: .75rem; letter-spacing: .08em; color: var(--faint); }
.ad-countdown { font-family: var(--font-head); font-size: 2.6rem; font-weight: 700; }
.prize { background: var(--yellow); border-color: var(--yellow); color: var(--ink); display: flex; flex-direction: column; gap: 6px; }
.prize .label { color: var(--ink); font-weight: 700; }
.prize-value { font-family: var(--font-head); font-weight: 700; font-size: clamp(2.8rem, 7vw, 4rem); line-height: 1; }
.progress { height: 16px; margin: 12px 0; border-radius: 8px; background: var(--line); overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--orange); border-radius: 8px; transition: width .4s ease; }

.stats { display: flex; flex-wrap: wrap; gap: 24px; }
.stat { flex: 1 1 220px; display: flex; flex-direction: column; gap: 4px; padding: 22px 24px; border-radius: 24px; }
.stat-value { font-family: var(--font-head); font-weight: 700; font-size: 2.5rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat.accent { background: var(--surface-2); border-color: var(--yellow); }
.stat.accent .stat-value { color: var(--yellow); }
.stats.four .stat { flex-basis: 200px; }

/* Grafici a barre */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 150px; margin-top: 14px; }
.bar-col { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.bar { width: 100%; min-height: 2px; background: #9db3f7; border-radius: 4px 4px 0 0; }
.bars.mine .bar { background: var(--orange); }
.bar-day { margin-top: 4px; font-size: .65rem; color: var(--faint); }

/* Tabelle e admin */
.row { display: flex; gap: 8px; margin: 14px 0; }
.row input { flex: 1; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.badge { padding: 2px 10px; border-radius: 999px; font-size: .8rem; background: var(--surface-2); }
.badge.suspended { background: none; border: 1px solid var(--danger); color: var(--danger); }
.plain { list-style: none; margin: 0; padding: 0; }
.plain li { padding: 8px 0; border-bottom: 1px solid var(--line); }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 20;
  background: var(--yellow); color: var(--ink); font-weight: 700; padding: 10px 18px; border-radius: 12px;
  max-width: calc(100% - 32px);
}
dialog { border: 2px solid var(--line); border-radius: 20px; background: var(--surface); color: var(--text); max-width: 480px; padding: 24px; }
dialog::backdrop { background: rgba(0, 0, 0, .55); }
dialog form { margin-top: 16px; }

/* Coriandoli */
.confetti-layer { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 30; }
.confetti {
  position: absolute; top: -20px; left: var(--x); width: 10px; height: 16px; background: var(--c);
  border-radius: 2px; animation: fall var(--d) ease-in var(--delay) forwards;
}
@keyframes fall { to { transform: translateY(110vh) rotate(var(--r)); opacity: .9; } }

@media (max-width: 560px) {
  .app { padding: 16px 16px 48px; }
  .card { padding: 22px; }
  .hero { padding: 24px; }
  .star { width: 36px; height: 36px; }
  .bar-day { display: none; }
  .btn.big { width: 100%; padding: 14px 20px; }
}

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

/* Premio del mese */
.prize-img { display: block; width: 100%; max-height: 260px; object-fit: cover; border-radius: 14px; border: 3px solid var(--ink); background: #fff; }
.prize-value.is-title { font-size: clamp(1.6rem, 4.5vw, 2.2rem); line-height: 1.15; overflow-wrap: anywhere; }
.prize-desc { color: var(--ink); font-size: 1rem; overflow-wrap: anywhere; }
.prize-desc:empty { display: none; }
#admin-prize-form textarea { width: 100%; font: inherit; }
#admin-prize-form { display: flex; flex-direction: column; gap: 14px; }

/* Accesso con Google */
.google-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.google-wrap[hidden] { display: none; }
.or { display: flex; align-items: center; gap: 12px; width: 100%; margin: 4px 0 0; color: var(--muted, #c9b8f5); font-size: .9rem; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line-strong); }
.g-btn { min-height: 44px; display: flex; justify-content: center; color-scheme: light; } /* senza questo Google disegna un riquadro bianco dietro il pulsante */
