/* Monocromo estilo Apple: blanco, negro y grises del sistema.
   Local = tinta principal, Visitante = gris medio. */
:root {
  --bg: #ffffff;
  --surface: #f5f5f7;
  --surface-2: #e8e8ed;
  --fg: #1d1d1f;
  --muted: #6e6e73;
  --line: #d2d2d7;
  --home: #1d1d1f;
  --away: #6e6e73;
  --on-team: #ffffff;
  --court: #f5f5f7;
  --court-paint: #ebebf0;
  --court-line: #b9b9bf;
  --veil: rgba(255, 255, 255, .94);
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 28px rgba(0, 0, 0, .08);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --radius: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000; --surface: #1c1c1e; --surface-2: #2c2c2e; --fg: #f5f5f7; --muted: #98989d;
    --line: #38383a; --home: #f5f5f7; --away: #8e8e93; --on-team: #000000;
    --court: #161618; --court-paint: #1f1f22; --court-line: #4a4a4e; --veil: rgba(0, 0, 0, .9);
    --shadow: 0 8px 28px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #000000; --surface: #1c1c1e; --surface-2: #2c2c2e; --fg: #f5f5f7; --muted: #98989d;
  --line: #38383a; --home: #f5f5f7; --away: #8e8e93; --on-team: #000000;
  --court: #161618; --court-paint: #1f1f22; --court-line: #4a4a4e; --veil: rgba(0, 0, 0, .9);
  --shadow: 0 8px 28px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--fg);
  font: 15px/1.45 var(--font); letter-spacing: -.01em;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
body.dock-open { padding-bottom: 260px; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
h1, h2, h3 { margin: 0; line-height: 1.15; text-wrap: balance; letter-spacing: -.02em; }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 13px; }
.mt { margin-top: 20px; }
.empty { color: var(--muted); font-size: 13px; padding: 6px 2px; }
.empty.big { font-size: 15px; text-align: center; padding: 40px 16px; }

.t-home { --tc: var(--home); --tc-on: var(--on-home, var(--on-team)); }
.t-away { --tc: var(--away); --tc-on: var(--on-away, var(--on-team)); }
.team-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--tc); flex-shrink: 0; }

/* ---------- Controles ---------- */
.btn {
  background: var(--surface); border: 0; border-radius: 999px; padding: 10px 18px;
  font-weight: 500; transition: background .15s, transform .08s, opacity .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--fg); color: var(--bg); }
