/* ShootLab — estilos
   Marca: negro + naranja (#FE5D00) del isotipo. El naranja puro va en superficies grandes
   (botones, puntos de la cancha) con texto negro encima; para texto naranja sobre fondo
   claro se usa una variante más oscura que pasa contraste AA. Números condensados de tablero. */

/* Barlow y Barlow Condensed (SIL OFL, ver fonts/OFL.txt), alojadas en el servidor: funcionan sin señal. */
@font-face { font-family: "Barlow"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/barlow-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/barlow-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/barlow-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/barlow-condensed-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/barlow-condensed-latin-700-normal.woff2") format("woff2"); }

:root {
  --paper: #f1f1f0;
  --surface: #ffffff;
  --surface-2: #f6f6f5;
  --ink: #141414;
  --muted: #5d5d5b;
  --line: #dadad7;
  --brand: #fe5d00;        /* naranja del logo: fondos y trazos */
  --brand-ink: #141414;    /* texto sobre naranja (6.8:1) */
  --brand-text: #b84300;   /* naranja para texto sobre claro (5.5:1) */
  --brand-soft: #ffe6d6;
  --made: #1f8a4c;
  --made-soft: #dcf1e4;
  --miss: #c2402a;
  --miss-soft: #f8e1dc;
  --warn: #c98a0c;
  --court-floor: #f3e6d0;
  --court-paint: #e6e1d9;
  --court-line: #2b2b2a;

  --display: "Barlow Condensed", "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
  --body: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --tab-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0d0d0d;
    --surface: #191919;
    --surface-2: #212121;
    --ink: #f1f1f0;
    --muted: #a3a3a0;
    --line: #2f2f2e;
    --brand: #fe5d00;
    --brand-ink: #111111;
    --brand-text: #ff8a4c;
    --brand-soft: #3a1d0b;
    --made: #3dba6e;
    --made-soft: #173a26;
    --miss: #e8664f;
    --miss-soft: #43221c;
    --warn: #e5b23a;
    --court-floor: #262320;
    --court-paint: #34302b;
    --court-line: #cfcfcc;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-text); }
h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.1; margin: 0; letter-spacing: 0.01em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.muted { color: var(--muted); }
.num { font-family: var(--display); font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ------------------------------------------------------------ Layout */
#app { min-height: 100dvh; }
.screen {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px calc(var(--tab-h) + var(--safe-b) + 24px);
}
.screen.full { padding-bottom: 16px; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px; min-height: 44px;
}
.topbar h1 { flex: 1; font-size: 1.7rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back {
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface);
  display: grid; place-items: center; cursor: pointer; flex: none;
}
.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.section { margin-top: 24px; }
.section > h2 { margin-bottom: 10px; }

/* ------------------------------------------------------------ Tab bar */
.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  height: calc(var(--tab-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--surface);
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 0.78rem; font-weight: 500;
}
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a[aria-current="page"] { color: var(--brand-text); font-weight: 600; box-shadow: inset 0 3px 0 var(--brand); }

/* ------------------------------------------------------------ Controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px;
  border-radius: var(--r-md); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
  font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.danger { color: var(--miss); }
.btn.block { width: 100%; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 0.9rem; }
.btn svg { width: 20px; height: 20px; flex: none; }

.field { display: grid; gap: 6px; }
.field > span { font-weight: 600; font-size: 0.92rem; }
.input {
  width: 100%; min-height: 48px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface);
}
.input:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px var(--brand-soft); }
.error-text { color: var(--miss); font-size: 0.92rem; min-height: 1.2em; }

.seg {
  display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 3px; gap: 3px;
}
.seg button {
  min-height: 38px; padding: 0 12px; border: 0; border-radius: 7px;
  background: transparent; color: var(--muted); font-weight: 600; cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }
.seg.full { display: grid; width: 100%; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 40px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  cursor: pointer; font-weight: 500;
}
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.stepper button { width: 48px; height: 48px; border: 0; background: none; font-size: 1.4rem; cursor: pointer; }
.stepper output { min-width: 56px; text-align: center; font-family: var(--display); font-size: 1.6rem; font-weight: 700; }

/* ------------------------------------------------------------ Lists */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; min-height: 64px;
  border-top: 1px solid var(--line);
  color: inherit; text-decoration: none; background: none; width: 100%; text-align: left; border-left: 0; border-right: 0; border-bottom: 0;
  cursor: pointer;
}
.item:first-child { border-top: 0; }
.item .main { flex: 1; min-width: 0; }
.item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub { color: var(--muted); font-size: 0.88rem; }
.item .big { font-family: var(--display); font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
}
.badge.live { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.jersey {
  width: 40px; height: 40px; border-radius: 10px; flex: none;
  display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand-text);
  font-family: var(--display); font-weight: 700; font-size: 1.2rem;
}

.empty {
  text-align: center; padding: 40px 20px;
  border: 2px dashed var(--line); border-radius: var(--r-lg); color: var(--muted);
}
.empty h2 { color: var(--ink); margin-bottom: 6px; }
.empty .btn { margin-top: 16px; }

/* ------------------------------------------------------------ Stats */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 12px; }
.kpi b { display: block; font-family: var(--display); font-size: 1.8rem; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi span { color: var(--muted); font-size: 0.85rem; }
.hero-pct { display: flex; align-items: baseline; gap: 12px; margin: 4px 0 16px; }
.hero-pct b { font-family: var(--display); font-size: 4.5rem; line-height: 0.9; font-weight: 700; font-variant-numeric: tabular-nums; }
.hero-pct span { color: var(--muted); }

.bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: var(--brand); }

table.stats { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; font-size: 0.95rem; }
table.stats th, table.stats td { padding: 10px 12px; text-align: right; border-top: 1px solid var(--line); }
table.stats th:first-child, table.stats td:first-child { text-align: left; }
table.stats thead th { border-top: 0; color: var(--muted); font-weight: 600; font-size: 0.85rem; background: var(--surface-2); }
table.stats td.pct { font-family: var(--display); font-weight: 700; font-size: 1.15rem; }

.court-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 10px; }
.court { width: 100%; height: auto; display: block; touch-action: manipulation; }
.court .floor { fill: var(--court-floor); }
.court .paint { fill: var(--court-paint); }
.court .ln { fill: none; stroke: var(--court-line); stroke-width: 3; }
.court .dot { cursor: pointer; }
.court .dot circle { stroke: var(--surface); stroke-width: 3; }
.court .dot text { font-family: var(--display); font-weight: 700; font-size: 17px; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.court .dot.off circle { fill: var(--surface); stroke: var(--court-line); stroke-width: 2; stroke-dasharray: 4 3; }
.court .dot.on circle { fill: var(--brand); }
.court .dot.on text { fill: var(--brand-ink); }
.court .dot.current circle { fill: var(--brand); stroke: var(--surface); stroke-width: 4; }
.court .dot.dim circle { fill: var(--line); stroke: none; }
.court .dot.ghost circle { fill: var(--surface); stroke: var(--line); stroke-width: 2; }
.court .dot.ghost text { fill: var(--muted); }
.court-legend { display: flex; gap: 14px; justify-content: center; font-size: 0.82rem; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.court-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }

.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .avg { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .line { fill: none; stroke: var(--brand); stroke-width: 3; stroke-linejoin: round; }
.chart .pt { fill: var(--surface); stroke: var(--brand); stroke-width: 2.5; }
.chart text { font-family: var(--body); font-size: 12px; fill: var(--muted); }
.chart text.val { font-family: var(--display); font-weight: 700; font-size: 15px; fill: var(--ink); }

/* ------------------------------------------------------------ Carga de tiros (la pantalla importante) */
.shoot {
  height: 100dvh; display: grid;
  grid-template-rows: auto auto 1fr auto auto;
  max-width: 640px; margin: 0 auto;
  padding: 10px 12px calc(10px + var(--safe-b));
  gap: 10px;
}
.shoot .topbar { margin: 0; }
.shoot .topbar h1 { font-size: 1.25rem; }
.shooter {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 12px 14px; display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center;
}
.shooter .who { font-family: var(--display); font-weight: 700; font-size: 1.7rem; line-height: 1; }
.shooter .where { color: var(--muted); font-weight: 500; }
.shooter .where b { color: var(--ink); }
.shooter .count { grid-row: span 2; font-family: var(--display); font-weight: 700; line-height: 0.85; font-size: 4.2rem; font-variant-numeric: tabular-nums; text-align: right; }
.shooter .count small { font-size: 1.7rem; color: var(--muted); }
.shots-row { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; min-height: 14px; }
.shots-row i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); }
.shots-row i.m { background: var(--made); border-color: var(--made); }
.shots-row i.x { background: var(--miss-soft); border-color: var(--miss); }
.shooter .meta { grid-column: 1 / -1; display: flex; gap: 16px; color: var(--muted); font-size: 0.88rem; margin-top: 6px; }
.shooter .meta b { color: var(--ink); font-family: var(--display); font-size: 1.05rem; }

