:root {
  --home-color: #f97316;
  --away-color: #38bdf8;
  --bg: #0b1020;
  --panel: #141b31;
  --panel-2: #1c2542;
  --line: #2a3357;
  --text: #eef2ff;
  --muted: #8e9ac4;
  --accent: #facc15;
  --ok: #34d399;
  --warn: #fb7185;
  --radius: 14px;
  --gap: clamp(0.4rem, 1vw, 1rem);
  --score-size: clamp(3.2rem, 12vw, 16rem);
  --clock-size: clamp(3.2rem, 9vw, 15rem);
  --shot-size: clamp(1.8rem, 4.5vw, 5.5rem);
  --player-size: clamp(0.7rem, 1.15vw, 1.15rem);
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --num: var(--ui);
  --glow: 0 0 24px color-mix(in srgb, var(--accent) 35%, transparent);
  color-scheme: dark;
}

html[data-font="mono"] { --num: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; }
html[data-font="condensed"] { --num: "Helvetica Neue", "Arial Narrow", Impact, var(--ui); }
html[data-font="digital"] {
  --num: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --glow: 0 0 28px color-mix(in srgb, var(--text) 30%, transparent);
}

html[data-theme="light"] {
  --bg: #eef1f8;
  --panel: #ffffff;
  --panel-2: #f2f5fc;
  --line: #cdd6e8;
  --text: #101728;
  --muted: #5a6584;
  color-scheme: light;
}
html[data-theme="oled"] { --bg: #000; --panel: #05070d; --panel-2: #0a0e18; --line: #1b2136; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#app { display: flex; flex-direction: column; flex: 1; min-height: 0; }

kbd {
  font: 600 0.85em/1 var(--num);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 2px 5px;
  color: var(--text);
}

.muted { color: var(--muted); font-size: 0.9rem; margin: 0 0 0.8rem; }

/* ---------- barra superior ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding: 0.5rem clamp(0.5rem, 1.5vw, 1.2rem);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 70%, transparent);
  flex: 0 0 auto;
}
.topbar__left, .topbar__right { display: flex; align-items: center; gap: 0.4rem; }
.brand { font-weight: 700; font-size: clamp(0.85rem, 1.4vw, 1.1rem); letter-spacing: 0.02em; }
.chip {
  font-size: clamp(0.65rem, 1vw, 0.85rem);
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.chip--status[data-live="1"] { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.chip--status[data-live="2"] { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }

.btn {
  font: 600 clamp(0.75rem, 1.2vw, 1rem)/1 var(--ui);
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.5rem 0.7rem;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  transition: transform 0.06s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.btn:active { transform: scale(0.96); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn--icon { padding: 0.45rem 0.6rem; font-size: clamp(0.9rem, 1.4vw, 1.2rem); }
.btn--sm { padding: 0.35rem 0.5rem; font-size: clamp(0.7rem, 1.1vw, 0.9rem); }
.btn--primary { background: var(--accent); color: #10131f; border-color: transparent; }
.btn--warn { border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); color: var(--warn); }
.btn--go { background: color-mix(in srgb, var(--ok) 18%, var(--panel-2)); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.btn--stop { background: color-mix(in srgb, var(--warn) 18%, var(--panel-2)); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }

/* ---------- marcador ---------- */

.board {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, clamp(15rem, 27vw, 34rem)) minmax(0, 1fr);
  gap: var(--gap);
  padding: var(--gap);
  align-items: start;
  overflow: auto;
}

.team {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.5rem;
}

