/* =====================================================================
   Componentes
   ===================================================================== */

/* ------------------------------------------------------------------ navbar */

.nav {
  position: sticky;
  top: 0;
  z-index: 40;
  padding-top: var(--safe-top);
  background: var(--bg-blur);
  backdrop-filter: saturate(180%) blur(22px);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--fast) linear;
}
.nav--scrolled { border-bottom-color: var(--hairline); }

.nav__bar {
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding-inline: var(--s4);
}

.nav__title {
  font-size: var(--t-headline);
  font-weight: 650;
  letter-spacing: -.01em;
  flex: 1 1 auto;
  min-width: 0;
}

.nav__action {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: var(--r-pill);
  color: var(--text);
  font-size: 1.0625rem;
  transition: background var(--fast) linear, transform var(--fast) var(--ease);
}
.nav__action:active { transform: scale(.9); background: var(--card-2); }
.nav__action--tint { color: var(--blue); }

.nav__large {
  padding: 0 var(--s4) var(--s3);
}
.nav__large h1 {
  font-family: var(--font-num);
  font-size: var(--t-large);
  font-weight: 780;
  letter-spacing: -.028em;
  line-height: 1.08;
}
.nav__large p {
  margin-top: 3px;
  font-size: var(--t-foot);
  color: var(--text-2);
}

/* ------------------------------------------------------------------ tabbar */

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  display: flex;
  padding-bottom: var(--safe-bottom);
  background: var(--bg-blur);
  backdrop-filter: saturate(180%) blur(22px);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  border-top: 1px solid var(--hairline);
}
@media (min-width: 700px) {
  .tabbar {
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: var(--shell-max);
    border-inline: 1px solid var(--hairline);
  }
}

.tab {
  flex: 1 1 0;
  height: var(--tab-h);
  display: grid;
  place-items: center;
  gap: 2px;
  grid-template-rows: 22px auto;
  color: var(--text-3);
  transition: color var(--fast) linear, transform var(--fast) var(--ease);
  position: relative;
}
.tab i { font-size: 1.125rem; }
.tab span {
  font-size: var(--t-micro);
  font-weight: 560;
  letter-spacing: -.005em;
}
.tab:active { transform: scale(.92); }
.tab[aria-current="page"] { color: var(--text); }
.tab[aria-current="page"] i {
  background: var(--ig-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.tab__dot {
  position: absolute;
  top: 6px; right: 50%;
  margin-right: -16px;
  width: 8px; height: 8px;
  border-radius: var(--r-pill);
  background: var(--red);
  box-shadow: 0 0 0 2px var(--bg);
}

/* ------------------------------------------------------------------ tarjetas */

.card {
  background: var(--card);
  border-radius: var(--r-lg);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.card--pad { padding: var(--s4); }
.card--flat { border-radius: 0; border-inline: 0; }

.card__head {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--hairline);
}
.card__head h3 {
  font-size: var(--t-sub);
  font-weight: 640;
  flex: 1;
}
.card__head i { color: var(--text-2); font-size: .875rem; }

/* Lista agrupada estilo iOS */
.list { background: var(--card); border-radius: var(--r-lg); border: 1px solid var(--hairline); overflow: hidden; }
.list__row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  padding: var(--s3) var(--s4);
  text-align: left;
  position: relative;
  transition: background var(--fast) linear;
}
.list__row + .list__row::before {
  content: "";
  position: absolute;
  top: 0; left: var(--s4); right: 0;
  height: 1px;
  background: var(--hairline);
}
button.list__row:active { background: var(--card-2); }
.list__row i.chev { color: var(--text-3); font-size: .8125rem; }

/* ------------------------------------------------------------------ pastillas */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: var(--r-pill);
  font-size: var(--t-caption);
  font-weight: 600;
  background: var(--card-2);
  color: var(--text-2);
  white-space: nowrap;
}
.pill i { font-size: .6875rem; }
.pill--green  { background: var(--tint-green);  color: var(--green); }
.pill--red    { background: var(--tint-red);    color: var(--red); }
.pill--blue   { background: var(--tint-blue);   color: var(--blue); }
.pill--orange { background: var(--tint-orange); color: var(--orange); }
.pill--solid  { background: var(--text); color: var(--bg); }
.pill--live   { background: var(--tint-red); color: var(--red); }
.pill--live .dot {
  width: 6px; height: 6px; border-radius: var(--r-pill);
  background: var(--red);
  animation: pulse-dot 1.6s ease-in-out infinite;
}

