/* ============ Tokens ============ */
/* ============ Tokens ============ */
:root {
  --brand: #1c2a5e;            /* color de marca (el club puede cambiarlo) */
  --brand-deep: color-mix(in srgb, var(--brand) 62%, #000);
  --on-brand: #ffffff;
  --bg: #f3f5fb;
  --surface: #ffffff;
  --surface-2: #e9edf8;
  --text: #0e1630;
  --muted: #5b6585;
  --border: #dbe0f0;
  --accent: var(--brand);
  --accent-ink: #ffffff;
  --accent-soft: #e2e8fa;
  --accent-deep: color-mix(in srgb, var(--accent) 70%, #000);
  --ball: #d7f23c;
  --warn: #a8480a;
  --warn-soft: #fdf0cf;
  --danger: #b42318;
  --danger-soft: #fde8e6;
  --drive: #1d5fd1;
  --reves: #a1369b;
  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 1px 2px rgba(14, 22, 48, .05), 0 8px 24px rgba(14, 22, 48, .07);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", Impact, sans-serif;
  --bar-h: 66px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #090e28;
    --surface: #131a3e;
    --surface-2: #1b2352;
    --text: #eaeefc;
    --muted: #98a3cf;
    --border: #262f62;
    --accent: #d7f23c;
    --accent-ink: #0b1130;
    --accent-soft: #232d63;
    --warn: #f5b041;
    --warn-soft: #3a2c10;
    --danger: #ff7b6e;
    --danger-soft: #3d1b18;
    --drive: #8fb0ff;
    --reves: #e58ae0;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.45 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 760px; margin: 0 auto; padding: 18px 16px 120px; }

h1, h2 { font-family: var(--display); text-transform: uppercase; letter-spacing: .01em; line-height: 1.05; }
h1 { font-size: 40px; font-weight: 800; margin: 8px 0 8px; }
h2 { font-size: 22px; font-weight: 700; margin: 0 0 12px; }
p.lead { color: var(--muted); margin: 0 0 22px; font-size: 17px; }

/* ============ Encabezado ============ */
header.top {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-deep) 100%);
  color: var(--on-brand);
}
header.top::after { /* línea de cancha */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: linear-gradient(90deg, var(--ball) 0 28%, transparent 28%);
}
header.top .brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 800; text-transform: uppercase; letter-spacing: .02em; font-size: 24px; text-decoration: none; color: inherit; }
header.top .ball { width: 26px; height: 26px; border-radius: 50%; background: var(--ball); box-shadow: inset -4px -4px 0 rgba(0,0,0,.14); flex: none; position: relative; }
header.top .ball::before, header.top .ball::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; border: 1.5px solid rgba(255,255,255,.85); }
header.top .ball::before { clip-path: inset(0 55% 0 0); }
header.top .ball::after { clip-path: inset(0 0 0 55%); }
header.top .titles { display: flex; flex-direction: column; min-width: 0; line-height: 1.1; }
header.top .title { font-family: var(--display); font-weight: 700; font-size: 24px; text-transform: uppercase; letter-spacing: .01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
header.top .club { opacity: .85; font-weight: 600; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
header.top .club:empty { display: none; }
.brand-logo { width: 36px; height: 36px; object-fit: contain; border-radius: 8px; background: #fff; padding: 2px; }
header.top .pill { font-family: var(--font); flex: none; }
@media (max-width: 719px) { header.top .title { font-size: 21px; } }

/* ============ Componentes base ============ */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; align-items: end; }
@media (max-width: 480px) { .grid3 { grid-template-columns: 1fr 1fr; } .grid3 > :first-child { grid-column: 1 / -1; } }

label.f { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .06em; }
input, select, button { font: inherit; color: inherit; }
input[type="text"], input[type="tel"], input[type="number"], select {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm); border: 1.5px solid var(--border);
  background: var(--surface); min-height: 46px; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
button:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 10px 22px; border-radius: 999px; border: 1.5px solid var(--border);
  background: var(--surface); cursor: pointer; font-weight: 700; text-decoration: none; color: var(--text);
  transition: transform .08s, background .15s, border-color .15s;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 32%, transparent); }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 36px; padding: 6px 14px; font-size: 14px; border-radius: 999px; }
