:root {
  --bg: #07090d; --panel: #10141c; --panel2: #161b26; --line: #2a3242; --text: #e8ecf4; --muted: #8d97ab;
  --red: #ff3366; --gold: #ffcc00; --green: #10b981; --blue: #00f2fe; --purple: #d500f9;
  --card-w: 214px; --slot-h: 88px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg) url("bg.png") center / cover fixed; color: var(--text);
  font-family: "Rajdhani", system-ui, sans-serif; font-size: 16px; min-height: 100vh;
}
body::before { content: ""; position: fixed; inset: 0; background: rgba(5, 6, 8, .82); z-index: -1; }
button, input, select, textarea { font: inherit; color: inherit; }

/* header */
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: rgba(8, 10, 14, .92); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-family: "Teko", sans-serif; font-weight: 700; font-size: 28px; letter-spacing: 1px; }
.brand img { height: 38px; width: auto; filter: drop-shadow(0 0 6px var(--red)); }
.top-controls { display: flex; gap: 8px; flex: 1 1 260px; min-width: 0; }
#tSelect { flex: 1; min-width: 0; max-width: 460px; }
select, input[type=text], input:not([type]), input[type=password], input[type=number], textarea {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; min-width: 0;
}
select:focus, input:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.btn { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 8px 14px; cursor: pointer; font-weight: 600; white-space: nowrap; text-decoration: none; display: inline-block; }
.btn:hover { border-color: var(--blue); }
.btn.gold { border-color: var(--gold); color: var(--gold); }
.btn.red { border-color: var(--red); color: var(--red); }
.btn.green { border-color: var(--green); color: var(--green); }
.btn.small { padding: 3px 9px; font-size: 14px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.user-box { display: flex; align-items: center; gap: 10px; margin-inline-start: auto; }
.user-box img { width: 28px; height: 28px; border-radius: 50%; }
.role { font-size: 12px; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--gold); color: var(--gold); text-transform: uppercase; letter-spacing: 1px; }
.role.viewer { border-color: var(--blue); color: var(--blue); }
.link { background: none; border: 0; color: var(--muted); cursor: pointer; text-decoration: underline; padding: 4px; }
.notice { margin: 12px 16px; padding: 10px 14px; border-radius: 6px; border: 1px solid var(--red); background: rgba(255, 51, 102, .1); }
.banner { margin: 0 0 12px; padding: 9px 14px; border-radius: 6px; border: 1px solid var(--blue); background: rgba(0, 242, 254, .07); color: var(--blue); }

main { padding: 18px 16px 60px; }
.empty { text-align: center; padding: 80px 10px; color: var(--muted); }

