/* Public tournament pages (/tournaments*, views/pages/tournaments.ts). Loaded after ranks.css (hero, tabs, chips, .lb
   tables, pager); tokens from chrome.css. The bracket: a grid of round columns with connector lines on desktop, a stack
   of rounds on phones (720 px and below). No inline styles (CSP style-src 'self'). */

.tr { display: grid; gap: 22px; }
.tr > * { min-width: 0; }
.rk-more { margin: 14px 0 0; font-size: .92rem; }
.rk-more a { color: var(--aet-amber-soft); font-weight: 600; text-decoration: none; }
.rk-more a:hover { text-decoration: underline; }
.tr-small { font-size: .85rem; }
.tr-h2 { margin: 0 0 12px; font: 700 1.15rem/1.25 var(--aet-font-display); color: #fff; letter-spacing: .02em; }
.tr-h2 .muted { font: 500 .85rem/1 var(--aet-font); margin-left: 6px; }
.tr-h3 { margin: 0 0 8px; font: 600 .72rem/1 var(--aet-font); letter-spacing: .14em; text-transform: uppercase; color: var(--aet-faint); }
.tr-intro { margin: 0; max-width: 72ch; }

/* ---------- status pills ---------- */
.tr-status { display: inline-flex; align-items: center; gap: 7px; height: 26px; padding: 0 11px; border-radius: 99px; white-space: nowrap;
  font: 700 .68rem/1 var(--aet-font); letter-spacing: .1em; text-transform: uppercase; color: var(--aet-muted);
  background: rgba(11, 13, 26, .7); border: 1px solid var(--aet-border-strong); }
.tr-status--registration { color: var(--aet-ok); border-color: rgba(74, 222, 128, .45); }
.tr-status--preparing { color: var(--aet-warn); border-color: rgba(251, 191, 36, .45); }
.tr-status--running { color: #fff; border-color: var(--aet-red); background: rgba(229, 72, 77, .18); }
.tr-status--paused { color: var(--aet-warn); }
.tr-status--completed { color: var(--aet-rune-soft); border-color: rgba(167, 139, 250, .45); }
.tr-status--cancelled { color: var(--aet-bad); border-color: rgba(248, 113, 113, .4); }
.tr-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--aet-red); box-shadow: 0 0 0 0 rgba(229, 72, 77, .6); animation: tr-pulse 1.6s infinite; }
@keyframes tr-pulse { 70% { box-shadow: 0 0 0 7px rgba(229, 72, 77, 0); } 100% { box-shadow: 0 0 0 0 rgba(229, 72, 77, 0); } }
@media (prefers-reduced-motion: reduce) { .tr-dot { animation: none; } }