.chips {
  display: flex;
  gap: var(--s2);
  overflow-x: auto;
  scrollbar-width: none;
  padding: var(--s1) var(--s4) var(--s3);
  scroll-snap-type: x proximity;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  scroll-snap-align: center;
  padding: 7px 14px;
  border-radius: var(--r-pill);
  background: var(--card);
  border: 1px solid var(--hairline);
  font-size: var(--t-foot);
  font-weight: 600;
  color: var(--text-2);
  transition: transform var(--fast) var(--ease), background var(--fast) linear,
              color var(--fast) linear, border-color var(--fast) linear;
}
.chip:active { transform: scale(.94); }
.chip[aria-pressed="true"] {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}
.chip--done::after {
  content: "";
  display: inline-block;
  width: 5px; height: 5px;
  margin-left: 6px;
  border-radius: var(--r-pill);
  background: var(--green);
  vertical-align: middle;
}

/* ------------------------------------------------------------------ botones */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: 46px;
  padding: 0 var(--s5);
  border-radius: var(--r-md);
  font-size: var(--t-headline);
  font-weight: 640;
  background: var(--card-2);
  color: var(--text);
  transition: transform var(--fast) var(--ease), opacity var(--fast) linear,
              filter var(--fast) linear;
}
.btn:active { transform: scale(.975); filter: brightness(.94); }
.btn[disabled] { opacity: .42; pointer-events: none; }
.btn--block { width: 100%; }
.btn--primary { background: var(--blue); color: #fff; }
.btn--gradient { background: var(--ig-gradient); color: #fff; }
.btn--danger { background: var(--tint-red); color: var(--red); }
.btn--ghost { background: transparent; color: var(--blue); min-height: 40px; }
.btn--sm { min-height: 36px; padding: 0 var(--s3); font-size: var(--t-foot); border-radius: var(--r-sm); }

.btn__spin {
  width: 15px; height: 15px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Barra flotante para guardar votos */
.savebar {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(var(--tab-h) + var(--safe-bottom));
  z-index: 45;
  padding: var(--s3) var(--s4);
  background: var(--bg-blur);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border-top: 1px solid var(--hairline);
  transform: translateY(130%);
  transition: transform var(--mid) var(--ease);
}
@media (min-width: 700px) {
  .savebar { left: 50%; transform: translateX(-50%) translateY(130%); width: 100%; max-width: var(--shell-max); }
  .savebar--on { transform: translateX(-50%) translateY(0); }
}
.savebar--on { transform: translateY(0); }

/* ------------------------------------------------------------------ campos */

.field { display: grid; gap: 6px; }
.field > span { font-size: var(--t-foot); font-weight: 600; color: var(--text-2); padding-left: 2px; }

.input {
  width: 100%;
  min-height: 48px;
  padding: 0 var(--s4);
  border-radius: var(--r-md);
  border: 1px solid var(--hairline);
  background: var(--card-2);
  color: var(--text);
  font-size: var(--t-body);
  font-family: var(--font);
  transition: border-color var(--fast) linear, background var(--fast) linear;
}
.input::placeholder { color: var(--text-3); }
.input:focus { outline: none; border-color: var(--blue); background: var(--card); }
select.input { appearance: none; padding-right: var(--s7); }
textarea.input { min-height: 90px; padding: var(--s3) var(--s4); }

.switch {
  --w: 50px;
  position: relative;
  width: var(--w); height: 30px;
  border-radius: var(--r-pill);
  background: var(--separator);
  transition: background var(--mid) var(--ease);
  flex: 0 0 auto;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0,0,0,.25);
  transition: transform var(--mid) var(--ease);
}
.switch[aria-checked="true"] { background: var(--green); }
.switch[aria-checked="true"]::after { transform: translateX(calc(var(--w) - 30px)); }

/* ------------------------------------------------------------------ avatar */

.avatar {
  position: relative;
  flex: 0 0 auto;
  width: var(--size, 40px);
  height: var(--size, 40px);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font-num);
  font-weight: 700;
  font-size: calc(var(--size, 40px) * .38);
  color: #fff;
  background: var(--tone, var(--blue));
  letter-spacing: -.02em;
}
/* Anillo degradado tipo Instagram para destacar */
.avatar--ring::before {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: var(--ig-gradient);
  z-index: -1;
}
.avatar--ring {
  box-shadow: 0 0 0 2.5px var(--card);
  z-index: 0;
}
.avatar--ring.on-bg { box-shadow: 0 0 0 2.5px var(--bg); }

.avatar__crown {
  position: absolute;
  top: -8px; right: -6px;
  font-size: .625rem;
  color: var(--yellow);
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.3));
}

/* ------------------------------------------------------------------ logos */

