/* =========================================================
   BRACKET — standalone stylesheet (v3)

   Structure (built by results.js):
     .bracket-wrapper        horizontal scroll container
       .bracket-inner        width: max-content
         .b-tree             one row of round columns
           .b-round          one column (label + body)
             .b-round-body   stack of .b-cell
               .b-cell       a slot that is exactly as tall as the
                             two slots feeding it → perfect alignment
                 .bracket-match   the match card
                 .b-link          connector to the next round
             .b-third        (Final column only) 3rd-place match
                             with a "Small Final" label above it

   v3 changes vs v2:
     • narrower column (340px) → 3 rounds + gaps fit inside the
       1200px content container on a standard desktop
     • "Final" and "Small Final" labels added above the final
       and 3rd-place matches respectively
   ========================================================= */

.bracket-scope {
  --b-col-w:   340px;   /* width of a match card */
  --b-gap-x:    48px;   /* space between rounds (connectors live here) */
  --b-slot-h:   92px;   /* height of a match card */
  --b-gap-y:    22px;   /* vertical breathing room between cards */
  --b-line:     rgba(212, 177, 106, 0.42);
  --b-line-w:   2px;
}

/* ---------------------------------------------------------
   Scroll container — scrolls sideways only if too narrow
   --------------------------------------------------------- */

.bracket-wrapper {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 12px 4px 24px;
  scrollbar-width: thin;
  scrollbar-color: rgba(212, 177, 106, 0.35) transparent;
}
@supports selector(::-webkit-scrollbar) {
  .bracket-wrapper::-webkit-scrollbar { height: 8px; }
  .bracket-wrapper::-webkit-scrollbar-track { background: transparent; }
  .bracket-wrapper::-webkit-scrollbar-thumb {
    background: rgba(212, 177, 106, 0.3);
    border-radius: 4px;
  }
}

.bracket-inner {
  display: flex;
  flex-direction: column;
  gap: 28px;
  width: max-content;
  min-width: 100%;
  padding: 0 4px;
}

.bracket-hint {
  display: none;
  position: sticky;
  left: 4px;
  width: max-content;
  margin: 0;
  color: var(--text-muted, #b7b0ac);
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.7;
}

.b-subtitle {
  position: sticky;
  left: 4px;
  width: max-content;
  margin: 8px 0 -6px;
  font-family: var(--font-heading, "Horta", "Arial Narrow", Arial, sans-serif);
  font-size: 1.35rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--gold, #d4b16a);
}

/* ---------------------------------------------------------
   Tree & columns
   --------------------------------------------------------- */

.b-tree {
  display: flex;
  align-items: stretch;
}

.b-round {
  display: flex;
  flex-direction: column;
  flex: 0 0 calc(var(--b-col-w) + var(--b-gap-x));
}
.b-round:last-child { flex-basis: var(--b-col-w); }

.b-round-label {
  display: flex;
  align-items: flex-end;
  width: var(--b-col-w);
  height: 40px;
  padding: 0 2px 10px;
  font-family: var(--font-heading, "Horta", "Arial Narrow", Arial, sans-serif);
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold, #d4b16a);
  opacity: 0.8;
}
.b-round-label::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  margin: 0 0 0.45em 12px;
  background: linear-gradient(90deg, rgba(212, 177, 106, 0.35), transparent);
}

.b-round-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
}

.b-cell {
  position: relative;
  display: flex;
  flex: 1 1 0;
  align-items: center;
  min-height: calc(var(--b-slot-h) + var(--b-gap-y));
  padding-block: calc(var(--b-gap-y) / 2);
}

/* ---------------------------------------------------------
   Final column — Final centered, 3rd place below
   --------------------------------------------------------- */

.b-round-body--final {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto minmax(0, 1fr);
  row-gap: 0;
}

/* Final cell: shrink-wrap the match; label floats above */
.b-round-body--final > .b-cell {
  grid-row: 2;
  position: relative;
  display: block;
  min-height: 0;
  padding: 0;
}

/* 3rd place: label (in flow) + match, with padding above the label */
.b-third {
  grid-row: 3;
  align-self: start;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding-top: 20px;
}

