/* Lotería — styles. Mobile first. */
:root {
  --ground: #F6EFE2; --surface: #FFFDF8; --line: #E3D6BF; --tint: #EFE4CF;
  --ink: #1F1A17; --muted: #5E534A;
  --red: #B3261E; --red-dark: #8E1D17; --blue: #1B5E8C; --green: #2E6B3A; --amber: #8A5A00;
  --serif: 'DM Serif Display', Georgia, serif;
  --sans: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --r: 12px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ground); color: var(--ink); font: 16px/1.45 var(--sans); }
a { color: var(--blue); }
a:hover { color: #123F5F; }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; line-height: 1.1; margin: 0 0 12px; }
h1 { font-size: 34px; } h2 { font-size: 24px; } h3 { font-size: 18px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.mono { font-family: var(--mono); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 4px; }

/* ---------- Top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top)); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark { width: 30px; height: 40px; border: 2px solid var(--ink); border-radius: 5px; background: var(--red); color: #FFFDF8;
  display: inline-flex; align-items: center; justify-content: center; font: 20px var(--serif); }
.brand-name { font: 24px var(--serif); }
.brand.big { margin-bottom: 20px; }
.nav { display: flex; gap: 4px; overflow-x: auto; order: 3; width: 100%; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.nav a { flex-shrink: 0; padding: 10px 14px; border-radius: 999px; color: var(--ink); text-decoration: none; font-weight: 500; min-height: 44px; display: flex; align-items: center; }
.nav a[aria-current="page"] { background: var(--ink); color: #FFFDF8; font-weight: 600; }
.logout { margin-left: auto; }
button.link { background: none; border: 0; padding: 10px 4px; color: var(--muted); font: 14px var(--sans); cursor: pointer; min-height: 44px; }
button.link:hover { color: var(--ink); text-decoration: underline; }
.link.danger { color: var(--red); }
@media (min-width: 900px) {
  .topbar { padding: 12px 32px; flex-wrap: nowrap; }
  .nav { order: 0; width: auto; margin-left: 24px; }
}

/* ---------- Layout ---------- */
.wrap { max-width: 1400px; margin: 0 auto; padding: 20px 16px 48px; padding-bottom: max(48px, env(safe-area-inset-bottom)); }
.wrap.narrow { max-width: 460px; padding-top: 48px; }
@media (min-width: 900px) { .wrap { padding: 32px 32px 64px; } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 20px; margin-bottom: 20px; }
.panel.dark { background: var(--ink); color: #E9DFCF; border-color: var(--ink); }
.panel.dark .pattern-name { color: #FFFDF8; }
.panel.empty { text-align: center; padding: 48px 20px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack.tight { gap: 8px; }
.row { display: flex; gap: 12px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.end { align-items: flex-end; }
.grow { flex: 1 1 auto; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; }
.page-head h1 { margin: 0; }
.two-col { display: grid; gap: 20px; }
@media (min-width: 1000px) { .two-col { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; } }

/* ---------- Forms & buttons ---------- */
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 15px; }
input, select { font: 17px var(--sans); color: var(--ink); background: #fff; border: 2px solid var(--line); border-radius: 10px;
  padding: 10px 12px; min-height: 48px; width: 100%; }
input:focus, select:focus { outline: 3px solid rgba(27, 94, 140, .35); border-color: var(--blue); }
.w-num { width: 130px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px;
  border: 2px solid var(--ink); border-radius: var(--r); background: transparent; color: var(--ink);
  font: 600 16px var(--sans); text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--tint); color: var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--red); border-color: var(--red); color: #FFFDF8; }
.btn-primary:hover { background: var(--red-dark); border-color: var(--red-dark); color: #FFFDF8; }
.btn-ok { background: var(--green); border-color: var(--green); color: #FFFDF8; }
.btn-ok:hover { background: #22522C; color: #FFFDF8; }
.btn-light { background: #FFFDF8; border-color: #FFFDF8; color: var(--ink); }
.btn-sm { min-height: 40px; padding: 0 14px; font-size: 14px; }
.btn-xl { min-height: 60px; font-size: 19px; font-weight: 700; }
.btn-block { width: 100%; margin-top: 10px; }
form { margin: 0; }

.flash { border-radius: 12px; padding: 12px 16px; margin-bottom: 16px; font-weight: 500; }
.flash ul { margin: 8px 0 0; padding-left: 20px; font-weight: 400; }
.flash-ok { background: #E3F0E4; color: #1E4A27; border: 1px solid #B9D7BD; }
.flash-bad { background: #F8E1DE; color: #7A1A14; border: 1px solid #E9B7B1; }
.flash-warn { background: #FBEFD6; color: #5C3D00; border: 1px solid #EACB8A; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th { text-align: left; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 8px; border-bottom: 2px solid var(--line); }
td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td.actions { text-align: right; white-space: nowrap; }
td.actions form { display: inline; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--tint); color: var(--ink); }
.badge-live { background: var(--red); color: #FFFDF8; }
ul.plain { list-style: none; margin: 0; padding: 0; } ul.plain li { padding: 6px 0; }

/* ---------- Caller ---------- */
.caller { display: grid; gap: 24px; }
@media (min-width: 1100px) { .caller { grid-template-columns: 340px minmax(0, 1fr) 290px; align-items: start; } }
.now-card { background: var(--surface); border: 3px solid var(--ink); border-radius: 16px; padding: 12px; margin: 8px 0 16px; }
.now-inner { border: 2px solid var(--red); border-radius: 8px; padding: 16px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.now-label { font-size: 13px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--red); }
.now-number { font: 150px/1 var(--serif); }
.now-foot { width: 100%; border-top: 2px solid var(--ink); padding-top: 10px; text-align: center; font: 24px var(--serif); }
.board { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
@media (min-width: 600px) { .board { grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 8px; } }
.board .cell { height: 48px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font: 700 18px var(--mono); background: var(--surface); border: 1px solid var(--line); }
@media (min-width: 600px) { .board .cell { height: 58px; font-size: 20px; } }
.cell.on { background: var(--blue); border-color: var(--blue); color: #FFFDF8; }
.cell.cur { background: var(--red); border-color: var(--red); color: #FFFDF8; }
.legend { display: flex; flex-wrap: wrap; gap: 16px; margin: 12px 0 20px; font-size: 13px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 14px; height: 14px; border-radius: 4px; background: var(--surface); border: 1px solid var(--line); }
.sw.on { background: var(--blue); border-color: var(--blue); }
.sw.cur { background: var(--red); border-color: var(--red); }
.history { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; gap: 8px; align-items: center; height: 38px; padding: 0 12px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); font: 700 15px var(--mono); }
.chip em { font: 400 13px var(--sans); color: var(--muted); font-style: normal; }
.pattern-name { font: 26px var(--serif); margin-bottom: 12px; }
.mini { display: grid; grid-template-columns: repeat(4, 12px); gap: 3px; flex-shrink: 0; }
.mini span { height: 12px; border-radius: 2px; background: var(--tint); }
.mini span.on { background: var(--red); }
.mini-lg { grid-template-columns: repeat(4, 38px); gap: 6px; margin-bottom: 14px; }
.mini-lg span { height: 38px; border-radius: 6px; }

/* ---------- Big-screen display ---------- */
body.display { background: var(--ink); color: #FFFDF8; }
.display-main { max-width: none; min-height: 100vh; padding: 3vw; }
.display-grid { display: grid; gap: 3vw; grid-template-columns: 1fr; }
@media (min-width: 1000px) { .display-grid { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); align-items: center; } }
.display-game { font: 3vw var(--serif); margin-bottom: 1vw; }
.now-card.huge { color: var(--ink); }
.now-card.huge .now-number { font-size: min(40vh, 26vw); }
.now-card.huge .now-label { font-size: 1.6vw; }
.now-card.huge .now-foot { font-size: 2.2vw; }
.board-display .cell { height: 7vh; font-size: 2.4vw; color: var(--ink); }
.board-display .cell.on, .board-display .cell.cur { color: #FFFDF8; }
.display-pattern { display: flex; align-items: center; justify-content: space-between; margin-top: 2vw; }
.display-pattern .eyebrow { color: #CFC3B0; }
.display-pattern .pattern-name { color: #FFFDF8; font-size: 2.6vw; }
.display-pattern .mini span { background: #3A322C; }
.display-pattern .mini span.on { background: var(--red); }

/* ---------- Patterns ---------- */
.patterns { display: grid; gap: 20px; }
@media (min-width: 1000px) { .patterns { grid-template-columns: 420px minmax(0, 1fr); align-items: start; } }
.pattern-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.pattern-item { display: flex; gap: 12px; align-items: center; padding: 14px; border-radius: 14px; background: var(--surface);
  border: 2px solid var(--line); color: var(--ink); text-decoration: none; min-height: 72px; }
.pattern-item:hover { border-color: var(--muted); color: var(--ink); }
.pattern-item.sel { border-color: var(--ink); }
.pattern-item span { display: flex; flex-direction: column; gap: 2px; }
.pattern-item.new { border-style: dashed; justify-content: center; font-weight: 600; }
.active-tag { font-style: normal; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--red); }
.slot-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; max-width: 440px; }
.slot { position: relative; display: block; }
.slot input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; min-height: 0; }
.slot span { display: flex; align-items: center; justify-content: center; aspect-ratio: 1; border-radius: 12px; border: 2px solid var(--line);
  background: #fff; color: var(--muted); font: 700 15px var(--mono); }
.slot input:checked + span { background: var(--red); border-color: var(--red); color: #FFFDF8; }
.slot input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: 2px; }
.danger-zone { margin-top: 8px; }

/* ---------- Cards ---------- */
.gen-form label { font-size: 14px; }
.stats { display: grid; gap: 12px; margin-bottom: 20px; }
@media (min-width: 800px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px; display: flex; flex-direction: column; gap: 4px; }
.stat b { font: 400 30px var(--serif); }
.stat span { font-size: 14px; color: var(--muted); }
.card-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

.gcard { background: #fff; border: 3px solid var(--ink); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 12px; margin: 12px 0; max-width: 420px; }
.gcard header { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 3px solid var(--red); padding-bottom: 8px; }
.gcard-title { font: 26px var(--serif); }
.gcard-code { font: 700 14px var(--mono); }
.gcard-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.gcard-grid div { aspect-ratio: 1; border: 2px solid var(--ink); border-radius: 8px; background: var(--surface);
  display: flex; align-items: center; justify-content: center; font: 30px var(--serif); }
.gcard footer { display: flex; gap: 12px; align-items: center; }
.gcard-qr { width: 110px; flex-shrink: 0; }
.gcard-qr svg { display: block; width: 100%; height: auto; }
.gcard-note { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.gcard-note strong { font: 700 16px var(--mono); color: var(--ink); }

/* ---------- Print ---------- */
.print-body { background: #ddd; }
.print-main { max-width: none; padding: 0 0 40px; }
.print-bar { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 20px; background: var(--surface); border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.sheet { width: 8.5in; height: 11in; margin: 0 auto 20px; background: #fff; padding: 0.25in; display: grid; gap: 0.2in;
  box-shadow: 0 1px 4px rgba(0,0,0,.2); page-break-after: always; break-after: page; overflow: hidden; }
.per-4 .sheet { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); }
.per-1 .sheet { grid-template-columns: 1fr; place-items: center; }
.gcard.print { margin: 0; max-width: none; width: 100%; height: 100%; border-radius: 12px; padding: 0.15in; gap: 0.1in; break-inside: avoid; }
.per-4 .gcard.print .gcard-title { font-size: 20px; }
.per-4 .gcard.print .gcard-grid div { font-size: 26px; border-radius: 6px; }
.per-4 .gcard.print .gcard-qr { width: 1.05in; }
.per-4 .gcard.print .gcard-note span { font-size: 9px; }
.per-4 .gcard.print .gcard-grid { width: 3.1in; margin: 0 auto; gap: 4px; }
.per-1 .gcard.print { width: 7in; height: auto; padding: 0.3in; gap: 0.25in; }
.per-1 .gcard.print .gcard-title { font-size: 44px; }
.per-1 .gcard.print .gcard-code { font-size: 20px; }
.per-1 .gcard.print .gcard-grid div { font-size: 64px; border-width: 3px; }
.per-1 .gcard.print .gcard-qr { width: 1.8in; }
.per-1 .gcard.print .gcard-note { font-size: 14px; }
.per-1 .gcard.print .gcard-note strong { font-size: 24px; }
@page { size: letter; margin: 0; }
@media print {
  .no-print { display: none !important; }
  body, .print-body { background: #fff; }
  .print-main { padding: 0; }
  .sheet { margin: 0; box-shadow: none; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Verify (phone) ---------- */
.verify-main { max-width: 520px; }
.verify h1 { font-size: 30px; }
.scanner { position: relative; aspect-ratio: 1; background: #2A2420; border-radius: 16px; overflow: hidden; margin: 12px 0; }
.scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame { position: absolute; inset: 18%; border: 3px solid rgba(255,253,248,.9); border-radius: 18px; box-shadow: 0 0 0 999px rgba(0,0,0,.25); pointer-events: none; }
.scan-msg { position: absolute; left: 12px; right: 12px; bottom: 12px; background: rgba(31,26,23,.85); color: #FFFDF8; border-radius: 10px; padding: 10px 12px; font-size: 14px; text-align: center; }
.manual { margin-top: 20px; }
.verify-meta { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 14px; color: var(--muted); margin-bottom: 12px; }
.verify-meta strong { color: var(--ink); }
.result { border-radius: 14px; padding: 16px; margin-bottom: 14px; color: #FFFDF8; }
.result-title { font: 30px/1.1 var(--serif); margin-bottom: 4px; }
.result-ok { background: var(--green); }
.result-bad { background: var(--red); }
.result-warn { background: var(--amber); }
.vgrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.vgrid div { aspect-ratio: 1.15; border-radius: 10px; display: flex; align-items: center; justify-content: center; font: 30px var(--serif);
  background: #fff; color: var(--muted); border: 2px solid var(--line); }
.vgrid .called, .sw.called { background: var(--tint); border-color: var(--tint); color: var(--ink); }
.vgrid .pat-called, .sw.pat-called { background: var(--blue); border-color: var(--blue); color: #FFFDF8; }
.vgrid .pat-missing, .sw.pat-missing { background: #fff; border: 3px dashed var(--red); color: var(--red); }
.checks { list-style: none; margin: 0 0 16px; padding: 0; }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.check strong { display: block; font-size: 15px; }
.check small { display: block; font-size: 13px; color: var(--muted); }
.check-icon svg { width: 22px; height: 22px; fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.check-ok svg { stroke: var(--green); } .check-bad svg { stroke: var(--red); } .check-warn svg { stroke: var(--amber); }
.other-game { margin-top: 24px; }
.auth h1 { font-size: 30px; }
