/* Basket Studio Live © UXIO DIGITAL S.L. — diseño horizontal para iPhone 15 Pro Max (932×430 pt).
   Línea visual: superficies planas de pizarra, sin bordes; el único color fuerte es el del equipo.
   Los botones de anotar toman el color del equipo seleccionado. Números en la tipografía redondeada del sistema. */

:root {
  /* Áreas seguras como variables para poder simularlas en pruebas. */
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);

  /* Paleta del logotipo: azul noche, cian del balón y rojo de «LIVE». */
  --bg: #0b1622;
  --s1: #112131;      /* superficie */
  --s2: #182b3e;      /* superficie elevada / pulsable */
  --s3: #21384f;      /* pulsado / activo */
  --line: rgba(120, 200, 255, .09);
  --text: #f1f6fb;
  --muted: #8ea3b7;
  --faint: #5a7086;
  --ok: #3ddc97;
  --warn: #f5b942;
  --bad: #ff6b6e;
  --violet: #b9a4ff;
  --brand: #2fd2f4;       /* cian del balón: acento de marca y líneas de pista */
  --brand-ink: #04202c;
  --live: #e8213a;        /* rojo del rótulo «LIVE» */
  --tc: #ff6a2b;      /* color del equipo seleccionado (lo fija la app) */
  --tc-ink: #fff;

  --num: ui-rounded, 'SF Pro Rounded', -apple-system, system-ui, sans-serif;
  --gap: 6px;
  --r: 12px;
  --r-sm: 9px;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; overscroll-behavior: none; }
body {
  font: 500 13px/1.2 -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
  position: fixed; inset: 0;
}
button {
  font: inherit; color: inherit; background: var(--s2); border: 0; border-radius: var(--r-sm);
  padding: 0 6px; min-width: 0; touch-action: manipulation; cursor: pointer;
  transition: transform .08s ease-out, background-color .12s;
}
button:active, button.pressed { transform: scale(.97); background-color: var(--s3); }
button:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ------------------------------------------------------------------ Estructura */
.app {
  position: fixed; inset: 0;
  padding: max(var(--sat), 6px) max(var(--sar), 8px) max(var(--sab), 6px) max(var(--sal), 8px);
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: var(--gap);
}

