:root {
  --navy: #192b4d;
  --navy-deep: #07192f;
  --green: #008536;
  --lime: #dada00;
  --paper: #f5f9fc;
  --card: #fff;
  --ink: #112b55;
  --muted: #647b9e;
  --line: #dbe6f0;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--paper); }
body { min-width: 320px; margin: 0; color: var(--ink); background: radial-gradient(circle at 84% 32%, rgba(218,218,0,.15), transparent 21rem), linear-gradient(180deg,#fbfdff,var(--paper) 36rem); font-family: "Fira Sans", Inter, Arial, sans-serif; }
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: wait; opacity: .7; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--lime); outline-offset: 3px; }

.shell { width: min(1560px, 100%); margin: 0 auto; padding: 30px 22px 62px; }
.top-layout { display: grid; grid-template-columns: minmax(0,1fr) 280px; gap: 22px; align-items: stretch; }

.hero {
  position: relative;
  display: grid;
  grid-template-columns: 220px minmax(0,1fr) auto;
  gap: 22px;
  align-items: center;
  min-height: 190px;
  overflow: hidden;
  padding: 22px 30px;
  color: #fff;
  border-radius: 20px 20px 28px 20px;
  background-color: var(--navy-deep);
  background-image: linear-gradient(90deg, rgba(5,20,40,.98) 0%, rgba(11,31,59,.9) 34%, rgba(10,32,59,.37) 68%, rgba(9,28,53,.78) 100%), url("/assets/hero-race-v1.png");
  background-position: center, center;
  background-size: cover;
  box-shadow: 0 24px 56px rgba(20,50,89,.23);
}

.hero-logo-official { position: relative; z-index: 1; display: block; width: 220px; height: 150px; object-fit: contain; }
.hero-copy, .hero-actions { position: relative; z-index: 1; }
.eyebrow, .section-kicker { margin: 0; font-size: .73rem; font-weight: 850; letter-spacing: .19em; text-transform: uppercase; }
.eyebrow { color: var(--lime); text-transform: none; }
.eyebrow span + span { margin-left: .42em; }
.hero h1 { margin: 6px 0 8px; font-size: clamp(2.1rem,3.7vw,3.45rem); line-height: .98; letter-spacing: -.047em; }
.hero p:not(.eyebrow) { max-width: 570px; margin: 0; color: #e7eef9; font-size: .9rem; line-height: 1.45; }
.hero-actions { display: flex; min-width: 152px; flex-direction: column; align-items: flex-end; gap: 13px; }
.hero-actions button, .search button { min-height: 44px; border: 0; border-radius: 10px; font-weight: 900; cursor: pointer; transition: transform .16s ease, box-shadow .16s ease, background-color .16s ease; }
.hero-actions button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 145px; padding: 0 16px; color: #102644; background: linear-gradient(135deg,#e7e900,var(--lime) 48%,#becc00); box-shadow: 0 7px 16px rgba(0,0,0,.23); }
.hero-actions button:hover, .search button:hover { transform: translateY(-2px); }
.hero-actions button:disabled { cursor: wait; opacity: .72; transform: none; }
.hero-actions button span { font-size: 1.2rem; line-height: 1; }
.hero-actions #updated { margin-top: 2px; color: #e4edf8; font-size: .82rem; font-weight: 650; text-align: right; }

.ranking-layout { display: block; margin-top: 22px; }
.panel { background: var(--card); border: 1px solid #d9e5f0; border-radius: 18px; box-shadow: 0 17px 40px rgba(19,51,89,.1); }
.ranking-panel { padding: 28px 30px 24px; border-color: #a8ec34; box-shadow: 0 21px 48px rgba(0,133,54,.14); }
.panel-head { display: flex; align-items: center; gap: 15px; min-height: 72px; padding: 0 7px 17px; border-bottom: 1px solid var(--line); }
.section-kicker { color: #6d83a6; }
.panel h2 { margin: 5px 0 0; font-size: 2.7rem; letter-spacing: -.055em; }
.badge { display: inline-flex; align-items: center; gap: 9px; flex: 0 0 auto; padding: 10px 16px; color: #087a39; border-radius: 999px; background: #e9f9e9; font-size: .79rem; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.badge::before { width: 10px; height: 10px; content: ""; border-radius: 50%; background: #0eb950; box-shadow: 0 0 0 4px rgba(14,185,80,.12); }
.panel-claim { margin: 0 0 0 auto; padding-left: 21px; color: #7084a5; border-left: 2px solid #dfe8f1; font-size: .7rem; font-weight: 850; letter-spacing: .18em; text-align: right; }

.podium { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 0; align-items: end; margin: 22px 0 14px; padding: 0; list-style: none; }
.podium[data-count="1"] { grid-template-columns: minmax(0,440px); justify-content: center; }
.podium[data-count="2"] { grid-template-columns: repeat(2,minmax(0,440px)); justify-content: center; }
.podium-step { display: grid; justify-items: center; align-content: center; gap: 5px; min-width: 0; min-height: 172px; margin: 0 8px; padding: 19px 12px; border: 1px solid #e1e9f1; border-radius: 16px; background: #f8fafc; text-align: center; }
.podium-step.place-1 { order: 2; min-height: 194px; border-color: #dfad00; background: linear-gradient(180deg,#ffd866,#fff3b6); box-shadow: 0 12px 28px rgba(187,139,0,.2); }
.podium-step.place-2 { order: 1; border-color: #9aa4b1; background: linear-gradient(180deg,#d8dde3,#f4f5f6); box-shadow: 0 10px 24px rgba(74,86,101,.13); }
.podium-step.place-3 { order: 3; border-color: #b96540; background: linear-gradient(180deg,#df9367,#f8ddd0); box-shadow: 0 10px 24px rgba(138,73,42,.14); }
.podium[data-count="1"] .podium-step, .podium[data-count="2"] .podium-step { order: 0; }
.podium-medal { display: block; flex: 0 0 auto; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; font-size: 2.5rem; line-height: 1; filter: drop-shadow(0 3px 4px rgba(25,43,77,.18)); }
.place-1 .podium-medal { font-size: 3.15rem; }
.podium-alias { max-width: 100%; overflow-wrap: anywhere; color: #102f61; font-size: 1.3rem; font-weight: 900; }
.place-1 .podium-alias { font-size: 1.42rem; }
.podium-net { color: #007b38; font-size: 1.15rem; font-weight: 900; }
.place-1 .podium-net { font-size: 1.28rem; }
.podium-label { color: #647b9e; font-size: .68rem; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.podium-step.is-searched { outline: 3px solid var(--green); outline-offset: 2px; }

.search-result { margin: 18px 6px 0; }
.result-card { display: flex; align-items: center; gap: 22px; padding: 16px 20px; border: 2px solid var(--green); border-radius: 14px; background: linear-gradient(90deg,#eefaf1,#fff); }
.result-position { display: grid; justify-items: center; min-width: 96px; padding-right: 20px; border-right: 1px solid #cfe7d6; }
.result-position small { color: #536d96; font-size: .65rem; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.position-fraction { display: inline-flex; align-items: baseline; justify-content: center; gap: 0; white-space: nowrap; }
.result-position strong { color: var(--green); font-size: 3.1rem; font-weight: 900; line-height: 1; }
.result-position span { color: #536d96; font-size: 1.02rem; font-weight: 850; }
.result-body { min-width: 0; }
.result-alias { margin: 0 0 6px; color: #102f61; font-size: 1.05rem; font-weight: 750; overflow-wrap: anywhere; }
.result-alias.is-outside-top-ten { margin: 6px 0 0; font-size: 1rem; font-weight: 500; }
.result-goal { margin: 0; color: #17366a; font-size: .97rem; }
.result-goal.is-distance { color: #087a39; font-size: 1.12rem; font-weight: 850; }
.race-dots { display: flex; gap: 10px; margin: 0; padding: 0; list-style: none; }
.race-dots li { display: grid; width: 46px; height: 46px; place-items: center; color: #647b9e; border: 2px dashed #b9c7d8; border-radius: 50%; font-weight: 900; }
.race-dots li.is-done { color: #fff; border: 2px solid var(--green); background: var(--green); }
.result-message { margin: 0; padding: 13px 16px; color: #17366a; border-left: 5px solid var(--lime); border-radius: 10px; background: #f2f6fa; font-weight: 700; }

.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; min-width: 0; border-collapse: separate; border-spacing: 0 6px; table-layout: fixed; }
th { padding: 15px 10px; color: #536d96; background: #edf3f9; font-size: .7rem; font-weight: 900; letter-spacing: .055em; text-align: center; text-transform: uppercase; white-space: nowrap; }
th:first-child { border-radius: 10px 0 0 10px; }
th:last-child { border-radius: 0 10px 10px 0; }
td { padding: 15px 10px; color: #17366a; border-bottom: 1px solid #e1e9f1; font-size: .97rem; font-weight: 700; text-align: center; white-space: nowrap; }
th:nth-child(1), td:nth-child(1), th:nth-child(2), td:nth-child(2), th:nth-child(3), td:nth-child(3) { width: 33.333%; }
tbody tr { transition: transform .15s ease, background-color .15s ease; }
tbody tr:hover td { background: #f4faf5; }
.rank-1 td { background: linear-gradient(90deg,#fff8d1,#fffdf3); border-bottom-color: #f3e3a7; }
.rank-2 td { background: #f2f6fa; }
.rank-3 td { background: #fff5f0; }
.rank-position { display: inline-grid; flex: 0 0 auto; width: 43px; height: 43px; place-items: center; color: var(--navy); border-radius: 50%; background: #e6edf5; font-size: 1.1rem; font-weight: 900; }
.rank-1 .rank-position { color: #fff; background: linear-gradient(135deg,#a76c05,#ead400); box-shadow: 0 4px 9px rgba(174,126,10,.3); }
.rank-2 .rank-position { color: #fff; background: linear-gradient(135deg,#6e7c8c,#c9d2da); box-shadow: 0 4px 9px rgba(82,100,120,.2); }
.rank-3 .rank-position { color: #fff; background: linear-gradient(135deg,#96532d,#dea06c); box-shadow: 0 4px 9px rgba(150,83,45,.19); }
.alias-cell { position: relative; color: #102f61; font-size: 1.06rem; font-weight: 900; overflow-wrap: anywhere; }
.alias-text { display: inline-block; max-width: 100%; }
.net-cell { color: #007b38; font-size: 1.12rem; font-weight: 900; }
#empty { margin: 19px 6px 6px; color: var(--muted); text-align: center; }
.ranking-footer { display: flex; justify-content: flex-end; align-items: center; gap: 16px; margin-top: 16px; padding: 18px 6px 0; color: #627b9e; border-top: 1px solid var(--line); font-size: .79rem; }
.ranking-footer span:last-child { font-size: .68rem; font-weight: 850; letter-spacing: .15em; }
.search-summary { margin: 16px 6px 4px; padding: 13px 16px; color: #fff; border-left: 5px solid var(--lime); border-radius: 10px; background: var(--navy); font-size: 1rem; font-weight: 750; line-height: 1.4; }
.tie-badge { display: inline-block; margin: 0 8px 0 0; padding: 3px 8px; color: var(--navy); border: 1px solid #7f95b1; border-radius: 999px; background: #f7fafc; font-size: .68rem; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; vertical-align: middle; }
.alias-cell .tie-badge-compact { position: absolute; top: 50%; left: 8px; margin: 0; padding: 2px 5px; font-size: .56rem; letter-spacing: .04em; line-height: 1; transform: translateY(-50%); }
tbody tr.is-tied td { background: linear-gradient(90deg,#f1faf2,#fbfdfb); border-bottom-color: #cfe7d6; }
tbody tr.is-tied td:first-child { box-shadow: inset 4px 0 0 #a7e830; }
tbody tr.is-searched td { background: #e9f9e9; border-top: 2px solid var(--green); border-bottom: 2px solid var(--green); }
.gap-row td { padding: 4px; color: var(--muted); border-bottom: 0; background: transparent; font-size: 1.2rem; letter-spacing: .3em; }

.search { position: relative; min-height: 292px; overflow: hidden; padding: 24px 23px; }
.search > :not(.search-mark) { position: relative; z-index: 2; }
.search-icon { float: left; display: grid; width: 40px; height: 40px; place-items: center; margin: 0 12px 11px 0; color: #fff; border-radius: 50%; background: var(--navy); box-shadow: 0 7px 15px rgba(25,43,77,.2); font-size: 1.7rem; line-height: 1; }
.search .section-kicker { padding-top: 3px; }
.search h2 { min-height: 29px; margin: 3px 0 19px; font-size: 1.35rem; }
.search > p:not(.section-kicker) { clear: both; margin: 0 0 17px; color: #49678f; font-size: .88rem; font-weight: 600; line-height: 1.45; }
.search label { display: block; margin-bottom: 8px; color: #496689; font-size: .73rem; font-weight: 900; letter-spacing: .1em; }
.search-row { display: flex; gap: 11px; }
.search input { width: 100%; min-width: 0; min-height: 44px; border: 1px solid #b7c8db; border-radius: 10px; padding: 0 11px; color: var(--navy); background: #fff; font-size: .9rem; }
.search button { flex: 0 0 auto; min-width: 91px; padding: 0 13px; color: #fff; background: linear-gradient(135deg,#008536,#006c2e); box-shadow: 0 6px 13px rgba(0,133,54,.22); }
.search-mark { position: absolute; z-index: 0; right: -17px; bottom: -33px; display: block; width: 122px; max-width: 122px; height: 149px; max-height: 149px; object-fit: contain; opacity: .1; pointer-events: none; }

/* La consulta acompaña al hero; la tabla queda a ancho completo debajo. */
.top-layout .search {
  min-height: 190px;
  padding: 18px 20px;
  color: #fff;
  border-color: rgba(255,255,255,.18);
  background-color: var(--navy-deep);
  background-image: linear-gradient(90deg, rgba(7,25,47,.91), rgba(18,48,83,.77)), url("/assets/hero-race-v1.png");
  background-position: center, right center;
  background-size: cover;
  box-shadow: 0 24px 56px rgba(20,50,89,.23);
  text-align: center;
}
.top-layout .search > :not(.search-mark) { z-index: 2; }
.top-layout .search-icon { float: none; width: 34px; height: 34px; margin: 0 auto 5px; color: var(--navy); background: #fff; box-shadow: none; font-size: 1.35rem; }
.top-layout .search .section-kicker { padding-top: 0; color: #dce7f4; font-size: .62rem; text-align: center; }
.top-layout .search h2 { min-height: 25px; margin: 2px 0 9px; color: #fff; font-size: 1.16rem; text-align: center; }
.top-layout .search > p:not(.section-kicker) { margin: 0 0 9px; color: #e4ecf7; font-size: .73rem; line-height: 1.35; text-align: center; }
.top-layout .search form { width: 100%; }
.top-layout .search label { margin-bottom: 4px; color: #dce7f4; font-size: .64rem; text-align: center; }
.top-layout .search-row { gap: 7px; }
.top-layout .search input { min-height: 44px; border: 1px solid rgba(255,255,255,.58); padding: 0 9px; font-size: 16px; }
.top-layout .search button { min-width: 76px; min-height: 44px; padding: 0 10px; font-size: .8rem; }
.top-layout .search-mark { right: -8px; bottom: -28px; width: 102px; height: 123px; opacity: .09; }
.admin, dialog { display: none; }

@media (max-width: 1190px) {
  .shell { padding: 24px 20px 48px; }
  .top-layout { grid-template-columns: minmax(0,1fr) 270px; gap: 20px; }
  .hero { grid-template-columns: 195px minmax(0,1fr) auto; gap: 16px; padding: 20px; }
  .hero-logo-official { width: 195px; height: 132px; }
  .hero h1 { font-size: clamp(2rem,3.6vw,3rem); }
  .panel-claim { display: none; }
}

@media (max-width: 910px) {
  .top-layout { grid-template-columns: 1fr; }
  .hero { grid-template-columns: 185px minmax(0,1fr); min-height: 170px; }
  .hero-logo-official { width: 185px; height: 122px; }
  .hero-actions { grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: space-between; }
  .hero-actions #updated { text-align: left; }
  .search { min-height: 270px; }
  .top-layout .search { min-height: 158px; }
}

@media (max-width: 620px) {
  .shell { padding: 10px 10px 34px; }
  .hero { grid-template-columns: 1fr; gap: 12px; min-height: 0; padding: 22px 20px 19px; border-radius: 17px; background-position: center, 62% center; }
  .hero-logo-official { width: 185px; height: 122px; margin-bottom: 3px; }
  .hero-copy { justify-self: center; text-align: center; }
  .eyebrow { line-height: 1.35; text-align: center; }
  .eyebrow span { display: block; }
  .eyebrow span + span { margin-left: 0; }
  .hero h1 { max-width: 275px; font-size: 2.3rem; }
  .hero p:not(.eyebrow) { max-width: 290px; font-size: .91rem; }
  .hero-actions { align-items: stretch; flex-direction: column; }
  .hero-actions button { width: 100%; }
  .hero-actions #updated { text-align: center; }
  .ranking-layout { margin-top: 16px; }
  .ranking-panel { border-radius: 16px; padding: 22px 18px; }
  .podium { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px 0; margin: 16px 0 8px; }
  .podium-step { min-height: 172px; margin: 0 8px; padding: 19px 12px; }
  .podium-step.place-1 { min-height: 194px; }
  .podium-step.place-1 { grid-column: 1 / -1; order: 0; }
  .podium-step.place-2 { order: 1; }
  .podium-step.place-3 { order: 2; }
  .podium[data-count="1"], .podium[data-count="2"] { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .podium[data-count="1"] .podium-step { grid-column: 1 / -1; }
  .podium-medal { font-size: 2.2rem; }
  .place-1 .podium-medal { font-size: 2.75rem; }
  .podium-alias { font-size: 1.06rem; }
  .place-1 .podium-alias { font-size: 1.18rem; }
  .podium-net { font-size: .96rem; }
  .place-1 .podium-net { font-size: 1.08rem; }
  .search-result { margin: 14px 0 0; }
  .result-card { align-items: stretch; flex-direction: column; gap: 12px; }
  .result-position { grid-template-columns: auto auto; justify-content: start; align-items: baseline; gap: 0 8px; padding: 0 0 10px; border-right: 0; border-bottom: 1px solid #cfe7d6; }
  .result-position small { grid-column: 1 / -1; }
  .search { border-radius: 16px; padding: 18px; }
  .panel-head { align-items: center; flex-wrap: nowrap; gap: 10px; min-height: 58px; padding: 0 0 13px; }
  .panel h2 { margin-top: 0; font-size: 2.25rem; line-height: 1; }
  .badge { padding: 8px 10px; font-size: .66rem; }
  .badge::before { width: 8px; height: 8px; }
  .table-wrap { overflow: visible; }
  table { min-width: 0; border-spacing: 0 4px; }
  th { padding: 11px 4px; font-size: .59rem; letter-spacing: .04em; white-space: normal; }
  td { padding: 12px 4px; font-size: .82rem; white-space: normal; }
  .rank-position { width: 36px; height: 36px; font-size: .96rem; }
  .alias-cell { font-size: .88rem; }
  .net-cell { font-size: .91rem; }
  .tie-badge { margin-right: 4px; padding: 2px 5px; font-size: .52rem; letter-spacing: .025em; }
  .alias-cell .tie-badge-compact { left: 3px; margin: 0; font-size: .48rem; }
  .gap-row td { padding: 4px; }
  .search-summary { margin: 12px 0 0; font-size: .92rem; }
  .ranking-footer { align-items: flex-start; flex-direction: column; gap: 7px; }
  .top-layout .search { min-height: 166px; padding: 17px 18px; }
  .top-layout .search h2 { margin-bottom: 8px; font-size: 1.14rem; }
  .top-layout .search > p:not(.section-kicker) { margin-bottom: 8px; font-size: .74rem; }
  .search h2 { margin-bottom: 17px; }
  .search-row { gap: 8px; }
  .search button { min-width: 94px; padding: 0 13px; }
  .search-mark { width: 135px; max-width: 135px; height: 165px; max-height: 165px; }
}

@media print {
  body { background: #fff; }
  .shell { width: 100%; padding: 0; }
  .hero { min-height: auto; color: var(--navy); border: 1px solid var(--line); background: #fff; box-shadow: none; }
  .search-mark { display: none !important; }
  .hero p:not(.eyebrow), .hero-actions #updated { color: #334966; }
  .hero-actions button { display: none; }
  .ranking-layout { grid-template-columns: 1fr; }
  .panel { break-inside: avoid; box-shadow: none; }
  .table-wrap { overflow: visible; }
}
