:root {
  --azul: #1D4ED8;
  --verde: #15803D;
  --gris: #E5E7EB;
  --texto: #111827;
  --fondo: #F8FAFC;
  --cat-color: #1D4ED8;
  --cat-texto: #FFFFFF;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fondo); color: var(--texto);
  font-size: 22px; line-height: 1.3;
  display: flex; flex-direction: column; min-height: 100dvh;
  user-select: none; -webkit-user-select: none;
}
[hidden] { display: none !important; }

header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  background: #fff; border-bottom: 2px solid var(--gris);
}
.chip {
  font: inherit; font-size: 20px; padding: 10px 16px; min-height: 52px;
  border: 2px solid var(--gris); border-radius: 999px; background: #fff; color: var(--texto);
}
.chip[aria-pressed="false"] { opacity: .45; text-decoration: line-through; }
.contador { font-weight: 700; font-size: 22px; }

main { flex: 1; display: flex; }
.pantalla {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 22px; padding: 24px 20px calc(24px + env(safe-area-inset-bottom)); text-align: center;
  max-width: 760px; margin: 0 auto; width: 100%;
}
h1 { font-size: 40px; margin: 0; line-height: 1.15; }
.grande { font-size: 30px; margin: 0; }
.ayuda { font-size: 22px; color: #4B5563; margin: 0; }
.error { color: #B91C1C; font-weight: 700; }

input[type="password"], input[type="text"] {
  font: inherit; font-size: 32px; text-align: center; letter-spacing: 4px;
  width: 100%; max-width: 420px; padding: 16px; border: 3px solid var(--gris); border-radius: 16px;
}
form { display: flex; flex-direction: column; gap: 18px; align-items: center; width: 100%; }

.btn {
  font: inherit; font-weight: 800; letter-spacing: .5px; cursor: pointer;
  border: 0; border-radius: 24px; width: 100%; max-width: 520px;
  min-height: 96px; padding: 20px 28px; font-size: 30px;
  display: flex; align-items: center; justify-content: center; gap: 14px;
  box-shadow: 0 6px 0 rgba(0,0,0,.18); transition: transform .08s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0,0,0,.18); }
.btn-primario { background: var(--azul); color: #fff; }
.btn-ok { background: var(--verde); color: #fff; min-height: 120px; font-size: 34px; }
.btn-secundario { background: #fff; color: var(--texto); border: 3px solid #9CA3AF; box-shadow: 0 6px 0 rgba(0,0,0,.08); }
.btn-foto {
  flex-direction: column; min-height: 320px; font-size: 40px; line-height: 1.1;
  background: var(--azul); color: #fff; border-radius: 36px;
}
.btn-foto-icono { font-size: 120px; line-height: 1; }
.acciones { display: flex; flex-direction: column; gap: 18px; width: 100%; align-items: center; }

.rejilla-nombres { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; width: 100%; }
.rejilla-nombres .btn { max-width: none; background: #fff; color: var(--texto); border: 3px solid var(--azul); }

.previa { max-height: 38dvh; max-width: 80%; border-radius: 16px; box-shadow: 0 8px 24px rgba(0,0,0,.2); object-fit: contain; }
.espera { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.ruedita {
  width: 72px; height: 72px; border: 10px solid var(--gris); border-top-color: var(--azul);
  border-radius: 50%; animation: girar 1s linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }

.tarjeta {
  width: 100%; max-width: 560px; border-radius: 32px; padding: 28px 24px;
  background: var(--cat-color); color: var(--cat-texto);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  box-shadow: 0 12px 32px rgba(0,0,0,.22);
  animation: aparecer .35s ease-out;
}
@keyframes aparecer { from { transform: scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }
.tarjeta-numero {
  width: 150px; height: 150px; border-radius: 50%; background: rgba(255,255,255,.95); color: #111;
  display: flex; align-items: center; justify-content: center; font-size: 96px; font-weight: 900; line-height: 1;
}
.tarjeta-icono { font-size: 80px; line-height: 1; }
.tarjeta-nombre { font-size: 40px; font-weight: 800; line-height: 1.15; }
.tarjeta-peq { padding: 18px; flex-direction: row; justify-content: center; gap: 20px; }
.tarjeta-peq .tarjeta-numero { width: 90px; height: 90px; font-size: 56px; }
.tarjeta-peq .tarjeta-nombre { font-size: 30px; text-align: left; }
.libro { font-size: 22px; color: #374151; margin: 0; max-width: 560px; }
.confianza { font-size: 22px; font-weight: 700; color: #92400E; background: #FEF3C7; padding: 10px 18px; border-radius: 12px; margin: 0; }

.rejilla-cats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; width: 100%; }
.cat-boton {
  font: inherit; cursor: pointer; border: 0; border-radius: 20px; padding: 16px 12px; min-height: 130px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  box-shadow: 0 5px 0 rgba(0,0,0,.2);
}
.cat-boton:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,.2); }
.cat-boton .n { font-size: 44px; font-weight: 900; line-height: 1; background: rgba(255,255,255,.95); color: #111; border-radius: 50%; width: 64px; height: 64px; display: flex; align-items: center; justify-content: center; }
.cat-boton .i { font-size: 36px; line-height: 1; }
.cat-boton .t { font-size: 20px; font-weight: 700; line-height: 1.15; }

@media (max-width: 480px) {
  body { font-size: 19px; }
  h1 { font-size: 32px; }
  .btn-foto { min-height: 240px; font-size: 32px; }
  .btn-foto-icono { font-size: 90px; }
  .tarjeta-numero { width: 120px; height: 120px; font-size: 76px; }
  .tarjeta-nombre { font-size: 32px; }
}
