/* Spritz Counter — grafica cartoon: contorni spessi, ombre piene, colori aperitivo. */

:root {
  --ink: #2a1712;
  --cream: #ffe8c7;
  --paper: #fff8ec;
  --orange: #ff6a1f;
  --orange-2: #ff9a3c;
  --lemon: #ffd23f;
  --mint: #33c48d;
  --pink: #ff7aa2;
  --sky: #7ec8f5;
  --grape: #9b7bff;
  --muted: #7a5a4a;
  --line: 3px solid var(--ink);
  --shadow: 4px 4px 0 var(--ink);
  --shadow-lg: 6px 6px 0 var(--ink);
  --r: 22px;
  --display: "Lilita One", "Arial Rounded MT Bold", system-ui, sans-serif;
  --body: "Nunito", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: var(--body);
  font-weight: 700;
  color: var(--ink);
  background-color: var(--cream);
  background-image: radial-gradient(rgba(255, 106, 31, 0.16) 2.2px, transparent 2.6px);
  background-size: 22px 22px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; }

h1, h2, h3, .display { font-family: var(--display); font-weight: 400; letter-spacing: 0.3px; margin: 0; }

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 120px);
  position: relative;
}

.boot { display: grid; place-items: center; min-height: 70dvh; }
.boot-dot {
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--orange); border: var(--line); box-shadow: var(--shadow);
  animation: boing 0.7s ease-in-out infinite alternate;
}
@keyframes boing { to { transform: translateY(-18px) scale(0.92, 1.08); } }

/* ───────── superfici e pulsanti ───────── */