.logo {
  --size: 34px;
  width: var(--size);
  height: var(--size);
  flex: 0 0 auto;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--logo-halo);
  overflow: hidden;
}
.logo img { width: 100%; height: 100%; object-fit: contain; }
.logo__fallback {
  font-family: var(--font-num);
  font-size: calc(var(--size) * .34);
  font-weight: 800;
  letter-spacing: -.03em;
  color: #fff;
}

/* ------------------------------------------------------------------ partido */

.game {
  padding: var(--s3) var(--s3) var(--s3);
  border-bottom: 1px solid var(--hairline);
}
.game:last-child { border-bottom: 0; }

.game__meta {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: 0 var(--s1) var(--s2);
  font-size: var(--t-caption);
  color: var(--text-2);
}
.game__meta .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game__when { font-weight: 640; color: var(--text); }

.picker { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }

.pick {
  --team: var(--text-2);
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--s2);
  padding: var(--s3);
  min-height: 62px;
  border-radius: var(--r-md);
  background: var(--card-2);
  border: 1.5px solid transparent;
  text-align: left;
  transition: transform var(--fast) var(--ease), background var(--fast) linear,
              border-color var(--fast) linear;
}
.pick:active:not([disabled]) { transform: scale(.97); }
.pick__abbr {
  font-family: var(--font-num);
  font-size: var(--t-callout);
  font-weight: 720;
  letter-spacing: -.02em;
  line-height: 1.1;
}
.pick__name {
  font-size: var(--t-micro);
  color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pick__score {
  font-family: var(--font-num);
  font-size: var(--t-title3);
  font-weight: 760;
  letter-spacing: -.03em;
  margin-left: auto;
  padding-left: var(--s2);
}

.pick[aria-pressed="true"] {
  border-color: var(--team);
  background:
    linear-gradient(0deg, color-mix(in srgb, var(--team) 13%, transparent),
                          color-mix(in srgb, var(--team) 13%, transparent)),
    var(--card-2);
}
.pick[aria-pressed="true"] .pick__abbr { color: var(--team); }

.pick__badge {
  position: absolute;
  top: -6px; right: -4px;
  width: 20px; height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: .5625rem;
  color: #fff;
  background: var(--team);
  box-shadow: 0 0 0 2px var(--card);
  animation: pop var(--mid) var(--spring) both;
}
.pick__badge--hit  { background: var(--green); }
.pick__badge--miss { background: var(--red); }

.pick[disabled] { cursor: default; }
.pick--dim { opacity: .5; }
.pick--won  { border-color: var(--green); background: var(--tint-green); }
.pick--lost { opacity: .62; }

.game__strip {
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin-top: var(--s2);
  padding: 7px var(--s3);
  border-radius: var(--r-sm);
  background: var(--card-sunken);
  font-size: var(--t-caption);
  color: var(--text-2);
}
.game__strip i { color: var(--text-3); }
.game__strip b { color: var(--text); font-weight: 640; }

/* ------------------------------------------------------------------ riel de historias */

.rail {
  display: flex;
  gap: var(--s4);
  overflow-x: auto;
  scrollbar-width: none;
  padding: var(--s2) var(--s4) var(--s4);
}
.rail::-webkit-scrollbar { display: none; }
.rail__item {
  flex: 0 0 auto;
  width: 66px;
  display: grid;
  justify-items: center;
  gap: 6px;
  transition: transform var(--fast) var(--ease);
}
.rail__item:active { transform: scale(.94); }
.rail__item span {
  font-size: var(--t-micro);
  color: var(--text-2);
  max-width: 66px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rail__item b {
  font-family: var(--font-num);
  font-size: var(--t-foot);
  font-weight: 700;
}

/* ------------------------------------------------------------------ grafica de barras */

.bars {
  display: flex;
  align-items: stretch;
  gap: 5px;
  height: 108px;
  padding-top: var(--s3);
}
.bars__col {
  flex: 1 1 0;
  min-width: 6px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
/* La pista da la altura definida contra la que se resuelve el porcentaje. */
.bars__track {
  position: relative;
  flex: 1 1 auto;
  border-radius: 5px;
  background: var(--card-sunken);
  overflow: hidden;
}
.bars__fill {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  border-radius: 5px 5px 0 0;
  background: var(--ig-gradient);
  min-height: 3px;
  transition: height var(--slow) var(--ease);
}
.bars__fill--flat { background: var(--separator); }
.bars__x {
  font-size: var(--t-micro);
  color: var(--text-3);
  text-align: center;
  flex: 0 0 auto;
}
.bars__value {
  font-family: var(--font-num);
  font-size: var(--t-micro);
  font-weight: 700;
  text-align: center;
  color: var(--text-2);
  flex: 0 0 auto;
}

/* ------------------------------------------------------------------ medidor */

.meter {
  height: 8px;
  border-radius: var(--r-pill);
  background: var(--card-sunken);
  overflow: hidden;
}
.meter__fill {
  height: 100%;
  border-radius: var(--r-pill);
  background: var(--tone, var(--blue));
  transition: width var(--slow) var(--ease);
}

/* ------------------------------------------------------------------ matriz de revelacion */

.matrix-wrap {
  overflow-x: auto;
  border-radius: var(--r-lg);
  border: 1px solid var(--hairline);
  background: var(--card);
  -webkit-overflow-scrolling: touch;
}
.matrix { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; }
.matrix th, .matrix td {
  padding: var(--s2) 10px;
  font-size: var(--t-caption);
  text-align: center;
  border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
}
.matrix thead th {
  position: sticky; top: 0;
  background: var(--card-2);
  font-weight: 640;
  z-index: 2;
}
.matrix .sticky-col {
  position: sticky;
  left: 0;
  background: var(--card);
  text-align: left;
  z-index: 1;
  border-right: 1px solid var(--hairline);
  min-width: 116px;
}
.matrix thead .sticky-col { background: var(--card-2); z-index: 3; }
.matrix tbody tr:last-child th, .matrix tbody tr:last-child td { border-bottom: 0; }

.cell {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: var(--r-pill);
  font-family: var(--font-num);
  font-weight: 700;
  font-size: var(--t-micro);
}
.cell--hit  { background: var(--tint-green); color: var(--green); }
.cell--miss { background: var(--tint-red);   color: var(--red); }
.cell--void { background: var(--card-2);     color: var(--text-2); }
.cell--none { color: var(--text-3); }

/* ------------------------------------------------------------------ hoja inferior */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0,0,0,.45);
  animation: fade var(--fast) linear both;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 61;
  max-width: var(--shell-max);
  margin-inline: auto;
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-sheet);
  padding-bottom: var(--safe-bottom);
  animation: sheet-up var(--mid) var(--ease) both;
}
@keyframes sheet-up {
  from { transform: translateY(100%); }
  to   { transform: none; }
}
.sheet--closing { animation: sheet-down var(--fast) var(--ease) both; }
@keyframes sheet-down {
  from { transform: none; }
  to   { transform: translateY(100%); }
}
.sheet__grip {
  width: 38px; height: 5px;
  border-radius: var(--r-pill);
  background: var(--separator);
  margin: var(--s2) auto var(--s1);
  flex: 0 0 auto;
}
.sheet__head {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s2) var(--s4) var(--s3);
  flex: 0 0 auto;
}
.sheet__head h2 { font-size: var(--t-title3); font-weight: 700; letter-spacing: -.02em; flex: 1; }
.sheet__body { overflow-y: auto; padding: 0 var(--s4) var(--s5); -webkit-overflow-scrolling: touch; }

