/* Tournaments panel (js/tournament.js): upcoming cups, live brackets, champions, prizes, GM host form.
   Load after panels.css + social.css (reuses .btn, .tabs, .sec, .empty, .spin, .sp-loading, .tier). Mobile-first. */

.tourney .tn-body { display: flex; flex-direction: column; gap: 0; }
.tn-body > * { flex: none; }
.tn-center { display: flex; justify-content: center; }
.tn-big { min-height: 44px; padding: 8px 14px; font-size: 14.5px; gap: 6px; }
.tn-big .ic { width: 18px; height: 18px; }
.tn-note { margin: 10px 2px 0; font-size: 12.5px; font-weight: 700; color: var(--muted); line-height: 1.45; }
.tn-back span { display: inline; }

/* avatars, pills, chips */
.tn-ava { --h: 210; --sz: 28px; width: var(--sz); height: var(--sz); flex: none; display: grid; place-items: center; border-radius: 50%;
  font-weight: 900; font-size: calc(var(--sz) * .44); color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.35);
  background: linear-gradient(140deg, hsl(var(--h) 70% 62%), hsl(calc(var(--h) + 40) 60% 38%)); box-shadow: inset 0 1px 0 rgba(255,255,255,.3); }
.tn-pill { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 10px; border-radius: 999px; flex: none; white-space: nowrap;
  font-size: 11px; font-weight: 900; letter-spacing: .4px; text-transform: uppercase; background: rgba(255,255,255,.1); color: #fff; border: 1px solid var(--line-2); }
.tn-pill.in { background: rgba(62, 224, 122, .16); border-color: rgba(62, 224, 122, .5); color: #9ff5bf; }
.tn-pill.out { color: var(--muted); }
.tn-pill.st-running { background: rgba(255, 95, 107, .18); border-color: rgba(255, 95, 107, .6); color: #ffc2c7; }
.tn-pill.st-finished { background: rgba(255, 207, 74, .18); border-color: rgba(255, 207, 74, .6); color: var(--gold); }
.tn-pill.st-cancelled { opacity: .7; }
.tn-live-dot { width: 8px; height: 8px; border-radius: 50%; background: #ff5f6b; display: inline-block; flex: none; box-shadow: 0 0 0 0 rgba(255,95,107,.6); animation: tn-live 1.6s ease-out infinite; margin-right: 2px; }
@keyframes tn-live { 0% { box-shadow: 0 0 0 0 rgba(255,95,107,.6); } 80%, 100% { box-shadow: 0 0 0 7px rgba(255,95,107,0); } }
.tn-prize { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.tn-prize-text { display: inline-flex; align-items: center; gap: 6px; width: 100%; font-size: 13px; font-weight: 800; color: #ffe9a8; }
.tn-prize-text .ic { width: 16px; height: 16px; color: var(--gold); flex: none; }
.tn-chip { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 9px; border-radius: 9px; font-size: 12.5px; background: rgba(0,0,0,.25); border: 1px solid var(--line); color: #fff; max-width: 100%; }
.tn-chip b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tn-chip .ic { width: 15px; height: 15px; flex: none; color: var(--accent-2); }
.tn-chip.dia { color: #bfe3ff; border-color: rgba(120, 190, 255, .4); }
.tn-chip.title { color: #f3c9ff; border-color: rgba(220, 150, 255, .4); }
.tn-chip.title .ic { color: #e4a8ff; }
.tn-dia { width: 15px; height: 15px; flex: none; fill: #8fd0ff; stroke: #2a64c8; stroke-width: 1.4; stroke-linejoin: round; vertical-align: -2px; }
.tn-crown { width: 18px; height: 18px; flex: none; fill: var(--gold); stroke: #9a5a00; stroke-width: 1.2; stroke-linejoin: round; filter: drop-shadow(0 1px 2px rgba(0,0,0,.4)); }
.tn-cd { font-variant-numeric: tabular-nums; font-weight: 900; color: #fff; }
.tn-cd.soon { color: var(--gold); }

/* calls to action: ready match / prize */
.tn-cta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; padding: 12px; margin-bottom: 10px; border-radius: 16px;
  background: linear-gradient(135deg, rgba(76, 141, 255, .25), rgba(76, 141, 255, .08)); border: 1px solid rgba(122, 168, 255, .5); }
.tn-cta.ready { background: linear-gradient(135deg, rgba(255, 95, 107, .32), rgba(255, 140, 60, .12)); border-color: rgba(255, 140, 120, .7);
  box-shadow: 0 0 0 0 rgba(255, 120, 100, .5); animation: tn-call 2.2s ease-out infinite; }
.tn-cta.prize { background: linear-gradient(135deg, rgba(255, 207, 74, .3), rgba(243, 165, 30, .1)); border-color: rgba(255, 207, 74, .75); }
.tn-cta.wait { background: var(--surface); border-color: var(--line); }
@keyframes tn-call { 0% { box-shadow: 0 0 0 0 rgba(255, 120, 100, .45); } 70%, 100% { box-shadow: 0 0 0 10px rgba(255, 120, 100, 0); } }
.tn-cta-ic { width: 42px; height: 42px; flex: none; display: grid; place-items: center; border-radius: 13px; background: rgba(0,0,0,.25); color: #fff; }
.tn-cta-ic .ic, .tn-cta-ic .tn-crown { width: 26px; height: 26px; }
.tn-cta-text { flex: 1 1 180px; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.tn-cta-text b { font-size: 15px; line-height: 1.25; }
.tn-cta-text small { font-size: 12.5px; font-weight: 700; color: #d4def5; display: block; }
.tn-cta-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; flex: 1 1 100%; }
.tn-cta-acts .btn { flex: 1 1 130px; }
.tn-cta.prize .btn { flex: none; margin-left: auto; }
.tn-checked { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 900; color: #9ff5bf; padding: 0 6px; }
.tn-checked .ic { width: 16px; height: 16px; }
.tn-on { font-weight: 900; color: var(--muted); }
.tn-on.on { color: #8cf0b0; }
@media (min-width: 640px) { .tn-cta-acts { flex: none; } .tn-cta-acts .btn { flex: none; } }

/* tabs + list cards */
.tn-tabs { margin: 4px 0 12px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.tn-tabs::-webkit-scrollbar { display: none; }
.tn-tabs .tab { flex: none; min-height: 44px; }
.tn-list { display: flex; flex-direction: column; gap: 10px; }
.tn-card { padding: 12px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); }
.tn-card.mine { border-color: rgba(62, 224, 122, .35); }
.tn-card.live { background: linear-gradient(160deg, rgba(255, 95, 107, .1), var(--surface) 55%); }
.tn-card-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tn-emb .ic-tile { width: 44px; height: 44px; display: block; }
.tn-card-title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tn-card-title b { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tn-card-title small { font-size: 12.5px; font-weight: 700; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px; }
.tn-fill { position: relative; height: 26px; margin-top: 10px; border-radius: 9px; overflow: hidden; background: rgba(0,0,0,.3); border: 1px solid var(--line); }
.tn-fill i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #4c8dff, #7aa8ff); transition: width .4s var(--ease, ease); }
.tn-fill span { position: relative; display: block; text-align: center; line-height: 24px; font-size: 12px; font-weight: 900; text-shadow: 0 1px 2px rgba(0,0,0,.5); }
.tn-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.tn-acts .btn { flex: 1 1 120px; }

/* champions hall */
.tn-hall { display: flex; flex-direction: column; gap: 8px; }
.tn-champ { position: relative; display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 12px; border-radius: 16px; min-height: 64px;
  background: linear-gradient(120deg, rgba(255, 207, 74, .16), var(--surface) 60%); border: 1px solid rgba(255, 207, 74, .3); }
.tn-champ.cancelled { background: var(--surface); border-color: var(--line); opacity: .7; }
.tn-champ-crown { position: absolute; left: 34px; top: 2px; transform: rotate(-14deg); }
.tn-champ-crown .tn-crown { width: 20px; height: 20px; }
.tn-champ-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tn-champ-text > b { font-size: 16px; color: var(--gold); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tn-champ-text small { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.tn-champ-text small b { color: #fff; }
.tn-champ-go { width: 44px; min-height: 44px; padding: 0; flex: none; }

/* detail hero */
.tn-hero { padding: 14px; border-radius: 18px; margin-bottom: 10px; background: radial-gradient(120% 140% at 0% 0%, rgba(255, 207, 74, .22), transparent 55%),
  linear-gradient(160deg, rgba(76, 141, 255, .28), rgba(20, 30, 70, .5)); border: 1px solid var(--line-2); }
.tn-hero.running { background: radial-gradient(120% 140% at 0% 0%, rgba(255, 95, 107, .25), transparent 55%), linear-gradient(160deg, rgba(76, 141, 255, .22), rgba(20, 30, 70, .5)); }
.tn-hero-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.tn-hero-top small { font-size: 12.5px; font-weight: 800; color: #d4def5; }
.tn-hero-cd { display: flex; flex-direction: column; margin-top: 10px; }
.tn-hero-cd .tn-cd { font-size: 26px; line-height: 1.1; }
.tn-hero-cd small { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.tn-hero-champ { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.tn-hero-champ .tn-crown { width: 30px; height: 30px; }
.tn-hero-champ div { display: flex; flex-direction: column; }
.tn-hero-champ small { font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.tn-hero-champ b { font-size: 20px; color: var(--gold); }

/* registered players */
.tn-plist { display: flex; flex-direction: column; gap: 6px; }
.tn-prow { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 6px 10px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.tn-prow.me { border-color: rgba(255, 207, 74, .5); }
.tn-prow .tn-nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tn-pnum { width: 22px; text-align: right; font-size: 12px; font-weight: 900; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- bracket */
.tn-bh { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.tn-you { color: var(--gold); text-transform: none; letter-spacing: 0; }
.tn-rchips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px 0 8px; }
.tn-rchips::-webkit-scrollbar { display: none; }
.tn-rchip { flex: none; min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); color: var(--muted); font: inherit; font-size: 12.5px; font-weight: 900; cursor: pointer; }
.tn-rchip.on { background: #fff; color: #13204a; border-color: #fff; }
html.touch .tn-rchip { min-height: 44px; }
.tn-bracket { overflow-x: auto; overflow-y: hidden; margin: 0 -16px; padding: 0 16px 10px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
.tn-bracket:focus-visible { outline: 2px solid var(--accent-2); outline-offset: -2px; border-radius: 12px; }
.tn-cols { --cw: 172px; --gap: 14px; --sh: 100px; display: flex; width: max-content; }
.tn-col { width: var(--cw); flex: none; display: flex; flex-direction: column; scroll-snap-align: start; scroll-margin-left: 8px; }
.tn-col-h { height: 26px; margin: 0 var(--gap) 6px; display: flex; align-items: center; font-size: 11px; font-weight: 900; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.tn-col.current .tn-col-h { color: #fff; }
.tn-col.current .tn-col-h::before { content: ''; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #ff5f6b; }
.tn-col.final .tn-col-h { color: var(--gold); }
.tn-col-b { display: flex; flex-direction: column; height: calc(var(--rows) * var(--sh)); }
.tn-slot { position: relative; flex: 1 1 0; display: flex; align-items: center; padding: 0 var(--gap); min-height: 0; }
/* connectors: each pair of matches joins into the next round's match */
.tn-slot::after, .tn-slot::before { content: ''; position: absolute; border-color: rgba(170, 195, 255, .28); border-style: solid; border-width: 0; pointer-events: none; }
.tn-col:not(.final):not(.champ) .tn-slot.even::after { right: 0; width: var(--gap); top: 50%; height: 50%; border-top-width: 2px; border-right-width: 2px; border-top-right-radius: 8px; }
.tn-col:not(.final):not(.champ) .tn-slot.odd::after { right: 0; width: var(--gap); bottom: 50%; height: 50%; border-bottom-width: 2px; border-right-width: 2px; border-bottom-right-radius: 8px; }
.tn-cols.has-champ .tn-col.final .tn-slot::after { right: 0; width: var(--gap); top: 50%; border-top-width: 2px; }
.tn-col + .tn-col .tn-slot::before { left: 0; width: var(--gap); top: 50%; border-top-width: 2px; }
.tn-slot.path::after { border-color: var(--gold) !important; z-index: 1; }
.tn-slot.mine::before { border-color: var(--gold); }

.tn-m { position: relative; width: 100%; display: flex; flex-direction: column; border-radius: 12px; background: rgba(16, 26, 60, .92); border: 1px solid var(--line-2); overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.tn-m.ready { border-color: rgba(255, 140, 120, .55); }
.tn-m.bye { opacity: .6; }
.tn-m.mine { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(255, 207, 74, .4), 0 2px 10px rgba(255, 207, 74, .2); }
.tn-m.me-next { animation: tn-glow 2s ease-in-out infinite; }
@keyframes tn-glow { 50% { box-shadow: 0 0 0 3px rgba(255, 207, 74, .45), 0 0 18px rgba(255, 207, 74, .35); } }
.tn-side { display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 8px 0 0; font-size: 13px; font-weight: 800; min-width: 0; }
.tn-side + .tn-side { border-top: 1px solid var(--line); }
.tn-seed { width: 22px; height: 100%; flex: none; display: grid; place-items: center; font-size: 10.5px; font-weight: 900; color: var(--muted); background: rgba(0,0,0,.25); font-variant-numeric: tabular-nums; }
.tn-side .tn-nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tn-side.tbd .tn-nm { color: rgba(163, 179, 217, .55); font-style: italic; font-weight: 700; }
.tn-side.won { background: linear-gradient(90deg, rgba(62, 224, 122, .16), transparent); }
.tn-side.won .tn-nm { color: #fff; font-weight: 900; }
.tn-side.lost .tn-nm { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(163, 179, 217, .5); }
.tn-side.me .tn-nm { color: var(--gold); }
.tn-side.me .tn-seed { background: rgba(255, 207, 74, .25); color: var(--gold); }
.tn-w { display: grid; place-items: center; width: 18px; flex: none; color: var(--ok); }
.tn-w .ic { width: 16px; height: 16px; }
.tn-w .tn-crown { width: 16px; height: 16px; }
.tn-ci { display: grid; place-items: center; color: #9ff5bf; }
.tn-ci .ic { width: 14px; height: 14px; }
.tn-dot { width: 8px; height: 8px; border-radius: 50%; background: #66708c; flex: none; }
.tn-dot.on { background: var(--ok); }
.tn-tag { display: block; padding: 3px 8px; font-size: 10.5px; font-weight: 900; letter-spacing: .3px; text-transform: uppercase; color: var(--muted); background: rgba(0,0,0,.25); border-top: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tn-tag.ready { color: #ffc2b8; }
.tn-tag .tn-cd { color: inherit; }
.tn-gm { display: flex; flex-direction: column; gap: 4px; padding: 6px; border-top: 1px solid var(--line); background: rgba(0,0,0,.2); }
.tn-gm .btn { min-height: 40px; width: 100%; justify-content: flex-start; font-size: 12px; gap: 4px; }
.tn-gm .btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tn-gm .btn .ic { width: 14px; height: 14px; flex: none; }
.tn-m.champion { flex-direction: row; align-items: center; justify-content: center; gap: 8px; min-height: 64px; padding: 8px; font-size: 15px;
  background: linear-gradient(135deg, rgba(255, 207, 74, .35), rgba(243, 165, 30, .15)); border-color: var(--gold); }
.tn-m.champion b { color: var(--gold); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tn-m.champion .tn-crown { width: 24px; height: 24px; }

/* GM host form */
.tn-form { display: flex; flex-direction: column; gap: 12px; }
.tn-form .sec { margin-top: 4px; }
.tn-grid2 { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 560px) { .tn-grid2 { grid-template-columns: 1fr 1fr; } }
.tn-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.tn-field > span { font-size: 12px; font-weight: 900; letter-spacing: .3px; color: var(--muted); }
.tn-field input, .tn-field select { width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line-2); background: rgba(0,0,0,.3);
  color: #fff; font: inherit; font-size: 15px; font-weight: 700; color-scheme: dark; }
.tn-field input:disabled { opacity: .6; }
.tn-field input:focus, .tn-field select:focus { border-color: var(--accent-2); outline: none; }
.tn-form-foot { display: flex; justify-content: flex-end; }
.tn-form-foot .btn { width: 100%; }
@media (min-width: 560px) { .tn-form-foot .btn { width: auto; min-width: 240px; } }

/* wider screens: roomier bracket */
@media (min-width: 720px) { .tn-cols { --cw: 200px; --gap: 18px; } .tn-side { height: 34px; font-size: 13.5px; } }
/* phone landscape: short, wide — keep the bracket compact */
@media (max-height: 500px) { .tn-hero { padding: 10px 12px; } .tn-hero-cd .tn-cd { font-size: 20px; } .tn-cols { --sh: 88px; } .tn-side { height: 28px; } }

/* motion */
@media (prefers-reduced-motion: reduce) { .tn-cta.ready, .tn-m.me-next, .tn-live-dot { animation: none; } }
html.reduce-motion .tn-cta.ready, html.reduce-motion .tn-m.me-next, html.reduce-motion .tn-live-dot { animation: none !important; }
html.reduce-motion .tn-fill i { transition: none; }
/* narrow phones: three tabs share the row (Host scrolls in for GMs) */
@media (max-width: 440px) { .tn-tabs .tab { flex: 1 0 auto; padding-left: 10px; padding-right: 10px; gap: 5px; } .tn-tabs .tab .ic { display: none; } }
