:root {
  --bg: #090b10;
  --bg2: #0e1219;
  --panel: #131922;
  --panel2: #18202b;
  --line: #242d3a;
  --line2: #323d4d;
  --text: #ebe6dc;
  --muted: #8a93a2;
  --dim: #5b6474;
  --gold: #d6a84e;
  --gold2: #f3d58c;
  --radiant: #5fbf6e;
  --dire: #d44a32;
  --lb: #e08a3c;
  --display: "Palatino Linotype", "Book Antiqua", Palatino, "Noto Serif", Georgia, serif;
  --sans: -apple-system, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --r: 12px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.4 var(--sans); }
body {
  min-height: 100vh;
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(212, 74, 50, .22), transparent 60%),
    radial-gradient(80% 40% at 100% 0%, rgba(214, 168, 78, .10), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
button { font: inherit; color: inherit; cursor: pointer; }
#app { max-width: 560px; margin: 0 auto; padding: 0 14px calc(84px + env(safe-area-inset-bottom)); }

/* ---------- hero ---------- */
.hero { padding: 18px 0 6px; }
.hero-top { display: flex; gap: 12px; align-items: center; }
.crest { width: 42px; height: 42px; color: var(--gold); flex: none; filter: drop-shadow(0 0 10px rgba(214,168,78,.35)); }
.crest svg { width: 100%; height: 100%; }
.eyebrow { font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
h1 { margin: 2px 0 0; font: 700 22px/1.1 var(--display); letter-spacing: .06em; text-transform: uppercase;
  background: linear-gradient(180deg, var(--gold2), var(--gold) 60%, #9b7430); -webkit-background-clip: text; background-clip: text; color: transparent; }
h2 { font: 700 13px/1 var(--display); letter-spacing: .14em; text-transform: uppercase; color: var(--gold); margin: 22px 2px 10px; display: flex; align-items: center; gap: 10px; }
h2::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--line2), transparent); }

/* ---------- next match ---------- */

.nextcard { margin-top: 16px; position: relative; border-radius: 16px; padding: 16px 14px 14px; overflow: hidden;
  background: linear-gradient(160deg, #1a1414 0%, #121820 55%, #0f1a14 100%); border: 1px solid #3a2e22;
  box-shadow: 0 10px 30px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.04); }
.nextcard::before { content: ""; position: absolute; inset: 0; background:
  linear-gradient(90deg, rgba(95,191,110,.10), transparent 40%, transparent 60%, rgba(212,74,50,.12)); pointer-events: none; }
.nextcard .tag { font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--gold); text-align: center; }
.nextcard .sub { text-align: center; color: var(--muted); font-size: 12px; margin-top: 2px; }
.vsrow { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin: 14px 0 12px; position: relative; }
.vsrow .side { display: flex; flex-direction: column; align-items: center; gap: 7px; min-width: 0; }
.vsrow .nm { font-weight: 700; font-size: 15px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vs { font: 700 20px var(--display); color: var(--gold); text-shadow: 0 0 14px rgba(214,168,78,.5); }
.when { display: flex; justify-content: center; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 99px; font-size: 12.5px;
  background: rgba(255,255,255,.05); border: 1px solid var(--line2); }
.pill.gold { color: var(--gold2); border-color: rgba(214,168,78,.45); background: rgba(214,168,78,.08); }

/* ---------- avatars ---------- */
.av { --c: #567; width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font: 700 20px var(--display); color: #fff; text-transform: uppercase;
  background: radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--c) 85%, #fff 15%), var(--c) 55%, color-mix(in srgb, var(--c) 50%, #000));
  box-shadow: 0 0 0 2px var(--ring, var(--line2)), 0 0 0 4px var(--bg2), 0 6px 18px rgba(0,0,0,.5); }
.av.r { --ring: var(--radiant); }
.av.d { --ring: var(--dire); }
.av.sm { width: 28px; height: 28px; font-size: 12px; box-shadow: 0 0 0 1.5px var(--ring, var(--line2)); }
.av.xs { width: 22px; height: 22px; font-size: 10px; box-shadow: none; }

/* ---------- cards ---------- */
.card { background: linear-gradient(180deg, var(--panel), var(--bg2)); border: 1px solid var(--line); border-radius: var(--r);
  padding: 12px; margin-bottom: 10px; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.card.hl { border-color: rgba(214,168,78,.45); box-shadow: 0 0 0 1px rgba(214,168,78,.15), 0 6px 20px rgba(0,0,0,.35); }
.mhead { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--muted);
  letter-spacing: .08em; text-transform: uppercase; }
