:root {
  color-scheme: light dark;
  --bg: #FBF7F2;
  --surface: #FFFFFF;
  --surface-2: #F4EEE6;
  --text: #1F1A15;
  --muted: #6B6158;
  --line: #E6DDD2;
  --danger: #B42318;
  --success: #1E7A46;
  --brand: #E85D04;
  --on-brand: #1F1A15;
  --radius: 20px;
  --shadow: 0 1px 2px rgb(31 26 21 / .06), 0 8px 24px rgb(31 26 21 / .08);
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16120E;
    --surface: #211B16;
    --surface-2: #2B241E;
    --text: #F5EFE8;
    --muted: #B3A89C;
    --line: #3A3129;
    --danger: #F97066;
    --success: #4ADE80;
    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 8px 24px rgb(0 0 0 / .35);
  }
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 var(--font-body);
  touch-action: manipulation;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -48px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
  z-index: 10;
}
.skip-link:focus-visible { top: 12px; }

.shell {
  flex: 1;
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left));
}

.footer {
  padding: 16px 16px max(16px, env(safe-area-inset-bottom));
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

/* ---------- Encabezado del negocio ---------- */
.brand-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  min-width: 0;
}
.brand-mark {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--brand);
  color: var(--on-brand);
  font: 700 22px/1 var(--font-display);
  overflow: hidden;
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.brand-name {
  margin: 0;
  min-width: 0;
  font: 600 20px/1.2 var(--font-display);
  overflow-wrap: anywhere;
}
.brand-sub { margin: 2px 0 0; font-size: 14px; color: var(--muted); }

/* ---------- Tarjeta ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 20px;
}
.card + .card { margin-top: 16px; }

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 4px;
  font-weight: 600;
  color: var(--success);
}
.status--muted { color: var(--muted); }

h1, h2 { text-wrap: balance; }
/* El título recibe foco al cambiar de vista (lectores de pantalla); no es interactivo */
[tabindex="-1"]:focus { outline: none; }
.title {
  margin: 0 0 6px;
  font: 700 28px/1.15 var(--font-display);
  letter-spacing: -.01em;
}
.lead { margin: 0; color: var(--muted); text-wrap: pretty; }

.count {
  margin: 20px 0 16px;
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}
.count strong { font: 700 56px/1 var(--font-display); }
.count span { color: var(--muted); font-size: 17px; }

.stamps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 10px;
}
.stamp {
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 2px dashed var(--line);
  color: var(--muted);
}
.stamp svg { width: 46%; height: 46%; }
.stamp--on {
  border: 0;
  background: var(--brand);
  color: var(--on-brand);
}
.stamp--new { animation: stamp-in 520ms cubic-bezier(.2, 1.4, .4, 1) both; }

@keyframes stamp-in {
  from { transform: scale(.3) rotate(-25deg); opacity: 0; }
  to { transform: scale(1) rotate(0); opacity: 1; }
}

.reward {
  margin-top: 20px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--surface-2);
}
.reward p { margin: 0; }
.reward strong { display: block; }
.reward--ready {
  background: var(--brand);
  color: var(--on-brand);
}

/* ---------- QR de respaldo ---------- */
.qr {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 16px;
  align-items: center;
}
.qr img {
  width: 112px;
  height: 112px;
  border-radius: 12px;
  background: #fff;
  padding: 4px;
}
.qr h2 { margin: 0 0 4px; font-size: 16px; }
.qr p { margin: 0; font-size: 14px; color: var(--muted); }

/* ---------- Formulario ---------- */
.form { display: grid; gap: 16px; margin-top: 20px; }
.field { display: grid; gap: 6px; }
.field label { font-weight: 500; }
.field .hint { font-size: 13px; color: var(--muted); }
.input {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 17px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.input:hover { border-color: var(--muted); }
.input:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 30%, transparent);
}
.input[aria-invalid="true"] { border-color: var(--danger); }
.error { margin: 0; font-size: 14px; color: var(--danger); }
.error:empty { display: none; }

.check {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 12px;
  align-items: start;
  padding: 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: background-color 150ms ease;
}
.check:hover { background: var(--surface-2); }
.check input {
  width: 22px;
  height: 22px;
  margin: 1px 0 0;
  accent-color: var(--brand);
}
.check input:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 45%, transparent); outline-offset: 2px; }
.check span { font-size: 15px; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 56px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: var(--brand);
  color: var(--on-brand);
  font: 600 17px/1 var(--font-body);
  cursor: pointer;
  transition: transform 120ms ease, filter 150ms ease;
}
.button:hover { filter: brightness(1.06); }
.button:active { transform: scale(.98); }
.button:focus-visible { outline: 3px solid var(--text); outline-offset: 3px; }
.button[disabled] { cursor: progress; filter: saturate(.6); }

