:root {
  color-scheme: dark;
  --bg: #0d0c0b; --side: #100f0d; --card: #181613; --card-2: #211e19; --line: #322d25;
  --ink: #f1ebdf; --dim: #aba294; --gold: #d9a441; --gold-dim: #6b5225;
  --red: #b5382c; --ok: #58b368; --bad: #ef6b5e; --idle: #b9a88a;
  --head: "Bahnschrift SemiCondensed", Bahnschrift, Rajdhani, "Roboto Condensed", "Arial Narrow", sans-serif;
  --text: "Segoe UI", Inter, Roboto, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--text); }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-family: var(--head); font-weight: 600; line-height: 1.15; text-wrap: balance; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 8px; top: 8px; z-index: 50; background: var(--gold); color: #000; padding: 8px 12px; }

/* Navegacion */
.side { position: fixed; inset: 0 auto 0 0; width: 232px; background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; z-index: 20; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 12px; padding: 22px 18px; text-decoration: none; }
.brand b { display: block; font: 600 1.25rem/1.1 var(--head); color: var(--gold); }
.brand small { color: var(--dim); font-size: .75rem; }
.side nav { flex: 1; padding: 4px 10px; }
.side nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 6px; text-decoration: none; color: var(--dim); transition: background .15s, color .15s; }
.side nav svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.side nav a:hover { background: var(--card); color: var(--ink); }
.side nav a[aria-current] { background: var(--card-2); color: var(--gold); font-weight: 600; }
.side-foot { padding: 16px 20px; font-size: .75rem; color: var(--dim); border-top: 1px solid var(--line); }
.side-foot b { color: var(--ink); }
.menu { display: none; }

main { margin-left: 232px; padding: 32px clamp(16px, 3vw, 44px) 64px; max-width: 1480px; }
.page-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head h1 { font-size: 2.1rem; }
.page-head p, .card > p { color: var(--dim); }
.card > p { font-size: .85rem; margin: 2px 0 12px; } .card > p:last-child { margin-bottom: 0; }
.sect { font-size: 1.35rem; margin: 34px 0 14px; }
.btn { border: 1px solid var(--gold-dim); color: var(--gold); text-decoration: none; padding: 9px 16px; border-radius: 6px; }
.btn:hover { background: var(--card-2); }
.stale { border: 1px solid var(--red); background: #2a1512; color: #ffd9d3; border-radius: 8px; padding: 11px 16px; margin-bottom: 20px; }
[hidden] { display: none !important; }

/* Portada */
.hero { position: relative; overflow: hidden; border-radius: 12px; min-height: clamp(220px, 30vw, 340px); display: flex; align-items: end; margin-bottom: 18px;
  background: radial-gradient(90% 130% at 82% 40%, #4a2a1a 0%, #1b130e 45%, #0f0d0b 100%); }
.hero video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 35%; opacity: 0; transition: opacity .9s; }
.hero video.on { opacity: .75; }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(13,12,11,.88), rgba(13,12,11,.1) 65%), linear-gradient(0deg, rgba(13,12,11,.75), transparent 60%); }
.hero-in { position: relative; z-index: 1; padding: clamp(20px, 3vw, 40px); }
.hero h1 { font-size: clamp(2.4rem, 6vw, 4.4rem); color: var(--gold); }
.hero p { font-size: 1.1rem; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; }
.tile span { color: var(--dim); font-size: .85rem; display: block; }
.tile strong { font: 600 2rem/1.2 var(--head); display: block; }
.tile small { color: var(--dim); }
.tile.ok strong { color: var(--ok); } .tile.bad strong { color: var(--bad); }

.boards { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 14px; margin-bottom: 18px; }
.board { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 18px; text-decoration: none; transition: border-color .15s; }
.board:hover { border-color: var(--gold-dim); }
.board h3 { font-size: 1.15rem; color: var(--gold); }
.board p { color: var(--dim); font-size: .8rem; margin-bottom: 12px; }
.board ol { list-style: none; margin: 0; padding: 0; }
.board li { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; align-items: baseline; gap: 2px 6px; padding: 7px 0; }
.board i { font: 600 1rem var(--head); color: var(--dim); }
.board b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.board em { font-style: normal; color: var(--dim); font-variant-numeric: tabular-nums; font-size: .88rem; }
.board u { grid-column: 2 / -1; height: 4px; border-radius: 0 2px 2px 0; width: var(--w); background: var(--gold-dim); }
.board li:first-child u { background: var(--gold); } .board li:first-child i { color: var(--gold); }
.board .none { display: block; color: var(--dim); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 20px; margin-bottom: 18px; min-width: 0; }
.card h2 { font-size: 1.2rem; }
.card.flush { padding: 0; overflow: hidden; } .card.flush h2 { padding: 18px 20px 12px; }
.cnt { color: var(--dim); font-weight: 400; }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 18px; }

