/* Sistema de diseño — "carta náutica nocturna".
   Base azul-gris de carta topográfica; el naranja es color de rescate y se usa SOLO para alertas.
   El resto del color lo aportan los equipos. Tipografía Barlow en dos anchos (señalética técnica). */

:root {
  --abyss: #0b1016;      /* fondo más profundo */
  --hull:  #121a23;      /* paneles */
  --deck:  #1a242f;      /* filas elevadas, hover */
  --rule:  #273341;      /* hairlines */
  --text:  #dce5ec;
  --muted: #7e90a2;
  --dim:   #55657a;
  --beacon:#ff5a1f;      /* alerta / SOS — nada más */
  --beacon-soft: rgba(255, 90, 31, .14);
  --lume:  #4ade80;      /* pasado / correcto */
  --sky:   #38bdf8;      /* selección, foco */
  --rail: 340px;
  --bar: 104px;
  --radius: 3px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%;
  background: var(--abyss);
  color: var(--text);
  font-family: Barlow, "Helvetica Neue", system-ui, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
body { overflow: hidden; }
a { color: inherit; }

.num, .clock, th, .bib, .tnum { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.cond { font-family: "Barlow Condensed", Barlow, sans-serif; }

:focus-visible { outline: 2px solid var(--sky); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------------------------------------------------------------- estructura */
.app { display: grid; height: 100vh; height: 100dvh;
  grid-template-columns: 52px minmax(0, 1fr) var(--rail);
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas: "tools stage rail" "tools bar rail"; }
.app.no-rail { grid-template-columns: 52px minmax(0, 1fr) 0; }
.tools { grid-area: tools; background: var(--hull); border-right: 1px solid var(--rule);
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0; }
.stage { grid-area: stage; position: relative; overflow: hidden; min-height: 0; }
.rail { grid-area: rail; background: var(--hull); border-left: 1px solid var(--rule);
  display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.app.no-rail .rail { display: none; }
.bar { grid-area: bar; background: var(--hull); border-top: 1px solid var(--rule); min-width: 0; }

/* ---------------------------------------------------------------- barra de herramientas */
.tool { width: 38px; height: 38px; border: 0; border-radius: var(--radius); background: transparent;
  color: var(--muted); cursor: pointer; display: grid; place-items: center; font-size: 17px; line-height: 1; }
.tool:hover { background: var(--deck); color: var(--text); }
.tool[aria-pressed="true"], .tool.on { background: var(--deck); color: var(--sky); }
.tool.alarm { color: var(--beacon); }
.tools hr { width: 24px; border: 0; border-top: 1px solid var(--rule); margin: 6px 0; }
.brand { font: 600 11px/1.1 "Barlow Condensed", sans-serif; letter-spacing: .14em; color: var(--dim);
  writing-mode: vertical-rl; margin-top: auto; padding-bottom: 6px; }

/* ---------------------------------------------------------------- panel lateral */
.rail header { padding: 14px 16px 10px; border-bottom: 1px solid var(--rule); }
.rail h1 { margin: 0; font: 600 20px/1.15 "Barlow Condensed", sans-serif; letter-spacing: .01em; }
.rail header .sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.tabs { display: flex; border-bottom: 1px solid var(--rule); }
.tabs button { flex: 1; border: 0; background: transparent; color: var(--muted); cursor: pointer;
  padding: 10px 4px 9px; font: 600 13px/1 "Barlow Condensed", sans-serif; letter-spacing: .07em;
  border-bottom: 2px solid transparent; }
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--sky); }
.tabs:has(button:only-child) button { border-bottom-color: transparent; cursor: default; color: var(--muted); }
.tabs .count { background: var(--beacon); color: #fff; border-radius: 9px; padding: 0 5px;
  font-size: 11px; margin-left: 4px; }
.filters { display: flex; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--rule); }
.filters select, .filters input, .field {
  background: var(--abyss); border: 1px solid var(--rule); color: var(--text);
  border-radius: var(--radius); padding: 7px 9px; font: inherit; font-size: 13.5px; width: 100%; }
.filters input::placeholder { color: var(--dim); }
.scroll { overflow-y: auto; flex: 1; min-height: 0; scrollbar-width: thin; }

/* ---------------------------------------------------------------- filas de equipo */
.team { display: grid; grid-template-columns: 26px 10px 1fr auto; gap: 9px; align-items: center;
  padding: 9px 12px; border-bottom: 1px solid var(--rule); cursor: pointer; }
.team:hover { background: var(--deck); }
.team.sel { background: var(--deck); box-shadow: inset 3px 0 0 var(--sky); }
.team.alarm { box-shadow: inset 3px 0 0 var(--beacon); }
.team .pos { font: 600 16px/1 "Barlow Condensed", sans-serif; color: var(--muted); text-align: right; }
.team .chip { width: 10px; height: 10px; border-radius: 50%; }
.team .nm { font-weight: 600; font-size: 14.5px; line-height: 1.2; }
.team .bib { color: var(--dim); font-weight: 400; margin-right: 5px; }
.team .meta { color: var(--muted); font-size: 12px; margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; }
.team .star { border: 0; background: transparent; color: var(--dim); cursor: pointer; font-size: 15px; padding: 2px 4px; }
.team .star.on { color: #fbbf24; }
.warn { color: var(--beacon); }
.ok { color: var(--lume); }
.tag { border: 1px solid var(--rule); border-radius: 2px; padding: 0 4px; font-size: 11px; color: var(--muted); }
.tag.danger { border-color: var(--beacon); color: var(--beacon); background: var(--beacon-soft); }

/* acciones que aparecen al seleccionar un equipo */
.acts { display: flex; gap: 4px; padding: 8px 12px; background: var(--abyss);
  border-bottom: 1px solid var(--rule); }
.acts button, .btn { background: var(--deck); border: 1px solid var(--rule); color: var(--text);
  border-radius: var(--radius); padding: 6px 10px; font: inherit; font-size: 12.5px; cursor: pointer; }
.acts button:hover, .btn:hover { border-color: var(--dim); }
.btn.primary { background: var(--sky); border-color: var(--sky); color: #04121c; font-weight: 600; }
.btn.danger { background: var(--beacon); border-color: var(--beacon); color: #fff; font-weight: 600; }

/* ---------------------------------------------------------------- alertas */
.alert { padding: 11px 13px; border-bottom: 1px solid var(--rule); border-left: 3px solid var(--rule); }
.alert.sos { border-left-color: var(--beacon); background: var(--beacon-soft); }
.alert.lvl2 { border-left-color: var(--beacon); }
.alert .hd { font-weight: 600; font-size: 14px; }
.alert .msg { color: var(--muted); font-size: 12.5px; margin: 2px 0 7px; }
.alert .row { display: flex; gap: 6px; }

/* ---------------------------------------------------------------- mensajes del público */
.msgitem { padding: 10px 13px; border-bottom: 1px solid var(--rule); }
.msgitem .who { font-weight: 600; font-size: 13.5px; }
.msgitem .who span { color: var(--muted); font-weight: 400; }
.msgitem .to { color: var(--sky); font-size: 12.5px; margin: 1px 0 3px; }
.msgitem .body { font-size: 13.5px; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.msgitem.pending { border-left: 3px solid var(--beacon); background: var(--beacon-soft); }
.msgitem .row { display: flex; gap: 6px; margin-top: 7px; }
textarea.field { resize: vertical; font-family: inherit; }

/* ---------------------------------------------------------------- formularios del organizador */
.form { padding: 12px; display: grid; gap: 10px; border-bottom: 1px solid var(--rule); }
.form label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.form .row { display: flex; gap: 8px; }
.msg { font-size: 12.5px; color: var(--muted); padding: 0 12px 10px; }

/* ---------------------------------------------------------------- barra inferior */
.bar .line { display: flex; align-items: center; gap: 12px; padding: 8px 14px; }
.clock { font: 600 22px/1 "Barlow Condensed", sans-serif; letter-spacing: .02em; min-width: 118px; }
.clock small { display: block; font: 500 10px/1.3 "Barlow Condensed", sans-serif;
  letter-spacing: .14em; color: var(--dim); }
.live { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--rule);
  border-radius: 20px; padding: 4px 11px 4px 8px; font: 600 12px/1 "Barlow Condensed", sans-serif;
  letter-spacing: .1em; color: var(--muted); background: transparent; cursor: pointer; }
.live.on { color: var(--lume); border-color: rgba(74, 222, 128, .45); }
.live .pip { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.live.on .pip { animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1 } 50% { opacity: .25 } }
#scrub { flex: 1; accent-color: var(--sky); height: 4px; }
.speeds { display: flex; gap: 2px; }
.speeds button { background: transparent; border: 1px solid transparent; color: var(--muted);
  border-radius: var(--radius); padding: 4px 7px; font: 600 12px/1 "Barlow Condensed", sans-serif; cursor: pointer; }
.speeds button:hover { color: var(--text); }
.speeds button.on { background: var(--deck); color: var(--text); border-color: var(--rule); }
#profile { display: block; width: 100%; height: 50px; border-top: 1px solid var(--rule); }

/* ---------------------------------------------------------------- sobre el mapa */
/* #map por id: la hoja de MapLibre se carga después y define .maplibregl-map{position:relative} */
#map.map { position: absolute; inset: 0; width: 100%; height: 100%; }
.float { position: absolute; z-index: 2; background: rgba(18, 26, 35, .93);
  border: 1px solid var(--rule); border-radius: var(--radius);
  backdrop-filter: blur(6px); box-shadow: 0 8px 28px rgba(0, 0, 0, .5); }
.sosbar { left: 50%; transform: translateX(-50%); top: 14px; background: var(--beacon); border: 0;
  color: #fff; font-weight: 600; padding: 9px 16px; display: none; }
.sosbar.show { display: block; }
.popover { top: 12px; left: 12px; width: 232px; padding: 12px; display: none; }
.popover.show { display: block; }
.popover h3 { margin: 0 0 8px; font: 600 12px/1 "Barlow Condensed", sans-serif; letter-spacing: .12em; color: var(--dim); }
.popover h3:not(:first-child) { margin-top: 14px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 5px 0; font-size: 13.5px; cursor: pointer; }
.switch input { appearance: none; width: 34px; height: 19px; border-radius: 10px; background: var(--deck);
  border: 1px solid var(--rule); position: relative; cursor: pointer; flex: none; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px;
  border-radius: 50%; background: var(--dim); transition: transform .15s, background .15s; }
.switch input:checked { background: rgba(56, 189, 248, .25); border-color: var(--sky); }
.switch input:checked::after { transform: translateX(15px); background: var(--sky); }
.basemaps { display: grid; grid-template-columns: repeat(2, 1fr); gap: 5px; }
.basemaps button { background: var(--deck); border: 1px solid var(--rule); color: var(--muted);
  border-radius: var(--radius); padding: 7px 4px; font-size: 12.5px; cursor: pointer; }
.basemaps button.on { border-color: var(--sky); color: var(--text); }
.legend { right: 12px; bottom: 34px; padding: 9px 11px; font-size: 12px; color: var(--muted); max-width: 230px; }
.legend div { display: flex; align-items: center; gap: 7px; padding: 2px 0; }
.legend i { width: 16px; height: 3px; border-radius: 2px; display: inline-block; }

/* popup del mapa: !important porque maplibre-gl.css se carga despues y si no, gana su fondo blanco */
.maplibregl-popup-content { background: var(--hull) !important; color: var(--text) !important;
  border: 1px solid var(--rule); border-radius: var(--radius); font-family: inherit; padding: 10px 12px;
  box-shadow: 0 6px 20px rgba(0,0,0,.4); }
.maplibregl-popup-tip { border-top-color: var(--hull) !important; border-bottom-color: var(--hull) !important; }
.maplibregl-ctrl-group { background: var(--hull) !important; border: 1px solid var(--rule); }
.maplibregl-ctrl-group button + button { border-top: 1px solid var(--rule); }
.maplibregl-ctrl-group button span { filter: invert(1) hue-rotate(180deg); }
.maplibregl-ctrl-attrib { background: rgba(11, 16, 22, .8) !important; }
.maplibregl-ctrl-attrib a { color: var(--muted) !important; }

/* ---------------------------------------------------------------- tablas (pasos, estadísticas) */
.page { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 11px 16px;
  border-bottom: 1px solid var(--rule); background: var(--hull); flex: none; }
.topbar h1 { margin: 0; font: 600 19px/1.1 "Barlow Condensed", sans-serif; }
.topbar nav { display: flex; gap: 2px; margin-left: auto; }
.topbar nav a { color: var(--muted); text-decoration: none; padding: 6px 11px; border-radius: var(--radius);
  font: 600 13px/1 "Barlow Condensed", sans-serif; letter-spacing: .06em; }
.topbar nav a:hover { background: var(--deck); color: var(--text); }
.topbar nav a[aria-current] { background: var(--deck); color: var(--text); }
.tablewrap { overflow: auto; flex: 1; }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13.5px; }
th { position: sticky; top: 0; z-index: 1; background: var(--hull); text-align: left;
  font: 600 12px/1.2 "Barlow Condensed", sans-serif; letter-spacing: .08em; color: var(--muted);
  padding: 9px 10px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
tbody tr:hover td { background: var(--deck); }
td.cp { color: var(--muted); }
td.cp b { color: var(--text); font-weight: 600; }
td.cp .gap { color: var(--dim); font-size: 11.5px; margin-left: 5px; }
td.cp.first b { color: var(--lume); }
.sticky-col { position: sticky; left: 0; background: var(--hull); z-index: 2; }
tbody tr:hover .sticky-col { background: var(--deck); }
th.sticky-col { z-index: 3; }
.note { color: var(--dim); font-size: 12.5px; padding: 12px 16px; }
.section { margin: 0; padding: 18px 16px 2px; color: var(--muted);
  font: 600 13px/1 "Barlow Condensed", sans-serif; letter-spacing: .1em; }
.filters.wrap { flex-wrap: wrap; background: var(--hull); border-bottom: 1px solid var(--rule); }
.filters .leg { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.filters .leg label { color: var(--muted); font-size: 12.5px; }
.filters .leg select { width: auto; min-width: 78px; }
.filters .switch.nowrap { white-space: nowrap; width: auto; }
.topbar nav button#langBtn { width: auto; min-width: 34px; height: 30px; font: 600 12px/1 "Barlow Condensed", sans-serif;
  letter-spacing: .08em; border: 1px solid var(--rule); margin-left: 8px; }

/* tarjetas de estadísticas */
.grid { display: grid; gap: 1px; background: var(--rule); grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stat { background: var(--hull); padding: 14px 16px; }
.stat .k { font: 600 11px/1 "Barlow Condensed", sans-serif; letter-spacing: .12em; color: var(--dim); }
.stat .v { font: 600 30px/1.1 "Barlow Condensed", sans-serif; margin-top: 5px; }
.stat .v small { font-size: 15px; color: var(--muted); }
.bars { padding: 4px 16px 16px; }
.cpbar { display: grid; grid-template-columns: 90px 1fr 92px; gap: 12px; align-items: center; padding: 6px 0; }
.cpbar .track { height: 7px; background: var(--deck); border-radius: 4px; overflow: hidden; }
.cpbar .fill { height: 100%; background: var(--lume); }
.cpbar .lbl { font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.cpbar .val { font-size: 12.5px; color: var(--muted); text-align: right; }

/* ---------------------------------------------------------------- móvil */
@media (max-width: 860px) {
  .app, .app.no-rail { grid-template-columns: 46px minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto auto;
    grid-template-areas: "tools stage" "tools bar" "rail rail"; }
  .rail { border-left: 0; border-top: 1px solid var(--rule); max-height: 46vh; }
  .clock { min-width: 86px; font-size: 18px; }
  .clock small { font-size: 9px; letter-spacing: .1em; }
  .bar .line { flex-wrap: wrap; gap: 8px; padding: 8px 10px; }
  #scrub { order: 10; flex-basis: 100%; }   /* la barra de tiempo pasa a su propia fila */
  .speeds button:nth-child(n+4) { display: none; }
  #profileLabel, .legend { display: none; }
  #profile { height: 40px; }
  .tool { width: 34px; height: 34px; font-size: 15px; }
  .brand { display: none; }
  .rail { max-height: 50vh; }
}

/* ================================================================ página pública del equipo */
/* Layout: encabezado + stats arriba, mapa ocupa la mitad derecha en escritorio */
.page .tablewrap { overflow-y: auto; padding-bottom: 24px; }
.page.teampage { display: grid; grid-template-columns: 380px 1fr; grid-template-rows: auto 1fr;
  height: auto; min-height: 100vh; overflow: visible; background: var(--abyss); }
.page.teampage .topbar { grid-column: 1 / -1; }
#teamMapWrap { position: relative; min-height: 400px; }
#teamMap { position: absolute; inset: 0; }

/* Hero del equipo */
.team-hero { display: flex; align-items: center; gap: 14px; padding: 20px 20px 12px; }
.team-dot { width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0; }
.team-num { font: 700 32px/1 "Barlow Condensed", sans-serif; color: var(--text); }
.team-name { font: 600 20px/1.2 "Barlow", sans-serif; color: var(--text); margin-top: 2px; }
.team-cat { font: 500 13px/1 "Barlow Condensed", sans-serif; color: var(--muted);
  letter-spacing: .1em; margin-top: 4px; }
.team-status-badge { margin-left: auto; padding: 4px 10px; border-radius: 3px;
  font: 600 11px/1 "Barlow Condensed", sans-serif; letter-spacing: .1em;
  background: var(--deck); color: var(--text); white-space: nowrap; }
.team-status-badge[data-status="racing"] { background: #0b4a3a; color: #2fe0aa; }
.team-status-badge[data-status="finished"] { background: #163060; color: #6aaeff; }
.team-status-badge[data-status="cut"] { background: #4a1515; color: #ff7a7a; }
.team-status-badge[data-status="withdrawn"] { background: #333; color: var(--muted); }

/* Tabla de pasos reutiliza estilos de passages.html */
.pass-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.pass-table th { font: 600 11px/1 "Barlow Condensed", sans-serif; letter-spacing: .1em;
  color: var(--dim); padding: 8px 16px; text-align: left; border-bottom: 1px solid var(--rule); }
.pass-table td { padding: 7px 16px; border-bottom: 1px solid var(--rule); color: var(--text); }
.pass-table .cp-code { font: 600 13px "Barlow Condensed", sans-serif; color: var(--lume); }
.pass-table .cp-name { color: var(--muted); font-size: 12px; }

/* Texto de miembros */
.members-text { padding: 6px 20px 12px; font-size: 14px; color: var(--text); line-height: 1.6; }

/* Botón compartir */
.share-row { padding: 20px 20px 8px; }
.share-btn { background: var(--lume); color: #000; border: none; border-radius: 4px;
  font: 600 13px/1 "Barlow Condensed", sans-serif; letter-spacing: .08em;
  padding: 10px 20px; cursor: pointer; transition: opacity .15s; }
.share-btn:hover { opacity: .85; }

/* Dot marker en el mapa */
.dot-marker { width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 0 8px rgba(0,0,0,.7); }

/* Mobile: columna única */
@media (max-width: 700px) {
  .page.teampage { grid-template-columns: 1fr; grid-template-rows: auto auto 300px; }
  #teamMapWrap { min-height: 300px; }
}

/* ---- posiciones (leaderboard) ---- */
.boardcats { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 12px 4px; }
.chipbtn { border: 1px solid var(--rule); background: transparent; color: var(--muted); border-radius: 14px;
  padding: 4px 11px; font: inherit; font-size: 12.5px; cursor: pointer; }
.chipbtn:hover { color: var(--text); }
.chipbtn.on { color: var(--text); border-color: var(--sky); background: var(--deck); }
.brow { display: grid; grid-template-columns: 30px 10px 1fr auto; gap: 9px; align-items: center;
  padding: 9px 12px; border-bottom: 1px solid var(--rule); cursor: pointer; }
.brow:hover, .brow.sel { background: var(--deck); }
.brow.sel { box-shadow: inset 3px 0 0 var(--sky); }
.brow .bpos { font: 700 20px/1 "Barlow Condensed", sans-serif; color: var(--muted); text-align: right; }
.brow.top1 .bpos { color: #fbbf24; } .brow.top2 .bpos { color: #cbd5e1; } .brow.top3 .bpos { color: #d97706; }
.brow .chip { width: 10px; height: 10px; border-radius: 50%; }
.brow .nm { font-weight: 600; font-size: 14.5px; line-height: 1.2; display: block; }
.brow .bib { color: var(--dim); font-weight: 400; margin-right: 5px; }
.brow .meta { color: var(--muted); font-size: 12px; margin-top: 2px; display: block; }
.brow .bval { font-weight: 600; font-size: 14px; white-space: nowrap; }
.brow .bval.ok { color: #4ade80; }
.brow.out { opacity: .6; }

/* ---- etapa visible en el mapa ---- */
.stagebadge { left: 50%; top: 10px; transform: translateX(-50%); padding: 5px 12px; font-size: 13px; font-weight: 600;
  border-radius: 3px; pointer-events: none; z-index: 4; }

/* ---- estadisticas: distribucion en escritorio ---- */
.stats-wrap { max-width: 1320px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
.stats-wrap .kpis { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); border: 1px solid var(--rule); }
.stats-wrap .cols { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.stats-wrap .stack { display: grid; gap: 16px; }
.stats-wrap .panel { background: var(--hull); border: 1px solid var(--rule); min-width: 0; }
.stats-wrap .panel[hidden] { display: none; }
.stats-wrap .ptitle { margin: 0; padding: 14px 16px 6px; color: var(--muted);
  font: 600 13px/1 "Barlow Condensed", sans-serif; letter-spacing: .1em; }
.stats-wrap .panel .grid { border-top: 1px solid var(--rule); }
.stats-wrap .bars { padding: 6px 16px 14px; }
.stats-wrap .cpbar { grid-template-columns: 90px 1fr 130px; }
table.mini { width: 100%; font-size: 13.5px; }
table.mini th { position: static; padding: 8px 14px; }
table.mini td { padding: 8px 14px; }
table.mini .r { text-align: right; }
table.mini .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; }
@media (max-width: 980px) { .stats-wrap .cols { grid-template-columns: 1fr; } }

/* ---- sponsors ---- */
.sponsors { overflow: hidden; background: var(--hull); border-top: 1px solid var(--rule); height: 52px; flex: none; }
.sponsors-page { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; }
.sp-track { display: flex; width: max-content; align-items: center; height: 100%; animation: sp-scroll 40s linear infinite; }
.sponsors:hover .sp-track { animation-play-state: paused; }
.sp-item { display: flex; align-items: center; height: 100%; padding: 0 7px; }
/* cada logo sobre su propia tarjeta clara: los logos siguen legibles sin una franja blanca entera */
.sp-item img { height: 30px; width: auto; max-width: 150px; object-fit: contain;
  background: #eef2f6; border-radius: 7px; padding: 5px 11px; }
@keyframes sp-scroll { to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) { .sp-track { animation: none; overflow-x: auto; } }
/* ---- popup de equipo ---- */
.tpop { max-width: 250px; color: var(--text); font-size: 13px; }
.tpop img { width: 100%; max-height: 150px; object-fit: cover; border-radius: 6px; margin-bottom: 6px; display: block; }
.tpop b { font-size: 14px; }
.tpop p { margin: 4px 0 0; }
.tpop a { color: var(--sky); }
.tpop .tpop-meta { margin: 6px 0 0; padding-top: 6px; border-top: 1px solid var(--rule); color: var(--muted);
  font-size: 12px; line-height: 1.5; }
.tpop .tpop-meta b { font-size: 12px; color: var(--text); }
.tpop .tpop-stale { color: var(--beacon); }
.infotext { white-space: pre-wrap; line-height: 1.5; padding: 4px 2px; word-break: break-word; }
.infotext a { color: var(--accent, #4dd0e1); }
.team-photo { width: 100%; max-height: 340px; object-fit: cover; border-radius: 10px; margin-bottom: 10px; }
.team-blurb { margin: 0 0 12px; color: var(--dim, #9fb0c2); }

/* ---- mensajes estilo chat ---- */
#tab-messages.chat:not([hidden]) { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.chatlist { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 10px 4px; display: flex; flex-direction: column; gap: 8px; }
.chatday { align-self: center; font-size: 11.5px; color: var(--muted); background: rgba(128,140,155,.15); padding: 2px 10px; border-radius: 10px; margin: 4px 0; }
.bubble-row { display: flex; gap: 8px; align-items: flex-end; max-width: 94%; }
.avatar { flex: none; width: 30px; height: 30px; border-radius: 50%; color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 14px; }
.bubble { background: rgba(128,140,155,.16); border-radius: 14px 14px 14px 4px; padding: 7px 11px 5px; min-width: 0; }
.bubble .who { font-weight: 600; font-size: 12.5px; color: var(--sky); }
.bubble .who .to { color: var(--muted); font-weight: 400; }
.bubble .body { font-size: 14px; line-height: 1.35; white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 1px; }
.bubble .when { font-size: 11px; color: var(--muted); text-align: right; margin-top: 2px; }
.bubble .when .tag { color: var(--beacon); }
.bubble .when .tag.no { color: #ff6b6b; }
.bubble .row { display: flex; gap: 6px; margin: 6px 0 3px; }
.bubble-row.pending .bubble { outline: 1.5px dashed var(--beacon); }
.bubble-row.rejected { opacity: .55; }
.chatform { flex: none; border-top: 1px solid var(--rule); padding: 8px 10px 6px; display: grid; gap: 6px; background: var(--hull); }
.chatform .r2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.chatform .r3 { display: flex; gap: 6px; align-items: flex-end; }
.chatform textarea { flex: 1; resize: none; max-height: 90px; border-radius: 16px; }
.chatform .meta { font-size: 11.5px; color: var(--muted); min-height: 14px; }

/* ---- selector de categoria en estadisticas + ajustes para pantallas chicas ---- */
.catchips { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 0 12px; }
.catchips .chipbtn { background: var(--hull); color: var(--text); border: 1px solid var(--rule); border-radius: 999px; padding: 6px 14px;
  font: 600 14px "Barlow Condensed", sans-serif; letter-spacing: .04em; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; }
.catchips .chipbtn i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.catchips .chipbtn.on { background: var(--text); color: var(--abyss); border-color: var(--text); }
.topbar { flex-wrap: wrap; row-gap: 6px; }
@media (max-width: 560px) {
  .topbar { padding: 9px 10px; gap: 8px; }
  .topbar h1 { font-size: 17px; flex: 1 1 100%; }
  .topbar nav { margin-left: 0; width: 100%; flex-wrap: wrap; }
  .topbar nav a { padding: 5px 8px; font-size: 12.5px; }
}

/* Botón de regreso al mapa / pantalla principal: bien visible para el espectador */
a.homebtn, .topbar nav a.homebtn, .tr-links a.homebtn {
  background: var(--sky); color: #04131c; font-weight: 700; padding: 6px 13px; border-radius: 999px;
  text-decoration: none; white-space: nowrap; box-shadow: 0 0 0 1px rgba(56,189,248,.35), 0 2px 8px rgba(56,189,248,.25); }
a.homebtn::before { content: "◀\00a0"; font-size: .8em; }
a.homebtn:hover, .topbar nav a.homebtn:hover, .tr-links a.homebtn:hover { background: #7dd3fc; color: #04131c; }
@media (max-width: 560px) { a.homebtn, .topbar nav a.homebtn { padding: 5px 10px; } }

/* aviso de cobertura en estadisticas/pasos cuando el evento esta en modo seguimiento */
.cov-banner { padding: 6px 16px; font-size: 12.5px; color: var(--muted); background: var(--hull);
  border-bottom: 1px solid var(--rule); }
.cov-banner b { color: var(--text); font-weight: 600; }

/* boton a la galeria de fotos del corredor */
.photosbtn { display: inline-block; margin: 0 0 12px; padding: 9px 18px; border-radius: 999px;
  background: var(--sky); color: #04131c; font-weight: 700; text-decoration: none; }
.photosbtn:hover { background: #7dd3fc; }
.photosbtn[hidden] { display: none; }

/* mandar ánimo desde la ficha del corredor */
.teammsg { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 4px; max-width: 560px; }
.teammsg .field { background: var(--hull); color: var(--text); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: 9px 12px; font: inherit; width: 100%; }
.teammsg textarea.field { resize: vertical; min-height: 60px; }
.teammsg-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.teammsg .note.warn { color: var(--beacon); }

/* La ficha del corredor crecio con el formulario de animo: en escritorio scrollea la columna
   de datos (el mapa queda fijo al costado) y en celular scrollea la pagina entera.
   Sin esto el `body { overflow: hidden }` global dejaba el final fuera de alcance. */
.page.teampage { height: 100vh; min-height: 0; overflow: hidden; }
.page.teampage .tablewrap { min-height: 0; overflow-y: auto; }
@media (max-width: 700px) {
  body.teampage-body { overflow: auto; }
  .page.teampage { height: auto; min-height: 100vh; overflow: visible; }
  .page.teampage .tablewrap { overflow: visible; }
}

/* Selector de emoticones (emoji.js) */
.emoji-btn {
  flex: none; width: 38px; height: 38px; border-radius: 999px; border: 1px solid var(--rule);
  background: var(--hull); font-size: 18px; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.emoji-btn:hover { background: #1a2530; }
.emoji-pop {
  position: fixed; z-index: 1000; width: 280px; max-height: 260px; overflow-y: auto;
  background: var(--hull); border: 1px solid var(--rule); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.45); padding: 8px 10px;
}
.emoji-pop[hidden] { display: none; }
.emoji-grupo + .emoji-grupo { margin-top: 6px; }
.emoji-grupo h4 {
  margin: 4px 0; font: 600 11px "Barlow Condensed", sans-serif; letter-spacing: .04em;
  color: var(--muted); text-transform: uppercase;
}
.emoji-grupo > div { display: flex; flex-wrap: wrap; gap: 2px; }
.emoji-grupo button {
  border: 0; background: none; font-size: 20px; line-height: 1; padding: 5px;
  border-radius: 6px; cursor: pointer;
}
.emoji-grupo button:hover { background: #1a2530; }