.shoot .mini { min-height: 0; display: grid; place-items: center; }
.shoot .mini svg { max-height: 100%; width: auto; max-width: 100%; }

.pad { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; height: clamp(150px, 30dvh, 260px); }
.pad button {
  border: 0; border-radius: var(--r-lg); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  font-family: var(--display); font-weight: 700; font-size: 2.1rem; letter-spacing: 0.02em;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
  transition: transform 80ms ease;
}
.pad button svg { width: 44px; height: 44px; }
.pad button:active { transform: scale(0.97); }
.pad .miss { background: var(--miss-soft); color: var(--miss); border: 2px solid var(--miss); }
.pad .made { background: var(--made); color: #fff; }
.pad button:disabled { opacity: 0.35; }

.shoot-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.shoot-actions .btn { min-height: 44px; padding: 0 8px; font-size: 0.92rem; }

.flash { animation: flash 260ms ease-out; }
@keyframes flash { from { box-shadow: 0 0 0 0 var(--flash-c); } to { box-shadow: 0 0 0 14px transparent; } }

.done-card { text-align: center; padding: 24px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.done-card b { font-family: var(--display); font-size: 3.4rem; display: block; line-height: 1; }

/* ------------------------------------------------------------ Hoja (bottom sheet) y toast */
.sheet-back { position: fixed; inset: 0; background: rgba(10, 18, 22, 0.45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 640px; max-height: 85dvh; overflow: auto;
  background: var(--paper); border-radius: 18px 18px 0 0;
  padding: 16px 16px calc(20px + var(--safe-b));
  animation: up 180ms ease-out;
}
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.set-item.active { background: var(--brand-soft); }
.set-item .done { color: var(--made); font-weight: 600; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--safe-b) + 16px); transform: translateX(-50%);
  z-index: 60; background: var(--ink); color: var(--paper);
  padding: 12px 18px; border-radius: var(--r-md); font-weight: 500;
  max-width: calc(100% - 32px); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  animation: up 160ms ease-out;
}
.toast.top { bottom: auto; top: calc(12px + env(safe-area-inset-top, 0px)); }

.sync-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 0.82rem; color: var(--muted); }
.sync-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--made); }
.sync-pill.pending i { background: var(--warn); }
.sync-pill.offline i { background: var(--miss); }