/* ---------- upcoming: cards ---------- */
.tr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 18px; }
.tr-card { display: flex; flex-direction: column; gap: 14px; margin: 0; }
.tr-card--running { border-color: rgba(229, 72, 77, .5); }
.tr-card--cancelled { opacity: .8; }
.tr-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.tr-card__name { margin: 0 0 8px; font: 700 1.2rem/1.2 var(--aet-font-display); color: #fff; overflow-wrap: anywhere; }
.tr-card > .btn { align-self: flex-start; margin-top: auto; }
.tr-cancel { margin: 0; color: var(--aet-bad); font-size: .9rem; }
.tr-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; margin: 0; }
.tr-facts dt { font: 600 .68rem/1.3 var(--aet-font); letter-spacing: .12em; text-transform: uppercase; color: var(--aet-faint); }
.tr-facts dd { margin: 3px 0 0; color: var(--aet-text); font-variant-numeric: tabular-nums; }
.tr-facts dd .tr-small { display: block; margin-top: 2px; }
.tr-card__prizes { padding-top: 12px; border-top: 1px solid var(--aet-border); }
.tr-prizes { display: grid; gap: 8px; margin: 0; }
.tr-prize { display: grid; grid-template-columns: 9.5em minmax(0, 1fr); gap: 8px; }
.tr-prize dt { font-weight: 600; color: var(--aet-muted); }
.tr-prize--champion dt { color: #ffdf9a; }
.tr-prize--runner_up dt { color: #e2e6f6; }
.tr-prize--semifinal dt { color: #f0c49c; }
.tr-prize dd { margin: 0; }
.tr-prize ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; }
.tr-more summary { cursor: pointer; margin: 8px 0; color: var(--aet-amber-soft); font-weight: 600; font-size: .9rem; }

/* ---------- brackets: picker, head, standings, live ---------- */
.tr-picker, .br-jump { display: flex; flex-wrap: wrap; gap: 8px; }
.tr-picker .gchip, .br-jump .gchip { padding-left: 11px; text-decoration: none; }
.tr-picker .gchip:hover, .br-jump .gchip:hover { border-color: var(--aet-rune); }
.tr-picker .gchip.is-on { border-color: var(--aet-amber); box-shadow: inset 0 -2px 0 var(--aet-amber); }
.tr-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; }
.tr-head .tr-h2 { margin-bottom: 4px; }
.tr-head p { margin: 0; }
.tr-standings, .tr-live, .tr-people, .tr-rule, .tr-prizes-card { padding: 16px 18px; }
.br-col .br-slot { padding-top: 10px; }
.tr-stand-list { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 8px; }
.tr-stand { display: grid; grid-template-columns: 34px 9.5em minmax(0, 1fr); align-items: center; gap: 10px; }
.tr-stand__pos { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; font: 700 .9rem/1 var(--aet-font-display); color: #1a1208; }
.tr-stand--gold .tr-stand__pos { background: linear-gradient(135deg, #ffe9a8, #f0b84a); }
.tr-stand--silver .tr-stand__pos { background: linear-gradient(135deg, #f4f6ff, #a9b1cc); }
.tr-stand--bronze .tr-stand__pos { background: linear-gradient(135deg, #e3b183, #9a5f2c); }
.tr-stand--rune .tr-stand__pos { background: linear-gradient(135deg, #e1d4ff, #a78bfa); }
.tr-stand__lbl { color: var(--aet-muted); font-weight: 600; }
.tr-stand__names { color: #fff; font-weight: 600; overflow-wrap: anywhere; }
.tr-stand--gold .tr-stand__names { color: #ffdf9a; }
.tr-live-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 12px; }
.tr-live-list li { display: grid; gap: 6px; }
.tr-people-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.tr-people-list .gchip { padding-left: 4px; }
.tr-people-list .who__icon { width: 24px; height: 24px; border-radius: 99px; }
.tr-people-list .who__icon svg { width: 14px; height: 14px; }
.tr-bracket .tr-h2 { margin-bottom: 10px; }
.tr-bracket .br-jump { margin-bottom: 12px; }

/* ---------- the bracket tree ---------- */
.br-scroll { overflow-x: auto; padding-bottom: 8px; scrollbar-color: var(--aet-border-strong) transparent; }
.br { --br-gap: 28px; --br-w: 214px; display: grid; grid-auto-flow: column; grid-auto-columns: var(--br-w); gap: var(--br-gap); min-width: max-content; }
.br-round { display: flex; flex-direction: column; min-width: 0; }
.br-round__h { margin: 0 0 10px; font: 600 .7rem/1.2 var(--aet-font); letter-spacing: .12em; text-transform: uppercase; color: var(--aet-faint); white-space: nowrap; }
.br-round__h .muted { letter-spacing: .04em; text-transform: none; color: var(--aet-faint); opacity: .8; }
.br-col { list-style: none; margin: 0; padding: 0; flex: 1; display: flex; flex-direction: column; }
.br-slot { position: relative; flex: 1 1 0; display: flex; align-items: center; padding: 6px 0; }
/* connectors: odd slot = top half of the bracket line to the next round, even slot = bottom half; plus a stub in */
.br-round:not(:last-child) .br-slot::after { content: ""; position: absolute; right: calc(var(--br-gap) / -2); width: calc(var(--br-gap) / 2);
  border-right: 2px solid var(--aet-border-strong); }
.br-round:not(:last-child) .br-slot:nth-child(odd)::after { top: 50%; height: 50%; border-top: 2px solid var(--aet-border-strong); border-top-right-radius: 6px; }
.br-round:not(:last-child) .br-slot:nth-child(even)::after { bottom: 50%; height: 50%; border-bottom: 2px solid var(--aet-border-strong); border-bottom-right-radius: 6px; }
.br-round:not(:first-child) .br-slot::before { content: ""; position: absolute; left: calc(var(--br-gap) / -2); top: 50%; width: calc(var(--br-gap) / 2);
  border-top: 2px solid var(--aet-border-strong); }

.br-m { position: relative; width: 100%; border-radius: 10px; background: rgba(17, 19, 40, .92); border: 1px solid var(--aet-border); overflow: hidden;
  box-shadow: 0 6px 18px -10px rgba(0, 0, 0, .8); }
.br-m:has(.br-tag) { overflow: visible; }
.br-m.is-live { border-color: var(--aet-red); box-shadow: 0 0 0 1px rgba(229, 72, 77, .4), 0 0 18px -6px var(--aet-red); }
.br-m--waiting { opacity: .75; }
.br-side { display: grid; grid-template-columns: 22px minmax(0, 1fr) 22px; align-items: center; gap: 6px; height: 32px; padding: 0 8px; font-size: .88rem; }
.br-side + .br-side { border-top: 1px solid var(--aet-border); }
.br-seed { font-size: .7rem; color: var(--aet-faint); text-align: right; font-variant-numeric: tabular-nums; }
.br-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--aet-text); }
.br-name--tbd { color: var(--aet-faint); font-style: italic; }
.br-name--bye { color: var(--aet-faint); font-style: italic; font-size: .82rem; }
.br-wins { text-align: center; font: 700 .9rem/1 var(--aet-font); color: var(--aet-muted); font-variant-numeric: tabular-nums; }
.br-side.is-win { background: linear-gradient(90deg, rgba(245, 168, 58, .14), rgba(245, 168, 58, 0) 80%); }
.br-side.is-win .br-name { color: #fff; font-weight: 700; }
.br-side.is-win .br-wins { color: var(--aet-amber-soft); }
.br-side.is-loss .br-name { color: var(--aet-faint); }
.br-m .br-tag { position: absolute; z-index: 1; top: -9px; right: 8px; display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 1px 8px; border-radius: 99px;
  font: 600 .66rem/1.4 var(--aet-font); letter-spacing: .06em; text-transform: uppercase; color: var(--aet-muted); background: rgba(11, 13, 26, .8); border: 1px solid var(--aet-border); }
.br-m .br-tag--live { color: #fff; border-color: rgba(229, 72, 77, .55); }

/* ---------- history + rules tables ---------- */
.tr-hist td { vertical-align: middle; }
.tr-gold { color: #ffdf9a; }
.tr-lbl { display: none; }
.tr-table { overflow-x: auto; margin-top: 10px; }
.tr-rules { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 460px), 1fr)); gap: 18px; }
.tr-rule { scroll-margin-top: calc(var(--aet-header-h) + 16px); }
.tr-rule-list { margin: 0; padding-left: 1.2em; display: grid; gap: 7px; color: var(--aet-text); }
.tr-rule-list li::marker { color: var(--aet-amber); }
.tr-rule-prizes { display: grid; gap: 14px; margin-top: 14px; }
.tr-rule-prize { padding-top: 12px; border-top: 1px solid var(--aet-border); }

/* ---------- phones ---------- */
@media (max-width: 720px) {
  .tr { gap: 16px; }
  .tr-facts { grid-template-columns: minmax(0, 1fr); }
  .tr-prize, .tr-stand { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .tr-stand { grid-template-columns: 34px minmax(0, 1fr); }
  .tr-stand__names { grid-column: 2; }
  .tr-standings, .tr-live, .tr-people, .tr-rule, .tr-head, .tr-prizes-card { padding: 14px; background: rgba(17, 19, 40, .86); border: 1px solid var(--aet-border); border-radius: 12px; }
  /* the tree becomes a list of rounds (no connectors); the round chips above jump to each */
  .br-scroll { overflow: visible; }
  .br { display: block; min-width: 0; }
  .br-round + .br-round { margin-top: 18px; }
  .br-round__h { position: sticky; top: var(--aet-header-h); z-index: 1; padding: 8px 0; background: var(--aet-bg); white-space: normal; }
  .br-col { display: grid; gap: 8px; }
  .br-slot { padding: 0; }
  .br-slot::before, .br-slot::after, .br-round:not(:last-child) .br-slot::after, .br-round:not(:first-child) .br-slot::before { display: none; }
  .br-side { height: 38px; font-size: .92rem; }
  .br-round { scroll-margin-top: calc(var(--aet-header-h) + 8px); }
  /* history rows as cards: each cell labelled */
  .lb.tr-hist tr.lb-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .lb.tr-hist tr.lb-row td { display: block; }
  .tr-lbl.rk-phone { display: inline-block; min-width: 8.5em; margin-right: 6px; font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; color: var(--aet-faint); }
  .tr-table .lb thead { display: table-header-group; }
  .tr-table .lb, .tr-table .lb tbody { display: table; width: 100%; }
  .tr-table .lb tbody { display: table-row-group; }
  .tr-table .lb tr.lb-row { display: table-row; margin: 0; padding: 0; border: 0; background: none; }
  .tr-table .lb tr.lb-row td { display: table-cell; padding: 8px 6px; border-top: 1px solid var(--aet-border); }
}
