/* =====================================================================
   CloudRO Tournament Bracket - Challonge-style single elimination
   Builds on ranking-theme.css (loaded first by the view).
   ===================================================================== */
.tb-head-row{ display:flex; align-items:flex-end; justify-content:space-between; gap:18px; flex-wrap:wrap; margin:0 0 18px; }
.tb-info{
  display:flex; align-items:center; gap:18px; flex-wrap:wrap;
  background:var(--w-panel); border:1px solid var(--w-line); border-radius:16px; padding:16px 20px;
  box-shadow:0 10px 30px rgba(0,0,0,0.35), inset 0 0 0 1px rgba(255,255,255,0.03);
  margin-bottom:18px;
}
.tb-info .tb-name{ font-family:var(--w-serif); font-size:24px; font-weight:800; color:#fff; line-height:1.15; text-shadow:0 2px 10px rgba(0,0,0,0.5); }
.tb-info .tb-desc{ color:var(--w-muted); font-size:14px; margin-top:4px; max-width:720px; }
.tb-info .tb-meta{ display:flex; gap:10px; flex-wrap:wrap; margin-left:auto; }
.rgh-wrap .rgh-pill.tb-status{ min-width:0; padding:7px 14px; font-size:12px; letter-spacing:.12em; text-transform:uppercase; }
.rgh-wrap .rgh-pill.tb-status.pending{ color:#aab7dc; }
.rgh-wrap .rgh-pill.tb-status.underway{ color:var(--w-alive); border-color:rgba(46,224,122,0.5); box-shadow:0 0 10px rgba(46,224,122,0.25); }
.rgh-wrap .rgh-pill.tb-status.complete{ color:var(--w-gold); border-color:rgba(245,197,66,0.5); box-shadow:0 0 10px rgba(245,197,66,0.25); }
.rgh-wrap .rgh-pill.tb-meta-pill{ min-width:0; padding:7px 14px; font-size:13px; font-weight:600; color:#dbe7ff; gap:8px; }
.rgh-wrap .rgh-pill.tb-meta-pill svg{ color:#9fb3e6; }

.tb-flash{ border-radius:12px; padding:12px 16px; font-size:14px; font-weight:600; margin-bottom:16px; border:1px solid; }
.tb-flash.ok{ background:rgba(46,224,122,0.10); border-color:rgba(46,224,122,0.45); color:#bdf5d4; }
.tb-flash.err{ background:rgba(255,79,109,0.10); border-color:rgba(255,79,109,0.45); color:#ffd0d8; }

/* champion banner */
.tb-champ{
  position:relative; overflow:hidden; display:flex; align-items:center; gap:18px;
  border-radius:16px; padding:16px 22px; margin-bottom:18px;
  background:linear-gradient(90deg, rgba(76,52,12,0.85) 0%, rgba(36,28,16,0.85) 55%, rgba(12,20,52,0.85) 100%);
  border:1px solid rgba(245,197,66,0.55); box-shadow:0 0 24px rgba(245,197,66,0.22), inset 0 0 40px rgba(245,197,66,0.06);
}
.tb-champ .tb-crown{ color:var(--w-gold); filter:drop-shadow(0 0 10px rgba(245,197,66,0.7)); flex-shrink:0; }
.tb-champ .lbl{ font-family:var(--w-serif); font-size:12px; letter-spacing:.2em; text-transform:uppercase; color:var(--w-gold-3); }
.tb-champ .nm{ font-family:var(--w-serif); font-size:26px; font-weight:800; color:#fff; text-shadow:0 0 16px rgba(245,197,66,0.5); }
.tb-champ .tb-head{ width:52px; height:52px; border-radius:50%; background:rgba(0,0,0,0.35); border:2px solid var(--w-gold); display:flex; align-items:center; justify-content:center; overflow:hidden; flex-shrink:0; }
.tb-champ .tb-head img{ width:40px; height:auto; image-rendering:pixelated; }

/* tabs row + panels */
.tb-tabbar{ display:flex; align-items:center; justify-content:space-between; gap:14px; flex-wrap:wrap; margin-bottom:16px; }
.tb-panel[hidden]{ display:none !important; }
.tb-tools{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.rgh-wrap button.tb-zoom{
  width:38px; height:38px; border-radius:10px; border:1.5px solid rgba(120,150,220,0.40); background:rgba(47,123,255,0.08); color:#dbe7ff;
  font-size:18px; font-weight:700; cursor:pointer; display:inline-flex; align-items:center; justify-content:center; padding:0; transition:all .18s;
}
.rgh-wrap button.tb-zoom:hover{ border-color:var(--w-blue); background:rgba(47,123,255,0.18); color:#fff; box-shadow:0 0 12px rgba(47,123,255,0.4); }
.tb-zoom-val{ min-width:46px; text-align:center; color:var(--w-muted); font-size:13px; font-weight:600; font-variant-numeric:tabular-nums; }

/* ---------- the bracket ---------- */
.tb-scroll{
  position:relative; overflow:auto; border-radius:18px;
  background:var(--w-panel-2); border:1px solid var(--w-line);
  box-shadow:0 10px 30px rgba(0,0,0,0.35), inset 0 0 0 1px rgba(255,255,255,0.03);
  padding:22px 26px 28px; cursor:grab; user-select:none;
  scrollbar-color:rgba(120,150,220,0.5) rgba(0,0,0,0.25);
}
.tb-scroll.is-drag{ cursor:grabbing; }
.tb-scroll::-webkit-scrollbar{ height:10px; width:10px; }
.tb-scroll::-webkit-scrollbar-thumb{ background:rgba(120,150,220,0.45); border-radius:10px; }
.tb-scroll::-webkit-scrollbar-track{ background:rgba(0,0,0,0.25); border-radius:10px; }
.tb-bracket{ --tb-col:250px; --tb-gap:56px; --tb-slot:104px; display:inline-block; min-width:100%; zoom:1; }
.tb-rounds-head{ display:flex; gap:var(--tb-gap); margin-bottom:14px; position:sticky; top:0; z-index:2; }
.tb-rounds-head > div{
  width:var(--tb-col); flex:0 0 var(--tb-col);
  font-family:var(--w-serif); font-size:12px; font-weight:800; letter-spacing:.18em; text-transform:uppercase; color:#d8e2ff;
  background:linear-gradient(180deg, rgba(18,32,82,0.95), rgba(10,20,52,0.95)); border:1px solid rgba(47,123,255,0.40);
  border-radius:10px; padding:9px 12px; text-align:center; box-shadow:0 4px 14px rgba(0,0,0,0.3);
}
.tb-rounds-head > div small{ display:block; color:var(--w-dim); letter-spacing:.08em; font-family:var(--w-sans); font-weight:600; font-size:11px; text-transform:none; margin-top:2px; }
.tb-rounds-head > div.is-final{ color:var(--w-gold-3); border-color:rgba(245,197,66,0.55); box-shadow:0 0 14px rgba(245,197,66,0.25); }
.tb-rounds-head > div small .bo{ color:#dbe7ff; font-weight:800; }
.tb-rounds-head > div small .bo.custom{ color:var(--w-gold-3); }
.tb-rounds-head > div.is-editable{ cursor:pointer; transition:border-color .15s, box-shadow .15s, transform .15s; }
.tb-rounds-head > div.is-editable .pen{ display:inline-flex; vertical-align:middle; color:#8e9bc0; margin-left:2px; opacity:.7; }
.tb-rounds-head > div.is-editable:hover, .tb-rounds-head > div.is-editable:focus-visible{ border-color:var(--w-gold); box-shadow:0 0 14px rgba(245,197,66,0.4); transform:translateY(-1px); outline:none; }
.tb-rounds-head > div.is-editable:hover .pen{ color:var(--w-gold-3); opacity:1; }
.rgh-modal .tb-form label{ display:flex; flex-direction:column; gap:6px; font-size:12px; font-weight:700; letter-spacing:.1em; text-transform:uppercase; color:var(--w-muted); }
.rgh-modal .tb-form select{ width:100%; box-sizing:border-box; background:rgba(6,12,34,0.9); border:1px solid rgba(47,123,255,0.40); border-radius:10px; color:#eef2ff; font-family:var(--w-sans); font-size:14px; font-weight:500; padding:10px 12px; outline:none; margin:0; }
.rgh-modal .tb-form select option{ background:#0b1430; }
.tb-grid{ display:flex; gap:var(--tb-gap); align-items:stretch; }
.tb-round{ display:flex; flex-direction:column; width:var(--tb-col); flex:0 0 var(--tb-col); }
.tb-round.tb-first .tb-slot{ min-height:var(--tb-slot); }
.tb-slot{ flex:1 1 0; display:flex; align-items:center; position:relative; }
/* incoming connector: two feeders merge ( ]- ) */
.tb-round.tb-merge .tb-slot::before{
  content:""; position:absolute; left:calc(var(--tb-gap) / -2); top:25%; height:50%; width:calc(var(--tb-gap) / 2); pointer-events:none;
  background:
    linear-gradient(rgba(120,150,220,0.55), rgba(120,150,220,0.55)) left top / 2px 100% no-repeat,
    linear-gradient(rgba(120,150,220,0.55), rgba(120,150,220,0.55)) left 50% / 100% 2px no-repeat;
  filter:drop-shadow(0 0 4px rgba(47,123,255,0.35));
}
/* incoming connector: straight from the match at the same height ( -- ) */
.tb-round.tb-straight .tb-slot::before{
  content:""; position:absolute; left:calc(var(--tb-gap) / -2); top:50%; height:0; width:calc(var(--tb-gap) / 2); pointer-events:none;
  border-top:2px solid rgba(120,150,220,0.55); box-shadow:0 0 8px rgba(47,123,255,0.25);
}
/* outgoing stub towards the next column */
.tb-round:not(.tb-last) .tb-slot::after{
  content:""; position:absolute; right:calc(var(--tb-gap) / -2); top:50%; width:calc(var(--tb-gap) / 2); height:0; pointer-events:none;
  border-top:2px solid rgba(120,150,220,0.55); box-shadow:0 0 8px rgba(47,123,255,0.25);
}
.tb-slot.has-winner::after{ border-top-color:var(--w-gold); box-shadow:0 0 10px rgba(245,197,66,0.45); }
/* drop-in marker for losers-bracket slots fed from the winners bracket */
.tb-p .drop{ font-size:9px; font-weight:800; letter-spacing:.08em; color:#5ec8ff; background:rgba(94,200,255,0.10); border:1px solid rgba(94,200,255,0.35); border-radius:5px; padding:1px 5px; flex-shrink:0; }

/* bracket sections (winners / losers) */
.tb-section{ margin-bottom:26px; }
.tb-scroll.losers{ border-color:rgba(255,79,109,0.35); background:linear-gradient(180deg, rgba(40,10,22,0.55), rgba(6,12,34,0.85)); }
.tb-scroll.losers .tb-rounds-head > div{ border-color:rgba(255,79,109,0.40); background:linear-gradient(180deg, rgba(70,18,36,0.95), rgba(28,10,24,0.95)); }
.tb-scroll.losers .tb-rounds-head > div.is-final{ color:#ffd0d8; border-color:rgba(255,79,109,0.7); box-shadow:0 0 14px rgba(255,79,109,0.3); }
.tb-scroll.losers .tb-match{ border-color:rgba(255,120,145,0.30); }
.tb-scroll.losers .tb-match.is-open{ border-color:rgba(255,79,109,0.7); box-shadow:0 0 0 1px rgba(255,79,109,0.25), 0 0 18px rgba(255,79,109,0.3); }
.tb-section:last-child{ margin-bottom:0; }
.tb-section-title{
  display:flex; align-items:center; gap:12px; margin:0 0 14px;
  font-family:var(--w-serif); font-size:15px; font-weight:800; letter-spacing:.16em; text-transform:uppercase; color:#fff;
}
.tb-section-title::after{ content:""; flex:1; height:1px; background:linear-gradient(90deg, rgba(120,150,220,0.5), transparent); }
.tb-section-title.losers{ color:#ffb3c0; }
.tb-section-title.losers::after{ background:linear-gradient(90deg, rgba(255,79,109,0.5), transparent); }
.tb-section-title .tag{ font-family:var(--w-sans); font-size:11px; letter-spacing:.08em; color:var(--w-muted); text-transform:none; font-weight:600; }
.tb-gf{ display:flex; flex-direction:column; gap:10px; width:100%; }
.tb-gf .tb-match.is-reset.is-unneeded{ opacity:.45; }
.tb-gf .tb-match.is-reset .tb-mlabel{ display:block; font-size:9px; letter-spacing:.14em; text-transform:uppercase; color:#8e9bc0; padding:5px 10px 0 24px; font-weight:800; }
.tb-match.is-void{ opacity:.35; }
.tb-match.is-void .tb-p .nm{ color:var(--w-dim); font-style:italic; }

.tb-match{
  position:relative; width:100%; border-radius:12px; overflow:hidden;
  background:linear-gradient(180deg, rgba(14,26,64,0.96), rgba(8,16,44,0.96));
  border:1px solid rgba(120,150,220,0.35); box-shadow:0 8px 20px rgba(0,0,0,0.4);
  transition:transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.tb-match.is-open{ border-color:rgba(47,123,255,0.65); box-shadow:0 0 0 1px rgba(47,123,255,0.25), 0 0 18px rgba(47,123,255,0.35); }
.tb-match.is-complete{ border-color:rgba(245,197,66,0.35); }
.tb-match.is-final{ border-color:rgba(245,197,66,0.6); box-shadow:0 0 22px rgba(245,197,66,0.25); }
.tb-match.is-editable{ cursor:pointer; }
.tb-match.is-editable:hover{ transform:translateY(-2px); border-color:var(--w-gold); box-shadow:0 0 18px rgba(245,197,66,0.4); }
.tb-match .tb-mno{
  position:absolute; left:-1px; top:50%;
  width:18px; height:30px; display:flex; align-items:center; justify-content:center;
  font-size:10px; font-weight:800; color:#8e9bc0; background:rgba(0,0,0,0.35); border-radius:0 6px 6px 0; writing-mode:vertical-rl; transform:translateY(-50%) rotate(180deg); pointer-events:none;
}
.tb-p{ display:flex; align-items:center; gap:8px; height:42px; padding:0 10px 0 24px; border-bottom:1px solid rgba(255,255,255,0.06); }
.tb-p:last-child{ border-bottom:0; }
.tb-p .seed{
  min-width:20px; height:20px; border-radius:6px; display:inline-flex; align-items:center; justify-content:center;
  font-size:10px; font-weight:800; color:#aab7dc; background:rgba(255,255,255,0.06); border:1px solid rgba(120,150,220,0.3); flex-shrink:0;
}
.tb-p .tb-head{ width:26px; height:26px; border-radius:50%; background:rgba(0,0,0,0.35); border:1px solid rgba(120,150,220,0.35); overflow:hidden; display:flex; align-items:center; justify-content:center; flex-shrink:0; }
.tb-p .tb-head img{ width:22px; height:auto; image-rendering:pixelated; }
.tb-p .nm{ flex:1; min-width:0; font-size:13.5px; font-weight:600; color:#eef2ff; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.tb-p .sc{
  min-width:30px; height:26px; padding:0 8px; border-radius:7px; display:inline-flex; align-items:center; justify-content:center;
  font-size:13px; font-weight:800; font-variant-numeric:tabular-nums; color:#dbe7ff; background:rgba(255,255,255,0.05); border:1px solid rgba(120,150,220,0.3); flex-shrink:0;
}
.tb-p.is-tbd .nm, .tb-p.is-bye .nm{ color:var(--w-dim); font-style:italic; font-weight:500; }
.tb-p.is-win{ background:linear-gradient(90deg, rgba(245,197,66,0.16), rgba(245,197,66,0.03)); }
.tb-p.is-win .nm{ color:var(--w-gold-3); text-shadow:0 0 10px rgba(245,197,66,0.45); }
.tb-p.is-win .sc{ color:#241a05; background:linear-gradient(180deg, var(--w-gold), var(--w-gold-2)); border-color:var(--w-gold-3); }
.tb-p.is-win .seed{ color:var(--w-gold-3); border-color:rgba(245,197,66,0.5); }
.tb-p.is-lose .nm{ color:#7f8bb0; text-decoration:line-through; text-decoration-color:rgba(255,79,109,0.6); }
.tb-p.is-lose .tb-head{ filter:grayscale(1); opacity:.6; }
.tb-match.is-complete .tb-p.is-win::after{
  content:""; width:8px; height:8px; border-radius:50%; background:var(--w-gold); box-shadow:0 0 8px rgba(245,197,66,0.8); flex-shrink:0;
}
.tb-legend{ display:flex; gap:16px; flex-wrap:wrap; margin-top:12px; color:var(--w-dim); font-size:12.5px; }
.tb-legend span{ display:inline-flex; align-items:center; gap:6px; }
.tb-legend i{ width:10px; height:10px; border-radius:3px; display:inline-block; }

/* participants tab */
.rgh-wrap .rgh-table.tb-ptable{ min-width:620px; }
.tb-ptable .tb-head{ width:40px; height:40px; border-radius:10px; background:rgba(0,0,0,0.35); border:1px solid rgba(120,150,220,0.35); overflow:hidden; display:flex; align-items:center; justify-content:center; }
.tb-ptable .tb-head img{ width:32px; height:auto; image-rendering:pixelated; }
.tb-ptable .pname{ font-weight:700; color:#fff; font-size:15px; }
.tb-ptable .psub{ color:var(--w-dim); font-size:12px; margin-top:2px; }
.rgh-wrap .rgh-pill.tb-rec{ min-width:0; padding:6px 12px; font-size:12px; }
.rgh-wrap .rgh-pill.tb-rec.out{ color:var(--w-dead); border-color:rgba(255,79,109,0.45); }
.rgh-wrap .rgh-pill.tb-rec.alive{ color:var(--w-alive); border-color:rgba(46,224,122,0.45); }
.rgh-wrap .rgh-pill.tb-rec.champ{ color:var(--w-gold); border-color:rgba(245,197,66,0.5); }

/* manage tab */
.tb-admin{ display:grid; grid-template-columns:1fr 1fr; gap:18px; }
.tb-card{
  background:var(--w-panel); border:1px solid var(--w-line); border-radius:16px; padding:20px 22px;
  box-shadow:0 10px 30px rgba(0,0,0,0.35), inset 0 0 0 1px rgba(255,255,255,0.03);
}
.tb-card.wide{ grid-column:1 / -1; }
.tb-card h3{ font-family:var(--w-serif); font-size:13px; letter-spacing:.18em; text-transform:uppercase; color:#d8e2ff; margin:0 0 14px; font-weight:800; }
.tb-card p.hint{ color:var(--w-dim); font-size:12.5px; margin:-8px 0 14px; }
.tb-form{ display:flex; flex-direction:column; gap:12px; }
.tb-form label{ display:flex; flex-direction:column; gap:6px; font-size:12px; font-weight:700; letter-spacing:.1em; text-transform:uppercase; color:var(--w-muted); }
.rgh-wrap .tb-form input[type=text], .rgh-wrap .tb-form input[type=number], .rgh-wrap .tb-form input[type=datetime-local], .rgh-wrap .tb-form textarea, .rgh-wrap .tb-form select{
  width:100%; box-sizing:border-box; background:rgba(6,12,34,0.9); border:1px solid rgba(47,123,255,0.40); border-radius:10px; color:#eef2ff;
  font-family:var(--w-sans); font-size:14px; font-weight:500; padding:10px 12px; outline:none; text-transform:none; letter-spacing:0; margin:0;
  transition:border-color .18s, box-shadow .18s;
}
.rgh-wrap .tb-form textarea{ min-height:110px; resize:vertical; }
.rgh-wrap .tb-form input:focus, .rgh-wrap .tb-form textarea:focus, .rgh-wrap .tb-form select:focus{ border-color:var(--w-blue); box-shadow:0 0 12px rgba(47,123,255,0.35); }
.rgh-wrap .tb-form select option{ background:#0b1430; }
.tb-actions{ display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
.rgh-wrap button.rgh-pm-btn.danger, .rgh-modal button.rgh-pm-btn.danger{ border-color:rgba(255,79,109,0.5); color:#ffb3c0; }
.rgh-wrap button.rgh-pm-btn.danger:hover, .rgh-modal button.rgh-pm-btn.danger:hover{ background:rgba(255,79,109,0.18); border-color:var(--w-dead); box-shadow:0 0 12px rgba(255,79,109,0.4); color:#fff; }
.tb-seed-list{ display:flex; flex-direction:column; gap:6px; }
.tb-seed-row{ display:flex; align-items:center; gap:10px; background:var(--w-row); border:1px solid var(--w-line-2); border-radius:10px; padding:6px 8px 6px 10px; }
.rgh-wrap .tb-seed-row input[type=number]{ width:64px; text-align:center; padding:6px 4px; }
.tb-seed-row .nm{ flex:1; font-weight:600; color:#eef2ff; font-size:14px; }
.rgh-wrap .tb-seed-row button.rgh-pm-btn{ padding:5px 10px; font-size:12px; }
.tb-inline{ display:inline; }

/* score modal */
.tb-score-grid{ display:flex; flex-direction:column; gap:10px; margin:16px 0; }
.tb-score-row{ display:flex; align-items:center; gap:12px; background:var(--w-row); border:1px solid var(--w-line-2); border-radius:12px; padding:10px 12px; }
.tb-score-row .nm{ flex:1; font-weight:700; color:#fff; font-size:15px; }
.rgh-modal .tb-score-row input[type=number]{
  width:76px; text-align:center; background:rgba(6,12,34,0.9); border:1px solid rgba(47,123,255,0.40); border-radius:10px; color:#fff;
  font-family:var(--w-sans); font-size:18px; font-weight:800; padding:8px 6px; outline:none; margin:0;
}
.rgh-modal .tb-score-row input[type=radio]{ width:18px; height:18px; accent-color:#f5c542; margin:0; cursor:pointer; }
.rgh-modal .tb-score-row label.win{ display:inline-flex; align-items:center; gap:6px; font-size:12px; color:var(--w-muted); cursor:pointer; font-weight:600; text-transform:uppercase; letter-spacing:.08em; }
.tb-modal-sub{ color:var(--w-muted); font-size:13px; }
.tb-bo-hint{ display:inline-flex; align-items:center; gap:6px; margin-top:10px; padding:6px 12px; border-radius:999px; font-size:12px; color:#dbe7ff; background:rgba(47,123,255,0.10); border:1px solid rgba(47,123,255,0.40); }
.tb-bo-hint b{ color:var(--w-gold-3); font-weight:800; }
.tb-two{ display:grid; grid-template-columns:1fr 1fr; gap:12px; }
@media (max-width:600px){ .tb-two{ grid-template-columns:1fr; } }

@media (max-width: 900px){
  .tb-admin{ grid-template-columns:1fr; }
  .tb-bracket{ --tb-col:210px; --tb-gap:40px; --tb-slot:96px; }
  .tb-scroll{ padding:16px; }
}

/* uploaded participant images */
.tb-head.is-photo{ overflow:hidden; }
.tb-head.is-photo img{ width:100% !important; height:100% !important; object-fit:cover; image-rendering:auto; display:block; }
.tb-p .tb-head.is-photo{ border-color:rgba(245,197,66,0.45); }
.tb-seed-row .tb-seed-av{ width:34px; height:34px; border-radius:9px; background:rgba(0,0,0,0.35); border:1px solid rgba(120,150,220,0.35); overflow:hidden; display:flex; align-items:center; justify-content:center; flex-shrink:0; }
.tb-seed-row .tb-seed-av img{ width:28px; height:auto; image-rendering:pixelated; }
.tb-seed-row .tb-seed-av.is-photo img{ width:100%; height:100%; }
.rgh-wrap .tb-file-btn{
  position:relative; overflow:hidden; display:inline-flex; align-items:center; cursor:pointer; margin:0;
  border:1.5px solid rgba(120,150,220,0.40); background:rgba(47,123,255,0.08); color:#dbe7ff;
  font-family:var(--w-sans); font-weight:600; font-size:12px; padding:5px 10px; border-radius:10px; transition:all .18s ease;
  text-transform:none; letter-spacing:0;
}
.rgh-wrap .tb-file-btn:hover{ border-color:var(--w-blue); background:rgba(47,123,255,0.18); color:#fff; box-shadow:0 0 12px rgba(47,123,255,0.4); }
.rgh-wrap .tb-file-btn input[type=file]{ position:absolute; inset:0; opacity:0; cursor:pointer; width:100%; height:100%; }