.btn.block { width: 100%; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

.seg { display: inline-flex; padding: 4px; gap: 2px; border-radius: 999px; background: var(--surface-2); }
.seg button { border: 0; background: transparent; padding: 8px 12px; min-height: 38px; cursor: pointer; font-size: 14px; font-weight: 700; color: var(--muted); border-radius: 999px; transition: background .15s, color .15s; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.16); }
.seg.wide { display: flex; width: 100%; }
.seg.wide button { flex: 1; }
.seg.strict { margin-top: 8px; }
.rule { margin-bottom: 14px; }
.check { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.check input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--accent); flex: none; }
input[type="color"] { width: 100%; height: 46px; padding: 4px; border-radius: var(--radius-sm); border: 1.5px solid var(--border); background: var(--surface); }
.logo-prev { width: 40px; height: 40px; object-fit: contain; border-radius: 8px; background: #fff; }
.iconbtn { width: 36px; height: 36px; border-radius: 50%; border: 1px solid transparent; background: transparent; cursor: pointer; color: var(--muted); font-size: 18px; }
.iconbtn:hover { border-color: var(--border); }

.summary { background: var(--accent-soft); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px; }
.warn { background: var(--warn-soft); color: var(--warn); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px; }
.err { background: var(--danger-soft); color: var(--danger); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px; }

.pill { display: inline-block; font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.pill.live { background: var(--accent); color: var(--accent-ink); }
.pill.live::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: 6px; vertical-align: 1px; animation: pulse 1.6s infinite; }
.pill.done { background: var(--accent-soft); color: var(--accent); }
@keyframes pulse { 50% { opacity: .25; } }

/* ============ Formulario de creación ============ */
.players { display: flex; flex-direction: column; gap: 8px; }
.prow { display: grid; grid-template-columns: 28px 1fr auto auto 36px; gap: 6px; align-items: center; }
.prow .lvl { display: none; width: auto; min-height: 40px; padding: 6px 8px; font-size: 14px; }
.players.with-level .prow { grid-template-columns: 28px 1fr auto auto auto 36px; }
.players.with-level .prow .lvl { display: block; }
.prow .num { color: var(--muted); font-size: 13px; text-align: right; font-family: var(--display); font-weight: 700; }
@media (max-width: 560px) {
  .prow { grid-template-columns: 22px 1fr 36px; }
  .prow .seg { grid-column: 2 / 3; justify-self: start; }
  .players.with-level .prow { grid-template-columns: 22px 1fr 36px; }
  .prow .lvl { grid-column: 2 / 3; justify-self: start; }
  .prow { row-gap: 6px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
  .prow .del { grid-row: 1; grid-column: 3; }
}

/* ============ Creación por pasos ============ */
.toplink { color: var(--on-brand); font-weight: 700; font-size: 14px; text-decoration: none; padding: 8px 14px; border-radius: 999px; background: rgba(255,255,255,.14); }
.toplink:hover { background: rgba(255,255,255,.24); }
.row.nowrap { flex-wrap: nowrap; }
.grow { flex: 1; min-width: 0; }

details.mine { margin-bottom: 4px; }
details.mine summary { cursor: pointer; font-weight: 700; padding: 6px 0; color: var(--muted); font-size: 14px; }
details.mine[open] { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 18px; margin-bottom: 14px; }

nav.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 4px 0 16px; position: sticky; top: 0; z-index: 15; padding: 8px 0; background: var(--bg); }
.stp { display: flex; flex-direction: column; align-items: center; gap: 4px; border: 0; background: none; cursor: pointer; padding: 4px 2px; color: var(--muted); font: inherit; font-size: 12px; font-weight: 700; position: relative; }
.stp b { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; font-family: var(--display); font-size: 19px; font-weight: 800; background: var(--surface-2); color: var(--muted); transition: background .15s, color .15s; }
.stp::before { content: ""; position: absolute; top: 21px; left: calc(-50% + 22px); width: calc(100% - 44px); height: 2px; background: var(--border); }
.stp:first-child::before { display: none; }
.stp.done b { background: var(--accent-soft); color: var(--accent); }
.stp.done::before, .stp[aria-current="step"]::before { background: var(--accent); }
.stp[aria-current="step"] { color: var(--text); }
.stp[aria-current="step"] b { background: var(--accent); color: var(--accent-ink); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }

input.title-input { font-family: var(--display); font-size: 24px; font-weight: 700; min-height: 52px; }
input.title-input::placeholder { font-weight: 600; opacity: .55; }
.step-h { margin-bottom: 12px; flex-wrap: nowrap; }
.step-h h2 { margin: 0; }
input.search { width: 100%; min-height: 46px; padding: 10px 16px 10px 40px; border-radius: 999px; border: 1.5px solid var(--border); background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%235b6585' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='8' cy='8' r='6'/%3E%3Cpath d='m16 16-3.6-3.6'/%3E%3C/svg%3E") no-repeat 14px center; font: inherit; color: inherit; }
input.search:focus { outline: none; border-color: var(--accent); background-color: var(--surface); }

.reg { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
@media (min-width: 720px) { .reg { max-height: min(58vh, 560px); overflow-y: auto; margin-right: -6px; padding-right: 6px; } }
.rp { display: flex; align-items: center; gap: 4px; border-radius: 16px; border: 1.5px solid var(--border); background: var(--surface); transition: border-color .15s, background .15s; }
.rp.on { border-color: var(--accent); background: var(--accent-soft); }
.rp-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 9px 4px 9px 10px; border: 0; background: none; cursor: pointer; text-align: left; font: inherit; color: inherit; }
.rp-main .avatar { width: 40px; height: 40px; font-size: 18px; }
.rp-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.rp-name { font-weight: 700; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-meta { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tick { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--border); flex: none; display: grid; place-items: center; transition: background .15s, border-color .15s; }
.rp.on .tick { background: var(--accent); border-color: var(--accent); }
.rp.on .tick::after { content: ""; width: 10px; height: 6px; border: solid var(--accent-ink); border-width: 0 0 2.5px 2.5px; transform: rotate(-45deg) translate(1px, -1px); }
.rp .iconbtn { margin-right: 4px; font-size: 16px; }
.empty { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 26px 12px; border: 2px dashed var(--border); border-radius: 18px; }

details.fold > summary { list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 10px; cursor: pointer; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::after { content: "›"; font-size: 24px; line-height: 1; color: var(--muted); transform: rotate(90deg); transition: transform .15s; }
details.fold[open] > summary::after { transform: rotate(-90deg); }
details.fold > summary > :last-child:not(:first-child) { margin-left: auto; }

.steppers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.numstep { display: flex; align-items: center; background: var(--surface-2); border-radius: 999px; padding: 4px; }
.numstep button { width: 46px; height: 46px; flex: none; border-radius: 50%; border: 0; background: var(--surface); font-size: 24px; font-weight: 700; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.12); color: var(--text); }
.numstep button:active { transform: scale(.94); }
.numstep input[type="number"] { flex: 1; min-width: 0; border: 0; background: transparent; text-align: center; font-family: var(--display); font-size: 32px; font-weight: 800; padding: 0; min-height: 46px; -moz-appearance: textfield; appearance: textfield; }
.numstep input::-webkit-outer-spin-button, .numstep input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.numstep input:focus { box-shadow: none; }
#timeOpts .numstep { max-width: 260px; }
.hint { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; width: 100%; margin-top: 14px; padding: 12px 14px; border: 0; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--text); font: inherit; font-size: 14px; text-align: left; cursor: pointer; }
.hint:disabled { cursor: default; color: var(--muted); }
.hint-go { margin-left: auto; font-weight: 800; color: var(--accent); }
.hint-sub { flex-basis: 100%; font-size: 13px; color: var(--muted); }

.opts { display: grid; gap: 8px; }
.opts.two { grid-template-columns: 1fr 1fr; }
.opt { display: flex; align-items: flex-start; gap: 12px; padding: 14px; border-radius: 16px; border: 1.5px solid var(--border); background: var(--surface); cursor: pointer; text-align: left; font: inherit; color: inherit; transition: border-color .15s, background .15s; }
.opt strong { display: block; font-size: 16px; }
.opt-desc { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; line-height: 1.35; }
.opt-dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border); flex: none; margin-top: 1px; transition: border .15s; }
.opt[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.opt[aria-pressed="true"] .opt-dot { border: 7px solid var(--accent); }

.review { display: flex; flex-direction: column; }
.rv { display: grid; grid-template-columns: 96px 1fr auto; gap: 10px; align-items: center; padding: 14px 0; border: 0; border-bottom: 1px solid var(--border); background: none; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.rv-l { font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.rv-v { font-weight: 700; min-width: 0; }
.rv-s { display: block; font-weight: 400; font-size: 13px; color: var(--muted); margin-top: 2px; }
.rv-e { font-size: 13px; font-weight: 700; color: var(--accent); }
.rv-total { padding-top: 12px; font-weight: 700; }
@media (max-width: 480px) { .rv { grid-template-columns: 1fr auto; } .rv-l { grid-column: 1 / -1; } }

.wizbar { position: sticky; bottom: 12px; z-index: 20; margin-top: 18px; padding: 10px; border-radius: 26px; background: var(--brand-deep); color: var(--on-brand); box-shadow: 0 10px 30px rgba(8, 12, 38, .3); }
.wizsum { text-align: center; font-size: 13px; font-weight: 700; opacity: .85; margin: 0 0 8px; }
.wizbar .btn { min-height: 52px; border-color: transparent; }
.wizbar #back { background: rgba(255,255,255,.14); color: var(--on-brand); }
.wizbar .btn.primary { background: var(--ball); color: #14204f; box-shadow: none; }
body.wizard .wrap { padding-bottom: 40px; }
body.wizard .card { margin-bottom: 12px; }
@media (max-width: 719px) { body.wizard .wrap { padding-bottom: calc(20px + env(safe-area-inset-bottom)); } .wizbar { bottom: calc(8px + env(safe-area-inset-bottom)); } }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .wizbar { background: var(--surface-2); box-shadow: 0 0 0 1px var(--border), 0 10px 30px rgba(0,0,0,.5); } }

/* Hoja (alta / edición de jugador) */
dialog.sheet { border: 0; padding: 0; width: min(520px, 100vw); max-width: 100vw; max-height: 92vh; border-radius: 26px; background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
dialog.sheet::backdrop { background: rgba(9, 14, 40, .55); }
dialog.sheet form { display: flex; flex-direction: column; gap: 6px; padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); }
dialog.sheet label.f { margin-top: 10px; }
dialog.sheet .btn.primary { margin-top: 14px; min-height: 52px; }
.sheet-h { display: flex; align-items: center; justify-content: space-between; }
.sheet-h h2 { margin: 0; }
.seg.big button { min-height: 44px; font-size: 15px; }
@media (max-width: 560px) {
  dialog.sheet { margin: auto 0 0; width: 100vw; border-radius: 26px 26px 0 0; }
}

/* ============ Página de jugadores ============ */
.ptiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0 4px; }
.ptile { background: var(--surface-2); border-radius: 16px; padding: 10px 6px; text-align: center; }
.ptile b { display: block; font-family: var(--display); font-size: 30px; font-weight: 800; line-height: 1; }
.ptile span { font-size: 11px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
@media (max-width: 420px) { .ptiles { grid-template-columns: repeat(2, 1fr); } }
.phead { display: flex; align-items: center; gap: 14px; }
.phead .avatar { width: 64px; height: 64px; font-size: 28px; }
.phead h1 { margin: 0; font-size: 34px; }
.plink { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); color: inherit; text-decoration: none; }
.plink:last-child { border-bottom: 0; }
.plink .rp-txt { flex: 1; }
.plink .num { font-family: var(--display); font-weight: 800; font-size: 22px; text-align: right; line-height: 1; }
.plink .num small { display: block; font-family: var(--font); font-size: 11px; color: var(--muted); font-weight: 700; }
.plink.off { opacity: .55; }

/* ============ Navegación (abajo en celular, arriba en escritorio) ============ */
nav.tabs {
  display: flex; background: color-mix(in srgb, var(--surface) 94%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
}
nav.tabs button { position: relative; flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; border: 0; background: none; padding: 14px 10px 16px; font-weight: 700; font-size: 15px; color: var(--muted); cursor: pointer; }
nav.tabs button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
nav.tabs button[aria-selected="true"] { color: var(--text); }
nav.tabs button[aria-selected="true"]::after { content: ""; position: absolute; bottom: 4px; left: 50%; width: 9px; height: 9px; margin-left: -4.5px; border-radius: 50%; background: var(--ball); box-shadow: 0 0 0 2px var(--brand); }
@media (max-width: 719px) {
  nav.tabs { position: fixed; top: auto; bottom: 10px; left: 12px; right: 12px; z-index: 30; border: 0; border-radius: 999px; padding: 0 6px; margin-bottom: env(safe-area-inset-bottom); background: var(--brand-deep); box-shadow: 0 10px 30px rgba(8, 12, 38, .35); -webkit-backdrop-filter: none; backdrop-filter: none; }
  nav.tabs button { flex-direction: column; gap: 3px; padding: 9px 4px 8px; font-size: 11px; letter-spacing: .03em; min-height: 58px; color: color-mix(in srgb, var(--on-brand) 62%, transparent); }
  nav.tabs button svg { width: 23px; height: 23px; }
  nav.tabs button[aria-selected="true"] { color: var(--on-brand); }
  nav.tabs button[aria-selected="true"] svg { stroke: var(--ball); }
  nav.tabs button[aria-selected="true"]::after { bottom: auto; top: 3px; width: 6px; height: 6px; margin-left: -3px; box-shadow: none; }
  .wrap { padding-bottom: calc(var(--bar-h) + 130px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(var(--bar-h) + 100px + env(safe-area-inset-bottom)) !important; }
  /* Hoja redondeada sobre la cabecera */
  header.top { padding-bottom: 38px; }
  header.top::after { display: none; }
  main.wrap { position: relative; margin-top: -26px; background: var(--bg); border-radius: 28px 28px 0 0; padding-top: 22px; max-width: none; }
  main.wrap > * { max-width: 760px; margin-left: auto; margin-right: auto; }
}

@media (max-width: 719px) and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) nav.tabs { background: var(--surface-2); box-shadow: 0 0 0 1px var(--border), 0 10px 30px rgba(0, 0, 0, .5); }
}

/* ============ Vista del jugador ============ */
.who { position: relative; overflow: hidden; margin-bottom: 16px; padding: 22px 18px 16px; border-radius: var(--radius); background: linear-gradient(160deg, var(--brand), var(--brand-deep)); color: var(--on-brand); }
.who::before { content: ""; position: absolute; right: -40px; top: -40px; width: 140px; height: 140px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, rgba(255,255,255,.35), rgba(255,255,255,.04) 70%); pointer-events: none; }
.who-title { font-family: var(--display); font-size: 34px; font-weight: 800; text-transform: uppercase; line-height: 1; position: relative; }
.who-sub { margin: 6px 0 14px; opacity: .8; font-size: 15px; position: relative; }
.who-search { width: 100%; min-height: 46px; padding: 10px 16px; border-radius: 999px; border: 0; background: rgba(255,255,255,.14); color: inherit; font: inherit; margin-bottom: 12px; position: relative; }
.who-search::placeholder { color: color-mix(in srgb, var(--on-brand) 60%, transparent); }
.who-search:focus { outline: none; box-shadow: 0 0 0 2px var(--ball); }
.namechips { display: flex; flex-wrap: wrap; gap: 8px; max-height: 320px; overflow-y: auto; position: relative; }
.namechip { border: 0; border-radius: 999px; padding: 10px 16px; min-height: 44px; font: inherit; font-weight: 700; cursor: pointer; background: rgba(255,255,255,.14); color: inherit; transition: transform .08s, background .15s; }
.namechip:hover { background: rgba(255,255,255,.24); }
.namechip:active { transform: scale(.96); background: var(--ball); color: #14204f; }
.who-skip { display: block; margin: 14px auto 0; border: 0; background: none; color: inherit; opacity: .75; font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; padding: 8px; position: relative; }

.me-card { position: relative; overflow: hidden; margin-bottom: 16px; border-radius: var(--radius); background: linear-gradient(160deg, var(--brand), var(--brand-deep)); color: var(--on-brand); box-shadow: var(--shadow); }
.me-card::before { content: ""; position: absolute; right: -44px; top: -44px; width: 150px; height: 150px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, rgba(255,255,255,.3), rgba(255,255,255,.03) 70%); pointer-events: none; }
.me-top { display: flex; align-items: center; gap: 12px; padding: 16px 18px 8px; position: relative; }
.me-top .avatar.big { width: 50px; height: 50px; font-size: 24px; background: var(--ball); color: #14204f; }
.me-card, .who { border: 1px solid rgba(255,255,255,.1); }
.me-name { font-family: var(--display); font-size: 28px; font-weight: 800; text-transform: uppercase; line-height: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-change { border: 0; background: none; color: inherit; opacity: .7; font: inherit; font-size: 12px; font-weight: 600; text-decoration: underline; cursor: pointer; padding: 4px 0 0; }
.me-rank { text-align: right; line-height: 1.05; }
.me-rank b { display: block; font-family: var(--display); font-size: 34px; font-weight: 800; color: var(--ball); }
.me-rank span { font-size: 12px; font-weight: 700; opacity: .8; }
.me-now { display: flex; align-items: center; gap: 16px; padding: 8px 18px 16px; position: relative; }
.me-court { display: grid; place-items: center; width: 88px; height: 88px; flex: none; border-radius: 22px; background: var(--ball); color: #14204f; line-height: .9; text-align: center; }
.me-court small { font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; margin-top: 8px; }
.me-court b { font-family: var(--display); font-size: 56px; font-weight: 800; margin-top: -6px; }
.me-who { min-width: 0; }
.me-label { font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; opacity: .7; margin-bottom: 4px; }
.me-with { font-size: 18px; line-height: 1.25; }
.me-with b { font-weight: 800; }
.me-vs { opacity: .85; font-size: 15px; line-height: 1.3; margin-top: 2px; overflow-wrap: anywhere; }
.me-result { display: inline-block; margin-top: 8px; padding: 3px 12px; border-radius: 999px; font-size: 13px; font-weight: 800; background: rgba(255,255,255,.18); }
.me-result.win { background: var(--ball); color: #14204f; }
.me-rest { padding: 10px 18px 20px; font-size: 20px; position: relative; }
.me-rest b { font-family: var(--display); font-size: 36px; text-transform: uppercase; color: var(--ball); margin-right: 4px; }
.me-next { display: flex; flex-direction: column; gap: 2px; padding: 12px 18px 14px; background: rgba(0,0,0,.2); font-size: 14px; position: relative; }
.me-next span { font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; opacity: .65; }

/* ============ Ronda ============ */
.roundbar { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.roundbar .label { flex: 1; text-align: center; font-family: var(--display); font-weight: 800; font-size: 30px; text-transform: uppercase; letter-spacing: .01em; line-height: 1; }
.roundbar .label #rPill { font-family: var(--font); vertical-align: 4px; margin-left: 6px; }
.roundbar .btn { width: 44px; min-height: 44px; padding: 0; font-size: 22px; border-radius: 50%; }
.rprog { display: flex; gap: 4px; margin: 10px 4px 16px; }
.rprog i { flex: 1; height: 5px; border-radius: 3px; background: var(--border); }
.rprog i.done { background: color-mix(in srgb, var(--accent) 55%, var(--border)); }
.rprog i.cur { background: var(--accent); }
.rprog i.view { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }

.timer { text-align: center; padding: 22px 16px 20px; overflow: hidden; position: relative; background: linear-gradient(160deg, var(--brand), var(--brand-deep)); color: var(--on-brand); border: 0; }
.timer::before { content: ""; position: absolute; right: -34px; top: -34px; width: 120px; height: 120px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, rgba(255,255,255,.35), rgba(255,255,255,.04) 70%); pointer-events: none; }
.timer .clock { font-family: var(--display); font-size: 88px; font-weight: 800; letter-spacing: .01em; line-height: .95; }
.timer.over .clock { color: #ff8a80; animation: pulse 1s infinite; }
.timer.low .clock { color: var(--ball); }
.timer .bar { height: 6px; border-radius: 3px; background: rgba(255,255,255,.18); margin: 14px 8px 4px; overflow: hidden; }
.timer .bar i { display: block; height: 100%; width: 100%; background: var(--ball); border-radius: 3px; transition: width .3s linear; }
.timer.low .bar i { background: #ffb74d; }
.timer.over .bar i { background: #ff8a80; }
.timer .small.muted { color: color-mix(in srgb, var(--on-brand) 70%, transparent); }
.timer .row { flex-wrap: nowrap; gap: 6px; }
.timer .btn { background: #fff; color: #14204f; border-color: transparent; padding: 10px 14px; flex: 1; min-width: 0; }
.timer .btn.primary { background: var(--ball); color: #14204f; box-shadow: none; }
.timer .row { justify-content: center; margin-top: 12px; }
#pointsInfo { background: var(--accent-soft); border-color: transparent; box-shadow: none; padding: 12px 14px; }

/* Tarjeta de partido */
.match { padding: 0; overflow: hidden; }
.match .mh { display: flex; justify-content: space-between; align-items: center; padding: 8px 14px 8px 8px; background: var(--surface-2); font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.match .court { display: flex; align-items: center; gap: 8px; }
.match .court b { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-family: var(--display); font-size: 20px; font-weight: 800; letter-spacing: 0; }
.match .teams { display: grid; grid-template-columns: 1fr auto; }
.team { display: contents; }
.team .names { padding: 14px 14px 14px 16px; display: flex; flex-direction: column; gap: 3px; min-width: 0; justify-content: center; border-left: 4px solid transparent; }
.team .score { display: flex; align-items: center; justify-content: center; padding: 8px 14px; font-family: var(--display); font-size: 52px; font-weight: 800; min-width: 92px; line-height: 1; }
.team.win .names { border-left-color: var(--accent); background: linear-gradient(90deg, var(--accent-soft), transparent 70%); }
.team.win .score { color: var(--accent); }
.team + .team .names, .team + .team .score { border-top: 1px solid var(--border); }
.pname { font-weight: 700; font-size: 17px; overflow-wrap: anywhere; line-height: 1.25; }
.pname.me { background: var(--ball); color: #13201a; border-radius: 5px; padding: 0 5px; margin-left: -5px; width: fit-content; }
.tag { display: inline-block; font-size: 10px; font-weight: 800; padding: 1px 5px; border-radius: 5px; margin-left: 6px; vertical-align: 2px; letter-spacing: .04em; }
.tag.drive { color: var(--drive); background: color-mix(in srgb, var(--drive) 13%, transparent); }
.tag.reves { color: var(--reves); background: color-mix(in srgb, var(--reves) 13%, transparent); }
.tag.fixed { color: var(--muted); background: var(--surface-2); }
.score input { width: 84px; height: 60px; text-align: center; font-family: var(--display); font-size: 40px; font-weight: 800; padding: 0; border-radius: var(--radius-sm); background: var(--surface-2); border-color: transparent; }
.score input::-webkit-outer-spin-button, .score input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.score input[type=number] { -moz-appearance: textfield; appearance: textfield; }
.match .mf { display: flex; gap: 8px; justify-content: flex-end; align-items: center; padding: 10px 14px 14px; border-top: 1px solid var(--border); }
.match .mf .btn.primary { flex: 1; }
.match.mine { box-shadow: 0 0 0 3px var(--ball), var(--shadow); }

.resting { font-size: 14px; color: var(--muted); padding: 2px 4px; }
.banner { background: var(--ball); color: #13201a; border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; font-weight: 700; }

/* Botón principal fijo al pie */
.cta { position: sticky; bottom: 16px; margin-top: 16px; z-index: 10; }
.cta .btn { min-height: 54px; font-size: 15px; padding: 10px 14px; white-space: nowrap; box-shadow: 0 8px 24px rgba(0,0,0,.22); }
@media (max-width: 719px) { .cta { bottom: calc(var(--bar-h) + 26px + env(safe-area-inset-bottom)); } }

/* ============ Tabla ============ */
table.std { width: 100%; border-collapse: collapse; font-size: 15px; }
table.std th { text-align: right; font-size: 11px; color: var(--muted); font-weight: 800; padding: 6px 6px; border-bottom: 2px solid var(--border); text-transform: uppercase; letter-spacing: .06em; }
table.std td { text-align: right; padding: 11px 6px; border-bottom: 1px solid var(--border); }
table.std th:nth-child(2), table.std td:nth-child(2) { text-align: left; font-weight: 700; }
table.std td.pos { color: var(--muted); width: 36px; font-family: var(--display); font-size: 20px; font-weight: 700; text-align: center; }
table.std td.pts { font-family: var(--display); font-weight: 800; font-size: 26px; line-height: 1; }
table.std tbody tr:nth-child(-n+3) td.pos { color: #fff; }
table.std tbody tr:nth-child(1) td.pos { background: radial-gradient(circle at center, #d4a72c 62%, transparent 64%); }
table.std tbody tr:nth-child(2) td.pos { background: radial-gradient(circle at center, #98a3ad 62%, transparent 64%); }
table.std tbody tr:nth-child(3) td.pos { background: radial-gradient(circle at center, #c07b45 62%, transparent 64%); }
table.std tr.me td { background-color: color-mix(in srgb, var(--ball) 38%, transparent); }
table.std tr.out td { opacity: .5; }
@media (max-width: 420px) { table.std .hide-sm { display: none; } }

/* ============ Jugadores (organizador) ============ */
.plist { display: flex; flex-direction: column; }
.plist .pi { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.plist .pi:last-child { border-bottom: 0; }
.plist .pi.out .pname { text-decoration: line-through; color: var(--muted); }
.plist .pi.out .avatar { filter: grayscale(1); opacity: .5; }
.avatar { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; flex: none; font-family: var(--display); font-size: 20px; font-weight: 800; letter-spacing: .02em; color: var(--accent); background: var(--accent-soft); }
.avatar[data-sex="F"] { color: var(--reves); background: color-mix(in srgb, var(--reves) 14%, var(--surface)); }
.avatar[data-sex="M"] { color: var(--drive); background: color-mix(in srgb, var(--drive) 14%, var(--surface)); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.chip { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.chip.pj { background: var(--accent-soft); color: var(--accent); }

.qr { display: grid; place-items: center; padding: 8px; }
.qr img { width: min(280px, 80vw); height: auto; background: #fff; padding: 12px; border-radius: var(--radius); border: 1px solid var(--border); }
.linkbox { display: flex; gap: 8px; }
.linkbox input { font-size: 14px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 12px 20px; border-radius: 999px; font-size: 14px; font-weight: 700; z-index: 50; max-width: calc(100vw - 32px); box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.conn { position: fixed; top: 8px; right: 8px; z-index: 60; }
.list-t a { display: flex; justify-content: space-between; padding: 14px 0; border-bottom: 1px solid var(--border); color: inherit; text-decoration: none; font-weight: 700; }

.pending { border-color: var(--ball); border-width: 2px; }
.pending .pi { display: flex; gap: 8px; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); flex-wrap: wrap; }

/* ============ Modo TV ============ */
body.tv-mode { overflow: hidden; }
body.tv-mode header.top, body.tv-mode nav.tabs, body.tv-mode main { display: none; }
.tv { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--bg); padding: 2vh 2vw; gap: 2vh; font-size: clamp(14px, 1.6vw, 34px); }
.tv-head { display: flex; align-items: center; gap: 1.5vw; background: linear-gradient(135deg, var(--brand), var(--brand-deep)); color: var(--on-brand); border-radius: 18px; padding: 1.5vh 2vw; }
.tv-logo { height: 8vh; width: auto; background: #fff; border-radius: 12px; padding: 4px; }
.ball.big { width: 6vh; height: 6vh; border-radius: 50%; background: var(--ball); flex: none; }
.tv-titles { flex: 1; min-width: 0; }
.tv-club { font-size: .8em; opacity: .85; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.tv-name { font-family: var(--display); font-size: 2em; font-weight: 800; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tv-round { font-family: var(--display); font-size: 2em; font-weight: 800; text-transform: uppercase; }
.tv-round span { font-size: .6em; opacity: .8; font-weight: 600; }
.tv-clock { font-family: var(--display); font-size: 4.6em; font-weight: 800; line-height: .9; min-width: 3.2em; text-align: right; }
.tv-clock.small { font-size: 2em; }
.tv-clock.low { color: var(--ball); }
.tv-clock.over { color: #fff; background: var(--danger); border-radius: 12px; padding: 0 .2em; }
.tv-body { flex: 1; display: grid; grid-template-columns: 1fr minmax(18em, 28%); gap: 2vw; min-height: 0; }
.tv-courts { display: grid; grid-template-columns: repeat(auto-fit, minmax(14em, 1fr)); gap: 1.5vw; align-content: start; overflow: hidden; }
.tv-court { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 1.2vh 1.2vw; }
.tv-court-h { font-size: .75em; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; margin-bottom: .4em; }
.tv-team { display: flex; align-items: center; gap: .5em; }
.tv-names { flex: 1; font-weight: 700; font-size: 1.15em; line-height: 1.25; }
.tv-score { font-family: var(--display); font-size: 3.2em; font-weight: 800; min-width: 1.2em; text-align: right; line-height: 1; }
.tv-team.win .tv-score { color: var(--accent); }
.tv-vs { font-size: .7em; color: var(--muted); font-weight: 700; margin: .2em 0; }
.tv-rest { grid-column: 1 / -1; color: var(--muted); font-size: .85em; }
.tv-side { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 1.5vh 1.2vw; display: flex; flex-direction: column; min-height: 0; }
.tv-side-h { font-family: var(--display); font-size: 1.4em; font-weight: 800; text-transform: uppercase; margin-bottom: .3em; }
.tv-table { width: 100%; border-collapse: collapse; font-size: .9em; }
.tv-table td { padding: .25em .2em; border-bottom: 1px solid var(--border); }
.tv-table .pos { color: var(--muted); width: 1.6em; font-family: var(--display); font-weight: 700; }
.tv-table .nm { font-weight: 600; }
.tv-table .pts { text-align: right; font-family: var(--display); font-weight: 800; font-size: 1.3em; }
.tv-qr { margin-top: auto; display: flex; align-items: center; gap: .6em; font-size: .7em; color: var(--muted); padding-top: 1vh; }
.tv-qr img { width: 7em; height: 7em; background: #fff; padding: 4px; border-radius: 8px; }
@media (max-aspect-ratio: 1/1) { .tv-body { grid-template-columns: 1fr; } .tv-side { display: none; } }

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