/* Componentes de la web. Los colores salen de tokens.css (diseño: design/prototipo.html). */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  background: var(--bg); color: var(--text);
  font-family: var(--font-body); font-size: 15px; line-height: 1.45;
  display: flex; flex-direction: column;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; margin: 0; text-wrap: balance; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.shell { width: 100%; max-width: 640px; margin: 0 auto; flex: 1; display: flex; flex-direction: column; }
.gutter { padding-left: max(14px, env(safe-area-inset-left, 0px)); padding-right: max(14px, env(safe-area-inset-right, 0px)); }

/* Barra superior */
.app-bar { background: var(--brand); color: var(--on-brand); padding-top: calc(14px + env(safe-area-inset-top, 0px)); padding-bottom: 12px; }
.app-bar .inner { max-width: 640px; margin: 0 auto; display: grid; gap: 2px; }
.logo { font-family: var(--font-display); font-weight: 700; font-size: 20px; letter-spacing: .02em; display: inline-flex; align-items: center; gap: 8px; }
/* Los dos logos con la misma altura; el ancho es el de cada uno. El título queda centrado. */
.app-bar .inner.brand-row { justify-items: center; }
.brand-home { display: block; }
.brand-logo { display: block; height: 76px; width: auto; }
.app-bar small { color: var(--on-brand-2); font-size: 12.5px; }
.back { display: inline-grid; place-items: center; width: 36px; height: 36px; margin-left: -8px; border-radius: 10px; color: var(--on-brand); }
.back:hover { background: color-mix(in srgb, var(--on-brand) 12%, transparent); }
.back svg { width: 20px; height: 20px; }
.app-bar.flat { padding-bottom: 4px; }
.app-bar .inner.bar-row { display: grid; grid-template-columns: 1fr minmax(0, auto) 1fr; align-items: center; gap: 12px; }
.app-bar .bar-row .back { justify-self: start; }
.app-bar .bar-title { font-family: var(--font-display); font-weight: 700; font-size: 17px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-bar .when { justify-self: end; font-size: 13px; color: var(--on-brand-2); white-space: nowrap; }
.hero .meta .tour-short { font-weight: 600; color: var(--on-brand); }

/* Listados */
.content { padding-top: 14px; padding-bottom: 24px; display: grid; gap: 14px; align-content: start; flex: 1; }
.day { display: grid; gap: 8px; }
.day-label { font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); padding-inline: 2px; }
.match { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px; display: grid; grid-template-columns: 56px 1fr; gap: 4px 12px; }
a.match:hover { border-color: var(--border-strong); }
.match .time { font-family: var(--font-display); font-size: 26px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; grid-row: span 3; padding-top: 2px; }
.match .tour { font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.match .foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
.match .foot .go { font-size: 13px; font-weight: 600; color: var(--primary); }
.match .foot .note { font-size: 13px; color: var(--text-3); }
.match .foot > :last-child { margin-left: auto; }
.match.past { grid-template-columns: 1fr; }
.pair { font-weight: 600; font-size: 16px; line-height: 1.3; min-width: 0; }
.pair .vsw { font-weight: 500; color: var(--text-3); font-size: 14px; padding-inline: 2px; }
.pair .sc { font-family: var(--font-display); font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-2); }
.pair.result { display: grid; grid-template-columns: 1fr auto auto auto 1fr; align-items: center; gap: 6px; }
.pair.result .t:last-child { text-align: right; }
.pair.result .t { color: var(--text-2); font-weight: 500; }
.pair.result .t.win, .pair.result .sc.win { color: var(--text); font-weight: 700; }

.filters { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin-inline: -14px; padding-inline: 14px; }
.filters a { flex: none; border: 1px solid var(--border-strong); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 13.5px; color: var(--text-2); white-space: nowrap; }
.filters a[aria-current="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.more { justify-self: center; font-weight: 600; color: var(--primary); padding: 8px 14px; }
.nothing { text-align: center; color: var(--text-2); padding: 40px 12px; }

/* Partido */
.hero { background: var(--brand); color: var(--on-brand); padding-top: 4px; padding-bottom: 16px; }
.hero .inner { max-width: 640px; margin: 0 auto; display: grid; gap: 12px; }
.hero .meta { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 13px; color: var(--on-brand-2); align-items: center; }
.vs { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.vs .name { font-family: var(--font-display); font-size: 24px; font-weight: 700; line-height: 1.05; min-width: 0; overflow-wrap: anywhere; }
.vs .name:last-child { text-align: right; }
.vs .mid { font-family: var(--font-display); font-size: 15px; color: var(--on-brand-2); font-weight: 600; white-space: nowrap; }
.vs .mid b { font-size: 26px; color: var(--on-brand); padding-inline: 4px; }

.other-live { display: flex; align-items: center; gap: 10px; background: var(--live-soft); color: var(--live-text); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; font-weight: 500; }
.other-live b { font-weight: 600; }
.other-live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--live); flex: none; }

