/* ═══════════════════════════════════════════════════════════
   S'Agapò Club — design system
   Palette brand (spec §2.1) · Poppins · tono caldo e giocoso
   ═══════════════════════════════════════════════════════════ */
@font-face { font-family: 'Poppins'; font-weight: 400; font-display: swap; src: url('../fonts/poppins-400.woff2') format('woff2'); }
@font-face { font-family: 'Poppins'; font-weight: 600; font-display: swap; src: url('../fonts/poppins-600.woff2') format('woff2'); }
@font-face { font-family: 'Poppins'; font-weight: 700; font-display: swap; src: url('../fonts/poppins-700.woff2') format('woff2'); }
@font-face { font-family: 'Poppins'; font-weight: 800; font-display: swap; src: url('../fonts/poppins-800.woff2') format('woff2'); }

:root {
  --ink: #15121A;
  --paper: #FBFAF8;
  --magenta: #FF2E7E;
  --yellow: #FFCB2D;
  --cyan: #25CBE0;
  --green: #2FD27A;
  --lav: #B79CFF;
  --orange: #FF7A3D;
  --points: #c81e63;     /* S'Agapoints */
  --cuori: #7a4fd6;      /* Cuori */
  --ink-60: rgba(21, 18, 26, .6);
  --ink-40: rgba(21, 18, 26, .4);
  --ink-08: rgba(21, 18, 26, .08);
  --card: #ffffff;
  --radius: 22px;
  --shadow: 0 6px 24px rgba(21, 18, 26, .08);
  --shadow-pop: 0 10px 32px rgba(255, 46, 126, .28);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body {
  font-family: 'Poppins', system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button { font-family: inherit; border: none; cursor: pointer; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: 1rem; }
a { color: var(--magenta); text-decoration: none; }
h1, h2, h3 { line-height: 1.15; letter-spacing: -.02em; }

/* ---------- layout app ---------- */
#app { max-width: 480px; margin: 0 auto; padding: 0 18px calc(110px + var(--safe-b)); min-height: 100dvh; }
.screen { animation: rise .28s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.06); } 100% { transform: scale(1); opacity: 1; } }
@keyframes floaty { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes shimmer { to { background-position: 200% center; } }

/* ---------- header wallet ---------- */
.wallet-bar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 0 10px;
  background: linear-gradient(var(--paper) 78%, transparent);
}
.wb-mark { height: 32px; width: auto; flex: 0 0 auto; cursor: pointer; }
.wb-pills { display: flex; gap: 8px; min-width: 0; }
@media (max-width: 380px) {
  .wb-pills .tiny { display: none; }   /* su schermi stretti tengo solo i numeri */
  .wb-mark { height: 28px; }
}
.pill {
  display: flex; align-items: center; gap: 7px;
  background: var(--card); border-radius: 999px;
  padding: 8px 15px; font-weight: 700; font-size: .95rem;
  box-shadow: var(--shadow);
}
.pill .ico { font-size: 1.05rem; }
.pill.points { color: var(--points); }
.pill.cuori  { color: var(--cuori); }

/* ---------- marchio S'Agapò (cuore+tilde e wordmark) ---------- */
.brand-mark { width: 92px; height: auto; display: block; margin: 0 auto 14px;
  filter: drop-shadow(0 8px 18px rgba(255,193,45,.35)); }
.brand-word { width: 210px; max-width: 66%; height: auto; display: block; margin: 0 auto; }
.ean-word { width: 150px; height: auto; display: block; margin: 0 auto 16px; }

/* ---------- cards ---------- */
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.card.hero {
  color: #fff; position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--ink) 0%, #2a1f3d 55%, #4a2560 100%);
}
.card.hero::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle at 85% 15%, rgba(255,46,126,.35), transparent 50%),
              radial-gradient(circle at 10% 90%, rgba(183,156,255,.25), transparent 45%);
}
.card.hero > * { position: relative; z-index: 1; }