/* ------------------------------------------------------------------ Marcador: una franja plana */
.sb { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: var(--gap); height: 54px; }
.sb-team {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 14px;
  background: transparent; border-radius: var(--r); text-align: left; overflow: hidden;
}
.sb-team.away { text-align: right; }
.sb-team.sel { background: var(--s1); }
.sb-meta { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.sb-team.away .sb-meta { align-items: flex-end; }
.sb-name { display: flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.sb-name::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }
.sb-team.away .sb-name { flex-direction: row-reverse; }
.sb-name:has(.logo)::before { display: none; }
.sb-sub { display: flex; gap: 10px; font-size: 11px; color: var(--muted); align-items: center; white-space: nowrap; }
.sb-team.away .sb-sub { flex-direction: row-reverse; }
.sb-score { font: 600 40px/1 var(--num); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.sb-score.flash { animation: flash .45s ease-out; }
@keyframes flash { 0% { color: var(--c); transform: scale(1.1); } 100% { color: var(--text); transform: none; } }
.pips { display: inline-flex; gap: 3px; vertical-align: middle; }
.pips i { width: 6px; height: 6px; border-radius: 50%; background: var(--s3); display: block; }
.pips i.on { background: var(--warn); }
.bonus .pips i.on { background: var(--bad); }
.bonus-tag { color: var(--bad); font-weight: 650; }

.sb-center { display: flex; align-items: center; gap: var(--gap); }
.sb-period { height: 54px; width: 56px; font: 600 13px/1 var(--num); color: var(--muted); background: var(--s1); }
.sb-period.ended { background: var(--warn); color: #1d1500; animation: pulse 1.2s infinite; }
.sb-period.break { color: var(--warn); }
@keyframes pulse { 50% { opacity: .7; } }
.sb-clockbox { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 54px; width: 132px; border-radius: var(--r); background: var(--s1); }
.sb-clock { background: none; font: 600 30px/34px var(--num); font-variant-numeric: tabular-nums; padding: 0; height: 34px; width: 100%; }
.sb-clock:active { background: none; }
.sb-clock.running { color: var(--ok); }
.sb-clock.low { color: var(--bad); }
.sb-session { font: 500 10px/1 var(--num); color: var(--faint); font-variant-numeric: tabular-nums; }
.sb-phase { height: 54px; min-width: 112px; padding: 0 16px; border-radius: 27px; font: 650 15px/1 var(--num); background: var(--ok); color: #062517; white-space: nowrap; }
.sb-phase:active { background: var(--ok); filter: brightness(1.1); }
.sb-phase.playing { background: var(--s2); color: var(--bad); }
.sb-phase.playing:active { background: var(--s3); }
.sb-phase.final { background: var(--bad); color: #fff; }
.sb-phase.finished { background: var(--s1); color: var(--faint); }
.sb-clock.raw { color: var(--text); }
.sb-clock.raw.running { color: var(--text); }
.sb-play { width: 54px; height: 54px; border-radius: 50%; font-size: 20px; background: var(--ok); color: #062517; }
.sb-play:active { background: var(--ok); }
.sb-play.running { background: var(--bad); color: #fff; }

/* ------------------------------------------------------------------ Pista */
.court { display: grid; grid-template-columns: minmax(150px, 0.95fr) minmax(0, 2.1fr) minmax(150px, 0.95fr); gap: var(--gap); min-height: 0; }
.roster {
  display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 30px; grid-auto-rows: minmax(0, 1fr); gap: 4px; min-height: 0;
}
.roster.dense { grid-template-columns: 1fr 1fr 1fr; }
.r-team { grid-column: 1 / -1; font-size: 12px; color: var(--muted); text-align: left; background: transparent; padding: 0 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-team.sel { color: var(--c-ink, #fff); background: var(--c); }
.pl { padding: 2px 6px; background: transparent; color: var(--faint); position: relative; overflow: hidden; text-align: left; }
.pl.on { background: var(--s1); color: var(--text); }
.pl-in { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: 1fr 1fr; column-gap: 8px; align-items: center; height: 100%; width: 100%; }
.pl-in.has-av { grid-template-columns: auto auto minmax(0, 1fr); }
.pl .n { grid-row: 1 / 3; font: 600 20px/1 var(--num); font-variant-numeric: tabular-nums; min-width: 26px; text-align: center; }
.pl .nm { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; align-self: end; }
.pl .st { display: flex; gap: 6px; align-items: center; font: 500 10px/1 var(--num); color: var(--muted); align-self: start; padding-top: 3px; white-space: nowrap; }
.pl .pips i { width: 5px; height: 5px; }
.pl .pips.f4 i.on { background: var(--bad); }
.pl.sel { background: var(--c); color: var(--c-ink, #fff); }
.pl.sel .st, .pl.sel .nm { color: var(--c-ink, #fff); }
.pl.sel .pips i { background: color-mix(in srgb, var(--c-ink, #fff) 25%, transparent); }
.pl.sel .pips i.on { background: var(--c-ink, #fff); }
.pl.dq { opacity: .4; }
.pl.dq .nm { text-decoration: line-through; }
.dense .pl { padding: 1px; text-align: center; }
.dense .pl-in { grid-template-columns: 1fr; grid-template-rows: auto auto; justify-items: center; align-content: center; }
.dense .pl .n { grid-row: auto; font-size: 17px; }
.dense .pl .nm { display: none; }
.dense .pl .st { justify-content: center; }
.roster.subbing .pl { background: var(--s1); }
.roster.subbing .pl:not(.on) { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.roster.subbing .pl.out-draft { box-shadow: inset 0 0 0 2px var(--bad); background: transparent; }
.roster.subbing .pl.in-draft { box-shadow: inset 0 0 0 2px var(--ok); }

/* En juego: sólo los cinco en pista, una columna de filas grandes. */
.roster.court { grid-template-columns: 1fr; }
.roster.court .pl { padding: 2px 8px 2px 6px; }
.roster.court .pl .n { font-size: 26px; min-width: 34px; }
.roster.court .pl .nm { font-size: 15px; font-weight: 600; }
.roster.court .pl .st { font-size: 11px; }
.roster.court .pl .pips i { width: 6px; height: 6px; }

/* Fotos y escudos */
.av, .av-lg, .logo { display: block; flex: none; overflow: hidden; border-radius: 50%; background: color-mix(in srgb, var(--c, #8b95a1) 22%, var(--s2)); }
.av img, .av-lg img, .logo img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.logo { border-radius: 4px; background: none; width: 20px; height: 20px; }
.logo img { object-fit: contain; }
.pl-in .av { grid-row: 1 / 3; width: 30px; height: 30px; }
.roster.court .pl-in .av { width: 42px; height: 42px; }
.pl.sel .av { box-shadow: 0 0 0 2px var(--c-ink, #fff); }
.dense .pl-in .av { display: none; }

/* ------------------------------------------------------------------ Panel central */
.pad { display: grid; gap: var(--gap); min-height: 0; grid-template-rows: 18px minmax(0, 1.35fr) minmax(0, .85fr) minmax(0, 3fr); position: relative; }
.mode-basic .pad { grid-template-rows: 18px minmax(0, 2fr) minmax(0, 2fr); }
.mode-basic .adv, .mode-advanced .basic { display: none !important; }
.sel-label { font-size: 12px; font-weight: 600; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--tc); line-height: 18px; }
.made, .miss { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap); min-height: 0; }
.stats { display: grid; grid-template-columns: repeat(5, 1fr); grid-auto-rows: minmax(0, 1fr); gap: var(--gap); min-height: 0; }
.stats.basic { grid-template-columns: repeat(2, 1fr); }
.act { font-size: 13px; font-weight: 600; line-height: 1.1; background: var(--s1); }
.made-btn { background: var(--tc); color: var(--tc-ink); font: 600 32px/1 var(--num); border-radius: var(--r); }
.made-btn:active { background: var(--tc); filter: brightness(1.15); }
.mode-basic .made-btn { font-size: 44px; }
.miss-btn { background: transparent; box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--tc) 55%, transparent); color: var(--text); font: 600 15px/1 var(--num); }
.foul { color: var(--bad); }
.neg { color: #ffa48a; }
.to { color: var(--warn); }
.sub { color: var(--ok); }
.hl { color: var(--violet); }
.star { font-size: 22px; }
.span2 { grid-column: span 2; }
.mode-basic .stats .act { font-size: 16px; }

.subpanel {
  position: absolute; inset: 24px 0 0 0; background: var(--s1); border-radius: var(--r);
  display: grid; grid-template-rows: auto 1fr auto; padding: 12px; gap: 8px; z-index: 2;
}
.subpanel h3 { margin: 0; font-size: 14px; font-weight: 600; text-align: center; }
.subpanel .lines { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 13px; align-content: start; }
.subpanel .lines div { line-height: 1.5; }
.subpanel .lines > div { background: var(--s2); border-radius: var(--r-sm); padding: 8px 10px; }
.subpanel .lines b { display: block; margin-bottom: 2px; font-weight: 650; }
.subpanel .warn { color: var(--warn); }
.subpanel .btns { display: grid; grid-template-columns: 1fr 2fr; gap: 6px; }
.subpanel .btns button { height: 46px; font-size: 15px; font-weight: 600; }
.subpanel .ok { background: var(--ok); color: #062517; }

/* ------------------------------------------------------------------ Barra inferior */
.bar { display: grid; grid-template-columns: 44px 112px minmax(0, 1fr) 60px 80px 86px 44px; gap: var(--gap); height: 40px; }
.bar-btn { font-size: 13px; font-weight: 600; background: var(--s1); color: var(--text); }
.bar-btn.sync { color: var(--ok); }
.bar-btn.exit { font-size: 17px; color: var(--muted); }
.menu-item.danger b { color: var(--bad); }
#undo { color: var(--warn); }
.ticker { display: flex; align-items: center; gap: 10px; padding: 0 12px; border-radius: var(--r-sm); font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.ticker .num { font-family: var(--num); color: var(--faint); }
.ticker b { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.ticker button { height: 30px; flex: none; font-size: 12px; padding: 0 10px; }
.ticker.fresh { animation: tick .6s ease-out; }
@keyframes tick { 0% { background: var(--s2); } 100% { background: transparent; } }

/* ------------------------------------------------------------------ Hojas (overlays) */
.sheet-bg { position: fixed; inset: 0; background: rgba(8, 10, 13, .6); z-index: 20; display: flex; }
.sheet {
  margin: auto; background: var(--s1); border-radius: 16px;
  width: min(880px, calc(100vw - max(var(--sal), 8px) - max(var(--sar), 8px)));
  max-height: calc(100dvh - max(var(--sat), 8px) - max(var(--sab), 8px));
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden;
  -webkit-user-select: text; user-select: text;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .45);
}
.sheet.small { width: min(520px, 94vw); }
.sheet-h { display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 16px; }
.sheet-h h2 { font-size: 16px; font-weight: 650; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-h button { height: 36px; min-width: 40px; }
.sheet-b { overflow: auto; padding: 4px 16px 14px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.sheet-f { display: flex; gap: 8px; padding: 10px 12px; justify-content: flex-end; flex-wrap: wrap; border-top: 1px solid var(--line); }
.sheet-f button, .sheet-b .btn { height: 42px; padding: 0 16px; font-weight: 600; }
.primary { background: var(--text); color: var(--bg); }
.primary:active { background: #d6dbe1; }
.danger { color: var(--bad); }
.tabs { display: flex; gap: 2px; background: var(--bg); padding: 3px; border-radius: 11px; }
.tabs button { height: 30px; font-size: 13px; background: transparent; color: var(--muted); padding: 0 12px; border-radius: 8px; }
.tabs button.on { background: var(--s2); color: var(--text); }

.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.form label { display: grid; gap: 5px; font-size: 12px; color: var(--muted); }
.form label.wide { grid-column: 1 / -1; }
.form label.check { grid-template-columns: auto 1fr; align-items: center; color: var(--text); font-size: 14px; }
input, select, textarea {
  font: 500 16px/1.3 -apple-system, system-ui, sans-serif; /* 16px evita el zoom automático de iOS */
  background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; width: 100%;
  -webkit-user-select: text; user-select: text;
}
input:focus, textarea:focus { outline: none; border-color: var(--muted); }
input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--ok); }
input[type=color] { height: 42px; padding: 3px; }
textarea { min-height: 150px; font-family: ui-monospace, Menlo, monospace; font-size: 16px; }
.hint { font-size: 12px; color: var(--muted); font-weight: 400; line-height: 1.45; }
.warn { color: var(--warn); }
.starters { display: flex; flex-wrap: wrap; gap: 6px; }
.starters button { height: 42px; min-width: 52px; font-family: var(--num); font-size: 16px; }
.starters button.on { background: var(--ok); color: #062517; }

.evlist { display: grid; gap: 2px; }
.ev { display: grid; grid-template-columns: 62px 74px 66px 1fr auto; gap: 10px; align-items: center; text-align: left; padding: 8px 10px; height: auto; min-height: 42px; background: transparent; font-weight: 500; }
.ev:nth-child(odd) { background: color-mix(in srgb, var(--s2) 45%, transparent); }
.ev .t { color: var(--muted); font: 500 12px/1 var(--num); font-variant-numeric: tabular-nums; }
.ev.del { opacity: .4; text-decoration: line-through; }
.ev.sys { color: var(--muted); }
.ev .rev { font-size: 11px; color: var(--warn); }
.grid-pick { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 14px; }
.grid-pick button { height: 42px; min-width: 52px; padding: 0 12px; }
.grid-pick button.on { background: var(--text); color: var(--bg); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.row .btn { flex: none; }
.big-clock { font: 600 48px/1.1 var(--num); font-variant-numeric: tabular-nums; text-align: center; margin: 8px 0; }
.list { display: grid; gap: 4px; }
.list .item { display: flex; align-items: center; gap: 10px; background: var(--s2); border-radius: 10px; padding: 8px 10px; font-size: 13px; }
.list .item span { flex: 1; min-width: 0; }
.list .item button { height: 36px; background: var(--s3); }
table.box { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
table.box th, table.box td { padding: 6px 6px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
table.box th:first-child, table.box td:first-child { text-align: left; }
table.box th { color: var(--muted); font-size: 11px; font-weight: 500; }
table.box td { font-family: var(--num); }
table.box td:first-child { font-family: inherit; }
h4 { margin: 16px 0 8px; font-size: 14px; font-weight: 650; }

/* ------------------------------------------------------------------ Preparación / final */
.overlay {
  position: fixed; inset: 0; z-index: 15; background: var(--bg);
  padding: max(var(--sat), 8px) max(var(--sar), 10px) max(var(--sab), 8px) max(var(--sal), 10px);
  display: flex;
}
.ov-setup { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 0.8fr) minmax(0, 1fr); gap: 10px; min-height: 0; }
.ov-team { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); gap: 8px; min-height: 0; }
.ov-team-h { display: flex; align-items: center; gap: 8px; min-width: 0; height: 36px; font-size: 14px; }
.ov-team-h::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }
.ov-team-h:has(.logo)::before { display: none; }
.ov-team-h b { flex: 1; min-width: 0; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ov-team-h .ok { color: var(--ok); }
.ov-team-h .warn { color: var(--warn); }
.ov-grid { display: grid; grid-template-columns: repeat(3, 1fr); grid-auto-rows: minmax(0, 1fr); gap: 6px; min-height: 0; }
.ov-grid button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; background: var(--s1); color: var(--muted); min-height: 36px; }
.ov-grid button .n { font: 600 21px/1 var(--num); color: var(--text); }
.ov-grid button .nm { font-size: 11px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ov-grid button.on { background: var(--c); color: var(--c-ink, #fff); }
.ov-grid button.on .n { color: inherit; }
.ov-grid .av-lg { width: 46px; height: 46px; }
.ov-grid.dense .av-lg { width: 34px; height: 34px; }
.ov-grid.dense .nm { display: none; }
.ov-mid { display: flex; flex-direction: column; justify-content: center; gap: 12px; text-align: center; padding: 0 6px; }
.ov-mid h2 { margin: 0; font-size: 20px; font-weight: 650; }
.ov-mid .hint { margin: 0; }
.ov-mid { gap: 10px; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; background: var(--s1); padding: 3px; border-radius: 12px; }
.seg button { height: 38px; background: transparent; color: var(--muted); font-weight: 600; font-size: 13px; padding: 0 2px; }
.seg button.on { background: var(--s3); color: var(--text); }
.fmt { font-family: var(--num); }
.dt { display: grid; grid-template-columns: 1.4fr 1fr; gap: 6px; }
.dt input { padding: 7px 8px; font-size: 16px; min-width: 0; }
.ov-links { display: flex; align-items: center; justify-content: center; gap: 8px; }
.ov-links .ov-edit { height: 36px; }
.ov-team-h .side { font-size: 12px; color: var(--muted); font-weight: 500; flex: none; }
.ov-start { height: 64px; background: var(--ok); color: #062517; font-size: 17px; font-weight: 650; border-radius: 16px; }
.ov-start:active { background: var(--ok); filter: brightness(1.1); }
.ov-edit { height: 42px; background: transparent; color: var(--muted); }
.ov-imp { height: 34px; font-size: 12px; padding: 0 10px; background: var(--s1); color: var(--muted); }
.ov-card { margin: auto; background: var(--s1); border-radius: 18px; padding: 20px 24px; text-align: center; width: min(640px, 100%); }
.ov-card h2 { margin: 0 0 10px; font-size: 18px; font-weight: 650; }
.ov-score { display: flex; justify-content: center; align-items: center; gap: 20px; font-size: 17px; font-weight: 650; }
.ov-score b { font: 600 44px/1 var(--num); font-variant-numeric: tabular-nums; }
.ov-btns { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; }
.ov-btns button { height: 44px; padding: 0 16px; font-weight: 600; }

/* ------------------------------------------------------------------ Avisos */
.banner { position: fixed; left: 50%; transform: translateX(-50%) translateY(var(--dy, 0px)); transition: transform .2s, opacity .2s; touch-action: none; cursor: grab; top: max(var(--sat), 8px); z-index: 40; background: var(--bad); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 13px; font-weight: 500; max-width: 80vw; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); }
.banner.info { background: var(--text); color: var(--bg); }
.banner.dragging { transition: none; }
.banner::after { content: ''; display: block; width: 32px; height: 3px; margin: 7px auto -3px; border-radius: 2px; background: currentColor; opacity: .25; }
.flash-sync { position: fixed; inset: 0; background: #fff; z-index: 50; pointer-events: none; animation: fsync .35s forwards; }
@keyframes fsync { to { opacity: 0; } }

/* Pantallas más bajas (Safari con barras visibles, móviles pequeños) */
@media (max-height: 380px) {
  .sb { height: 46px; }
  .sb-period, .sb-clockbox { height: 46px; }
  .sb-play { width: 46px; height: 46px; }
  .sb-phase { height: 46px; }
  .sb-score { font-size: 34px; }
  .sb-clock { font-size: 26px; height: 30px; line-height: 30px; }
  .bar { height: 36px; }
  .made-btn { font-size: 26px; }
  .pl .n { font-size: 17px; }
  .roster.court .pl .n { font-size: 22px; }
  .roster.court .pl-in .av { width: 34px; height: 34px; }
}
@media (min-width: 1200px) {
  .app { max-width: 1200px; margin: 0 auto; }
}

/* ================================================================== Pantallas previas */
body:not([data-screen="game"]) #app { visibility: hidden; }
.scr {
  position: fixed; inset: 0; z-index: 12; background: var(--bg);
  padding: max(var(--sat), 10px) max(var(--sar), 12px) max(var(--sab), 10px) max(var(--sal), 12px);
  display: grid; gap: 10px; min-height: 0;
}
.face { display: block; flex: none; border-radius: 50%; overflow: hidden; background: color-mix(in srgb, var(--c, #8b95a1) 26%, var(--s2)); }
.face img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.face.no-photo { display: grid; place-items: center; font: 650 13px/1 var(--num); color: var(--c, var(--text)); }
.ghost { background: transparent; color: var(--muted); height: 38px; padding: 0 10px; font-size: 14px; font-weight: 500; }
.ghost:active { background: var(--s1); }
.cta { height: 50px; padding: 0 28px; border-radius: 14px; background: var(--text); color: var(--bg); font-size: 16px; font-weight: 650; }
.cta:active { background: #d7dce2; }
.cta:disabled { opacity: .3; }
.cta.go { background: var(--ok); color: #062517; }
.cta.go:active { background: var(--ok); filter: brightness(1.08); }
.scr-top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; height: 40px; }
.scr-top > :first-child { justify-self: start; }
.scr-top > :last-child { justify-self: end; }
.scr-top h1 { margin: 0; font-size: 16px; font-weight: 650; white-space: nowrap; }
.brand-mini { font-size: 13px; color: var(--muted); }
.brand-mini b { display: inline-block; margin-left: 4px; padding: 1px 7px 1px 6px; transform: skewX(-12deg); background: var(--live); color: #fff; font: italic 800 11px/1.5 var(--num); letter-spacing: .04em; text-transform: uppercase; }
.user::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 7px; vertical-align: middle; }

/* --- Acceso ---------------------------------------------------------------- */
.login { grid-template-columns: minmax(0, 1.15fr) minmax(300px, 1fr); gap: 14px; }
.login-brand {
  position: relative; overflow: hidden; border-radius: 22px; padding: 26px 28px;
  background: radial-gradient(120% 90% at 85% 10%, rgba(47, 210, 244, .16), transparent 60%), linear-gradient(155deg, #13263a 0%, #0d1a28 70%);
  display: flex; flex-direction: column; justify-content: flex-end; gap: 10px;
}
.login-art-wrap { position: absolute; top: -18%; left: auto; right: -28%; height: 136%; aspect-ratio: 1; color: var(--brand); opacity: .09; pointer-events: none; }
.login-art { width: 100%; height: 100%; }
.wordmark { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 14px; }
.logo-icon { width: 96px; height: 96px; filter: drop-shadow(0 10px 24px rgba(0, 0, 0, .45)); }
.logo-word { width: min(100%, 380px); height: auto; }
.login-claim { position: relative; margin: 0; max-width: 28ch; font-size: 15px; line-height: 1.4; color: var(--muted); }
.login-legal { position: relative; margin: 6px 0 0; font-size: 11px; color: var(--faint); }
.login-panel { display: flex; align-items: center; justify-content: center; overflow: auto; min-height: 0; }
.login-form { width: min(340px, 100%); display: grid; gap: 12px; padding: 8px 4px; }
.login-form h1 { margin: 0 0 4px; font-size: 24px; font-weight: 650; letter-spacing: -.01em; }
.field { display: grid; gap: 6px; font-size: 12px; color: var(--muted); }
.field input { height: 48px; background: var(--s1); border: 1px solid transparent; border-radius: 12px; padding: 0 14px; }
.field input:focus { border-color: var(--brand); background: var(--s2); }
.pw { position: relative; display: block; }
.pw input { padding-right: 86px; }
.pw-toggle { position: absolute; right: 6px; top: 6px; height: 36px; padding: 0 10px; font-size: 13px; background: transparent; color: var(--muted); }
.login-err { margin: 0; padding: 10px 12px; border-radius: 12px; font-size: 13px; line-height: 1.4; color: #ffd1d4; background: color-mix(in srgb, var(--live) 16%, transparent); box-shadow: inset 3px 0 0 var(--live); }
.login-err:empty { display: none; }
.login-go { height: 52px; border-radius: 14px; background: linear-gradient(180deg, #5ee7ff, #14b8e6); color: var(--brand-ink); font-size: 16px; font-weight: 650; }
.login-go:active { background: var(--brand); filter: brightness(1.08); }
.login-note { margin: 2px 0 0; font-size: 12px; line-height: 1.45; color: var(--faint); }

/* --- Crear partido ---------------------------------------------------------- */
.create { grid-template-rows: auto minmax(0, 1fr) auto; }
.create-body { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.4fr); gap: 14px; min-height: 0; }
.create-when { background: var(--s1); border-radius: 18px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.create-when h2 { margin: 2px 0 0; font-size: 12px; font-weight: 600; color: var(--muted); }
.create-when .dt { display: grid; grid-template-columns: 1.35fr 1fr; gap: 8px; }
.create-when .dt input { height: 44px; background: var(--s2); border-color: transparent; }
.create-when .seg { background: var(--bg); }
.create-when .seg button { height: 40px; }
.fmt { margin: 0; font: 500 12px/1.4 var(--num); color: var(--muted); }
.create-teams { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 10px; min-height: 0; }
.team-pick {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  background: var(--s1); border-radius: 18px; padding: 30px 12px 16px; min-width: 0;
  box-shadow: inset 0 3px 0 var(--c, transparent);
}
.team-pick:active { background: var(--s2); }
.team-pick:disabled { opacity: .55; }
.team-pick.empty { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); }
.tp-role { position: absolute; top: 12px; left: 14px; font-size: 12px; color: var(--muted); }
.crest { width: 70px; height: 70px; border-radius: 50%; display: grid; place-items: center; overflow: hidden; background: color-mix(in srgb, var(--c) 22%, var(--s2)); font: 700 18px/1 var(--num); color: var(--c); }
.crest img { width: 100%; height: 100%; object-fit: contain; padding: 8px; }
.crest:not(.no-logo) { background: color-mix(in srgb, var(--c) 10%, var(--s2)); }
.crest.empty { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); color: var(--muted); font-size: 28px; font-weight: 400; }
.crest.sm { width: 24px; height: 24px; font-size: 9px; }
.crest.sm img { padding: 2px; }
.tp-name { font-size: 17px; font-weight: 650; text-align: center; line-height: 1.2; max-width: 100%; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tp-meta { font-size: 12px; color: var(--muted); text-align: center; }
.swap { align-self: center; width: 44px; height: 44px; border-radius: 50%; font-size: 18px; background: var(--s1); color: var(--muted); }
.scr-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.tlist { display: grid; gap: 4px; }
.trow { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px 12px; height: auto; min-height: 60px; background: transparent; border-radius: 12px; text-align: left; }
.trow.on { background: var(--s2); box-shadow: inset 3px 0 0 var(--c); }
.trow .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--c); justify-self: center; }
.trow .logo.lg { width: 40px; height: 40px; border-radius: 8px; }
.trow-name { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trow-meta { font-size: 12px; color: var(--muted); }

/* --- Previa: quintetos sobre la pista ---------------------------------------- */
.previa { grid-template-rows: auto minmax(0, 1fr) auto; gap: 8px; }
.previa .scr-top h1 { font-size: 15px; }
.previa .vs { color: var(--faint); }
.pv-meta { font-size: 12px; color: var(--muted); font-family: var(--num); }
/* Columnas con proporción fija: la pista no depende del contenido de los banquillos (Safari la reducía a 0 de ancho). */
.pv-main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2.5fr) minmax(0, 1fr); gap: 12px; min-height: 0; }
.pv-court { display: flex; align-items: center; justify-content: center; min-height: 0; min-width: 0; container-type: size; }
.pv-pitch {
  position: relative; flex: none; width: min(100cqw, 100cqh * var(--ar, 1.844)); aspect-ratio: var(--ar, 1.844); color: color-mix(in srgb, var(--brand) 45%, transparent);
  background: color-mix(in srgb, var(--brand) 7%, var(--bg)); border-radius: 10px;
}
.court-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.cchip { position: absolute; transform: translate(-50%, -42%); display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 0; background: none; min-width: 64px; }
.cchip:active { background: none; transform: translate(-50%, -42%) scale(.95); }
.cchip .face { width: 48px; height: 48px; box-shadow: 0 0 0 2px var(--c), 0 6px 14px rgba(0, 0, 0, .35); }
.cchip-n { position: absolute; top: 32px; left: calc(50% + 12px); min-width: 22px; height: 22px; padding: 0 5px; border-radius: 11px; background: var(--c); color: #fff; font: 700 12px/22px var(--num); text-align: center; box-shadow: 0 0 0 2px var(--bg); }
.cchip-name { font-size: 11px; font-weight: 600; color: var(--text); white-space: nowrap; text-shadow: 0 1px 3px rgba(0, 0, 0, .8); max-width: 76px; overflow: hidden; text-overflow: ellipsis; }
.cchip.swappable .face { animation: ring 1.1s ease-in-out infinite; }
@keyframes ring { 50% { box-shadow: 0 0 0 4px var(--c), 0 6px 14px rgba(0, 0, 0, .35); } }
.bench { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 8px; min-height: 0; min-width: 0; }
.bench header { display: flex; align-items: center; gap: 8px; min-width: 0; height: 26px; }
.bench header b { flex: 1; min-width: 0; font-size: 14px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bench .count { font: 600 13px/1 var(--num); color: var(--warn); }
.bench .count.ok { color: var(--ok); }
.bench-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); grid-auto-rows: 42px; gap: 5px; align-content: start; overflow: auto; min-height: 0; overscroll-behavior: contain; }
.bchip { display: flex; align-items: center; gap: 6px; padding: 0 8px 0 6px; background: var(--s1); border-radius: 10px; text-align: left; }
.bchip .face { width: 28px; height: 28px; font-size: 11px; }
.bchip-n { font: 650 15px/1 var(--num); }
.bchip-name { flex: 1; min-width: 0; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bchip.pending { background: var(--s2); box-shadow: inset 0 0 0 2px var(--c); }
.bench-list.dense { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); grid-auto-rows: 50px; }
.bench-list.dense .bchip { position: relative; flex-direction: column; justify-content: center; gap: 2px; padding: 3px 4px; }
.bench-list.dense .bchip-name { flex: none; max-width: 100%; font-size: 10px; text-align: center; }
.bench-list.dense .bchip-n { position: absolute; top: 2px; right: 4px; font-size: 11px; }
.pv-foot { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; }
.pv-hint { grid-column: 1; margin: 0; font-size: 13px; color: var(--muted); }
.pv-foot .cta { grid-column: 2; min-width: 280px; }

/* --- Jugador seleccionado en la pantalla de acciones ---------------------------- */
.sel-label { display: flex; align-items: center; justify-content: center; gap: 7px; }
.sel-label .face { width: 18px; height: 18px; font-size: 8px; }
.sel-label b { color: var(--tc); font-weight: 650; }
.sel-label span { color: var(--muted); font-weight: 500; }
.sel-label:not(.has-player) span { color: var(--faint); }

@media (max-height: 380px) {
  .scr-top { height: 34px; }
  .logo-icon { width: 64px; height: 64px; }
  .crest { width: 54px; height: 54px; }
  .cchip .face { width: 40px; height: 40px; }
  .cchip-n { top: 26px; }
  .cta { height: 44px; }
  .bench-list { grid-auto-rows: 36px; }
}

/* Acceso Cloud: cancelar sin añadir una fila de controles. */
.login-actions { display: flex; gap: 8px; }
.login-actions .login-go { flex: 1; }
.login-actions button:not(.login-go) { min-width: 90px; }
.cloud-login { gap: 8px; }
.cloud-login .field { gap: 4px; }
.cloud-login .field input { height: 44px; }
.cloud-login .login-go { height: 44px; }

/* Pop-up de zonas de tiro: media pista con las áreas reales; minimalista. */
.zone-bg { align-items: center; justify-content: center; padding: 8px calc(var(--sar, 0px) + 8px) calc(var(--sab, 0px) + 8px) calc(var(--sal, 0px) + 8px); background: rgba(8, 10, 13, .72); }
.zone-pop { display: flex; gap: 18px; align-items: stretch; background: var(--s1); border-radius: 20px; padding: 14px 18px 14px 14px; box-shadow: 0 24px 70px rgba(0, 0, 0, .55); max-height: 100%; }
.zp-court { position: relative; height: min(320px, calc(100dvh - var(--sab, 0px) - 44px)); aspect-ratio: 150 / 140; }
.zp-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.zp-area { fill: transparent; stroke: none; }
.zp-area.on { fill: color-mix(in srgb, var(--brand) 9%, transparent); stroke: var(--s1); stroke-width: .8; cursor: pointer; transition: fill .12s; -webkit-tap-highlight-color: transparent; outline: none; }
.zp-area.on:hover, .zp-area.on:focus-visible { fill: color-mix(in srgb, var(--brand) 20%, transparent); }
.zp-area.on.hit, .zp-area.on:active { fill: color-mix(in srgb, var(--brand) 42%, transparent); }
.zp-lines { color: color-mix(in srgb, var(--brand) 55%, transparent); pointer-events: none; }
.zp-labels { pointer-events: none; }
.zp-label { font: 600 5.2px/1 var(--num); fill: color-mix(in srgb, var(--text) 18%, transparent); letter-spacing: .1px; }
.zp-label.on { fill: var(--text); }
.zp-side { display: flex; flex-direction: column; gap: 6px; width: 150px; padding-top: 4px; }
.zp-kind { font: 700 20px/1.1 var(--num); letter-spacing: -.2px; }
.zp-who { font-size: 14px; font-weight: 600; color: var(--c); }
.zp-bar { height: 2px; margin: 10px 0 6px; border-radius: 1px; background: var(--line); overflow: hidden; }
.zp-bar span { display: block; height: 100%; background: var(--brand); transform-origin: left; animation: zp-wait linear forwards; }
@keyframes zp-wait { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.zp-hint { margin: 0; font-size: 12px; color: var(--muted); }
.zp-side button { height: 44px; font-weight: 600; background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.zp-none { margin-top: auto; color: var(--text); }
.zp-cancel { color: var(--muted); }

/* Menú de inicio */
.menu { display: grid; gap: 8px; }
.menu-item { display: grid; gap: 3px; text-align: left; height: auto; padding: 14px 16px; border-radius: 14px; background: var(--s2); }
.menu-item b { font-size: 16px; font-weight: 650; }
.menu-item span { font-size: 12px; color: var(--muted); }
.menu h4 { margin: 10px 0 0; font-size: 12px; font-weight: 600; color: var(--muted); }

/* ------------------------------------------------------------------ Vertical: acceso y datos del partido */
@media (orientation: portrait) {
  .login { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); align-content: start; overflow: auto; }
  .login-brand { padding: 22px 22px 18px; min-height: 0; }
  .login-art-wrap { top: -40%; left: auto; right: -45%; height: 180%; }
  .logo-icon { width: 72px; height: 72px; }
  .login-claim { font-size: 14px; }
  .login-panel { align-items: flex-start; overflow: visible; }
  .login-form { width: 100%; max-width: 420px; padding: 4px 2px; }
  .login-form h1 { font-size: 22px; }

  .scr-top h1 { font-size: 17px; }
  .create-body { grid-template-columns: minmax(0, 1fr); align-content: start; overflow: auto; gap: 12px; }
  .create-teams { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 8px; }
  .team-pick { padding: 32px 8px 16px; min-height: 190px; }
  .tp-name { font-size: 15px; }
  .scr-foot { flex-direction: column-reverse; align-items: stretch; gap: 6px; }
  .scr-foot .cta { width: 100%; }
  .scr-foot > span:empty { display: none; }
}

/* Acceso: progreso discreto (sin texto rojo), error en tarjeta suave. */
.login-go { display: inline-flex; align-items: center; justify-content: center; gap: 10px; }
.login-go .spin { display: none; width: 18px; height: 18px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--brand-ink) 25%, transparent); border-top-color: var(--brand-ink); animation: spin .8s linear infinite; }
.login-go.busy .spin { display: inline-block; }
.login-go:disabled { opacity: 1; filter: saturate(.85); }
@keyframes spin { to { transform: rotate(360deg); } }
.login-progress { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 0; }
.login-status { margin: 0; font-size: 13px; color: var(--muted); }
.login-status::after { content: '…'; display: inline-block; width: 1.2em; animation: dots 1.2s steps(4, end) infinite; overflow: hidden; vertical-align: bottom; }
@keyframes dots { from { width: 0; } to { width: 1.2em; } }
.login-cancel { height: 34px; padding: 0 12px; background: transparent; color: var(--muted); font-size: 13px; box-shadow: inset 0 0 0 1px var(--line); border-radius: 10px; }
.login-err.soft { color: var(--muted); background: var(--s1); box-shadow: inset 3px 0 0 var(--line); }
.seg.seg2 { grid-template-columns: repeat(2, 1fr); }

/* ================================================================== Vertical (móvil en vertical)
   Acción primero; quién la hizo en una hoja inferior con los dos quintetos; después la zona del tiro.
   Al girar a horizontal se ve la pantalla de siempre. */
.pv-right { display: flex; align-items: center; gap: 6px; justify-self: end; }
.pv-exit { width: 40px; padding: 0; font-size: 18px; }

@media (orientation: portrait) and (max-width: 1100px) {
  /* --- Partido */
  .app { gap: 8px; padding: max(var(--sat), 10px) max(var(--sar), 12px) max(var(--sab), 8px) max(var(--sal), 12px); }
  .sb { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "home away" "center center"; height: auto; row-gap: 8px; }
  .sb-team.home { grid-area: home; }
  .sb-team.away { grid-area: away; }
  .sb-team, .sb-team.sel { height: 62px; padding: 0 12px; background: var(--s1); pointer-events: none; }
  .sb-team .sb-name { font-size: 13px; }
  .sb-score { font-size: 38px; }
  .sb-center { grid-area: center; justify-content: center; }
  .sb-period, .sb-clockbox, .sb-phase, .sb-play { height: 50px; }
  .sb-play { width: 50px; }
  .sb-clockbox { flex: 1; width: auto; max-width: 170px; }
  .sb-phase { flex: 1; min-width: 0; max-width: 170px; padding: 0 10px; border-radius: 25px; font-size: 14px; }

  .court { grid-template-columns: minmax(0, 1fr); }
  .roster, .sel-label, .subpanel { display: none !important; }
  .pad { grid-template-rows: minmax(0, 1.35fr) minmax(0, .8fr) minmax(0, 3.3fr); gap: 8px; }
  .mode-basic .pad { grid-template-rows: minmax(0, 2fr) minmax(0, 2fr); }
  .made, .miss { gap: 8px; }
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
  .stats .star { grid-column: span 2; }
  .act { font-size: 14px; border-radius: var(--r); }
  /* Todavía no hay equipo elegido: los botones de anotar van en el cian de la marca. */
  .made-btn, .made-btn:active { background: var(--brand); color: var(--brand-ink); font-size: 36px; }
  .mode-basic .made-btn { font-size: 46px; }
  .miss-btn { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--brand) 45%, transparent); }

  .bar {
    grid-template-columns: 44px minmax(0, 1.35fr) repeat(3, minmax(0, 1fr)) 44px; grid-auto-rows: 40px; height: auto;
    grid-template-areas: "ticker ticker ticker ticker ticker ticker" "exit undo sync events mode menu";
  }
  #exit { grid-area: exit; } #undo { grid-area: undo; } #ticker { grid-area: ticker; } #sync { grid-area: sync; } #events { grid-area: events; } #mode { grid-area: mode; } #menu { grid-area: menu; }
  .bar-btn { font-size: 12px; padding: 0 4px; }
  .bar-btn.exit, #menu { font-size: 17px; }
  .ticker { background: var(--s1); padding: 0 12px; }

  /* --- Zona del tiro: pista arriba, opciones debajo */
  .zone-pop { flex-direction: column; gap: 12px; width: min(100%, 460px); padding: 14px; }
  .zp-court { height: auto; width: 100%; }
  .zp-side { width: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0; }
  .zp-kind, .zp-who, .zp-bar, .zp-hint { grid-column: 1 / -1; }
  .zp-bar { margin: 4px 0 2px; }
  .zp-none { margin-top: 0; }

  /* --- Quintetos: visitante arriba, pista en vertical (local abajo), local debajo */
  .previa.vert .scr-top { grid-template-columns: auto minmax(0, 1fr) auto; gap: 6px; }
  .previa.vert .scr-top h1 { font-size: 14px; text-align: center; overflow: hidden; text-overflow: ellipsis; }
  .previa.vert .pv-main { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; gap: 10px; }
  .previa.vert .bench { grid-template-rows: auto auto; gap: 6px; }
  .previa.vert .bench-list { grid-auto-flow: column; grid-template-columns: none; grid-template-rows: repeat(var(--rows, 2), 40px); grid-auto-columns: 118px; overflow-x: auto; overflow-y: hidden; padding-bottom: 2px; }
  .previa.vert .bench-list.dense { grid-template-rows: repeat(var(--rows, 2), 46px); grid-auto-columns: 64px; }
  .previa.vert .bench-list .hint { margin: 0; align-self: center; }
  .previa.vert .cchip { min-width: 56px; }
  .previa.vert .cchip .face { width: 42px; height: 42px; }
  .previa.vert .cchip-n { top: 28px; }
  .previa.vert .cchip-name { max-width: 70px; font-size: 10.5px; }
  .previa.vert .pv-foot { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .previa.vert .pv-hint { text-align: center; }
  .previa.vert .pv-foot .cta { grid-column: 1; min-width: 0; width: 100%; }
}

/* --- Hoja inferior: quién hizo la acción / cambio */
.pick-bg { align-items: flex-end; justify-content: center; background: rgba(8, 10, 13, .66); }
.pick {
  width: 100%; max-width: 640px; margin: 0 auto; display: grid; gap: 12px; align-content: start;
  padding: 16px max(var(--sar), 14px) max(var(--sab), 14px) max(var(--sal), 14px);
  max-height: calc(100dvh - max(var(--sat), 16px) - 8px); overflow: auto; overscroll-behavior: contain;
  background: var(--s1); border-radius: 22px 22px 0 0; box-shadow: 0 -18px 50px rgba(0, 0, 0, .45);
  animation: pick-up .18s ease-out;
}
@keyframes pick-up { from { transform: translateY(28px); opacity: 0; } }
.pick-h { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; }
.pick-h b { font: 700 19px/1.1 var(--num); letter-spacing: -.2px; }
.pick-h span { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-x { height: 40px; padding: 0 12px; background: transparent; color: var(--muted); font-size: 13px; box-shadow: inset 0 0 0 1px var(--line); border-radius: 10px; }
.pick-teams { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.pick-team { display: grid; gap: 6px; align-content: start; min-width: 0; }
.pick-team header { display: flex; align-items: center; gap: 7px; height: 26px; min-width: 0; }
.pick-team header b { flex: 1; min-width: 0; font-size: 13px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-list { display: grid; gap: 6px; }
.pick-pl, .sub-pl { display: flex; align-items: center; gap: 9px; height: 58px; padding: 0 10px 0 8px; background: var(--s2); border-radius: 14px; text-align: left; min-width: 0; }
.pick-pl:active, .pick-pl.pressed { background: var(--c); color: var(--c-ink, #fff); }
.pick-pl:active .pick-nm { color: inherit; }
.f-pick { width: 40px; height: 40px; box-shadow: 0 0 0 2px var(--c); }
.face.f-pick.no-photo { font: 700 17px/1 var(--num); background: color-mix(in srgb, var(--c) 18%, var(--s1)); }
.pick-n { font: 700 21px/1 var(--num); font-variant-numeric: tabular-nums; }
.pick-nm { flex: 1; min-width: 0; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-f { flex: none; font: 600 11px/1 var(--num); color: var(--warn); }
.pick-f.hot { color: var(--bad); }
.pick-pl.dq { opacity: .4; }
.pick-list.dense .pick-pl { height: 46px; }
.pick-list.dense .f-pick { width: 32px; height: 32px; }
.pick-none { height: 42px; background: transparent; color: var(--muted); font-size: 13px; box-shadow: inset 0 0 0 1px var(--line); border-radius: 12px; }
.pick-teambtn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; height: 168px; background: var(--s2); border-radius: 18px; box-shadow: inset 0 3px 0 var(--c); min-width: 0; }
.pick-teambtn b { font-size: 15px; font-weight: 650; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-teambtn span:not(.crest) { font: 500 12px/1 var(--num); color: var(--muted); }
.pick-teambtn:active { background: var(--c); color: var(--c-ink, #fff); }
.sub-seg button { height: 40px; }
.sub-seg button.on { box-shadow: inset 0 -2px 0 var(--c); }
.sub-body { display: grid; gap: 8px; }
.sub-body h4 { margin: 2px 0 0; display: flex; gap: 8px; align-items: center; font-size: 12px; font-weight: 600; color: var(--muted); }
.sub-body .count { font: 600 12px/1 var(--num); color: var(--warn); }
.sub-body .count.ok { color: var(--ok); }
.sub-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.sub-grid .hint { margin: 0; }
.sub-pl { height: 50px; background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.sub-pl .f-pick { width: 34px; height: 34px; }
.sub-pl.on { background: var(--s2); box-shadow: none; }
.sub-pl.in { box-shadow: inset 0 0 0 2px var(--ok); }
.sub-pl.out { box-shadow: inset 0 0 0 2px var(--bad); }
.sub-foot { display: grid; gap: 8px; }
.sub-foot .hint { margin: 0; text-align: center; font-family: var(--num); }
.sub-foot .cta { width: 100%; }

/* --- Cuerpo técnico en la hoja de «¿Quién?» (técnica y descalificante) */
.pick-staff { display: grid; gap: 6px; }
.pick-staff h5 { margin: 4px 0 0; font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.pick-pl.staff { height: 52px; background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.pick-pl.staff .pick-nm { display: grid; gap: 2px; }
.pick-pl.staff .pick-nm b { color: var(--text); font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.pick-pl.staff .pick-nm small { font-size: 11px; color: var(--muted); }
.face.staff-face.no-photo { font: 700 13px/1 var(--num); letter-spacing: .02em; background: var(--s2); color: var(--c); }
.staff-box { margin-top: 6px; }
.staff-box td.danger { color: var(--bad); }
/* En horizontal la hoja es más baja: filas compactas. */
@media (orientation: landscape) {
  .pick { max-width: 760px; gap: 8px; padding-top: 12px; }
  .pick-pl { height: 44px; }
  .pick-pl.staff { height: 42px; }
  .f-pick { width: 32px; height: 32px; }
  .pick-none { height: 36px; }
}

/* --- ¿Asistencia? tras una canasta de 2 o de 3 */
.assist-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 6px; }
.assist-bar { margin: 0; }
.pick-assist .pick-h span { font: 600 14px/1.2 var(--num); }

/* ================================================================== Rediseño 0.9.9: marca, «Nuevo partido» y final */
/* Cabecera de marca: el logotipo manda; a la derecha, la cuenta. */
.brand-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; }
.brand-lockup { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.brand-icon { width: 34px; height: 34px; flex: none; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .35)); }
.brand-word { height: 15px; width: auto; max-width: 62vw; }
.brand-top .user { font-size: 13px; }

/* «Nuevo partido» */
.create { grid-template-rows: auto minmax(0, 1fr) auto; gap: 14px; }
.create-body { grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.3fr); gap: 16px; }
.create-when { background: none; padding: 0; gap: 14px; overflow: visible; }
.create-title { margin: 2px 0 2px; font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.when { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 8px; }
.when-tile { position: relative; display: grid; gap: 4px; padding: 11px 14px 12px; border-radius: 16px; background: var(--s1); box-shadow: inset 3px 0 0 var(--brand); cursor: pointer; }
.when-tile.time { box-shadow: none; }
.when-tile:active { background: var(--s2); }
.when-l { font-size: 12px; color: var(--muted); }
.when-v { font: 650 19px/1.2 var(--num); letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.when-tile.date .when-v::first-letter { text-transform: uppercase; }
.when-tile.empty .when-v { color: var(--brand); font-weight: 600; font-size: 16px; }
.when-native { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; border: 0; padding: 0; cursor: pointer; -webkit-appearance: none; appearance: none; }
.cat { display: grid; gap: 6px; }
.create .seg { background: var(--s1); }
.create .seg button { height: 42px; font-size: 14px; }
.create .fmt { padding-left: 4px; }

/* Enfrentamiento: un solo bloque, local y visitante cara a cara, «vs» en medio. */
.create-teams { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 0; background: var(--s1); border-radius: 22px; padding: 6px; align-items: stretch; min-height: 0; }
.team-pick { background: transparent; border-radius: 18px; box-shadow: none; padding: 34px 10px 18px; gap: 10px; }
.team-pick:not(.empty) { background: linear-gradient(180deg, color-mix(in srgb, var(--c) 16%, transparent), transparent 70%); }
.team-pick.empty { box-shadow: none; }
.team-pick .crest { width: 84px; height: 84px; }
.team-pick .crest.empty { border: 1.5px dashed color-mix(in srgb, var(--brand) 45%, transparent); box-shadow: none; color: var(--brand); }
.tp-role { left: 50%; transform: translateX(-50%); top: 12px; }
.swap { align-self: center; display: grid; place-items: center; gap: 2px; width: 46px; height: 64px; border-radius: 23px; background: var(--bg); color: var(--muted); }
.swap .vs { font: 700 13px/1 var(--num); color: var(--text); }
.swap .swap-i { font-size: 13px; color: var(--faint); }
.scr-foot { display: grid; gap: 8px; justify-content: stretch; }
.scr-foot .cta { width: 100%; height: 54px; border-radius: 16px; background: linear-gradient(180deg, #5ee7ff, #14b8e6); color: var(--brand-ink); }
.scr-foot .cta:disabled { background: var(--s2); color: var(--muted); opacity: 1; }
.scr-foot .resume { color: var(--ok); height: 40px; }

@media (orientation: landscape) {
  .create .scr-foot { grid-template-columns: auto minmax(0, 360px); justify-content: end; }
  .create-title { font-size: 22px; }
}
@media (orientation: portrait) {
  .create-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); gap: 18px; overflow: auto; }
  .create-teams { min-height: 230px; }
  .team-pick { min-height: 0; padding: 36px 8px 20px; }
  .scr-foot { flex-direction: unset; }
}
/* El enfrentamiento ocupa el hueco disponible: escudos que crecen con la altura y un grupo centrado. */
.create-teams { container-type: size; }
.tp-role { position: static; transform: none; margin-bottom: 2px; }
.team-pick { justify-content: center; gap: 8px; }
.team-pick:not(.empty) { background: radial-gradient(120% 70% at 50% 42%, color-mix(in srgb, var(--c) 20%, transparent), transparent 70%); }
.team-pick .crest { width: clamp(72px, 34cqh, 150px); height: clamp(72px, 34cqh, 150px); font-size: clamp(18px, 7cqh, 30px); }
.team-pick .tp-name { font-size: 18px; }
@media (orientation: landscape) {
  .team-pick .crest { width: clamp(64px, 40cqh, 120px); height: clamp(64px, 40cqh, 120px); }
}
.team-pick:not(.empty) { background: radial-gradient(closest-side circle at 50% 46%, color-mix(in srgb, var(--c) 22%, transparent), transparent); }

/* --- Partido finalizado: marcador de retransmisión, parciales, destacados y comparativa */
.overlay:has(.final) { display: block; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.final { display: grid; gap: 14px; max-width: 1100px; margin: 0 auto; padding-bottom: 8px; }
.final-grid { display: grid; gap: 18px; }
.final-main, .final-side { display: grid; gap: 12px; align-content: start; min-width: 0; }
.fs-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
/* «FINAL» con el mismo gesto que el rótulo LIVE, en el cian de la marca. */
.fs-tag { flex: none; padding: 3px 10px 3px 9px; transform: skewX(-12deg); background: var(--brand); color: var(--brand-ink); font: italic 800 13px/1.3 var(--num); letter-spacing: .04em; }
.fs-meta { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fs-board { display: grid; gap: 2px; border-radius: 18px; overflow: hidden; background: var(--s1); }
.fs-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px 18px 12px 14px; box-shadow: inset 4px 0 0 var(--c); }
.fs-row + .fs-row { border-top: 1px solid var(--line); }
.fs-crest { width: 40px; height: 40px; font-size: 12px; }
.fs-name { font-size: 17px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fs-score { font: 700 46px/1 var(--num); font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.fs-row.lose .fs-name, .fs-row.lose .fs-score { color: var(--muted); }
.fs-row.win .fs-score { color: var(--text); }
.fs-periods { display: grid; grid-template-columns: minmax(48px, auto) repeat(var(--n), minmax(0, 1fr)); gap: 6px 4px; align-items: center; padding: 10px 14px; border-radius: 14px; background: var(--s1); font: 500 13px/1 var(--num); font-variant-numeric: tabular-nums; }
.fs-ph { color: var(--faint); text-align: center; font-size: 11px; }
.fs-pt { color: var(--c); font-weight: 700; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fs-pv { text-align: center; }
.fs-foot { margin: 0; font-size: 12px; color: var(--faint); }
.f-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.f-actions button { height: 46px; font-size: 14px; font-weight: 600; border-radius: 13px; background: var(--s1); }
.f-actions .f-primary { grid-column: 1 / -1; height: 52px; background: linear-gradient(180deg, #5ee7ff, #14b8e6); color: var(--brand-ink); font-size: 15px; }
.f-block { display: grid; gap: 8px; }
.f-block h3 { margin: 4px 0 0; font-size: 15px; font-weight: 650; }
.f-leaders, .f-compare { display: grid; gap: 2px; border-radius: 16px; overflow: hidden; background: var(--s1); }
.fl-row { display: grid; grid-template-columns: minmax(0, 1fr) 86px minmax(0, 1fr); align-items: center; gap: 8px; padding: 9px 12px; }
.fl-row + .fl-row, .fc-row + .fc-row { border-top: 1px solid var(--line); }
.fl-label { text-align: center; font-size: 12px; color: var(--muted); }
.fl-cell { display: flex; align-items: baseline; gap: 7px; min-width: 0; }
.fl-cell.away { flex-direction: row-reverse; text-align: right; }
.fl-cell b { font: 700 18px/1 var(--num); color: var(--c); }
.fl-cell span { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fl-none { color: var(--faint); }
.fc-row { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 4px 8px; padding: 9px 12px 10px; }
.fc-v { font: 600 14px/1 var(--num); font-variant-numeric: tabular-nums; }
.fc-v.away { text-align: right; }
.fc-l { font-size: 12px; color: var(--muted); text-align: center; }
.fc-bar { grid-column: 1 / -1; height: 4px; border-radius: 2px; background: linear-gradient(90deg, var(--a) var(--p), var(--s3) var(--p), var(--s3) calc(var(--p) + 3px), var(--b) calc(var(--p) + 3px)); opacity: .85; }
@media (orientation: landscape) and (min-width: 700px) {
  .final-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 22px; }
  .f-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.final-grid { grid-template-areas: "main" "side" "actions"; }
.final-main { grid-area: main; }
.final-side { grid-area: side; }
.f-actions { grid-area: actions; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; }
.f-actions .f-ghost { grid-column: 1 / -1; height: 40px; background: none; color: var(--muted); font-weight: 500; font-size: 13px; }
@media (orientation: landscape) and (min-width: 700px) {
  .final-grid { grid-template-areas: "main side" "actions side"; grid-template-rows: auto 1fr; }
  .f-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.fs-tag { margin-left: 4px; }

/* --- Final 0.9.9b: parciales dentro del marcador, selector Destacados/Equipos, cabe en una pantalla en horizontal */
.fs-board { --cols: 40px minmax(0, 1fr) repeat(var(--n), 26px) 62px; gap: 0; }
.fs-hrow, .fs-row { display: grid; grid-template-columns: var(--cols); align-items: center; column-gap: 8px; }
.fs-hrow { padding: 9px 18px 0 14px; }
.fs-hrow .fs-q { font: 600 10px/1 var(--num); color: var(--faint); text-align: center; }
.fs-row { padding: 10px 18px 10px 14px; }
.fs-row + .fs-row { border-top: 1px solid var(--line); }
.fs-q { font: 500 14px/1 var(--num); font-variant-numeric: tabular-nums; color: var(--muted); text-align: center; }
.fs-row .fs-score { text-align: right; }
.fs-hrow + .fs-row { border-top: 0; }
.fs-periods { display: none; }
.f-tabs { background: var(--s1); }
.f-tabs button { height: 38px; font-size: 13px; }
.f-pane { min-height: 0; }
.fl-empty { margin: 0; padding: 16px; text-align: center; font-size: 13px; color: var(--muted); }
.fs-foot { text-align: right; }

@media (orientation: landscape) and (min-width: 700px) {
  .overlay:has(.final) { overflow: hidden; }
  .final { height: 100%; grid-template-rows: auto minmax(0, 1fr); gap: 10px; padding: 0; }
  .final .brand-icon { width: 28px; height: 28px; }
  .final .brand-word { height: 12px; }
  .final .brand-top { min-height: 32px; }
  .final-grid { grid-template-rows: auto minmax(0, 1fr); min-height: 0; gap: 10px 20px; }
  .final-side { min-height: 0; grid-template-rows: auto minmax(0, 1fr); gap: 8px; }
  .f-pane { overflow: auto; overscroll-behavior: contain; border-radius: 16px; }
  .final-main { gap: 8px; }
  .fs-row { padding: 7px 16px 7px 12px; }
  .fs-crest { width: 32px; height: 32px; font-size: 10px; }
  .fs-board { --cols: 32px minmax(0, 1fr) repeat(var(--n), 24px) 52px; }
  .fs-score { font-size: 36px; }
  .fs-name { font-size: 15px; }
  .fs-hrow { padding-top: 7px; }
  .f-actions { gap: 6px; align-content: end; }
  .f-actions button { height: 40px; font-size: 13px; }
  .f-actions .f-primary { height: 44px; }
  .f-actions .f-ghost { height: 30px; }
  .fl-row, .fc-row { padding: 7px 12px; }
  .fc-row { gap: 3px 8px; }
}
@media (orientation: portrait) {
  .fs-board { --cols: 34px minmax(0, 1fr) repeat(var(--n), 21px) 54px; }
  .fs-crest { width: 34px; height: 34px; font-size: 10px; }
  .fs-row, .fs-hrow { column-gap: 6px; padding-left: 12px; padding-right: 14px; }
  .fs-name { font-size: 16px; }
  .fs-score { font-size: 42px; }
}