.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: transparent; border-radius: 8px; padding: 8px 6px; cursor: pointer; font-weight: 600; font-size: 14.5px; color: var(--text-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.players { display: grid; gap: 12px; }
.players[hidden] { display: none; }

.player { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.player-head { padding: 10px 12px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 16px; line-height: 1.15; }
.hcols { display: grid; grid-template-columns: 1fr 1fr; }
.hcol { padding: 2px 12px 2px; min-width: 0; }
.hcol + .hcol { border-left: 1px solid var(--border); background: var(--bg); }
.horses { list-style: none; margin: 0; padding: 0; }
.horse { display: grid; grid-template-columns: 1fr; padding-block: 6px; min-width: 0; }
.horse + .horse { border-top: 1px solid var(--border); }
.horse.has-ch { grid-template-columns: 16px 1fr; column-gap: 6px; }
.horse.has-ch .ch { grid-row: 1 / span 2; font-family: var(--font-display); font-weight: 600; font-size: 15px; color: var(--text-3); line-height: 1.3; font-variant-numeric: tabular-nums; }
.horse.has-ch .hline, .horse.has-ch .pel { grid-column: 2; }
.horse .hline { min-width: 0; }
.horse .aaccp { display: inline-block; width: auto; height: 13px; vertical-align: -1px; margin-left: 3px; }
.horse .hname { font-weight: 600; font-size: 14.5px; line-height: 1.3; overflow-wrap: anywhere; }
.horse .ped { color: var(--primary); text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: 3px; }
.horse .ped:hover { text-decoration-color: currentColor; }
.horse .pel { font-size: 12.5px; color: var(--text-3); min-height: 1em; }

.empty { background: var(--surface); border: 1px dashed var(--border-strong); border-radius: 14px; padding: 22px 18px; display: grid; justify-items: center; text-align: center; gap: 10px; }
.empty svg { width: 52px; height: 52px; }
.empty .empty-logo { width: auto; height: 60px; }
.empty h3 { font-size: 21px; }
.lineup { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; display: grid; padding-bottom: 6px; }
.lineup h4 { margin: 0; padding: 10px 12px 4px; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); font-weight: 600; }
.lineup .row { padding: 6px 12px; font-size: 14.5px; }

/* Secciones del partido (Caballos / Partido) y datos del partido */
.views { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: -16px; border-top: 1px solid color-mix(in srgb, var(--on-brand) 12%, transparent); }
.views button { border: 0; background: transparent; cursor: pointer; padding: 11px 6px 10px; font-weight: 600; font-size: 14.5px; color: var(--on-brand-2); border-bottom: 2px solid transparent; }
.views button[aria-selected="true"] { color: var(--on-brand); border-bottom-color: var(--secondary); }
.view { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.view[hidden] { display: none; }
.facts { margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; display: grid; }
.facts div { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 10px; padding: 9px 12px; font-size: 14.5px; }
.facts div + div { border-top: 1px solid var(--border); }
.facts dt { color: var(--text-3); font-size: 13px; padding-top: 1px; }
.facts dd { margin: 0; }
.scorers { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.score-row { display: flex; justify-content: space-between; gap: 12px; }
.score-row b { font-family: var(--font-display); font-variant-numeric: tabular-nums; }
.stats { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); padding-top: 6px; }
.sec-title { font-size: 19px; }
.chk-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow-x: auto; }
.chk { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 14px; }
.chk th, .chk td { padding: 8px 4px; text-align: center; }
.chk thead th { font-size: 12px; font-weight: 600; color: var(--text-3); border-bottom: 1px solid var(--border); }
.chk tbody tr + tr > * { border-top: 1px solid var(--border); }
.chk tbody th { text-align: left; font-weight: 600; padding-left: 12px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chk td { color: var(--text-3); min-width: 22px; }
.chk td.won { color: var(--text); font-weight: 700; }
.chk .tot { font-family: var(--font-display); font-weight: 700; font-size: 16px; color: var(--text); padding-right: 12px; border-left: 1px solid var(--border); }
.chk thead .tot { font-family: var(--font-body); font-size: 12px; color: var(--text-3); }
.gen { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; font-size: 14px; font-variant-numeric: tabular-nums; table-layout: fixed; }
.gen th, .gen td { padding: 8px 12px; }
.gen thead th { font-size: 12px; font-weight: 600; color: var(--text-3); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gen thead th:first-child { width: 44%; }
.gen tbody th { text-align: left; font-weight: 500; color: var(--text-2); }
.gen td { text-align: right; font-weight: 600; }
.gen tbody tr > * { border-top: 1px solid var(--border); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Pedigree */
.ped-dialog { width: min(96vw, 720px); max-height: 96vh; padding: 0; border: 0; border-radius: 14px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); overflow: auto; }
.ped-dialog:focus { outline: none; }
.ped-dialog::backdrop { background: rgb(0 0 0 / .55); }
.ped-head { display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 14px; border-bottom: 1px solid var(--border); }
.ped-head h2 { flex: 1; min-width: 0; font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ped-icon { flex: none; display: inline-grid; place-items: center; border: 0; background: transparent; width: 36px; height: 36px; padding: 0; border-radius: 8px; cursor: pointer; color: var(--text-2); }
.ped-icon:hover { background: var(--surface-2); }
.ped-share { margin-right: -6px; }
.ped-share svg { width: 21px; height: 21px; }
.ped-close { font-size: 26px; line-height: 1; }
.ped-dialog img { display: block; width: 100%; height: auto; background: #fff; }

/* Listas de caballos por torneo */
.lp-search { width: 100%; font: inherit; font-size: 16px; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 999px; padding: 7px 14px; min-width: 0; }
.lp-search:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: transparent; }
.lp-teams button { flex: none; font: inherit; border: 1px solid var(--border-strong); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 13.5px; color: var(--text-2); white-space: nowrap; cursor: pointer; }
.lp-teams button[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.lp-note { color: var(--text-3); font-size: 13px; margin: 0; }
.lp-team { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.lp-team-name { font-size: 20px; padding-top: 6px; }
.lp-team[hidden], .lp-player[hidden], .lp-block[hidden], .lp-horses li[hidden], #lp-none[hidden] { display: none; }
.lp-player { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.lp-player > h3 { padding: 10px 12px; border-bottom: 1px solid var(--border); font-family: var(--font-body); font-size: 16px; font-weight: 600; line-height: 1.15; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.lp-badge { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text-2); }
.lp-block { padding: 8px 12px 10px; display: grid; gap: 4px; }
.lp-block + .lp-block { border-top: 1px solid var(--border); }
.lp-used { background: var(--bg); }
.lp-block h4 { margin: 0; font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.lp-horses { list-style: none; margin: 0; padding: 0; }
.lp-horses li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0 8px; padding-block: 6px; }
.lp-n { flex: none; display: inline-flex; align-items: center; gap: 2px; border: 0; background: transparent; padding: 6px 0 6px 8px; margin-block: -6px; font-size: 12.5px; font-weight: 600; color: var(--primary); cursor: pointer; font-variant-numeric: tabular-nums; }
.lp-n svg { width: 16px; height: 16px; transition: transform .15s; }
.lp-n[aria-expanded="true"] svg { transform: rotate(180deg); }
.lp-matches { flex-basis: 100%; display: grid; gap: 2px; margin-top: 6px; padding: 4px; background: var(--surface-2); border-radius: 10px; }
.lp-matches[hidden] { display: none; }
.lp-matches a { display: grid; gap: 1px; padding: 7px 8px; border-radius: 7px; }
.lp-matches a:hover { background: var(--surface); }
.lp-matches b { font-size: 13.5px; font-weight: 600; }
.lp-matches small { font-size: 12px; color: var(--text-3); }
.lp-horses li + li { border-top: 1px solid var(--border); }
.lp-horses small { flex: none; font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.lp-horses li.unused .hname { color: var(--text-3); }
.lp-name { min-width: 0; font-weight: 600; font-size: 14.5px; line-height: 1.3; overflow-wrap: anywhere; }
.lp-name .ped { color: var(--primary); text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: 3px; }
.lp-name .ped:hover { text-decoration-color: currentColor; }
.lp-name .aaccp { display: inline-block; width: auto; height: 13px; vertical-align: -1px; margin-left: 3px; }
.lp-name .who { display: block; font-size: 12px; font-weight: 400; color: var(--text-3); }

/* Barra de secciones */
.tabbar { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom, 0px); }
.tabbar .inner { max-width: 640px; margin: 0 auto; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 6px 4px 8px; }
.tabbar a { display: grid; justify-items: center; align-content: start; gap: 2px; text-align: center; line-height: 1.2; font-size: 11.5px; font-weight: 600; color: var(--text-3); position: relative; padding-block: 2px; }
.tabbar a svg { width: 22px; height: 22px; }
/* Ícono de una imagen: la silueta del PNG, pintada con el color de la solapa. */
.tabbar .tab-ico { width: 22px; height: 22px; background: currentColor; -webkit-mask: var(--ico) center / contain no-repeat; mask: var(--ico) center / contain no-repeat; }
.tabbar .tab-ico.horse { --ico: url("logos/polo_breeders_interno.png"); }
.tabbar a[aria-current="page"] { color: var(--primary); }
.tabbar a .badge { position: absolute; top: 1px; left: calc(50% + 7px); width: 8px; height: 8px; border-radius: 50%; background: var(--live); border: 2px solid var(--surface); box-sizing: content-box; }

/* Las columnas de grid no se estiran por contenido largo (chips, nombres). */
.content, .hero .inner, .app-bar .inner { grid-template-columns: minmax(0, 1fr); }
.day, .players { grid-template-columns: minmax(0, 1fr); }

/* Color del equipo (app/colors.py): un punto antes del nombre. */
.team-dot { display: inline-block; width: .62em; height: .62em; border-radius: 50%; background: var(--team); margin: 0 .4em .06em 0; vertical-align: middle; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .22); flex: none; }
.vs .name:last-child .team-dot { margin: 0 0 .06em .4em; }