.level-chip {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px; padding: 5px 14px;
  font-weight: 800; font-size: .85rem; letter-spacing: .04em; text-transform: uppercase;
  background: rgba(255,255,255,.14); backdrop-filter: blur(4px);
}
.progress-track {
  height: 12px; border-radius: 999px; background: rgba(255,255,255,.16);
  overflow: hidden; margin: 12px 0 6px;
}
.progress-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--magenta), var(--lav), var(--magenta));
  background-size: 200% auto; animation: shimmer 3.2s linear infinite;
  transition: width .8s cubic-bezier(.2,.9,.3,1.2);
}

/* ---------- buttons ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 15px 20px; border-radius: 18px;
  font-weight: 700; font-size: 1rem; transition: transform .12s, box-shadow .12s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--magenta); color: #fff; box-shadow: var(--shadow-pop); }
.btn.dark    { background: var(--ink); color: #fff; }
.btn.ghost   { background: var(--ink-08); color: var(--ink); }
.btn.small   { width: auto; padding: 9px 16px; font-size: .88rem; border-radius: 13px; }
.btn:disabled { opacity: .45; pointer-events: none; }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: flex; justify-content: center;
}
.tabbar-inner {
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
  width: min(480px, 100%); margin: 0 12px calc(12px + var(--safe-b));
  background: var(--ink); border-radius: 26px; padding: 10px 8px;
  box-shadow: 0 12px 36px rgba(21,18,26,.35);
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: rgba(255,255,255,.55); font-size: .62rem; font-weight: 600;
  padding: 4px 0; border-radius: 14px; transition: color .15s;
}
.tab .t-ico { font-size: 1.35rem; line-height: 1; }
.tab.active { color: #fff; }
.tab.center {
  margin-top: -34px;
}
.tab.center .t-ean {
  width: 62px; height: 62px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--magenta), var(--orange));
  box-shadow: 0 8px 22px rgba(255,46,126,.45), 0 0 0 5px var(--paper);
  font-size: 1.6rem; animation: floaty 3.4s ease-in-out infinite;
}

/* ---------- tessera EAN ---------- */
.ean-card {
  background: #fff; border-radius: 26px; padding: 26px 20px;
  box-shadow: var(--shadow); text-align: center;
}
.ean-card svg.barcode { width: 100%; max-width: 320px; height: 110px; }
.ean-digits { font-variant-numeric: tabular-nums; letter-spacing: .18em; font-weight: 700; color: var(--ink-60); font-size: .95rem; }
.qr-wrap { display: flex; justify-content: center; margin-top: 18px; }
.qr-wrap img, .qr-wrap canvas { width: 132px; height: 132px; image-rendering: pixelated; }

