/* ==========================================================================
   Sports app - mobile first, clean "super-app" style UI.
   Theme: html[data-theme=light|dark]; sport palette: --c1/--c2 (light)
   and --dc1/--dc2 (dark) set per page from the Sport model.
   ========================================================================== */

:root {
  --c1: #1677FF; --c2: #00C2FF; --dc1: #3C8CFF; --dc2: #2FD0FF; --on: #FFFFFF;
  --g1: var(--c1); --g2: var(--c2);
  --grad: linear-gradient(120deg, var(--g1), var(--g2));
  --brand: var(--g1);

  --bg: #F4F5F7;
  --card: #FFFFFF;
  --card-2: #F5F6F8;
  --card-3: #EDEFF2;
  --text: #15181E;
  --text-2: #5E6570;
  --text-3: #9BA1AB;
  --line: #EEF0F3;
  --overlay: rgba(10, 12, 16, .45);
  --shadow: 0 2px 10px rgba(22, 28, 45, .05), 0 8px 24px rgba(22, 28, 45, .04);
  --shadow-lg: 0 12px 40px rgba(22, 28, 45, .16);
  --success: #12B76A; --success-bg: #E8F8F0;
  --danger: #F5414A;  --danger-bg: #FEECEC;
  --warn: #F59E0B;    --warn-bg: #FEF5E6;
  --gold: #F5B301; --silver: #A3ADBA; --bronze: #D9894A;

  --r-sm: 10px; --r: 16px; --r-lg: 22px;
  --tabbar-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Helvetica Neue", "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
  --font-num: "DIN Alternate", "DIN Pro", "Bahnschrift", "Roboto Condensed", var(--font);
  color-scheme: light;
}

html[data-theme="dark"] {
  --g1: var(--dc1); --g2: var(--dc2);
  --bg: #0D0F13;
  --card: #171A20;
  --card-2: #1F232A;
  --card-3: #282D35;
  --text: #ECEEF2;
  --text-2: #A3AAB6;
  --text-3: #6C737F;
  --line: #242830;
  --overlay: rgba(0, 0, 0, .6);
  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 6px 20px rgba(0, 0, 0, .25);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, .55);
  --success-bg: rgba(18, 183, 106, .14);
  --danger-bg: rgba(245, 65, 74, .15);
  --warn-bg: rgba(245, 158, 11, .14);
  color-scheme: dark;
}

/* brand wordmark face, self-hosted (Barlow ExtraBold Italic, latin subset) */
@font-face { font-family: "Bisai Brand"; src: url("../fonts/barlow-800-italic-latin.woff2") format("woff2"); font-style: italic; font-weight: 800; font-display: swap; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 var(--font); letter-spacing: .1px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh; min-height: 100dvh;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: 0; }
p { margin: 0; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.center { text-align: center; }
.hidden { display: none !important; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ic { flex: none; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.ic.fill { fill: currentColor; stroke: none; }

/* -- app shell -------------------------------------------------------------- */
.app { max-width: 560px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; position: relative;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 20px); }
.app.no-tabbar { padding-bottom: calc(var(--safe-b) + 24px); }
@media (min-width: 600px) {
  body { background: var(--card-3); }
  .app { background: var(--bg); box-shadow: 0 0 0 1px var(--line); }
}

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 8px;
  height: calc(52px + var(--safe-t)); padding: var(--safe-t) 8px 0;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(18px); -webkit-backdrop-filter: saturate(180%) blur(18px);
}
.topbar h1 { font-size: 17px; font-weight: 650; flex: 1; text-align: center; padding: 0 4px; }
.topbar .tb-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; border: 0; background: none; cursor: pointer; color: var(--text); }
.topbar .tb-btn:active { background: var(--card-3); }
.topbar.on-grad { background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; color: var(--on); position: absolute; left: 0; right: 0; }
.topbar.on-grad .tb-btn { color: var(--on); }