.card {
  background: var(--paper);
  border: var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 54px; padding: 0 22px;
  border: var(--line); border-radius: 999px;
  background: var(--paper); box-shadow: var(--shadow);
  font-family: var(--display); font-size: 20px; letter-spacing: 0.4px;
  text-decoration: none; color: var(--ink);
  transition: transform 0.12s cubic-bezier(.3,.7,.4,1.5), box-shadow 0.12s;
  user-select: none;
}
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.btn:disabled { opacity: 0.45; pointer-events: none; }
.btn-orange { background: var(--orange); color: #fff; text-shadow: 2px 2px 0 var(--ink); }
.btn-mint { background: var(--mint); color: #fff; text-shadow: 2px 2px 0 var(--ink); }
.btn-lemon { background: var(--lemon); }
.btn-pink { background: var(--pink); color: #fff; text-shadow: 2px 2px 0 var(--ink); }
.btn-block { width: 100%; }

.icon-btn {
  width: 46px; height: 46px; border-radius: 50%;
  border: var(--line); background: var(--paper); box-shadow: 3px 3px 0 var(--ink);
  display: grid; place-items: center; font-size: 20px; padding: 0;
  transition: transform 0.12s;
}
.icon-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }

.field {
  width: 100%; min-height: 54px; padding: 0 18px;
  border: var(--line); border-radius: 16px; background: #fff;
  font-weight: 800; font-size: 18px; outline: none;
  box-shadow: inset 3px 3px 0 rgba(42, 23, 18, 0.08);
}
.field:focus { box-shadow: 0 0 0 4px var(--lemon); }
.field::placeholder { color: #b39a8c; }

.stack { display: grid; gap: 14px; }

/* ───────── barra in alto ───────── */

.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.topbar .logo { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.topbar .logo svg { width: 40px; height: 52px; flex: none; }
.topbar .logo span { font-family: var(--display); font-size: 26px; line-height: 1; }
.topbar .logo span b { color: var(--orange); font-weight: 400; -webkit-text-stroke: 1px var(--ink); }
.me-btn { padding: 0; overflow: hidden; }
.me-btn img { width: 100%; height: 100%; object-fit: cover; }

.title-row { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.title-row h1 { font-size: 26px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ───────── login ───────── */

.login { display: grid; justify-items: center; text-align: center; padding-top: 4dvh; gap: 12px; }
.login .hero-glass { width: 210px; margin: 6px 0 -6px; }
.login h1 { font-size: 46px; line-height: 0.95; }
.login h1 b { color: var(--orange); font-weight: 400; display: block; font-size: 58px; -webkit-text-stroke: 1.5px var(--ink); text-shadow: 4px 4px 0 var(--ink); }
.login .tagline { font-size: 18px; max-width: 300px; margin: 6px 0 14px; line-height: 1.35; }
.google-btn { background: #fff; font-family: var(--body); font-weight: 900; font-size: 18px; min-height: 60px; padding: 0 26px; }
.google-btn svg { width: 24px; height: 24px; }
.login .steps { display: grid; gap: 10px; margin-top: 26px; width: 100%; text-align: left; }
.login .step { display: flex; align-items: center; gap: 12px; padding: 12px 14px; font-size: 15px; line-height: 1.3; }
.login .step .n {
  flex: none; width: 34px; height: 34px; border-radius: 50%; border: var(--line);
  display: grid; place-items: center; font-family: var(--display); font-size: 18px;
}
.fineprint { font-size: 12px; color: var(--muted); margin-top: 20px; font-weight: 700; }
.fineprint a { color: inherit; }

/* ───────── riepilogo ───────── */

.summary { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 22px; }
.sum {
  padding: 14px 14px 12px; position: relative; overflow: hidden;
  display: grid; gap: 2px;
}
.sum .k { font-size: 13px; text-transform: uppercase; letter-spacing: 0.8px; }
.sum .v { font-family: var(--display); font-size: 44px; line-height: 1; display: flex; align-items: baseline; gap: 6px; }
.sum .v small { font-size: 16px; font-family: var(--body); font-weight: 900; }
.sum.owe { background: var(--orange); color: #fff; }
.sum.owe .v { text-shadow: 3px 3px 0 var(--ink); }
.sum.owed { background: var(--mint); color: #fff; }
.sum.owed .v { text-shadow: 3px 3px 0 var(--ink); }
.sum .deco { position: absolute; right: -8px; top: -6px; font-size: 40px; transform: rotate(14deg); }

.section-h { display: flex; align-items: center; justify-content: space-between; margin: 0 4px 12px; }
.section-h h2 { font-size: 22px; }
.section-h span { font-size: 14px; color: var(--muted); }

/* ───────── lista amici ───────── */

.friends { display: grid; gap: 12px; }
.friend {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  text-align: left; width: 100%; color: inherit; text-decoration: none;
  transition: transform 0.12s cubic-bezier(.3,.7,.4,1.5), box-shadow 0.12s;
}
.friend:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.friend .who { flex: 1; min-width: 0; }
.friend .name { font-family: var(--display); font-size: 21px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.friend .sub { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }

.avatar {
  flex: none; width: 54px; height: 54px; border-radius: 18px; border: var(--line);
  display: grid; place-items: center; font-size: 30px; box-shadow: 3px 3px 0 var(--ink);
  position: relative;
}
.avatar.big { width: 76px; height: 76px; font-size: 44px; border-radius: 24px; }
.avatar .pic {
  position: absolute; right: -8px; bottom: -8px; width: 26px; height: 26px; border-radius: 50%;
  border: 2.5px solid var(--ink); overflow: hidden; background: #fff;
}
.avatar .pic img { width: 100%; height: 100%; object-fit: cover; }

.pill {
  flex: none; display: grid; justify-items: center; min-width: 64px; padding: 6px 10px 5px;
  border: var(--line); border-radius: 16px; box-shadow: 3px 3px 0 var(--ink);
  line-height: 1;
}
.pill b { font-family: var(--display); font-weight: 400; font-size: 26px; }
.pill i { font-style: normal; font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }
.pill.owe { background: var(--orange); color: #fff; }
.pill.owe b { text-shadow: 2px 2px 0 var(--ink); }
.pill.owed { background: var(--mint); color: #fff; }
.pill.owed b { text-shadow: 2px 2px 0 var(--ink); }
.pill.even { background: var(--lemon); }

.linked-tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 99px;
  background: var(--sky); border: 2px solid var(--ink); color: var(--ink); font-size: 11px; font-weight: 900;
}

.empty { text-align: center; padding: 26px 18px 22px; display: grid; justify-items: center; gap: 8px; }
.empty svg { width: 120px; }
.empty h3 { font-size: 24px; }
.empty p { margin: 0; color: var(--muted); max-width: 260px; }

.fab {
  position: fixed; z-index: 20;
  left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 22px);
  min-height: 64px; padding: 0 28px; font-size: 22px; box-shadow: var(--shadow-lg);
}
.fab:active { transform: translate(calc(-50% + 3px), 3px); }

/* ───────── dettaglio conto ───────── */

.stage { position: relative; display: grid; justify-items: center; margin: 4px 0 10px; }
.stage .mascot { width: 190px; }
.bubble {
  position: relative; margin: 0 6px 14px; padding: 14px 18px; text-align: center;
  background: #fff; border: var(--line); border-radius: 26px; box-shadow: var(--shadow);
  font-size: 17px; line-height: 1.3; max-width: 340px;
}
.bubble::after {
  content: ""; position: absolute; left: 50%; bottom: -14px; width: 22px; height: 22px;
  background: #fff; border-right: var(--line); border-bottom: var(--line);
  transform: translateX(-50%) rotate(45deg); border-bottom-right-radius: 4px;
}
.bubble .count { font-family: var(--display); font-size: 64px; line-height: 0.95; display: block; }
.bubble .count.owe { color: var(--orange); text-shadow: 3px 3px 0 var(--ink); -webkit-text-stroke: 1.5px var(--ink); }
.bubble .count.owed { color: var(--mint); text-shadow: 3px 3px 0 var(--ink); -webkit-text-stroke: 1.5px var(--ink); }
.bubble .count.even { color: var(--lemon); text-shadow: 3px 3px 0 var(--ink); -webkit-text-stroke: 1.5px var(--ink); }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 8px 0 18px; }
.act {
  display: grid; justify-items: center; gap: 2px; padding: 12px 8px 10px;
  border: var(--line); border-radius: var(--r); box-shadow: var(--shadow);
  transition: transform 0.12s cubic-bezier(.3,.7,.4,1.5), box-shadow 0.12s;
  text-align: center;
}
.act:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.act:disabled { opacity: 0.45; pointer-events: none; }
.act .e { font-size: 30px; line-height: 1.1; }
.act .t { font-family: var(--display); font-size: 21px; line-height: 1.05; }
.act .s { font-size: 12px; font-weight: 800; opacity: 0.9; }
.act.owe { background: var(--orange); color: #fff; }
.act.owe .t { text-shadow: 2px 2px 0 var(--ink); }
.act.owed { background: var(--mint); color: #fff; }
.act.owed .t { text-shadow: 2px 2px 0 var(--ink); }
.act.drink { grid-column: 1 / -1; background: var(--lemon); grid-template-columns: auto 1fr; justify-items: start; align-items: center; column-gap: 14px; padding: 12px 18px; text-align: left; }
.act.drink .e { font-size: 38px; grid-row: span 2; }

.invite { padding: 14px 16px; display: flex; gap: 12px; align-items: center; margin-bottom: 18px; background: var(--sky); }
.invite p { margin: 0; flex: 1; font-size: 14px; line-height: 1.3; }
.invite p b { font-family: var(--display); font-weight: 400; font-size: 18px; display: block; }
.invite .btn { min-height: 46px; padding: 0 16px; font-size: 17px; flex: none; }

.history { padding: 6px 0; }
.history h2 { font-size: 20px; padding: 10px 16px 4px; }
.entry { display: flex; gap: 12px; align-items: center; padding: 10px 16px; border-top: 2px dashed rgba(42, 23, 18, 0.15); }
.entry:first-of-type { border-top: 0; }
.entry .ico {
  flex: none; width: 38px; height: 38px; border-radius: 12px; border: 2.5px solid var(--ink);
  display: grid; place-items: center; font-size: 19px;
}
.entry .txt { flex: 1; min-width: 0; font-size: 15px; line-height: 1.25; }
.entry .txt small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.entry .txt .note { font-weight: 800; color: var(--ink); font-style: italic; }
.entry .undo { width: 34px; height: 34px; border-radius: 50%; border: 2.5px solid var(--ink); background: #fff; font-size: 14px; padding: 0; flex: none; }
.history .none { padding: 12px 16px 16px; color: var(--muted); }

/* ───────── fogli (bottom sheet) ───────── */

.scrim {
  position: fixed; inset: 0; z-index: 50; background: rgba(42, 23, 18, 0.45);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade 0.18s ease-out;
}
.scrim.out { animation: fade 0.16s ease-in reverse forwards; }
.sheet {
  width: 100%; max-width: 480px; background: var(--paper);
  border: var(--line); border-bottom: 0; border-radius: 30px 30px 0 0;
  padding: 10px 18px calc(env(safe-area-inset-bottom) + 20px);
  box-shadow: 0 -4px 0 var(--ink);
  animation: slideUp 0.32s cubic-bezier(.2,.9,.3,1.15);
  max-height: 92dvh; overflow-y: auto;
}
.scrim.out .sheet { animation: slideDown 0.18s ease-in forwards; }
.sheet .grab { width: 54px; height: 6px; border-radius: 9px; background: var(--ink); opacity: 0.25; margin: 0 auto 12px; }
.sheet h2 { font-size: 28px; margin-bottom: 4px; }
.sheet .lead { margin: 0 0 16px; color: var(--muted); }
@keyframes fade { from { opacity: 0; } }
@keyframes slideUp { from { transform: translateY(100%); } }
@keyframes slideDown { to { transform: translateY(100%); } }

body.plain { display: grid; place-items: center; min-height: 100dvh; padding: 16px; }
body.plain .sheet { border: var(--line); border-radius: 30px; box-shadow: var(--shadow-lg); animation: none; padding: 24px; display: grid; gap: 14px; }
body.plain .sheet p { margin: 0; }

.avatars { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.avatars button {
  aspect-ratio: 1; border: var(--line); border-radius: 16px; background: #fff; font-size: 28px; padding: 0;
  transition: transform 0.12s cubic-bezier(.3,.7,.4,1.5);
}
.avatars button[aria-pressed="true"] { background: var(--lemon); box-shadow: 3px 3px 0 var(--ink); transform: translate(-2px, -2px) rotate(-4deg); }

.stepper { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 4px 0 16px; }
.stepper .icon-btn { width: 58px; height: 58px; font-family: var(--display); font-size: 30px; }
.stepper .num { min-width: 110px; text-align: center; }
.stepper .num b { font-family: var(--display); font-weight: 400; font-size: 72px; line-height: 1; display: block; -webkit-text-stroke: 1.5px var(--ink); text-shadow: 4px 4px 0 var(--ink); }
.stepper .num i { font-style: normal; font-size: 14px; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: -4px 0 4px; }
.chip {
  border: 2.5px solid var(--ink); border-radius: 99px; background: #fff; padding: 6px 12px; font-size: 14px; font-weight: 800;
}
.chip:active { background: var(--lemon); }

.menu-list { display: grid; gap: 10px; }
.menu-list .btn { justify-content: flex-start; font-family: var(--body); font-weight: 900; font-size: 17px; }
.menu-list .danger { color: #d1342f; }

.me-card { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.me-card img, .me-card .ph { width: 54px; height: 54px; border-radius: 50%; border: var(--line); object-fit: cover; }
.me-card .ph { display: grid; place-items: center; background: var(--lemon); font-family: var(--display); font-size: 24px; }
.me-card b { display: block; font-family: var(--display); font-weight: 400; font-size: 22px; }
.me-card span { font-size: 13px; color: var(--muted); word-break: break-all; }

/* ───────── invito ───────── */

.invite-page { text-align: center; display: grid; justify-items: center; gap: 14px; padding-top: 4dvh; }
.invite-page .from { width: 92px; height: 92px; border-radius: 50%; border: var(--line); box-shadow: var(--shadow); object-fit: cover; background: var(--lemon); display: grid; place-items: center; font-family: var(--display); font-size: 40px; }
.invite-page h1 { font-size: 34px; line-height: 1.05; }
.invite-page .card { padding: 16px; width: 100%; }

/* ───────── toast ed effetti ───────── */

.toast {
  position: fixed; z-index: 80; left: 50%; top: calc(env(safe-area-inset-top) + 14px);
  transform: translateX(-50%);
  background: var(--ink); color: #fff; border-radius: 99px; padding: 12px 20px;
  font-weight: 900; font-size: 16px; box-shadow: 4px 4px 0 var(--orange);
  animation: toastIn 0.35s cubic-bezier(.2,.9,.3,1.4); white-space: nowrap; max-width: calc(100vw - 32px);
  overflow: hidden; text-overflow: ellipsis;
}
.toast.out { animation: toastOut 0.25s ease-in forwards; }
@keyframes toastIn { from { transform: translate(-50%, -140%) rotate(-6deg); } }
@keyframes toastOut { to { transform: translate(-50%, -160%); opacity: 0; } }

#fx { position: fixed; inset: 0; pointer-events: none; z-index: 90; overflow: hidden; }
.particle { position: absolute; left: 0; top: 0; font-size: 26px; will-change: transform, opacity; }
.particle.dot { width: 14px; height: 14px; border-radius: 50%; border: 2.5px solid var(--ink); }

.cheers {
  position: fixed; z-index: 85; left: 50%; top: 38%; transform: translate(-50%, -50%);
  font-family: var(--display); font-size: 64px; color: var(--lemon); white-space: nowrap;
  -webkit-text-stroke: 2px var(--ink); text-shadow: 5px 5px 0 var(--ink);
  pointer-events: none;
  animation: cheers 1.3s cubic-bezier(.2,.9,.3,1.3) forwards;
}
@keyframes cheers {
  0% { transform: translate(-50%, -50%) scale(0.2) rotate(-20deg); opacity: 0; }
  25% { transform: translate(-50%, -50%) scale(1.15) rotate(6deg); opacity: 1; }
  40% { transform: translate(-50%, -50%) scale(1) rotate(-3deg); }
  80% { opacity: 1; }
  100% { transform: translate(-50%, -80%) scale(0.9) rotate(0); opacity: 0; }
}

/* ───────── mascotte ───────── */

.mascot { overflow: visible; }
.mascot .body { animation: bob 3.2s ease-in-out infinite; transform-origin: 100px 230px; }
.mascot .bub { animation: rise 2.6s ease-in infinite; transform-box: fill-box; transform-origin: center; }
.mascot .bub:nth-of-type(2) { animation-delay: 0.7s; animation-duration: 2.2s; }
.mascot .bub:nth-of-type(3) { animation-delay: 1.4s; animation-duration: 3s; }
.mascot .bub:nth-of-type(4) { animation-delay: 0.3s; animation-duration: 2.8s; }
.mascot .blink { animation: blink 4.5s infinite; transform-box: fill-box; transform-origin: center; }
.mascot .sweat { animation: sweat 1.6s ease-in infinite; }
.mascot.wiggle .body { animation: wiggle 0.6s cubic-bezier(.3,.7,.4,1.5); }
.mascot .liquid { transition: transform 0.7s cubic-bezier(.3,.8,.3,1.25); }

@keyframes bob { 50% { transform: translateY(-6px) rotate(1.5deg); } }
@keyframes rise {
  0% { transform: translateY(0) scale(0.6); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translateY(-80px) scale(1.1); opacity: 0; }
}
@keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(0.1); } }
@keyframes sweat { 0% { transform: translateY(0); opacity: 0; } 30% { opacity: 1; } 100% { transform: translateY(16px); opacity: 0; } }
@keyframes wiggle {
  0% { transform: rotate(0); }
  25% { transform: rotate(-9deg) scale(1.06); }
  50% { transform: rotate(7deg) scale(0.97); }
  75% { transform: rotate(-3deg); }
  100% { transform: rotate(0); }
}

.page-in { animation: pageIn 0.28s cubic-bezier(.2,.8,.3,1.1); }
@keyframes pageIn { from { opacity: 0; transform: translateY(12px); } }

.pop { animation: pop 0.45s cubic-bezier(.3,.7,.4,1.6); }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.25) rotate(-4deg); } 100% { transform: scale(1); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