/* Small per-match label */
.b-match-label {
  display: block;
  color: var(--gold, #d4b16a);
  font-family: var(--font-heading, "Horta", "Arial Narrow", Arial, sans-serif);
  font-size: 0.76rem;
  letter-spacing: 0.12em;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
  opacity: 0.9;
  white-space: nowrap;
}

/* "Final" label — positioned above the match, floating in row 1 */
.b-match-label--final {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  right: 0;
  pointer-events: none;
}

/* ---------------------------------------------------------
   Connectors
   --------------------------------------------------------- */

.b-link {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--b-col-w);
  width: var(--b-gap-x);
  pointer-events: none;
}
.b-link::before {
  content: "";
  position: absolute;
  left: 0;
  width: 50%;
  top: 50%;
  height: var(--b-line-w);
  margin-top: calc(var(--b-line-w) / -2);
  background: var(--b-line);
}
.b-link::after {
  content: "";
  position: absolute;
  left: 50%;
  width: var(--b-line-w);
  margin-left: calc(var(--b-line-w) / -2);
  background: var(--b-line);
}
.b-link--top::after    { top: calc(50% - var(--b-line-w) / 2); bottom: 0; }
.b-link--bottom::after { bottom: calc(50% - var(--b-line-w) / 2); top: 0; }

.b-cell.has-in::before {
  content: "";
  position: absolute;
  left: calc(var(--b-gap-x) / -2);
  width: calc(var(--b-gap-x) / 2);
  top: 50%;
  height: var(--b-line-w);
  margin-top: calc(var(--b-line-w) / -2);
  background: var(--b-line);
  pointer-events: none;
}

/* ---------------------------------------------------------
   Match card
   --------------------------------------------------------- */

.bracket-match {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  width: var(--b-col-w);
  height: var(--b-slot-h);
  box-sizing: border-box;
  background: linear-gradient(180deg, #25222a 0%, var(--bg-card, #201d20) 100%);
  border: 1px solid var(--border, rgba(212, 177, 106, 0.18));
  border-radius: 8px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.28);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.bracket-match:hover {
  border-color: rgba(212, 177, 106, 0.4);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4);
}

.bracket-trophy {
  position: absolute;
  top: -158px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
}
.bracket-trophy img {
  height: 130px;
  width: auto;
  opacity: 0.75;
  filter: drop-shadow(0 4px 10px rgba(212, 177, 106, 0.25));
}

.bracket-body {
  display: flex;
  align-items: stretch;
  flex: 1 1 auto;
  min-height: 0;
  border-radius: 7px;
  overflow: hidden;
}

.bracket-players {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
}

.bracket-player {
  display: flex;
  flex: 1 1 0;
  align-items: center;
  min-height: 0;
  padding: 0 12px;
  font-family: var(--font-body, Inter, Arial, sans-serif);
  font-size: 0.88rem;
  line-height: 1.2;
  color: var(--text, #f5f2ec);
  border-bottom: 1px solid rgba(212, 177, 106, 0.1);
}
.bracket-players .bracket-player:last-child { border-bottom: 0; }

.bracket-player-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}

.bracket-player-line {
  display: flex;
  align-items: center;
  gap: 6px;              /* ← small space everywhere */
  flex: 1 1 auto;
  min-width: 0;
}

