:root {
  --primary: #2340FF;
  --on-primary: #FFFFFF;
  --bg: #F1EFEA;
  --card: #FFFFFF;
  --ink: #111317;
  --muted: #5B6170;
  --line: #EFEDE7;
  --chip: #ECEAE4;
  --strong: #111317;
  --on-strong: #FFFFFF;
  --deep: #111317;
  --won: #067647;
  --won-soft: #DDF5E6;
  --won-ink: #05603A;
  --pending: #FDB022;
  --lost: #D92D20;
  --gold: #FEC84B;
  --live: #D92D20;
  --radius: 20px;
  --font: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Barlow Condensed", Inter, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0E1015;
  --card: #181B22;
  --ink: #F2F3F5;
  --muted: #A3A9B6;
  --line: #262A33;
  --chip: #262A33;
  --strong: #F2F3F5;
  --on-strong: #111317;
  --deep: #1C2029;
  --won-soft: #10301F;
  --won-ink: #7EE2A8;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  padding-bottom: calc(92px + env(safe-area-inset-bottom));
}
a { color: var(--primary); }
button { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

.shell { max-width: 1280px; margin: 0 auto; }
main { outline: none; }

/* Barra superior */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; padding-top: calc(14px + env(safe-area-inset-top));
}
.brand { font-family: var(--display); font-weight: 800; font-size: 28px; letter-spacing: .5px; color: var(--ink); text-decoration: none; }
.topnav { display: none; gap: 4px; }
.topnav a { padding: 10px 14px; border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 700; font-size: 14px; }
.topnav a.active { background: var(--strong); color: var(--on-strong); }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 14px; border: 0; background: var(--card); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.desktop-only { display: none; }

