/* Fuentes incluidas en la app (sin peticiones a terceros), con licencia SIL OFL 1.1.
   Rajdhani (fonts/OFL.txt): rótulos, botones y cifras. Barlow (fonts/OFL-barlow.txt): textos de lectura. */
@font-face {
  font-family: 'Rajdhani'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('fonts/rajdhani-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Rajdhani'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('fonts/rajdhani-latin-600-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Rajdhani'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('fonts/rajdhani-latin-700-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Barlow'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('fonts/barlow-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Barlow'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('fonts/barlow-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Barlow'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('fonts/barlow-latin-600-normal.woff2') format('woff2');
}

:root {
  /* Superficies, de la más profunda a la más elevada */
  --bg: #06080a;
  --surface: #0e1217;
  --surface2: #161b22;
  --surface3: #212833;
  --field: #0a0d11;
  --card: linear-gradient(180deg, #12171d, #0e1217 120px);
  --border: #242b35;
  --border2: #38424f;
  /* Texto */
  --text: #edf1f5;
  --muted: #94a2b6;
  --gray: #6a7586;
  /* Color: verde = nuestro equipo y acción principal; azul = rival; ámbar = destacado */
  --green: #00e676;
  --blue: #29b6f6;
  --amber: #ffca28;
  --orange: #ff9100;
  --red: #ff5252;
  --purple: #b388ff;
  --pink: #ff80ab;
  --teal: #1de9b6;
  --miss: #ff8a80;
  --ball: #ff8a00;
  --on-accent: #04150b;
  --on-amber: #1a1300;
  --primary: linear-gradient(180deg, #37f093, #00d86c);
  /* Gráficos: tonos propios de cada tema, comprobados para daltonismo y contraste sobre la superficie */
  --c-us: #0fae62;
  --c-them: #3d9be9;
  --c-win: #0fae62;
  --c-loss: #bf3f36;
  --c-neutral: #6a7586;
  --zebra: #ffffff05;
  --toast-bg: #1d232cf5;
  --toast-border: #3a4452;
  --toast-text: #edf1f5;
  --shadow: rgba(0, 0, 0, .6);
  --backdrop: rgba(3, 5, 8, .74);
  --elev: inset 0 1px 0 #ffffff08;
  --key: inset 0 -2px 0 #00000040;
  --glow: .5;
  --press: brightness(1.45);
  --radius: 10px;
  --font: 'Rajdhani', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-digits: 'Rajdhani', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-text: 'Barlow', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f0f3f8;
  --surface: #ffffff;
  --surface2: #f3f6fa;
  --surface3: #e4e9f1;
  --field: #f6f8fb;
  --card: #ffffff;
  --border: #d5dce8;
  --border2: #b6c1d2;
  --text: #172136;
  --muted: #51627c;
  --gray: #7889a3;
  --green: #00a854;
  --blue: #0284c7;
  --amber: #c26a04;
  --orange: #ea580c;
  --red: #dc2626;
  --purple: #7c3aed;
  --pink: #db2777;
  --teal: #0d9488;
  --miss: #e05252;
  --on-accent: #ffffff;
  --on-amber: #ffffff;
  --primary: linear-gradient(180deg, #0cb862, #009a4d);
  --c-us: #00a854;
  --c-them: #0284c7;
  --c-win: #00a854;
  --c-loss: #c81e1e;
  --c-neutral: #7889a3;
  --zebra: #1721360a;
  --toast-bg: #172136f5;
  --toast-border: #172136;
  --toast-text: #ffffff;
  --shadow: rgba(23, 33, 54, .22);
  --backdrop: rgba(23, 33, 54, .45);
  --elev: 0 1px 2px #1721360f, 0 6px 18px -8px #17213626;
  --key: inset 0 -2px 0 #1721360f;
  --glow: 0;
  --press: brightness(.93);
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; }
body {
  overflow: hidden; overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility;
}
input, select, textarea { user-select: text; -webkit-user-select: text; }
button, .btn, select, input { font-family: inherit; touch-action: manipulation; }
button { cursor: pointer; color: inherit; background: none; border: 0; padding: 0; }
button:disabled { opacity: .35; cursor: default; }
a { color: var(--blue); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
h2 { font-size: 14px; letter-spacing: .13em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; font-weight: 700; }
h2:not(:first-child) { margin-top: 20px; }
h3 { margin: 0; font-size: 19px; font-weight: 700; }
p { font-family: var(--font-text); }
.muted { color: var(--muted); font-weight: 500; }
.small { font-size: 13.5px; line-height: 1.45; }
h2 .muted { letter-spacing: .04em; }
.grow { flex: 1 1 auto; min-width: 0; }
.hl { color: var(--amber); }
.row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.empty { color: var(--muted); text-align: center; padding: 24px 8px; line-height: 1.5; font-size: 15px; }
.empty .ball { display: block; width: 56px; height: 56px; margin: 0 auto 12px; opacity: .9; }
.warn {
  background: color-mix(in srgb, var(--amber) 9%, transparent); border: 1px solid color-mix(in srgb, var(--amber) 33%, transparent);
  color: var(--amber); padding: 8px 10px; border-radius: 10px; font-size: 14px; margin: 0 0 10px;
}
.warn a { color: inherit; font-weight: 600; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--red); margin-right: 6px; vertical-align: middle; animation: pulse 1.6s ease-out infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--red) 55%, transparent); }
  70%, 100% { box-shadow: 0 0 0 7px transparent; }
}

/* Iconos: trazo propio, heredan el color del texto */
.ic { width: 1.2em; height: 1.2em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.22em; }
.ic.solid { fill: currentColor; stroke-width: 1.5; }
.ball { flex: none; width: 1.2em; height: 1.2em; vertical-align: -.22em; }

/* ── Formularios ── */
label { display: flex; flex-direction: column; gap: 5px; font-family: var(--font-text); font-size: 13px; font-weight: 500; color: var(--muted); min-width: 0; }
input, select {
  background: var(--field); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 9px 11px; font-size: 17px; font-weight: 600; min-width: 0; width: 100%;
  transition: border-color .12s, box-shadow .12s;
}
input::placeholder { color: var(--gray); font-weight: 500; }
input:focus, select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 25%, transparent); }
input[type=date] {
  /* Safari en iOS da al campo de fecha un ancho mínimo propio y se sale del contenedor */
  min-height: 42px; display: block; max-width: 100%; min-width: 0;
  -webkit-appearance: none; appearance: none; text-align: left;
}
input[type=date]::-webkit-date-and-time-value { text-align: left; margin: 0; min-width: 0; }
select {
  -webkit-appearance: none; appearance: none; padding-right: 38px; text-overflow: ellipsis; cursor: pointer;
  background-color: var(--surface2);
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 19px) 55%, calc(100% - 13px) 55%; background-size: 6px 6px; background-repeat: no-repeat;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--surface2); border: 1px solid var(--border); color: var(--text); box-shadow: var(--elev);
  border-radius: 10px; padding: 8px 14px; font-size: 15.5px; font-weight: 700; letter-spacing: .01em; text-decoration: none;
  white-space: nowrap; min-height: 40px; cursor: pointer; transition: background .12s, border-color .12s, transform .06s;
}
.btn .ic { width: 18px; height: 18px; }
.btn:active { transform: scale(.97); background: var(--surface3); }
.btn.primary {
  background: var(--primary); border-color: transparent; color: var(--on-accent);
  box-shadow: inset 0 1px 0 #ffffff59, 0 8px 18px -10px color-mix(in srgb, var(--green) 80%, transparent);
}
.btn.primary:active { filter: brightness(.94); }
.btn.primary:disabled { box-shadow: none; filter: grayscale(.6); }
.btn.danger-fill { background: var(--red); border-color: transparent; color: #fff; box-shadow: inset 0 1px 0 #ffffff40; }
.btn.big { font-size: 18px; min-height: 50px; letter-spacing: .04em; border-radius: 12px; }
.btn.big .ic { width: 20px; height: 20px; }
label.btn { flex-direction: row; font-family: var(--font); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 40px; height: 40px; border-radius: 10px; font-size: 20px; color: var(--text);
  background: var(--surface2); border: 1px solid var(--border); box-shadow: var(--elev); text-decoration: none; flex: none;
  transition: background .12s, color .12s, transform .06s;
}
.icon-btn .ic { width: 20px; height: 20px; }
.icon-btn:active { transform: scale(.94); background: var(--surface3); }
.icon-btn.danger { color: var(--muted); background: transparent; border-color: transparent; box-shadow: none; }
.icon-btn.danger .ic { width: 18px; height: 18px; }
.icon-btn.danger:active { color: var(--red); background: color-mix(in srgb, var(--red) 12%, transparent); }
@media (hover: hover) {
  .btn:not(.primary):not(.danger-fill):hover, .icon-btn:not(.danger):hover { border-color: var(--border2); }
  .icon-btn.danger:hover { color: var(--red); background: color-mix(in srgb, var(--red) 10%, transparent); }
}

/* ── Páginas (Equipo / Partidos / Estadísticas / Ajustes) ── */
.page {
  height: 100dvh; display: flex; flex-direction: column;
  padding: 0 max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  background:
    radial-gradient(60vw 240px at 8% -90px, color-mix(in srgb, var(--green) calc(9% * var(--glow)), transparent), transparent 70%),
    radial-gradient(50vw 220px at 96% -100px, color-mix(in srgb, var(--ball) calc(10% * var(--glow)), transparent), transparent 70%);
}
.nav { flex: none; display: flex; align-items: center; gap: 6px; min-height: 54px; border-bottom: 1px solid var(--border); padding-top: env(safe-area-inset-top); }
.brand {
  display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; margin-right: 6px; max-width: 30vw; height: 40px;
  color: var(--text); text-decoration: none; padding: 0 8px 0 6px; border-radius: 12px; border: 1px solid transparent; flex: none;
  transition: background .12s, border-color .12s;
}
.brand:active, .brand.on { background: var(--surface2); border-color: var(--border); }
.brand .brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.brand .brand-swap { color: var(--muted); flex: none; display: inline-flex; }
.brand .brand-swap .ic { width: 15px; height: 15px; }
.brand .ball { width: 26px; height: 26px; filter: drop-shadow(0 2px 6px color-mix(in srgb, var(--ball) 40%, transparent)); }
.tabs { display: flex; gap: 2px; padding: 3px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; flex: none; }
.tab {
  display: inline-flex; align-items: center; height: 32px; padding: 0 13px; border-radius: 9px;
  color: var(--muted); text-decoration: none; font-weight: 700; font-size: 15.5px; letter-spacing: .02em;
  transition: background .12s, color .12s;
}
.tab:active { background: var(--surface2); }
.tab.on { color: var(--text); background: var(--surface3); box-shadow: inset 0 -2px 0 var(--green), var(--elev); }
.live-link {
  border-color: color-mix(in srgb, var(--red) 45%, transparent); background: color-mix(in srgb, var(--red) 9%, var(--surface));
  border-radius: 20px; padding: 0 14px 0 12px; margin-right: 2px; max-width: 30vw; overflow: hidden; text-overflow: ellipsis; display: inline-block; line-height: 38px;
}
.content { --pad-top: 12px; flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: var(--pad-top) 0 calc(16px + env(safe-area-inset-bottom)); }

.cols { display: flex; gap: 12px; align-items: flex-start; }
.move-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px;
  padding: 10px 10px 10px 14px; border-radius: 14px; font-size: 15px;
  border: 1px solid color-mix(in srgb, var(--green) 45%, transparent); background: color-mix(in srgb, var(--green) 9%, var(--surface));
}
.card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 14px; box-shadow: var(--elev); }
.card.side { flex: 0 0 min(350px, 40%); }