/* ---------- Estados ---------- */
.loading {
  min-height: 60dvh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  color: var(--muted);
}
.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--brand);
  animation: spin 800ms linear infinite;
}
.button .spinner { width: 18px; height: 18px; border-width: 2.5px; border-color: currentColor; border-top-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty-icon {
  width: 56px;
  height: 56px;
  margin-bottom: 16px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--muted);
}

.scope-note { margin: 12px 0 0; font-size: 14px; color: var(--muted); }

/* ---------- Dónde vale, visitas y datos ---------- */
#extras > .card { margin-top: 16px; }

/* ---------- Google Wallet: botón oficial (no se recolorea ni deforma) ---------- */
#wallet-slot:not(:empty) { margin-top: 16px; }
.wallet { display: grid; justify-items: center; gap: 10px; text-align: center; }
.wallet-button {
  display: block; width: 100%; max-width: 300px; padding: 0; border: 0; border-radius: 999px;
  background: none; cursor: pointer; transition: transform 120ms ease, opacity 150ms ease;
}
.wallet-button img { display: block; width: 100%; height: auto; }
.wallet-button:active { transform: scale(.98); }
.wallet-button[disabled] { cursor: progress; opacity: .6; }
.wallet-button:focus-visible { outline: 3px solid var(--text); outline-offset: 3px; }
.wallet-hint { margin: 0; font-size: 14px; color: var(--muted); }
.wallet .error { margin: 0; }
@media (prefers-reduced-motion: reduce) { .wallet-button { transition: none; } }
.section-title { margin: 0 0 12px; font: 600 18px/1.3 var(--font-display); }
.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.plain-list li { display: grid; gap: 2px; }
.plain-list li span { font-size: 14px; color: var(--muted); }
.history li { padding-bottom: 10px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.history li:last-child { padding-bottom: 0; border-bottom: 0; }
.history-reward { color: var(--success); }
.hint-line { margin: 8px 0 0; font-size: 14px; color: var(--muted); }
.hint-line:empty { display: none; }
.danger-zone { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); display: grid; gap: 12px; }
.danger-zone p { margin: 0 0 12px; }
.link-button {
  justify-self: start;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: 500 15px/1.3 var(--font-body);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.link-button:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
.link-button--danger, .button--danger { color: var(--danger); }
.button--danger { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); }

/* Texto largo: política de privacidad */
.prose { padding-top: 28px; padding-bottom: 28px; }
.prose h2 { margin: 28px 0 8px; font: 600 19px/1.3 var(--font-display); }
.prose p, .prose ul { margin: 12px 0 0; text-wrap: pretty; }
.prose ul { padding-left: 20px; }
.prose li + li { margin-top: 6px; }
.prose .lead { margin-top: 0; font-size: 14px; }

a { color: inherit; text-underline-offset: 3px; }
a:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

@media (prefers-reduced-motion: reduce) {
  .stamp--new { animation: none; }
  .spinner { animation-duration: 2.4s; }
  .button, .input, .check { transition: none; }
}

/* ---------- Regalo de bienvenida ---------- */
.gift-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 16px 0 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--brand) 12%, var(--surface));
  font-size: 15px;
  text-wrap: pretty;
}
.gift-icon { flex: none; display: grid; color: var(--brand); margin-top: 1px; }
.history-gift { color: var(--brand); }

/* ---------- Aviso de navegador interno (WhatsApp, Instagram…) ---------- */
.inapp-note {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1.5px solid color-mix(in srgb, #D97706 45%, var(--line));
  border-radius: 14px;
  background: color-mix(in srgb, #D97706 10%, var(--surface));
}
.inapp-title { margin: 0; font-weight: 600; font-size: 15px; text-wrap: pretty; }
.inapp-help { margin: 4px 0 0; font-size: 14px; color: var(--muted); }
.inapp-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-top: 6px;
  font-weight: 600;
  font-size: 15px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- Verificar este celular ---------- */
.claim-note {
  margin: 16px 0 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface-2);
  font-size: 15px;
}
.claim-note p { margin: 0 0 4px; text-wrap: pretty; }
.verify .lead { margin-bottom: 16px; }
.verify-button { margin-top: 4px; }
.verify-code {
  display: flex;
  justify-content: center;
  gap: .4em;
  margin: 8px 0 4px;
  padding: 18px 12px;
  border-radius: 16px;
  background: var(--surface-2);
  font: 700 44px/1 var(--font-display);
  letter-spacing: .06em;
  font-variant-numeric: tabular-nums;
}
.verify-timer { margin: 8px 0 0; text-align: center; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.verify-ok {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--success) 14%, var(--surface));
  color: var(--success);
  font-weight: 600;
}
#extras > .verify-ok { margin: 16px 0 0; }

/* ---------- Reseña de Google ---------- */
.review { display: grid; justify-items: center; gap: 10px; text-align: center; }
.review .section-title { margin: 0; }
.review-stars { display: inline-flex; gap: 2px; color: #F5A623; }
.review-button { text-decoration: none; margin-top: 6px; }
.review .link-button { justify-self: center; text-align: center; }