/* Barra inferior (celular) */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-around;
  height: calc(76px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--deep); border-radius: 24px 24px 0 0;
}
.bottomnav a { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 64px; padding: 6px 0; color: #A3A9B6; text-decoration: none; font-size: 11px; font-weight: 700; }
.bottomnav a.active { color: #FFFFFF; }
.bottomnav a.scan { width: 56px; height: 56px; border-radius: 16px; background: var(--primary); color: #FFF; justify-content: center; min-width: 0; }

@media (min-width: 900px) {
  body { padding-bottom: 32px; }
  .topnav, .desktop-only { display: flex; }
  .bottomnav { display: none; }
  .topbar { padding: 18px 28px; }
}

/* Bloques */
.page { padding: 4px 16px 24px; display: flex; flex-direction: column; gap: 14px; }
@media (min-width: 900px) { .page { padding: 8px 28px 32px; } }
.hero {
  background: var(--primary); color: var(--on-primary); border-radius: 28px; padding: 20px;
}
.hero .row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.hero .meta { font-size: 13px; font-weight: 600; opacity: .88; }
.hero .big { font-family: var(--display); font-size: 52px; font-weight: 800; line-height: 1; margin-top: 6px; }
.hero .big.struck { text-decoration: line-through; text-decoration-thickness: 3px; }
.hero .stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 16px; }
.hero .stat { background: rgba(255,255,255,.15); border-radius: 14px; padding: 10px 12px; }
.hero .stat b { display: block; font-family: var(--display); font-size: 28px; font-weight: 800; }
.hero .stat span { font-size: 12px; opacity: .9; }
.badge { display: inline-block; font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 8px; }
.badge.white { background: #FFF; color: #B42318; }
.badge.white.ok { color: var(--won); }
.badge.white.open { color: #111317; }

.card { background: var(--card); border-radius: var(--radius); padding: 16px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); align-items: start; }
.split { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.split > .main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.split > .side { flex: 1 1 280px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }

.section-title { margin: 8px 4px 0; font-size: 13px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.section-title span { text-transform: none; letter-spacing: 0; font-weight: 600; }
h1.title { margin: 0; font-family: var(--display); font-size: 40px; font-weight: 800; letter-spacing: .3px; }

/* Partido */
.match-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tag { font-size: 11px; font-weight: 800; padding: 4px 8px; border-radius: 6px; background: var(--chip); color: var(--ink); white-space: nowrap; }
.tag.live { background: var(--live); color: #FFF; }
.small { font-size: 12px; color: var(--muted); font-weight: 600; }
.score { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 8px; margin: 12px 0 6px; }
.score .team { font-size: 16px; font-weight: 700; }
.score .team.away { text-align: right; }
.score .num { font-family: var(--display); font-size: 40px; font-weight: 800; }

.leg { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.leg .ico { width: 28px; height: 28px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex: none; }
.leg .ico svg { width: 15px; height: 15px; stroke-width: 3; }
.leg .ico.won { background: var(--won); color: #FFF; }
.leg .ico.pending, .leg .ico.notStarted { background: var(--pending); color: #111317; }
.leg .ico.notStarted { background: var(--chip); color: var(--muted); }
.leg .ico.lost { background: var(--lost); color: #FFF; }
.leg .ico.unknown { background: var(--chip); color: var(--muted); }
.leg .txt { flex: 1; min-width: 0; }
.leg .txt b { display: block; font-size: 14px; }
.leg .txt span { font-size: 12px; color: var(--muted); }
.leg .count { font-family: var(--display); font-size: 22px; font-weight: 800; }
.gold { display: inline-block; margin-top: 4px; font-size: 11px; font-weight: 800; color: #111317; background: var(--gold); padding: 2px 7px; border-radius: 5px; }

/* Botones y formularios */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 14px; border: 0; font-weight: 800; font-size: 14px; text-decoration: none; cursor: pointer; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-strong { background: var(--strong); color: var(--on-strong); }
.btn-ghost { background: var(--chip); color: var(--ink); }
.btn-block { width: 100%; min-height: 52px; font-size: 15px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { min-height: 38px; padding: 0 14px; border-radius: 10px; border: 0; background: var(--card); color: var(--ink); font-weight: 700; font-size: 13px; cursor: pointer; }
.chip.on { background: var(--strong); color: var(--on-strong); }
select, input[type="text"], input[type="number"] {
  width: 100%; min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); padding: 0 12px; font: inherit;
}
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 700; color: var(--muted); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; }
.switch input { width: 50px; height: 30px; appearance: none; border-radius: 15px; background: var(--chip); position: relative; cursor: pointer; flex: none; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 12px; background: #FFF; transition: transform .15s; }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { transform: translateX(20px); }

.drop { border: 2px dashed var(--muted); border-radius: var(--radius); padding: 28px 16px; text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; cursor: pointer; }
.drop.over { border-color: var(--primary); background: var(--card); }
.thumb { width: 88px; max-height: 160px; object-fit: cover; object-position: top; border-radius: 12px; }
.progress { height: 8px; border-radius: 4px; background: var(--chip); overflow: hidden; }
.progress > div { height: 100%; background: var(--primary); transition: width .2s; }
.warn { background: #FEF0C7; color: #7A2E0E; border-radius: 12px; padding: 10px 12px; font-size: 13px; font-weight: 600; }
:root[data-theme="dark"] .warn { background: #3A2A0B; color: #FCD58B; }

/* Hoy */
.pick { display: flex; border-radius: 20px; overflow: hidden; background: var(--card); }
.pick .pct { width: 96px; flex: none; background: var(--primary); color: #FFF; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 14px 0; }
.pick .pct b { font-family: var(--display); font-size: 36px; font-weight: 800; line-height: 1; }
.pick .pct span { font-size: 11px; font-weight: 600; opacity: .88; }
.pick .body { padding: 12px 14px; min-width: 0; }
.pill { font-size: 12px; font-weight: 700; background: var(--bg); padding: 4px 8px; border-radius: 6px; display: inline-block; }
.pill.value { background: var(--won-soft); color: var(--won-ink); }
.row-match { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: 14px; padding: 10px 12px; }
.row-match .time { width: 52px; flex: none; text-align: center; font-family: var(--display); font-size: 18px; font-weight: 700; background: var(--bg); border-radius: 8px; padding: 4px 0; }
.row-match .mid { flex: 1; min-width: 0; }
.row-match .mid b { font-size: 14px; }
.row-match .fav { text-align: right; flex: none; }
.row-match .fav b { display: block; font-family: var(--display); font-size: 20px; font-weight: 800; color: var(--primary); }
:root[data-theme="dark"] .row-match .fav b { color: #8FA0FF; }

/* Alertas */
.alert { display: flex; gap: 12px; background: var(--card); border-radius: 16px; padding: 12px 14px; }
.alert .ico { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex: none; background: var(--chip); }
.alert .ico svg { width: 16px; height: 16px; stroke-width: 2.6; }
.alert.goal .ico { background: var(--primary); color: #FFF; }
.alert.won .ico { background: var(--won); color: #FFF; }
.alert.lost .ico, .alert.bet-lost .ico { background: var(--lost); color: #FFF; }
.alert.golden .ico { background: var(--gold); color: #111317; }
.alert b { display: block; font-size: 14px; }
.alert p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty h2 { color: var(--ink); margin: 0 0 6px; font-size: 20px; }

#toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: var(--strong); color: var(--on-strong); padding: 12px 16px; border-radius: 12px; font-weight: 700; font-size: 14px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 20; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (min-width: 900px) { #toast { bottom: 24px; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Armador */
a.row-match, a.pick { color: inherit; text-decoration: none; }
a.row-match:hover, a.pick:hover { outline: 2px solid var(--primary); outline-offset: -2px; }
.stat-row { padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.stat-row .hits { font-family: var(--display); font-size: 24px; font-weight: 800; color: var(--primary); }
:root[data-theme="dark"] .stat-row .hits { color: #8FA0FF; }
.dots { display: flex; gap: 3px; }
.dots span { flex: 1; height: 10px; border-radius: 3px; background: var(--chip); max-width: 28px; }
.dots span.on { background: var(--won); }
.combo { background: var(--deep); color: #FFF; }
.combo .small { color: #A3A9B6; }
.combo .leg { border-top-color: #2A2E37; }
.combo .leg .txt span { color: #A3A9B6; }

/* Partido en vivo */
a.score { color: inherit; text-decoration: none; }
.cmp { padding: 8px 0; }
.cmp-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; }
.cmp-head span { color: var(--muted); font-weight: 600; }
.cmp-head b { font-family: var(--display); font-size: 20px; font-weight: 800; min-width: 40px; }
.cmp-head b:last-child { text-align: right; }
.cmp-bar { display: flex; gap: 4px; height: 8px; margin-top: 4px; }
.cmp-bar span { border-radius: 4px; background: var(--primary); min-width: 4px; }
.cmp-bar span:last-child { background: var(--muted); }
.tl { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--line); }
.tl:first-child { border-top: 0; }
.tl .min { width: 44px; flex: none; font-family: var(--display); font-weight: 800; font-size: 17px; }
.tl b { font-size: 13px; }
.pl { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.pl.mine { background: var(--won-soft); border-radius: 8px; padding: 8px; }

.count small.prob { display: block; font-size: 11px; font-weight: 700; color: var(--muted); font-family: var(--body, inherit); }
.count small.prob.hi { color: var(--won); }
.count small.prob.lo { color: var(--lost); }
.lineup-warn { color: var(--lost); font-weight: 700; }