.bracket-meta {
  flex: 0 0 auto;
  color: var(--text-muted, #b7b0ac);
  font-size: 0.72rem;
  white-space: nowrap;   /* ← no padding-left, no margin-left */
}

.bracket-flag {
  flex: 0 0 auto;
  font-size: 0.95em;
}
.bracket-placeholder {
  color: var(--text-muted, #b7b0ac);
  font-style: italic;
  opacity: 0.65;
}

.bracket-player.is-winner {
  background: linear-gradient(90deg, rgba(212, 177, 106, 0.16), rgba(212, 177, 106, 0.04));
  box-shadow: inset 3px 0 0 var(--gold, #d4b16a);
}
.bracket-player.is-winner .bracket-player-name {
  color: var(--gold, #d4b16a);
  font-weight: 600;
}
.bracket-player.is-loser { color: var(--text-muted, #b7b0ac); }
.bracket-player.is-loser .bracket-player-line { opacity: 0.7; }

/* Stones */
.bracket-stone {
  display: inline-block;
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-sizing: border-box;
}
.bracket-stone--black {
  background: radial-gradient(circle at 35% 30%, #4a4a4a 0%, #1a1a1a 60%, #000 100%);
  box-shadow: 0 0 0 1px rgba(212, 177, 106, 0.28),
              inset 0 1px 2px rgba(255, 255, 255, 0.08);
}
.bracket-stone--white {
  background: radial-gradient(circle at 35% 30%, #ffffff 0%, #ececec 55%, #c8c8c8 100%);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55),
              inset 0 1px 2px rgba(0, 0, 0, 0.06);
}
.bracket-stone--unknown {
  background: transparent;
  border: 1px dashed rgba(212, 177, 106, 0.35);
}

/* ---------------------------------------------------------
   Result panel
   --------------------------------------------------------- */

.bracket-result {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 72px;
  padding: 4px 6px;
  font-family: var(--font-body, Inter, Arial, sans-serif);
  font-size: 0.78rem;
  text-align: center;
  color: var(--text-muted, #b7b0ac);
  background: rgba(0, 0, 0, 0.22);
  border-left: 1px solid rgba(212, 177, 106, 0.12);
}

.bracket-result-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.bracket-result-link {
  padding: 2px 6px;
  color: var(--gold, #d4b16a);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  border-radius: 4px;
  transition: background 0.15s ease, color 0.15s ease;
}
.bracket-result-link:hover {
  background: rgba(212, 177, 106, 0.16);
  color: #f0d59a;
}

.bracket-result-hint {
  color: var(--text-muted, #b7b0ac);
  font-size: 0.56rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  line-height: 1;
  text-decoration: none;
  text-transform: uppercase;
  opacity: 0.55;
}
.bracket-result-hint:hover { opacity: 1; color: var(--gold, #d4b16a); }

.bracket-result-text {
  color: var(--text-muted, #b7b0ac);
  font-weight: 600;
  white-space: nowrap;
}

.bracket-result-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  color: #e74c3c;
  font-size: 0.72rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  border-radius: 4px;
}
.bracket-result-live:hover { background: rgba(231, 76, 60, 0.14); }
.bracket-result-live .live-label {
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.bracket-result-pending {
  color: var(--text-muted, #b7b0ac);
  opacity: 0.35;
  user-select: none;
}

.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e74c3c;
  animation: bracket-live-pulse 1.3s infinite;
  vertical-align: middle;
}
@keyframes bracket-live-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.55); opacity: 1; }
  70%  { box-shadow: 0 0 0 8px rgba(231, 76, 60, 0); opacity: 0.85; }
  100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0); opacity: 1; }
}

/* ---------------------------------------------------------
   Final accent
   --------------------------------------------------------- */

.bracket-match--final {
  border-color: rgba(212, 177, 106, 0.5);
  box-shadow: 0 0 0 1px rgba(212, 177, 106, 0.2),
              0 12px 30px rgba(0, 0, 0, 0.45),
              0 0 36px rgba(212, 177, 106, 0.08);
}

/* ---------------------------------------------------------
   Final standings
   --------------------------------------------------------- */

.standings-table {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  border-collapse: collapse;
  font-family: var(--font-body, Inter, Arial, sans-serif);
  font-size: 0.95rem;
}
.standings-table thead th {
  padding: 8px 12px;
  color: var(--gold, #d4b16a);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: left;
  border-bottom: 1px solid rgba(212, 177, 106, 0.28);
}
.standings-table thead th.st-place { width: 56px; text-align: center; }
.standings-table tbody td {
  padding: 10px 12px;
  color: var(--text, #f5f2ec);
  border-bottom: 1px solid rgba(212, 177, 106, 0.08);
  vertical-align: middle;
}
.standings-table tbody tr:last-child td { border-bottom: 0; }
.standings-table td.st-place {
  text-align: center;
  font-family: var(--font-heading, "Horta", Arial, sans-serif);
  font-size: 1.15rem;
  color: var(--gold, #d4b16a);
  opacity: 0.85;
}
.standings-table td.st-player { font-weight: 500; }
.standings-table .st-tbd {
  color: var(--text-muted, #b7b0ac);
  font-style: italic;
  opacity: 0.55;
  font-weight: 400;
}
.standings-table tr.st-place-1 td.st-place { color: #f0d59a; font-size: 1.35rem; }
.standings-table tr.st-place-1 td { background: rgba(212, 177, 106, 0.06); }
.standings-table tr.st-place-1 .st-name { color: var(--gold, #d4b16a); font-weight: 600; }
.standings-table tr.st-place-2 td.st-place { color: #e5e5e5; }
.standings-table tr.st-place-3 td.st-place { color: #cdb892; }

/* ---------------------------------------------------------
   Small screens — same bracket, scrolls sideways.
   The hint appears and the column shrinks a touch so
   scrolling isn't painful on phones.
   --------------------------------------------------------- */

@media (max-width: 1100px) {
  .bracket-scope {
    --b-col-w: 320px;
    --b-gap-x:  44px;
  }
}

@media (max-width: 900px) {
  .bracket-hint { display: block; }
  .bracket-scope {
    --b-col-w: 300px;
    --b-gap-x:  40px;
  }
}

@media (max-width: 600px) {
  .bracket-scope {
    --b-col-w: 290px;
    --b-gap-x:  36px;
    --b-slot-h: 86px;
  }
  .bracket-player { font-size: 0.82rem; padding: 0 10px; }
  .bracket-result { width: 66px; }
  .b-subtitle { font-size: 1.15rem; }
  .b-match-label { font-size: 0.7rem; }

}
