:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --brand: #0b1d3a;
  --accent: #e8473c;
  --line: #e2e8f0;
  --up: #16a34a;
  --down: #dc2626;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --card: #131c2e;
    --ink: #e5e9f2;
    --muted: #94a3b8;
    --line: #1f2a40;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
a { color: inherit; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  padding: 10px 16px;
  background: var(--brand); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; text-decoration: none; }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
nav a { text-decoration: none; padding: 8px 12px; border-radius: 8px; font-weight: 600; opacity: .8; }
nav a.active, nav a:hover { opacity: 1; background: rgba(255,255,255,.12); }

nav a.live-link { color: #fff; background: var(--accent); opacity: 1; }
.live-fab { position: fixed; right: 16px; bottom: 16px; z-index: 20; border: 0; border-radius: 999px;
  padding: 12px 18px; font: inherit; font-weight: 800; color: #fff; background: var(--accent);
  box-shadow: 0 6px 20px rgba(0,0,0,.3); cursor: pointer; }
.live-fab:hover { transform: scale(1.04); }

/* Ventana flotante de En vivo dentro de la página (móvil) */
#live-float { position: fixed; right: 10px; bottom: 80px; z-index: 50; width: min(380px, calc(100vw - 20px)); height: min(460px, 60vh);
  display: flex; flex-direction: column; background: #0b1220; border-radius: 14px; overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,.5); border: 1px solid #24314d; resize: both; }
#live-float.min { height: 40px !important; resize: none; }
#live-float.min iframe { display: none; }
.lf-bar { display: flex; align-items: center; gap: 8px; padding: 0 6px 0 12px; height: 40px; flex: none; color: #fff;
  background: #131c2e; cursor: move; touch-action: none; user-select: none; }
.lf-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.lf-bar button { margin-left: auto; width: 32px; height: 32px; border: 0; border-radius: 8px; background: #1a2540; color: #fff;
  font-size: 1.1rem; cursor: pointer; }
.lf-bar .lf-close { margin-left: 4px; }
#live-float iframe { flex: 1; border: 0; width: 100%; }

main { max-width: 1200px; margin: 0 auto; padding: 20px 16px 40px; min-height: 70vh; }
h2 { margin: 28px 0 12px; font-size: 1.3rem; }
footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 24px 16px; }

.loading, .empty { color: var(--muted); padding: 40px 0; text-align: center; }

/* Destacada */
.hero {
  position: relative; border-radius: 16px; overflow: hidden; cursor: pointer;
  aspect-ratio: 21/9; background: #000;
}
@media (max-width: 700px) { .hero { aspect-ratio: 4/3; } }
.hero img { width: 100%; height: 100%; object-fit: cover; opacity: .75; }
.hero .txt { position: absolute; inset: auto 0 0 0; padding: 24px; color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,.85)); }
.hero h1 { margin: 6px 0 0; font-size: clamp(1.3rem, 3vw, 2.2rem); }

.tag { display: inline-block; font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: #fff; background: var(--accent); padding: 3px 8px; border-radius: 4px; }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card { background: var(--card); border-radius: 12px; overflow: hidden; border: 1px solid var(--line);
  cursor: pointer; text-decoration: none; display: flex; flex-direction: column; transition: transform .15s; }
.card:hover { transform: translateY(-3px); }
.card img { width: 100%; aspect-ratio: 16/9; object-fit: cover; background: var(--line); }
.card .body { padding: 12px 14px 16px; }
.card h3 { margin: 8px 0 6px; font-size: 1rem; line-height: 1.3; }
.card p { margin: 0; color: var(--muted); font-size: .85rem; }
.thumb { position: relative; }
.thumb .dur { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.75); color: #fff;
  font-size: .75rem; padding: 2px 6px; border-radius: 4px; }

/* Controles */
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.seg { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; color: var(--ink); padding: 7px 12px; border-radius: 8px;
  font: inherit; font-weight: 600; cursor: pointer; }
.seg button.on { background: var(--accent); color: #fff; }
input[type=search], select { font: inherit; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); }

