/* Networking with Balls — hand-rolled shadcn-style design system (Tempus-inspired). */

:root {
  --bg: #ffffff;
  --fg: #0b0b0c;
  --muted: #f6f6f5;
  --muted-2: #efefee;
  --muted-fg: #8a8a87;
  --subtle-fg: #5d5d5a;
  --border: #e9e9e7;
  --border-strong: #dcdcd9;
  --ring: #0b0b0c22;
  --sidebar: #f8f8f7;
  --primary: #0b0b0c;
  --primary-fg: #ffffff;
  --win: #1f9d55;
  --win-soft: #e7f6ec;
  --loss: #d64545;
  --loss-soft: #fcebeb;
  --warning: #d9a300;
  --warning-soft: #fdf6dd;
  --brand: #e2683c; /* ForLoop spark */
  --bar: #e6e6e4;
  --bar-strong: #cfcfcc;
  --highlight: #fbfaf3;
  --radius: 18px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px #0000000a, 0 8px 24px #0000000d;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --rail-w: 64px;
  --panel-w: 264px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0b0c;
    --fg: #f2f2f0;
    --muted: #161617;
    --muted-2: #1d1d1f;
    --muted-fg: #8d8d8a;
    --subtle-fg: #b0b0ac;
    --border: #232325;
    --border-strong: #2e2e31;
    --ring: #ffffff2a;
    --sidebar: #111112;
    --primary: #f2f2f0;
    --primary-fg: #0b0b0c;
    --win: #3ccf7a;
    --win-soft: #12301f;
    --loss: #f06a6a;
    --loss-soft: #3a1717;
    --warning: #f0c43c;
    --warning-soft: #33290b;
    --bar: #242426;
    --bar-strong: #39393c;
    --highlight: #17160f;
    --shadow: 0 1px 2px #0000004d, 0 8px 24px #00000066;
    color-scheme: dark;
  }
}
/* Dark mode switched on in the profile (any device setting). */
:root[data-theme="dark"] {
    --bg: #0b0b0c;
    --fg: #f2f2f0;
    --muted: #161617;
    --muted-2: #1d1d1f;
    --muted-fg: #8d8d8a;
    --subtle-fg: #b0b0ac;
    --border: #232325;
    --border-strong: #2e2e31;
    --ring: #ffffff2a;
    --sidebar: #111112;
    --primary: #f2f2f0;
    --primary-fg: #0b0b0c;
    --win: #3ccf7a;
    --win-soft: #12301f;
    --loss: #f06a6a;
    --loss-soft: #3a1717;
    --warning: #f0c43c;
    --warning-soft: #33290b;
    --bar: #242426;
    --bar-strong: #39393c;
    --highlight: #17160f;
    --shadow: 0 1px 2px #0000004d, 0 8px 24px #00000066;
    color-scheme: dark;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; background: var(--muted-2); padding: 1px 6px; border-radius: 6px; }
kbd { font-family: var(--font); font-size: 12px; color: var(--muted-fg); background: var(--muted); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; }

:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; border-radius: 6px; }

.icon { display: inline-flex; width: 20px; height: 20px; flex: none; }
.icon svg { width: 100%; height: 100%; }

.muted { color: var(--muted-fg); }
.strong { font-weight: 600; }
.right { text-align: right; }
.center { display: flex; justify-content: center; padding-bottom: 8px; }
.w-full { width: 100%; }

/* ---------- boot ---------- */
.boot { min-height: 100vh; display: grid; place-items: center; }
.boot-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--fg); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; transform: scale(0.7); } }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--rail-w) var(--panel-w) minmax(0, 1fr); min-height: 100vh; }

.rail {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 16px 0;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
}
.rail-logo { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; color: var(--fg); }
.rail-logo .logo, .rail-logo svg { width: 40px; height: 40px; display: block; }
.rail-sep { width: 100%; height: 1px; background: var(--border); margin: 8px 0; }
.rail-item {
  position: relative; display: grid; place-items: center;
  width: 42px; height: 42px; border-radius: 12px; border: 0; background: none; cursor: pointer;
  color: var(--subtle-fg); transition: background 0.15s, color 0.15s;
}
.rail-item:hover { background: var(--muted-2); color: var(--fg); }
.rail-item.active { background: var(--muted-2); color: var(--fg); }
.rail-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.rail-spacer { flex: 1; }
.avatar {
  display: grid; place-items: center; width: 34px; height: 34px; margin-top: 6px; border-radius: 50%;
  background: #2f9e44; color: #fff; font-weight: 600; font-size: 14px;
}

.panel {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
  padding: 22px 16px 16px;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
}
.find {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--bg); color: var(--muted-fg); cursor: pointer; text-align: left;
  transition: border-color 0.15s;
}
.find:hover { border-color: var(--border-strong); }
.find span:not(.icon) { flex: 1; }
.panel-label { margin: 24px 8px 6px; font-size: 12.5px; color: var(--muted-fg); }
.panel-list { display: flex; flex-direction: column; gap: 1px; }
.panel-link {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-radius: 10px; color: var(--subtle-fg);
  transition: background 0.15s, color 0.15s;
}
.panel-link:hover { background: var(--muted-2); color: var(--fg); }
.panel-link.active { background: var(--muted-2); color: var(--fg); font-weight: 500; }
.panel-spacer { flex: 1; min-height: 24px; }

/* ForLoop card — like Tempus' "What's new" card with the dotted texture */
.powered {
  display: block; padding: 16px 18px; border-radius: 16px;
  background:
    radial-gradient(circle, var(--border-strong) 1px, transparent 1.3px) 0 0 / 12px 12px,
    var(--bg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: transform 0.15s;
}
.powered:hover { transform: translateY(-1px); }
.powered-kicker { font-size: 13px; color: var(--muted-fg); background: var(--bg); display: inline; }
.powered-name { font-size: 18px; font-weight: 600; margin: 4px 0 6px; letter-spacing: -0.01em; }
.powered-name, .powered-text { background: var(--bg); width: fit-content; }
.powered-text { font-size: 13.5px; color: var(--subtle-fg); }
.powered-cta { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 13px; font-weight: 500; color: var(--brand); background: var(--bg); }
.powered-cta .icon { width: 14px; height: 14px; }

.main { min-width: 0; }
.main-inner { max-width: 1600px; margin: 0 auto; padding: 56px 48px 64px; } /* fills the page; capped + centred on very wide screens */
.mobile-footer { display: none; }

/* ---------- page header ---------- */
.page { display: flex; flex-direction: column; gap: 24px; }
.page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 32px; flex-wrap: wrap; padding-bottom: 8px; }
.page-heading { min-width: 0; }
.kicker { color: var(--muted-fg); font-size: 15px; margin-bottom: 6px; }
.page-title { font-size: clamp(30px, 4.2vw, 44px); line-height: 1.1; font-weight: 600; letter-spacing: -0.03em; }
.page-sub { margin-top: 10px; color: var(--muted-fg); display: flex; flex-direction: column; gap: 4px; }
.page-meta { min-width: 260px; display: flex; justify-content: flex-end; }
.back { display: inline-flex; align-items: center; gap: 2px; color: var(--muted-fg); font-size: 14px; margin: 0 0 14px -4px; }
.back:hover { color: var(--fg); }
.back .icon { width: 18px; height: 18px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 12px 32px; margin: 0; align-items: center; }
.kv dt { color: var(--fg); }
.kv dd { margin: 0; color: var(--subtle-fg); text-align: right; }
.page-meta .kv dd { text-align: left; }
.link-plain:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- banner + alert ---------- */
.banner {
  display: flex; gap: 16px; align-items: flex-start;
  padding: 22px 28px; border: 1px solid var(--border); border-radius: var(--radius);
}
.banner-icon { color: var(--brand); display: inline-flex; }
.banner-icon .icon { width: 24px; height: 24px; }
.banner-title { font-weight: 500; font-size: 16px; }
.banner-text { color: var(--muted-fg); margin-top: 2px; }
.banner-text a { color: var(--subtle-fg); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--border-strong); }
.banner-text a:hover { color: var(--fg); }

.alert {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 22px; border-radius: var(--radius);
  background: var(--warning-soft); border: 1px solid color-mix(in srgb, var(--warning) 30%, transparent);
}
.alert > div { flex: 1; min-width: 0; }
.alert-title { font-weight: 600; }
.alert-text { color: var(--subtle-fg); font-size: 14px; }
.alert-cta { display: inline-flex; align-items: center; gap: 2px; font-weight: 500; white-space: nowrap; }

/* ---------- cards ---------- */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.card { border: 1px solid var(--border); border-radius: var(--radius); padding: 28px 32px; background: var(--bg); min-width: 0; }
.card-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.card-title { font-size: 20px; font-weight: 500; letter-spacing: -0.01em; }
.card-title-sub { color: var(--muted-fg); font-weight: 400; font-size: 15px; margin-left: 12px; }
.card-link { color: var(--muted-fg); }
.card-link:hover { color: var(--fg); }
.card-flush { padding: 0; overflow: hidden; }
.card-flush .card-header { padding: 22px 24px 0; margin-bottom: 12px; }

/* schedule (Week ahead) */
.schedule { display: flex; flex-direction: column; }
.schedule-row { display: grid; grid-template-columns: 120px 1fr auto; gap: 16px; padding: 11px 0; align-items: baseline; border-radius: 8px; }
.schedule-row:hover .schedule-what { text-decoration: underline; text-underline-offset: 3px; }
.schedule-day { color: var(--muted-fg); }
.schedule-day.today { color: var(--fg); font-weight: 600; }
.schedule-what { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.schedule-meta { color: var(--muted-fg); font-size: 14px; }

/* big stat */
.stat-big { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px; margin-bottom: 20px; }
.stat-num { font-size: 32px; font-weight: 500; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted-fg); }

/* chart axis labels (oldest / latest) */
.bars-axis { display: flex; justify-content: space-between; color: var(--muted-fg); font-size: 13px; margin-top: 10px; border-top: 2px solid var(--border); padding-top: 8px; }

/* split (list + side stats) */
.split { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(220px, 1fr); gap: 48px; }
.issue-list { display: flex; flex-direction: column; }
.issue { display: grid; grid-template-columns: auto 64px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 10px 0; }
.issue:hover .issue-title { text-decoration: underline; text-underline-offset: 3px; }
.issue-id { color: var(--muted-fg); font-variant-numeric: tabular-nums; font-size: 14px; letter-spacing: 0.02em; }
.issue-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.issue-meta { color: var(--subtle-fg); font-variant-numeric: tabular-nums; }

.status { display: inline-flex; }
.status .icon { width: 22px; height: 22px; }
.status-pending { color: var(--warning); }
.status-won { color: var(--win); }
.status-lost { color: var(--loss); }
.status-drawn { color: var(--muted-fg); }
.status-upcoming, .status-done { color: var(--muted-fg); }

.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 500; background: var(--muted-2); color: var(--subtle-fg); white-space: nowrap; }
.badge-warning { background: var(--warning-soft); color: color-mix(in srgb, var(--warning) 70%, var(--fg)); }