.t-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.t-head h2 { margin: 0 0 6px; font-family: "Teko", sans-serif; font-size: 40px; line-height: 1; letter-spacing: 1px; }
.badges { display: flex; flex-wrap: wrap; gap: 8px; }
.badge { font-size: 13px; padding: 3px 10px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.badge.draft { border-color: var(--red); color: var(--red); }
.badge.live { border-color: var(--green); color: var(--green); }
.badge.reg { border-color: var(--purple); color: var(--purple); }
.admin-bar { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 14px; padding: 10px; border: 1px dashed var(--line); border-radius: 8px; }
.admin-bar .spacer { flex: 1; }

/* registration */
.reg-panel { background: var(--panel); border: 1px solid var(--purple); border-radius: 10px; padding: 16px; margin-bottom: 16px; box-shadow: 0 0 18px rgba(213, 0, 249, .12); }
.reg-panel h3 { margin: 0 0 4px; font-family: "Teko", sans-serif; font-size: 28px; color: var(--purple); letter-spacing: 1px; }
.reg-count { color: var(--muted); margin-bottom: 12px; }
.reg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; margin: 12px 0; }
.chip { display: flex; align-items: center; gap: 8px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; min-width: 0; }
.chip.mine { border-color: var(--green); }
.chip img { height: 22px; width: auto; flex: none; }
.chip .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.chip .nm small { display: block; color: var(--muted); font-size: 12px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.reg-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; margin-top: 8px; }
.reg-form .field { display: flex; flex-direction: column; gap: 4px; min-width: 190px; position: relative; }
.reg-form label { font-size: 13px; color: var(--muted); }
.pick-results { position: fixed; z-index: 50; box-shadow: 0 8px 24px #000a; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; max-height: 220px; overflow-y: auto; }
.pick-results button { display: flex; width: 100%; gap: 8px; align-items: center; background: none; border: 0; padding: 6px 10px; cursor: pointer; text-align: start; }
.pick-results button:hover { background: var(--panel); }
.pick-results img { width: 22px; height: 22px; border-radius: 50%; }
.picked { display: inline-flex; gap: 6px; align-items: center; border: 1px solid var(--green); border-radius: 99px; padding: 3px 10px; }
.good { color: var(--green); }
.bad { color: var(--red); }
.pick-results button[disabled] { opacity: .5; cursor: not-allowed; }
.warn { border: 1px solid var(--gold); background: rgba(255, 204, 0, .07); border-radius: 8px; padding: 12px 14px; margin: 6px 0 4px; }
.warn strong { color: var(--gold); font-size: 18px; }
.warn p { margin: 6px 0 10px; }
.warn-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* bracket board */
.capture { background: #050608; border: 1px solid var(--line); border-radius: 10px; padding: 22px 16px 30px; overflow-x: auto; }
.viewbar { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; }
.viewbar .btn.on { border-color: var(--blue); color: var(--blue); }
.zoomwrap { width: max-content; min-width: 100%; }
.board { width: max-content; min-width: 100%; display: flex; flex-direction: column; align-items: center; gap: 34px; }

/* the important things sit in the middle, stacked: logo + title, the final, the standings */
.hero { display: flex; flex-direction: column; align-items: center; gap: 22px; width: 100%; padding-bottom: 6px; }
.capture.tools { --slot-h: 120px; } /* editors get a "force winner" row on every card */
.hero-brand { text-align: center; }
.hero-brand img { height: 130px; width: auto; filter: drop-shadow(0 0 14px rgba(0, 110, 255, .55)); }
.hero-title { font-family: "Teko", sans-serif; font-weight: 700; font-size: 38px; line-height: 1.05; letter-spacing: 3px; text-transform: uppercase; color: var(--blue); text-shadow: 0 0 12px rgba(0, 242, 254, .45); margin-top: 8px; max-width: 360px; }
.hero-sub { color: var(--muted); letter-spacing: 2px; text-transform: uppercase; font-size: 14px; margin-top: 4px; }
.hero-final { width: 290px; }
.hero-label { font-family: "Teko", sans-serif; font-size: 22px; letter-spacing: 1.5px; text-align: center; color: var(--text); margin-bottom: 8px; }
.hero-final .match { border-color: var(--gold); box-shadow: 0 0 22px rgba(255, 204, 0, .3), inset 0 0 12px rgba(255, 204, 0, .07); }
.hero-final .match + .hero-label { margin-top: 18px; color: var(--purple); }
.standings { width: 320px; background: rgba(12, 14, 20, .88); border: 1px solid rgba(255, 51, 102, .22); border-radius: 6px; padding: 12px; }
.standings h4 { margin: 0 0 8px; text-align: center; font-family: "Teko", sans-serif; font-size: 20px; letter-spacing: 1.5px; color: var(--gold); }
.place { display: flex; align-items: center; gap: 10px; background: rgba(6, 8, 12, .9); border: 1px solid rgba(255, 255, 255, .06); border-radius: 3px; padding: 7px 10px; margin-top: 6px; }
.place .ic { font-size: 22px; width: 28px; text-align: center; flex: none; }
.place .who { flex: 1; min-width: 0; }
.place .lbl { font-family: "Teko", sans-serif; letter-spacing: 1px; font-size: 15px; line-height: 1.1; }
.place .nm { font-weight: 600; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.place .nm.set { color: var(--text); }
.place .prize { font-family: "Teko", sans-serif; font-size: 24px; font-weight: 700; margin-inline-start: auto; }
.place.p1 { border-inline-start: 4px solid var(--gold); background: linear-gradient(90deg, rgba(255, 204, 0, .12), rgba(6, 8, 12, .9)); }
.place.p1 .lbl, .place.p1 .prize { color: var(--gold); text-shadow: 0 0 6px rgba(255, 204, 0, .45); }
.place.p2 { border-inline-start: 4px solid #cbd5e1; } .place.p2 .lbl, .place.p2 .prize { color: #cbd5e1; }
.place.p3 { border-inline-start: 4px solid var(--red); background: linear-gradient(90deg, rgba(255, 51, 102, .1), rgba(6, 8, 12, .9)); } .place.p3 .lbl, .place.p3 .prize { color: var(--red); }
.place.p4 { border-inline-start: 4px solid #64748b; } .place.p4 .lbl, .place.p4 .prize { color: #94a3b8; }

.section { width: 100%; display: flex; flex-direction: column; align-items: center; }
.section > h3 { margin: 0 0 6px; font-family: "Teko", sans-serif; font-size: 26px; letter-spacing: 3px; text-transform: uppercase; color: var(--blue); }
.section.losers > h3 { color: var(--red); }
.row { position: relative; display: flex; align-items: stretch; justify-content: center; gap: 36px; }
.row svg { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.half { display: flex; align-items: stretch; gap: 36px; }
.round { display: flex; flex-direction: column; width: var(--card-w); }
.round.center { width: 262px; }
.round-title { text-align: center; font-family: "Teko", sans-serif; font-size: 17px; letter-spacing: 1px; color: var(--muted); height: 24px; direction: rtl; }
.round-matches { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.round.center .round-matches { gap: 30px; }
.slot { flex: 1 1 0; min-height: var(--slot-h); display: flex; align-items: center; }
.round.center .slot { flex: none; min-height: 0; }
.center-extra-title { margin: 26px 0 4px; text-align: center; font-family: "Teko", sans-serif; font-size: 18px; letter-spacing: 1px; color: var(--purple); direction: rtl; }
.match { width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; position: relative; }
.match > .team:first-of-type { border-radius: 5px 5px 0 0; }
.match > .team:last-of-type, .match > .force { border-radius: 0 0 5px 5px; }
.match.ready { border-color: #3a6f8a; }
.match.done { border-color: #2a4a3a; }
.match.bye { opacity: .45; }
.tag { position: absolute; top: -8px; inset-inline-end: 8px; font-family: "Teko", sans-serif; font-size: 13px; line-height: 14px; padding: 0 5px; letter-spacing: .5px; color: var(--gold); background: var(--bg); border: 1px solid #5a4a10; border-radius: 3px; }
.keybtn { position: absolute; top: -15px; inset-inline-start: 8px; font-size: 12px; line-height: 14px; padding: 0 6px; cursor: pointer; background: var(--bg); color: var(--blue); border: 1px solid #1d5a60; border-radius: 3px; font-family: inherit; }
.keybtn:hover { background: var(--panel2); }
.team { display: flex; align-items: center; gap: 7px; height: 33px; padding: 0 8px; border-top: 1px solid var(--line); }
.team:first-of-type { border-top: 0; }
.team .seed { font-size: 12px; color: var(--gold); width: 20px; text-align: center; flex: none; }
.team img.rank { height: 19px; width: auto; flex: none; }
.team .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.team .name small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); overflow: hidden; text-overflow: ellipsis; line-height: 1; margin-top: -1px; }
.team .score { min-width: 24px; text-align: center; font-weight: 700; color: var(--muted); flex: none; }
.team.pending .name { color: var(--muted); font-style: italic; font-weight: 500; font-size: 13px; direction: rtl; text-align: start; }
.team.winner { background: rgba(16, 185, 129, .13); }
.team.winner .name, .team.winner .score { color: var(--green); }
.team.loser .name { color: var(--muted); }
.team input[type=number] { width: 42px; padding: 2px 3px; text-align: center; flex: none; }
.force { width: 100%; border: 0; border-top: 1px solid var(--line); border-radius: 0; font-size: 12px; padding: 3px 6px; color: var(--muted); }
.reportbtn { display: block; width: 100%; border: 0; border-top: 1px solid var(--line); border-radius: 0 0 5px 5px; background: rgba(16, 185, 129, .12); color: var(--green); padding: 5px; cursor: pointer; font-weight: 700; font-family: inherit; }
.reportbtn:hover { background: rgba(16, 185, 129, .22); }
.reportbtn.warnbtn { background: rgba(255, 204, 0, .08); color: var(--gold); }
.disputed { position: absolute; bottom: -9px; inset-inline-end: 8px; font-size: 11px; line-height: 15px; padding: 0 6px; color: var(--red); background: var(--bg); border: 1px solid var(--red); border-radius: 3px; }
.capture.exporting .force, .capture.exporting .keybtn, .capture.exporting .reportbtn, .capture.exporting .disputed { display: none; }
.capture:not(.show-seeds) .seed { display: none; }

/* dialogs */
dialog.editor { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px; width: min(880px, 96vw); max-height: 92vh; overflow-y: auto; padding: 20px; }
dialog.editor.small { width: min(430px, 96vw); }
dialog::backdrop { background: rgba(0, 0, 0, .7); }
dialog h3 { margin: 0 0 14px; font-size: 22px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 12px; }
.grid label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
.grid label.check, label.check { flex-direction: row; align-items: center; gap: 8px; }
.grid label.check { align-self: end; }
label.auto { display: flex; margin: 8px 0; color: var(--muted); font-size: 14px; }
.prizes { display: grid; grid-template-columns: auto repeat(4, minmax(80px, 1fr)); gap: 8px; align-items: center; margin-bottom: 8px; }
.rows-head { display: flex; align-items: baseline; gap: 10px; margin: 10px 0 6px; }
.muted { color: var(--muted); font-size: 14px; }
.info { margin-inline-start: auto; color: var(--gold); font-size: 14px; }
.rows { max-height: 40vh; overflow-y: auto; display: block; padding-inline-end: 4px; }
.erow { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; flex: none; }
.erow .n { width: 28px; text-align: center; color: var(--gold); flex: none; }
.erow input.nm { flex: 2 1 150px; }
.erow input.mem { flex: 1 1 100px; }
.erow select { flex: 1 1 130px; }
.erow .btn { padding: 4px 9px; flex: none; }
.erow .tagd { font-size: 11px; color: var(--purple); border: 1px solid var(--purple); border-radius: 99px; padding: 1px 6px; flex: none; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.bulk { width: 100%; margin: 6px 0; }
.error { margin-top: 10px; color: var(--red); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.kv { display: grid; grid-template-columns: auto 1fr auto; gap: 8px 12px; align-items: center; margin: 6px 0; }
.kv code { font-family: "Teko", monospace; font-size: 26px; letter-spacing: 3px; color: var(--gold); }
.lobbies table { width: 100%; border-collapse: collapse; font-size: 15px; }
.lobbies th, .lobbies td { text-align: start; padding: 5px 8px; border-bottom: 1px solid var(--line); }
.lobbies td.pw { font-family: monospace; letter-spacing: 2px; color: var(--gold); }

@media (max-width: 640px) {
  .top { position: static; }
  .t-head h2 { font-size: 32px; }
  :root { --card-w: 196px; }
  .erow { flex-wrap: wrap; }
  .prizes { grid-template-columns: 1fr 1fr; }
  .hero-brand img { height: 90px; }
}
@media print { .top, .admin-bar, .force, .keybtn { display: none !important; } }

/* ---- additions: rank icons everywhere, history, bans, invitations, best-of stages, preview ---- */
img.rank { height: 18px; width: auto; max-width: 28px; flex: none; vertical-align: middle; object-fit: contain; } /* default size for a rank icon anywhere (the originals are huge) */
.btn.on { border-color: var(--blue); color: var(--blue); }
.banner.preview { border-color: var(--gold); color: var(--gold); background: rgba(255, 204, 0, .08); font-weight: 700; }
.match.predicted { border-style: dashed; border-color: var(--gold); opacity: .9; }
.match.predicted .team.winner { background: rgba(255, 204, 0, .1); }

.history h2 { font-family: "Teko", sans-serif; font-size: 36px; margin: 0 0 4px; }
table.hist { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
table.hist th, table.hist td { text-align: start; padding: 9px 12px; border-bottom: 1px solid var(--line); }
table.hist th { color: var(--muted); font-size: 13px; letter-spacing: 1px; text-transform: uppercase; }
table.hist tbody tr { cursor: pointer; }
table.hist tbody tr:hover, table.hist tbody tr:focus { background: var(--panel2); outline: none; }
table.hist td.champ { color: var(--gold); font-weight: 700; }

.pending-box { border: 1px solid var(--purple); background: rgba(213, 0, 249, .06); border-radius: 8px; padding: 12px 14px; margin: 6px 0; }
.pending-box ul { margin: 8px 0; padding-inline-start: 18px; }
.pending-box.invite { border-color: var(--green); background: rgba(16, 185, 129, .07); }
.pending-admin { margin-top: 14px; padding-top: 10px; border-top: 1px dashed var(--line); }
.pend-row { margin: 6px 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.warn.bad-box { border-color: var(--red); background: rgba(255, 51, 102, .07); }
.warn.bad-box strong { color: var(--red); }

details.stages { margin: 6px 0 10px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
details.stages summary { cursor: pointer; font-weight: 600; }
.stage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px 12px; margin-top: 10px; }
.stage { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--muted); }
.field-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }

.ban-add { display: grid; grid-template-columns: 1.2fr 1.4fr auto; gap: 8px; margin: 10px 0; }
.ban-results { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.ban-hit { display: flex; align-items: center; gap: 10px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel2); }
.ban-hit img:not(.rank) { width: 24px; height: 24px; border-radius: 50%; }
.ban-hit span[dir] { flex: 1; font-weight: 600; }
dialog h4 { margin: 14px 0 6px; }

.pcell { position: relative; flex: 1 1 140px; min-width: 120px; display: inline-flex; }
.pcell input { width: 100%; }
.erow .picked { flex: 1 1 140px; min-width: 120px; justify-content: space-between; }
.erow .picked .link { margin-inline-start: auto; }
@media (max-width: 640px) { .ban-add { grid-template-columns: 1fr; } }