.page { padding: 4px 16px 0; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 22px 4px 10px; }
.section-title h2 { font-size: 17px; }
.section-title a { font-size: 13px; color: var(--text-2); display: inline-flex; align-items: center; gap: 2px; }

/* -- hero (gradient header with floating cards) ---------------------------- */
.hero {
  position: relative; color: var(--on); background: var(--grad);
  padding: calc(14px + var(--safe-t)) 18px 64px; border-radius: 0 0 28px 28px; overflow: hidden;
}
.hero::before, .hero::after { content: ""; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .12); pointer-events: none; }
.hero::before { width: 240px; height: 240px; right: -70px; top: -90px; }
.hero::after { width: 140px; height: 140px; right: 70px; bottom: -80px; background: rgba(255, 255, 255, .08); }
.hero > * { position: relative; z-index: 1; }
.hero .hello { font-size: 13px; opacity: .85; }
.hero .title { font-size: 24px; font-weight: 750; margin-top: 2px; }
.hero-top { display: flex; align-items: center; justify-content: space-between; }
.hero-actions { display: flex; gap: 6px; }
.hero-actions a, .hero-actions button { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: rgba(255, 255, 255, .18); border: 0; color: var(--on); cursor: pointer; position: relative; }
.float-up { margin-top: -46px; position: relative; z-index: 2; }

/* -- sport switcher chips --------------------------------------------------- */
.sport-chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 16px -18px 0; padding: 0 18px; }
.sport-chips::-webkit-scrollbar { display: none; }
.sport-chip { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px 0 10px; border-radius: 17px;
  background: rgba(255, 255, 255, .18); color: var(--on); font-weight: 600; font-size: 14px; border: 0; cursor: pointer; }
.sport-chip.active { background: #FFFFFF; color: #15181E; box-shadow: 0 4px 12px rgba(0, 0, 0, .12); }
.sport-chip .ic { width: 18px; height: 18px; }
.sport-chip.active .ic { color: var(--c1); }

/* sport badge with the sport's own gradient (used in lists) */
.sport-dot { width: 34px; height: 34px; flex: none; border-radius: 11px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--sc1, var(--g1)), var(--sc2, var(--g2))); }
.sport-dot .ic { width: 19px; height: 19px; }
html[data-theme="dark"] .sport-dot { background: linear-gradient(135deg, var(--sdc1, var(--g1)), var(--sdc2, var(--g2))); }