/* ------------------------------------------------------------------ toast */

.toasts {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(var(--tab-h) + var(--safe-bottom) + var(--s3));
  z-index: 80;
  display: grid;
  gap: var(--s2);
  justify-items: center;
  padding-inline: var(--s4);
  pointer-events: none;
}
.toast {
  max-width: 100%;
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: 11px var(--s4);
  border-radius: var(--r-pill);
  background: rgba(28,28,30,.94);
  color: #fff;
  font-size: var(--t-sub);
  font-weight: 560;
  box-shadow: var(--shadow-float);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: rise var(--mid) var(--spring) both;
}
.toast--out { animation: fade var(--fast) linear reverse both; }
.toast--ok i   { color: var(--green); }
.toast--err i  { color: #FF6B6B; }
.toast--info i { color: #6FB2FF; }

/* ------------------------------------------------------------------ esqueletos */

.skel {
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--card-2) 25%, var(--card-sunken) 37%, var(--card-2) 63%);
  background-size: 300% 100%;
  animation: shimmer 1.3s linear infinite;
}
.skel--line { height: 12px; }
.skel--game { height: 104px; border-radius: var(--r-md); }
.skel--row  { height: 56px; border-radius: var(--r-md); }

/* ------------------------------------------------------------------ vacio */

.empty {
  display: grid;
  justify-items: center;
  gap: var(--s3);
  padding: var(--s7) var(--s5);
  text-align: center;
}
.empty__icon {
  width: 62px; height: 62px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 1.5rem;
  color: var(--text-2);
  background: var(--card-2);
}
.empty h3 { font-size: var(--t-title3); font-weight: 700; letter-spacing: -.02em; }
.empty p { font-size: var(--t-sub); color: var(--text-2); max-width: 34ch; line-height: 1.45; }