.player-form { display: grid; grid-template-columns: 80px 1fr; gap: 8px; }
.player-form .form-actions { grid-column: 1 / -1; display: flex; gap: 8px; }
.player-form .form-actions .btn { flex: 1; }
.player-form .f-num input { text-align: center; font-size: 19px; font-weight: 700; }

.roster { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; }
.roster li { display: flex; align-items: center; gap: 10px; background: var(--surface2); border: 1px solid var(--border); border-radius: 12px; padding: 5px; }
.roster li.editing { border-color: var(--amber); box-shadow: 0 0 0 3px color-mix(in srgb, var(--amber) 18%, transparent); }
.roster .num, .chip .num, .pid .num {
  font-family: var(--font-digits); font-weight: 700; color: var(--green);
  background: color-mix(in srgb, var(--green) 10%, transparent); border: 1px solid color-mix(in srgb, var(--green) 20%, transparent);
  border-radius: 9px; min-width: 44px; height: 40px; display: inline-flex; align-items: center; justify-content: center; font-size: 19px; flex: none;
}
.roster .name { flex: 1; font-weight: 700; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roster .icon-btn:not(.danger) { background: transparent; border-color: transparent; box-shadow: none; color: var(--muted); }
.roster .icon-btn:not(.danger) .ic { width: 18px; height: 18px; }
.roster .icon-btn + .icon-btn { margin-left: -8px; }

.games { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.games li { display: flex; align-items: center; gap: 8px; background: var(--surface2); border: 1px solid var(--border); border-radius: 12px; padding: 6px; }
.g-date {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; width: 44px; height: 42px; flex: none;
  border-radius: 9px; background: var(--surface3); line-height: 1;
}
.g-date b { font-size: 19px; }
.g-date small { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.g-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.g-main b { font-size: 17px; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-main small { font-family: var(--font-text); color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-res {
  width: 24px; height: 24px; border-radius: 7px; flex: none; display: grid; place-items: center;
  font-size: 13px; font-weight: 700; background: var(--surface3); color: var(--muted);
}
.g-res.win { background: color-mix(in srgb, var(--green) 16%, transparent); color: var(--green); }
.g-res.loss { background: color-mix(in srgb, var(--red) 16%, transparent); color: var(--red); }
.g-res.now { background: color-mix(in srgb, var(--red) 12%, transparent); }
.g-res.now .dot { margin: 0; }
.g-score { font-family: var(--font-digits); font-weight: 700; font-size: 20px; padding: 0 4px 0 0; white-space: nowrap; text-align: right; }
.g-score i { font-style: normal; color: var(--gray); margin: 0 3px; }
.g-score.win { color: var(--green); }
.g-score.loss { color: var(--red); }
.games .icon-btn.danger { margin-left: -6px; }
.games .icon-btn:not(.danger) + .icon-btn:not(.danger) { margin-left: -6px; }
/* Partidos agrupados por fase: nivel a la izquierda y balance a la derecha */
.phase-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.phase-head:first-of-type { margin-top: 0; }
.phase-head span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.phase-rec { flex: none; font-family: var(--font-digits); letter-spacing: .04em; color: var(--text); }
.phase-line { margin: 0; }
.phase-line b { color: var(--text); }

/* ── Partido en directo ── */
.live {
  height: 100dvh; display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.live-top {
  flex: none; height: clamp(46px, 14vh, 62px); display: flex; align-items: center; gap: 6px;
  padding: 4px 6px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.live-top .icon-btn { height: 100%; max-height: 46px; min-width: 42px; }

.period {
  position: relative; overflow: hidden; display: flex; align-items: center; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 10px; height: 100%; max-height: 46px; flex: none; box-shadow: var(--elev);
}
/* Progreso del partido: periodo actual sobre el total */
.period::after { content: ''; position: absolute; left: 0; bottom: 0; height: 2px; width: calc(var(--p, 0) * 100%); background: var(--amber); border-radius: 0 2px 2px 0; }
.period button { width: 32px; height: 100%; color: var(--muted); display: grid; place-items: center; }
.period button .ic { width: 18px; height: 18px; stroke-width: 2.4; }
.period button:active { color: var(--text); background: var(--surface3); }
.period div { display: flex; flex-direction: column; align-items: center; line-height: 1; min-width: 34px; }
.period b { font-family: var(--font-digits); font-size: 18px; color: var(--amber); }
.period small { font-size: 11px; font-weight: 600; color: var(--muted); margin-top: 2px; }

.board { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 8px; }
.board .tname { font-weight: 700; font-size: clamp(12px, 2.6vh, 16px); color: var(--muted); text-transform: uppercase; letter-spacing: .08em; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; }
.board .tname.us { text-align: right; }
.board .score {
  font-family: var(--font-digits); font-weight: 700; font-size: clamp(24px, 8vh, 40px); line-height: 1; flex: none;
  min-width: 1.75em; padding: .06em .22em 0; text-align: center; border-radius: 9px;
  background: var(--field); border: 1px solid var(--border);
}
.board .score.us { color: var(--green); text-shadow: 0 0 calc(18px * var(--glow)) color-mix(in srgb, var(--green) 60%, transparent); }
.board .score.them { color: var(--blue); text-shadow: 0 0 calc(18px * var(--glow)) color-mix(in srgb, var(--blue) 60%, transparent); }
.board .dash { color: var(--gray); font-size: 20px; font-weight: 700; flex: none; margin: 0 -3px; }

.opp-btns { display: flex; gap: 3px; height: 100%; max-height: 46px; flex: none; }
.opp-btns button {
  min-width: 40px; border-radius: 10px; font-family: var(--font-digits); font-weight: 700; font-size: 16px;
  background: color-mix(in srgb, var(--blue) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--blue) 36%, var(--surface)); color: var(--blue);
  box-shadow: var(--key); transition: transform .06s;
}
.opp-btns button.minus { background: transparent; border-color: var(--border); color: var(--muted); box-shadow: none; }
.opp-btns button:active { transform: scale(.92); background: color-mix(in srgb, var(--blue) 28%, var(--surface)); }

.court { flex: 1; min-height: 0; display: grid; grid-template-rows: repeat(5, minmax(0, 1fr)); gap: 4px; padding: 4px 6px; }
.prow { display: grid; grid-template-columns: clamp(86px, 14.5vw, 170px) 1fr; gap: 4px; min-height: 0; }
.prow.f-warn .pid { border-color: color-mix(in srgb, var(--amber) 70%, transparent); }
.prow.f-out .pid { border-color: color-mix(in srgb, var(--red) 70%, transparent); background: color-mix(in srgb, var(--red) 10%, var(--surface)); }
.prow.f-out .acts { opacity: .5; }
.pid {
  display: flex; align-items: center; gap: 6px; padding: 0 6px 0 4px; min-width: 0; text-align: left;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--elev);
}
.pid:active { background: var(--surface2); }
.pid .num {
  position: relative; min-width: clamp(26px, 5.5vw, 52px); height: calc(100% - 8px); max-height: 68px; font-size: clamp(15px, 5vh, 26px);
  flex-direction: column; gap: 0; padding-bottom: clamp(5px, 1.6vh, 9px);
}
/* Faltas del jugador: un punto por falta bajo el dorsal */
.fouls-dots { position: absolute; left: 0; right: 0; bottom: clamp(3px, 1vh, 6px); display: flex; justify-content: center; gap: clamp(1.5px, .3vw, 3px); }
.fouls-dots i { width: clamp(3px, .62vw, 5px); height: clamp(3px, .62vw, 5px); border-radius: 50%; background: color-mix(in srgb, var(--green) 28%, transparent); }
.fouls-dots i.on { background: var(--text); }
.prow.f-warn .fouls-dots i.on { background: var(--amber); }
.prow.f-out .fouls-dots i.on { background: var(--red); }
.prow.f-warn .pid .num { color: var(--amber); background: color-mix(in srgb, var(--amber) 10%, transparent); border-color: color-mix(in srgb, var(--amber) 26%, transparent); }
.prow.f-warn .fouls-dots i { background: color-mix(in srgb, var(--amber) 28%, transparent); }
.prow.f-out .pid .num { color: var(--red); background: color-mix(in srgb, var(--red) 12%, transparent); border-color: color-mix(in srgb, var(--red) 30%, transparent); }
.pinfo { display: flex; flex-direction: column; min-width: 0; line-height: 1.1; }
.pname { font-weight: 700; font-size: clamp(13px, 4vh, 20px); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.pline { font-size: clamp(9px, min(3vh, 1.75vw), 14px); font-weight: 600; color: var(--muted); white-space: nowrap; }
.pline b { color: var(--green); }
.prow.f-warn .fouls { color: var(--amber); font-weight: 700; }
.prow.f-out .fouls, .prow.f-out .pline { color: var(--red); font-weight: 700; }

.acts { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)) 3px repeat(8, minmax(0, 1fr)); gap: 3px; min-width: 0; }
.acts .sep { background: var(--border); border-radius: 2px; margin: 6px 0; }
/* Cada familia de botones tiene su color (--c): fondo, borde y texto salen de él */
.act {
  --c: var(--muted); --fill: 15%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  border-radius: 9px; min-width: 0; overflow: hidden; color: var(--c);
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) var(--fill), var(--surface)), color-mix(in srgb, var(--c) calc(var(--fill) * .55), var(--surface)));
  border: 1px solid color-mix(in srgb, var(--c) 38%, var(--surface)); box-shadow: var(--key);
  transition: transform .06s, filter .06s;
}
.act b { font-family: var(--font-digits); font-weight: 700; font-size: clamp(14px, min(5.5vh, 3.2vw), 26px); line-height: 1; }
.act i { font-style: normal; font-weight: 700; font-size: clamp(8px, min(2.8vh, 1.45vw), 13px); line-height: 1; white-space: nowrap; letter-spacing: 0; }
.act i .ic { display: block; width: clamp(11px, min(3.6vh, 2vw), 17px); height: clamp(11px, min(3.6vh, 2vw), 17px); stroke-width: 3; }
.act.made { --c: var(--green); --fill: 20%; }
.act.miss { --c: var(--miss); --fill: 10%; border-color: color-mix(in srgb, var(--red) 30%, var(--surface)); }
.act.pos { --c: var(--blue); }
.act.neg { --c: var(--orange); }
.act.reb { --c: var(--purple); }
.act.foul { --c: var(--red); border-color: color-mix(in srgb, var(--red) 46%, var(--surface)); }
.act.ast { --c: var(--pink); }
.act.blk { --c: var(--teal); }
.act.pos b, .act.neg b, .act.reb b, .act.foul b, .act.ast b, .act.blk b { font-family: var(--font); font-size: clamp(12px, min(4.6vh, 2.6vw), 22px); letter-spacing: .3px; }
.act:active { transform: scale(.92); filter: var(--press); }
.act.flash { animation: flash .5s ease-out; }
@keyframes flash {
  0% { filter: var(--press); transform: scale(.93); box-shadow: 0 0 0 0 color-mix(in srgb, var(--c) 75%, transparent); }
  100% { filter: none; transform: none; box-shadow: 0 0 0 10px transparent; }
}
:root[data-theme="light"] .act { color: color-mix(in srgb, var(--c) 82%, #000); }

.empty-row { display: block; }
.add-player {
  width: 100%; height: 100%; border: 1.5px dashed var(--border2); border-radius: 10px; color: var(--muted);
  font-size: 16px; font-weight: 700; letter-spacing: .03em; display: flex; align-items: center; justify-content: center; gap: 8px;
}
.add-player:active { background: var(--surface2); color: var(--text); }

.field { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-family: var(--font-text); font-size: 13px; font-weight: 500; color: var(--muted); }
.seg-radio { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.seg-radio label { display: block; cursor: pointer; position: relative; font-family: var(--font); }
.seg-radio input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; pointer-events: none; }
.seg-radio span {
  display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 8px 6px; text-align: center;
  background: var(--field); border: 1.5px solid var(--border); border-radius: 10px; color: var(--muted); transition: border-color .12s, background .12s;
}
.seg-radio b { font-size: 17px; color: var(--text); }
.seg-radio small { font-family: var(--font-text); font-size: 12px; font-weight: 500; }
.seg-radio input:checked + span { border-color: var(--green); background: color-mix(in srgb, var(--green) 12%, var(--surface)); }
.seg-radio input:checked + span b { color: var(--green); }
.seg-radio input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 1px; }
/* Campo sin elegir al empezar un partido */
.venue-field.need .field-label { color: var(--amber); font-weight: 600; }
.venue-field.need .seg-radio span { border-color: var(--amber); background: color-mix(in srgb, var(--amber) 8%, var(--field)); }
.form-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ── Equipos ── */
.teams { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px; }
.team-card {
  display: flex; align-items: stretch; gap: 2px; background: var(--surface2); border: 1.5px solid var(--border); border-radius: 14px; padding: 4px;
  transition: border-color .12s;
}
.team-card.current { border-color: var(--green); background: color-mix(in srgb, var(--green) 6%, var(--surface2)); }
.team-pick { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 8px; text-align: left; border-radius: 10px; }
.team-pick:active { background: var(--surface3); }
/* Escudo con las iniciales; el tono (--h) sale del nombre del equipo */
.crest {
  flex: none; width: 46px; height: 46px; display: grid; place-items: center; font-size: 19px; font-weight: 700; letter-spacing: .02em; color: #fff;
  border-radius: 14px 14px 20px 20px / 12px 12px 26px 26px;
  background: linear-gradient(160deg, hsl(var(--h) 58% 44%), hsl(calc(var(--h) + 24) 62% 30%));
  box-shadow: inset 0 1px 0 #ffffff40, inset 0 -2px 0 #0000002e;
}
.team-info { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.team-name { font-size: 20px; font-weight: 700; line-height: 1.1; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-pick small { font-family: var(--font-text); color: var(--muted); font-size: 12.5px; font-weight: 500; }
.team-pick small.team-phase { color: var(--amber); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-live { color: var(--red); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; margin-top: 2px; }
.team-card .icon-btn.danger { align-self: center; }

/* ── Privacidad ── */
.privacy { max-width: 760px; margin: 0 auto; line-height: 1.6; font-family: var(--font-text); font-size: 16px; }
.privacy h1 { font-family: var(--font); font-size: 28px; margin: 14px 0 4px; display: flex; align-items: center; gap: 10px; }
.privacy h1 .ic { color: var(--green); }
.privacy > .btn { font-family: var(--font); }
.privacy > .btn:last-child { margin-top: 16px; }
.privacy .lead { font-size: 18px; font-weight: 500; margin: 0 0 6px; }
.privacy h2 { font-family: var(--font); margin-top: 22px; }
.privacy p, .privacy ul { margin: 6px 0; }
.privacy ul { padding-left: 22px; }
.privacy li { margin: 4px 0; }
.privacy-note { font-size: 13px; color: var(--muted); margin-top: 10px; display: flex; gap: 6px; align-items: baseline; }
.privacy-note .ic { color: var(--green); flex: none; align-self: center; }
.privacy-note a, .privacy a { color: var(--blue); }

/* ── Ajustes ── */
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.card-head h2 { margin: 0; }
h3.sub { font-size: 12.5px; letter-spacing: .13em; text-transform: uppercase; color: var(--muted); margin: 14px 0 6px; }
.opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 6px; }
.opt {
  display: flex; align-items: center; gap: 10px; padding: 6px 10px 6px 6px; text-align: left; min-width: 0;
  background: var(--surface2); border: 1px solid var(--border); border-radius: 12px; transition: border-color .12s;
}
.opt:not(.on) .opt-btns { opacity: .35; filter: grayscale(1); }
.opt:not(.on) .opt-txt b { color: var(--muted); }
.opt-btns { display: flex; gap: 3px; flex: none; }
.opt-btns .act { width: 44px; height: 42px; }
.opt-btns .act b { font-size: 18px; }
.opt-btns .act i { font-size: 11px; }
.opt-btns .act i .ic { width: 13px; height: 13px; }
.opt-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.opt-txt b { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.opt-txt small { font-family: var(--font-text); color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.switch { flex: none; width: 44px; height: 26px; border-radius: 13px; background: var(--surface3); border: 1px solid var(--border2); position: relative; transition: background .15s, border-color .15s; }
.switch i { position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--muted); box-shadow: 0 1px 3px #0006; transition: transform .15s, background .15s; }
.opt.on .switch { background: var(--green); border-color: var(--green); }
.opt.on .switch i { transform: translateX(18px); background: #fff; }
.preview-card { margin-bottom: 12px; }
.preview .prow { height: clamp(52px, 16vh, 72px); }
.preview .act, .preview .pid { pointer-events: none; }

.btn.kofi { background: #ff5e5b; border-color: transparent; color: #fff; width: 100%; font-size: 16px; min-height: 44px; box-shadow: inset 0 1px 0 #ffffff40; }
.btn.kofi:active { background: #e94e4b; }
.support { text-align: center; color: var(--muted); font-size: 14px; margin: 18px 0 4px; }
.support a { color: #ff5e5b; font-weight: 600; text-decoration: none; white-space: nowrap; }
:root[data-theme="light"] .support a { color: #d63b38; }

/* ── Estadísticas ── */
.stats-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.stats-select { width: auto; max-width: 46vw; min-height: 40px; box-shadow: var(--elev); }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.seg button { height: 32px; padding: 0 12px; border-radius: 9px; font-weight: 700; font-size: 14.5px; color: var(--muted); transition: background .12s, color .12s; }
.seg button.on { background: var(--surface3); color: var(--text); box-shadow: inset 0 -2px 0 var(--green), var(--elev); }
.seg.wide { display: flex; width: 100%; }
.seg.wide button { flex: 1 1 0; min-width: 0; padding: 0 8px; }
.phase-info { font-family: var(--font-text); font-size: 13.5px; font-weight: 500; color: var(--amber); }

.summary { display: flex; align-items: center; gap: 18px; margin-bottom: 10px; }
.final { display: flex; align-items: center; gap: 12px; flex: none; }
.ft { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 72px; }
.ft small { color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .1em; font-size: 12px; max-width: 132px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ft b {
  font-family: var(--font-digits); font-size: 42px; font-weight: 700; line-height: 1; min-width: 1.7em; text-align: center;
  padding: .08em .2em 0; border-radius: 10px; background: var(--field); border: 1px solid var(--border);
}
.ft.us b { color: var(--green); text-shadow: 0 0 calc(20px * var(--glow)) color-mix(in srgb, var(--green) 55%, transparent); }
.ft.them b { color: var(--blue); text-shadow: 0 0 calc(20px * var(--glow)) color-mix(in srgb, var(--blue) 55%, transparent); }
.ft-mid { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.ft-mid small { font-family: var(--font-text); color: var(--muted); font-size: 12px; font-weight: 500; }
.ft-mid small.g-meta { margin-top: -3px; }
.badge { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 20px; background: var(--surface3); color: var(--muted); text-transform: uppercase; letter-spacing: .1em; white-space: nowrap; }
.badge.win { background: color-mix(in srgb, var(--green) 15%, transparent); color: var(--green); }
.badge.loss { background: color-mix(in srgb, var(--red) 15%, transparent); color: var(--red); }

/* Parciales por periodo y, debajo y con las mismas columnas, la evolución del marcador */
.ptable-wrap { flex: 1; overflow-x: auto; min-width: 0; }
.ptable { border-collapse: collapse; width: 100%; }
.ptable th, .ptable td { padding: 4px 6px; text-align: center; font-family: var(--font-digits); font-size: 15px; font-weight: 600; }
.ptable th { color: var(--muted); font-family: var(--font); font-weight: 700; font-size: 12px; letter-spacing: .06em; }
.ptable td.l { font-family: var(--font); font-weight: 700; font-size: 14px; text-align: left; max-width: 120px; width: 1%; padding-left: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ptable td.l.us { color: var(--green); }
.ptable td.l.them { color: var(--blue); }
.ptable td.w { color: var(--text); font-weight: 700; }
.ptable td:not(.l):not(.w):not(.t):not(.flow-cell) { color: var(--gray); }
.ptable td.t, .ptable th.t { width: 1%; padding-left: 12px; padding-right: 2px; border-left: 1px solid var(--border); }
.ptable td.t { color: var(--text); font-weight: 700; font-size: 16px; }
.ptable tr.flow-row td { padding-top: 6px; padding-bottom: 0; }
.ptable td.l.flow-label { color: var(--muted); font-family: var(--font-text); font-size: 11.5px; font-weight: 500; white-space: normal; line-height: 1.2; }
.flow-label b { display: block; font-family: var(--font-digits); font-size: 13px; color: var(--text); white-space: nowrap; }
.ptable td.flow-cell { padding-left: 0; padding-right: 0; }
.flow { position: relative; height: clamp(40px, 11vh, 72px); touch-action: pan-y; cursor: crosshair; }
.flow svg { display: block; width: 100%; height: 100%; overflow: visible; }
.flow path { vector-effect: non-scaling-stroke; fill: none; }
.flow .grid { stroke: var(--border); stroke-width: 1; }
.flow .base { stroke: var(--border2); stroke-width: 1; }
.flow .area.us { fill: color-mix(in srgb, var(--c-us) 30%, transparent); }
.flow .area.them { fill: color-mix(in srgb, var(--c-them) 30%, transparent); }
.flow .line.us { stroke: var(--c-us); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.flow .line.them { stroke: var(--c-them); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.flow-end, .flow-dot {
  position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; pointer-events: none;
  background: var(--c-neutral); box-shadow: 0 0 0 2px var(--surface);
}
.flow-end.us, .flow-dot.us { background: var(--c-us); }
.flow-end.them, .flow-dot.them { background: var(--c-them); }
.flow-cross { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--muted); pointer-events: none; }
.flow-cross[hidden], .flow-dot[hidden] { display: none; }
.ptable td.flow-diff.us { color: var(--green); }
.ptable td.flow-diff.them { color: var(--blue); }

/* Temporada: cifras clave y diferencia de puntos partido a partido */
.kpis { flex: 0 1 auto; min-width: 0; max-width: 440px; display: flex; flex-wrap: wrap; gap: 12px 0; overflow: hidden; margin-left: -12px; }
.kpi-row { display: flex; }
.kpi { display: flex; flex-direction: column; gap: 3px; min-width: 62px; padding: 0 12px; border-left: 1px solid var(--border); margin-left: -1px; }
.kpi small { max-width: 104px; }
.kpi b { font-family: var(--font-digits); font-size: 28px; line-height: 1; }
.kpi small { font-family: var(--font-text); color: var(--muted); font-size: 12px; font-weight: 500; line-height: 1.2; }
.kpi.win b { color: var(--green); }
.kpi.loss b { color: var(--red); }
.trend { flex: 1 1 0; min-width: 240px; margin: 0; align-self: stretch; display: flex; flex-direction: column; padding-left: 18px; border-left: 1px solid var(--border); }
.trend figcaption { font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trend-plot { position: relative; flex: 1; min-height: 50px; margin: 16px 0 15px; display: flex; gap: 2px; }
.trend-plot::before { content: ''; position: absolute; left: 0; right: 0; top: var(--base); height: 1px; background: var(--border2); }
.tcol { position: relative; flex: 0 1 46px; min-width: 0; text-decoration: none; color: var(--text); border-radius: 6px; }
.tcol:active { background: var(--surface2); }
.tbar { position: absolute; left: 50%; width: min(24px, 72%); transform: translateX(-50%); height: var(--h); min-height: 3px; background: var(--c-neutral); }
.tcol.up .tbar { bottom: calc(100% - var(--base)); border-radius: 4px 4px 0 0; }
.tcol.down .tbar { top: var(--base); border-radius: 0 0 4px 4px; }
.tcol.flat .tbar { top: calc(var(--base) - 2px); height: 4px; min-height: 0; border-radius: 2px; }
.tcol.win .tbar { background: var(--c-win); }
.tcol.loss .tbar { background: var(--c-loss); }
.tcol.open .tbar { background: transparent; border: 1.5px solid var(--c-neutral); }
.tcol.up.open .tbar { border-bottom: 0; }
.tcol.down.open .tbar { border-top: 0; }
.tval, .tx { position: absolute; left: 50%; transform: translateX(-50%); font-family: var(--font-digits); line-height: 1; white-space: nowrap; }
.tval { font-size: 12.5px; font-weight: 700; }
.tcol.up .tval { bottom: calc(100% - var(--base) + var(--h) + 3px); }
.tcol.down .tval, .tcol.flat .tval { bottom: calc(100% - var(--base) + 4px); }
.tx { top: calc(100% + 4px); font-size: 11px; font-weight: 600; color: var(--muted); }

.leaders { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.leader {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 8px 12px 9px; min-width: 0; box-shadow: var(--elev);
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: baseline; column-gap: 8px; row-gap: 1px;
}
.leader small { grid-column: 1 / -1; font-family: var(--font-text); color: var(--muted); font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.leader b { font-family: var(--font-digits); font-size: 26px; line-height: 1; color: var(--amber); }
.leader span { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.leader span i { font-style: normal; color: var(--muted); margin-right: 1px; }

.table-card { padding: 0; overflow: hidden; overflow: clip; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* Si la tabla cabe sin desplazarse en horizontal, la cabecera se queda fija al bajar por la página */
.table-wrap.fits { overflow: visible; }
table.stats { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 15.5px; white-space: nowrap; }
table.stats th, table.stats td { padding: 7px 6px; text-align: center; border-bottom: 1px solid var(--border); }
table.stats th {
  font-size: 12px; letter-spacing: .08em; color: var(--muted); font-weight: 700; background: var(--surface2); cursor: pointer;
  position: sticky; top: calc(-1 * var(--pad-top)); z-index: 2; padding-top: 10px; padding-bottom: 9px;
}
table.stats th.sorted { color: var(--amber); }
.sort-ind { display: inline-block; margin-left: 4px; border: 4px solid transparent; vertical-align: middle; }
.sort-ind.asc { border-bottom-color: currentColor; margin-top: -5px; }
.sort-ind.desc { border-top-color: currentColor; margin-bottom: -5px; }
table.stats td { font-weight: 600; font-variant-numeric: tabular-nums; }
table.stats td.sorted { background-image: linear-gradient(color-mix(in srgb, var(--text) 4%, transparent), color-mix(in srgb, var(--text) 4%, transparent)); }
table.stats td.zero { color: var(--gray); font-weight: 500; }
table.stats .gs { border-left: 1px solid var(--border); }
table.stats .c-num { font-family: var(--font-digits); color: var(--muted); width: 40px; padding-left: 12px; }
table.stats .c-name { text-align: left; font-weight: 700; position: sticky; left: 0; background: var(--surface); z-index: 1; }
table.stats th.c-name { background: var(--surface2); z-index: 3; }
table.stats td.hl { color: var(--text); font-weight: 700; font-size: 17px; }
table.stats td.hl.zero { color: var(--gray); }
table.stats td.c-val { padding-right: 12px; }
.val { display: inline-block; min-width: 34px; padding: 2px 7px 1px; border-radius: 8px; background: var(--surface3); }
.val.pos { background: color-mix(in srgb, var(--green) 15%, transparent); color: var(--green); }
.val.neg { background: color-mix(in srgb, var(--red) 15%, transparent); color: var(--red); }
table.stats td.neg { color: var(--red); }
/* Tiros: anotados/intentados y, debajo, el porcentaje con su barra */
.shot { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; line-height: 1; }
.shot small { display: flex; align-items: center; gap: 4px; font-family: var(--font-text); font-size: 10.5px; font-weight: 500; color: var(--muted); }
.meter { display: block; width: 22px; height: 4px; border-radius: 2px; background: color-mix(in srgb, var(--c-us) 22%, transparent); overflow: hidden; }
.meter i { display: block; height: 100%; width: calc(var(--p) * 100%); border-radius: 2px; background: var(--c-us); }
table.stats td.zero .shot small { color: var(--gray); }
table.stats tbody tr:nth-child(even) td { background-color: var(--zebra); }
table.stats tbody tr:nth-child(even) td.c-name { background: linear-gradient(var(--zebra), var(--zebra)), var(--surface); }
table.stats tbody tr.dnp td { color: var(--gray); }
table.stats tbody tr.dnp .val { background: transparent; }
table.stats tfoot td { font-weight: 700; background: var(--surface2); border-bottom: 0; border-top: 1px solid var(--border2); }
table.stats tfoot .c-name { background: var(--surface2); text-transform: uppercase; letter-spacing: .08em; font-size: 13.5px; }
table.stats tfoot td.zero { color: var(--muted); }
.formula { margin: 10px 2px; line-height: 1.45; }

/* ── Modales ── */
#modal[hidden], #toast[hidden] { display: none; }
.modal-back {
  position: fixed; inset: 0; z-index: 50; background: var(--backdrop);
  display: flex; align-items: center; justify-content: center;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  animation: fade .14s;
}
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.modal {
  background: var(--card); background-color: var(--surface); border: 1px solid var(--border2); border-radius: 18px; padding: 14px;
  width: min(920px, 100%); max-height: 100%; display: flex; flex-direction: column; gap: 12px; overflow: hidden;
  box-shadow: 0 28px 70px -18px var(--shadow), var(--elev); animation: pop .18s cubic-bezier(.2, .8, .3, 1);
}
.modal.confirm { width: min(440px, 100%); }
.modal.menu { width: min(420px, 100%); }
.modal.log, .modal.share { width: min(640px, 100%); }
.modal.edit-game { width: min(520px, 100%); }
.modal.edit-game form { overflow-y: auto; min-height: 0; padding: 2px; }
.modal-head h3 small { font-size: 15px; }
.modal-head { display: flex; align-items: center; gap: 10px; justify-content: space-between; flex: none; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; flex: none; flex-wrap: wrap; }
.confirm-msg { margin: 6px 4px; font-size: 17px; line-height: 1.45; }
.confirm-msg small { display: inline-block; margin-top: 4px; font-size: 13.5px; }
.count { font-family: var(--font-digits); font-size: 14px; font-weight: 600; color: var(--amber); background: color-mix(in srgb, var(--amber) 11%, transparent); padding: 4px 11px; border-radius: 20px; white-space: nowrap; }
.count.ok { color: var(--green); background: color-mix(in srgb, var(--green) 11%, transparent); }

.chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 6px; overflow-y: auto; min-height: 0; padding: 2px; }
.chip {
  display: flex; align-items: center; gap: 8px; padding: 4px; text-align: left; min-width: 0;
  background: var(--surface2); border: 1.5px solid var(--border); border-radius: 12px; transition: border-color .1s, background .1s, transform .06s;
}
.chip .cinfo { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.chip .name { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip small { font-family: var(--font-text); color: var(--muted); font-size: 12px; font-weight: 500; white-space: nowrap; }
.chip.on { border-color: var(--green); background: color-mix(in srgb, var(--green) 10%, var(--surface)); }
.chip.on .num { background: var(--primary); border-color: transparent; color: var(--on-accent); }
.chip.out { border-style: dashed; }
.chip.out small { color: var(--red); }
.chip:active { transform: scale(.97); }

.menu-list { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; min-height: 0; padding: 2px; }
.menu-list .btn { justify-content: flex-start; gap: 12px; font-size: 17px; min-height: 46px; }
.menu-list .btn .ic { width: 20px; height: 20px; color: var(--muted); }
.menu-list .btn.finish .ic { color: var(--green); }

.log { overflow-y: auto; min-height: 0; display: flex; flex-direction: column; gap: 3px; }
.log-row { display: flex; align-items: center; gap: 8px; padding: 2px 4px 2px 8px; border-radius: 9px; background: var(--surface2); border-left: 3px solid var(--gray); }
.log-row.made { border-left-color: var(--green); }
.log-row.miss { border-left-color: var(--miss); }
.log-row.pos { border-left-color: var(--blue); }
.log-row.neg { border-left-color: var(--orange); }
.log-row.reb { border-left-color: var(--purple); }
.log-row.foul { border-left-color: var(--red); }
.log-row.ast { border-left-color: var(--pink); }
.log-row.blk { border-left-color: var(--teal); }
.log-row.opp { border-left-color: var(--blue); background: color-mix(in srgb, var(--blue) 6%, transparent); }
.log-row .lp { font-family: var(--font-digits); font-size: 12.5px; font-weight: 700; color: var(--amber); width: 26px; flex: none; }
.log-row .lt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-row .them { color: var(--blue); font-weight: 700; }
.log-row .icon-btn { height: 34px; min-width: 34px; }

.share-preview {
  margin: 0; background: var(--field); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  font-size: 13px; line-height: 1.45; overflow: auto; min-height: 0; white-space: pre-wrap; user-select: text; -webkit-user-select: text;
}

/* ── Toast ── */
#toast {
  position: fixed; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 80;
  color: var(--toast-text); font-family: var(--font-text); font-weight: 500;
  background: var(--toast-bg); border: 1px solid var(--toast-border); border-radius: 14px; padding: 8px 8px 8px 14px;
  display: flex; align-items: center; gap: 12px; box-shadow: 0 12px 32px -6px var(--shadow); font-size: 14.5px;
  max-width: calc(100vw - 24px); white-space: nowrap; pointer-events: auto;
}
#toast span { overflow: hidden; text-overflow: ellipsis; padding: 3px 6px 3px 0; }
#toast b { font-weight: 600; }
#toast button { background: var(--amber); color: var(--on-amber); font-family: var(--font); font-weight: 700; padding: 6px 12px; border-radius: 9px; font-size: 14px; }
#toast.show { animation: toastIn .18s ease-out; }
#toast.top { bottom: auto; top: max(6px, env(safe-area-inset-top)); padding: 5px 14px; font-size: 14px; border-radius: 20px; pointer-events: none; }
#toast.top.show { animation: toastInTop .18s ease-out; }
@keyframes toastInTop { from { opacity: 0; transform: translate(-50%, -10px); } }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ── Aviso de orientación ── */
#rotate { display: none; }
@media (orientation: portrait) {
  #rotate {
    display: flex; position: fixed; inset: 0; z-index: 1000; background: var(--bg);
    flex-direction: column; align-items: center; justify-content: flex-start; gap: 40px; text-align: center;
    overflow-y: auto; -webkit-overflow-scrolling: touch;
    padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
    background-image:
      radial-gradient(ellipse 70% 38% at 50% 24%, color-mix(in srgb, var(--ball) 14%, transparent), transparent 70%),
      radial-gradient(ellipse 90% 30% at 50% 108%, color-mix(in srgb, var(--green) 9%, transparent), transparent 70%);
  }
  /* Centrado vertical que no recorta si el contenido no cabe (se puede desplazar) */
  #rotate > :first-child { margin-top: auto; }
  #rotate > :last-child { margin-bottom: auto; }
  .splash-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; }
  .splash-logo { width: 112px; height: 112px; filter: drop-shadow(0 12px 28px color-mix(in srgb, var(--ball) 38%, transparent)); }
  .splash-name { margin: 6px 0 0; font-size: 42px; font-weight: 700; letter-spacing: .01em; line-height: 1; }
  .splash-name span { color: var(--green); }
  .splash-tag { margin: 0; color: var(--muted); font-family: var(--font); font-size: 15px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; max-width: 280px; line-height: 1.4; text-wrap: balance; }
  .install {
    width: min(340px, 100%); background: var(--card); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--elev);
    padding: 14px 16px; text-align: left; display: flex; flex-direction: column; gap: 8px;
  }
  .install[hidden] { display: none; }
  .install h2 { margin: 0; text-align: center; color: var(--text); font-size: 14px; }
  .install ol { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 6px; font-family: var(--font-text); font-size: 15.5px; line-height: 1.35; }
  .install small { font-family: var(--font-text); color: var(--muted); font-size: 13px; text-align: center; }
  .install .install-btn { width: 100%; }
  .ios-share { width: 20px; height: 20px; vertical-align: -4px; color: var(--blue); }
  /* El candado va en línea con el texto para que las dos líneas queden centradas, como el resto de la pantalla */
  .splash-privacy { margin: 4px 0 0; color: var(--muted); font-size: 13px; font-weight: 500; max-width: 300px; text-align: center; text-wrap: balance; }
  .splash-privacy .ic { color: var(--green); width: 16px; height: 16px; margin-right: 5px; vertical-align: -3px; }
  .rotate-hint { display: flex; flex-direction: column; align-items: center; gap: 6px; }
  .rotate-hint p { margin: 0; font-family: var(--font); font-size: 22px; font-weight: 700; }
  .rotate-hint small { font-family: var(--font-text); color: var(--muted); font-size: 14px; }
  .rotate-icon { width: 48px; height: 48px; color: var(--text); animation: rot 2.4s cubic-bezier(.6, 0, .3, 1) infinite; }
  .rotate-icon .ic { width: 100%; height: 100%; stroke-width: 1.5; }
  @media (max-height: 700px) {
    #rotate { gap: 22px; }
    .splash-logo { width: 84px; height: 84px; }
    .splash-name { font-size: 32px; }
    .splash-tag { font-size: 13px; }
    .rotate-icon { width: 36px; height: 36px; }
    .rotate-hint p { font-size: 19px; }
  }
  @keyframes rot { 0%, 25% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
}

/* ── Pantallas bajas (móvil en horizontal) ── */
@media (max-height: 430px) {
  .seg-radio small { display: none; }
  .seg-radio span { padding: 4px 6px; }
  form[data-form=game].stack { gap: 6px; }
  input, select { padding: 6px 10px; font-size: 16px; }
  select { padding-right: 38px; }
  input[type=date] { min-height: 36px; }
  .btn.big { min-height: 44px; font-size: 17px; }
  label, .field { gap: 2px; }
  .nav { min-height: 46px; }
  .brand { height: 36px; }
  .tab { height: 28px; padding: 0 11px; font-size: 15px; }
  .nav .icon-btn { height: 36px; min-width: 36px; }
  .live-link { line-height: 34px; min-height: 36px; }
  .content { --pad-top: 8px; }
  .card { padding: 10px; }
  h2 { margin-bottom: 6px; }
  h2:not(:first-child) { margin-top: 14px; }
  .stats-head { margin-bottom: 8px; }
  .stats-head .btn, .stats-select { min-height: 36px; }
  .seg button { height: 28px; }
  .summary { margin-bottom: 8px; gap: 14px; }
  .leaders { gap: 6px; margin-bottom: 8px; }
  .leader { padding: 6px 10px 7px; border-radius: 12px; }
  .leader b { font-size: 22px; }
  .leader span { font-size: 15px; }
  .ft b { font-size: 34px; }
  .ptable th, .ptable td { padding-top: 2px; padding-bottom: 2px; }
  .kpi b { font-size: 24px; }
  .trend-plot { min-height: 44px; }
  .opp-btns button { min-width: 36px; font-size: 14px; }
  .team-pick { padding: 6px 8px; }
  /* En un móvil en horizontal el menú del partido va en dos columnas para que quepa sin desplazarse */
  .modal.menu { width: min(620px, 100%); }
  .menu-list { display: grid; grid-template-columns: 1fr 1fr; }
  .menu-list .btn { min-height: 44px; font-size: 16px; }
  .crest { width: 40px; height: 40px; font-size: 17px; }
}
@media (max-width: 760px) {
  .games li { flex-wrap: wrap; row-gap: 4px; }
  .g-main { flex: 1 1 40%; }
  .g-main small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .games li > .btn:first-of-type { margin-left: auto; }
  .brand .brand-name { display: none; }
  .brand { margin-right: 2px; gap: 4px; padding: 0 4px; }
  .tab { padding: 0 9px; }
  .board .tname { display: none; }
  .live-top { gap: 4px; }
  .pid { gap: 4px; padding: 0 4px 0 3px; }
  .live-top .icon-btn { min-width: 36px; }
  .leaders { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .leaders .leader:nth-child(n+4) { display: none; }
  .summary { gap: 12px; }
  .ft { min-width: 60px; }
  .ft small { max-width: 92px; }
  .kpis { max-width: 400px; }
  .trend { padding-left: 12px; }
}
/* Móviles pequeños: el gráfico de la temporada pasa debajo de las cifras, a todo el ancho */
@media (max-width: 700px) {
  .summary:has(.trend) { flex-wrap: wrap; }
  .kpis { max-width: none; }
  .trend { flex-basis: 100%; min-width: 0; padding-left: 0; border-left: 0; }
  .trend-plot { height: 56px; flex: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