.btn.primary:hover { opacity: .86; }
.btn.danger { background: transparent; box-shadow: inset 0 0 0 1px var(--fg); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.large { padding: 14px 28px; font-size: 17px; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.icon-btn { background: transparent; border: 0; border-radius: 999px; min-width: 34px; height: 34px; font-size: 18px; line-height: 1; color: var(--muted); }
.icon-btn:hover { background: var(--surface); color: var(--fg); }
.icon-btn.small { min-width: 28px; height: 28px; font-size: 13px; }
.pill { background: var(--surface); border: 0; border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 500; color: var(--muted); }
.pill b { color: var(--fg); font-weight: 600; }
.pill:hover { background: var(--surface-2); }
.pill.active { background: var(--fg); color: var(--bg); }
.pill.active b { color: var(--bg); }
.short { display: none; }
.link { background: none; border: 0; color: var(--muted); padding: 8px 0 0; font-size: 13px; display: block; margin: 0 auto; }
.link:hover { color: var(--fg); }

label { font-size: 13px; color: var(--fg); font-weight: 500; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
input, textarea, select {
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
  font-size: 15px; min-width: 0; width: 100%;
}
textarea { resize: vertical; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 14px; }

.panel { background: var(--surface); border: 0; border-radius: var(--radius); padding: 20px; margin: 0; min-width: 0; }
.panel h3 { font-size: 17px; margin-bottom: 10px; }
.panel legend { float: left; width: 100%; padding: 0; margin-bottom: 14px; font-size: 19px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.panel legend + * { clear: both; }

/* ---------- Configuración ---------- */
#setup, #report, #season { max-width: 1040px; margin: 0 auto; padding-block: 40px 64px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.eyebrow { margin: 0 0 6px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.setup-head h1 { font-size: clamp(34px, 6vw, 56px); font-weight: 700; letter-spacing: -.035em; }
.lede { font-size: 19px; color: var(--muted); margin: 10px 0 32px; max-width: 34em; }
.setup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.team-form { display: flex; flex-direction: column; gap: 8px; }
.team-form textarea { margin-top: 2px; }
.team-form label:not(:first-of-type) { margin-top: 10px; }
.setup-config { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.setup-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-top: 28px; }
.setup-meta { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.setup-meta .wide, .setup-meta legend, .setup-config legend { grid-column: 1 / -1; margin-bottom: 0; }
.setup-meta, .setup-config { align-items: end; }
.saved-team { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
.saved-team select { flex: 1; }
.saved-team .btn { white-space: nowrap; }
.team-look { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 2px; }
.look-color { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; cursor: pointer; }
.look-color input { width: 34px; height: 34px; padding: 2px; border-radius: 10px; cursor: pointer; }
.team-look .btn { display: inline-flex; align-items: center; gap: 6px; }
.logo-prev { width: 22px; height: 22px; object-fit: contain; }
.sb-logo { width: 26px; height: 26px; object-fit: contain; flex-shrink: 0; }
.sb-logo:not([hidden]) + .team-dot { display: none; }
.rp-logo { width: 34px; height: 34px; object-fit: contain; }

/* Reloj de posesión */
.sb-shot { display: flex; align-items: center; gap: 4px; }
.shot-val { min-width: 2.2ch; text-align: center; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.shot-val.warn { color: #d70015; }
.shot-val.off { color: var(--muted); }
.sb-shot .pill { padding: 2px 8px; }

/* Avisos de tiempos muertos */
.pill.none b { color: #d70015; }

/* Teclas en los botones del jugador */
.dock-grid kbd { display: none; }
@media (hover: hover) and (pointer: fine) {
  .dock-grid kbd { display: inline-block; margin-left: 6px; font: 600 10px/1 var(--font); padding: 2px 4px; border-radius: 4px; border: 1px solid currentColor; opacity: .55; vertical-align: 1px; }
}

/* Partidos guardados */
.history { margin-top: 32px; }
.history > p { margin: 0 0 12px; }
.history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.history-item { display: flex; align-items: center; gap: 12px; background: var(--bg); border-radius: 14px; padding: 12px 14px; }
.history-item.current { outline: 2px solid var(--fg); outline-offset: -2px; }
.history-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.history-main strong { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-main span { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-score { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.history-btns { display: flex; gap: 6px; align-items: center; }
.tag { display: inline-block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--fg); margin-left: 6px; vertical-align: 1px; }
.rp-meta { margin: 6px 0 0; color: var(--muted); font-size: 14px; }

/* ---------- Marcador ---------- */
.scoreboard {
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 16px; align-items: center;
  padding-block: 12px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: var(--veil); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line); position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
}
.sb-team { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name score" "meta score"; gap: 4px 16px; align-items: center; min-width: 0; }
#sb-away { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "score name" "score meta"; text-align: right; }
#sb-away .sb-name, #sb-away .sb-meta { justify-content: flex-end; }
.sb-name { grid-area: name; display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 17px; min-width: 0; }
.sb-name .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-score { grid-area: score; font-size: 52px; font-weight: 700; letter-spacing: -.04em; font-variant-numeric: tabular-nums; line-height: 1; min-width: 2ch; text-align: center; }
.sb-meta { grid-area: meta; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.sb-fouls b { color: var(--fg); font-weight: 600; }
.sb-fouls.bonus { color: var(--fg); font-weight: 600; }
.sb-fouls.bonus::after { content: "Bonus"; margin-left: 6px; padding: 1px 6px; border-radius: 999px; background: var(--fg); color: var(--bg); font-size: 10px; text-transform: uppercase; letter-spacing: .06em; }
.sb-center { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.sb-period { display: flex; align-items: center; gap: 2px; font-size: 13px; font-weight: 500; color: var(--muted); }
.sb-clock {
  font-size: 38px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.02em; line-height: 1;
  background: none; border: 0; padding: 2px 8px; border-radius: 10px; min-width: 4.2ch;
}
.sb-clock:hover { background: var(--surface); }
.sb-clock.running::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 8px; vertical-align: middle; border-radius: 50%; background: var(--fg); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .15; } }
.sb-ctrl { display: flex; gap: 6px; }
#btn-clock { min-width: 96px; padding: 7px 16px; font-size: 14px; }
#btn-finish { padding: 7px 14px; font-size: 14px; }

/* ---------- Partido ---------- */
.game-main {
  display: grid; grid-template-columns: minmax(180px, 230px) minmax(0, 1fr) minmax(180px, 230px); gap: 16px; align-items: start;
  padding-block: 16px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.court-wrap { min-width: 0; }
.court { display: block; width: 100%; max-width: 100%; height: auto; user-select: none; -webkit-user-select: none; }
#court { cursor: crosshair; touch-action: manipulation; }
.court .floor { fill: var(--court); }
.court .paint { fill: var(--court-paint); stroke: var(--court-line); stroke-width: .5; }
.court .line { fill: none; stroke: var(--court-line); stroke-width: .5; }
.court .line.dash { stroke-dasharray: 2 2; }
.court .board { stroke: var(--fg); stroke-width: 1.2; }
.court .rim { fill: none; stroke: var(--fg); stroke-width: .8; }
.court .mk { stroke: var(--bg); }
.court .mk.home { fill: var(--home); }
.court .mk.away { fill: var(--away); }
.court .mkx.home { stroke: var(--home); }
.court .mkx.away { stroke: var(--away); }
.court .faded { opacity: .55; }
.court .tap { fill: none; stroke: var(--fg); stroke-width: 1; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { r: 6.5; opacity: .4; } }
.court-tools { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; margin-top: 12px; }
.hint { margin: 0; text-align: center; font-size: 13px; color: var(--muted); }
.hint b { color: var(--fg); }

.roster { background: var(--surface); border-radius: var(--radius); padding: 12px; min-width: 0; }
.roster-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-bottom: 6px; }
.roster-head strong { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 15px; }
.roster-head strong span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roster-btns { display: flex; gap: 4px; flex-shrink: 0; }
.subs-note { font-size: 12px; background: var(--bg); border-radius: 10px; padding: 6px 10px; margin-bottom: 6px; }
.plist { display: flex; flex-direction: column; gap: 4px; }
.plist-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 8px 2px 2px; }
.pchip {
  display: grid; grid-template-columns: 34px minmax(0, 1fr); grid-template-areas: "num name" "num stat";
  text-align: left; gap: 0 10px; align-items: center; padding: 6px 8px; background: transparent;
  border: 0; border-radius: 12px; opacity: .6; transition: background .12s, opacity .12s;
}
.pchip:hover { background: var(--bg); }
.pchip.on { opacity: 1; background: var(--bg); }
.pchip.sel { box-shadow: inset 0 0 0 2px var(--fg); opacity: 1; background: var(--bg); }
.pchip.out .pname { text-decoration: line-through; color: var(--muted); }
.num { display: grid; place-items: center; border-radius: 50%; background: var(--tc); color: var(--tc-on); font-weight: 600; font-variant-numeric: tabular-nums; }
.pchip .num { grid-area: num; width: 34px; height: 34px; font-size: 14px; }
.pchip .pname { grid-area: name; font-weight: 500; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pchip .pstat { grid-area: stat; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pchip .pstat b { color: var(--fg); font-weight: 600; }
.foul-warn { color: var(--fg); font-weight: 700; }

/* ---------- Dock del jugador seleccionado ---------- */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--veil); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line);
  padding-top: 12px; padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  animation: rise .18s ease-out;
}
@keyframes rise { from { transform: translateY(16px); opacity: .4; } }
.dock-inner { max-width: 980px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.dock-head { display: flex; align-items: center; gap: 12px; }
.dock-head .num { width: 38px; height: 38px; font-size: 15px; flex-shrink: 0; }
.dock-who { min-width: 0; flex: 1; }
.dock-who strong { display: block; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dock-who span { font-size: 12px; color: var(--muted); }
.sub-btn { background: var(--fg); color: var(--bg); flex-shrink: 0; }
.sub-btn:hover { background: var(--fg); opacity: .86; }
.dock-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.dock-grid button, .act {
  border: 0; border-radius: 12px; background: var(--surface); padding: 11px 6px; font-size: 13px; font-weight: 500; line-height: 1.15;
}
.dock-grid button:hover, .act:hover { background: var(--surface-2); }
.dock-grid .made, .act.made { background: var(--fg); color: var(--bg); font-weight: 600; }
.dock-grid .made:hover, .act.made:hover { background: var(--fg); opacity: .86; }
.dock-grid .miss, .act.miss { background: transparent; box-shadow: inset 0 0 0 1.5px var(--fg); font-weight: 600; }
.dock-grid button:active, .act:active { transform: scale(.96); }

/* ---------- Pestañas ---------- */
.tabs {
  display: flex; gap: 4px; overflow-x: auto; margin-top: 8px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.tab { background: none; border: 0; border-radius: 999px; padding: 8px 16px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.tab:hover { color: var(--fg); }
.tab.active { background: var(--fg); color: var(--bg); }
.tab-panel { padding-block: 20px 56px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }

.table-wrap { overflow-x: auto; margin-bottom: 24px; border-radius: 14px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; font-size: 13px; }
th, td { padding: 9px 10px; text-align: center; white-space: nowrap; border-bottom: 1px solid var(--line); }
tbody tr:last-child td { border-bottom-color: var(--line); }
thead th { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
th[title] { cursor: help; }
td.pname, th.pname { text-align: left; }
td.dorsal { font-weight: 600; }
tr.out td { color: var(--muted); }
tfoot td { border-bottom: 0; }
tr.total td { font-weight: 600; }
tr.pct td { color: var(--muted); font-size: 12px; padding-top: 0; }
.oncourt-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--fg); margin-left: 6px; vertical-align: middle; }
.partials { max-width: 680px; }
.partials .tname { text-align: left; font-weight: 600; }
.partials .tname .team-dot { margin-right: 8px; }
.box-team h3 { display: flex; align-items: baseline; gap: 10px; margin: 0 0 10px; font-size: 19px; }
.box-team h3 .team-dot { align-self: center; }

.pbp { list-style: none; margin: 0; padding: 0; max-width: 860px; }
.pbp li { display: grid; grid-template-columns: 96px 16px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.pbp li.scoring .pbp-desc { font-weight: 600; }
.pbp-time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pbp-score { font-weight: 600; font-variant-numeric: tabular-nums; }

.filters { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.filters .field { flex: 0 1 220px; }

/* Avanzadas y temporada */
.adv-team th:first-child, .adv-team td:first-child { text-align: left; }
.lu-names { text-align: left; white-space: normal; min-width: 160px; }
.lu-names .num { display: inline-grid; width: 24px; height: 24px; font-size: 11px; margin-right: 3px; vertical-align: middle; }
.pos { color: #248a3d; font-weight: 600; }
.neg { color: #d70015; font-weight: 600; }
.glossary { font-size: 12px; color: var(--muted); margin: -12px 0 28px; max-width: 70em; }
.sec-title { font-size: 19px; margin: 8px 0 12px; display: flex; align-items: center; gap: 8px; }
.history-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.history-head h3 { margin: 0; }
/* Club y sincronización */
.club { margin-top: 32px; }
.club > p { margin: 0 0 12px; }
.club-row { display: flex; gap: 8px; max-width: 460px; }
.club-row input { flex: 1; }
.sync-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line); flex-shrink: 0; }
.sync-dot.ok { background: #34c759; }
.sync-dot.offline { background: #ff9f0a; }
.sync-dot.error { background: #d70015; }
.online p { margin: 0 0 12px; }
.online .btn-col { margin-top: 4px; }
.share-url { font-size: 13px; word-break: break-all; background: var(--bg); border-radius: 10px; padding: 8px 10px; margin: 0 0 10px; user-select: all; }
.role-note { font-size: 13px; padding: 10px 12px; border-radius: 12px; background: var(--bg); margin: 0 0 12px; }
.helper .court-tools .hint::before { content: "Ayudante · "; font-weight: 600; }
.season-head { margin-bottom: 20px; }
.season-head .btn { margin-bottom: 16px; }
.season-head h1 { font-size: clamp(30px, 5vw, 44px); font-weight: 700; letter-spacing: -.03em; }
.season-filters { align-items: flex-end; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; padding-bottom: 10px; cursor: pointer; }
.check input { width: auto; }
.season-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.res-w { font-weight: 700; }
.res-l { color: var(--muted); font-weight: 700; }
.chart-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(240px, 1fr); gap: 24px; align-items: start; }
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.kpi { background: var(--surface); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 2px; }
.kpi span { font-size: 11px; color: var(--muted); font-weight: 500; }
.kpi b { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi small { color: var(--muted); font-variant-numeric: tabular-nums; }
.zones { background: var(--surface); border-radius: 14px; overflow: hidden; }
.zones td:first-child, .zones th:first-child { text-align: left; }
.legend { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin: 12px 0 0; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend svg { width: 12px; height: 12px; }
.legend .lg-home { fill: var(--home); stroke: var(--home); }
.legend .lg-away { fill: var(--away); stroke: var(--away); }
.legend .lg-ink { fill: var(--fg); stroke: var(--fg); }

.menu-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; max-width: 1100px; }
.menu-grid .wide { grid-column: 1 / -1; }
.menu-grid .panel > p { margin: 0 0 14px; }
.btn-col { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.btn-col .btn { text-align: left; background: var(--bg); }
.shortcuts { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
kbd { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; font: 12px var(--font); color: var(--fg); }
.roster-editor { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.re-team { display: flex; flex-direction: column; gap: 6px; }
.re-row { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 6px; }
.re-num { text-align: center; }

/* ---------- Hoja y diálogo ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.dialog { z-index: 60; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .32); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.sheet-card {
  position: relative; width: min(600px, 100%); max-height: calc(100% - 32px); overflow-y: auto;
  background: var(--bg); border-radius: 22px; padding: 20px; box-shadow: var(--shadow); animation: pop .16s ease-out;
}
.dialog .sheet-card { width: min(420px, 100%); display: flex; flex-direction: column; gap: 12px; }
@keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0; } }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.sheet-head h2, .dialog h2 { font-size: 22px; font-weight: 700; }
.sheet-sub { color: var(--muted); font-size: 13px; margin-top: 4px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sheet-body { display: flex; flex-direction: column; gap: 12px; }
.dialog-text { margin: 0; color: var(--muted); }
.dialog-text:empty { display: none; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.grid-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 6px; }
.big { padding: 18px 10px; font-size: 17px; font-weight: 600; border-radius: 14px; border: 0; background: var(--surface); }
.big:hover { background: var(--surface-2); }
.big.made { background: var(--fg); color: var(--bg); }
.big.miss { background: transparent; box-shadow: inset 0 0 0 1.5px var(--fg); }
.big.wide { width: 100%; font-size: 15px; padding: 14px; }
.sheet button:active { transform: scale(.97); }
.pgroups { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.pgroup-h { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 8px; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px; }
.pgrid.roomy { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.pbtn { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 12px; border: 0; background: var(--surface); text-align: left; min-width: 0; }
.pbtn:hover { background: var(--surface-2); }
.pbtn .num { flex-shrink: 0; width: 32px; height: 32px; font-size: 13px; }
.pbtn .pname { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pbtn.out { opacity: .45; }

/* ---------- Informe final ---------- */
.rp-head { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.rp-score { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 24px; width: 100%; max-width: 760px; margin: 18px 0 6px; }
.rp-team { display: flex; flex-direction: column; gap: 8px; align-items: center; min-width: 0; }
.rp-team .rp-name { font-size: 19px; font-weight: 600; display: flex; align-items: center; gap: 8px; max-width: 100%; }
.rp-team .rp-name span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-team .rp-pts { font-size: clamp(56px, 12vw, 104px); font-weight: 700; letter-spacing: -.05em; line-height: 1; font-variant-numeric: tabular-nums; }
.rp-team.loser .rp-pts { color: var(--muted); }
.rp-dash { font-size: 40px; color: var(--muted); font-weight: 300; }
.rp-result { font-size: 15px; font-weight: 600; padding: 4px 14px; border-radius: 999px; background: var(--fg); color: var(--bg); }
.rp-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 22px 0 8px; }
.rp-section { margin-top: 48px; }
.rp-section > h2 { font-size: 28px; font-weight: 700; margin-bottom: 18px; }
.rp-section > h2 .muted { font-size: 17px; font-weight: 400; }
.rp-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.rp-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.leader { background: var(--surface); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.leader h4 { margin: 0; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.leader-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.leader-row .num { width: 30px; height: 30px; font-size: 12px; flex-shrink: 0; }
.leader-row .who { flex: 1; min-width: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leader-row .val { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.mvp { background: var(--fg); color: var(--bg); border-radius: var(--radius); padding: 20px 24px; display: flex; align-items: center; gap: 18px; margin-bottom: 12px; }
.mvp .num { width: 52px; height: 52px; font-size: 20px; background: var(--bg); color: var(--fg); }
.mvp .mvp-txt { flex: 1; min-width: 0; }
.mvp .mvp-txt small { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; opacity: .7; font-weight: 600; }
.mvp .mvp-txt strong { display: block; font-size: 22px; letter-spacing: -.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mvp .mvp-line { font-size: 14px; opacity: .8; font-variant-numeric: tabular-nums; }
.cmp { background: var(--surface); border-radius: var(--radius); padding: 8px 20px 16px; }
.cmp-head { display: grid; grid-template-columns: 1fr 1fr; padding: 10px 0 4px; font-weight: 600; font-size: 14px; }
.cmp-head span { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cmp-head span:last-child { justify-content: flex-end; }
.cmp-row { display: grid; grid-template-columns: 4.5em minmax(0, 1fr) minmax(0, 1fr) 4.5em; grid-template-areas: "lbl lbl lbl lbl" "vh bh ba va"; gap: 4px 4px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.cmp-row:last-child { border-bottom: 0; }
.cmp-lbl { grid-area: lbl; text-align: center; font-size: 12px; color: var(--muted); font-weight: 500; }
.cmp-v { font-weight: 600; font-variant-numeric: tabular-nums; font-size: 15px; }
.cmp-v.h { grid-area: vh; }
.cmp-v.a { grid-area: va; text-align: right; }
.cmp-v.lead { font-weight: 700; }
.cmp-bar { height: 8px; display: flex; }
.cmp-bar.h { grid-area: bh; justify-content: flex-end; }
.cmp-bar.a { grid-area: ba; }
.cmp-bar i { display: block; height: 100%; background: var(--tc); min-width: 2px; }
.cmp-bar.h i { border-radius: 4px 0 0 4px; }
.cmp-bar.a i { border-radius: 0 4px 4px 0; }
.flow { background: var(--surface); border-radius: var(--radius); padding: 18px 20px; }
.flow-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.flow-stats div { display: flex; flex-direction: column; }
.flow-stats span { font-size: 12px; color: var(--muted); }
.flow-stats b { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.flow-svg { width: 100%; height: auto; display: block; overflow: visible; }
.flow-svg .grid { stroke: var(--line); stroke-width: 1; }
.flow-svg .zero { stroke: var(--muted); stroke-width: 1; }
.flow-svg .area-home { fill: var(--home); opacity: .16; }
.flow-svg .area-away { fill: var(--away); opacity: .28; }
.flow-svg .ln { fill: none; stroke: var(--fg); stroke-width: 2; stroke-linejoin: round; }
.flow-svg text { fill: var(--muted); font: 11px var(--font); }
.flow-svg .hit { fill: transparent; }
.flow-svg .hit:hover { fill: var(--fg); }
.rp-shot { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.rp-shot h3 { font-size: 17px; display: flex; align-items: center; gap: 8px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 16px); z-index: 70;
  background: var(--fg); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 500; font-size: 14px;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .2s; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
body.dock-open .toast { bottom: calc(250px + env(safe-area-inset-bottom, 0px)); }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .game-main { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .court-wrap { grid-column: 1 / -1; order: -1; }
  .chart-layout { grid-template-columns: 1fr; }
  .menu-grid { grid-template-columns: 1fr 1fr; }
  .rp-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  body { font-size: 14px; }
  body.dock-open { padding-bottom: 300px; }
  body.dock-open .toast { bottom: calc(290px + env(safe-area-inset-bottom, 0px)); }
  #setup, #report, #season { padding-block: 24px 48px; }
  .setup-grid, .menu-grid, .roster-editor, .rp-grid2 { grid-template-columns: 1fr; }
  .setup-config { grid-template-columns: 1fr 1fr; gap: 10px; }
  .setup-meta { grid-template-columns: 1fr 1fr; gap: 10px; }
  .history-item { flex-wrap: wrap; }
  .season-kpis { grid-template-columns: 1fr 1fr; }
  .history-btns { width: 100%; justify-content: flex-end; }
  .scoreboard { gap: 8px; padding-block: 8px; }
  .sb-team, #sb-away { grid-template-columns: minmax(0, 1fr); grid-template-areas: "name" "score" "meta"; text-align: center; }
  .sb-name, #sb-away .sb-name, .sb-meta, #sb-away .sb-meta { justify-content: center; }
  .sb-name { font-size: 13px; }
  .sb-score { font-size: 38px; }
  .sb-meta { gap: 4px; }
  .sb-meta .pill { padding: 3px 8px; font-size: 11px; }
  .long { display: none; }
  .short { display: inline; }
  .roster-head { flex-direction: column; align-items: stretch; }
  .roster-btns .pill:first-child { flex: 1; }
  .sb-clock { font-size: 28px; }
  #btn-clock { min-width: 0; padding: 6px 12px; }
  .game-main { gap: 10px; padding-block: 10px; }
  .court-tools { grid-template-columns: 1fr 1fr; }
  .hint { grid-column: 1 / -1; order: -1; }
  .roster { padding: 8px; }
  .pchip { grid-template-columns: 28px minmax(0, 1fr); gap: 0 8px; padding: 5px 6px; }
  .pchip .num { width: 28px; height: 28px; font-size: 12px; }
  .pchip .pname { font-size: 13px; }
  .dock-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .dock-grid button { padding: 10px 4px; font-size: 12px; }
  .sheet { align-items: flex-end; padding: 0; }
  .sheet-card { border-radius: 22px 22px 0 0; max-height: 90%; padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
  .dialog { align-items: center; padding: 16px; }
  .dialog .sheet-card { border-radius: 22px; }
  .pbp li { grid-template-columns: 64px 12px minmax(0, 1fr) auto auto; gap: 6px; }
  .rp-score { gap: 10px; }
  .rp-team .rp-name { font-size: 15px; }
  .rp-dash { font-size: 28px; }
  .flow-stats { grid-template-columns: 1fr 1fr; }
  .mvp { padding: 16px; gap: 12px; }
  .mvp .mvp-txt strong { font-size: 18px; }
}

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

/* ---------- Marcador en directo (directo.html) ---------- */
.live { max-width: 1040px; margin: 0 auto; padding-block: 28px 56px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.live-head { text-align: center; margin-bottom: 28px; }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #d70015; margin-right: 6px; vertical-align: 1px; animation: blink 1.4s steps(2, start) infinite; }
.live-score { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 12px; margin-top: 12px; }
.live-team { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.live-logo { width: 44px; height: 44px; object-fit: contain; }
.live-team .team-dot { width: 14px; height: 14px; }
.live-name { font-size: 18px; font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-pts { font-size: clamp(52px, 12vw, 84px); font-weight: 700; letter-spacing: -.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.live-mid { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.live-period { font-size: 13px; color: var(--muted); font-weight: 500; }
.live-clock { font-size: clamp(26px, 6vw, 40px); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.live-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.live .partials { margin-inline: auto; }
.live .pbp li { grid-template-columns: 76px 16px minmax(0, 1fr) auto 0; }
.live-foot { text-align: center; margin-top: 32px; }
@media (max-width: 760px) { .live-grid { grid-template-columns: 1fr; } }