.bo { font-weight: 700; color: var(--gold); border: 1px solid rgba(214,168,78,.35); border-radius: 5px; padding: 1px 6px; font-size: 10.5px; }
.teams { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin: 12px 0 10px; }
.team { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 600; }
.team span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team.b { flex-direction: row-reverse; text-align: right; }
.team.win span { color: var(--gold2); }
.team.lose { opacity: .45; }
.team.tbd span { color: var(--dim); font-style: italic; font-weight: 400; font-size: 12.5px; }
.score { font: 700 20px var(--display); letter-spacing: .05em; min-width: 54px; text-align: center; }
.score.tbd { color: var(--dim); font-size: 13px; font-family: var(--sans); }

.picks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pgrp { display: flex; gap: 6px; }
.pgrp.b { justify-content: flex-end; }
.pick { flex: 1; position: relative; overflow: hidden; border-radius: 9px; padding: 9px 4px 8px; text-align: center;
  background: var(--panel2); border: 1px solid var(--line2); font-weight: 700; font-size: 15px; letter-spacing: .04em;
  transition: transform .08s, border-color .15s, background .15s; }
.pick small { display: block; font-size: 10px; font-weight: 500; color: var(--muted); letter-spacing: 0; margin-top: 1px; position: relative; }
.pick b { position: relative; }
.pick:active { transform: scale(.96); }
.pick.r { border-bottom: 2px solid rgba(95,191,110,.6); }
.pick.d { border-bottom: 2px solid rgba(212,74,50,.6); }
.pick.on { background: linear-gradient(180deg, rgba(214,168,78,.28), rgba(214,168,78,.10)); border-color: var(--gold); color: var(--gold2); }
.pick.correct { border-color: var(--radiant); box-shadow: inset 0 0 0 1px var(--radiant); }
.pick[disabled] { cursor: default; }
.pick[disabled]:active { transform: none; }
.pick .bar { position: absolute; left: 0; bottom: 0; top: 0; background: rgba(255,255,255,.06); }
.mfoot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; font-size: 12px; color: var(--muted); gap: 8px; }
.badge { font-weight: 800; font-size: 11.5px; padding: 3px 8px; border-radius: 6px; letter-spacing: .04em; }
.badge.ex { background: rgba(214,168,78,.18); color: var(--gold2); }
.badge.ok { background: rgba(95,191,110,.16); color: var(--radiant); }
.badge.no { background: rgba(255,255,255,.06); color: var(--muted); }

.empty { text-align: center; color: var(--muted); padding: 26px 10px; }
.note { color: var(--muted); font-size: 12px; line-height: 1.5; }

/* champion */
.champ-list { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 6px; scrollbar-width: none; }
.champ-list::-webkit-scrollbar { display: none; }
.champ { flex: none; width: 82px; padding: 10px 4px 8px; border-radius: 12px; background: var(--panel2); border: 1px solid var(--line2);
  display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; }