.team__bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
  border-bottom: 3px solid var(--team);
  padding-bottom: 0.3rem;
}
.team__name {
  flex: 1;
  min-width: 0;
  font: 800 clamp(0.95rem, 2.1vw, 2rem)/1.1 var(--ui);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text);
  background: transparent;
  border: 1px dashed transparent;
  border-radius: 8px;
  padding: 0.15rem 0.35rem;
  text-align: center;
}
.team__name:hover { border-color: var(--line); }
.team__name:focus { outline: none; border-color: var(--accent); background: var(--panel-2); }
.team__logo { width: clamp(2rem, 4vw, 3.5rem); height: clamp(2rem, 4vw, 3.5rem); object-fit: contain; flex: 0 0 auto; border-radius: 7px; background: color-mix(in srgb, var(--panel-2) 80%, transparent); }
.team__logo-btn, .team__logo-remove { flex: 0 0 auto; border: 1px solid var(--line); border-radius: 7px; padding: 0.25rem 0.4rem; color: var(--muted); background: var(--panel-2); font: 700 0.68rem/1 var(--ui); cursor: pointer; }
.team__logo-btn:hover, .team__logo-remove:hover { color: var(--text); border-color: var(--accent); }
.team__logo-remove { color: var(--warn); font-size: 1rem; padding: 0.1rem 0.35rem; }
.team__logo-btn[hidden], .team__logo-remove[hidden], .team__logo[hidden], .pub__logo[hidden] { display: none; }
.team__badge {
  font: 800 clamp(0.55rem, 0.9vw, 0.8rem)/1 var(--ui);
  letter-spacing: 0.06em;
  color: #10131f;
  background: var(--warn);
  border: 0;
  border-radius: 6px;
  padding: 0.3rem 0.4rem;
  cursor: default;
}
.team__poss { color: var(--accent); font-size: clamp(0.8rem, 1.4vw, 1.3rem); }

.team__scorebox {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0;
}
.team__score {
  font: 800 var(--score-size)/1 var(--num);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--team);
  text-shadow: var(--glow);
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 0 0.15em;
  min-width: 2.2ch;
  white-space: nowrap;
}
.team__score:active { transform: scale(0.97); }

.team__quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.3rem; }
.btn--pt {
  font: 800 clamp(0.85rem, 1.7vw, 1.6rem)/1 var(--num);
  padding: 0.45rem 0;
  color: var(--team);
  border-color: color-mix(in srgb, var(--team) 35%, var(--line));
}
.btn--pt.btn--sub { color: var(--muted); border-color: var(--line); font-size: clamp(0.7rem, 1.2vw, 1.1rem); }