/* Ranking */
.table { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.row { display: grid; grid-template-columns: 52px 48px 1fr 70px 90px; align-items: center; gap: 10px;
  padding: 8px 14px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row.head { font-size: .75rem; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.pos { font-weight: 800; font-size: 1.1rem; }
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--line); }
.name strong { display: block; }
.name span { color: var(--muted); font-size: .8rem; }
.delta { font-size: .8rem; font-weight: 700; }
.delta.up { color: var(--up); } .delta.down { color: var(--down); }
.pts { text-align: right; font-weight: 700; }
@media (max-width: 560px) {
  .row { grid-template-columns: 36px 40px 1fr 70px; }
  .row .delta { display: none; }
}

/* Calendario */
.event { display: grid; grid-template-columns: 90px 1fr; gap: 14px; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 10px; }
.event .date { text-align: center; border-right: 1px solid var(--line); padding-right: 10px; }
.event .date b { display: block; font-size: 1.5rem; }
.event .date small { color: var(--muted); text-transform: uppercase; font-weight: 700; }
.event h3 { margin: 4px 0; font-size: 1rem; }
.event p { margin: 0; color: var(--muted); font-size: .85rem; }
.status { font-size: .7rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; margin-left: 6px; }
.status.live { background: var(--accent); color: #fff; }
.status.past { background: var(--line); color: var(--muted); }
a.event { color: inherit; text-decoration: none; transition: border-color .15s; }
a.event:hover { border-color: var(--accent); }
.event .go { display: inline-block; margin-top: 6px; font-size: .8rem; font-weight: 700; color: var(--accent); }

.muted-p { color: var(--muted); margin: -4px 0 14px; }
.muted-p.small { font-size: .8rem; margin-top: 12px; }
.status.src { background: var(--line); color: var(--ink); }
#t-region { flex-wrap: wrap; }

/* Cuadro del evento */
.back-link { display: inline-block; margin-top: 4px; color: var(--muted); text-decoration: none; font-weight: 600; }
.back-link:hover { color: var(--ink); }
.ev-sub { margin: -6px 0 6px; color: var(--muted); }
.ev-status { margin: 0 0 12px; color: var(--muted); font-size: .8rem; min-height: 1em; }
.lv { color: var(--accent); font-weight: 800; }
.live-btn { border: 0; border-radius: 10px; padding: 9px 14px; font: inherit; font-weight: 700; color: #fff;
  background: var(--accent); cursor: pointer; }
.note { color: var(--muted); font-size: .8rem; }

.bracket-wrap { overflow-x: auto; padding-bottom: 8px; }
.bracket { display: flex; gap: 28px; min-width: max-content; }
.col { display: flex; flex-direction: column; width: 310px; }
.col h4 { margin: 0 0 8px; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
  text-align: center; position: sticky; top: 0; }
.col-body { flex: 1; display: flex; flex-direction: column; }
.pair { flex: 1; display: flex; flex-direction: column; position: relative; }
.slot { flex: 1; display: flex; align-items: center; position: relative; padding: 4px 0; }
.slot > .bm { width: 100%; }
/* Conectores: cada pareja se une a la derecha y entra al partido siguiente. */
.pair:not(.single)::after { content: ''; position: absolute; right: -14px; top: 25%; bottom: 25%; width: 14px;
  border: 2px solid var(--line); border-left: 0; border-radius: 0 6px 6px 0; }
.col.joined .slot::before { content: ''; position: absolute; left: -14px; top: 50%; width: 14px; border-top: 2px solid var(--line); }

.bm { background: var(--card); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; font-size: .82rem; }
.bm.empty { visibility: hidden; height: 40px; }
.bm.bye { opacity: .55; }
.bm.live { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.bm.hit { box-shadow: 0 0 0 2px #f5b301; }
.bh { font-size: .68rem; color: var(--muted); padding: 3px 8px; border-bottom: 1px solid var(--line); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.bp { display: grid; grid-template-columns: 18px 1fr auto 24px; align-items: center; gap: 6px; padding: 4px 8px; }
.bp + .bp { border-top: 1px solid var(--line); }
.bp .seed { font-size: .68rem; color: var(--muted); text-align: center; }
.bp .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.bp .nm small { color: var(--muted); }
.bp .nm i { color: var(--muted); font-style: normal; }
.bp .gs { display: flex; gap: 1px; font-variant-numeric: tabular-nums; }
.bp .gs span { min-width: 17px; text-align: center; color: var(--muted); font-size: .74rem; }
.bp .gs span.w { color: var(--ink); font-weight: 700; }
.bp .gs span.cur { color: var(--accent); font-weight: 800; background: var(--bg); border-radius: 3px; }
.bp b { text-align: center; font-variant-numeric: tabular-nums; border-radius: 4px; background: var(--bg); }
.bp.won { font-weight: 700; }
.bp.won b { background: var(--up); color: #fff; }
.bp.lost .nm { color: var(--muted); }
.bp.hit .nm { color: #c28a00; font-weight: 800; }

.groups { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.group { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.group h4 { margin: 0 0 8px; }
.standings { width: 100%; border-collapse: collapse; font-size: .82rem; margin-bottom: 10px; }
.standings th, .standings td { padding: 5px 4px; border-bottom: 1px solid var(--line); text-align: center; }
.standings th { font-size: .7rem; color: var(--muted); }
.standings td.nm { text-align: left; cursor: pointer; }
.standings td.nm small { color: var(--muted); }
.standings tr.hit td { color: #c28a00; font-weight: 800; }
.gmatches { display: grid; gap: 6px; }
.gmatches.extra { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.extra-h { margin: 18px 0 8px; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

/* Artículo */
dialog { width: min(820px, 94vw); max-height: 90vh; border: 0; border-radius: 16px; padding: 0;
  background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog .close { position: sticky; top: 8px; float: right; margin: 8px; border: 0; width: 36px; height: 36px;
  border-radius: 50%; font-size: 1.4rem; cursor: pointer; background: var(--line); color: var(--ink); }
#article-body { padding: 0 24px 24px; line-height: 1.6; }
#article-body img { max-width: 100%; height: auto; border-radius: 8px; }
#article-body .cover { width: calc(100% + 48px); margin: 0 -24px 16px; border-radius: 0; }