/* Controles */
.bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.chip, .search, select { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 8px 14px; min-height: 40px; }
.chip { cursor: pointer; } .chip:hover { border-color: var(--gold-dim); }
.chip[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: #17120a; font-weight: 600; }
.search { margin-left: auto; width: min(100%, 240px); } .search::placeholder { color: var(--dim); }
.pick { color: var(--dim); display: flex; gap: 10px; align-items: center; }

/* Tablas */
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 16px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--card-2); }
th { font-size: .8rem; font-weight: 600; color: var(--dim); background: var(--card-2); white-space: nowrap; }
.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td b { font-weight: 600; } td small, li small { color: var(--dim); }
.sortable th:not([data-nosort]) { cursor: pointer; user-select: none; } .sortable th:not([data-nosort]):hover { color: var(--ink); }
th[data-sorted]::after { content: " ↓"; color: var(--gold); } th[data-sorted="asc"]::after { content: " ↑"; }
.up { color: var(--ok); } .down { color: var(--bad); }
.pos { width: 56px; color: var(--dim); } .wide { width: 38%; }
tr.medal .pos { color: var(--gold); font-weight: 600; }
.why { color: var(--dim); font-size: .88rem; min-width: 260px; }
.rk { display: inline-block; min-width: 34px; text-align: center; border-radius: 4px; padding: 1px 6px; font-size: .8rem; font-weight: 600; background: var(--card-2); color: var(--dim); }
.rk.r5 { background: var(--gold); color: #17120a; } .rk.r4 { background: #cfc6b5; color: #17120a; } .rk.r3 { color: var(--ink); background: #3b352b; }
.st::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; background: var(--idle); }
.st { white-space: nowrap; } .st.ok::before { background: var(--ok); } .st.bad::before { background: var(--bad); border-radius: 1px; } .st.idle::before { background: transparent; box-shadow: inset 0 0 0 2px var(--idle); }
summary { cursor: pointer; } summary::marker { color: var(--bad); }
details ul { margin: 6px 0 2px; padding-left: 18px; color: var(--dim); font-size: .88rem; }
.spark { width: 92px; height: 24px; display: block; } .spark polyline { fill: none; stroke: var(--gold); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.meter { display: block; height: 8px; border-radius: 4px; background: #372b16; min-width: 80px; overflow: hidden; } .meter i { display: block; height: 100%; background: var(--gold); border-radius: 4px; }
td:has(.meter) { vertical-align: middle; }
.empty td { color: var(--dim); text-align: center; padding: 28px; }

/* Graficas */
.chart { position: relative; min-height: 220px; } .chart svg { display: block; width: 100%; overflow: visible; }
.chart text { fill: var(--dim); font: 12px var(--text); font-variant-numeric: tabular-nums; } .chart text.val { fill: var(--ink); font-weight: 600; }
.grid { stroke: var(--line); } .ln { fill: none; stroke: var(--gold); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; } .ar { fill: var(--gold); opacity: .1; }
.dot { fill: var(--gold); stroke: var(--card); stroke-width: 2; } .cross { stroke: var(--dim); } .col { fill: var(--gold); } .hit { fill: transparent; } .hit:hover + .col, .hit:focus + .col { fill: #f0c46d; }
.tip { position: absolute; pointer-events: none; background: #000; border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; font-size: .82rem; white-space: nowrap; transform: translate(-50%, -100%); z-index: 5; } .tip b { display: block; }
.hb { display: grid; grid-template-columns: minmax(80px, 34%) 1fr auto; gap: 10px; align-items: center; padding: 5px 0; } .hb span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .hb u { height: 14px; border-radius: 0 4px 4px 0; background: var(--gold); } .hb em { font-style: normal; font-variant-numeric: tabular-nums; }
.lv .hb { grid-template-columns: 64px 1fr auto; }

/* Comandos y articulo */
code { font-family: Consolas, monospace; background: #0f0e0c; border: 1px solid var(--line); border-radius: 4px; padding: 2px 7px; color: var(--gold); white-space: nowrap; }
.cmds code { cursor: copy; } code.done { color: var(--ok); } .card h2 + .scroll { margin-top: 12px; }
.cmds { table-layout: fixed; min-width: 680px; }
.cmds th:first-child { width: 42%; }
.article { padding: clamp(20px, 4vw, 48px); background: linear-gradient(160deg, #221811, var(--card) 55%); }
.article .kicker { color: var(--gold); margin-bottom: 8px; } .article h2.title { font-size: 1.6rem; margin-bottom: 18px; }
.article .body { max-width: 68ch; line-height: 1.7; } .article .body p { margin-bottom: 1em; } .article .closing { color: var(--dim); font-style: italic; }
#art-r4-r5 { scroll-margin-top: 20px; }

.intro { position: fixed; inset: 0; background: #000; z-index: 99; } .intro video { width: 100%; height: 100%; object-fit: cover; }
.intro button { position: absolute; right: 24px; bottom: 24px; font: inherit; color: var(--ink); background: rgba(0,0,0,.7); border: 1px solid var(--gold); border-radius: 6px; padding: 10px 20px; cursor: pointer; }

@media (max-width: 860px) {
  .side { transform: translateX(-100%); transition: transform .2s; visibility: hidden; } .side.open { transform: none; visibility: visible; box-shadow: 0 0 0 100vmax rgba(0,0,0,.6); }
  .menu { display: block; position: fixed; right: 14px; bottom: 14px; z-index: 30; font: 600 1rem var(--text); background: var(--gold); color: #17120a; border: 0; border-radius: 24px; padding: 12px 22px; box-shadow: 0 4px 16px rgba(0,0,0,.5); }
  main { margin-left: 0; padding: 18px 16px 90px; }
  .sm { display: none; } th, td { padding: 9px 10px; } .tiles { grid-template-columns: 1fr 1fr; gap: 10px; } .tile { padding: 12px 14px; } .tile strong { font-size: 1.55rem; }
  .search { margin-left: 0; width: 100%; } .page-head h1 { font-size: 1.7rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