.form-pills { display: inline-flex; gap: 4px; }
.pill { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; font-size: 11.5px; font-weight: 600; }
.pill-win { background: var(--win-soft); color: var(--win); }
.pill-loss { background: var(--loss-soft); color: var(--loss); }
.pill-draw { background: var(--muted-2); color: var(--muted-fg); }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 28px 12px; gap: 4px; }
.empty-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--muted); color: var(--muted-fg); margin-bottom: 8px; }
.empty-title { font-weight: 500; }
.empty-text { color: var(--muted-fg); font-size: 14px; max-width: 340px; }

.footnote { color: var(--muted-fg); font-size: 13.5px; }

/* ---------- tabs + segmented ---------- */
.tabs { display: flex; gap: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { border: 0; background: none; padding: 4px 0; cursor: pointer; color: var(--muted-fg); white-space: nowrap; font-size: 15px; transition: color 0.15s; }
.tab:hover { color: var(--fg); }
.tab.active { color: var(--fg); }
.division-tabs { gap: 6px; }
.division-tabs .tab { padding: 7px 14px; border-radius: 999px; }
.division-tabs .tab.active { background: var(--muted-2); font-weight: 500; }

.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: 12px; background: var(--muted-2); }
.segment {
  border: 0; background: none; cursor: pointer; padding: 7px 14px; border-radius: 9px;
  color: var(--subtle-fg); font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.segment:hover { color: var(--fg); }
.segment.active { background: var(--bg); color: var(--fg); box-shadow: 0 1px 2px #00000014, 0 0 0 1px var(--border); }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th { font-weight: 400; color: var(--muted-fg); font-size: 13.5px; text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th.right { text-align: right; }
.table th button { border: 0; background: none; padding: 0; color: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.table th button:hover { color: var(--fg); }
.table th.right button { flex-direction: row-reverse; }
.sort-icon { width: 14px; height: 14px; }
.table td { padding: 13px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td.strong { max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background 0.1s; }
.table tbody tr:hover { background: var(--muted); }
.table tr.row-highlight { background: var(--highlight); }
.table tr.row-highlight td:first-child { box-shadow: inset 3px 0 0 var(--brand); }
.table td.pos { color: var(--muted-fg); width: 40px; }
.table th:first-child, .table td:first-child { padding-left: 24px; }
.table th:last-child, .table td:last-child { padding-right: 24px; }
.show-sm { display: none; }

/* ---------- fixtures ---------- */
.weeks { display: flex; flex-direction: column; gap: 16px; }
.weeks .card { padding: 22px 28px; }
.weeks .card-header { margin-bottom: 8px; }
.weeks .card-title { font-size: 17px; }
.fixture-list { display: flex; flex-direction: column; }
.fixture-line {
  display: grid; grid-template-columns: auto minmax(0, 1fr) 96px minmax(0, 1fr) 110px; gap: 14px; align-items: center;
  padding: 10px 10px; margin: 0 -10px; border-radius: 10px; transition: background 0.1s;
}
.fixture-line:hover { background: var(--muted); }
.fixture-line.mine { background: var(--highlight); }
.fl-team { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--subtle-fg); }
.fl-team.home { text-align: right; }
.fl-team.winner { color: var(--fg); font-weight: 500; }
.fl-team.me { text-decoration: underline; text-decoration-color: var(--brand); text-underline-offset: 4px; text-decoration-thickness: 2px; }
.fl-score { text-align: center; font-variant-numeric: tabular-nums; font-weight: 500; color: var(--fg); }
.fl-score:not(:has(+ *)) { color: var(--muted-fg); }
.fl-date { color: var(--muted-fg); font-size: 13.5px; text-align: right; }

/* ---------- fixture detail ---------- */
.vs-title { display: inline-flex; flex-wrap: wrap; gap: 0 14px; align-items: baseline; }
.vs { color: var(--muted-fg); font-weight: 400; font-size: 0.6em; }
.scoreboard {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 24px; align-items: center;
  padding: 32px; border: 1px solid var(--border); border-radius: var(--radius);
}
.sb-name { font-size: 20px; font-weight: 500; color: var(--subtle-fg); }
.sb-team.winner .sb-name { color: var(--fg); font-weight: 600; }
.sb-team.right { text-align: right; }
.sb-tag { color: var(--muted-fg); font-size: 13.5px; }
.sb-score { text-align: center; }
.sb-points { font-size: 48px; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.sb-detail { color: var(--muted-fg); font-size: 13.5px; margin-top: 4px; }
.games { display: flex; flex-direction: column; }
.game-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) 64px minmax(0, 1fr); gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border); align-items: center; }
.game-row:last-child { border-bottom: 0; }
.game-label { color: var(--muted-fg); font-size: 14px; }
.game-side { color: var(--subtle-fg); }
.game-side.right { text-align: right; }
.game-side.winner { color: var(--fg); font-weight: 500; }
.game-score { text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }

/* result entry */
.entry { display: flex; flex-direction: column; gap: 16px; }
.entry-game { border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 24px; }
.entry-game-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; }
.entry-game-head h3 { font-size: 16px; font-weight: 600; }
.entry-game-head .muted { font-size: 13.5px; }
.entry-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 20px; align-items: start; }
.entry-grid > .entry-frames { align-self: center; }
.entry-side { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.entry-team { font-size: 13px; color: var(--muted-fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-side.right .entry-team { text-align: right; }
.entry-frames { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.entry-hint { font-size: 12px; color: var(--muted-fg); }
.entry-bar {
  position: sticky; bottom: 16px; z-index: 5;
  display: flex; flex-wrap: wrap; align-items: center; gap: 16px 24px;
  padding: 16px 20px; border-radius: var(--radius);
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.entry-summary { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 16px; align-items: center; flex: 1; min-width: 260px; }
.es-label { font-size: 12.5px; color: var(--muted-fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.es-num { font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.1; }
.es-col.right { text-align: right; }
.es-mid { text-align: center; }
.es-dash { color: var(--muted-fg); font-size: 22px; line-height: 1.1; }
.entry-actions { display: flex; gap: 8px; margin-left: auto; }
.entry-bar .form-error { flex-basis: 100%; order: 3; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 14px; font-weight: 500; }
.field-hint { font-size: 13px; color: var(--muted-fg); }
.input, .select {
  width: 100%; height: 42px; padding: 0 12px;
  font: inherit; color: var(--fg); background: var(--bg);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input::placeholder { color: var(--muted-fg); }
.input:focus, .select:focus { outline: none; border-color: var(--fg); box-shadow: 0 0 0 3px var(--ring); }
.select-wrap { position: relative; }
.select { appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer; text-overflow: ellipsis; }
.select:has(option[value='']:checked) { color: var(--muted-fg); }
.select-chevron { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted-fg); pointer-events: none; }
.form-error { color: var(--loss); font-size: 14px; }
.form-error[hidden] { display: none; }


/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: var(--radius-sm); cursor: pointer;
  font-weight: 500; white-space: nowrap; transition: background 0.15s, opacity 0.15s, border-color 0.15s;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn .icon { width: 17px; height: 17px; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 14px; }
.btn-md { height: 40px; padding: 0 16px; }
.btn-lg { height: 46px; padding: 0 22px; font-size: 15.5px; }
.btn-default { background: var(--primary); color: var(--primary-fg); }
.btn-default:hover:not(:disabled) { opacity: 0.88; }
.btn-outline { background: var(--bg); border-color: var(--border-strong); }
.btn-outline:hover { background: var(--muted); }
.btn-ghost { background: none; }
.btn-ghost:hover { background: var(--muted-2); }

/* ---------- overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50; display: flex; justify-content: center; align-items: flex-start;
  padding: 12vh 16px 16px; background: #0000; transition: background 0.15s;
}
.overlay.open { background: #00000033; }
.dialog {
  width: 100%; max-width: 560px; background: var(--bg); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 24px 64px #00000033;
  opacity: 0; transform: translateY(-6px) scale(0.98); transition: opacity 0.15s, transform 0.15s;
}
.overlay.open .dialog { opacity: 1; transform: none; }
.command-search { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--border); color: var(--muted-fg); }
.command-input { flex: 1; height: 54px; border: 0; outline: 0; background: none; font: inherit; font-size: 16px; color: var(--fg); }
.command-list { max-height: min(420px, 60vh); overflow-y: auto; padding: 8px; }
.command-group { font-size: 12.5px; color: var(--muted-fg); padding: 10px 10px 4px; }
.command-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; background: none; border-radius: 10px; cursor: pointer; text-align: left; }
.command-item .icon { width: 17px; height: 17px; color: var(--muted-fg); }
.command-item.active { background: var(--muted-2); }
.command-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.command-sub { color: var(--muted-fg); font-size: 13px; white-space: nowrap; }
.command-empty { padding: 24px; text-align: center; color: var(--muted-fg); }

.toasts { position: fixed; z-index: 60; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px;
  background: var(--primary); color: var(--primary-fg); box-shadow: var(--shadow); font-weight: 500;
  opacity: 0; transform: translateY(8px); transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: none; }
.toast .icon { width: 18px; height: 18px; }
.toast-error { background: var(--loss); color: #fff; }

/* ---------- login ---------- */
.login {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; padding: 32px 16px;
  background: radial-gradient(circle, var(--border) 1px, transparent 1.3px) 0 0 / 16px 16px, var(--sidebar);
}
.login-card { width: 100%; max-width: 420px; padding: 36px; background: var(--bg); border: 1px solid var(--border); border-radius: 22px; box-shadow: var(--shadow); }
.login-logo { display: grid; place-items: center; width: 72px; height: 72px; margin-bottom: 16px; }
.login-logo .logo, .login-logo svg { width: 72px; height: 72px; display: block; }
.login-title { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; margin-bottom: 6px; }
.login-form { display: flex; flex-direction: column; gap: 16px; margin-top: 28px; }
.login-powered { display: inline-flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 999px; background: var(--bg); border: 1px solid var(--border); font-size: 14px; color: var(--subtle-fg); }
.login-powered .icon { width: 18px; height: 18px; }
.login-powered strong { color: var(--fg); font-weight: 600; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .split { grid-template-columns: 1fr; gap: 28px; }
}

@media (max-width: 1024px) {
  .shell { grid-template-columns: var(--rail-w) minmax(0, 1fr); }
  .panel { display: none; }
  .main-inner { padding: 40px 32px 56px; }
  .mobile-footer {
    display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-top: 40px; padding-top: 20px;
    border-top: 1px solid var(--border); color: var(--muted-fg); font-size: 13.5px;
  }
  .mobile-footer a { color: var(--fg); font-weight: 500; }
}

@media (max-width: 760px) {
  body { font-size: 15px; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; z-index: 40; height: auto;
    flex-direction: row; justify-content: space-around; gap: 0;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--sidebar) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  }
  .rail-logo, .rail-sep, .rail-spacer, .avatar { display: none; }
  .rail-item { width: auto; height: auto; flex: 1; padding: 6px 0 4px; gap: 2px; border-radius: 10px; }
  .rail-item.active { background: none; }
  .rail-label { position: static; width: auto; height: auto; clip: auto; overflow: visible; font-size: 11px; }
  .main-inner { padding: 28px 16px calc(96px + env(safe-area-inset-bottom)); }
  .page { gap: 18px; }
  .page-header { flex-direction: column; align-items: stretch; gap: 20px; }
  .page-meta { min-width: 0; justify-content: flex-start; }
  .grid-2 { grid-template-columns: 1fr; gap: 18px; }
  .card { padding: 22px 18px; }
  .card-flush { padding: 0; }
  .card-flush .card-header { padding: 18px 16px 0; }
  .banner { padding: 18px; }
  .schedule-row { grid-template-columns: 92px 1fr auto; gap: 10px; }
  .issue { grid-template-columns: auto minmax(0, 1fr) auto; }
  .issue-id { display: none; }
  .hide-sm { display: none; }
  .show-sm { display: table-cell; }
  .table th, .table td { padding: 11px 8px; }
  .table th:first-child, .table td:first-child { padding-left: 16px; }
  .table th:last-child, .table td:last-child { padding-right: 16px; }
  .table td.strong { max-width: 150px; }
  .weeks .card { padding: 16px; }
  .fixture-line { grid-template-columns: auto minmax(0, 1fr) 56px minmax(0, 1fr); gap: 8px; font-size: 14px; }
  .fl-date { display: none; }
  .scoreboard { padding: 22px 16px; gap: 10px; }
  .sb-name { font-size: 15px; }
  .sb-points { font-size: 34px; }
  .game-row { grid-template-columns: minmax(0, 1fr) 44px minmax(0, 1fr); row-gap: 2px; font-size: 14px; }
  .game-label { grid-column: 1 / -1; font-size: 12.5px; }
  .entry-game { padding: 16px; }
  .entry-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
  .entry-frames { grid-column: 1 / -1; grid-row: 2; }
  .entry-frames .segmented { width: 100%; }
  .entry-frames .segment { flex: 1; padding: 10px 0; }
  .entry-bar { bottom: calc(76px + env(safe-area-inset-bottom)); padding: 12px 14px; gap: 12px; }
  .entry-summary { min-width: 0; flex-basis: 100%; }
  .entry-actions { width: 100%; }
  .entry-actions .btn { flex: 1; }
  .toasts { left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); }
  .login-card { padding: 28px 20px; }
}

/* =====================================================================
   v2 — accounts, organisations, teams, tournaments, casual games
   ===================================================================== */

.small { font-size: 13.5px; }
.tabular { font-variant-numeric: tabular-nums; }
.stack { display: flex; flex-direction: column; gap: 20px; }

/* badges */
.badge-brand { background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); }
.badge-success { background: var(--win-soft); color: var(--win); }

/* buttons */
.btn-danger { background: var(--loss); color: #fff; }
.btn-danger:hover:not(:disabled) { opacity: 0.88; }

/* "Playing as" switcher */
.ctx-list { display: flex; flex-direction: column; gap: 2px; }
.ctx-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 12px;
  background: none; cursor: pointer; text-align: left; color: var(--subtle-fg); transition: background 0.15s;
}
.ctx-item:hover { background: var(--muted-2); color: var(--fg); }
.ctx-item.active { background: var(--bg); color: var(--fg); box-shadow: 0 0 0 1px var(--border), 0 1px 2px #0000000d; }
.ctx-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--muted-2); flex: none; }
.ctx-item.active .ctx-icon { background: var(--fg); color: var(--bg); }
.ctx-icon .icon { width: 16px; height: 16px; }
.ctx-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ctx-label { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-sub { font-size: 12px; color: var(--muted-fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-check { width: 16px; height: 16px; color: var(--brand); }
.ctx-add { display: flex; align-items: center; gap: 8px; padding: 8px 10px; font-size: 13.5px; color: var(--muted-fg); border-radius: 10px; }
.ctx-add:hover { color: var(--fg); background: var(--muted-2); }
.ctx-add .icon { width: 16px; height: 16px; }
.dialog .ctx-list { margin-top: 12px; }

.ctx-pill {
  display: inline-flex; align-items: center; gap: 8px; width: fit-content; margin-top: 4px;
  padding: 7px 12px 7px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--bg);
  color: var(--fg); font-weight: 500; cursor: pointer; transition: border-color 0.15s;
}
.ctx-pill:hover { border-color: var(--border-strong); }
.ctx-pill .icon { width: 17px; height: 17px; }
.ctx-pill-swap { color: var(--muted-fg); }

.panel { gap: 0; }
.panel .find { margin-bottom: 4px; }
.panel-crown { width: 14px; height: 14px; color: var(--brand); }
.panel-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.avatar-btn { border: 0; background: none; padding: 0; cursor: pointer; border-radius: 50%; margin-top: 6px; }
.avatar-sm {
  display: inline-grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 50%;
  background: hsl(var(--hue, 140) 45% 42%); color: #fff; font-size: 12.5px; font-weight: 600; letter-spacing: 0.02em;
}
.avatar-sm.lg { width: 48px; height: 48px; font-size: 16px; }

/* generic rows */
.rows { display: flex; flex-direction: column; }
.rows-2col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 32px; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 0; border: 0; background: none;
  text-align: left; color: inherit; border-bottom: 1px solid var(--border);
}
.rows .row:last-child, .rows-2col .row:nth-last-child(-n + 2) { border-bottom: 0; }
a.row:hover .row-title, button.row:hover .row-title { text-decoration: underline; text-underline-offset: 3px; }
.row-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--muted); color: var(--subtle-fg); flex: none; }
.row-icon .icon { width: 18px; height: 18px; }
.row-won .row-icon { background: var(--win-soft); color: var(--win); }
.row-lost .row-icon { background: var(--loss-soft); color: var(--loss); }
.row-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.row-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 13.5px; color: var(--muted-fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-right { display: flex; align-items: center; gap: 8px; flex: none; color: var(--subtle-fg); font-variant-numeric: tabular-nums; }

.inline-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline-actions.center { justify-content: center; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form > .input, .inline-form > .select-wrap { flex: 1; min-width: 160px; }

/* cards */
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.card-foot { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.card-intro { margin: -8px 0 16px; font-size: 14px; }
.card-list { padding: 8px 28px; }
.card-narrow { max-width: 640px; }
.card-danger { border-color: color-mix(in srgb, var(--loss) 35%, var(--border)); }
.danger-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.danger-row.plain { padding: 4px 4px 0; }
.result-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.schedule-what { display: flex; flex-direction: column; }
.schedule-sub { font-size: 12.5px; color: var(--muted-fg); overflow: hidden; text-overflow: ellipsis; }

.alert-info { background: color-mix(in srgb, var(--brand) 8%, var(--bg)); border-color: color-mix(in srgb, var(--brand) 25%, transparent); }
.alert-info .status { color: var(--brand); }

/* tournament */
.pill-tabs { gap: 6px; }
.pill-tabs .tab { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border); font-size: 14px; }
.pill-tabs .tab.active { border-color: var(--fg); }
.enter-box { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.enter-line { display: flex; align-items: center; gap: 10px; }
.division-block + .division-block { margin-top: 18px; }
.division-name { font-size: 13px; color: var(--muted-fg); margin-bottom: 2px; }

/* forms */
.form-stack { display: flex; flex-direction: column; gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: end; }
.form-grid .check { grid-column: 1 / -1; }
.form-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.field-sub { font-size: 12.5px; color: var(--muted-fg); }
.entry-note { margin: 0 0 12px; font-size: 13.5px; color: var(--muted-fg); }
.form-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.card .form-actions { margin-top: 16px; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--fg); }
.code-input { text-transform: uppercase; letter-spacing: 0.2em; font-weight: 600; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* QR */
.qr-wrap { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.qr { width: 168px; height: 168px; flex: none; border-radius: 14px; overflow: hidden; border: 1px solid var(--border); background: #fff; }
.qr svg { width: 100%; height: 100%; display: block; }
.qr-info { display: flex; flex-direction: column; gap: 12px; flex: 1; min-width: 200px; }
.join-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 30px; font-weight: 600; letter-spacing: 0.18em; }
.hint-warn { display: flex; gap: 8px; font-size: 13px; color: var(--warning); }
.hint-warn .icon { width: 16px; height: 16px; flex: none; margin-top: 2px; }

.join-hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 24px 8px; }
.join-hero .inline-actions { margin-top: 14px; }
.join-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 16px; background: var(--fg); color: var(--bg); margin-bottom: 6px; }
.join-icon .icon { width: 28px; height: 28px; }
.join-note { display: flex; align-items: center; gap: 10px; margin-top: 18px; padding: 10px 14px; border-radius: 12px; background: var(--muted); font-size: 14px; }
.join-note .icon { width: 18px; height: 18px; color: var(--brand); }

.auth-tabs { margin-top: 24px; border-bottom: 1px solid var(--border); gap: 24px; }
.auth-tabs .tab { padding: 8px 0; margin-bottom: -1px; border-bottom: 2px solid transparent; }
.auth-tabs .tab.active { border-color: var(--fg); font-weight: 500; }
.login-form { margin-top: 20px; }

/* dialogs */
.dialog-sm { max-width: 420px; }
.dialog-body { padding: 24px; }
.dialog-title { font-size: 18px; font-weight: 600; }
.dialog-text { color: var(--muted-fg); margin-top: 6px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }

/* casual */
.score-row { display: flex; align-items: flex-end; gap: 16px; }
.score-dash { font-size: 22px; color: var(--muted-fg); padding-bottom: 8px; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.stepper-btn { width: 44px; height: 44px; border: 0; background: var(--muted); font-size: 20px; cursor: pointer; }
.stepper-btn:hover { background: var(--muted-2); }
.stepper-value { width: 72px; min-width: 48px; height: 44px; border: 0; background: transparent; color: var(--fg); text-align: center; font: inherit; font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; outline: none; }
.stepper-value:focus { background: var(--muted); }

.entry-grid-single { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; }
.entry-grid-single .entry-team { font-size: 16px; color: var(--fg); font-weight: 500; }
.entry-team.right { text-align: right; }

@media (max-width: 1024px) {
  .rows-2col { grid-template-columns: 1fr; }
  .rows-2col .row:nth-last-child(2) { border-bottom: 1px solid var(--border); }
}

@media (max-width: 760px) {
  .form-grid, .form-grid-2 { grid-template-columns: 1fr; }
  .form-grid-3 { gap: 8px; }
  .card-list { padding: 4px 16px; }
  .qr-wrap { flex-direction: column; align-items: stretch; text-align: center; }
  .qr { margin: 0 auto; width: 200px; height: 200px; }
  .qr-info .inline-actions { justify-content: center; }
  .row-right .btn:has(> .icon) > span:not(.icon) { display: none; } /* icon-only on phones; text-only buttons keep their words */
  .row-right .btn-sm { padding: 0 10px; }
  .entry-grid-single { grid-template-columns: 1fr 1fr; }
  .entry-grid-single .entry-frames { grid-column: 1 / -1; grid-row: 2; }
  .page-meta .btn { width: 100%; }
  .avatar-btn { flex: 1; margin: 0; display: grid; place-items: center; }
  .avatar-btn .avatar-sm { width: 28px; height: 28px; font-size: 11px; }
}

/* tournament → Your team */
.team-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; padding-bottom: 22px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.team-stat { display: flex; flex-direction: column; gap: 6px; }
.team-stat-num { font-size: 30px; font-weight: 500; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.team-stat .form-pills { height: 33px; align-items: center; }
.team-stat-label { color: var(--muted-fg); font-size: 13.5px; }
.team-fixture { display: grid; grid-template-columns: auto 92px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 9px 10px; margin: 0 -10px; border-radius: 10px; }
.team-fixture:hover { background: var(--muted); }
.tf-date { color: var(--muted-fg); font-size: 14px; }
.tf-opp { display: flex; flex-direction: column; min-width: 0; }
.tf-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tf-ha { font-size: 12.5px; color: var(--muted-fg); }
.tf-score { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 40px; text-align: right; color: var(--muted-fg); }
.tf-score.win { color: var(--win); }
.tf-score.loss { color: var(--loss); }
.tf-score.draw { color: var(--fg); }
.tf-score.due { color: var(--warning); font-weight: 500; font-size: 13.5px; }
@media (max-width: 760px) {
  .team-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 20px; }
}

/* Teams page */
.row-chevron { width: 16px; height: 16px; color: var(--muted-fg); }
.card-search { margin-bottom: 8px; }
.teams-browse { max-height: 560px; overflow-y: auto; }

/* ---------- player stats ---------- */
.card-heading { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.card-sub { margin: 0; color: var(--muted-fg); font-size: 13.5px; }
.player-link { color: inherit; text-decoration: none; border-bottom: 1px dashed color-mix(in srgb, currentColor 35%, transparent); }
.player-link:hover { border-bottom-style: solid; border-bottom-color: currentColor; }
.player-title { display: inline-flex; align-items: center; gap: 14px; }
.team-summary.no-rule { border-bottom: 0; padding-bottom: 0; margin-bottom: 0; }
.res-win { color: var(--win); font-weight: 500; }
.res-loss { color: var(--loss); font-weight: 500; }

/* legend */
.chart-legend { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 14px; font-size: 12.5px; color: var(--muted-fg); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; }
.sw-win { background: var(--win); }
.sw-loss { background: var(--loss); }

/* radar */
.radar-wrap { display: flex; justify-content: center; }
.radar { width: 100%; max-width: 420px; height: auto; overflow: visible; }
.radar-grid { fill: none; stroke: var(--border); stroke-width: 1; }
.radar-area { fill: color-mix(in srgb, var(--win) 14%, transparent); stroke: var(--win); stroke-width: 2; stroke-linejoin: round; }
.radar-dot { fill: var(--win); stroke: var(--card, var(--bg)); stroke-width: 2; cursor: pointer; outline: none; }
.radar-dot:hover, .radar-dot:focus { r: 7; }
.radar-label { font-size: 13px; fill: var(--muted-fg); }
.radar-val { fill: var(--fg); font-weight: 600; }
.radar-val.none { fill: var(--muted-fg); font-weight: 400; }
.radar-tick { font-size: 10.5px; fill: var(--muted-fg); }

/* split bars */
.split-group + .split-group { margin-top: 26px; }
.split-group-title { margin: 0 0 10px; font-size: 13px; font-weight: 500; color: var(--fg); }
.split-bars { display: flex; flex-direction: column; gap: 14px; }
.split-head { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; margin-bottom: 6px; }
.split-label { color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.split-meta { color: var(--muted-fg); font-variant-numeric: tabular-nums; white-space: nowrap; }
.split-track { display: flex; gap: 2px; height: 12px; }
.split-seg { min-width: 4px; outline: none; cursor: default; }
.split-seg:first-child { border-radius: 4px 0 0 4px; }
.split-seg:last-child { border-radius: 0 4px 4px 0; }
.split-seg:only-child { border-radius: 4px; }
.split-seg:hover, .split-seg:focus { filter: brightness(1.12); }
.seg-win { background: var(--win); }
.seg-loss { background: var(--loss); }
.split-sub { margin: 4px 0 0; font-size: 12px; color: var(--muted-fg); }

/* results columns */
.cols-frame { position: relative; padding-left: 18px; }
.cols { display: block; width: 100%; height: 168px; }
.cols-base { stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; }
.col-win { fill: var(--win); }
.col-loss { fill: var(--loss); }
.cols-hit { cursor: pointer; outline: none; }
.cols-hit:hover path, .cols-hit:focus path { filter: brightness(1.15); }
.cols-axis { position: absolute; left: 0; font-size: 11px; font-weight: 600; color: var(--muted-fg); }
.cols-axis.top { top: 4px; }
.cols-axis.bottom { bottom: 4px; }

/* tooltip */
.chart-tip {
  position: fixed; z-index: 100; pointer-events: none; opacity: 0; transition: opacity 0.12s;
  background: var(--fg); color: var(--bg); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; max-width: 240px;
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.2);
}
.chart-tip.show { opacity: 1; }
.chart-tip p { margin: 0; line-height: 1.45; opacity: 0.8; }
.chart-tip .chart-tip-title { font-weight: 600; opacity: 1; }
.cols-wrap .bars-axis { border-top: 0; padding-top: 4px; }

/* profile */
a.avatar-btn { display: grid; place-items: center; text-decoration: none; }
.avatar-btn.active .avatar-sm { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--fg); }
.profile-sub { display: flex; flex-direction: column; gap: 4px; }
.profile-sub p { margin: 0; }
.hl-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px 24px; }
.hl { min-width: 0; }
.hl-label { margin: 0 0 6px; font-size: 13px; color: var(--muted-fg); }
.hl-value { margin: 0; font-size: 22px; font-weight: 500; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hl-sub { margin: 4px 0 0; font-size: 12.5px; color: var(--muted-fg); }
.scorelines { display: flex; flex-direction: column; gap: 10px; }
.sl-row { display: grid; grid-template-columns: 72px 1fr 84px; align-items: center; gap: 12px; font-size: 13.5px; }
.sl-score { font-variant-numeric: tabular-nums; font-weight: 500; display: inline-flex; gap: 8px; }
.sl-wl { color: var(--muted-fg); font-weight: 600; width: 10px; }
.sl-track { height: 12px; }
.sl-bar { display: block; height: 100%; min-width: 4px; border-radius: 0 4px 4px 0; }
.sl-n { color: var(--muted-fg); text-align: right; font-variant-numeric: tabular-nums; }
.standing-pos { width: 44px; font-size: 20px; font-weight: 500; font-variant-numeric: tabular-nums; }
.standing-pts { font-weight: 600; margin-right: 12px; font-variant-numeric: tabular-nums; }
@media (max-width: 760px) {
  .hl-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .avatar-btn.active .avatar-sm { box-shadow: none; }
}

/* extra games */
.extra-bar { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin: 4px 0 20px; padding: 16px 18px; border: 1px dashed var(--border); border-radius: 14px; }
.extra-title { margin: 0 0 2px; font-weight: 500; }
.extra-text p { margin: 0; }
.entry-extra { border-style: dashed; }
.entry-extra .badge { margin-right: 4px; vertical-align: 2px; }
.game-row.game-extra .game-label { font-style: italic; }

/* doubles with more than 2 a side */
.picker-row { display: flex; gap: 6px; align-items: center; }
.picker-row > :first-child { flex: 1; min-width: 0; }
.entry-side .add-player { align-self: flex-start; }
.entry-side.right .add-player { align-self: flex-end; }

/* score picker labels */
.entry-frames-label { margin: 0; font-size: 12px; font-weight: 500; color: var(--muted-fg); text-transform: uppercase; letter-spacing: 0.06em; }
.entry-hint { text-align: center; max-width: 240px; }
.entry-hint.picked { color: var(--fg); font-weight: 500; }

/* a doubles slot played as singles */
.game-title-note { margin-left: 8px; font-size: 13px; font-weight: 400; color: var(--muted-fg); }
.game-label-note { display: block; font-size: 11.5px; color: var(--muted-fg); font-style: normal; }

/* typed frame scores */
.score-boxes { display: flex; align-items: center; gap: 10px; }
.score-box { width: 64px; height: 52px; text-align: center; font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; padding: 0; }
.score-dash { font-size: 20px; color: var(--muted-fg); }
.entry-hint.bad { color: var(--loss); }

.score-box { width: 84px; }
.entry-hint.format-note { color: var(--warning); font-weight: 400; margin-top: -2px; }

/* type-or-pick player field */
.picker { position: relative; flex: 1; min-width: 0; }
.picker-input { width: 100%; padding-right: 64px; }
.picker-tag { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 11px; font-weight: 600; color: var(--muted-fg); background: var(--muted-2); border-radius: 6px; padding: 2px 6px; pointer-events: none; }
.player-guest { font-style: italic; }

/* donuts */
:root { --cat-1: #2a78d6; --cat-2: #eb6834; --cat-3: #1baf7a; --cat-4: #eda100; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --cat-1: #3987e5; --cat-2: #d95926; --cat-3: #199e70; --cat-4: #c98500; } }
:root[data-theme="dark"] { --cat-1: #3987e5; --cat-2: #d95926; --cat-3: #199e70; --cat-4: #c98500; }
.donut-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 24px; }
.donut-block { display: flex; align-items: center; gap: 18px; min-width: 0; }
.donut-title { margin: 0 0 12px; font-size: 13px; font-weight: 500; color: var(--fg); }
.donut-wrap { position: relative; width: 120px; height: 120px; flex: none; }
.donut { width: 100%; height: 100%; display: block; }
.donut-track { fill: none; stroke: var(--muted-2); }
.donut-seg { fill: none; cursor: default; outline: none; transition: stroke-width 0.12s; }
.donut-seg:hover, .donut-seg:focus { stroke-width: 22; }
.donut-seg.seg-win, .donut-seg.cat-win { stroke: var(--win); }
.donut-seg.seg-loss { stroke: var(--loss); }
.donut-seg.cat-1 { stroke: var(--cat-1); } .donut-seg.cat-2 { stroke: var(--cat-2); }
.donut-seg.cat-3 { stroke: var(--cat-3); } .donut-seg.cat-4 { stroke: var(--cat-4); }
.donut-centre { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
.donut-big { margin: 0; font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.1; }
.donut-sub { margin: 2px 0 0; font-size: 11.5px; color: var(--muted-fg); }
.donut-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 13px; min-width: 0; }
.donut-legend li { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 8px; }
.donut-label { color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.donut-val { color: var(--muted-fg); font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 1180px) { .donut-grid { grid-template-columns: 1fr; } }

/* ⓘ info tips */
.donut-title { display: flex; align-items: center; gap: 6px; }
.info { position: relative; display: inline-flex; }
.info-btn { display: inline-grid; place-items: center; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--muted-fg); cursor: pointer; }
.info-btn .icon, .info-btn svg { width: 16px; height: 16px; }
.info-btn:hover, .info-btn:focus-visible, .info.open .info-btn { color: var(--fg); background: var(--muted-2); outline: none; }
.info-bubble {
  position: absolute; z-index: 50; top: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  width: min(300px, 80vw); padding: 12px 14px; border-radius: 12px;
  background: var(--fg); color: var(--bg); box-shadow: 0 10px 30px rgb(0 0 0 / 0.25);
  font-size: 13px; font-weight: 400; line-height: 1.5; text-align: left;
  opacity: 0; visibility: hidden; transition: opacity 0.12s;
}
.info-bubble p { margin: 0; }
.info-bubble p + p { margin-top: 8px; }
.info-bubble strong { font-weight: 600; }
.info:hover .info-bubble, .info-btn:focus-visible + .info-bubble, .info.open .info-bubble { opacity: 1; visibility: visible; }
@media (max-width: 1180px) { .info-bubble { left: 0; transform: none; } }

.ctx-sub-line { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }

/* "Playing as" lives in the sidebar; the pill only appears when the sidebar is hidden (tablet/phone). */
.ctx-pill { display: none; }
@media (max-width: 1024px) { .ctx-pill { display: inline-flex; } }

/* join a tournament */
.dialog-join { width: min(520px, calc(100vw - 32px)); }
.join-panel .inline-form { margin-top: 16px; }
.join-panel .code-input { text-transform: uppercase; letter-spacing: 0.18em; font-weight: 600; }
.join-or { display: flex; align-items: center; gap: 12px; margin: 18px 0 12px; color: var(--muted-fg); font-size: 12.5px; }
.join-or::before, .join-or::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.scan-area { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.scan-area p { margin: 0; }
.scan-video { width: 100%; max-height: 300px; border-radius: 12px; background: #000; object-fit: cover; }
.inline-icon { display: inline-flex; vertical-align: -3px; margin-right: 6px; }
.inline-icon svg { width: 16px; height: 16px; }
.join-found { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 16px; }
.join-found .dialog-title { margin: 2px 0 4px; }
.join-cta-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.join-cta-row > div { flex: 1; min-width: 200px; }
.join-cta-title { margin: 0 0 2px; font-weight: 500; }
button.ctx-add { width: 100%; border: 0; background: none; font: inherit; text-align: left; cursor: pointer; }

/* Basic app (parked features off): rail + main only, no side panel; ForLoop footer shows on every size. */
.shell.basic { grid-template-columns: var(--rail-w) minmax(0, 1fr); }
.shell.basic .mobile-footer {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-top: 40px; padding-top: 20px;
  border-top: 1px solid var(--border); color: var(--muted-fg); font-size: 13.5px;
}
.shell.basic .mobile-footer a { color: var(--fg); font-weight: 500; }
@media (max-width: 760px) { .shell.basic { grid-template-columns: minmax(0, 1fr); } }

/* casual: any number of players a side */
.sides { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.player-list { display: flex; flex-direction: column; gap: 8px; }
.player-list .picker-row > .input { flex: 1; min-width: 0; }
.picker-spacer { width: 32px; flex: none; }
.player-list .add-player { align-self: flex-start; }
.me-chip { display: flex; align-items: center; height: 40px; padding: 0 12px; border-radius: var(--radius-sm); background: var(--muted-2); font-weight: 500; margin-bottom: 8px; margin-right: 38px; }
@media (max-width: 760px) { .sides { grid-template-columns: 1fr; } }

/* "Played before" quick picks */

/* name box: type, pick from dropdown, or scan */
.namebox { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; }
.namebox-field { position: relative; flex: 1; min-width: 0; }
.namebox-field .input { width: 100%; }
.namebox-menu { position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px; list-style: none;
  background: var(--card, var(--bg)); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: var(--shadow); max-height: 280px; overflow-y: auto; }
.namebox-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.namebox-item:hover, .namebox-item.active { background: var(--muted-2); }
.namebox-tag { font-size: 11px; color: var(--muted-fg); white-space: nowrap; }
.invites-card { border-color: color-mix(in srgb, var(--warning) 45%, var(--border)); }

/* player code + QR on your profile */
.profile-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 14px; }
.player-code { display: flex; align-items: center; gap: 12px; padding: 8px 14px 8px 8px; border: 1px solid var(--border); border-radius: 14px; background: var(--card, var(--bg)); color: var(--fg); cursor: pointer; text-align: left; font: inherit; }
.player-code:hover { border-color: var(--border-strong); }
.qr-mini { display: block; width: 72px; height: 72px; padding: 4px; background: #fff; border-radius: 8px; }
.qr-mini svg, .qr-big svg { width: 100%; height: 100%; display: block; }
.player-code-text { display: flex; flex-direction: column; gap: 2px; }
.player-code-label { font-size: 12px; color: var(--muted-fg); }
.player-code-value { font-size: 20px; font-weight: 600; letter-spacing: 0.16em; font-variant-numeric: tabular-nums; }
.player-code-hint { font-size: 12px; color: var(--muted-fg); }
.qr-big { width: min(260px, 70vw); height: min(260px, 70vw); margin: 16px auto 8px; padding: 12px; background: #fff; border-radius: 16px; }
.qr-dialog { display: flex; flex-direction: column; align-items: center; text-align: center; }
.qr-dialog .dialog-actions { justify-content: center; }
@media (max-width: 760px) { .profile-meta { align-items: flex-start; } }

/* Home hub: two big containers */
.hub-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
@media (max-width: 1100px) { .hub-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.hub-tile { display: flex; flex-direction: column; gap: 10px; min-height: 280px; padding: 28px 32px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); color: var(--fg); text-decoration: none; transition: border-color 0.15s, transform 0.15s, background 0.15s; }
a.hub-tile:hover { border-color: var(--border-strong); background: var(--muted); transform: translateY(-2px); }
.hub-tile.disabled { opacity: 0.6; cursor: default; }
.hub-tile-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.hub-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; background: var(--fg); color: var(--bg); }
.hub-icon .icon, .hub-icon svg { width: 26px; height: 26px; }
.hub-title { margin: 0; font-size: 28px; font-weight: 600; letter-spacing: -0.02em; }
.hub-text { margin: 0; color: var(--muted-fg); max-width: 46ch; }
.hub-stats { display: flex; gap: 32px; margin-top: 8px; }
.hub-stat-value { margin: 0; font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.hub-stat-label { margin: 2px 0 0; font-size: 12.5px; color: var(--muted-fg); }
.hub-cta { margin-top: auto; padding-top: 16px; display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.hub-cta .icon, .hub-cta svg { width: 16px; height: 16px; }
@media (max-width: 760px) { .hub-grid { grid-template-columns: 1fr; } .hub-tile { min-height: 0; padding: 22px; } }

/* breadcrumbs */
.crumbs { margin-bottom: 14px; }
.crumbs ol { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin: 0; padding: 0; list-style: none; font-size: 14px; }
.crumbs li { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.crumbs a { color: var(--muted-fg); text-decoration: none; }
.crumbs a:hover { color: var(--fg); text-decoration: underline; }
.crumbs [aria-current] { color: var(--fg); font-weight: 500; }
.crumb-sep { display: inline-flex; color: var(--muted-fg); opacity: 0.6; }
.crumb-sep svg { width: 14px; height: 14px; }
.crumbs .crumb-sep { width: 14px; height: 14px; line-height: 0; align-self: center; }
.crumbs .crumb-sep svg { display: block; }

.division-list { display: flex; flex-direction: column; gap: 8px; }
.division-list .picker-row > .input { flex: 1; min-width: 0; }
.division-list .add-player { align-self: flex-start; }
.card-narrow { margin-inline: auto; width: 100%; } /* short confirm pages (join / add player): centred */

/* "Best of [ N ] frames" */
.bestof { display: inline-flex; align-items: center; gap: 10px; font-weight: 500; }
.bestof-input { width: 96px; text-align: center; font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }

.bestof-input.invalid { border-color: var(--loss); }
.bestof-warn { font-size: 12.5px; color: var(--loss); font-weight: 400; }

/* Match format: the three number boxes fill their columns so they line up evenly */
.form-grid-3 .bestof { display: flex; width: 100%; }
.form-grid-3 .bestof-input { flex: 1; min-width: 0; width: auto; }
.form-grid-3 .bestof > span { white-space: nowrap; }
.bestof { position: relative; }
.bestof-warn { position: absolute; top: 100%; left: 0; margin-top: 4px; white-space: nowrap; }
.form-grid-3:has(.bestof) { gap: 28px; }
.stepper-value { width: 96px; }
.score-box { min-width: 84px; width: auto; max-width: 160px; field-sizing: content; }

/* side-bar badge (invites waiting) */
.rail-item { position: relative; }
.rail-badge { position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--warning); color: #111; font-size: 10.5px; font-weight: 700; line-height: 16px; text-align: center; }

/* "You're playing today" bar on Home */

/* PWA: offline notice + install steps */
.offline-banner { position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 120;
  display: flex; align-items: center; gap: 10px; max-width: min(560px, calc(100vw - 32px)); padding: 10px 16px; border-radius: 12px;
  background: var(--fg); color: var(--bg); font-size: 13.5px; box-shadow: 0 8px 30px rgb(0 0 0 / 0.3); }
.offline-banner[hidden] { display: none; }
.offline-banner .icon, .offline-banner svg { width: 16px; height: 16px; flex: none; }
@media (max-width: 760px) { .offline-banner { bottom: calc(84px + env(safe-area-inset-bottom)); } }
.install-steps { margin: 12px 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.install-wrap:empty { display: none; }

/* Phones: top bar — app logo top-left (Home), profile top-right. The avatar leaves the bottom bar. */
.mobile-topbar { display: none; }
@media (max-width: 760px) {
  .mobile-topbar {
    position: sticky; top: 0; z-index: 45; grid-column: 1 / -1;
    display: flex; align-items: center; justify-content: space-between;
    padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
    background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
  }
  .topbar-logo { display: block; width: 40px; height: 40px; }
  .topbar-logo .logo, .topbar-logo svg { width: 40px; height: 40px; display: block; }
  .topbar-profile { display: grid; place-items: center; border-radius: 50%; text-decoration: none; }
  .topbar-profile .avatar-sm { width: 34px; height: 34px; font-size: 12.5px; }
  .topbar-profile.active .avatar-sm { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--fg); }
  .rail .avatar-btn { display: none; }
  .main-inner { padding-top: 20px; }
}

/* Phones: the top bar and bottom bar are pinned to the screen and never scroll away or hide. */
@media (max-width: 760px) {
  .mobile-topbar { position: fixed; top: 0; left: 0; right: 0; transform: translateZ(0); }
  .rail { position: fixed !important; bottom: 0; left: 0; right: 0; transform: translateZ(0); }
  .main-inner { padding-top: calc(76px + env(safe-area-inset-top)); }
  html, body { overscroll-behavior-y: none; } /* no rubber-band drag pulling the bars */
}

/* ---- Nothing spills off the screen on phones ---- */
/* Info bubbles: not laid out at all while closed (so they can't widen the page); JS nudges them on screen. */
.info-bubble { display: none; }
.info:hover .info-bubble, .info-btn:focus-visible + .info-bubble, .info.open .info-bubble { display: block; }
.info-bubble { max-width: calc(100vw - 24px); }
/* Casual score boxes: the two steppers share the row and shrink to fit. */
.score-row .field { flex: 1 1 0; min-width: 0; }
.score-row .stepper { display: flex; width: 100%; max-width: 200px; }
.score-row .stepper-value { flex: 1; width: auto; min-width: 0; }
@media (max-width: 420px) { .score-row { gap: 8px; } .score-row .stepper-btn { width: 38px; } }
/* "Best of [n] frames": the number box shrinks rather than pushing "frames" off the edge. */
.bestof { max-width: 100%; }
.bestof-input { flex: 0 1 96px; min-width: 48px; }
/* Long words, names and links wrap instead of overflowing. */
.main-inner { overflow-wrap: break-word; }
.main-inner, .card, .hub-tile { min-width: 0; }
/* Match format (doubles / singles / best of): stack on phones instead of three squashed columns. */
@media (max-width: 560px) {
  .form-grid-3 { grid-template-columns: minmax(0, 1fr) !important; gap: 18px !important; }
  .form-grid-2 { grid-template-columns: minmax(0, 1fr); }
}

/* Phones: the bars never move or flash; the selected button gets a shaded circle behind its icon. */
@media (max-width: 760px) {
  .mobile-topbar, .rail { will-change: transform; }
  .rail-item, .topbar-logo, .topbar-profile {
    -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; user-select: none;
    transition: none; transform: none;
  }
  .rail-item, .rail-item:hover, .rail-item:active, .rail-item.active { background: none; }
  .rail-item:focus { outline: none; }
  .rail-item:focus-visible .icon { outline: 2px solid var(--fg); outline-offset: 1px; }
  /* Every icon always reserves the circle's space, so selecting a button never shifts anything. */
  .rail-item .icon { box-sizing: content-box; width: 22px; height: 22px; padding: 7px; border-radius: 50%; background: transparent; }
  .rail-item.active .icon { background: var(--muted-2); }
  .rail-item.active .rail-label { color: var(--fg); }
  .rail-badge { top: 0; right: calc(50% - 26px); }
  /* Profile (top right): shaded circle around the avatar when you're on your profile. */
  .topbar-profile { width: 46px; height: 46px; border-radius: 50%; }
  .topbar-profile.active { background: var(--muted-2); }
  .topbar-profile.active .avatar-sm { box-shadow: none; }
}
@media (max-width: 760px) {
  .rail-item.active .icon, .topbar-profile.active { background: color-mix(in srgb, var(--fg) 16%, transparent); }
}

.banner-link { color: inherit; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); }
.banner-link:hover { text-decoration-color: currentColor; }

/* Dark mode switch (profile) */
.theme-switch { display: inline-flex; align-items: center; gap: 10px; padding: 6px 10px 6px 12px; border: 1px solid var(--border-strong); border-radius: 999px;
  background: none; color: var(--fg); font: inherit; font-size: 13.5px; font-weight: 500; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.theme-switch .icon, .theme-switch > svg { width: 16px; height: 16px; }
.switch-track { position: relative; width: 40px; height: 24px; border-radius: 999px; background: var(--bar-strong); transition: background .15s; flex: none; }
.switch-thumb { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .3); transition: transform .15s; }
.theme-switch[aria-checked="true"] .switch-track { background: var(--win); }
.theme-switch[aria-checked="true"] .switch-thumb { transform: translateX(16px); }
.theme-switch:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
/* The whole "Powered by ForLoop" banner is one big link to the website (the title link stretches over it);
   "Get the info pack" sits above it so it still goes to the info pack. */
.banner { position: relative; cursor: pointer; transition: border-color .15s, background .15s; }
.banner:hover { border-color: var(--border-strong); background: var(--muted); }
.banner-link::after { content: ''; position: absolute; inset: 0; border-radius: inherit; }
.banner-link:focus-visible { outline: none; }
.banner:has(.banner-link:focus-visible) { outline: 2px solid var(--fg); outline-offset: 2px; }
.banner-text a { position: relative; z-index: 1; }

/* Pop-ups: the page behind is locked (see lockScroll in ui.js); a tall pop-up scrolls inside itself instead. */
.overlay { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.dialog { margin-bottom: 16px; }

/* Profile header: player code centred; buttons evenly spaced and the same size. */
.profile-meta { align-items: center; gap: 16px; }
.profile-meta .player-code { align-self: center; }
.profile-meta .inline-actions { gap: 10px; justify-content: center; }
.profile-meta .install-wrap { display: inline-flex; }
.profile-meta .install-wrap:empty { display: none; }
@media (max-width: 760px) {
  .profile-meta { align-items: stretch; width: 100%; }
  .profile-meta .player-code { align-self: center; }
  /* Phones: one tidy column, every row the same width and height, with even gaps. */
  .profile-meta .inline-actions { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; width: 100%; }
  .profile-meta .inline-actions > *, .profile-meta .install-wrap > .btn { width: 100%; min-height: 44px; justify-content: center; }
  .profile-meta .theme-switch { justify-content: space-between; padding: 0 14px; border-radius: var(--radius-sm); }
  .profile-meta .theme-switch > span:not(.switch-track) { margin-right: auto; }
}
@media (max-width: 760px) {
  .profile-meta .theme-switch { justify-content: flex-start; }
  .profile-meta .theme-switch > span:not(.switch-track) { margin-right: 0; }
  .profile-meta .theme-switch .switch-track { margin-left: auto; }
}

/* Pencil next to your name on your profile (replaces the Edit name button). */
.player-name { min-width: 0; }
.name-edit { display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px; padding: 0; margin-left: -4px;
  border: 0; border-radius: 50%; background: none; color: var(--muted-fg); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.name-edit .icon, .name-edit svg { width: 18px; height: 18px; }
.name-edit:hover, .name-edit:focus-visible { color: var(--fg); background: var(--muted-2); outline: none; }

/* Anything marked hidden stays hidden, whatever its display style. */
[hidden] { display: none !important; }

/* Pop-ups sit in the middle of the screen over a grey shade.
   margin:auto centres it but still lets a tall pop-up scroll from its top (align-items:center would cut it off). */
.overlay { align-items: flex-start; padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)); }
.overlay .dialog { margin: auto; }
.overlay.open { background: rgb(17 17 19 / 0.55); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.overlay { z-index: 100; } /* above the phone top/bottom bars too */

/* Profile filter: "Tournament ▾" pill + its menu */
.scope-drop { display: inline-flex; align-items: center; gap: 6px; }
.scope-drop .icon, .scope-drop svg { width: 15px; height: 15px; transition: transform .15s; }
.scope-drop[aria-expanded="true"] .icon, .scope-drop[aria-expanded="true"] svg { transform: rotate(180deg); }
.scope-menu { position: fixed; z-index: 90; min-width: 200px; max-width: calc(100vw - 24px); max-height: min(360px, 60vh); overflow-y: auto;
  padding: 6px; border: 1px solid var(--border-strong); border-radius: 14px; background: var(--bg); box-shadow: 0 12px 32px rgb(0 0 0 / 0.25); }
.scope-option { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 10px 12px; border: 0; border-radius: 9px;
  background: none; color: var(--fg); font: inherit; font-size: 14.5px; text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.scope-option:hover, .scope-option:focus-visible { background: var(--muted-2); outline: none; }
.scope-option.active { font-weight: 600; }
.scope-option .icon, .scope-option svg { width: 16px; height: 16px; flex: none; }
.scope-empty { margin: 0; padding: 10px 12px; color: var(--muted-fg); font-size: 14px; }

/* ----- organiser's manual match-up override ----- */
.fixtures-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.fixtures-toolbar p { margin: 0; }
.fixture-edit-row { display: flex; align-items: center; gap: 6px; }
.fixture-edit-row .fixture-line { flex: 1; min-width: 0; margin-right: 0; }
.fixture-edit {
  flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 999px;
  border: 0; background: transparent; color: var(--muted-fg); cursor: pointer;
}
.fixture-edit:hover, .fixture-edit:focus-visible { background: var(--muted); color: var(--fg); }
.fixture-edit .icon { width: 16px; height: 16px; }
.dialog-matchup { max-width: 480px; }
.matchup-form { margin-top: 16px; }
.matchup-teams { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 10px; align-items: end; }
.matchup-swap { height: 40px; width: 40px; padding: 0; justify-content: center; }
.matchup-note { margin: 0; }
.dialog-matchup .dialog-actions { flex-wrap: wrap; }
.dialog-matchup .matchup-delete { margin-right: auto; color: var(--loss); }
@media (max-width: 480px) {
  .matchup-teams { grid-template-columns: minmax(0, 1fr); }
  .matchup-swap { justify-self: center; transform: rotate(90deg); }
}

/* ----- catch up past results ----- */
.catchup-div { max-width: 320px; margin-bottom: 20px; }
.catchup-rows { display: flex; flex-direction: column; gap: 8px; }
.catchup-head, .catchup-row {
  display: grid; align-items: center; gap: 8px;
  grid-template-columns: 28px 150px minmax(0, 1fr) 60px 10px 60px minmax(0, 1fr) 34px;
}
.catchup-row.team { grid-template-areas: 'num date home hs dash as away x' '. . frames frames frames frames frames .'; }
.catchup-head { font-size: 12px; color: var(--muted-fg); padding-bottom: 6px; }
.catchup-head .right { grid-column: 3; }
.catchup-head .center-text { grid-column: 4 / 7; text-align: center; }
.catchup-num { color: var(--muted-fg); font-size: 13px; text-align: center; display: grid; place-items: center; }
.catchup-num .icon { width: 15px; height: 15px; }
.catchup-score { text-align: center; padding-left: 4px; padding-right: 4px; -moz-appearance: textfield; }
.catchup-score::-webkit-inner-spin-button, .catchup-score::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.catchup-dash { text-align: center; color: var(--muted-fg); }
.catchup-team { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.catchup-team.catchup-home { text-align: right; }
.catchup-frames { grid-column: 3 / 8; display: flex; align-items: center; justify-content: center; gap: 8px; }
.catchup-frames .catchup-score { width: 60px; }
.catchup-row.team .catchup-frames { grid-area: frames; }
.catchup-row.team .catchup-num { grid-area: num; } .catchup-row.team .catchup-date { grid-area: date; }
.catchup-row.team .catchup-home { grid-area: home; } .catchup-row.team > .catchup-score:nth-of-type(2) { grid-area: hs; }
.catchup-row.team > .catchup-dash { grid-area: dash; } .catchup-row.team > .catchup-score:nth-of-type(3) { grid-area: as; }
.catchup-row.team .catchup-away { grid-area: away; } .catchup-row.team .catchup-remove, .catchup-row.team .catchup-week { grid-area: x; }
.catchup-row.team { padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.catchup-week { font-size: 12px; color: var(--muted-fg); white-space: nowrap; }
.catchup-row.due { grid-template-columns: 28px 150px minmax(0, 1fr) 60px 10px 60px minmax(0, 1fr) 110px; }
.catchup-row.due.team { grid-template-areas: 'num date home hs dash as away x' '. . frames frames frames frames frames .'; }
.catchup-remove {
  width: 34px; height: 34px; border-radius: 999px; border: 0; background: transparent; color: var(--muted-fg);
  display: grid; place-items: center; cursor: pointer;
}
.catchup-remove:hover, .catchup-remove:focus-visible { background: var(--muted); color: var(--fg); }
.catchup-remove .icon { width: 16px; height: 16px; }
.catchup-add { margin-top: 14px; }
.catchup-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.catchup-bar .form-error { flex-basis: 100%; margin: 0; }
.catchup-bar p.muted { margin: 0; flex: 1 1 260px; }

/* Phones: each match becomes a little card — date, then Home [score], Away [score]. */
@media (max-width: 760px) {
  .catchup-head { display: none; }
  .catchup-row, .catchup-row.team, .catchup-row.due, .catchup-row.due.team {
    grid-template-columns: minmax(0, 1fr) 64px;
    grid-template-areas: 'date x' 'home hs' 'away as' 'frames frames';
    padding: 12px; border: 1px solid var(--border); border-radius: 12px; row-gap: 8px;
  }
  .catchup-num, .catchup-dash { display: none; }
  .catchup-row .catchup-date { grid-area: date; }
  .catchup-row .catchup-home { grid-area: home; }
  .catchup-row .catchup-away { grid-area: away; }
  .catchup-row > .catchup-score:nth-of-type(2) { grid-area: hs; }
  .catchup-row > .catchup-score:nth-of-type(3) { grid-area: as; }
  .catchup-row .catchup-remove { grid-area: x; justify-self: end; }
  .catchup-row .catchup-week { display: none; }
  .catchup-row.due .catchup-date { grid-column: 1 / -1; }
  .catchup-row .catchup-frames { grid-area: frames; justify-content: flex-start; }
  .catchup-frames .catchup-dash { display: inline; }
  .catchup-team.catchup-home { text-align: left; }
}

/* ----- organisers card ----- */
.organiser-add { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.organiser-add p { margin: 0; }
.organiser-add .inline-form .select-wrap { flex: 1; min-width: 0; }
.organiser-add .inline-form .select-wrap { flex: 1 1 200px; }
.organiser-add .inline-form .input { flex: 1 1 160px; min-width: 0; width: auto; }

/* ----- team logos ----- */
.team-logo {
  display: inline-grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 10px;
  object-fit: cover; background: var(--muted); box-shadow: inset 0 0 0 1px var(--border);
}
img.team-logo { box-shadow: 0 0 0 1px var(--border); }
.team-logo-initials { background: hsl(var(--hue, 140) 40% 38%); color: #fff; font-size: 12.5px; font-weight: 700; letter-spacing: 0.02em; box-shadow: none; }
.team-logo.xs { width: 20px; height: 20px; border-radius: 6px; font-size: 8.5px; }
.team-logo.lg { width: 48px; height: 48px; border-radius: 12px; font-size: 16px; }
.team-logo.xl { width: 64px; height: 64px; border-radius: 16px; font-size: 22px; }
.team-logo.xxl { width: 128px; height: 128px; border-radius: 24px; font-size: 40px; }
.team-name { display: inline-flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%; }
.team-name-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-title { display: inline-flex; align-items: center; gap: 16px; min-width: 0; }
.team-logo-btn { position: relative; border: 0; padding: 0; background: none; cursor: pointer; border-radius: 16px; flex: none; }
.team-logo-btn:focus-visible { outline: 2px solid var(--fg); outline-offset: 3px; }
.team-logo-edit {
  position: absolute; right: -6px; bottom: -6px; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; background: var(--fg); color: var(--bg); box-shadow: 0 0 0 3px var(--bg);
}
.team-logo-edit .icon { width: 13px; height: 13px; }
.sb-team .team-logo { margin-bottom: 8px; }
.sb-team.right .team-logo { margin-left: auto; }
.logo-preview { display: grid; place-items: center; margin: 20px 0 16px; }
.logo-dialog .form-error { text-align: center; margin-top: 10px; }
.logo-dialog .dialog-actions { flex-wrap: wrap; }
.logo-dialog .logo-remove { margin-right: auto; color: var(--loss); }
@media (max-width: 560px) {
  .team-logo.xl { width: 52px; height: 52px; border-radius: 14px; font-size: 18px; }
  .team-title { gap: 12px; }
}

/* ----- player photos ----- */
img.avatar-img { object-fit: cover; background: var(--muted); padding: 0; }
.avatar-sm.xxl { width: 128px; height: 128px; font-size: 40px; }
.avatar-edit-btn { border-radius: 50%; }
.avatar-edit-btn .team-logo-edit { right: -4px; bottom: -4px; width: 22px; height: 22px; }
.avatar-edit-btn .team-logo-edit .icon { width: 11px; height: 11px; }
.team-title .name-edit { margin-left: -6px; }

/* Phones: form buttons stack full width, main action on top (it's last in the row on wider screens). */
@media (max-width: 560px) {
  .form-actions { flex-direction: column-reverse; align-items: stretch; }
  .form-actions .btn { width: 100%; justify-content: center; }
}

/* ----- ⋯ action menu (team player roles) ----- */
.action-menu-btn {
  display: grid; place-items: center; width: 36px; height: 36px; flex: none; padding: 0;
  border: 0; border-radius: 999px; background: transparent; color: var(--muted-fg); cursor: pointer;
}
.action-menu-btn:hover, .action-menu-btn:focus-visible, .action-menu-btn[aria-expanded="true"] { background: var(--muted); color: var(--fg); outline: none; }
.action-menu-btn .icon { width: 20px; height: 20px; }
.action-menu {
  position: fixed; z-index: 95; min-width: 220px; max-width: calc(100vw - 16px); padding: 6px;
  background: var(--card, var(--bg)); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 12px 32px rgb(0 0 0 / .22);
}
.action-menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; border-radius: 9px;
  background: none; color: var(--fg); font: inherit; font-size: 14px; text-align: left; cursor: pointer; min-height: 40px;
}
.action-menu-item:hover, .action-menu-item:focus-visible { background: var(--muted); outline: none; }
.action-menu-item .icon { width: 16px; height: 16px; flex: none; color: var(--muted-fg); }
.action-menu-item.danger, .action-menu-item.danger .icon { color: var(--loss); }
.action-menu-divider { height: 1px; margin: 4px 6px; background: var(--border); }

/* ----- team code ----- */
.team-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 12px; }
@media (max-width: 560px) { .team-meta { align-items: stretch; } .team-meta .player-code { align-self: center; } }
.add-team-or { margin: 14px 0 8px; }
.tc-list { display: flex; flex-direction: column; gap: 8px; width: 100%; margin-top: 18px; text-align: left; }
.tc-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 0; border-top: 1px solid var(--border); }
.tc-name { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

/* Buttons that must keep their words in list rows on phones (e.g. "Accept"). */
.row-right .btn.keep-label > span:not(.icon) { display: inline; }
.invites-card { border-color: color-mix(in srgb, var(--brand) 45%, var(--border)); }
@media (max-width: 560px) {
  .invites-card .row { flex-wrap: wrap; }
  .invites-card .row-text { flex: 1 1 calc(100% - 60px); }
  .invites-card .row-right { width: 100%; justify-content: flex-end; }
}

/* ----- side bar tooltips (computers only: the phone bottom bar already shows its labels) ----- */
@media (min-width: 761px) {
  .rail { z-index: 30; }
  .rail [data-tip] { position: relative; }
  .rail [data-tip]::after, .rail [data-tip]::before {
    position: absolute; left: calc(100% + 12px); top: 50%; z-index: 60;
    opacity: 0; pointer-events: none; transform: translate(-4px, -50%);
    transition: opacity 0.12s ease, transform 0.12s ease; transition-delay: 0s;
  }
  .rail [data-tip]::after {
    content: attr(data-tip); white-space: nowrap;
    padding: 6px 10px; border-radius: 8px;
    background: var(--fg); color: var(--bg); font-size: 13px; font-weight: 500; line-height: 1.3; letter-spacing: 0;
    box-shadow: 0 6px 18px rgb(0 0 0 / 0.18);
  }
  /* little arrow pointing at the icon */
  .rail [data-tip]::before {
    content: ''; left: calc(100% + 6px); width: 0; height: 0;
    border: 6px solid transparent; border-right-color: var(--fg); border-left: 0;
  }
  .rail [data-tip]:hover::after, .rail [data-tip]:hover::before,
  .rail [data-tip]:focus-visible::after, .rail [data-tip]:focus-visible::before {
    opacity: 1; transform: translate(0, -50%); transition-delay: 0.15s;
  }
}
@media (min-width: 761px) and (prefers-reduced-motion: reduce) {
  .rail [data-tip]::after, .rail [data-tip]::before { transition: none; transform: translate(0, -50%); }
}

/* ----- casual: change the score ----- */
.score-edit { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: end; gap: 10px; margin: 18px 0 12px; }
.score-edit-side { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.score-edit-side .field-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-edit-side .stepper { width: 100%; }
.score-edit-dash { padding-bottom: 12px; color: var(--muted-fg); }
.fl-unconfirmed { opacity: 0.6; font-style: italic; }

/* ----- result waiting for the other side ----- */
.awaiting-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 16px 20px; margin-bottom: 16px; border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--warning) 50%, var(--border));
  background: color-mix(in srgb, var(--warning) 9%, var(--bg));
}
.awaiting-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1 1 260px; }
@media (max-width: 560px) { .awaiting-banner .inline-actions { width: 100%; } .awaiting-banner .inline-actions .btn { flex: 1; justify-content: center; } }

/* ----- "new version ready" ----- */
.update-banner {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 125;
  bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 12px; max-width: calc(100vw - 32px);
  padding: 10px 10px 10px 16px; border-radius: 14px;
  background: var(--fg); color: var(--bg); font-size: 14px; box-shadow: 0 10px 30px rgb(0 0 0 / 0.25);
}
.update-banner .btn { background: var(--bg); color: var(--fg); }
@media (max-width: 760px) { .update-banner { bottom: calc(84px + env(safe-area-inset-bottom)); } }

/* ----- partners & opponents ----- */
.people-sorts { flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.people-find { position: relative; margin-bottom: 12px; }
.people-search { width: 100%; }
.people-suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20; padding: 4px;
  background: var(--card, var(--bg)); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 28px rgb(0 0 0 / 0.18);
  max-height: 280px; overflow-y: auto;
}
.people-option {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 40px;
  padding: 8px 10px; border: 0; border-radius: 8px; background: none; color: var(--fg); font: inherit; text-align: left; cursor: pointer;
}
.people-option:hover, .people-option:focus-visible { background: var(--muted); outline: none; }
.people-none { margin: 0; padding: 8px 10px; }
.people-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 12px; }
.people-chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 4px 4px 10px; border-radius: 999px;
  background: var(--muted); border: 1px solid var(--border); font-size: 13px;
}
.people-chip button { display: grid; place-items: center; width: 22px; height: 22px; border: 0; border-radius: 50%; background: none; color: var(--muted-fg); cursor: pointer; padding: 0; }
.people-chip button:hover { background: var(--muted-2); color: var(--fg); }
.people-chip .icon { width: 12px; height: 12px; }
.link-btn { border: 0; background: none; padding: 4px 6px; color: var(--muted-fg); font: inherit; font-size: 13px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.people-foot { margin: 10px 0 0; }

/* ----- pagination ----- */
.pagination { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px; margin-top: 18px; }
.page-nums { display: flex; align-items: center; gap: 4px; }
.page-btn {
  display: grid; place-items: center; min-width: 38px; height: 38px; padding: 0 8px;
  border: 1px solid var(--border); border-radius: 10px; background: transparent; color: var(--fg);
  font: inherit; font-size: 14px; font-variant-numeric: tabular-nums; cursor: pointer;
}
.page-btn:hover:not(:disabled), .page-btn:focus-visible { background: var(--muted); outline: none; }
.page-btn.active { background: var(--fg); color: var(--bg); border-color: var(--fg); font-weight: 600; }
.page-btn:disabled { opacity: 0.35; cursor: default; }
.page-btn .icon { width: 16px; height: 16px; }
.page-gap { min-width: 20px; text-align: center; color: var(--muted-fg); }
.page-count { flex-basis: 100%; text-align: center; font-size: 13px; color: var(--muted-fg); }

/* Donut keys: the game-type colours (class names are built in charts.js as `sw-${cls}`, e.g. sw-cat-1). */
.sw-cat-1 { background: var(--cat-1); } .sw-cat-2 { background: var(--cat-2); }
.sw-cat-3 { background: var(--cat-3); } .sw-cat-4 { background: var(--cat-4); }
/* More room between each donut and its key, especially once the donuts stack one per row. */
.donut-block { gap: 28px; }
@media (max-width: 1180px) { .donut-block { gap: 40px; } }
@media (max-width: 400px) { .donut-block { gap: 24px; } }

/* Page-header buttons once they stack (e.g. Join tournament / New tournament): a centred column. */
@media (max-width: 760px) {
  .page-meta > .inline-actions { flex-direction: column; align-items: stretch; width: 100%; max-width: 420px; margin: 0 auto; }
  .page-meta > .btn { max-width: 420px; margin: 0 auto; }
  .page-meta:has(> .inline-actions, > .btn) { justify-content: center; }
}

/* ---- Ad banner: pinned to the bottom of the screen (above the bottom bar on phones) ---- */
.ad-banner {
  position: sticky; bottom: 16px; z-index: 30; overflow: hidden;
  display: flex; align-items: center; gap: 8px;
  width: calc(100% - 64px); max-width: 920px; margin: 0 auto 16px; padding: 8px;
  border: 1px solid var(--border); border-radius: 18px; color: var(--fg);
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}
.ad-link { position: relative; z-index: 1; display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; color: inherit; text-decoration: none; border-radius: 12px; }
.ad-img { width: 112px; height: 63px; flex-shrink: 0; object-fit: cover; border-radius: 10px; background: var(--muted); }
.ad-noimg { display: grid; place-items: center; color: var(--muted-fg); }
.ad-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.ad-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ad-title strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ad-tag { flex-shrink: 0; font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; padding: 1px 6px; border-radius: 6px; border: 1px solid color-mix(in srgb, currentColor 30%, transparent); opacity: 0.75; }
.ad-desc { font-size: 14px; opacity: 0.72; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ad-go { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; padding: 8px 14px; border-radius: 999px; background: var(--fg); color: var(--bg); font-size: 14px; font-weight: 500; }
.ad-go .icon { width: 15px; height: 15px; }
.ad-link:hover .ad-go { opacity: 0.88; }
.ad-count { position: relative; z-index: 1; font-size: 12px; opacity: 0.7; font-variant-numeric: tabular-nums; }
.ad-close { position: relative; z-index: 1; display: grid; place-items: center; width: 32px; height: 32px; flex-shrink: 0; border: 0; border-radius: 50%; background: none; color: inherit; opacity: 0.7; cursor: pointer; }
.ad-close:hover { opacity: 1; background: color-mix(in srgb, currentColor 12%, transparent); }
.ad-close .icon { width: 16px; height: 16px; }
/* where the picture sits */
.ad-pos-left .ad-img { order: 0; }
.ad-pos-left .ad-text { order: 1; }
/* centre = the middle of the whole banner (not just between the words and Visit); the words keep to the left half */
.ad-pos-center:not(.ad-fill) .ad-link { position: static; }
.ad-pos-center:not(.ad-fill) .ad-img { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.ad-pos-center:not(.ad-fill) .ad-text { flex: 0 1 auto; max-width: calc(50% - 56px - 24px); }
.ad-pos-center:not(.ad-fill) .ad-go { margin-left: auto; }
.ad-pos-right .ad-text { order: 0; }
.ad-pos-right .ad-img { order: 4; } /* far right, after Visit */
.ad-go { order: 3; }
/* designed banners: their own background, text to suit it */
.ad-designed { backdrop-filter: none; -webkit-backdrop-filter: none; border-color: color-mix(in srgb, currentColor 14%, transparent); }
.ad-on-dark { color: #fff; }
.ad-on-dark .ad-go { background: #fff; color: #111; }
.ad-on-light { color: #111; }
.ad-on-light .ad-go { background: #111; color: #fff; }
.ad-on-light .ad-noimg, .ad-on-dark .ad-noimg { background: color-mix(in srgb, currentColor 10%, transparent); color: inherit; }
/* Fit: the whole picture, as tall as the banner, never cropped; the banner's colours show around it */
.ad-fit { padding: 0 8px 0 0; min-height: 80px; }
.ad-fit .ad-link { align-self: stretch; }
.ad-fit .ad-img { width: auto; height: 80px; max-width: 42%; object-fit: contain; border-radius: 0; background: none; }
.ad-fit .ad-text { padding: 10px 0; }
.ad-fit.ad-pos-right { padding: 0; }
.ad-fit.ad-pos-right .ad-link { padding-left: 14px; }
.ad-fit.ad-pos-center .ad-link { padding-left: 14px; }
.ad-fit.ad-pos-center:not(.ad-fill) .ad-img { top: 0; height: 100%; transform: translateX(-50%); }
.ad-fit.ad-pos-center:not(.ad-fill) .ad-text { max-width: 30%; }
/* picture fills the banner, with a wash behind the words */
.ad-fill { display: block; padding: 0; gap: 0; }
.ad-fill-link { display: block; position: relative; line-height: 1.3; color: inherit; text-decoration: none; }
/* the whole picture, in its own shape; a very tall one is shrunk to fit (240px high) with the background around it */
.ad-fill-img { display: block; width: 100%; height: auto; min-height: 64px; max-height: 240px; object-fit: contain; }
/* the words on top, placed on a 3×3 grid */
.ad-fill-layer { position: absolute; inset: 0; display: flex; padding: 10px 14px; }
.ad-fill-layer.ad-v-top { align-items: flex-start; }
.ad-fill-layer.ad-v-middle { align-items: center; }
.ad-fill-layer.ad-v-bottom { align-items: flex-end; }
.ad-fill-layer.ad-h-left { justify-content: flex-start; }
.ad-fill-layer.ad-h-center { justify-content: center; }
.ad-fill-layer.ad-h-right { justify-content: flex-end; }
.ad-fill-words { display: flex; align-items: center; gap: 14px; max-width: 100%; min-width: 0; }
.ad-fill-layer.ad-h-center .ad-fill-words { text-align: center; }
.ad-fill-layer.ad-h-center .ad-fill-words .ad-title { justify-content: center; }
.ad-fill-words .ad-text { flex: 0 1 auto; }
.ad-fill-words .ad-desc { opacity: 0.9; }
/* light words (with a dark shade) or dark words (with a light shade); the shade fades in from the words' side */
.ad-tone-light { color: #fff; }
.ad-tone-light .ad-fill-words { text-shadow: 0 1px 3px rgba(0, 0, 0, 0.55); }
.ad-tone-light .ad-go { background: #fff; color: #111; text-shadow: none; }
.ad-tone-dark { color: #111; }
.ad-tone-dark .ad-fill-words { text-shadow: 0 1px 2px rgba(255, 255, 255, 0.6); }
.ad-tone-dark .ad-go { background: #111; color: #fff; text-shadow: none; }
.ad-fill-shade { position: absolute; inset: 0; pointer-events: none; --shade: rgba(0, 0, 0, 0.55); }
.ad-tone-dark .ad-fill-shade { --shade: rgba(255, 255, 255, 0.6); }
.ad-shade-left .ad-fill-shade { background: linear-gradient(90deg, var(--shade), transparent 75%); }
.ad-shade-right .ad-fill-shade { background: linear-gradient(270deg, var(--shade), transparent 75%); }
.ad-shade-center .ad-fill-shade { background: radial-gradient(ellipse at center, var(--shade), transparent 75%); }
.ad-shade-all .ad-fill-shade { background: color-mix(in srgb, var(--shade) 65%, transparent); } /* words in several places: an even shade */
/* separate placement: each spot stacks what's in it */
.ad-fill-stack { display: flex; flex-direction: column; gap: 4px; max-width: 100%; min-width: 0; }
.ad-fill-layer.ad-h-left .ad-fill-stack { align-items: flex-start; text-align: left; }
.ad-fill-layer.ad-h-center .ad-fill-stack { align-items: center; text-align: center; }
.ad-fill-layer.ad-h-right .ad-fill-stack { align-items: flex-end; text-align: right; }
.ad-fill-stack .ad-title, .ad-fill-stack .ad-desc { max-width: 100%; }
.ad-fill-stack .ad-desc { opacity: 0.9; }
.ad-tone-light .ad-fill-stack { text-shadow: 0 1px 3px rgba(0, 0, 0, 0.55); }
.ad-tone-dark .ad-fill-stack { text-shadow: 0 1px 2px rgba(255, 255, 255, 0.6); }
/* the small × (and the 1/2 counter) in the top-right corner of every banner */
.ad-extras { position: absolute; z-index: 3; top: 5px; right: 5px; display: flex; align-items: center; gap: 2px; padding: 1px; border-radius: 999px; background: rgba(0, 0, 0, 0.45); color: #fff; }
.ad-extras .ad-count { padding-left: 6px; font-size: 11px; opacity: 0.9; }
.ad-extras .ad-close { width: 22px; height: 22px; opacity: 0.9; color: #fff; }
.ad-extras .ad-close:hover { opacity: 1; background: rgba(255, 255, 255, 0.18); }
.ad-extras .ad-close .icon { width: 13px; height: 13px; }
.ad-has-x:not(.ad-fill) { padding-right: 34px; }
.ad-has-x .ad-fill-layer.ad-h-right { padding-right: 38px; } /* right-hand words keep clear of the × */
@media (max-width: 760px) {
  .ad-banner { bottom: calc(90px + env(safe-area-inset-bottom)); width: calc(100% - 24px); margin-bottom: calc(96px + env(safe-area-inset-bottom)); gap: 4px; }
  .ad-link { gap: 10px; }
  .ad-img { width: 72px; height: 48px; }
  .ad-go { padding: 7px; font-size: 0; gap: 0; } /* phones: just the arrow */
  .ad-go .icon { width: 16px; height: 16px; }
  .ad-pos-center:not(.ad-fill) .ad-text { max-width: calc(50% - 36px - 16px); }
  .ad-fit { min-height: 64px; }
  .ad-fill-img { max-height: 160px; }
  .ad-fill-layer { padding: 6px 10px; }
  .ad-fill-words { gap: 8px; }
  .ad-fit .ad-img { width: auto; height: 64px; }
}
/* a banner shown as a preview (back office), not pinned */
.ad-preview { position: relative; bottom: auto; z-index: 0; width: 100%; max-width: none; margin: 0; } /* stays under the back office's top bar */
.ad-preview-phone { max-width: 360px; }
.ad-preview-phone.ad-banner { gap: 4px; }
.ad-preview-phone .ad-link { gap: 10px; }
.ad-preview-phone .ad-img { width: 72px; height: 48px; }
.ad-preview-phone .ad-go { padding: 7px; font-size: 0; gap: 0; }
.ad-preview-phone.ad-pos-center:not(.ad-fill) .ad-text { max-width: calc(50% - 36px - 16px); }
.ad-preview-phone.ad-fit { min-height: 64px; }
.ad-preview-phone .ad-fill-img { max-height: 160px; }
.ad-preview-phone .ad-fill-layer { padding: 6px 10px; }
.ad-preview-phone .ad-fill-words { gap: 8px; }
.ad-preview-phone.ad-fit .ad-img { width: auto; height: 64px; }
.ad-preview-phone.ad-fit.ad-pos-center .ad-img { height: 100%; }
.ad-preview-phone.ad-fit.ad-pos-center .ad-text { max-width: 30%; }
