:root {
  --bg: #07090c;
  --surface: #11151a;
  --surface-2: #181d24;
  --surface-3: #212833;
  --line: #262e39;
  --text: #eef2f6;
  --muted: #8b95a5;
  --faint: #5b6574;
  --accent: #46e3b7;
  --accent-ink: #03140e;
  --a: #46e3b7;
  --b: #79a6ff;
  --in: #3ddc84;
  --out: #ff5d5d;
  --close: #ffb547;
  --radius: 20px;
  --radius-sm: 14px;
  --display: "Barlow Condensed", "SF Compact Display", "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--body); font-size: 15px; }
body { min-height: 100dvh; overscroll-behavior-y: none; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
button:disabled { opacity: .35; cursor: default; }
input, select { font: inherit; color: var(--text); }
svg.i { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- layout ---------- */
.page { max-width: 560px; margin: 0 auto; padding: calc(var(--safe-top) + 10px) 16px calc(var(--safe-bottom) + 110px); }
.page.wide { max-width: 1400px; }
.topbar { display: flex; align-items: center; gap: 10px; min-height: 52px; margin-bottom: 6px; }
.topbar .title { flex: 1; text-align: center; min-width: 0; }
.topbar .title b { display: block; font-family: var(--display); font-size: 22px; letter-spacing: .3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .title span { color: var(--muted); font-size: 12px; }
.round { width: 42px; height: 42px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; flex: none; }
.round:active { background: var(--surface-3); }
.h1 { font-family: var(--display); font-weight: 800; font-size: 40px; line-height: 1; margin: 18px 0 6px; letter-spacing: .2px; }
.h2 { font-family: var(--display); font-weight: 700; font-size: 22px; margin: 26px 2px 10px; color: var(--text); }
.sub { color: var(--muted); line-height: 1.45; }
.card { background: var(--surface); border-radius: var(--radius); padding: 16px; }
.row { display: flex; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.stack > * + * { margin-top: 12px; }

/* ---------- chips, buttons ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; background: var(--surface-2);
  font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.chip.live { color: #ff6b6b; background: rgba(255, 93, 93, .12); }
.chip.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #ff5d5d; animation: blink 1.4s infinite; }
.chip.ok { color: var(--accent); background: rgba(70, 227, 183, .12); }
.chip.warn { color: var(--close); background: rgba(255, 181, 71, .12); }
.chip.bad { color: var(--out); background: rgba(255, 93, 93, .12); }
@keyframes blink { 50% { opacity: .25; } }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 50px; padding: 0 20px; border-radius: 999px;
  background: var(--surface-2); font-weight: 600; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.block { width: 100%; }
.btn.sm { height: 38px; padding: 0 14px; font-size: 13.5px; }
.seg { display: flex; background: var(--surface-2); border-radius: 999px; padding: 4px; gap: 4px; }
.seg button { flex: 1; height: 38px; border-radius: 999px; font-weight: 600; font-size: 14px; color: var(--muted); }
.seg button.on { background: var(--surface-3); color: var(--text); box-shadow: 0 1px 0 rgba(255,255,255,.04) inset; }

/* ---------- home ---------- */
.brand { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.brand img { width: 40px; height: 40px; border-radius: 11px; }
.brand b { font-family: var(--display); font-size: 26px; letter-spacing: .4px; }
.hero-actions { display: grid; gap: 12px; margin-top: 18px; }
.big-action { display: flex; align-items: center; gap: 14px; padding: 18px; border-radius: var(--radius); background: var(--surface); text-align: left; }
.big-action .ic { width: 50px; height: 50px; border-radius: 15px; display: grid; place-items: center; background: var(--surface-2); }
.big-action.hot { background: linear-gradient(135deg, rgba(70,227,183,.18), rgba(70,227,183,.04)); outline: 1px solid rgba(70,227,183,.28); }
.big-action.hot .ic { background: var(--accent); color: var(--accent-ink); }
.big-action b { display: block; font-size: 17px; margin-bottom: 3px; }
.big-action span { color: var(--muted); font-size: 13px; }
.match-item { display: flex; gap: 12px; align-items: center; padding: 14px 16px; background: var(--surface); border-radius: var(--radius-sm); }
.match-item + .match-item { margin-top: 10px; }
.match-item .names { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.match-item .sc { font-family: var(--display); font-size: 26px; font-weight: 700; }

/* ---------- form ---------- */
.field { display: block; margin-top: 14px; }
.field > span { display: block; color: var(--muted); font-size: 12.5px; font-weight: 600; margin: 0 4px 7px; text-transform: uppercase; letter-spacing: .6px; }
.input { width: 100%; height: 50px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); padding: 0 14px; outline: none; }
.input:focus { border-color: var(--accent); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.team-tag { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.dropzone { display: grid; place-items: center; text-align: center; gap: 8px; padding: 34px 16px; border-radius: var(--radius); border: 1.5px dashed var(--line); background: var(--surface); }
.dropzone.has { border-color: var(--accent); border-style: solid; }
.or { display: flex; align-items: center; gap: 10px; margin: 14px 4px 0; color: var(--muted); font-size: 12.5px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.linkfield { position: relative; }
.linkfield > .i { position: absolute; left: 14px; top: 16px; color: var(--muted); pointer-events: none; }
.linkfield > .input { padding-left: 42px; }
.progress { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .3s; }

/* ---------- match: stage ---------- */
.stage { position: relative; border-radius: var(--radius); overflow: hidden; background: #000; aspect-ratio: 16 / 9; }
.stage.square { aspect-ratio: 1; }
.stage video, .stage img { width: 100%; height: 100%; object-fit: cover; display: block; background: #000; }
.stage .empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--muted); padding: 20px; background: radial-gradient(circle at 50% 40%, #121820, #05070a); }
.stage .tags { position: absolute; left: 10px; right: 10px; top: 10px; display: flex; gap: 6px; justify-content: space-between; pointer-events: none; }
.stage .tags > div { display: flex; gap: 6px; flex-wrap: wrap; min-width: 0; }
.stage .tags > div:last-child { justify-content: flex-end; }
.stage .tags .chip { background: rgba(7, 9, 12, .72); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); pointer-events: auto; }
.stage .ctrls { position: absolute; left: 10px; right: 10px; bottom: 10px; display: flex; gap: 6px; justify-content: space-between; align-items: flex-end; }
.pill-seg { display: flex; background: rgba(7, 9, 12, .72); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-radius: 999px; padding: 3px; }
.pill-seg button { height: 30px; padding: 0 11px; border-radius: 999px; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.pill-seg button.on { background: rgba(255, 255, 255, .14); color: var(--text); }
.stage canvas.overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.stage .replay-chip { display: inline-flex; align-items: center; gap: 4px; color: var(--text); font-weight: 700; cursor: pointer; }
.stage .poster { position: absolute; inset: 0; display: block; width: 100%; height: 100%; padding: 0; border: 0; background: #000; cursor: pointer; }
.stage .poster .play { position: absolute; left: 50%; top: 50%; width: 64px; height: 64px; margin: -32px 0 0 -32px; border-radius: 50%;
  display: grid; place-items: center; background: rgba(7, 9, 12, .62); color: #fff; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.flash { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; animation: flash 1.6s ease-out forwards; }
.flash b { font-family: var(--display); font-size: 92px; font-weight: 800; letter-spacing: 2px; text-shadow: 0 4px 30px rgba(0,0,0,.6); }
@keyframes flash { 0% { opacity: 0; transform: scale(1.3); } 12% { opacity: 1; transform: scale(1); } 75% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- match: scoreboard ---------- */
.board { margin-top: 12px; background: var(--surface); border-radius: var(--radius); padding: 14px 14px 10px; }
.board-meta { display: flex; gap: 6px; align-items: center; margin: 0 2px 8px; flex-wrap: wrap; }
.team-row { display: grid; grid-template-columns: 5px 1fr auto 76px; align-items: center; gap: 12px; padding: 8px 2px; }
.team-row + .team-row { border-top: 1px solid var(--line); }
.team-row .bar { height: 44px; border-radius: 4px; background: var(--a); }
.team-row.b .bar { background: var(--b); }
.team-row .name { font-weight: 700; font-size: 16.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.team-row .who-sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; display: flex; align-items: center; gap: 5px; min-height: 16px; }
.team-row .serve { color: var(--accent); }
.team-row.b .serve { color: var(--b); }
.pips { display: flex; gap: 5px; }
.pips i { width: 9px; height: 9px; border-radius: 50%; background: var(--surface-3); }
.team-row.a .pips i.on { background: var(--a); }
.team-row.b .pips i.on { background: var(--b); }
.pts { font-family: var(--display); font-weight: 800; font-size: 60px; line-height: .9; text-align: right; font-variant-numeric: tabular-nums; }
.pts.bump { animation: bump .45s ease-out; }
@keyframes bump { 30% { transform: scale(1.18); color: var(--accent); } }

.actions { display: grid; grid-template-columns: 1.3fr 1fr 1fr 1fr 1.3fr; gap: 8px; margin-top: 12px; }
.actions button { height: 62px; border-radius: 18px; background: var(--surface); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.actions button:active { background: var(--surface-2); }
.actions .pt { font-family: var(--display); font-size: 26px; font-weight: 800; color: var(--accent-ink); }
.actions .pt small { font-family: var(--body); font-size: 11px; font-weight: 700; opacity: .8; }
.actions .pt.a { background: var(--a); }
.actions .pt.b { background: var(--b); color: #06122a; }

/* ---------- call card ---------- */
.callcard { margin-top: 12px; border-radius: var(--radius); padding: 14px; background: var(--surface); display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; align-items: center; }
.verdict { font-family: var(--display); font-weight: 800; font-size: 34px; padding: 6px 14px; border-radius: 14px; line-height: 1; letter-spacing: 1px; }
.v-IN { color: var(--in); background: rgba(61, 220, 132, .12); }
.v-OUT { color: var(--out); background: rgba(255, 93, 93, .12); }
.v-CLOSE { color: var(--close); background: rgba(255, 181, 71, .12); }
.callcard .what b { font-size: 15.5px; }
.callcard .what div { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.callcard .btns { grid-column: 1 / -1; display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.status-note { grid-column: 1 / -1; font-size: 12.5px; color: var(--close); }

/* ---------- lists ---------- */
.tabs { margin-top: 18px; }
.list { margin-top: 12px; }
.li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface); border-radius: var(--radius-sm); }
.li + .li { margin-top: 8px; }
.li .n { width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); font-weight: 700; font-size: 13px; color: var(--muted); }
.li .sc { font-family: var(--display); font-size: 22px; font-weight: 700; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.a { background: var(--a); }
.dot.b { background: var(--b); }
.thumbs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 12px; }
.thumb { position: relative; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); aspect-ratio: 16 / 10; text-align: left; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: .9; }
.thumb .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 26px 10px 8px; background: linear-gradient(transparent, rgba(0,0,0,.85)); font-size: 12px; }
.thumb .cap b { font-family: var(--display); font-size: 20px; display: block; letter-spacing: .5px; }
.thumb .badge { position: absolute; top: 8px; left: 8px; }
.empty-note { text-align: center; color: var(--muted); padding: 28px 10px; background: var(--surface); border-radius: var(--radius-sm); line-height: 1.5; }

/* ---------- tab bar ---------- */
.tabbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-bottom) + 14px); display: flex; gap: 4px; padding: 6px; border-radius: 999px;
  background: rgba(24, 29, 36, .86); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: 0 10px 40px rgba(0,0,0,.45); z-index: 20; }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 74px; padding: 8px 12px; border-radius: 999px; font-size: 11px; font-weight: 600; color: var(--muted); }
.tabbar a.on { background: rgba(255, 255, 255, .09); color: var(--text); }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .92); display: flex; flex-direction: column; padding: calc(var(--safe-top) + 10px) 14px calc(var(--safe-bottom) + 16px); }
.modal .stage { margin: auto 0; aspect-ratio: auto; max-height: 72vh; }
.modal .stage video { object-fit: contain; max-height: 72vh; }

/* ---------- toasts ---------- */
#toasts { position: fixed; top: calc(var(--safe-top) + 10px); left: 0; right: 0; display: grid; justify-items: center; gap: 8px; z-index: 80; pointer-events: none; }
.toast { max-width: 520px; margin: 0 14px; padding: 12px 16px; border-radius: 16px; background: rgba(33, 40, 51, .96); box-shadow: 0 10px 30px rgba(0,0,0,.4); font-size: 13.5px; line-height: 1.4; animation: tin .25s ease-out; }
.toast.warn { border-left: 4px solid var(--close); }
@keyframes tin { from { transform: translateY(-12px); opacity: 0; } }

/* ---------- connect ---------- */
.qr-card { display: grid; grid-template-columns: 112px 1fr; gap: 14px; align-items: center; background: var(--surface); border-radius: var(--radius); padding: 14px; }
.qr-card + .qr-card { margin-top: 10px; }
.qr-card img { width: 112px; height: 112px; border-radius: 12px; background: #fff; padding: 4px; }
.qr-card b { display: block; font-size: 16px; margin-bottom: 4px; }

/* ---------- camera mode ---------- */
.cam { position: fixed; inset: 0; background: #000; }
.cam video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.cam canvas.overlay { position: absolute; inset: 0; width: 100%; height: 100%; }
.cam .hud { position: absolute; top: calc(var(--safe-top) + 10px); left: 12px; right: 12px; display: flex; gap: 8px; align-items: center; }
.cam .hud .chip { background: rgba(7, 9, 12, .7); }
.cam .score-mini { margin-left: auto; font-family: var(--display); font-size: 26px; font-weight: 800; padding: 4px 14px; border-radius: 14px; background: rgba(7, 9, 12, .7); }
.cam .foot { position: absolute; left: 12px; right: 12px; bottom: calc(var(--safe-bottom) + 12px); display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.cam .help { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); max-width: 340px; text-align: center; padding: 18px; border-radius: 18px; background: rgba(7, 9, 12, .78); line-height: 1.5; }

/* ---------- monitor (laptop / TV) ---------- */
.monitor { display: grid; grid-template-columns: minmax(340px, 0.9fr) 1.4fr; gap: 16px; align-items: start; }
.monitor .pts { font-size: 120px; }
.monitor .team-row { grid-template-columns: 8px 1fr auto 150px; }
.monitor .team-row .bar { height: 90px; }
.monitor .team-row .name { font-size: 26px; }
.monitor .stage { aspect-ratio: 16 / 9; }
@media (max-width: 900px) { .monitor { grid-template-columns: 1fr; } .monitor .pts { font-size: 84px; } .monitor .team-row { grid-template-columns: 6px 1fr auto 104px; } }
@media (min-width: 700px) { .thumbs { grid-template-columns: repeat(3, 1fr); } }
