:root {
  --brand: #b3261e;
  --cream: #fbf6ee;
  --ink: #2a1f1a;
  --muted: #7a6a60;
  --line: #eadfce;
  --ok: #2e7d32;
  --card: #ffffff;
  --gold: #ffcf4a;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body { margin: 0; background: var(--cream); min-height: 100vh; }
.wrap { max-width: 460px; margin: 0 auto; padding: 20px 16px 48px; }
.wide { max-width: 1100px; }
h1 { font-size: 1.6rem; margin: 0 0 4px; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
p { line-height: 1.5; }
.muted { color: var(--muted); font-size: .92rem; }
.small { font-size: .82rem; }
.center { text-align: center; }

.hero { background: var(--brand); color: #fff; padding: 28px 16px 56px; text-align: center; }
.hero img { width: 72px; height: 72px; border-radius: 50%; background: #fff; box-shadow: 0 6px 18px rgba(0,0,0,.2); }
.hero p { opacity: .92; margin: 6px 0 0; }
.panel { background: var(--card); border-radius: 20px; padding: 20px; box-shadow: 0 8px 28px rgba(60, 30, 10, .08); }
.overlap { margin-top: -40px; }

label { display: block; font-weight: 600; margin: 14px 0 6px; font-size: .95rem; }
input[type=text], input[type=email], input[type=password], input[type=search] {
  width: 100%; padding: 14px; border: 1.5px solid var(--line); border-radius: 14px; font-size: 1rem; background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 15%, transparent); }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; font-size: .9rem; margin: 12px 0; }
.check input { margin-top: 3px; width: 20px; height: 20px; accent-color: var(--brand); flex: none; }

/* ---------- Pulsanti ---------- */
.btn {
  --bg: var(--brand);
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 54px; padding: 14px 18px; border: 0; border-radius: 16px;
  font: inherit; font-size: 1.05rem; font-weight: 700; letter-spacing: .01em;
  color: #fff; text-decoration: none; cursor: pointer; user-select: none;
  background: linear-gradient(180deg, color-mix(in srgb, var(--bg) 88%, #fff) 0%, var(--bg) 55%, color-mix(in srgb, var(--bg) 85%, #000) 100%);
  box-shadow: 0 1px 0 rgba(255,255,255,.35) inset, 0 6px 0 color-mix(in srgb, var(--bg) 60%, #000), 0 10px 22px rgba(0,0,0,.18);
  transform: translateY(0); transition: transform .08s, box-shadow .08s, filter .15s;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(5px); box-shadow: 0 1px 0 rgba(255,255,255,.35) inset, 0 1px 0 color-mix(in srgb, var(--bg) 60%, #000), 0 3px 8px rgba(0,0,0,.18); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn .ico { font-size: 1.35em; line-height: 1; }
.btn.ok { --bg: var(--ok); }
.btn.dark { --bg: #262626; }
.btn.big { min-height: 72px; font-size: 1.3rem; border-radius: 20px; }
.btn.ghost {
  background: #fff; color: var(--ink); border: 1.5px solid var(--line);
  box-shadow: 0 4px 0 var(--line), 0 6px 14px rgba(0,0,0,.06);
}
.btn.ghost:active { box-shadow: 0 1px 0 var(--line); }
.btn.pulse::after {
  content: ""; position: absolute; inset: -4px; border-radius: inherit; border: 3px solid var(--gold);
  animation: ring 1.6s ease-out infinite;
}
@keyframes ring { from { opacity: .9; transform: scale(.98); } to { opacity: 0; transform: scale(1.08); } }

/* Pulsante ufficiale Google Wallet: immagine originale, nessuna modifica di colore/forma */
.gwallet { display: block; width: 100%; padding: 8px 0; text-align: center; }
.gwallet img { height: 54px; max-width: 100%; transition: transform .1s; }
.gwallet:active img { transform: scale(.97); }

/* Barra di navigazione a pulsanti */
.nav { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 999px;
  background: #fff; color: var(--ink); text-decoration: none; font-weight: 600; font-size: .92rem; border: 1.5px solid var(--line);
  box-shadow: 0 3px 0 var(--line); cursor: pointer; font-family: inherit; transition: transform .08s, box-shadow .08s;
}
.chip:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.chip.danger { color: var(--brand); }

.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.stack > * + * { margin-top: 12px; }
.error { color: var(--brand); font-weight: 600; min-height: 1.2em; margin: 10px 0 0; }

/* ---------- Timbri ---------- */
.stamps { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 10px; margin: 14px 0; }
.stamp {
  position: relative; aspect-ratio: 1; border-radius: 50%; border: 2.5px dashed var(--line);
  display: grid; place-items: center; font-weight: 800; color: var(--line); font-size: .95rem;
}
.stamp.on { border: 0; background: #fff var(--stamp-on, url(/stamps/pizza.png)) center / 100% no-repeat; color: transparent; box-shadow: 0 3px 8px rgba(0,0,0,.18); }
.stamp.new { animation: stampIn .7s cubic-bezier(.2, 1.6, .4, 1) both; z-index: 1; }
.stamp.new::after {
  content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 4px solid var(--gold);
  animation: burst .8s ease-out .15s both;
}
@keyframes stampIn {
  0% { transform: scale(2.4) rotate(-200deg); opacity: 0; }
  60% { transform: scale(.85) rotate(10deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}
@keyframes burst { from { transform: scale(.6); opacity: 1; } to { transform: scale(1.8); opacity: 0; } }
.stamp.gone { animation: stampOut .4s ease-in both; }
@keyframes stampOut { to { transform: scale(0) rotate(90deg); opacity: 0; } }

.bump { animation: bump .5s ease-out; display: inline-block; }
@keyframes bump { 30% { transform: scale(1.6); color: var(--gold); } 100% { transform: scale(1); } }

/* ---------- Tessera ---------- */
.passcard {
  background: radial-gradient(120% 80% at 100% 0%, color-mix(in srgb, var(--brand) 70%, #fff) 0%, var(--brand) 45%, color-mix(in srgb, var(--brand) 75%, #000) 100%);
  color: #fff; border-radius: 24px; padding: 18px; box-shadow: 0 14px 34px color-mix(in srgb, var(--brand) 35%, transparent);
}
.passcard .top { display: flex; align-items: center; gap: 10px; }
.passcard .top img { width: 44px; height: 44px; border-radius: 50%; background: #fff; }
.passcard .stamp { border-color: rgba(255,255,255,.5); color: rgba(255,255,255,.6); }
.passcard .qr { background: #fff; border-radius: 16px; padding: 12px; text-align: center; color: var(--ink); }
.passcard .qr img { width: 200px; height: 200px; display: block; margin: 0 auto; }
.passcard.flash { animation: flash .6s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 0 var(--gold); } 50% { box-shadow: 0 0 0 10px color-mix(in srgb, var(--gold) 50%, transparent); } 100% { box-shadow: 0 14px 34px color-mix(in srgb, var(--brand) 35%, transparent); } }
.progress { height: 10px; border-radius: 999px; background: rgba(255,255,255,.25); overflow: hidden; }
.progress > div { height: 100%; background: var(--gold); border-radius: inherit; transition: width .6s cubic-bezier(.2, 1.4, .4, 1); }
.badge { display: inline-block; background: var(--gold); color: #4a3500; font-weight: 800; border-radius: 999px; padding: 7px 14px; animation: wiggle 2.4s ease-in-out infinite; }
@keyframes wiggle { 0%, 90%, 100% { transform: rotate(0); } 93% { transform: rotate(-4deg); } 96% { transform: rotate(4deg); } }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: .75rem; opacity: .85; }
.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #7CFC9A; box-shadow: 0 0 0 0 #7CFC9A; animation: live 1.8s infinite; }
.live.off::before { background: #ccc; animation: none; }
@keyframes live { 70% { box-shadow: 0 0 0 7px rgba(124,252,154,0); } }

/* Popup "+1" */
.plus {
  position: fixed; left: 50%; top: 38%; transform: translate(-50%, -50%); z-index: 50; pointer-events: none;
  font-size: 4.5rem; font-weight: 900; color: var(--gold); text-shadow: 0 4px 0 color-mix(in srgb, var(--brand) 70%, #000), 0 10px 24px rgba(0,0,0,.3);
  animation: plus 1.1s ease-out both;
}
@keyframes plus {
  0% { transform: translate(-50%, -20%) scale(.3); opacity: 0; }
  25% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
  70% { transform: translate(-50%, -70%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -110%) scale(.9); opacity: 0; }
}
canvas.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60; }

/* Tessera stile "Wallet": griglia di pizze grandi in primo piano */
.passcard .top strong { font-size: 1.05rem; }
.tiles { grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 18px 4px 14px; }
.tiles .stamp {
  border: 0; background: var(--stamp-off, url(/stamps/pizza-empty.png)) center / contain no-repeat; color: transparent; box-shadow: none;
}
.tiles .stamp.on { background: var(--stamp-on, url(/stamps/pizza.png)) center / contain no-repeat; box-shadow: none; }
.tiles .stamp.new::after { inset: 2px; }
.pass-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; }
.pass-label { font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; opacity: .85; }
.pass-value { font-size: 1.35rem; font-weight: 800; }
.pass-foot {
  display: flex; justify-content: space-between; gap: 10px; margin-top: 12px; padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,.3); font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
}
.pass-foot span:last-child { font-weight: 500; text-transform: none; letter-spacing: 0; opacity: .9; }
.msg { border-left: 4px solid var(--brand); padding: 6px 0 6px 12px; }
.msg + .msg { margin-top: 12px; }

/* Salva la tessera sul telefono */
.install {
  background: #fff; border-radius: 20px; padding: 16px; display: grid; gap: 12px;
  border: 2px solid color-mix(in srgb, var(--brand) 25%, #fff); box-shadow: 0 8px 24px rgba(60, 30, 10, .08);
}
.install-row { display: flex; gap: 12px; align-items: center; }
.install-ico { width: 52px; height: 52px; border-radius: 14px; flex: none; box-shadow: 0 3px 8px rgba(0,0,0,.2); }
.install-later { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; justify-self: center; font: inherit; }
.overlay { position: fixed; inset: 0; z-index: 80; background: rgba(20, 10, 5, .55); display: flex; align-items: flex-end; justify-content: center; padding: 16px 16px 90px; }
.sheet-panel { background: #fff; border-radius: 22px; padding: 22px; width: 100%; max-width: 440px; box-shadow: 0 20px 50px rgba(0,0,0,.35); animation: sheetUp .3s ease-out both; }
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.steps { margin: 0; padding-left: 22px; line-height: 1.7; font-size: 1.02rem; }
.steps li + li { margin-top: 8px; }
.sheet-arrow { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); font-size: 2.6rem; animation: arrowBob 1s ease-in-out infinite; }
@keyframes arrowBob { 50% { transform: translate(-50%, 10px); } }

/* ---------- Dashboard ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.kpi { background: #fff; border-radius: 16px; padding: 14px 16px; box-shadow: 0 4px 14px rgba(60,30,10,.05); }
.kpi b { display: block; font-size: 1.8rem; }
.kpi span { color: var(--muted); font-size: .85rem; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; }
.scroll { overflow-x: auto; }
.grid2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
@media (max-width: 800px) { .grid2 { grid-template-columns: 1fr; } }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: #fff;
  padding: 13px 20px; border-radius: 14px; font-weight: 700; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none;
  max-width: calc(100% - 32px); text-align: center; z-index: 70; box-shadow: 0 10px 24px rgba(0,0,0,.25);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.hidden { display: none !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
