/* Torneo histórico. Usa el mismo escenario oscuro de la pantalla del Draft. */

.screen-torneo, .screen-torneo-historial { min-height: 100dvh; }
.tn { width: 100%; max-width: 1240px; margin: 0 auto; padding: .4rem clamp(1rem, 3vw, 2rem) 3rem; display: flex; flex-direction: column; gap: 1.1rem; }
.tn-card {
  background: linear-gradient(180deg, rgba(20, 32, 26, .82), rgba(10, 17, 14, .82)); border: 1px solid rgba(var(--neon-rgb), .18);
  border-radius: 18px; padding: clamp(1rem, 2.4vw, 1.6rem); box-shadow: 0 20px 40px rgba(0, 0, 0, .3);
}
.tn-card h2 { font: 700 clamp(1.4rem, 2.6vw, 1.9rem)/1.1 var(--ui, var(--body)); letter-spacing: -.02em; margin-bottom: .4rem; }
.tn-card h3 { font: 700 1.05rem var(--ui, var(--body)); margin-bottom: .6rem; }
.tn-hero { max-width: 760px; }
.tn-hero p { margin-top: .3rem; line-height: 1.5; }
.tn-actions { display: flex; flex-wrap: wrap; gap: .7rem; justify-content: flex-end; align-items: center; }
.tn-warn { color: #F0C44C; }
.tn-pick { max-width: 600px; }
.tn-k { font-size: .82rem; color: var(--stand); }

/* Escudos */
.crest { position: relative; display: inline-grid; place-items: center; flex: none; border-radius: 12px; }
.crest img { width: 100%; height: 100%; object-fit: contain; position: absolute; inset: 0; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .45)); }
.crest-fb { width: 86%; height: 86%; display: grid; place-items: center; clip-path: polygon(50% 0, 100% 14%, 92% 72%, 50% 100%, 8% 72%, 0 14%); }
.crest-fb b { font: 800 calc(var(--cs) * .32)/1 var(--ui, var(--body)); }
.crest-sm { --cs: 30px; width: 30px; height: 30px; }
.crest-md { --cs: 52px; width: 52px; height: 52px; }
.crest-lg { --cs: 74px; width: 74px; height: 74px; }
.crest-xl { --cs: 150px; width: 150px; height: 150px; }
.crest-user img { padding: 8%; }
.crest-user { background: radial-gradient(circle, rgba(var(--neon-rgb), .25), transparent 70%); }
.crest-empty { border: 1px dashed var(--line-2); border-radius: 50%; }

/* Sorteo */
.tn-draw { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .6rem; margin-top: .8rem; }
.tn-draw-team { display: flex; align-items: center; gap: .6rem; padding: .55rem .7rem; border-radius: 12px; background: rgba(255, 255, 255, .04); border: 1px solid var(--line); font-weight: 600; font-size: .92rem;
  animation: tn-in .4s var(--ease) both; animation-delay: calc(var(--i) * 90ms); }
.tn-reveal { animation: tn-in .5s var(--ease) both; animation-delay: calc(var(--i) * 90ms); }
@keyframes tn-in { from { opacity: 0; transform: translateY(10px) scale(.97); } }

