:root {
  --accent: #4a6585; /* azul grisáceo (slate); se sobreescribe por branding del comercio */
  --accent-strong: #3b5270;
  --accent-soft: #eef2f7;
  --accent-ring: rgba(74, 101, 133, 0.22);
  --accent-contrast: #ffffff;
  --bg-top: #f3f5f9;
  --bg-bottom: #e7ebf1;
  --surface: #ffffff;
  --text: #1f2a37;
  --muted: #6b7785;
  --border: #d7dde5;
  --error: #c0392b;
  --radius: 16px;
  --overlay: rgba(15, 20, 28, 0.58); /* oscurecido sobre la foto del comercio */
}

* {
  box-sizing: border-box;
}

/* hidden SIEMPRE gana (sin esto, reglas como form{display:flex} lo pisan). */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  color: var(--text);
  font-family:
    system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Foto de fondo del comercio (la setea JS como inline style en body). */
body.has-bg {
  background-size: cover;
  background-position: center;
}

/* Overlay que oscurece la foto. Aparece con una transición al cargar. */
body.has-bg::before {
  content: '';
  position: fixed;
  inset: 0;
  background: var(--overlay);
  opacity: 0;
  transition: opacity 0.6s ease;
  z-index: 0;
}
body.has-bg.loaded::before {
  opacity: 1;
}

/* Contenedores de nivel superior, por encima del overlay. */
.floating,
#screen {
  position: relative;
  z-index: 1;
}
#screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
}

.card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(15, 20, 28, 0.22);
  padding: 32px 26px;
}

/* Reveal de la card al cargar */
#screen .card {
  opacity: 0;
  transform: translateY(16px) scale(0.99);
  transition:
    opacity 0.55s ease 0.2s,
    transform 0.55s ease 0.2s;
}
body.loaded #screen .card {
  opacity: 1;
  transform: none;
}

/* Marca del comercio */
.brand {
  text-align: center;
  margin-bottom: 24px;
}
.brand-logo {
  max-height: 72px;
  max-width: 65%;
  margin: 0 auto 14px;
  display: block;
}
.brand h1 {
  margin: 0 0 10px;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.reward-line {
  display: inline-block;
  margin: 0;
  padding: 6px 14px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}

/* Footer "con <app>" — deja claro que es una plataforma externa. */
.powered {
  opacity: 0;
  transition: opacity 0.5s ease 0.45s;
  font-size: 0.8rem;
  color: #fff;
  background: rgba(15, 20, 28, 0.45);
  padding: 5px 12px;
  border-radius: 999px;
  backdrop-filter: blur(4px);
}
.powered strong {
  font-weight: 700;
}
body.loaded .powered {
  opacity: 1;
}

/* Formularios / pasos */
form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}
.optional {
  color: var(--muted);
  font-weight: 400;
}

input[type='text'],
input[type='email'],
input[type='date'],
input[type='tel'] {
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 11px;
  font-size: 1rem;
  width: 100%;
  background: #fff;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
input[type='text']:focus,
input[type='email']:focus,
input[type='date']:focus,
input[type='tel']:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

label.checkbox {
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.4;
}
label.checkbox input {
  width: auto;
  margin-top: 2px;
  accent-color: var(--accent);
}

button {
  margin-top: 4px;
  padding: 14px;
  border: 0;
  border-radius: 11px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition:
    background 0.15s,
    transform 0.05s;
}
button:hover {
  background: var(--accent-strong);
}
button:active {
  transform: translateY(1px);
}
button:disabled {
  opacity: 0.55;
  cursor: default;
}

.error {
  color: var(--error);
  font-size: 0.88rem;
  margin: 0;
}
.hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0;
}
.dev-hint {
  font-size: 0.8rem;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border: 1px dashed var(--accent);
  border-radius: 8px;
  padding: 8px 10px;
  text-align: center;
}

#not-found .card,
#success-state {
  text-align: center;
}
#success-state h1 {
  font-size: 1.5rem;
  margin: 0 0 8px;
}

.wallet-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 20px 0 14px;
}
.wallet-btn {
  display: block;
  padding: 14px;
  border-radius: 11px;
  background: #1f2a37;
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  transition: opacity 0.15s;
}
.wallet-btn:hover {
  opacity: 0.9;
}

/* Spinner de carga inicial */
.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(74, 101, 133, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Página del código rotativo */
.code-card {
  text-align: center;
}
.code-instructions {
  margin-bottom: 18px;
}
.code-display {
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 12px;
  margin: 6px 0 18px;
}
.code-value {
  font-size: clamp(2.6rem, 14vw, 3.6rem);
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--accent-strong);
  font-variant-numeric: tabular-nums;
  font-family: 'SF Mono', 'Roboto Mono', ui-monospace, Menlo, Consolas, monospace;
}
.code-countdown {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.code-countdown-bar {
  height: 6px;
  width: 100%;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.code-countdown-fill {
  height: 100%;
  width: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 1s linear;
}

/* Grilla de sellos a juntar (la meta del programa) */
.stamp-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  max-width: 240px;
  margin: 14px auto 0;
}
.stamp-cell {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed rgba(0, 0, 0, 0.18);
  border-radius: 50%;
  font-size: 1.1rem;
  filter: grayscale(0.4);
  opacity: 0.65;
}
