:root {
  --yellow: #ffbc0d;
  --red: #db0007;
  --ink: #292929;
  --muted: #6b6b6b;
  --paper: #fff8e6;
  --line: #e8dfc6;
  --ok: #1f8a4c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
}

.screen { display: none; }
.screen.is-active { display: block; }

.hero h1 {
  font-size: 28px;
  line-height: 1.15;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}
.hero p { margin: 0 0 24px; color: var(--muted); line-height: 1.5; }

/* Calendario */
.calendar {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
}
.calendar-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.calendar-head strong { font-size: 16px; text-transform: capitalize; }
.nav {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--line); background: #fff;
  font-size: 20px; line-height: 1; cursor: pointer;
}
.nav:disabled { opacity: .3; cursor: default; }

.calendar-weekdays, .calendar-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
}
.calendar-weekdays span {
  text-align: center; font-size: 12px; color: var(--muted); padding-bottom: 4px;
}
.day {
  aspect-ratio: 1; border-radius: 10px; border: 0;
  background: transparent; font: inherit; font-size: 15px;
  color: var(--ink); cursor: pointer;
}
.day.is-empty { visibility: hidden; }
.day.is-out { color: #c9c2ad; cursor: default; }
.day.is-in { background: #fff3cc; }
.day.is-in:hover { background: #ffe8a3; }
.day.is-selected { background: var(--yellow); font-weight: 600; }
.day:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

.cta-bar { display: grid; gap: 10px; margin-top: 20px; }
.selection { margin: 0; text-align: center; color: var(--muted); font-size: 14px; }

.btn {
  width: 100%; padding: 16px; border: 0; border-radius: 999px;
  background: var(--red); color: #fff; font: inherit; font-size: 16px; font-weight: 600;
  cursor: pointer;
}
.btn:disabled { background: #d9c99c; cursor: default; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }

.status { text-align: center; font-size: 13px; color: var(--muted); margin-top: 16px; }
.status.is-ready { color: var(--ok); }
.status.is-error { color: var(--red); }

/* Camera */
.camera-wrap {
  position: relative; width: 100%; aspect-ratio: 3 / 4;
  border-radius: 20px; overflow: hidden; background: #111;
}
#video, #overlay {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; transform: scaleX(-1); /* specchio, come un selfie */
}
.ring {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  width: 72px; height: 72px; border-radius: 50%;
  background: conic-gradient(var(--yellow) calc(var(--p) * 1%), rgba(255,255,255,.25) 0);
  display: grid; place-items: center;
}
.ring::before {
  content: ""; position: absolute; inset: 6px; border-radius: 50%; background: rgba(0,0,0,.55);
}
.ring span { position: relative; color: #fff; font-weight: 600; font-size: 14px; }
.ring.is-done { background: var(--ok); }

.hint {
  margin: 16px 0 0; min-height: 3em; text-align: center; line-height: 1.5; font-size: 16px;
}
.fallback { margin-top: 16px; text-align: center; color: var(--red); }

/* Successo */
.offer-card {
  background: var(--yellow); border-radius: 20px; padding: 28px 20px; text-align: center;
}
.offer-day { margin: 0; font-size: 22px; font-weight: 700; text-transform: capitalize; }
.offer-id { margin: 8px 0 0; font-size: 13px; color: #5a4300; }

@media (prefers-reduced-motion: no-preference) {
  .ring { transition: background .15s linear; }
}