.team__stats { display: grid; grid-template-columns: 1fr 1fr; gap: 0.3rem; }
.stat { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 0.25rem 0.35rem; text-align: center; }
.stat__label { display: block; font-size: clamp(0.55rem, 0.9vw, 0.78rem); color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat__label em { font-style: normal; color: var(--accent); }
.stat__val { display: flex; align-items: center; justify-content: center; gap: 0.3rem; }
.stat__num { font: 800 clamp(1rem, 2vw, 1.9rem)/1 var(--num); font-variant-numeric: tabular-nums; }
.pill {
  font: 700 clamp(0.8rem, 1.4vw, 1.2rem)/1 var(--ui);
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  width: 1.9em;
  height: 1.9em;
  cursor: pointer;
  flex: 0 0 auto;
}
.pill:active { transform: scale(0.9); }
.dots { display: flex; gap: 0.2rem; flex-wrap: wrap; justify-content: center; }
.dot { width: 0.62em; height: 0.62em; border-radius: 50%; border: 1.5px solid var(--line); min-width: 8px; min-height: 8px; }
.dot--used { background: var(--muted); border-color: var(--muted); }
.dot--left { background: var(--ok); border-color: var(--ok); }

/* ---------- tarjetas de jugador ---------- */

.roster { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.25rem; }
.player {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--team);
  border-radius: 10px;
  padding: 0.25rem 0.4rem 0.3rem;
  font-size: var(--player-size);
}
.player--fouled { border-color: color-mix(in srgb, var(--warn) 55%, var(--line)); }
.player--bench { opacity: 0.62; border-style: dashed; }
.player[draggable="true"] { cursor: grab; }
.player--dragging { opacity: 0.32; transform: scale(0.985); }
.player--drop-target { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent), 0 0 16px color-mix(in srgb, var(--accent) 35%, transparent); }
.player--sub-selected { opacity: 1; border: 2px solid var(--accent); border-left: 5px solid var(--accent); background: color-mix(in srgb, var(--accent) 16%, var(--panel-2)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 32%, transparent), 0 0 18px color-mix(in srgb, var(--accent) 35%, transparent); }
.player__drag { display: inline-flex; align-items: center; justify-content: center; min-width: 1.7rem; height: 2rem; margin-left: auto; color: var(--accent); font-size: 1.15rem; font-weight: 900; letter-spacing: -0.2em; cursor: grab; touch-action: none; user-select: none; }
.player__drag:active { cursor: grabbing; }
.player__top { display: flex; align-items: center; gap: 0.35rem; min-width: 0; }
.player__num { font: 800 1.05em/1 var(--num); color: var(--muted); width: 2.8ch; min-width: 2.8ch; text-align: center; flex: 0 0 auto; background: var(--panel); border: 1px dashed var(--line); border-radius: 5px; padding: 0.2rem 0; appearance: textfield; -moz-appearance: textfield; }
.player__num::-webkit-inner-spin-button, .player__num::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.player__num:focus { color: var(--text); border-color: var(--accent); outline: 1px solid var(--accent); }
.player__name {
  min-width: 0; width: 100%;
  font: 700 1.05em/1.25 var(--ui);
  color: var(--text);
  background: transparent; border: 1px dashed transparent; border-radius: 6px; padding: 0.1rem 0.25rem;
}
.player__name::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); font-weight: 500; }
.player__name:hover { border-color: var(--line); }
.player__name:focus { outline: none; border-color: var(--accent); background: var(--panel); }
.player__pts { font: 800 1.9em/1 var(--num); font-variant-numeric: tabular-nums; min-width: 1.8ch; text-align: right; color: var(--team); flex: 0 0 auto; }
.player__bot { display: flex; align-items: center; gap: 0.25rem; }
.mini {
  font: 700 1em/1 var(--ui);
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  min-width: 2.1em;
  height: 2em;
  padding: 0 0.3em;
  cursor: pointer;
}
.mini--pts { color: var(--team); border-color: color-mix(in srgb, var(--team) 35%, var(--line)); }
.mini--foul { color: var(--warn); display: inline-flex; align-items: center; gap: 0.2em; }
.mini--foul b { font-family: var(--num); font-weight: 800; }
.mini--time { color: var(--muted); font-family: var(--num); margin-left: auto; font-size: 0.9em; }
.mini--sub { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); flex: 0 0 auto; }
.mini:active { transform: scale(0.9); }
.team__poss { cursor: pointer; }

/* ---------- centro ---------- */

.center { display: flex; flex-direction: column; gap: 0.4rem; min-width: 0; }
.center__clocks { display: flex; flex-direction: column; gap: 0.4rem; }
.clockbox, .periodbox, .shotbox {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.4rem;
  text-align: center;
}
.clockbox__label, .shotbox__label, .periodbox__label {
  display: block;
  font-size: clamp(0.55rem, 0.9vw, 0.8rem);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.clock {
  font: 800 var(--clock-size)/1 var(--num);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  color: var(--text);
  text-shadow: var(--glow);
  background: transparent;
  border: 0;
  cursor: pointer;
  width: 100%;
  padding: 0.1rem 0;
  white-space: nowrap;
}
.clock--run { color: var(--ok); }
.clock--low { color: var(--warn); animation: blink 1s steps(2, start) infinite; }
.clockbox--low { border-color: var(--warn); }
@keyframes blink { 50% { opacity: 0.45; } }
.clockbox__ctrls, .shotbox__ctrls { display: flex; flex-wrap: wrap; gap: 0.25rem; justify-content: center; }
.center__meta { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; }
.periodbox__val { display: flex; align-items: center; justify-content: center; gap: 0.35rem; }
.periodbox__num {
  font: 800 clamp(1.1rem, 2.4vw, 2.2rem)/1.15 var(--num);
  min-width: 2.2ch;
  text-align: center;
}
.shotbox { border-color: color-mix(in srgb, var(--shot, var(--line)) 60%, var(--line)); }
.shotbox--on { border-color: var(--ok); box-shadow: 0 0 0 1px color-mix(in srgb, var(--ok) 40%, transparent) inset; }
.shotbox--low { border-color: var(--warn); }
.shotbox--low .shotclock { color: var(--warn); }
.shotclock {
  font: 800 var(--shot-size)/1.15 var(--num);
  font-variant-numeric: tabular-nums;
  color: var(--ok);
  background: transparent;
  border: 0;
  cursor: pointer;
  width: 100%;
  padding: 0.05rem 0;
}
.shotbox--off .shotclock { color: var(--muted); }
.center__bigctrls { display: flex; flex-direction: column; gap: 0.3rem; }
.btn--big { font-size: clamp(0.75rem, 1.3vw, 1.1rem); padding: 0.55rem 0.5rem; }

/* ---------- barra inferior ---------- */

.botbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.9rem;
  align-items: center;
  padding: 0.35rem clamp(0.5rem, 1.5vw, 1.2rem);
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 70%, transparent);
  font-size: clamp(0.65rem, 1vw, 0.85rem);
  color: var(--muted);
  flex: 0 0 auto;
}
.hint { display: inline-flex; align-items: center; gap: 0.25rem; }
.hint--save { margin-left: auto; color: var(--ok); }
.hint--save[data-save="0"] { color: var(--warn); }