/* ---------- liste ---------- */
.row-item {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border-radius: 18px; padding: 14px 16px;
  box-shadow: var(--shadow); margin-bottom: 10px;
}
.row-item .emoji {
  width: 46px; height: 46px; border-radius: 14px; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.45rem; background: var(--ink-08);
}
.row-item .grow { flex: 1; min-width: 0; }
.row-item h4 { font-size: .95rem; font-weight: 700; }
.row-item p { font-size: .8rem; color: var(--ink-60); margin-top: 1px; }
.chips { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.chip {
  font-size: .72rem; font-weight: 700; border-radius: 999px; padding: 3px 10px;
}
.chip.points { background: rgba(200,30,99,.1); color: var(--points); }
.chip.cuori  { background: rgba(122,79,214,.12); color: var(--cuori); }
.chip.done   { background: rgba(47,210,122,.15); color: #1d9d5a; }
.chip.lock   { background: var(--ink-08); color: var(--ink-40); }

/* ---------- timeline livelli ---------- */
.lvl-item { display: flex; gap: 16px; position: relative; padding-bottom: 26px; }
.lvl-item::before {
  content: ''; position: absolute; left: 24px; top: 52px; bottom: 0;
  width: 3px; border-radius: 3px; background: var(--ink-08);
}
.lvl-item:last-child::before { display: none; }
.lvl-item.reached::before { background: linear-gradient(var(--magenta), var(--lav)); }
.lvl-dot {
  width: 50px; height: 50px; border-radius: 50%; flex: none; z-index: 1;
  display: flex; align-items: center; justify-content: center; font-size: 1.4rem;
  background: var(--card); box-shadow: var(--shadow);
}
.lvl-item.current .lvl-dot { outline: 3px solid var(--magenta); animation: pop .5s ease both; }
.lvl-body { flex: 1; }
.lvl-body ul { list-style: none; margin-top: 6px; }
.lvl-body li { font-size: .82rem; color: var(--ink-60); padding: 2px 0 2px 20px; position: relative; }
.lvl-body li::before { content: '♥'; position: absolute; left: 0; color: var(--lav); font-size: .75rem; }
.lvl-item.locked { opacity: .55; filter: grayscale(.4); }

/* ---------- forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .82rem; font-weight: 700; margin-bottom: 6px; color: var(--ink-60); }
.field input[type=text], .field input[type=email], .field input[type=tel],
.field input[type=date], .field input[type=number], .field input[type=password], .field select, .field textarea {
  width: 100%; padding: 14px 16px; border-radius: 15px; border: 2px solid var(--ink-08);
  background: var(--card); font-size: 1rem; outline: none; transition: border-color .15s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--magenta); }
.check {
  display: flex; gap: 11px; align-items: flex-start; padding: 12px 14px;
  background: var(--card); border-radius: 15px; border: 2px solid var(--ink-08);
  margin-bottom: 10px; font-size: .84rem; cursor: pointer;
}
.check input { width: 20px; height: 20px; margin-top: 1px; accent-color: var(--magenta); flex: none; }
.check .bonus { color: var(--points); font-weight: 700; }
.otp-row { display: flex; gap: 8px; justify-content: center; }
.otp-row input {
  width: 46px; height: 58px; text-align: center; font-size: 1.5rem; font-weight: 700;
  border: 2px solid var(--ink-08); border-radius: 14px; background: var(--card); outline: none;
}
.otp-row input:focus { border-color: var(--magenta); }

/* ---------- toast & modali ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(120px + var(--safe-b)); transform: translateX(-50%);
  background: var(--ink); color: #fff; border-radius: 999px; padding: 11px 22px;
  font-size: .88rem; font-weight: 600; z-index: 90; box-shadow: 0 10px 30px rgba(0,0,0,.3);
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; text-align: center;
  max-width: 88vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(21,18,26,.55); z-index: 60;
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadein .2s ease both;
}
@keyframes fadein { from { opacity: 0; } }
.sheet {
  width: min(480px, 100%); background: var(--paper);
  border-radius: 28px 28px 0 0; padding: 26px 22px calc(26px + var(--safe-b));
  animation: rise .3s ease both; max-height: 86dvh; overflow-y: auto;
}
.sheet h3 { font-size: 1.25rem; margin-bottom: 8px; }
.sheet .lead { color: var(--ink-60); font-size: .9rem; margin-bottom: 18px; }

/* ---------- celebrazione ---------- */
.celebrate {
  position: fixed; inset: 0; z-index: 80; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; padding: 30px;
  background: linear-gradient(160deg, var(--magenta), #d61b68 45%, var(--ink) 130%); color: #fff;
}
.celebrate .big { font-size: 4.5rem; animation: pop .6s cubic-bezier(.2,1.4,.4,1) both; }
.celebrate h2 { font-size: 1.8rem; font-weight: 800; margin: 14px 0 8px; }
.celebrate p { opacity: .9; }
.confetti { position: absolute; font-size: 1.5rem; animation: confetti-fall 2.8s linear infinite; top: -8%; }
@keyframes confetti-fall { to { transform: translateY(110vh) rotate(540deg); opacity: .2; } }

/* ---------- varie ---------- */
.section-title { font-size: 1.15rem; font-weight: 800; margin: 22px 0 12px; display: flex; align-items: center; gap: 8px; }
.muted { color: var(--ink-60); font-size: .85rem; }
.tiny { color: var(--ink-40); font-size: .74rem; }
.banner {
  background: linear-gradient(120deg, rgba(255,203,45,.25), rgba(255,122,61,.18));
  border-radius: 16px; padding: 12px 16px; font-size: .84rem; font-weight: 600; margin-bottom: 16px;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.center { text-align: center; }
.spin {
  width: 26px; height: 26px; border-radius: 50%; margin: 30px auto;
  border: 3px solid var(--ink-08); border-top-color: var(--magenta);
  animation: spinning .8s linear infinite;
}
@keyframes spinning { to { transform: rotate(360deg); } }
.collection-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.col-item {
  aspect-ratio: 1; border-radius: 18px; background: var(--card); box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: 1.8rem; text-align: center;
}
.col-item span { font-size: .62rem; font-weight: 600; color: var(--ink-60); padding: 0 4px; }
.col-item.locked { opacity: .4; filter: grayscale(1); }
.col-item.golden { outline: 3px solid var(--yellow); box-shadow: 0 6px 20px rgba(255,203,45,.4); }

/* ---------- Pioggia di gioielli (catch game) ---------- */
/* ---------- mini-giochi a schermo intero ---------- */
.game-fs {
  position: fixed; inset: 0; margin: auto; max-width: 560px; z-index: 300;
  display: flex; flex-direction: column;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 12px calc(env(safe-area-inset-bottom, 0px) + 10px);
  background: #15121A;
}
.game-fs.light { background: #FFFFFF; }
.game-fs .rain-wrap { flex: 1; height: auto; min-height: 0; max-height: none; }
.game-close {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%; border: none; cursor: pointer;
  font-size: 1rem; font-weight: 800; line-height: 1; display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.16); color: #fff;
}
.game-fs.light .game-close { background: rgba(21,18,26,.08); color: var(--ink); }
.game-hint { margin-top: 8px; }
.game-fs:not(.light) .game-hint { color: rgba(255,255,255,.6); }

/* schermata di fine partita (sopra il gioco a schermo intero) */
.game-over {
  position: absolute; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: rgba(21,18,26,.6); backdrop-filter: blur(5px); animation: goFade .25s ease both;
}
@keyframes goFade { from { opacity: 0; } to { opacity: 1; } }
.go-card {
  width: min(88%, 340px); max-height: 90dvh; overflow-y: auto; background: var(--card);
  border-radius: 26px; padding: 30px 24px 24px;
  text-align: center; box-shadow: 0 24px 70px rgba(0,0,0,.4);
  animation: pop .5s cubic-bezier(.2,1.4,.4,1) both;
}
/* classifica settimanale nella card di fine partita */
.go-board {
  margin-top: 18px; padding: 14px 14px 12px; border-radius: 18px;
  background: linear-gradient(180deg, rgba(122,79,214,.07), rgba(122,79,214,.03));
  border: 1px solid rgba(122,79,214,.14); text-align: left;
}
.lb-title { font-size: .78rem; font-weight: 800; color: var(--cuori); text-align: center; margin-bottom: 10px; }
.lb-row {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 10px;
  font-size: .9rem; font-weight: 600;
}
.lb-row + .lb-row { margin-top: 2px; }
.lb-row.me { background: rgba(255,203,45,.22); font-weight: 800; }
.lb-pos { flex: 0 0 auto; width: 26px; text-align: center; font-size: 1.05rem; }
.lb-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-pts { flex: 0 0 auto; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }
.lb-sep { text-align: center; color: var(--ink-40); font-size: .8rem; line-height: .6; margin: 2px 0; }
.lb-empty { font-size: .82rem; color: var(--ink-60); text-align: center; padding: 6px 0; }
.lb-spur {
  margin-top: 10px; padding: 8px 10px; border-radius: 12px; text-align: center;
  font-size: .82rem; font-weight: 700; color: var(--cuori); background: rgba(122,79,214,.1);
}
.lb-spur.record { color: #b8860b; background: rgba(255,203,45,.22); animation: pop .5s .1s both; }
.lb-pb { margin-top: 6px; text-align: center; font-size: .74rem; color: var(--ink-60); }
.go-emoji { font-size: 3.6rem; line-height: 1; animation: pop .6s .08s cubic-bezier(.2,1.4,.4,1) both; }
.go-card h2 { font-size: 1.5rem; font-weight: 800; margin: 8px 0 12px; }
.go-score { font-size: 1rem; color: var(--ink-60); }
.go-score b { display: block; font-size: 2.4rem; color: var(--ink); line-height: 1.1; }
.go-cuori {
  display: inline-block; margin-top: 14px; font-weight: 800; font-size: 1.5rem; color: var(--cuori);
  background: rgba(122,79,214,.12); padding: 8px 22px; border-radius: 999px; animation: pop .5s .18s both;
}
.go-card > p { margin-top: 12px; }
.go-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }

.rain-hud { display: flex; align-items: center; gap: 10px; padding: 12px 2px 8px; }
.rain-hud .rain-score { margin-right: auto; }
.rain-score {
  font-weight: 800; font-size: 1.15rem; color: var(--ink);
  background: rgba(122,79,214,.12); padding: 6px 14px; border-radius: 999px;
}
.rain-lives {
  font-size: 1.15rem; letter-spacing: 2px;
  background: rgba(255,46,126,.10); padding: 6px 12px; border-radius: 999px;
}
.rain-wrap {
  position: relative; width: 100%; height: 68dvh; max-height: 620px;
  border-radius: 24px; overflow: hidden; box-shadow: var(--shadow);
  background: #FFFFFF;
}
.rain-wrap canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.rain-start {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; padding: 24px; color: #fff;
  background: rgba(21,18,26,.6); backdrop-filter: blur(3px);
}
.rain-start .muted { color: rgba(255,255,255,.75); }
.game-logo { height: 24px; width: auto; margin-bottom: 10px; opacity: .95; }

/* ---------- Fusione dei gioielli ---------- */
.fusion-next { display: flex; align-items: center; gap: 6px; font-size: .72rem; font-weight: 700;
  color: var(--ink-40); text-transform: uppercase; letter-spacing: .5px; }
.fusion-next canvas { width: 42px; height: 42px; background: #201830; border-radius: 12px; }
.fusion-wrap { height: 66dvh; }
/* card del pezzo più prezioso composto finora (immagine + collezione + descrizione + prezzo) */
.fusion-hero {
  display: flex; align-items: center; gap: 12px; margin: 10px 4px 0; padding: 10px 12px;
  min-height: 64px; border-radius: 16px;
  background: rgba(255,255,255,.75); border: 1.5px solid rgba(122,79,214,.18);
  box-shadow: 0 6px 18px rgba(60,40,90,.10); backdrop-filter: blur(6px);
  transition: border-color .25s, box-shadow .25s;
}
.fusion-hero.empty { justify-content: center; }
.fusion-hero.top { border-color: var(--magenta); box-shadow: 0 8px 22px rgba(255,46,126,.22); }
.fusion-hero .fh-hint { font-size: .82rem; font-weight: 600; color: var(--ink-40); text-align: center; }
.fusion-hero .fh-img {
  flex: 0 0 auto; width: 52px; height: 52px; object-fit: contain;
  background: #fff; border-radius: 12px; padding: 3px; box-shadow: 0 2px 8px rgba(0,0,0,.14);
}
.fusion-hero .fh-info { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.fusion-hero .fh-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.fusion-hero .fh-coll {
  font-size: .82rem; font-weight: 800; letter-spacing: .02em; color: var(--cuori);
  text-transform: capitalize; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fusion-hero.top .fh-coll { color: var(--magenta); }
.fusion-hero .fh-price { flex: 0 0 auto; font-size: .9rem; font-weight: 800; color: var(--ink); }
.fusion-hero .fh-desc {
  font-size: .72rem; line-height: 1.25; color: var(--ink-60);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* ---------- desktop hint ---------- */
@media (min-width: 720px) {
  body.client-app::before {
    content: "💡 S'Agapò Club è pensata per il telefono: apri questo link dal tuo smartphone";
    display: block; text-align: center; padding: 8px; font-size: .8rem;
    background: var(--yellow); font-weight: 600;
  }
}
