/* =====================================================================
   Tombolix — "app moderna, pulita e calda"
   Sfondo chiaro, testo grafite, un solo colore forte: il rosso della pallina.
   Schibsted Grotesk (titoli e numeri) + Hanken Grotesk (testo). Font ospitati in locale.
   ===================================================================== */
@font-face {
  font-family: "Schibsted Grotesk";
  src: url("/fonts/schibsted-grotesk.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
}
@font-face {
  font-family: "Hanken Grotesk";
  src: url("/fonts/hanken-grotesk.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Hanken Grotesk";
  src: url("/fonts/hanken-grotesk-italic.woff2") format("woff2");
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}

:root {
  --bg: #F6F5F1;
  --surface: #FFFFFF;
  --surface-2: #F0EEE8;
  --ink: #17181B;
  --ink-2: #3C3F45;
  --muted: #6C6F76;
  --line: #E6E3DC;
  --line-2: #D4D0C7;
  --red: #E5432D;
  --red-dark: #C4331F;
  --red-soft: #FDEDE9;
  --green: #17855A;
  --green-soft: #E4F3EB;
  --gold: #B97F00;
  --gold-soft: #FFF3D1;
  --display: "Schibsted Grotesk", "Helvetica Neue", Arial, sans-serif;
  --text: "Hanken Grotesk", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r: 14px;
  --r-sm: 10px;
  --r-lg: 22px;
  --shadow: 0 1px 2px rgba(23, 24, 27, .04), 0 8px 24px rgba(23, 24, 27, .06);
  --shadow-lg: 0 2px 6px rgba(23, 24, 27, .05), 0 24px 48px rgba(23, 24, 27, .12);
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--text);
  font-size: 16.5px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { max-width: 100%; display: block; }
a { color: inherit; text-decoration-thickness: 1.5px; text-underline-offset: 3px; text-decoration-color: var(--line-2); transition: color .15s, text-decoration-color .15s; }
a:hover { color: var(--red); text-decoration-color: currentColor; }
p { margin: 0 0 1em; }
h1, h2, h3, h4 { margin: 0 0 .45em; font-family: var(--display); font-weight: 700; line-height: 1.08; letter-spacing: -.025em; }
h1 { font-size: clamp(2.2rem, 5.5vw, 3.4rem); }
h2 { font-size: clamp(1.6rem, 3.4vw, 2.1rem); }
h3 { font-size: 1.2rem; letter-spacing: -.015em; }
h4 { font-size: 1rem; }
[hidden] { display: none !important; }
::selection { background: var(--red-soft); color: var(--red-dark); }
:focus-visible { outline: 3px solid rgba(229, 67, 45, .45); outline-offset: 2px; border-radius: 6px; }

.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.wrap--narrow { max-width: 640px; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.tiny { font-size: .8rem; }
.center { text-align: center; }
.upper { font-size: .78rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.row--end { justify-content: flex-end; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 14px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 1.2em; height: 1.2em; flex-shrink: 0; display: inline-block; vertical-align: -.22em; }
.red { color: var(--red); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Marchio ---------- */
.mark { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); font-family: var(--display); font-weight: 800; font-size: 1.3rem; letter-spacing: -.03em; line-height: 1; }
.mark:hover { color: var(--ink); }
.mark__ball { width: 32px; height: 32px; border-radius: 50%; background: var(--red); color: #fff; display: grid; place-items: center; font-size: .82rem; font-weight: 800; letter-spacing: -.02em; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .12); }
.mark--light, .mark--light:hover { color: #fff; }

/* ---------- Pulsanti ---------- */
.btn {
  --bg: var(--surface); --fg: var(--ink); --bd: var(--line-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border: 1px solid var(--bd); border-radius: 12px;
  background: var(--bg); color: var(--fg);
  font: 600 .98rem/1 var(--text); text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .12s var(--ease), box-shadow .15s;
}
.btn:hover { border-color: var(--ink); color: var(--fg); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn--red { --bg: var(--red); --fg: #fff; --bd: var(--red); box-shadow: 0 6px 16px rgba(229, 67, 45, .24); }
.btn--red:hover { --bg: var(--red-dark); --bd: var(--red-dark); }
.btn--ink { --bg: var(--ink); --fg: #fff; --bd: var(--ink); }
.btn--ink:hover { --bg: #000; }
.btn--line { --bg: transparent; }
.btn--flat { --bg: transparent; --bd: transparent; padding: 0 10px; }
.btn--flat:hover { --bg: var(--surface-2); --bd: transparent; }
.btn--danger { --bg: transparent; --fg: var(--red-dark); --bd: #F2C2B9; }
.btn--danger:hover { --bg: var(--red-soft); --bd: var(--red); }
.btn--sm { min-height: 36px; padding: 0 12px; font-size: .9rem; border-radius: 10px; }
.btn--lg { min-height: 56px; padding: 0 26px; font-size: 1.06rem; border-radius: 14px; }
.btn--block { width: 100%; }
.btn--display { font-family: var(--display); font-weight: 700; font-size: 1.35rem; letter-spacing: -.02em; }
.link-arrow { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; text-decoration: none; }
.link-arrow .icon { transition: transform .2s var(--ease); }
.link-arrow:hover .icon { transform: translateX(3px); }

/* ---------- Form ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.field > label, .label { font-weight: 600; font-size: .92rem; }
.hint { font-size: .85rem; color: var(--muted); margin: 0; font-weight: 400; }
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=url], input[type=search], select, textarea {
  width: 100%; min-height: 48px; padding: 11px 14px; border-radius: 12px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font: inherit;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: #A3A6AC; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='m5 8 5 5 5-5' fill='none' stroke='%236C6F76' stroke-width='1.8'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 18px; padding-right: 40px; }
textarea { min-height: 100px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 4px var(--red-soft); }
input[readonly] { background: var(--surface-2); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 640px) { .pair { grid-template-columns: 1fr; } }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--red); flex-shrink: 0; }
.code-input { font-family: var(--display); font-weight: 700; font-size: 2rem; letter-spacing: .35em; text-align: center; padding-left: .35em; }

.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 600; }
.switch input { appearance: none; width: 46px; height: 28px; border-radius: 999px; background: var(--line-2); position: relative; cursor: pointer; transition: background .2s; margin: 0; flex-shrink: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: transform .2s var(--ease); }
.switch input:checked { background: var(--green); }
.switch input:checked::after { transform: translateX(18px); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; border: 1px solid var(--line-2); border-radius: 12px; background: var(--surface); padding: 6px; min-height: 48px; transition: border-color .15s, box-shadow .15s; }
.chips:focus-within { border-color: var(--red); box-shadow: 0 0 0 4px var(--red-soft); }
.chips input { border: 0 !important; box-shadow: none !important; min-height: 34px; padding: 4px 8px; flex: 1; min-width: 160px; background: transparent; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-2); padding: 5px 6px 5px 11px; border-radius: 8px; font-weight: 600; font-size: .9rem; }
.chip button { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 2px; border-radius: 6px; display: grid; place-items: center; }
.chip button:hover { color: var(--red); background: var(--red-soft); }

/* ---------- Messaggi ---------- */
.note { background: var(--surface-2); border-radius: 12px; padding: 13px 16px; margin: 14px 0; font-size: .95rem; }
.note--red { background: var(--red-soft); color: var(--red-dark); }
.note--ok { background: var(--green-soft); color: #0E5E3E; }
.note--sun { background: var(--gold-soft); color: #7A5400; }
.note b { font-weight: 700; }

/* ---------- Stati (pillole) ---------- */
.stamp, .tag { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; line-height: 1.2; white-space: nowrap; background: var(--surface-2); color: var(--ink-2); }
.stamp::before, .tag::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .85; }
.stamp { background: var(--green-soft); color: var(--green); }
.stamp--red { background: var(--surface-2); color: var(--muted); }   /* in attesa: neutro, non allarmante */
.stamp--muted { background: var(--surface-2); color: #9A9DA3; }
.stamp--sun { background: var(--gold-soft); color: var(--gold); }
.tag--red { background: var(--red-soft); color: var(--red-dark); }
.tag--ink { background: var(--green-soft); color: var(--green); }
.tag--line { color: var(--muted); }
.tag--line::before { opacity: .4; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); display: inline-block; box-shadow: 0 0 0 0 rgba(229, 67, 45, .5); animation: ping 1.6s infinite; }
@keyframes ping { 70% { box-shadow: 0 0 0 7px rgba(229, 67, 45, 0); } 100% { box-shadow: 0 0 0 0 rgba(229, 67, 45, 0); } }

/* ---------- Riquadri ---------- */
.box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 22px; box-shadow: var(--shadow); }
.box + .box { margin-top: 18px; }
.cols > .box + .box { margin-top: 0; }
.box--flat { box-shadow: none; background: transparent; }
.box__title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 16px; }
.box__title h2, .box__title h3 { margin: 0; display: flex; align-items: center; gap: 8px; }
.rule { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }
.rule--thin { margin: 16px 0; }

/* ---------- Tabellone 1-90 ---------- */
.board { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.board__n {
  aspect-ratio: 1; display: grid; place-items: center; border-radius: 9px; background: var(--surface-2);
  font-family: var(--display); font-weight: 600; font-size: clamp(.82rem, 2.4vw, 1.1rem); color: #A5A8AE;
  font-variant-numeric: tabular-nums; transition: background .3s var(--ease), color .3s var(--ease), transform .3s var(--ease);
}
.board__n[data-drawn] { background: var(--ink); color: #fff; }
.board__n[data-last] { background: var(--red); color: #fff; transform: scale(1.08); box-shadow: 0 6px 14px rgba(229, 67, 45, .35); }

/* ---------- Pallina ---------- */
.ball {
  width: 112px; height: 112px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  background: radial-gradient(circle at 34% 28%, #FF7B66 0, var(--red) 46%, var(--red-dark) 100%); color: #fff;
  font-family: var(--display); font-weight: 800; font-size: 3.4rem; line-height: 1; letter-spacing: -.04em; font-variant-numeric: tabular-nums;
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .1), 0 10px 26px rgba(229, 67, 45, .32);
}
.ball--empty { background: var(--surface-2); color: #B2B4B9; box-shadow: none; }
.ball.pop { animation: pop .5s var(--ease); }
@keyframes pop { 0% { transform: scale(.5); opacity: .2; } 60% { transform: scale(1.06); } 100% { transform: none; opacity: 1; } }
.recent { display: flex; gap: 6px; flex-wrap: wrap; }
.recent span { min-width: 32px; height: 32px; padding: 0 6px; border-radius: 999px; display: grid; place-items: center; background: var(--surface-2); color: var(--ink-2); font-family: var(--display); font-weight: 600; font-size: .9rem; font-variant-numeric: tabular-nums; }

/* ---------- Cartella ---------- */
.ticket { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); position: relative; overflow: hidden; transition: box-shadow .2s, border-color .2s; }
.ticket__head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--line); min-height: 48px; }
.ticket__no { font-family: var(--display); font-weight: 700; font-size: 1rem; letter-spacing: -.01em; }
.ticket__meta { font-size: .8rem; color: var(--muted); font-weight: 600; }
.ticket__grid { display: grid; grid-template-columns: repeat(9, 1fr); gap: 4px; padding: 8px; }
.ticket__cell {
  aspect-ratio: 1 / 1.1; display: grid; place-items: center; position: relative; user-select: none; border-radius: 9px;
  background: var(--surface); border: 1px solid var(--line);
  font-family: var(--display); font-weight: 700; font-size: clamp(1rem, 4.4vw, 1.5rem); font-variant-numeric: tabular-nums; letter-spacing: -.02em;
  transition: background .2s, color .2s, border-color .2s;
}
.ticket__cell span { position: relative; z-index: 1; }
.ticket__cell--empty { background: var(--surface-2); border-color: transparent; }
button.ticket__cell { color: inherit; cursor: pointer; padding: 0; font-family: var(--display); }
button.ticket__cell:hover { border-color: var(--ink); }
/* Uscito ma non segnato (modalità a mano): bordo rosso tratteggiato */
.ticket__cell[data-drawn]:not([data-marked]) { border: 2px dashed var(--red); }
/* Segnato */
.ticket__cell[data-marked] { background: var(--red); border-color: var(--red); color: #fff; animation: mark .25s var(--ease); }
@keyframes mark { from { transform: scale(.8); } }
/* Riga vincente: si colorano d'oro solo i numeri segnati */
.ticket__cell[data-marked].ticket__row-win { background: #E8A60F; border-color: #E8A60F; }
.ticket--off { box-shadow: none; }
.ticket--off .ticket__grid { opacity: .5; }
.ticket--won { border-color: #F0C04A; box-shadow: 0 0 0 3px var(--gold-soft), var(--shadow); }

/* ---------- Avvisi ---------- */
.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 300; width: min(92vw, 420px); pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 13px 16px; border-radius: 14px; font-weight: 600; font-size: .95rem; box-shadow: var(--shadow-lg); animation: toastIn .3s var(--ease); pointer-events: auto; display: flex; gap: 10px; align-items: center; }
.toast .icon { color: #7FD3A8; }
.toast--win { background: #FFF; color: var(--ink); border: 1px solid #F0C04A; }
.toast--win .icon { color: var(--gold); }
.toast--error .icon { color: #FF9A8A; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(.98); } }

/* ---------- Sponsor ---------- */
.sponsors { overflow: hidden; background: var(--surface); border-top: 1px solid var(--line); }
.sponsors__inner { display: flex; align-items: center; }
.sponsors__label { font-size: .78rem; font-weight: 600; color: var(--muted); padding: 0 18px; flex-shrink: 0; white-space: nowrap; }
.sponsors__viewport { overflow: hidden; flex: 1; mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent); }
.sponsors__track { display: flex; gap: 44px; width: max-content; animation: marquee 40s linear infinite; padding: 12px 20px; align-items: center; }
.sponsors:hover .sponsors__track { animation-play-state: paused; }
.sponsors a, .sponsors .sponsor { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; white-space: nowrap; color: var(--ink-2); }
.sponsors img { height: 38px; width: auto; max-width: 140px; object-fit: contain; filter: grayscale(1); opacity: .75; transition: filter .2s, opacity .2s; }
.sponsors a:hover img { filter: none; opacity: 1; }
@keyframes marquee { to { transform: translateX(-50%); } }

/* ---------- Tabelle ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
table.table { width: 100%; border-collapse: collapse; font-size: .94rem; }
.table th { text-align: left; font-size: .78rem; color: var(--muted); font-weight: 600; padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #FBFAF8; }
.table td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: #FBFAF8; }
.table tr[data-click] { cursor: pointer; }

.spinner { width: 30px; height: 30px; margin: 60px auto; border: 3px solid var(--line); border-top-color: var(--red); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty { text-align: center; padding: 40px 24px; border: 1.5px dashed var(--line-2); border-radius: var(--r-lg); }
.empty h3 { margin-bottom: 6px; }
.empty .icon { width: 36px; height: 36px; margin: 0 auto 12px; color: var(--muted); }

.footer-mini { padding: 32px 20px; color: var(--muted); font-size: .85rem; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .sponsors__track { animation: none; flex-wrap: wrap; width: auto; }
}