/* -- cards ----------------------------------------------------------------- */
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; }
.card + .card { margin-top: 12px; }
.card.flush { padding: 0; overflow: hidden; }
.card-title { font-size: 15px; font-weight: 650; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-title .faint { font-weight: 400; font-size: 12px; }

/* stat row (elo tiles) */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.stat { text-align: center; padding: 4px 0; position: relative; }
.stat + .stat::before { content: ""; position: absolute; left: -2px; top: 18%; bottom: 18%; width: 1px; background: var(--line); }
.stat .v { font-family: var(--font-num); font-size: 26px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat .v.brand { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat .l { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* quick actions grid */
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.quick a { display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 6px 0; font-size: 12.5px; color: var(--text-2); }
.quick .qi { width: 46px; height: 46px; border-radius: 15px; display: grid; place-items: center; color: var(--g1);
  background: color-mix(in srgb, var(--g1) 12%, var(--card)); }
.quick .qi.solid { background: var(--grad); color: var(--on); box-shadow: 0 6px 16px color-mix(in srgb, var(--g1) 35%, transparent); }

/* -- list rows ------------------------------------------------------------- */
.list { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.li { display: flex; align-items: center; gap: 12px; padding: 13px 16px; position: relative; min-height: 56px; }
.li + .li::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: 1px; background: var(--line); }
a.li:active, button.li:active { background: var(--card-2); }
button.li { width: 100%; border: 0; background: none; text-align: left; cursor: pointer; }
.li .t { font-weight: 600; font-size: 15px; }
.li .s { font-size: 12.5px; color: var(--text-3); margin-top: 1px; }
.li .chev { color: var(--text-3); width: 18px; height: 18px; }
.li .end { margin-left: auto; text-align: right; flex: none; }
.empty { padding: 28px 16px; text-align: center; color: var(--text-3); font-size: 14px; }
.empty .ic { width: 40px; height: 40px; margin-bottom: 6px; opacity: .6; }

/* -- avatars --------------------------------------------------------------- */
.av { --s: 36px; width: var(--s); height: var(--s); flex: none; border-radius: 50%; display: inline-grid; place-items: center;
  color: #fff; font-weight: 650; font-size: calc(var(--s) * .38); letter-spacing: .3px; object-fit: cover; vertical-align: middle; user-select: none; }
.av-stack { display: inline-flex; }
.av-stack .av { box-shadow: 0 0 0 2px var(--card); }
.av-stack .av + .av { margin-left: -10px; }

/* -- buttons --------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 48px; padding: 0 22px; border-radius: 24px;
  border: 0; font-size: 16px; font-weight: 650; cursor: pointer; white-space: nowrap; transition: transform .08s, opacity .15s, box-shadow .15s; }
.btn:active { transform: scale(.98); }
.btn[disabled], .btn.disabled { opacity: .45; pointer-events: none; }
.btn.block { display: flex; width: 100%; }
.btn.sm { height: 34px; padding: 0 14px; font-size: 13.5px; border-radius: 17px; gap: 5px; }
.btn.md { height: 40px; padding: 0 18px; font-size: 14.5px; border-radius: 20px; }
.btn-primary { background: var(--grad); color: var(--on); box-shadow: 0 8px 20px -6px color-mix(in srgb, var(--g1) 60%, transparent); }
.btn-soft { background: color-mix(in srgb, var(--g1) 12%, var(--card)); color: var(--g1); }
.btn-ghost { background: var(--card-2); color: var(--text); }
.btn-outline { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1px var(--card-3); }
.btn-danger { background: linear-gradient(120deg, #FF5A5F, #E5262F); color: #fff; box-shadow: 0 8px 20px -6px rgba(229, 38, 47, .55); }
.btn-danger-soft { background: var(--danger-bg); color: var(--danger); }
.btn-success { background: linear-gradient(120deg, #22C77F, #0FA968); color: #fff; }
.btn .ic { width: 19px; height: 19px; }
.btn-row { display: flex; gap: 10px; }
.btn-row > .btn { flex: 1; }
.link { color: var(--g1); font-weight: 600; background: none; border: 0; padding: 0; cursor: pointer; }

/* -- chips / badges -------------------------------------------------------- */
.chip { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 12px; font-weight: 600;
  background: var(--card-2); color: var(--text-2); white-space: nowrap; }
.chip.brand { background: color-mix(in srgb, var(--g1) 13%, var(--card)); color: var(--g1); }
.chip.green { background: var(--success-bg); color: var(--success); }
.chip.red { background: var(--danger-bg); color: var(--danger); }
.chip.amber { background: var(--warn-bg); color: var(--warn); }
.chip .ic { width: 13px; height: 13px; }
.badge { position: absolute; top: -3px; right: -5px; min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 700; display: grid; place-items: center; box-shadow: 0 0 0 2px var(--card); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 0 rgba(18, 183, 106, .6); animation: pulse 1.8s infinite; display: inline-block; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(18, 183, 106, 0); } 100% { box-shadow: 0 0 0 0 rgba(18, 183, 106, 0); } }

/* -- segmented control & tabs --------------------------------------------- */
.seg { display: flex; background: var(--card-3); border-radius: 12px; padding: 3px; gap: 2px; }
.seg a, .seg button { flex: 1; text-align: center; height: 34px; line-height: 34px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--text-2); border: 0; background: none; cursor: pointer; white-space: nowrap; padding: 0 8px; }
.seg .on { background: var(--card); color: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, .08); }
.tabs { display: flex; gap: 22px; overflow-x: auto; scrollbar-width: none; padding: 0 4px; border-bottom: 1px solid var(--line); }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; position: relative; padding: 12px 0 11px; border: 0; background: none; font-size: 15px; font-weight: 600; color: var(--text-3); cursor: pointer; }
.tabs button.on { color: var(--text); }
.tabs button.on::after { content: ""; position: absolute; left: 50%; bottom: -1px; width: 20px; height: 3px; margin-left: -10px; border-radius: 2px; background: var(--grad); }
.tab-panel { display: none; }
.tab-panel.on { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* -- forms ----------------------------------------------------------------- */
.field { margin-bottom: 14px; }
.field > label, .label { display: block; font-size: 13px; color: var(--text-2); margin: 0 2px 6px; font-weight: 500; }
.input, .field input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=hidden]), .field select, .field textarea,
.auth-card input:not([type=checkbox]):not([type=radio]):not([type=hidden]), .auth-card select {
  width: 100%; height: 48px; padding: 0 14px; border-radius: 12px; border: 1.5px solid transparent; background: var(--card-2);
  outline: none; transition: border-color .15s, background .15s; -webkit-appearance: none; appearance: none; }