/* ------------------------------------------------------------ Auth */
.auth { max-width: 420px; margin: 0 auto; padding: 32px 20px 40px; }
.brand { display: block; margin: 8px auto 28px; width: min(280px, 78%); color: var(--ink); }
.brand svg { display: block; width: 100%; height: auto; }
.brand-mark { width: 34px; height: 34px; flex: none; display: block; }
.auth p.lead { color: var(--muted); margin: -8px 0 28px; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (min-width: 700px) {
  .tabbar { inset: auto 50% 0 auto; transform: translateX(50%); width: 640px; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

/* Íconos sueltos */
.item > svg { width: 20px; height: 20px; flex: none; color: var(--muted); }
.back svg { width: 22px; height: 22px; }

/* ------------------------------------------------------------ Planilla (anotar al terminar) */
.bulk-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 12px; border-top: 1px solid var(--line); }
.bulk-row:first-child { border-top: 0; }
.bulk-row.done { background: color-mix(in srgb, var(--made-soft) 45%, transparent); }
.bulk-label { flex: 1 1 100%; min-width: 0; }
.bulk-label .title { font-weight: 600; }
.bulk-label .sub { color: var(--muted); font-size: 0.85rem; }
.bulk-ctrl { display: flex; align-items: center; gap: 6px; width: 100%; }
.mini-step { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.mini-step button { width: 34px; height: 44px; border: 0; background: none; font-size: 1.3rem; cursor: pointer; color: var(--ink); }
.num-in {
  width: 42px; height: 44px; border: 0; background: transparent; text-align: center;
  font-family: var(--display); font-weight: 700; font-size: 1.45rem; font-variant-numeric: tabular-nums;
  -moz-appearance: textfield; appearance: textfield;
}
.num-in::-webkit-outer-spin-button, .num-in::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.num-in:focus { outline: none; background: var(--brand-soft); border-radius: 6px; }
.row-pct { margin-left: auto; font-family: var(--display); font-size: 1.25rem; min-width: 0; text-align: right; white-space: nowrap; }
.bulk-footer {
  position: sticky; bottom: 0; margin: 20px -16px 0; padding: 12px 16px calc(12px + var(--safe-b));
  background: var(--paper); border-top: 1px solid var(--line); display: grid; gap: 10px;
}
.badge.self { background: var(--brand-soft); border-color: transparent; color: var(--brand-text); }

/* ------------------------------------------------------------ Link del jugador */
.link-box { display: grid; gap: 10px; }
.link-url { font-size: 0.85rem; word-break: break-all; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 12px; user-select: all; }
.qr { background: #fff; border-radius: var(--r-md); padding: 10px; width: 220px; margin: 0 auto; }
.qr svg { width: 100%; height: auto; display: block; }
.tabbar.three { grid-template-columns: repeat(3, 1fr); }

/* El foco programático en el título (para lectores de pantalla) no necesita recuadro visible. */
h1[tabindex="-1"]:focus { outline: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