.champ .av { width: 40px; height: 40px; font-size: 16px; }
.champ span { max-width: 74px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.champ.on { border-color: var(--gold); background: rgba(214,168,78,.12); color: var(--gold2); }
.champ.out { opacity: .3; }
.champ em { font-style: normal; color: var(--muted); font-size: 10.5px; font-weight: 500; }

/* banner */
.banner { display: flex; gap: 10px; align-items: center; background: rgba(214,168,78,.08); border: 1px dashed rgba(214,168,78,.45);
  border-radius: var(--r); padding: 10px 12px; margin-top: 14px; font-size: 13px; }
.banner .grow { flex: 1; }

/* ---------- buttons / inputs ---------- */
.btn { border: 0; border-radius: 10px; padding: 11px 14px; font-weight: 700; letter-spacing: .03em;
  background: linear-gradient(180deg, #e3b85e, #b8862f); color: #1b1307; box-shadow: 0 4px 14px rgba(214,168,78,.25), inset 0 1px 0 rgba(255,255,255,.35); }
.btn.ghost { background: var(--panel2); color: var(--text); border: 1px solid var(--line2); box-shadow: none; }
.btn.red { background: linear-gradient(180deg, #e0573e, #a8321f); color: #fff; box-shadow: 0 4px 14px rgba(212,74,50,.25); }
.btn.block { width: 100%; }
.btn.sm { padding: 7px 10px; font-size: 12.5px; }
select, input, textarea { font: inherit; color: var(--text); background: var(--bg2); border: 1px solid var(--line2); border-radius: 9px; padding: 8px 10px; }
select { appearance: none; -webkit-appearance: none; padding-right: 26px;
  background-image: linear-gradient(45deg, transparent 50%, var(--gold) 50%), linear-gradient(135deg, var(--gold) 50%, transparent 50%);
  background-position: calc(100% - 13px) 55%, calc(100% - 8px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
textarea { width: 100%; min-height: 80px; resize: vertical; }
input[type=datetime-local] { color-scheme: dark; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.stack > * + * { margin-top: 8px; }
label.lbl { display: block; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }

/* ---------- bracket ---------- */
.bk-wrap { overflow-x: auto; margin: 0 -14px; padding: 0 14px 6px; scrollbar-width: thin; }
.bk { display: flex; gap: 22px; min-width: max-content; }
.bk-col { display: flex; flex-direction: column; justify-content: space-around; gap: 10px; width: 168px; }
.bk-colwrap h4 { margin: 0 0 2px; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 600; text-align: center; }
.bk-colwrap { display: flex; flex-direction: column; }
.bk-colwrap .bk-col { flex: 1; }
.bm { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; overflow: visible; }
.bm.next { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(214,168,78,.25), 0 0 18px rgba(214,168,78,.18); }
.bm .id { position: absolute; top: -7px; left: 8px; font-size: 9px; font-weight: 700; padding: 0 5px; border-radius: 4px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.bm.next .id { color: var(--gold); border-color: var(--gold); }
.bm .ln { display: flex; align-items: center; gap: 7px; padding: 7px 8px; font-size: 12.5px; }
.bm .ln + .ln { border-top: 1px solid var(--line); }
.bm .ln span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bm .ln b { font-family: var(--display); min-width: 12px; text-align: right; }
.bm .ln.w span, .bm .ln.w b { color: var(--gold2); font-weight: 700; }
.bm .ln.l { opacity: .45; }
.bm .ln.t span { color: var(--dim); font-style: italic; font-size: 11.5px; }
.bk-col:not(.last) .bm::after { content: ""; position: absolute; right: -23px; top: 50%; width: 22px; height: 1px; background: var(--line2); }
.bk-title { display: flex; align-items: center; gap: 8px; font: 700 12px var(--display); letter-spacing: .14em; text-transform: uppercase; margin: 18px 0 12px; }
.bk-title i { width: 8px; height: 8px; border-radius: 2px; transform: rotate(45deg); }
.bk-title.ub { color: var(--radiant); } .bk-title.ub i { background: var(--radiant); }
.bk-title.lb { color: var(--lb); } .bk-title.lb i { background: var(--lb); }
.bk-title.gf { color: var(--gold); } .bk-title.gf i { background: var(--gold); }
.gf-box { max-width: 260px; }

/* ---------- vote ---------- */
.status { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.chip { font-size: 11.5px; padding: 4px 9px; border-radius: 99px; background: rgba(255,255,255,.05); border: 1px solid var(--line2); color: var(--muted); }
.chip.ok { color: var(--radiant); border-color: rgba(95,191,110,.4); background: rgba(95,191,110,.08); }
.chip.wait { color: var(--lb); border-color: rgba(224,138,60,.4); background: rgba(224,138,60,.08); }
.day { padding: 10px 0; border-top: 1px solid var(--line); }
.day:first-child { border-top: 0; padding-top: 2px; }
.day-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.day-h b { font-size: 14px; }
.day-h .sum { font-size: 12px; color: var(--muted); }
.day-h .sum.ok { color: var(--radiant); }
.day-h .sum.no { color: var(--dire); }
.seg { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.seg button { border: 1px solid var(--line2); background: var(--panel2); border-radius: 8px; padding: 8px 2px; font-size: 11.5px; font-weight: 600; color: var(--muted); }
.seg button.on { color: #1b1307; background: linear-gradient(180deg, #e3b85e, #b8862f); border-color: transparent; }
.seg button.no.on { color: #fff; background: linear-gradient(180deg, #d4533c, #9c2f1e); }
.hrs { display: flex; gap: 8px; align-items: center; margin-top: 8px; font-size: 13px; color: var(--muted); }
.hrs select { flex: 1; }
.sticky { position: sticky; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 5; padding-top: 6px; }

.heat { display: grid; gap: 3px; font-size: 10px; }
.heat .hl { color: var(--muted); white-space: nowrap; padding-right: 6px; display: flex; align-items: center; }
.heat .hh { color: var(--dim); text-align: center; }
.heat .c { height: 22px; border-radius: 4px; background: rgba(255,255,255,.03); position: relative; }
.heat .c.cap { box-shadow: inset 0 0 0 1.5px var(--gold); }
.heat .c.best::after { content: "★"; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 11px; text-shadow: 0 0 4px #000; }
.legend { display: flex; gap: 12px; align-items: center; font-size: 11px; color: var(--muted); margin-top: 10px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 4px; }
.best-box { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 10px; background: rgba(214,168,78,.08); border: 1px solid rgba(214,168,78,.35); margin-bottom: 12px; }
.best-box .star { font-size: 22px; color: var(--gold); }
.best-box b { color: var(--gold2); font-size: 15px; }

/* ---------- rating ---------- */
.segtabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg2); border: 1px solid var(--line); border-radius: 11px; padding: 3px; margin-top: 16px; }
.segtabs button { border: 0; background: none; padding: 9px; border-radius: 8px; font-weight: 700; color: var(--muted); font-size: 13px; }
.segtabs button.on { background: var(--panel2); color: var(--gold2); box-shadow: inset 0 0 0 1px var(--line2); }
.lb-row { display: grid; grid-template-columns: 30px 1fr auto; gap: 10px; align-items: center; padding: 10px 4px; border-top: 1px solid var(--line); }
.lb-row:first-child { border-top: 0; }
.rank { font: 700 15px var(--display); text-align: center; color: var(--muted); }
.rank.g1 { color: #f3d58c; text-shadow: 0 0 10px rgba(243,213,140,.5); }
.rank.g2 { color: #c9d1dc; }
.rank.g3 { color: #d39a6a; }
.lb-name { font-weight: 600; display: flex; align-items: center; gap: 8px; min-width: 0; }
.lb-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.pts { font: 700 20px var(--display); color: var(--gold2); text-align: right; }
.pts small { display: block; font: 500 10px var(--sans); color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.me-row { background: rgba(214,168,78,.06); border-radius: 8px; }
.ct-row { display: grid; grid-template-columns: 34px 1fr auto auto; gap: 10px; align-items: center; padding: 10px 4px; border-top: 1px solid var(--line); }
.ct-row:first-child { border-top: 0; }
.ct-row.out { opacity: .5; }
.st { font-size: 10.5px; font-weight: 700; letter-spacing: .04em; padding: 2px 7px; border-radius: 5px; display: inline-block; margin-top: 2px; }
.st.ub { color: var(--radiant); background: rgba(95,191,110,.12); }
.st.lb { color: var(--lb); background: rgba(224,138,60,.12); }
.st.out { color: var(--muted); background: rgba(255,255,255,.05); }
.st.champ { color: #1b1307; background: linear-gradient(180deg, #f3d58c, #c8963a); }
.num { text-align: center; font-size: 12px; color: var(--muted); min-width: 44px; }
.num b { display: block; color: var(--text); font-size: 15px; }
.rules { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
.rules div { text-align: center; padding: 8px 4px; border-radius: 9px; background: var(--bg2); border: 1px solid var(--line); font-size: 11px; color: var(--muted); }
.rules b { display: block; font: 700 17px var(--display); color: var(--gold2); }

/* ---------- admin ---------- */
.adm-match { padding: 10px 0; border-top: 1px solid var(--line); }
.adm-match:first-child { border-top: 0; padding-top: 0; }
.adm-match .t { font-weight: 600; margin-bottom: 8px; }
.adm-match .t small { color: var(--muted); font-weight: 400; }
.cap-edit { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; margin-bottom: 8px; }
.cap-edit input, .cap-edit select { min-width: 0; width: 100%; }

/* ---------- nav ---------- */
.tabs { position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 560px; z-index: 10;
  display: flex; padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  background: rgba(9,11,16,.92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
.tabs button { flex: 1; border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0;
  color: var(--dim); font-size: 10.5px; font-weight: 600; position: relative; }
.tabs svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tabs svg .fill { fill: currentColor; }
.tabs button.on { color: var(--gold); }
.tabs button.on::before { content: ""; position: absolute; top: -7px; width: 26px; height: 2px; border-radius: 2px; background: var(--gold); box-shadow: 0 0 10px var(--gold); }
.dot { position: absolute; top: 4px; right: calc(50% - 16px); width: 7px; height: 7px; border-radius: 50%; background: var(--dire); box-shadow: 0 0 0 2px var(--bg); display: none; }
.dot.show { display: block; }

.tab { display: none; animation: fade .2s ease; }
.tab.on { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

#toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0;
  background: #1f2732; border: 1px solid var(--line2); color: var(--text); padding: 10px 16px; border-radius: 10px; font-size: 13px; font-weight: 600;
  transition: .2s; pointer-events: none; z-index: 20; max-width: 90%; text-align: center; box-shadow: 0 8px 24px rgba(0,0,0,.5); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { border-color: var(--dire); color: #ffb4a6; }
.loading { text-align: center; color: var(--muted); padding: 60px 0; }