.field textarea { height: auto; min-height: 84px; padding: 12px 14px; resize: vertical; }
.field select, select.input { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%239BA1AB' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m1 1.5 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus, .auth-card input:focus { border-color: var(--g1); background: var(--card); }
.field .help, .helptext { font-size: 12px; color: var(--text-3); margin: 5px 2px 0; display: block; }
.errorlist { list-style: none; margin: 6px 2px 0; padding: 0; color: var(--danger); font-size: 13px; }
.form-error { background: var(--danger-bg); color: var(--danger); padding: 10px 14px; border-radius: 12px; font-size: 14px; margin-bottom: 14px; }
.form-error .errorlist { margin: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* toggle rows (checkbox as iOS-style switch) */
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; cursor: pointer; }
.toggle + .toggle { border-top: 1px solid var(--line); }
.toggle .t { font-weight: 550; }
.toggle .s { font-size: 12.5px; color: var(--text-3); }
.switch { position: relative; flex: none; width: 50px; height: 30px; -webkit-appearance: none; appearance: none; border-radius: 15px; background: var(--card-3); cursor: pointer; transition: background .2s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0, 0, 0, .2); transition: transform .2s; }
.switch:checked { background: var(--grad); }
.switch:checked::after { transform: translateX(20px); }

/* option cards (radio choices) */
.options { display: grid; gap: 10px; }
.options.two { grid-template-columns: 1fr 1fr; }
.opt { position: relative; display: block; padding: 14px; border-radius: 14px; background: var(--card-2); border: 1.5px solid transparent; cursor: pointer; }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt .t { font-weight: 650; display: flex; align-items: center; gap: 8px; }
.opt .s { font-size: 12.5px; color: var(--text-3); margin-top: 3px; }
.opt:has(input:checked) { border-color: var(--g1); background: color-mix(in srgb, var(--g1) 8%, var(--card)); }
.opt:has(input:checked) .t { color: var(--g1); }
.opt .ic { width: 20px; height: 20px; }

/* stepper (number of courts) */
.stepper { display: inline-flex; align-items: center; background: var(--card-2); border-radius: 12px; height: 44px; }
.stepper button { width: 44px; height: 44px; border: 0; background: none; font-size: 22px; color: var(--g1); cursor: pointer; }
.stepper input { width: 46px; text-align: center; border: 0; background: none; font-size: 17px; font-weight: 700; outline: none; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }

/* -- tables (leaderboards) -------------------------------------------------- */
.board { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.board th { font-size: 11.5px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .4px; padding: 10px 6px; text-align: right; white-space: nowrap; }
.board th:first-child, .board td:first-child { padding-left: 14px; text-align: center; width: 40px; }
.board th.l, .board td.l { text-align: left; }
.board th:last-child, .board td:last-child { padding-right: 16px; }
.board td { padding: 10px 6px; text-align: right; border-top: 1px solid var(--line); font-size: 14px; white-space: nowrap; }
.board td.who { width: 100%; max-width: 0; }
.board .who-in { display: flex; align-items: center; gap: 10px; min-width: 0; }
.board .who-in .n { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .who-in .sub { font-size: 12px; color: var(--text-3); }
.board .key { font-weight: 750; font-size: 15.5px; font-family: var(--font-num); }
.board tr.me td { background: color-mix(in srgb, var(--g1) 7%, transparent); }
.rank { width: 24px; height: 24px; border-radius: 8px; display: inline-grid; place-items: center; font-size: 13px; font-weight: 750; color: var(--text-2); font-family: var(--font-num); }
.rank.r1 { background: linear-gradient(135deg, #FFD54A, #F5A300); color: #fff; }
.rank.r2 { background: linear-gradient(135deg, #CFD6DF, #98A3B1); color: #fff; }
.rank.r3 { background: linear-gradient(135deg, #F2B27C, #CF7A3B); color: #fff; }
.delta.up { color: var(--success); }
.delta.down { color: var(--danger); }

/* podium for top-3 */
.podium { display: grid; grid-template-columns: 1fr 1.15fr 1fr; align-items: end; gap: 8px; padding: 6px 4px 0; }
.podium .p { text-align: center; }
.podium .p .av { box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--ring, var(--silver)); }
.podium .p .n { font-weight: 650; font-size: 13.5px; margin-top: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium .p .e { font-family: var(--font-num); font-weight: 750; font-size: 18px; }
.podium .block { margin-top: 8px; border-radius: 12px 12px 0 0; background: var(--card-2); display: grid; place-items: center; font-family: var(--font-num); font-weight: 800; font-size: 22px; color: var(--text-3); }
.podium .p1 { --ring: var(--gold); } .podium .p1 .block { height: 64px; background: linear-gradient(180deg, color-mix(in srgb, var(--gold) 26%, var(--card)), var(--card-2)); color: var(--gold); }
.podium .p2 .block { height: 44px; } .podium .p3 { --ring: var(--bronze); } .podium .p3 .block { height: 32px; }

/* -- games / courts --------------------------------------------------------- */
.court { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.court + .court { margin-top: 12px; }
.court-h { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; font-size: 13px; font-weight: 650; color: var(--text-2); background: var(--card-2); }
.court-h .ic { width: 16px; height: 16px; }
.team { display: flex; align-items: center; gap: 10px; padding: 11px 14px; }
.team + .team { border-top: 1px dashed var(--line); }
.team .names { flex: 1; min-width: 0; }
.team .names div { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team .sc { font-family: var(--font-num); font-size: 26px; font-weight: 750; min-width: 34px; text-align: right; color: var(--text-3); }
.team.win .sc { color: var(--text); }
.team.win .names div:first-child::after { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--g1); margin-left: 6px; vertical-align: middle; }
.court-f { display: flex; gap: 8px; padding: 0 14px 12px; }

.vs-card { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; text-align: center; }
.vs-card .side .av-stack { justify-content: center; }
.vs-card .side .n { font-weight: 650; margin-top: 6px; font-size: 14px; }
.vs-card .score { font-family: var(--font-num); font-size: 38px; font-weight: 800; letter-spacing: 1px; }
.vs-card .vs { font-weight: 800; color: var(--text-3); font-size: 15px; }

/* bracket */
.bracket { display: flex; gap: 14px; overflow-x: auto; padding: 4px 16px 14px; margin: 0 -16px; scroll-snap-type: x proximity; scroll-padding: 0 16px; }
.bracket .col { flex: none; width: 200px; display: flex; flex-direction: column; scroll-snap-align: start; }
.bracket .col .games { flex: 1; display: flex; flex-direction: column; justify-content: space-around; gap: 12px; }
.bracket .col h4 { font-size: 12px; color: var(--text-3); text-transform: uppercase; letter-spacing: .5px; text-align: center; margin-bottom: 2px; }
.bk { background: var(--card); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; font-size: 13.5px; }
.bk .tm { display: flex; align-items: center; gap: 8px; padding: 8px 10px; }
.bk .tm + .tm { border-top: 1px solid var(--line); }
.bk .tm .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.bk .tm .sc { font-family: var(--font-num); font-weight: 750; }
.bk .tm.win .nm, .bk .tm.win .sc { color: var(--g1); font-weight: 700; }
.bk .tm.tbd .nm { color: var(--text-3); font-weight: 400; }
.bk.clickable { cursor: pointer; }

/* -- chat ------------------------------------------------------------------ */
.chat { display: flex; flex-direction: column; gap: 10px; padding: 4px 0 8px; }
.msg { display: flex; gap: 8px; align-items: flex-end; max-width: 86%; }
.msg .bubble { background: var(--card); padding: 9px 12px; border-radius: 16px 16px 16px 5px; box-shadow: var(--shadow); word-wrap: break-word; overflow-wrap: anywhere; }
.msg .who { font-size: 11.5px; color: var(--text-3); margin: 0 0 2px 4px; }
.msg .time { font-size: 10.5px; color: var(--text-3); margin-left: 6px; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg.mine .bubble { background: var(--grad); color: var(--on); border-radius: 16px 16px 5px 16px; }
.msg.mine .time { color: rgba(255, 255, 255, .75); }
.msg.sys { align-self: center; max-width: 100%; }
.msg.sys .bubble { background: var(--card-3); box-shadow: none; font-size: 12.5px; color: var(--text-2); padding: 5px 12px; border-radius: 12px; }
.chat-bar { position: sticky; bottom: calc(var(--tabbar-h) + var(--safe-b) + 8px); display: flex; gap: 8px; padding: 8px; background: var(--card); border-radius: 26px; box-shadow: var(--shadow-lg); }
.chat-bar input { flex: 1; border: 0; background: none; outline: none; padding: 0 10px; height: 40px; }
.chat-bar button { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--grad); color: var(--on); display: grid; place-items: center; cursor: pointer; }

/* -- tab bar --------------------------------------------------------------- */
.tabbar { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 560px; z-index: 40;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 -1px 0 var(--line); }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; font-weight: 550; color: var(--text-3); position: relative; padding-top: 4px; }
.tabbar a .ic { width: 24px; height: 24px; }
.tabbar a.on { color: var(--g1); }
.tabbar a.on .ic { stroke-width: 2.2; }
.tabbar .ti { position: relative; }
.tabbar .fab { justify-self: center; width: 54px; height: 54px; margin-top: -22px; border-radius: 50%; border: 4px solid var(--bg); background: var(--grad); color: var(--on);
  display: grid; place-items: center; cursor: pointer; box-shadow: 0 8px 18px -4px color-mix(in srgb, var(--g1) 70%, transparent); }
.tabbar .fab .ic { width: 26px; height: 26px; stroke-width: 2.4; }

/* -- bottom sheets / modals ------------------------------------------------- */
.sheet-bg { position: fixed; inset: 0; background: var(--overlay); z-index: 60; opacity: 0; pointer-events: none; transition: opacity .22s; }
.sheet { position: fixed; left: 50%; bottom: 0; z-index: 61; width: 100%; max-width: 560px; transform: translate(-50%, 105%);
  background: var(--card); border-radius: 22px 22px 0 0; padding: 8px 18px calc(18px + var(--safe-b)); transition: transform .28s cubic-bezier(.2, .8, .2, 1);
  max-height: 88vh; max-height: 88dvh; overflow-y: auto; box-shadow: var(--shadow-lg);
  visibility: hidden; transition: transform .28s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .28s; }
.sheet::before { content: ""; display: block; width: 36px; height: 5px; border-radius: 3px; background: var(--card-3); margin: 0 auto 12px; }
.sheet.open { transform: translate(-50%, 0); visibility: visible; transition-delay: 0s; }
.sheet-bg.open { opacity: 1; pointer-events: auto; }
.sheet h3 { font-size: 18px; text-align: center; margin-bottom: 4px; }
.sheet .sub { text-align: center; color: var(--text-3); font-size: 13px; margin-bottom: 16px; }

.action-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 8px 0 14px; }
.action-grid a { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 6px; border-radius: 16px; background: var(--card-2); font-size: 13px; font-weight: 600; text-align: center; }
.action-grid .qi { width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center; background: var(--grad); color: var(--on); }

/* score entry */
.score-entry { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin: 6px 0 16px; }
.score-entry .sideblk { text-align: center; }
.score-entry .sideblk .n { font-size: 13px; font-weight: 600; color: var(--text-2); min-height: 36px; display: flex; align-items: center; justify-content: center; line-height: 1.25; }
.score-entry input { width: 100%; height: 72px; text-align: center; border-radius: 16px; border: 2px solid var(--card-3); background: var(--card-2); font-family: var(--font-num); font-size: 38px; font-weight: 800; outline: none; -moz-appearance: textfield; }
.score-entry input::-webkit-inner-spin-button { -webkit-appearance: none; }
.score-entry input:focus { border-color: var(--g1); background: var(--card); }
.score-entry .colon { font-size: 30px; font-weight: 800; color: var(--text-3); padding-top: 34px; }
.quick-scores { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: -6px 0 14px; }
.quick-scores button { height: 30px; padding: 0 12px; border-radius: 15px; border: 0; background: var(--card-2); font-size: 13px; font-weight: 600; cursor: pointer; color: var(--text-2); }

/* -- toasts ---------------------------------------------------------------- */
.toasts { position: fixed; top: calc(10px + var(--safe-t)); left: 50%; transform: translateX(-50%); z-index: 90; width: calc(100% - 32px); max-width: 420px; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; background: var(--text); color: var(--bg); font-size: 14px; font-weight: 550;
  box-shadow: var(--shadow-lg); animation: toast-in .25s cubic-bezier(.2, .8, .2, 1); }
.toast .ic { width: 18px; height: 18px; }
.toast.success .ic { color: #34D399; } .toast.error .ic { color: #FF7A80; }
.toast.out { animation: toast-out .25s forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px) scale(.97); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-10px); } }

/* -- misc ------------------------------------------------------------------ */
.banner { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 14px; background: var(--warn-bg); color: var(--text); font-size: 13.5px; margin-bottom: 12px; }
.banner .ic { color: var(--warn); }
.banner.brand { background: color-mix(in srgb, var(--g1) 10%, var(--card)); }
.banner.brand .ic { color: var(--g1); }
.code-box { display: flex; justify-content: center; gap: 6px; font-family: var(--font-num); font-size: 30px; font-weight: 800; letter-spacing: 2px; }
.code-box span { width: 40px; height: 52px; border-radius: 12px; background: var(--card-2); display: grid; place-items: center; }
.qr-wrap { background: #fff; border-radius: 18px; padding: 14px; width: 220px; margin: 0 auto; box-shadow: var(--shadow); }
.qr-wrap img { display: block; width: 100%; image-rendering: pixelated; }
.code-input { width: 100%; height: 64px; text-align: center; font-family: var(--font-num); font-size: 34px; font-weight: 800; letter-spacing: 12px; border-radius: 16px; border: 2px solid var(--card-3); background: var(--card-2); outline: none; padding-left: 12px; }
.code-input:focus { border-color: var(--g1); }
.meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--text-2); }
.meta span { display: inline-flex; align-items: center; gap: 4px; }
.meta .ic { width: 15px; height: 15px; }
.kv { display: flex; justify-content: space-between; padding: 11px 0; font-size: 14px; }
.kv + .kv { border-top: 1px solid var(--line); }
.kv .k { color: var(--text-2); }
.kv .v { font-weight: 600; text-align: right; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--text-3); font-size: 12.5px; margin: 18px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* social login buttons */
.social { display: grid; gap: 10px; }
.social .btn { background: var(--card); color: var(--text); box-shadow: inset 0 0 0 1px var(--card-3); font-weight: 600; font-size: 15px; }
.social .btn svg { width: 20px; height: 20px; }

/* auth pages */
.auth-hero { padding: calc(36px + var(--safe-t)) 24px 70px; }
.auth-card { margin: -48px 16px 0; position: relative; z-index: 2; }
.auth-card form p { margin-bottom: 12px; }
.auth-card label { font-size: 13px; color: var(--text-2); display: block; margin: 0 2px 6px; }
.auth-card button[type=submit]:not(.btn) { width: 100%; height: 48px; border: 0; border-radius: 24px; background: var(--grad); color: var(--on); font-weight: 650; font-size: 16px; cursor: pointer; margin-top: 6px; }
.auth-card ul { padding-left: 18px; }

/* user picker */
.picker { position: relative; }
.picker .results { position: absolute; left: 0; right: 0; top: 52px; z-index: 20; background: var(--card); border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; max-height: 280px; overflow-y: auto; }
.picker .results:empty { display: none; }
.picked { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 10px; border-radius: 14px; background: color-mix(in srgb, var(--g1) 9%, var(--card)); }
.picked .n { font-weight: 650; flex: 1; }
.picked button { width: 30px; height: 30px; border-radius: 50%; border: 0; background: var(--card); color: var(--text-2); display: grid; place-items: center; cursor: pointer; }

/* skeleton loading shimmer when fragments refresh */
.refreshing { opacity: .55; transition: opacity .2s; }

/* theme picker in settings */
.theme-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.theme-pick label { cursor: pointer; text-align: center; font-size: 13px; font-weight: 600; color: var(--text-2); }
.theme-pick input { position: absolute; opacity: 0; }
.theme-pick .prev { height: 86px; border-radius: 14px; border: 2px solid transparent; margin-bottom: 6px; position: relative; overflow: hidden; box-shadow: var(--shadow); }
.theme-pick .prev.l { background: #F4F5F7; } .theme-pick .prev.d { background: #0D0F13; }
.theme-pick .prev.s { background: linear-gradient(105deg, #F4F5F7 50%, #0D0F13 50%); }
.theme-pick .prev i { position: absolute; left: 10px; right: 10px; height: 10px; border-radius: 5px; }
.theme-pick .prev i:nth-child(1) { top: 12px; background: var(--grad); }
.theme-pick .prev i:nth-child(2) { top: 32px; right: 30px; background: rgba(128, 128, 128, .3); }
.theme-pick .prev i:nth-child(3) { top: 50px; right: 50px; background: rgba(128, 128, 128, .2); }
.theme-pick label:has(input:checked) { color: var(--g1); }
.theme-pick label:has(input:checked) .prev { border-color: var(--g1); }

.profile-head { display: flex; align-items: center; gap: 14px; }
.profile-head .n { font-size: 21px; font-weight: 750; }
.profile-head .s { font-size: 13px; opacity: .85; margin-top: 2px; }
.profile-head .av { box-shadow: 0 0 0 3px rgba(255, 255, 255, .5); }

.pager { display: flex; justify-content: center; gap: 10px; margin: 14px 0; }

/* -- brand lockup: logo B + "bisai.pro" ----------------------------------- */
.brand { display: inline-flex; align-items: center; gap: 6px; color: inherit; line-height: 1; }
.brand-mark { width: 34px; height: 34px; flex: none; }
.brand-word { font-family: "Bisai Brand", var(--font); font-style: italic; font-weight: 800; font-size: 24px; letter-spacing: -.3px;
  display: inline-block; transform: skewX(-4deg); /* Barlow's 10deg + 4 = the logo's 14deg slant */ }
.brand-word span { opacity: .6; }
.hero .brand { color: var(--on); }
.hero-greet { margin-top: 18px; }