/* Partidos (fila de dos equipos) */
.tn-mrow { display: grid; gap: 2px; }
.tn-side { display: flex; align-items: center; gap: .5rem; padding: .35rem .55rem; border-radius: 8px; background: rgba(255, 255, 255, .03); min-width: 0; }
.tn-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .88rem; font-weight: 600; }
.tn-score { font-variant-numeric: tabular-nums; font-size: .95rem; }
.tn-side.won { background: rgba(var(--neon-rgb), .1); }
.tn-side.won .tn-name { color: #fff; }
.tn-side.lost { opacity: .45; }
.tn-side.lost .tn-name { text-decoration: line-through; text-decoration-color: rgba(255, 255, 255, .35); }
.tn-side.is-user { box-shadow: inset 3px 0 0 var(--neon); background: rgba(var(--neon-rgb), .14); }
.tn-side.is-user .tn-name { color: var(--neon); }

/* Cuadro */
.tn-next { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 1.4rem; justify-content: space-between; }
.tn-next-row { display: flex; align-items: center; gap: .8rem; flex: 1; min-width: 220px; }
.tn-next-row b { display: block; font-size: 1.25rem; }
.tn-next .tn-k { width: 100%; }
.tn-bracket { display: grid; grid-template-columns: repeat(5, minmax(200px, 1fr)); gap: .9rem; overflow-x: auto; padding-bottom: .6rem; scroll-snap-type: x mandatory; }
.tn-col { display: flex; flex-direction: column; justify-content: space-around; gap: .6rem; scroll-snap-align: start; }
.tn-col h3 { font: 700 .82rem var(--ui, var(--body)); color: var(--stand); text-align: center; letter-spacing: .02em; }
.tn-col-prelim { justify-content: flex-start; }
.tn-match { padding: .3rem; border-radius: 12px; background: rgba(10, 17, 14, .85); border: 1px solid var(--line); }
.tn-match.on-path { border-color: rgba(var(--neon-rgb), .55); box-shadow: 0 0 0 1px rgba(var(--neon-rgb), .25), 0 0 18px rgba(var(--neon-rgb), .12); }
.tn-col-final .tn-match { border-color: #E9B949; }

/* Partido: los dos equipos */
.tn-vs { display: grid; grid-template-columns: 1fr auto 1fr; gap: 1rem; align-items: start; }
.tn-vs-mid { align-self: center; display: flex; flex-direction: column; align-items: center; gap: .3rem; }
.tn-vs-mid b { font: 800 2rem var(--ui, var(--body)); color: var(--neon); text-shadow: 0 0 18px rgba(var(--neon-rgb), .5); }
.tn-team { padding: 1.1rem; border-radius: 18px; background: linear-gradient(180deg, rgba(20, 32, 26, .85), rgba(10, 17, 14, .85)); border: 1px solid var(--line); display: flex; flex-direction: column; gap: .8rem; }
.tn-team.is-user { border-color: rgba(var(--neon-rgb), .5); }
.tn-team-head { display: flex; gap: .8rem; align-items: center; }
.tn-team-head h2 { font: 700 1.3rem/1.15 var(--ui, var(--body)); }
.tn-ovr { display: flex; align-items: baseline; gap: .35rem .5rem; flex-wrap: wrap; }
.tn-ovr b { font: 800 1.6rem var(--ui, var(--body)); }
.tn-ovr span { color: var(--stand); font-size: .8rem; margin-right: .6rem; }
.tn-ovr em { font-style: normal; font-size: .8rem; padding: .15rem .55rem; border-radius: 999px; border: 1px solid var(--line-2); }
.tn-bars { display: grid; gap: .4rem; }
.tn-bar { display: grid; grid-template-columns: 2.6rem 1fr 2rem; align-items: center; gap: .5rem; font-size: .8rem; }
.tn-bar span { color: var(--stand); font-weight: 600; }
.tn-bar > i { height: 7px; border-radius: 4px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.tn-bar > i > i { display: block; height: 100%; background: linear-gradient(90deg, #1FA14C, var(--neon)); }
.tn-bar b { text-align: right; font-variant-numeric: tabular-nums; }
.tn-squad summary { cursor: pointer; font-weight: 600; font-size: .9rem; }
.tn-squad ol { list-style: none; margin: .5rem 0; display: grid; gap: .2rem; font-size: .85rem; }
.tn-squad li { display: grid; grid-template-columns: 2.6rem 1fr auto; gap: .5rem; }
.tn-pos { color: var(--stand); font-weight: 700; }
.tn-squad a { color: inherit; }
.tn-switch { display: inline-flex; align-items: center; gap: .55rem; margin-right: auto; font-weight: 600; cursor: pointer; }

/* Resultado */
.tn-result { border-radius: 22px; padding: clamp(1rem, 3vw, 2rem); background: linear-gradient(180deg, rgba(20, 32, 26, .9), rgba(8, 14, 11, .9)); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 1.2rem; }
.tn-result.is-win { border-color: rgba(var(--neon-rgb), .6); box-shadow: 0 0 40px rgba(var(--neon-rgb), .12); }
.tn-result.is-loss { border-color: rgba(229, 83, 75, .45); }
.tn-result-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem; }
.tn-rteam { display: flex; flex-direction: column; align-items: center; gap: .5rem; text-align: center; }
.tn-rteam b { font-size: 1.05rem; }
.tn-score-big { display: flex; align-items: center; gap: .7rem; font: 800 clamp(2.6rem, 8vw, 4.4rem)/1 var(--ui, var(--body)); font-variant-numeric: tabular-nums; }
.tn-score-big span { color: var(--stand); }
.tn-pens { text-align: center; font-weight: 700; display: flex; flex-direction: column; align-items: center; gap: .4rem; }
.tn-kicks { display: grid; gap: .3rem; }
.tn-kicks > span { display: flex; gap: .3rem; justify-content: center; }
.tn-kicks i { width: 12px; height: 12px; border-radius: 50%; }
.tn-kicks i.ok { background: #5BE08C; }
.tn-kicks i.ko { background: #E5534B; }
.tn-scorers { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; font-size: .9rem; }
.tn-scorers > div { display: flex; flex-direction: column; gap: .15rem; }
.tn-scorers > div:first-child { align-items: flex-end; text-align: right; }
.tn-scorers > div:last-child { align-items: flex-start; }
.tn-stats { display: grid; gap: .55rem; max-width: 620px; width: 100%; margin: 0 auto; }
.tn-stat { display: grid; grid-template-columns: 3rem 1fr 3rem; align-items: center; gap: .7rem; }
.tn-stat > b { text-align: center; font-variant-numeric: tabular-nums; }
.tn-stat-mid { display: flex; flex-direction: column; gap: .25rem; align-items: center; font-size: .8rem; color: var(--stand); }
.tn-stat-mid > i { width: 100%; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.tn-stat-mid > i > i { display: block; height: 100%; background: var(--neon); }
.tn-verdict { text-align: center; font: 700 1.2rem var(--ui, var(--body)); }
.tn-verdict.ok { color: var(--neon); }
.tn-verdict.ko { color: #FF7A70; }
.tn-feed { list-style: none; display: grid; gap: .35rem; max-width: 620px; width: 100%; margin: 0 auto; }
.tn-line { display: grid; grid-template-columns: 2.6rem 1fr; gap: .5rem; padding: .45rem .7rem; border-radius: 10px; background: rgba(255, 255, 255, .04); animation: tn-in .35s var(--ease) both; font-size: .92rem; }
.tn-line span { color: var(--stand); font-variant-numeric: tabular-nums; }
.tn-line.goal { background: rgba(var(--neon-rgb), .12); font-weight: 700; }
.tn-line.end, .tn-line.pens { font-weight: 700; }

/* Campeón */
.tn-champ { position: relative; overflow: hidden; display: flex; flex-direction: column; align-items: center; gap: .8rem; text-align: center; padding: 2.4rem 1rem; border-radius: 24px;
  background: radial-gradient(500px 260px at 50% 30%, rgba(233, 185, 73, .2), transparent 70%), linear-gradient(180deg, rgba(20, 32, 26, .9), rgba(8, 14, 11, .9)); border: 1px solid rgba(233, 185, 73, .5); }
.tn-champ h2 { font: 800 clamp(1.8rem, 4vw, 2.8rem)/1.1 var(--ui, var(--body)); }
.tn-champ.is-user { border-color: var(--neon); }
.tn-confetti i { position: absolute; top: -10px; left: calc(var(--i) * 4.2%); width: 8px; height: 14px; background: hsl(calc(var(--i) * 37), 85%, 60%);
  animation: tn-fall 2.8s linear infinite; animation-delay: calc(var(--i) * -0.13s); opacity: .85; }
@keyframes tn-fall { to { transform: translateY(520px) rotate(540deg); } }
.tn-path { list-style: none; display: grid; gap: .35rem; }
.tn-path li { display: grid; grid-template-columns: 9rem 1fr auto; gap: .6rem; padding: .45rem .7rem; border-radius: 10px; background: rgba(255, 255, 255, .04); font-size: .9rem; }
.tn-path li.ok { box-shadow: inset 3px 0 0 var(--neon); }
.tn-path li.ko { box-shadow: inset 3px 0 0 #E5534B; }

/* Historial */
.tn-totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: .6rem; margin-top: .6rem; }
.tn-tot { padding: .7rem; border-radius: 12px; background: rgba(255, 255, 255, .04); display: flex; flex-direction: column; }
.tn-tot b { font: 800 1.5rem var(--ui, var(--body)); }
.tn-tot span { color: var(--stand); font-size: .8rem; }
.tn-hist-head { display: flex; flex-wrap: wrap; gap: .3rem .8rem; align-items: baseline; margin-bottom: .6rem; }
.tn-hist.is-champ { border-color: #E9B949; }

@media (max-width: 760px) {
  .tn-vs { grid-template-columns: 1fr; }
  .tn-vs-mid { flex-direction: row; justify-content: center; }
  .tn-bracket { grid-template-columns: repeat(5, 78vw); }
  .tn-path li { grid-template-columns: 1fr auto; }
  .tn-path li span:first-child { grid-column: 1 / -1; color: var(--stand); font-size: .78rem; }
  .crest-lg { --cs: 56px; width: 56px; height: 56px; }
  .crest-xl { --cs: 110px; width: 110px; height: 110px; }
  .tn-actions { justify-content: stretch; }
  .tn-actions .btn { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .tn-draw-team, .tn-reveal, .tn-line, .tn-confetti i { animation: none; }
}

/* Escudo oscuro sobre fondo oscuro: lleva una placa clara. */
.crest-plate::before { content: ''; position: absolute; inset: 4%; border-radius: 50%; background: #F4F6F2; box-shadow: 0 4px 10px rgba(0, 0, 0, .35); }
.crest-plate img { padding: 16%; filter: none; }

/* Las pantallas de estadio (Draft en juego y Torneo) son oscuras también con el tema claro. */
:root[data-theme="light"] .screen-draft-play {
  color-scheme: dark; color: #E6EBE9;
  --night: #12181C; --night-2: #182026; --panel: #1A2228; --panel-2: #212A31;
  --line: rgba(226, 233, 230, .07); --line-2: rgba(226, 233, 230, .13);
  --chalk: #E6EBE9; --stand: #8A9792; --grass: #2E8A58; --grass-hi: #48B47A; --gold: #7FD99A; --gold-rgb: 127, 217, 154;
}
:root[data-theme="light"] .screen-draft-play .topbar { background: transparent; }
:root[data-theme="light"] .screen-draft-play .btn.ghost { background: rgba(255, 255, 255, .04); border-color: var(--line-2); color: var(--chalk); }
:root[data-theme="light"] .screen-draft-play .dbench .dslot-empty { background: rgba(255, 255, 255, .05); border-color: rgba(255, 255, 255, .35); color: var(--chalk); }
:root[data-theme="light"] .screen-draft-play .seg-btn { background: var(--night-2); color: var(--chalk); }
:root[data-theme="light"] .screen-draft-play .seg-btn.on { background: var(--grass); color: #F4FBF7; }