/* ---------- modo pantalla grande ---------- */

/* Pantalla publica estilo retransmision */
body[data-view="display"] { background: #050505; color: #f5f5f5; overflow: hidden; }
body[data-view="display"] .topbar, body[data-view="display"] .botbar, body[data-view="display"] #app { display: none !important; }
#publicView { display: none; }
body[data-view="display"] #publicView { display: flex; position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; background: #050505; align-items: center; justify-content: center; overflow: hidden; padding: 0; }
.broadcast { width: min(100vw, calc(100dvh * 16 / 9)); height: min(100dvh, calc(100vw * 9 / 16)); aspect-ratio: 16 / 9; max-width: 100%; max-height: 100%; box-sizing: border-box; background: #050505; display: grid; grid-template-rows: 18% 25% minmax(0, 1fr) auto; gap: .65%; padding: 1.1%; overflow: hidden; font-family: Arial, Helvetica, sans-serif; }
.broadcast__header { display: grid; grid-template-columns: 1fr 1.2fr 1fr; align-items: center; gap: 1%; min-height: 0; text-align: center; }
.broadcast__team { min-width: 0; display: flex; align-items: center; justify-content: center; gap: .5em; }
.broadcast__logo { width: clamp(1rem, 4vw, 5rem); height: clamp(1rem, 8vh, 5rem); object-fit: contain; }
.broadcast__teamname { color: var(--home-color); font-size: clamp(.65rem, 2.2vw, 2rem); line-height: 1.05; font-weight: 900; text-transform: uppercase; overflow-wrap: anywhere; }
.broadcast__team--away .broadcast__teamname { color: var(--away-color); }
.broadcast__mainclock { align-self: stretch; background: #111; display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 0; }
.broadcast__label { font-weight: 900; font-size: clamp(.5rem, 1.2vw, 1.2rem); line-height: 1.05; text-transform: uppercase; }
.broadcast__clock { color: #ffef00; font-size: clamp(1.7rem, 7.5vw, 7.5rem); line-height: .95; font-weight: 1000; letter-spacing: -.055em; white-space: nowrap; font-variant-numeric: tabular-nums; }
.broadcast__clock.low { color: #ff4949; }
.broadcast__period { font-size: clamp(.55rem, 1.2vw, 1.1rem); font-weight: 800; }
.broadcast__scores { display: grid; grid-template-columns: 1fr .72fr 1fr; align-items: center; text-align: center; gap: 1%; min-height: 0; }
.broadcast__scorebox { min-width: 0; }
.broadcast__score { color: var(--home-color); font-size: clamp(2.2rem, 9.3vw, 9rem); font-weight: 1000; line-height: .95; letter-spacing: -.06em; font-variant-numeric: tabular-nums; }
.broadcast__scorebox--away .broadcast__score { color: var(--away-color); }
.broadcast__shotbox { align-self: stretch; display: flex; flex-direction: column; justify-content: center; align-items: center; min-width: 0; }
.broadcast__shot { color: #ff3535; font-size: clamp(2rem, 8.7vw, 8rem); line-height: .95; font-weight: 1000; font-variant-numeric: tabular-nums; }
.broadcast__shot.off { color: #888; }
.broadcast__rosters { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5%; min-height: 0; overflow: hidden; }
.broadcast__roster { min-width: 0; min-height: 0; overflow: hidden; border: 1px solid #777; background: #090909; }
.broadcast__roster table, .broadcast__teamfouls table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: clamp(.48rem, .95vw, 1rem); line-height: 1.05; }
.broadcast th, .broadcast td { border: 1px solid #444; padding: .12em .32em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.broadcast thead th { color: #fff; background: #252525; text-align: left; font-size: .86em; }
.broadcast thead tr:first-child th { text-align: center; font-size: 1em; }
.broadcast tbody th { text-align: left; font-weight: 700; color: #f4e94b; }
.broadcast tbody td { text-align: center; color: #f4e94b; font-weight: 800; font-variant-numeric: tabular-nums; }
.broadcast__player--court th { color: var(--ok) !important; }
.broadcast__teamfouls { min-height: 0; border: 1px solid #666; background: #090909; }
.broadcast__tabletitle { text-align: center; background: #292929; font-size: clamp(.5rem, 1vw, 1rem); font-weight: 900; line-height: 1.1; }
.broadcast__teamfouls table { font-size: clamp(.48rem, .95vw, 1rem); }
.broadcast__teamfouls th, .broadcast__teamfouls td { text-align: center; }
.broadcast__teamfouls tbody th { color: var(--home-color); }
.broadcast__teamfouls tbody tr:nth-child(2) th { color: var(--away-color); }
.broadcast__teamfouls .is-bonus { color: #28f0b4; }
@media (max-aspect-ratio: 4/3) {
  .broadcast { width: 100vw; height: 100dvh; aspect-ratio: auto; grid-template-rows: 17% 23% minmax(0,1fr) auto; }
  .broadcast__teamname { font-size: clamp(.65rem, 2.8vw, 1.5rem); }
  .broadcast__clock { font-size: clamp(1.6rem, 8vw, 5rem); }
  .broadcast__score { font-size: clamp(2rem, 10vw, 5rem); }
  .broadcast__shot { font-size: clamp(1.8rem, 9vw, 4.5rem); }
  .broadcast__roster table, .broadcast__teamfouls table { font-size: clamp(.45rem, 1.5vw, .85rem); }
}
@media (max-height: 500px) {
  .broadcast { gap: .35%; padding: .6%; grid-template-rows: 17% 23% minmax(0,1fr) auto; }
  .broadcast__clock { font-size: clamp(1.5rem, 11vh, 4.5rem); }
  .broadcast__score { font-size: clamp(1.8rem, 13vh, 5rem); }
  .broadcast__shot { font-size: clamp(1.6rem, 12vh, 4rem); }
}
/* ---------- modales ---------- */

.modal { border: 0; padding: 0; background: transparent; max-width: 100vw; max-height: 100dvh; }
.modal::backdrop { background: rgba(3, 6, 18, 0.72); backdrop-filter: blur(3px); }
.modal__box {
  width: min(58rem, 96vw);
  max-height: 92dvh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
}
.modal__head, .modal__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.7rem 1rem;
  background: var(--panel-2);
}
.modal__head { border-bottom: 1px solid var(--line); }
.modal__foot { border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal__head h2 { margin: 0; font-size: 1.05rem; }
.modal__body { padding: 1rem; overflow: auto; display: grid; gap: 1rem; }
.modal__note { font-size: 0.8rem; color: var(--muted); }

.field { border: 1px solid var(--line); border-radius: 12px; padding: 0.7rem 0.9rem 0.9rem; margin: 0; display: grid; gap: 0.55rem; }
.field legend { font: 700 0.8rem/1 var(--ui); text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); padding: 0 0.4rem; }
.row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0.6rem; font-size: 0.9rem; }
.row--check { grid-template-columns: auto 1fr; justify-content: start; }
.row--check input { justify-self: start; width: 1.15rem; height: 1.15rem; accent-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem 0.9rem; }
.row input[type="number"], .row input[type="text"], .row select {
  font: 600 0.95rem/1 var(--ui);
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0.45rem 0.55rem;
  width: 8.5rem;
}
.row input[type="color"] {
  width: 3.2rem; height: 2rem; padding: 0;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
}
.row select { width: 12rem; }
.row input:focus, .row select:focus { outline: none; border-color: var(--accent); }

.saves { list-style: none; margin: 0.4rem 0 0; padding: 0; display: grid; gap: 0.35rem; max-height: 14rem; overflow: auto; }
.saves li { display: flex; align-items: center; gap: 0.5rem; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 0.4rem 0.6rem; font-size: 0.85rem; }
.saves li b { font-weight: 700; }
.saves li span { color: var(--muted); font-size: 0.78rem; }
.saves li .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.roster-edit { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.roster-edit__col h3 { margin: 0 0 0.5rem; font-size: 0.9rem; text-transform: uppercase; border-bottom: 3px solid var(--team); padding-bottom: 0.3rem; }
.roster-edit__list { list-style: none; margin: 0 0 0.6rem; padding: 0; display: grid; gap: 0.3rem; }
.pedit {
  display: grid;
  grid-template-columns: 3rem 1fr auto auto;
  gap: 0.3rem;
  align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0.3rem;
}
.pedit input {
  font: 600 0.9rem/1 var(--ui);
  color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 7px; padding: 0.35rem 0.45rem; width: 100%;
}
.pedit input[type="number"] { text-align: center; }
.pedit input:focus { outline: none; border-color: var(--accent); }
.pedit__del { color: var(--warn); }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 5vh;
  transform: translate(-50%, 20px);
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.6rem 1rem;
  font: 600 0.95rem/1.2 var(--ui);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 50;
  max-width: 90vw;
  text-align: center;
}
.toast--on { opacity: 1; transform: translate(-50%, 0); }
.toast--warn { border-color: var(--warn); color: var(--warn); }

body.no-roster .roster { display: none; }

.banner {
  background: color-mix(in srgb, var(--warn) 25%, var(--panel));
  border-bottom: 1px solid var(--warn);
  color: var(--text);
  padding: 0.5rem clamp(0.5rem, 1.5vw, 1.2rem);
  font-size: clamp(0.7rem, 1.1vw, 0.9rem);
  line-height: 1.4;
}

/* ---------- responsive ---------- */

@media (max-width: 860px) {
  .board { grid-template-columns: 1fr 1fr; grid-template-areas: "center center" "home away"; }
  .center { grid-area: center; }
  #teamHome { grid-area: home; }
  #teamAway { grid-area: away; }
  .center__meta { grid-template-columns: 1fr 1fr; }
  .roster-edit { grid-template-columns: 1fr; }
  .hint { display: none; }
  .hint--save { display: inline-flex; }
}

@media (max-width: 560px) {
  :root { --score-size: clamp(3rem, 19vw, 6rem); --clock-size: clamp(2.6rem, 15vw, 5rem); }
  .board { grid-template-columns: 1fr; grid-template-areas: "center" "home" "away"; overflow: auto; }
  .team__stats { grid-template-columns: 1fr 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .row input[type="number"], .row input[type="text"] { width: 100%; }
  .row { grid-template-columns: 1fr; }
}

@media (min-width: 861px) and (max-height: 520px) {
  .roster { display: none; }
}

@media (min-width: 861px) and (max-height: 860px) {
  :root {
    --score-size: clamp(2.6rem, 15vh, 9rem);
    --clock-size: clamp(1.9rem, 12vh, 6rem);
    --shot-size: clamp(1.1rem, 5.5vh, 2.8rem);
    --player-size: clamp(0.66rem, 1.7vh, 1rem);
  }
  .team { padding: 0.35rem; }
  .team__scorebox { padding: 0 0; }
  .player { padding: 0.15rem 0.35rem 0.2rem; gap: 0.1rem; }
  .mini { height: 1.8em; min-width: 2em; }
  .btn--pt { padding: 0.32rem 0; }
  .stat { padding: 0.15rem 0.3rem; }
  .clockbox, .periodbox, .shotbox { padding: 0.3rem; }
  .center__bigctrls .btn--big { padding: 0.4rem 0.4rem; }
}

@media print {
  .topbar, .botbar, .center__bigctrls, .clockbox__ctrls, .shotbox__ctrls, .team__quick { display: none; }
}


/* Public roster refinements: readable names and timeout counter */
.broadcast__roster table { font-size: clamp(.68rem, 1.18vw, 1.25rem); }
.broadcast__roster tbody th { font-size: 1.08em; font-weight: 800; }
.broadcast__roster tbody tr { transition: background .18s ease, color .18s ease; }
.broadcast__roster tbody tr:nth-child(even) { background: #171717; }
.broadcast__roster .broadcast__player--court { background: linear-gradient(90deg, color-mix(in srgb, var(--home-color) 20%, #101010), #101010); }
.broadcast__roster .broadcast__player--court th { color: #fff !important; }
.broadcast__roster .broadcast__player--court th::before { content: "● "; color: #2fffc2; }
.broadcast__timeout-row td { text-align: center; background: #252525; color: #fff; font-weight: 900; font-size: .9em; padding: .28em; }
@media (max-aspect-ratio: 4/3) { .broadcast__roster table { font-size: clamp(.58rem, 1.65vw, 1rem); } }

/* Tercera pantalla: reloj de juego y posesión en un único panel */
body[data-view="hoop"] { margin: 0; background: #000; color: #fff; overflow: hidden; }
body[data-view="hoop"] #app,
body[data-view="hoop"] #publicView,
body[data-view="hoop"] .topbar,
body[data-view="hoop"] .botbar { display: none !important; }
#hoopView { display: none; }
body[data-view="hoop"] #hoopView {
  display: flex; position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh;
  align-items: stretch; justify-content: stretch; padding: clamp(4px, 1vmin, 14px);
  box-sizing: border-box; background: #000; overflow: hidden;
}
body[data-view="hoop"] .hoop-board {
  display: grid; grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1.4fr) minmax(0, 1fr); gap: 0;
  width: 100%; height: 100%; min-width: 0; min-height: 0;
  padding: clamp(4px, 1vmin, 14px); box-sizing: border-box; background: #000;
  border: clamp(2px, 0.45vmin, 7px) solid #555;
  border-radius: clamp(4px, 0.8vmin, 12px); overflow: hidden;
}
body[data-view="hoop"] .hoop-clockbox {
  display: flex; align-items: center; justify-content: center; width: 100%; height: 100%;
  min-width: 0; min-height: 0; padding: 0; border: 0; border-radius: 0;
  background: transparent; box-sizing: border-box; overflow: hidden;
}
body[data-view="hoop"] .hoop-clockbox--shot { border-top: clamp(1px, 0.25vmin, 3px) solid #252525; }
body[data-view="hoop"] .hoop-label { display: none; }
body[data-view="hoop"] .hoop-game-clock,
body[data-view="hoop"] .hoop-shot-clock {
  display: flex; align-items: center; justify-content: center; width: 100%; height: 100%;
  min-width: 0; min-height: 0; margin: 0; padding: 0; font-weight: 1000;
  line-height: 0.9; letter-spacing: -0.055em; text-align: center;
  white-space: nowrap; font-variant-numeric: tabular-nums; overflow: hidden;
}
/* Ambos cronómetros usan exactamente el mismo tamaño visual. */
body[data-view="hoop"] .hoop-game-clock { color: #ffef00; font-size: clamp(2rem, min(30vw, 48vh), 30rem); }
body[data-view="hoop"] .hoop-shot-clock { color: #ff3333; font-size: clamp(2rem, min(30vw, 48vh), 30rem); }
body[data-view="hoop"] .hoop-shot-clock.is-zero { animation: hoop-zero-flash 0.45s steps(2, end) infinite; }
@keyframes hoop-zero-flash { 50% { color: #fff; } }
@media (max-height: 320px) {
  body[data-view="hoop"] #hoopView, body[data-view="hoop"] .hoop-board { padding: 2px; }
  body[data-view="hoop"] .hoop-game-clock,
  body[data-view="hoop"] .hoop-shot-clock { font-size: clamp(1.25rem, 28vh, 8rem); }
}
