/* Lotería Irwin · página pública de resultados */
:root {
  --bg: #f2f5f3;
  --card: #ffffff;
  --text: #13201a;
  --muted: #5b6b62;
  --border: #dbe4de;
  --brand: #15803d;
  --brand-dark: #0f5f2d;
  --brand-text: #ffffff;
  --cell: #f6f9f7;
  --cell-empty: #eef2ef;
  --gold: #b45309;
  --gold-bg: #fef3c7;
  --live: #1d4ed8;
  --live-bg: #e0e9ff;
  --miss: #b91c1c;
  --miss-bg: #fde8e8;
  --miss-border: #f3b4b4;
  --hit-bg: #e6f6ea;
  --shadow: 0 1px 2px rgba(16, 40, 24, .06), 0 2px 8px rgba(16, 40, 24, .06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1310;
    --card: #151d18;
    --text: #e7efe9;
    --muted: #93a59a;
    --border: #26332b;
    --brand: #16a34a;
    --brand-dark: #0b3d1f;
    --cell: #1b251f;
    --cell-empty: #18201b;
    --gold: #fbbf24;
    --gold-bg: #3a2a0a;
    --live: #8fb0ff;
    --live-bg: #1a2546;
  --miss: #f87171;
  --miss-bg: #3a1618;
  --miss-border: #6b2427;
  --hit-bg: #12301d;
    --miss: #f87171;
    --miss-bg: #3a1618;
    --miss-border: #6b2427;
    --hit-bg: #12301d;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1310;
  --card: #151d18;
  --text: #e7efe9;
  --muted: #93a59a;
  --border: #26332b;
  --brand: #16a34a;
  --brand-dark: #0b3d1f;
  --cell: #1b251f;
  --cell-empty: #18201b;
  --gold: #fbbf24;
  --gold-bg: #3a2a0a;
  --live: #8fb0ff;
  --live-bg: #1a2546;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: clip; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3, p { margin: 0; }
.wrap { max-width: 960px; margin: 0 auto; padding-left: 16px; padding-right: 16px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Cabecera */
.hero {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: var(--brand-text);
  padding: calc(18px + env(safe-area-inset-top, 0px)) 0 22px;
}
.hero-in { display: flex; flex-wrap: wrap; gap: 14px 20px; align-items: center; justify-content: space-between; }
.brand { display: flex; gap: 12px; align-items: center; }
.ball {
  width: 46px; height: 46px; border-radius: 50%; background: #fff; color: var(--brand);
  display: grid; place-items: center; font-weight: 900; font-size: 17px;
  box-shadow: inset 0 0 0 4px #b91c1c, 0 2px 6px rgba(0, 0, 0, .2);
}
.brand h1 { font-size: 22px; line-height: 1.1; }
.brand p { font-size: 13px; opacity: .85; }
.when { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.when select {
  font: inherit; font-weight: 600; color: var(--text); background: var(--card);
  border: 0; border-radius: 10px; padding: 9px 12px; max-width: 100%;
}
.updated { font-size: 12px; opacity: .9; }

main { padding-top: 18px; padding-bottom: 8px; display: grid; gap: 16px; }
.loading, .empty { text-align: center; color: var(--muted); padding: 32px 12px; }

/* Juego (Tripleta, Descarte, Dupleta) */
.game { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.game-head { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.game-head h2 { font-size: 20px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.game-head h2 small { font-size: 13px; font-weight: 500; color: var(--muted); }
.pill { font-size: 13px; font-weight: 700; padding: 5px 11px; border-radius: 999px; white-space: nowrap; }
.pill.espera, .pill.sin_jugadas { background: var(--cell-empty); color: var(--muted); }
.pill.en_juego { background: var(--live-bg); color: var(--live); }
.pill.en_juego::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; margin-right: 6px; vertical-align: 1px; animation: pulse 1.4s ease-in-out infinite; }
.pill.ganador { background: var(--brand); color: var(--brand-text); }
.pill.acumulado { background: var(--gold-bg); color: var(--gold); }
@keyframes pulse { 50% { opacity: .3; } }

.prize {
  display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: baseline; justify-content: space-between;
  background: var(--cell); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; margin-bottom: 14px;
}
.prize .amount { font-size: 22px; font-weight: 800; color: var(--brand); font-variant-numeric: tabular-nums; }
.prize .label { font-size: 13px; color: var(--muted); }
.prize .winners { width: 100%; font-weight: 700; }
.prize.acumulado .amount { color: var(--gold); }

/* Tabla de resultados: horas x loterías */
.grid { display: grid; grid-template-columns: 52px repeat(var(--cols, 4), minmax(0, 1fr)); gap: 6px; align-items: stretch; }
.grid .lh { font-size: 12px; font-weight: 700; text-align: center; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; padding-bottom: 2px; }
.grid .hr { font-size: 13px; font-weight: 700; color: var(--muted); display: grid; align-items: center; }
.cell {
  background: var(--cell); border: 1px solid var(--border); border-radius: 12px; padding: 7px 4px 6px;
  display: grid; justify-items: center; gap: 1px; min-width: 0; position: relative;
}
.cell .emo { font-size: 26px; line-height: 1.1; }
.cell .num { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.cell .name { font-size: 12px; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell.empty { background: var(--cell-empty); border-style: dashed; color: var(--muted); align-content: center; min-height: 74px; }
.cell.empty .num { font-size: 15px; font-weight: 600; opacity: .6; }
.cell.none { background: transparent; border: 0; align-content: center; }
.cell.none .name { font-size: 11px; opacity: .7; }
.cell.new { border: 2px solid var(--brand); }
.cell.new::after {
  content: "Nuevo"; position: absolute; top: -8px; right: -4px; font-size: 10px; font-weight: 800;
  background: var(--brand); color: var(--brand-text); border-radius: 999px; padding: 1px 6px;
}

/* Buscador */
/* Barra fija arriba: selector de modalidad + buscador */
.bar { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 10px 0; box-shadow: 0 1px 0 var(--border); }
.bar .wrap { display: grid; gap: 8px; }
.modos { display: grid; grid-template-columns: repeat(var(--modos, 3), minmax(0, 1fr)); gap: 6px; }
.modo {
  position: relative; font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 8px 4px; cursor: pointer; display: grid; gap: 1px; text-align: center; min-width: 0;
}
.modo b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.modo span { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.modo.active { background: var(--brand); border-color: var(--brand); color: var(--brand-text); }
.modo.active span { color: var(--brand-text); opacity: .85; }
.modo .dot { position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--live); }
.modo.active .dot { background: var(--brand-text); }
.search[hidden] { display: none; }
.search input {
  width: 100%; font: inherit; color: var(--text); background: var(--card);
  border: 1px solid var(--border); border-radius: 12px; padding: 11px 14px;
}
.search input:focus { outline: 2px solid var(--brand); outline-offset: 0; }
.bar + main { padding-top: 14px; }

/* Jugadas de cada jugador */
.n {
  display: inline-flex; justify-content: center; align-items: center; min-width: 32px; padding: 3px 5px;
  border-radius: 7px; font-weight: 800; font-size: 14px; font-variant-numeric: tabular-nums; border: 1px solid transparent;
}
.n.hit { background: var(--brand); color: var(--brand-text); }
.n.miss { background: var(--miss-bg); color: var(--miss); border-color: var(--miss-border); }
.n sup { font-size: .62em; font-weight: 800; margin-left: 1px; position: relative; top: -.45em; vertical-align: baseline; line-height: 0; }
.plays { margin-top: 16px; display: grid; gap: 8px; }
.plays.nomatch { display: none; }
.plays-head { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: baseline; justify-content: space-between; }
.plays-head h3 { font-size: 17px; }
.plays-head h3 small { font-size: 13px; font-weight: 500; color: var(--muted); }
details.player { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--card); }
details.player.winner { border: 2px solid var(--brand); }
details.player summary {
  list-style: none; cursor: pointer; display: flex; gap: 10px; align-items: center; justify-content: space-between;
  padding: 10px 12px; background: var(--cell);
}
details.player summary::-webkit-details-marker { display: none; }
details.player summary::before { content: "▸"; color: var(--muted); transition: transform .15s; }
details.player[open] summary::before { transform: rotate(90deg); }
.pname { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pinfo { flex: none; font-size: 13px; color: var(--muted); white-space: nowrap; }
.pinfo b { color: var(--text); }
.tk { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 6px 12px; border-top: 1px solid var(--border); }
.tk.won { background: var(--hit-bg); }
.tk .idx { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tk .nums { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.tk .sc { font-weight: 800; font-variant-numeric: tabular-nums; color: var(--miss); }
.tk .sc.on { color: var(--brand); }
.won-tag { font-size: 12px; font-weight: 800; color: var(--brand); white-space: nowrap; }
.late-tag { font-size: 12px; color: var(--muted); white-space: nowrap; }


.foot { padding-top: 6px; padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px)); color: var(--muted); font-size: 13px; display: grid; gap: 6px; }

@media (max-width: 520px) {
  .wrap { padding-left: 12px; padding-right: 12px; }
  .game { padding: 12px; border-radius: 14px; }
  .grid { grid-template-columns: 40px repeat(var(--cols, 4), minmax(0, 1fr)); gap: 4px; }
  .grid .lh { font-size: 10px; letter-spacing: 0; }
  .grid .hr { font-size: 12px; }
  .cell { padding: 6px 2px 5px; border-radius: 10px; }
  .cell .emo { font-size: 22px; }
  .cell .num { font-size: 16px; }
  .cell .name { font-size: 11px; }
  .cell.empty { min-height: 66px; }
  .prize .amount { font-size: 20px; }
}

/* Sumatoria: total de puntos debajo de los aciertos */
.tk .sc { text-align: right; }
.tk .sc small { display: block; font-size: 11px; font-weight: 600; color: var(--muted); }
.points-note { font-size: 12px; color: var(--muted); margin-top: -2px; }
@media (max-width: 520px) {
  .tk { grid-template-columns: 28px minmax(0, 1fr) auto; gap: 6px; padding: 6px 8px; }
  .tk .nums { gap: 3px; }
  .tk .n { min-width: 28px; padding: 3px 3px; font-size: 13px; }
  .tk .n sup { font-size: .6em; }
}

/* Bono especial (Tripleta) */
.prize.bono { background: var(--gold-bg); border-color: transparent; margin-top: -6px; }
.prize.bono .amount { color: var(--gold); }
.prize.bono .label { color: var(--gold); font-weight: 700; }

/* Tabla informativa "Cómo se juega" */
.howto { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 16px; margin-top: 16px; box-shadow: var(--shadow); }
.howto h2 { font-size: 18px; margin-bottom: 10px; }
.howto .table-wrap { overflow-x: auto; }
.howto table { width: 100%; border-collapse: collapse; font-size: 14px; }
.howto th, .howto td { text-align: left; padding: 8px 6px; border-top: 1px solid var(--border); vertical-align: top; }
.howto thead th { border-top: 0; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.howto tbody th { font-weight: 800; white-space: nowrap; }
.howto tbody tr.sel th, .howto tbody tr.sel td { background: var(--cell); }
.howto td.num { font-weight: 800; font-size: 18px; color: var(--brand); text-align: center; }
.howto ul { margin: 12px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; display: grid; gap: 4px; }

/* Historial de premios */
.hist:empty { display: none; }
.hist > .muted { margin: -4px 0 10px; font-size: 13px; }
.hday { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin-top: 10px; }
.hdate { background: var(--cell); padding: 8px 12px; font-weight: 700; font-size: 14px; }
.hrow { padding: 8px 12px; border-top: 1px solid var(--border); display: grid; gap: 3px; }
.htop { display: flex; gap: 10px; align-items: baseline; }
.htop .hpot { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--brand); }
.hbot { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 13px; }
.hres { font-weight: 600; color: var(--muted); }
.hres.won { color: var(--brand); }
.hres.acc { color: var(--gold); }
.hres.live { color: var(--live); }
.hbono { color: var(--gold); }
