/* Voleytracker — estilos
   Paleta: negro en las barras, azul de la pelota para lo principal, naranja de la trayectoria como acento. Tipografía: Barlow Condensed (títulos, números) + Barlow (texto). */

:root {
  color-scheme: light;
  --bg: #F4F5F8;
  --surface: #FFFFFF;
  --surface-2: #ECEEF3;
  --ink: #14161C;
  --muted: #5D6472;
  --line: #DEE1E8;
  --bar: #0E1016;
  --bar-ink: #FFFFFF;
  --fire: linear-gradient(90deg, #FFA233, #F26A1D 55%, #D9351A);
  --court: #2244C2;
  --court-ink: #FFFFFF;
  --court-soft: #E7ECFB;
  --link: #2244C2;
  --ball: #F57C1F;
  --ball-ink: #1F0E00;
  --good: #1B7F45;
  --good-bg: #DFF2E7;
  --bad: #BF362D;
  --bad-bg: #FBE4E2;
  --mid: #A04E00;
  --mid-bg: #FFF0E1;
  --neutral-bg: #ECEEF2;
  /* Botones de calificación: # verde, + azul, − rojo (texto blanco, mismos tonos en claro y oscuro) */
  --eval-dp: #1E8A4C;
  --eval-p: #1F6BC9;
  --eval-n: #C8372D;
  --shadow: 0 1px 2px rgba(18, 26, 38, .06), 0 4px 16px rgba(18, 26, 38, .06);
  --display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", system-ui, sans-serif;
  --body: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0A0B0F;
    --surface: #14161D;
    --surface-2: #1B1E27;
    --ink: #ECEEF3;
    --muted: #9AA0AE;
    --line: #262A35;
    --bar: #000000;
    --court: #3F63E0;
    --court-ink: #FFFFFF;
    --court-soft: #18203D;
    --link: #8EA6FF;
    --ball: #FF8F33;
    --good: #52C585;
    --good-bg: #143324;
    --bad: #F2766B;
    --bad-bg: #3A1D1B;
    --mid: #FFAE66;
    --mid-bg: #33200D;
    --neutral-bg: #1F222C;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0A0B0F; --surface: #14161D; --surface-2: #1B1E27; --ink: #ECEEF3; --muted: #9AA0AE; --line: #262A35;
  --bar: #000000; --court: #3F63E0; --court-ink: #FFFFFF; --court-soft: #18203D; --link: #8EA6FF; --ball: #FF8F33;
  --good: #52C585; --good-bg: #143324; --bad: #F2766B; --bad-bg: #3A1D1B; --mid: #FFAE66; --mid-bg: #33200D;
  --neutral-bg: #1F222C; --shadow: 0 1px 2px rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--link); }
h1, h2, h3 { margin: 0; line-height: 1.15; text-wrap: balance; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.center { text-align: center; }
.good-text { color: var(--good); }
.bad-text { color: var(--bad); }
.danger-text { color: var(--bad) !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--ball); outline-offset: 2px; }
.boot { padding: 72px 16px; color: var(--muted); font-family: var(--display); font-size: 1.2rem; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.boot img { width: 120px; height: 120px; }

/* ---------- Layout ---------- */
[hidden] { display: none !important; }
.page { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; max-width: 640px; margin: 0 auto; }
.page.has-nav { padding-bottom: calc(64px + var(--safe-bottom)); }
.content { padding: 16px 16px 32px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 10px; }
.stack-xs { display: flex; flex-direction: column; gap: 8px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 520px) { .two-col { grid-template-columns: 1fr; } }

/* ---------- Barra superior ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 8px;
  padding: calc(6px + var(--safe-top)) 8px 6px;
  background: var(--bar); color: var(--bar-ink);
}
/* Franja de fuego bajo el encabezado */
.topbar::after, .scoreboard::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--fire); }
.live .topbar::after { display: none; }
.topbar-logo { width: 40px; height: 40px; display: block; justify-self: center; }
.topbar-title { min-width: 0; }
.topbar h1 { font-family: var(--display); font-weight: 700; font-size: 1.35rem; letter-spacing: .01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar small { display: block; opacity: .85; font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; gap: 4px; }
.icon-btn {
  min-width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent; color: inherit;
  font-size: 1.7rem; line-height: 1; display: grid; place-items: center; text-decoration: none;
}
.icon-btn:hover { background: rgba(255, 255, 255, .12); }
.icon-btn.text-btn { font-family: var(--display); font-size: 1rem; font-weight: 600; padding: 0 10px; letter-spacing: .04em; text-transform: uppercase; }
.icon-spacer { width: 44px; }

/* ---------- Navegación inferior ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom);
}
.nav-item {
  min-height: 56px; display: grid; place-items: center; text-decoration: none; color: var(--muted);
  font-family: var(--display); font-weight: 600; font-size: 1.05rem; letter-spacing: .03em;
}
.nav-item.is-active { color: var(--court); box-shadow: inset 0 3px 0 var(--ball); }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 0 16px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-weight: 600; text-decoration: none; text-align: center;
}
.btn:hover { border-color: var(--court); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--court); border-color: var(--court); color: var(--court-ink); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-big { min-height: 56px; font-family: var(--display); font-size: 1.25rem; letter-spacing: .02em; }

/* ---------- Formularios ---------- */
.field { display: flex; flex-direction: column; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span, .field > legend { font-weight: 600; font-size: .92rem; padding: 0; margin-bottom: 6px; }
.input {
  width: 100%; min-height: 48px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.input:focus { outline: none; border-color: var(--court); box-shadow: 0 0 0 3px var(--court-soft); }
textarea.input { font-family: ui-monospace, Menlo, monospace; font-size: .85rem; }
.form-error { color: var(--bad); font-weight: 600; min-height: 0; }
.form-error:empty { display: none; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.seg-wrap { grid-auto-flow: row; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
.seg-opt { position: relative; }
.seg-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.seg-opt span {
  display: grid; place-items: center; min-height: 44px; padding: 6px 8px; border-radius: 10px; text-align: center;
  border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: .92rem;
}
.seg-opt input:checked + span { background: var(--court); border-color: var(--court); color: var(--court-ink); }
.seg-opt input:focus-visible + span { outline: 3px solid var(--ball); outline-offset: 1px; }

.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.check-chip { position: relative; }
.check-chip input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.check-chip span {
  display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 6px 10px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
}
.check-chip b { font-family: var(--display); font-size: 1.2rem; color: var(--ink); min-width: 1.4em; }
.check-chip small { margin-left: auto; font-size: .72rem; letter-spacing: .06em; }
.check-chip input:checked + span { border-color: var(--court); background: var(--court-soft); color: var(--ink); }
.check-chip input:focus-visible + span { outline: 3px solid var(--ball); }

/* ---------- Listas y tarjetas ---------- */
.section-title { font-family: var(--display); font-size: 1rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 600; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card-title { font-family: var(--display); font-size: 1.3rem; font-weight: 700; }
.mini-title { font-family: var(--display); font-size: .95rem; font-weight: 600; letter-spacing: .04em; margin-bottom: 8px; display: block; }
.empty { text-align: center; padding: 28px 12px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.empty h2 { font-family: var(--display); font-size: 1.3rem; }
.empty p { max-width: 40ch; }

.match-card {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; text-decoration: none; color: var(--ink);
}
.match-card.is-live { border-color: var(--court); box-shadow: inset 4px 0 0 var(--ball); }
.match-main { display: flex; flex-direction: column; min-width: 0; }
.match-rival { font-family: var(--display); font-size: 1.3rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.match-meta, .match-sets { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.match-res { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; }
.match-score { font-family: var(--display); font-size: 1.8rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.chip { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; padding: 2px 8px; border-radius: 999px; background: var(--neutral-bg); color: var(--muted); }
.chip-live { background: var(--ball); color: var(--ball-ink); }
.chip-good { background: var(--good-bg); color: var(--good); }
.chip-bad { background: var(--bad-bg); color: var(--bad); }

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.list li { display: flex; gap: 6px; }
.player-row {
  flex: 1; min-width: 0; display: grid; grid-template-columns: 48px 1fr; align-items: center; gap: 10px; min-height: 56px; color: inherit; text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 12px; text-align: left;
}
.player-row.is-off { opacity: .55; }
.row-link { display: grid; place-items: center; padding: 0 12px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); text-decoration: none; font-weight: 600; font-size: .9rem; }
.num-badge { font-family: var(--display); font-weight: 700; font-size: 1.5rem; background: var(--court); color: var(--court-ink); border-radius: 10px; width: 44px; height: 44px; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.player-name { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.player-pos { display: block; font-weight: 400; }
.accion-jugador { display: grid; min-width: 88px; }
.accion-jugador:empty { display: none; }
.estado-unido { background: var(--good-bg); border-color: transparent; color: var(--good); }
.estado-pendiente { background: var(--mid-bg); border-color: transparent; color: var(--mid); }
.plain { margin: 0; padding-left: 1.1rem; display: flex; flex-direction: column; gap: 4px; }

/* ---------- Modal ---------- */
.backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(8, 12, 20, .55); display: flex; align-items: flex-end; justify-content: center; }
/* Escudo invisible que se traga el segundo toque de un doble toque al cerrarse una hoja (ver ui.js) */
.tap-shield { position: fixed; inset: 0; z-index: 70; background: transparent; touch-action: none; }
/* Recién abierta, la hoja no responde: el segundo toque de un doble toque no aprieta nada (ver ui.js, is-lista) */
.sheet:not(.is-lista) button, .sheet:not(.is-lista) a, .sheet:not(.is-lista) input, .sheet:not(.is-lista) label, .sheet:not(.is-lista) .court-picker { pointer-events: none; }
.sheet {
  width: 100%; max-width: 560px; max-height: 88vh; overflow: auto; background: var(--bg);
  border-radius: 18px 18px 0 0; padding: 20px 16px calc(20px + var(--safe-bottom));
  animation: up .18s ease-out;
}
.sheet:focus { outline: none; }
@media (min-width: 640px) { .backdrop { align-items: center; } .sheet { border-radius: 18px; } }
.sheet-title { font-family: var(--display); font-size: 1.45rem; font-weight: 700; }
@keyframes up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }

#toast {
  position: fixed; left: 50%; bottom: calc(80px + var(--safe-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: .92rem;
  opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; z-index: 60; max-width: calc(100% - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Formación (cancha) ---------- */
.court { background: var(--court-soft); border: 2px solid var(--court); border-radius: var(--radius); padding: 0 8px 8px; }
.net { text-align: center; font-family: var(--display); font-size: .75rem; letter-spacing: .3em; color: var(--court); border-bottom: 3px dashed var(--court); padding: 4px 0; margin-bottom: 8px; font-weight: 700; }
.court-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.zone {
  position: relative; min-height: 76px; border-radius: 10px; border: 2px solid var(--line); background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 6px 4px; line-height: 1.1;
}
.zone b { font-family: var(--display); font-size: 1.8rem; font-weight: 700; }
.zone small { font-size: .75rem; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zone.is-empty { border-style: dashed; }
.zone.is-selected { border-color: var(--ball); box-shadow: 0 0 0 3px var(--ball); }
.zone-n { position: absolute; top: 4px; left: 6px; font-size: .68rem; font-weight: 700; color: var(--muted); }

.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 6px; }
.pick {
  min-height: 64px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; padding: 4px;
}
.pick b { font-family: var(--display); font-size: 1.5rem; font-weight: 700; }
.pick small { font-size: .75rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick em { font-style: normal; font-size: .66rem; font-weight: 700; color: var(--muted); letter-spacing: .06em; }
.pick.is-used { background: var(--court-soft); border-color: var(--court); }
.pick.is-used em { color: var(--court); }
.pick.is-libero em { color: var(--mid); }

/* ---------- Pantalla en vivo ---------- */
.live .topbar { position: static; }
.scoreboard {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  background: var(--bar); color: var(--bar-ink); padding: 2px 16px 12px;
  position: sticky; top: 0; z-index: 9;
}
.sb-team { display: flex; flex-direction: column; }
.sb-right { align-items: flex-end; }
.sb-name { font-family: var(--display); font-size: .85rem; text-transform: uppercase; letter-spacing: .12em; opacity: .85; display: flex; gap: 6px; align-items: center; }
.sb-pts { font-family: var(--display); font-size: 3rem; font-weight: 700; line-height: .95; font-variant-numeric: tabular-nums; }
.sb-mid { display: flex; flex-direction: column; align-items: center; font-family: var(--display); line-height: 1.1; padding: 0 8px; }
.sb-mid span { font-size: .85rem; letter-spacing: .12em; opacity: .85; }
.sb-mid b { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.sb-mid small { font-size: .72rem; opacity: .7; }
.serve-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--ball); box-shadow: 0 0 0 2px rgba(255, 255, 255, .6); display: inline-block; }

.live-body { padding: 10px 10px calc(16px + var(--safe-bottom)); }
.live-court { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.ptile {
  position: relative; min-height: 62px; border-radius: 10px; border: 2px solid var(--line); background: var(--surface); color: var(--ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05; padding: 12px 2px 4px;
}
.ptile b { font-family: var(--display); font-size: 1.75rem; font-weight: 700; }
.ptile small { font-size: .7rem; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
.ptile-tag { position: absolute; top: 3px; left: 5px; font-size: .6rem; font-weight: 700; letter-spacing: .06em; color: var(--muted); }
.ptile.is-selected { border-color: var(--ball); background: var(--court-soft); box-shadow: 0 0 0 2px var(--ball); }
.ptile.is-libero { background: var(--mid-bg); }
.ptile.is-libero.is-selected { background: var(--mid-bg); }
.ptile.is-action { background: var(--neutral-bg); border-style: dashed; }
.ptile.is-action b { font-size: 1.4rem; }
.ptile.is-blank { border-style: dashed; background: transparent; }
.ptile .ptile-tag:where(:only-child) { position: static; }
.hint { text-align: center; font-size: .9rem; color: var(--muted); min-height: 1.3em; font-weight: 500; }
.hint.has-sel { color: var(--ink); font-weight: 700; }

/* Orden de las jugadas: qué corresponde ahora y el botón para prender todo por una jugada */
.orden-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 40px; }
.orden-ahora { font-family: var(--display); font-weight: 700; font-size: .95rem; letter-spacing: .02em; color: var(--link); }
.btn-chico { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 6px 12px; font: 600 .8rem var(--body); min-height: 40px; touch-action: manipulation; }
.act-grid { display: flex; flex-direction: column; gap: 5px; }
.act-row { display: grid; grid-template-columns: 64px 1fr; gap: 5px; align-items: stretch; }
.act-label { font-family: var(--display); font-weight: 600; font-size: .9rem; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); display: flex; flex-direction: column; align-items: flex-start; justify-content: center; line-height: 1.1; }
.act-label small { font-family: var(--body); font-size: .62rem; font-weight: 600; letter-spacing: .02em; text-transform: none; opacity: .85; }
/* Saque apagado (saca el rival u otro jugador): la nota dice por qué */
.act-row.is-bloqueada .act-label small { color: var(--ink); opacity: 1; }
.act-btns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
.act-btns.act-btns-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.act {
  min-height: 48px; border: 0; border-radius: 10px; padding: 4px 2px; font-weight: 600; font-size: clamp(.72rem, 3.2vw, .88rem); line-height: 1.1;
  touch-action: manipulation; user-select: none;
}
.act.tone-g { background: var(--good-bg); color: var(--good); }
.act.tone-m { background: var(--neutral-bg); color: var(--ink); }
.act.tone-b { background: var(--bad-bg); color: var(--bad); }
.act.tone-dp, .act.tone-p, .act.tone-n { min-height: 54px; color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.act.tone-dp { background: var(--eval-dp); }
.act.tone-p { background: var(--eval-p); }
.act.tone-n { background: var(--eval-n); }
.act.tone-dp b, .act.tone-p b, .act.tone-n b { font-family: var(--display); font-size: 1.65rem; font-weight: 700; line-height: .9; }
.act.tone-dp small, .act.tone-p small, .act.tone-n small { font-size: .68rem; font-weight: 600; opacity: .92; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
.act.ends { font-weight: 700; }
.act.tone-undo { background: var(--surface); border: 1px solid var(--line); color: var(--ink); }
.act:disabled { opacity: .35; cursor: not-allowed; }
@media (prefers-reduced-motion: no-preference) {
  .act, .ptile, .zone, .pick { transition: transform .06s ease-out; }
  .act:active:not(:disabled), .ptile:active, .zone:active, .pick:active { transform: scale(.95); }
}
.team-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 2px; }
.team-row .act { min-height: 50px; }

.log { list-style: none; margin: 6px 0 0; padding: 8px 0 0; border-top: 1px dashed var(--line); display: flex; flex-direction: column; gap: 3px; font-size: .84rem; }
.log li { display: flex; justify-content: space-between; gap: 10px; }
.log-score { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
.log .log-nos .log-score { color: var(--good); }
.log .log-riv .log-score { color: var(--bad); }

.setover { padding-top: 6px; }
.setover-head { text-align: center; }
.setover-head h2 { font-family: var(--display); font-size: 3.2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.eyebrow { font-family: var(--display); text-transform: uppercase; letter-spacing: .14em; color: var(--court); font-weight: 700; }

/* ---------- Indicadores ---------- */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.kpis-6 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 520px) { .kpis-6 { grid-template-columns: repeat(2, 1fr); } }
.kpis-1 { grid-template-columns: 1fr; }
.kpi-ancho { grid-column: 1 / -1; }
/* Los cuatro cuadros de arriba del Resumen (Saques, Ataques, Recep/Defensa, Bloqueos), como la planilla en papel */
.cuadros { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 720px) { .cuadros { grid-template-columns: repeat(4, 1fr); } }
.cuadro { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.cuadro-titulo { font-family: var(--display); font-size: 1.05rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; line-height: 1.1; align-self: flex-start; padding-bottom: 3px; border-bottom: 2px solid var(--court); }
.cuadro-filas { margin: 0; display: flex; flex-direction: column; gap: 3px; }
.cuadro-filas > div { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.cuadro-filas dt { color: var(--muted); font-size: .86rem; }
.cuadro-filas dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.cuadro-filas .cuadro-efic { margin-top: 4px; padding-top: 6px; border-top: 1px solid var(--line); }
.cuadro-efic dt { color: var(--ink); font-weight: 600; }
.cuadro-efic dd { font-family: var(--display); font-size: 1.7rem; line-height: 1; }
@media (max-width: 360px) {
  .cuadro { padding: 10px 10px 12px; }
  .cuadro-efic dd { font-size: 1.45rem; }
}
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: transparent; }
.kpi-good::before { background: var(--good); }
.kpi-mid::before { background: var(--ball); }
.kpi-bad::before { background: var(--bad); }
.kpi-v { font-family: var(--display); font-size: 1.9rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi-l { font-size: .82rem; font-weight: 600; }
.kpi-s { font-size: .75rem; color: var(--muted); }

.result { text-align: center; display: flex; flex-direction: column; gap: 4px; }
.result-line { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; font-family: var(--display); font-size: 1.15rem; font-weight: 600; }
.result-line span:first-child { text-align: right; }
.result-line span:last-child { text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-line b { font-size: 2.6rem; font-variant-numeric: tabular-nums; color: var(--court); }

.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip-btn { flex-shrink: 0; min-height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: .9rem; }
.chip-btn.is-active { background: var(--ink); border-color: var(--ink); color: var(--bg); }
/* Fila de filtros con su título (mapas de ataque y de saque) */
.filtro { display: grid; gap: 4px; }
.filtro-titulo { font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }

.hbars { display: flex; flex-direction: column; gap: 6px; }
.hbar { display: grid; grid-template-columns: minmax(96px, 40%) 1fr 28px; align-items: center; gap: 8px; font-size: .85rem; }
.hbar-track { height: 12px; background: var(--neutral-bg); border-radius: 6px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; border-radius: 6px; min-width: 2px; }
.tone-good { background: var(--good); }
.tone-bad { background: var(--bad); }
.tone-court { background: var(--court); }
.hbar-val { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.hbars-valor-ancho .hbar { grid-template-columns: minmax(96px, 36%) 1fr auto; }
.hbars-valor-ancho .hbar-val { white-space: nowrap; min-width: 64px; }
.hbar-label { min-width: 0; overflow-wrap: anywhere; } /* un nombre larguísimo no ensancha la pantalla */


.tbl { overflow-x: auto; margin: 0 -4px; }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { padding: 8px 6px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.num-table td:not(:first-child), .num-table th:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.td-name a { font-weight: 600; text-decoration: none; color: var(--ink); }
.td-name small { margin-left: 6px; color: var(--muted); font-size: .7rem; }
.eff { display: inline-block; min-width: 48px; text-align: center; padding: 1px 6px; border-radius: 6px; font-weight: 700; }
.eff-good { background: var(--good-bg); color: var(--good); }
.eff-mid { background: var(--mid-bg); color: var(--mid); }
.eff-bad { background: var(--bad-bg); color: var(--bad); }

.spark-row { display: flex; flex-wrap: wrap; gap: 24px; }
.spark-line { stroke: var(--court); stroke-width: 2; }
.spark-dot { fill: var(--ball); stroke: var(--court); stroke-width: 1.5; }
.spark-zero { stroke: var(--line); stroke-dasharray: 3 3; }

.install-card { border-color: var(--court); background: var(--court-soft); }
.install-card .btn-ghost { align-self: flex-start; min-height: 40px; padding: 0 4px; }

/* ---------- Equipos ---------- */
.title-btn { background: transparent; border: 0; color: inherit; text-align: left; padding: 4px 6px; margin-left: -6px; border-radius: 8px; font: inherit; min-width: 0; }
.title-btn:hover { background: rgba(255, 255, 255, .12); }
.title-btn .caret { font-size: .9em; opacity: .85; }
.team-opt {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 56px; padding: 10px 14px;
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); text-align: left;
}
.team-opt.is-current { border-color: var(--court); box-shadow: inset 4px 0 0 var(--ball); background: var(--court-soft); }
.team-opt small { color: var(--muted); }
.team-name { font-family: var(--display); font-size: 1.3rem; font-weight: 700; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.team-card .team-main {
  flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; text-align: left;
}
.team-card.is-current .team-main { border-color: var(--court); box-shadow: inset 4px 0 0 var(--ball); }
.team-meta { font-size: .85rem; color: var(--muted); }
.welcome-title { font-family: var(--display); font-size: 2.2rem; font-weight: 700; }
.welcome-logo { width: 132px; height: 132px; border-radius: 50%; align-self: center; margin: 4px 0 8px; box-shadow: 0 0 0 2px rgba(255, 140, 50, .45), 0 8px 24px rgba(0, 0, 0, .25); }
.status-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: .9rem; }
.status-list li { padding: 8px 10px 8px 12px; border-radius: 8px; border-left: 4px solid var(--line); background: var(--surface-2); }
.status-list li.ok { border-left-color: var(--good); }
.status-list li.warn { border-left-color: var(--ball); }
.status-list li.bad { border-left-color: var(--bad); }
.ptile.is-lib-action { background: var(--mid-bg); border-color: var(--ball); }
.ptile.is-lib-action .ptile-tag { color: var(--mid); }
.lib-auto { background: var(--mid-bg); border-radius: 10px; padding: 10px 12px; }
.lib-auto-title { font-weight: 700; font-size: .92rem; }

/* Posición y sacador en los casilleros */
.ptile-pos {
  position: absolute; top: 3px; right: 4px; font-size: .66rem; font-weight: 700; letter-spacing: .04em; line-height: 1.35;
  padding: 0 4px; border-radius: 4px; background: var(--ink); color: var(--bg);
}
.ptile-pos:empty { display: none; }
.ptile-pos.is-lib { background: var(--ball); color: var(--ball-ink); }
.zone .ptile-pos { top: 4px; right: 5px; font-size: .68rem; }
.tag-saca { display: inline-flex; align-items: center; gap: 3px; color: var(--ink) !important; }
.ball-icon { flex-shrink: 0; display: block; }
.ptile.is-server { border-color: var(--ball); }
.ptile.is-server:not(.is-selected) { box-shadow: inset 0 0 0 1px var(--ball); }
.ptile b { margin-top: 2px; }
.serve-ball { display: inline-flex; }

/* ---------- Cancha rival: elegir dónde cayó el ataque y mapa de ataque ---------- */
/* Escala de calor: un solo tono (azul de la paleta documentada), más oscuro = más ataques.
   En modo oscuro se invierte: lo poco se funde con el fondo y lo mucho brilla. */
:root {
  --heat-0: #EEF1F6; --heat-1: #B7D3F6; --heat-2: #6DA7EC; --heat-3: #2A78D6; --heat-4: #184F95;
  --hz-dot: #EB6834;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --heat-0: #1B1E27; --heat-1: #184F95; --heat-2: #2A78D6; --heat-3: #6DA7EC; --heat-4: #B7D3F6;
    --hz-dot: #D95926;
  }
}
:root[data-theme="dark"] {
  --heat-0: #1B1E27; --heat-1: #184F95; --heat-2: #2A78D6; --heat-3: #6DA7EC; --heat-4: #B7D3F6;
  --hz-dot: #D95926;
}

.court-svg { display: block; width: 100%; height: auto; max-width: 420px; margin: 0 auto; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.cs-afuera { fill: var(--surface-2); }
.cs-afuera-txt { font: 600 13px var(--body); letter-spacing: .2em; fill: var(--muted); }
.cs-red { stroke: var(--ink); stroke-width: 6; stroke-linecap: round; }
.cs-red-txt { font: 600 13px var(--body); letter-spacing: .1em; fill: var(--muted); }

/* Selector (en vivo) */
.court-picker { cursor: crosshair; }
.cs-cancha { fill: var(--court-soft); }
.cs-borde { fill: none; stroke: var(--court); stroke-width: 3; }
.cs-guia { stroke: var(--court); stroke-width: 1; opacity: .3; }
.cs-linea3 { stroke: var(--court); stroke-width: 2.5; }
.cs-num { font: 700 30px var(--display); fill: var(--court); opacity: .35; pointer-events: none; }
.cs-marca { fill: var(--ball); stroke: var(--surface); stroke-width: 3; }
/* Lo que no corresponde al resultado se ve apagado (y la app no lo acepta) */
.court-picker.no-afuera .cs-afuera { fill: var(--neutral-bg); opacity: .45; }
.court-picker.no-afuera .cs-afuera-txt { opacity: .6; }
.court-picker.no-cancha .cs-cancha { fill: var(--neutral-bg); }
.court-picker.no-cancha .cs-num, .court-picker.no-cancha .cs-guia { opacity: .12; }
.court-picker.no-cancha .cs-borde, .court-picker.no-cancha .cs-linea3 { opacity: .4; }
.cs-red-banda { fill: transparent; }
.court-picker.no-red .cs-red-banda { fill: var(--neutral-bg); opacity: .45; }
.court-picker.no-red .cs-red-txt { opacity: .5; }
.cs-aviso { font: 600 17px var(--body); fill: var(--muted); pointer-events: none; }
.pick-aviso { color: var(--bad); font-weight: 700; font-size: .92rem; min-height: 1.3em; text-align: center; }
.pick-aviso:empty { min-height: 0; }
.sheet-court .court-svg { max-width: 360px; }
.pick-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pick-actions .btn { flex: 1; min-width: 96px; }

/* Mapa (estadísticas) */
.heat-0 { fill: var(--heat-0); background: var(--heat-0); }
.heat-1 { fill: var(--heat-1); background: var(--heat-1); }
.heat-2 { fill: var(--heat-2); background: var(--heat-2); }
.heat-3 { fill: var(--heat-3); background: var(--heat-3); }
.heat-4 { fill: var(--heat-4); background: var(--heat-4); }
.hz-zona { cursor: pointer; }
.hz-zona:focus-visible, .hz-hit:focus-visible { outline: none; stroke: var(--ink); stroke-width: 3; }
.hz-label { pointer-events: none; }
.hz-label rect { fill: var(--surface); opacity: .92; }
.hz-label text { font: 700 15px var(--display); letter-spacing: .02em; fill: var(--ink); }
.hz-label.is-empty text { fill: var(--muted); }
.hz-dot { fill: var(--hz-dot); stroke: var(--surface); stroke-width: 2; pointer-events: none; }
.hz-hit { fill: transparent; cursor: pointer; }
.hz-readout { font-size: .9rem; font-weight: 600; text-align: center; min-height: 1.35em; }
.hz-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: .8rem; color: var(--muted); }
.hz-legend-title { width: 100%; font-weight: 700; color: var(--ink); }
.hz-key { display: inline-flex; align-items: center; gap: 6px; }
.hz-swatch { display: inline-block; width: 14px; height: 14px; border-radius: 3px; }
.hz-dot-key { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--hz-dot); box-shadow: 0 0 0 2px var(--surface); }
/* Armados recibidos: la cancha de la tele, con pelotitas que caen sin parar sobre cada lugar de ataque */
.arm-tv { display: block; width: 100%; max-width: 460px; margin: 0 auto; border-radius: 10px; }
.arm-logo { opacity: .92; }
.arm-pel, .arm-aura { pointer-events: none; }
/* El aura del tramo final de cada arco: que se vea, pero suave (cada pedazo se enciende un poco más con su opacity) */
.arm-aura-halo { fill: none; stroke: #FFFFFF; stroke-opacity: .08; stroke-width: 7; }
.arm-aura-linea { fill: none; stroke: #FFFFFF; stroke-opacity: .3; stroke-width: 1; }
/* Las pelotitas se animan desde JavaScript (Web Animations, en views/armado.js) */
.arm-lugar { cursor: pointer; outline: none; }
.arm-lugar rect { fill: #FFFFFF; stroke: rgba(20, 22, 28, .14); }
.arm-lugar:focus-visible rect { stroke: var(--ball); stroke-width: 2.5; }
.arm-pct { font: 700 19px var(--display); fill: #14161C; }
.arm-nombre { font: 600 10px var(--body); letter-spacing: .02em; fill: #5D6472; }
.arm-lugar.is-empty .arm-pct { fill: #5D6472; }


/* ---------- Entrar (cuenta) ---------- */
.page-entrar { justify-content: center; }
.entrar { display: flex; flex-direction: column; gap: 16px; width: 100%; max-width: 420px; margin: 0 auto; padding-top: 32px; }
.entrar-marca { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; margin-bottom: 8px; }
.entrar-logo { width: 96px; height: 96px; }
.entrar-titulo { font-family: var(--display); font-size: 2.4rem; font-weight: 700; letter-spacing: .01em; }
.entrar-aviso { background: var(--mid-bg); color: var(--ink); border-left: 4px solid var(--ball); border-radius: 8px; padding: 10px 12px; font-size: .92rem; }
.btn-google { gap: 10px; background: var(--surface); color: var(--ink); min-height: 52px; font-weight: 600; }
.entrar-o { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .9rem; }
.entrar-o::before, .entrar-o::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.input-codigo { font-family: var(--display); font-size: 1.6rem; letter-spacing: .25em; text-align: center; text-transform: uppercase; }

/* ---------- Invitaciones y personas ---------- */
.codigo-grande { font-family: var(--display); font-size: 2.8rem; font-weight: 700; letter-spacing: .12em; text-align: center; color: var(--link); background: var(--court-soft); border-radius: var(--radius); padding: 14px 8px; }
.persona { display: flex; gap: 8px; align-items: stretch; }
.persona-datos { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; overflow-wrap: anywhere; }
.persona-rol { font-weight: 600; font-size: .8rem; }
.invitados { max-height: 45vh; overflow-y: auto; }
.invitado-nombre { flex: 1; min-width: 0; display: flex; flex-direction: column; font-weight: 600; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; }

/* ---------- Inicio del jugador ---------- */
.equipo-elegir { display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 8px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); font-weight: 600; text-align: left; color: inherit; }

/* ---------- Páginas de privacidad y términos ---------- */
.legal { max-width: 720px; margin: 0 auto; line-height: 1.55; }
.legal h1 { font-family: var(--display); font-size: 2rem; font-weight: 700; }
.legal h2 { font-family: var(--display); font-size: 1.3rem; font-weight: 700; margin-top: 8px; }
.legal ul { padding-left: 1.2rem; display: flex; flex-direction: column; gap: 6px; }
.legal a { color: var(--link); }
.entrar-legal { display: flex; justify-content: center; gap: 16px; font-size: .85rem; }
.entrar-legal a { color: var(--muted); }

/* ---------- Demostración ---------- */
.demo-cinta { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; padding: 6px 12px; background: var(--ball); color: var(--ball-ink); font-size: .85rem; font-weight: 600; text-align: center; }
.demo-cinta-btn { border: 0; border-radius: 999px; padding: 4px 12px; background: var(--ball-ink); color: var(--ball); font: inherit; min-height: 32px; }
