/**
 * DinkSync component library. Bootstrap (vendored, assets/vendor/bootstrap)
 * supplies the grid and JS-driven components (offcanvas, dropdown, modal);
 * this file owns every branded visual component; tokens.css owns the
 * variables both this file and templates read.
 *
 * Fonts: self-hosted only, by design — the service worker's network-first/
 * cache-first rules only cover this origin, and a PWA that promises
 * offline support shouldn't depend on a live Google Fonts request. The
 * family is shipped in assets/fonts/ as woff2 and declared below.
 */

/* Self-hosted so the service worker's same-origin caching covers them and
   an offline launch still renders in the brand's type. Poppins is the
   geometric, high-contrast modern sans the brand sheet calls for. */
@font-face {
  font-family: 'DinkSans';
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  src: url('/assets/fonts/poppins-bold.woff2') format('woff2');
}
@font-face {
  font-family: 'DinkSans';
  font-weight: 500;
  font-style: normal;
  font-display: swap;
  src: url('/assets/fonts/poppins-medium.woff2') format('woff2');
}
@font-face {
  font-family: 'DinkSans';
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  src: url('/assets/fonts/poppins-regular.woff2') format('woff2');
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--ds-bg);
  color: var(--ds-text);
  font-family: var(--ds-font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--ds-font-display);
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--ds-text);
  margin: 0 0 var(--ds-space-3);
}

a {
  color: var(--ds-accent-ink);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.text-muted {
  color: var(--ds-text-muted) !important;
}

.container-narrow {
  max-width: var(--ds-max-content-width);
  margin: 0 auto;
  padding: 0 var(--ds-space-4);
}

/* ---------------- Buttons ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ds-space-2);
  font-weight: 700;
  font-size: 0.95rem;
  border-radius: var(--ds-radius-pill);
  padding: 0.65rem 1.4rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.15s ease, background-color 0.15s ease;
  text-decoration: none;
}
.btn:active {
  transform: scale(0.98);
}
.btn-block {
  width: 100%;
}
.btn-primary {
  background: var(--ds-accent);
  color: var(--ds-accent-fg);
  box-shadow: var(--ds-shadow-sm);
}
.btn-primary:hover {
  box-shadow: var(--ds-shadow-md);
  text-decoration: none;
  filter: brightness(1.03);
}
.btn-secondary {
  background: transparent;
  color: var(--ds-text);
  border-color: var(--ds-border);
}
.btn-secondary:hover {
  background: var(--ds-slate-100);
  text-decoration: none;
}
.btn-dark {
  background: var(--ds-slate-900);
  color: var(--ds-white);
}
.btn-sm {
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
}

/* ---------------- Forms ---------------- */

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ds-text-muted);
  margin: var(--ds-space-4) 0 var(--ds-space-1);
}
.form-control {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border-radius: var(--ds-radius-md);
  border: 1.5px solid var(--ds-border);
  background: var(--ds-surface);
  color: var(--ds-text);
  font-size: 1rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-control:focus {
  outline: none;
  border-color: var(--ds-accent);
  box-shadow: 0 0 0 3px rgba(204, 255, 0, 0.35);
}

.alert {
  padding: var(--ds-space-3) var(--ds-space-4);
  border-radius: var(--ds-radius-md);
  font-size: 0.9rem;
  margin: var(--ds-space-4) 0;
}
.alert-danger {
  background: rgba(220, 38, 38, 0.1);
  color: #b91c1c;
  border: 1px solid rgba(220, 38, 38, 0.25);
}
:root[data-theme='dark'] .alert-danger {
  color: #fca5a5;
}
.alert-success {
  background: rgba(22, 163, 74, 0.1);
  color: #15803d;
  border: 1px solid rgba(22, 163, 74, 0.25);
}

/* ---------------- Cards ---------------- */

.card {
  background: var(--ds-surface);
  border-radius: var(--ds-radius-lg);
  border: 1px solid var(--ds-border);
  box-shadow: var(--ds-shadow-sm);
  padding: var(--ds-space-5);
}

/* ---------------- Auth page ---------------- */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--ds-space-4);
  background: radial-gradient(circle at top, var(--ds-slate-900), #060b18 65%);
}
.auth-card {
  width: 100%;
  max-width: 400px;
}
.auth-brand {
  text-align: center;
  margin-bottom: var(--ds-space-5);
}
.auth-logo {
  height: 40px;
}
.auth-tabs {
  display: flex;
  background: var(--ds-slate-100);
  border-radius: var(--ds-radius-pill);
  padding: 4px;
  margin-bottom: var(--ds-space-3);
}
:root[data-theme='dark'] .auth-tabs {
  background: rgba(255, 255, 255, 0.06);
}
.auth-tab {
  flex: 1;
  text-align: center;
  padding: 0.5rem;
  border-radius: var(--ds-radius-pill);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--ds-text-muted);
}
.auth-tab:hover {
  text-decoration: none;
}
.auth-tab.active {
  background: var(--ds-surface);
  color: var(--ds-text);
  box-shadow: var(--ds-shadow-sm);
}
.auth-form {
  display: flex;
  flex-direction: column;
}
.auth-form .btn {
  margin-top: var(--ds-space-5);
}
.auth-footnote {
  text-align: center;
  margin-top: var(--ds-space-4);
  font-size: 0.85rem;
  color: var(--ds-text-muted);
}

/* ---------------- PSR badge + reliability meter ---------------- */

.psr-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3em;
  background: var(--ds-slate-900);
  color: var(--ds-white);
  border-radius: var(--ds-radius-pill);
  padding: 0.3rem 0.75rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.psr-badge .psr-label {
  font-size: 0.65em;
  font-weight: 600;
  color: var(--ds-accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.psr-badge .psr-value {
  font-size: 1em;
}

.reliability-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: var(--ds-radius-pill);
  background: var(--ds-slate-100);
  color: var(--ds-text-muted);
}
:root[data-theme='dark'] .reliability-pill {
  background: rgba(255, 255, 255, 0.08);
}
.reliability-dot {
  width: 0.55em;
  height: 0.55em;
  border-radius: 50%;
  flex-shrink: 0;
}
.reliability-provisional .reliability-dot { background: var(--ds-reliability-provisional); }
.reliability-building .reliability-dot { background: var(--ds-reliability-building); }
.reliability-established .reliability-dot { background: var(--ds-reliability-established); }

/* ---------------- Match / player cards ---------------- */

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--ds-slate-200);
  border: 2px solid var(--ds-surface);
}
.avatar-stack {
  display: flex;
}
.avatar-stack .avatar {
  margin-left: -12px;
}
.avatar-stack .avatar:first-child {
  margin-left: 0;
}

.match-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ds-space-3);
  padding: var(--ds-space-3) var(--ds-space-4);
  border-radius: var(--ds-radius-md);
  border: 1px solid var(--ds-border);
  background: var(--ds-surface);
}

/* ---------------- Leaderboard podium ---------------- */

.podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: var(--ds-space-3);
  padding: var(--ds-space-5) 0 var(--ds-space-3);
}
.podium-spot {
  text-align: center;
  flex: 1;
  max-width: 120px;
}
.podium-spot .avatar {
  width: 56px;
  height: 56px;
  margin: 0 auto var(--ds-space-2);
}
.podium-spot.rank-1 .avatar {
  width: 72px;
  height: 72px;
  border: 3px solid var(--ds-accent);
}
.podium-rank {
  font-family: var(--ds-font-display);
  font-weight: 800;
  color: var(--ds-accent-ink);
}
:root[data-theme='dark'] .podium-rank {
  color: var(--ds-accent);
}

/* ---------------- Navigation ---------------- */

/* The mockup's list screens (Matches/Leaderboard/Players, screens 03-05) show
   a topnav that follows the page surface — white in light mode — rather than
   a permanently dark bar. */
.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--ds-space-3) var(--ds-space-4);
  background: var(--ds-surface);
  color: var(--ds-text);
  border-bottom: 1px solid var(--ds-border);
}
:root[data-theme='dark'] .topnav {
  background: var(--ds-slate-900);
  color: var(--ds-white);
  border-bottom-color: rgba(255, 255, 255, 0.07);
}
.topnav .brand {
  display: flex;
  align-items: center;
  gap: var(--ds-space-2);
  font-family: var(--ds-font-display);
  font-weight: 800;
  color: inherit;
}
.topnav .brand img {
  height: 26px;
  display: block;
}
/* Two wordmark cuts are emitted; show the one that suits the surface. */
.topnav .brand .brand-on-dark { display: none; }
.topnav .brand .brand-on-light { display: block; }
:root[data-theme='dark'] .topnav .brand .brand-on-light { display: none; }
:root[data-theme='dark'] .topnav .brand .brand-on-dark { display: block; }
/* The transparent bar always sits on a dark-scrimmed hero photo. */
.topnav-transparent .brand .brand-on-light,
.topnav-overlay .brand .brand-on-light { display: none !important; }
.topnav-transparent .brand .brand-on-dark,
.topnav-overlay .brand .brand-on-dark { display: block !important; }
/* Screens 01/02: on Home the bar sits directly on the hero photo. */
.topnav-transparent {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  background: none;
  border-bottom: none;
  color: #fff;
}
:root[data-theme='dark'] .topnav-transparent {
  background: none;
  border-bottom-color: transparent;
}
.topnav-transparent .icon-btn {
  color: #fff;
}

/* The mockup renders the bottom bar as a light, slightly floating bar in
   BOTH themes (see screens 01 dark and 02 light) — the active tab is dark
   ink with a lime underline beneath the label, not a lime-tinted icon. */
.bottom-tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: #fff;
  border-top: 1px solid rgba(15, 23, 42, 0.07);
  box-shadow: 0 -4px 18px rgba(15, 23, 42, 0.07);
  height: var(--ds-bottom-nav-height);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 40;
}
:root[data-theme='dark'] .bottom-tab-bar {
  background: #fff;
  border-top-color: rgba(15, 23, 42, 0.07);
}
.bottom-tab-bar a,
:root[data-theme='dark'] .bottom-tab-bar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--ds-slate-600);
}
.bottom-tab-bar a.active,
:root[data-theme='dark'] .bottom-tab-bar a.active {
  color: var(--ds-slate-900);
  font-weight: 700;
}
.bottom-tab-bar a span {
  position: relative;
  padding-bottom: 4px;
}
.bottom-tab-bar a.active span::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  border-radius: 2px;
  background: var(--ds-accent);
}
.bottom-tab-bar a:hover {
  text-decoration: none;
}

.page-with-bottom-nav {
  padding-bottom: calc(var(--ds-bottom-nav-height) + var(--ds-space-4));
}

/* ---------------- Admin sidebar ---------------- */

.admin-shell {
  display: flex;
  min-height: 100vh;
}
.admin-sidebar {
  width: var(--ds-sidebar-width);
  flex-shrink: 0;
  background: var(--ds-slate-900);
  color: var(--ds-white);
  padding: var(--ds-space-5) var(--ds-space-3);
}
.admin-sidebar .brand {
  display: flex;
  align-items: center;
  gap: var(--ds-space-2);
  padding: 0 var(--ds-space-2) var(--ds-space-5);
  font-family: var(--ds-font-display);
  font-weight: 800;
}
.admin-sidebar .brand img {
  height: 26px;
}
.admin-sidebar nav a {
  display: flex;
  align-items: center;
  gap: var(--ds-space-2);
  padding: 0.65rem var(--ds-space-3);
  border-radius: var(--ds-radius-md);
  color: #cbd5e1;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 2px;
}
.admin-sidebar nav a:hover {
  background: rgba(255, 255, 255, 0.06);
  text-decoration: none;
}
.admin-sidebar nav a.active {
  background: var(--ds-accent);
  color: var(--ds-slate-900);
}
.admin-main {
  flex: 1;
  min-width: 0;
  padding: var(--ds-space-6);
}

.admin-bottom-nav {
  display: none;
}
@media (max-width: 900px) {
  .admin-sidebar {
    display: none;
  }
  .admin-main {
    padding: var(--ds-space-4);
    padding-bottom: calc(var(--ds-bottom-nav-height) + var(--ds-space-4));
  }
  .admin-bottom-nav {
    display: flex;
  }
}

/* ---------------- Theme toggle ---------------- */

.theme-toggle {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--ds-white);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ---------------- Utility tables ---------------- */

.table-clean {
  width: 100%;
  border-collapse: collapse;
}
.table-clean th {
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ds-text-muted);
  padding: var(--ds-space-2) var(--ds-space-3);
  border-bottom: 1px solid var(--ds-border);
  background: none;
}
.table-clean td {
  padding: var(--ds-space-3);
  border-bottom: 1px solid var(--ds-border);
  vertical-align: middle;
  /* Bootstrap's vendored reset (table>:not(caption)>*>*) sets its own
     --bs-table-color on every table cell in the app, which resolves to a
     near-black tone that's unreadable on our dark surfaces. Reassert the
     design-system text color explicitly so it wins regardless of source
     order. */
  color: var(--ds-text);
  background: none;
}
.table-clean td.text-muted {
  /* Higher specificity than the ".table-clean td" rule above so cells
     that opt into the muted style (e.g. date columns) still get it. */
  color: var(--ds-text-muted);
}
.table-clean tr:last-child td {
  border-bottom: none;
}

/* ---------------- Install prompt / offline ---------------- */

.install-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ds-space-3);
  background: var(--ds-surface);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-md);
  padding: var(--ds-space-3) var(--ds-space-4);
  box-shadow: var(--ds-shadow-md);
}

.offline-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--ds-space-6);
  gap: var(--ds-space-3);
}

.btn-outline {
  background: var(--ds-surface);
  color: var(--ds-text);
  border: 1.5px solid var(--ds-border);
}
.btn-outline:hover {
  background: var(--ds-slate-100);
  text-decoration: none;
}
:root[data-theme='dark'] .btn-outline:hover {
  background: rgba(255, 255, 255, 0.06);
}

.install-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--ds-radius-md);
  flex-shrink: 0;
  object-fit: cover;
}
.install-copy {
  flex: 1;
  min-width: 0;
}
.install-copy strong {
  display: block;
  font-size: 0.95rem;
}
.install-copy span {
  display: block;
  font-size: 0.78rem;
  color: var(--ds-text-muted);
  margin-top: 2px;
}
.install-actions {
  display: flex;
  gap: var(--ds-space-2);
  flex-shrink: 0;
}

.offline-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--ds-slate-100);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ds-text-muted);
}
:root[data-theme='dark'] .offline-icon {
  background: rgba(255, 255, 255, 0.06);
}

/* ---------------- Icon buttons (hamburger / back / more) ---------------- */

.icon-btn {
  background: transparent;
  border: none;
  color: inherit;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.icon-btn:hover {
  background: rgba(148, 163, 184, 0.18);
}
.icon-btn svg {
  width: 20px;
  height: 20px;
}

/* Overlay variant: sits on top of a hero photo, needs its own scrim so it
   reads regardless of the theme or image underneath. */
.topnav-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--ds-space-3) var(--ds-space-4);
  z-index: 2;
}
.topnav-overlay .icon-btn {
  background: rgba(15, 23, 42, 0.4);
  color: #fff;
}
.topnav-overlay .icon-btn:hover {
  background: rgba(15, 23, 42, 0.6);
}
.topnav-overlay .brand img {
  height: 22px;
}

/* Offcanvas menu content (Bootstrap supplies the panel mechanics) */
.topnav-menu-list a {
  display: flex;
  align-items: center;
  gap: var(--ds-space-3);
  padding: 0.75rem var(--ds-space-2);
  border-radius: var(--ds-radius-md);
  color: var(--ds-text);
  font-weight: 600;
}
.topnav-menu-list a:hover {
  background: var(--ds-slate-100);
  text-decoration: none;
}
:root[data-theme='dark'] .topnav-menu-list a:hover {
  background: rgba(255, 255, 255, 0.06);
}
.topnav-menu-list hr {
  border-color: var(--ds-border);
  margin: var(--ds-space-3) 0;
}

/* ---------------- Stat tiles ---------------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--ds-space-3);
  margin-bottom: var(--ds-space-5);
}
.stat-grid.stat-grid-2 {
  grid-template-columns: repeat(2, 1fr);
}
.stat-tile {
  background: var(--ds-surface);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-md);
  padding: var(--ds-space-3) var(--ds-space-3);
  text-align: center;
}
.stat-tile .stat-value {
  font-family: var(--ds-font-display);
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--ds-text);
  line-height: 1.15;
}
.stat-tile .stat-label {
  font-size: 0.72rem;
  color: var(--ds-text-muted);
  margin-top: 1px;
}
/* Screen 08's admin tiles are left-aligned, not centred. */
.stat-grid-2 .stat-tile {
  text-align: left;
}
.stat-tile-dark {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.08);
}
.stat-tile-dark .stat-value {
  color: #fff;
}
.stat-tile-dark .stat-label {
  color: #a8b3c7;
}

/* ---------------- Segmented tabs (generalized auth-tabs) ---------------- */

.segmented-tabs {
  display: flex;
  background: var(--ds-slate-100);
  border-radius: var(--ds-radius-pill);
  padding: 4px;
  gap: 2px;
  margin-bottom: var(--ds-space-4);
}
:root[data-theme='dark'] .segmented-tabs {
  background: rgba(255, 255, 255, 0.06);
}
.segmented-tab {
  flex: 1;
  text-align: center;
  padding: 0.4rem 0.6rem;
  border-radius: var(--ds-radius-pill);
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--ds-text-muted);
  white-space: nowrap;
  background: none;
  border: none;
  cursor: pointer;
}
.segmented-tab:hover {
  text-decoration: none;
}
/* Every mockup screen shows the selected segment as a WHITE pill with dark
   ink, in dark mode as well as light (screens 01, 03, 04). */
.segmented-tab.active,
:root[data-theme='dark'] .segmented-tab.active {
  background: #fff;
  color: var(--ds-slate-900);
  font-weight: 700;
  box-shadow: var(--ds-shadow-sm);
}

/* ---------------- Filter chips ---------------- */

.chip-row {
  display: flex;
  gap: var(--ds-space-2);
  overflow-x: auto;
  padding-bottom: 2px;
  margin-bottom: var(--ds-space-4);
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar {
  display: none;
}
.filter-chip {
  flex-shrink: 0;
  padding: 0.32rem 0.8rem;
  border-radius: var(--ds-radius-pill);
  background: var(--ds-slate-100);
  color: var(--ds-text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  white-space: nowrap;
}
:root[data-theme='dark'] .filter-chip {
  background: rgba(255, 255, 255, 0.06);
}
.filter-chip:hover {
  text-decoration: none;
}
/* Screen 05: the selected rating filter is dark ink on light, and the
   inverse (white pill) on dark — never a lime fill. */
.filter-chip.active {
  background: var(--ds-slate-900);
  color: #fff;
  font-weight: 700;
}
:root[data-theme='dark'] .filter-chip.active {
  background: #fff;
  color: var(--ds-slate-900);
}

.attribute-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.85rem;
  border-radius: var(--ds-radius-pill);
  background: var(--ds-slate-100);
  color: var(--ds-text);
  font-weight: 600;
  font-size: 0.8rem;
}
:root[data-theme='dark'] .attribute-chip {
  background: rgba(255, 255, 255, 0.06);
}

/* ---------------- Search input ---------------- */

.search-wrap {
  position: relative;
  margin-bottom: var(--ds-space-4);
}
.search-wrap .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ds-text-muted);
  pointer-events: none;
}
.search-wrap input.form-control {
  padding-left: 2.35rem;
  padding-top: 0.55rem;
  padding-bottom: 0.55rem;
  font-size: 0.88rem;
  border-radius: var(--ds-radius-pill);
}
.search-wrap input.form-control::placeholder {
  color: var(--ds-text-muted);
  opacity: 1;
}

/* ---------------- Date strip (week picker) ---------------- */

.date-strip-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--ds-space-3);
  font-weight: 700;
}
.date-strip-header .icon-btn {
  color: var(--ds-text-muted);
}
.date-strip {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: var(--ds-space-4);
}
.date-cell {
  flex: 1;
  text-align: center;
  padding: 0.4rem 0.15rem;
  border-radius: var(--ds-radius-md);
  color: var(--ds-text);
}
.date-cell:hover {
  text-decoration: none;
}
/* Screen 03: day initials are sentence-case and small; the selected day is a
   dark rounded SQUARE, not a lime circle. */
.date-cell .dow {
  display: block;
  font-size: 0.62rem;
  color: var(--ds-text-muted);
  margin-bottom: 3px;
  letter-spacing: 0.01em;
}
.date-cell .dom {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  font-weight: 700;
  font-size: 0.85rem;
}
.date-cell.active .dom,
:root[data-theme='dark'] .date-cell.active .dom {
  background: var(--ds-slate-900);
  color: #fff;
}
:root[data-theme='dark'] .date-cell.active .dom {
  background: #fff;
  color: var(--ds-slate-900);
}

/* ---------------- Player list row ---------------- */

.player-row {
  display: flex;
  align-items: center;
  gap: var(--ds-space-3);
  padding: var(--ds-space-3);
  border-radius: var(--ds-radius-md);
  background: var(--ds-surface);
  border: 1px solid var(--ds-border);
  margin-bottom: var(--ds-space-2);
  color: var(--ds-text);
}
.player-row:hover {
  text-decoration: none;
  border-color: var(--ds-accent);
}
.player-row .player-name {
  font-weight: 700;
}
/* Screen 05 shows players as one connected list with hairline dividers,
   not as a stack of detached cards. */
.player-list {
  background: var(--ds-surface);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-lg);
  overflow: hidden;
  margin-bottom: var(--ds-space-4);
}
.player-list .player-row {
  border: 0;
  border-bottom: 1px solid var(--ds-border);
  border-radius: 0;
  margin-bottom: 0;
  background: none;
  padding: 0.6rem var(--ds-space-3);
}
.player-list .player-row:last-child {
  border-bottom: 0;
}
.player-list .player-row:hover {
  background: var(--ds-slate-100);
}
:root[data-theme='dark'] .player-list .player-row:hover {
  background: rgba(255, 255, 255, 0.04);
}
.player-list .player-name {
  font-size: 0.92rem;
}
.player-row .player-sub {
  font-size: 0.78rem;
  color: var(--ds-text-muted);
  margin-top: 1px;
}
.player-row .player-meta {
  margin-left: auto;
  text-align: right;
  display: flex;
  align-items: center;
  gap: var(--ds-space-3);
}
.player-row .chevron {
  color: var(--ds-text-muted);
  flex-shrink: 0;
}

/* ---------------- Podium rank badges ---------------- */

.podium-spot .rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 800;
  color: #fff;
  margin: 0 auto 4px;
}
.podium-spot.rank-1 .rank-badge { background: #eab308; }
.podium-spot.rank-2 .rank-badge { background: #94a3b8; }
.podium-spot.rank-3 .rank-badge { background: #c2703d; }
.podium-spot .crown {
  font-size: 1.1rem;
  line-height: 1;
  display: block;
  margin-bottom: 2px;
}

/* ---------------- Profile header / underline tabs ---------------- */

.profile-header {
  text-align: center;
  padding: var(--ds-space-4) 0 var(--ds-space-3);
}
.profile-header .avatar {
  width: 96px;
  height: 96px;
  margin: 0 auto var(--ds-space-3);
}
.profile-header .profile-name {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 1.3rem;
  margin-bottom: 0;
}
.verified-badge {
  color: var(--ds-success);
  display: inline-flex;
}

.underline-tabs {
  display: flex;
  gap: var(--ds-space-5);
  border-bottom: 1px solid var(--ds-border);
  margin-bottom: var(--ds-space-4);
}
.underline-tab {
  padding-bottom: 0.6rem;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--ds-text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
  cursor: pointer;
}
.underline-tab:hover {
  text-decoration: none;
}
.underline-tab.active {
  color: var(--ds-text);
  border-bottom-color: var(--ds-accent);
}

/* ---------------- Tournament hero + detail rows ---------------- */

.tournament-hero {
  position: relative;
  margin: 0 0 var(--ds-space-4);
  min-height: 300px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: var(--ds-space-5) var(--ds-space-4) var(--ds-space-4);
  background-size: cover;
  background-position: center;
  color: #fff;
}
.tournament-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.1) 0%, rgba(15, 23, 42, 0.55) 55%, rgba(15, 23, 42, 0.94) 100%);
}
.tournament-hero > * {
  position: relative;
  z-index: 1;
}
.tournament-hero h1 {
  color: #fff;
  font-size: 1.35rem;
  margin-bottom: var(--ds-space-2);
}
.tournament-meta {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.85rem;
  color: #e2e8f0;
  margin-bottom: var(--ds-space-3);
}
.tournament-meta span {
  display: flex;
  align-items: center;
  gap: 6px;
}
.tournament-hero .btn-row {
  display: flex;
  align-items: center;
  gap: var(--ds-space-2);
}
.tournament-tagline {
  font-family: var(--ds-font-display);
  font-weight: 800;
  letter-spacing: 0.08em;
  font-size: 0.8rem;
  margin-top: var(--ds-space-3);
  line-height: 1.7;
  text-transform: uppercase;
}

.detail-row {
  display: flex;
  align-items: center;
  gap: var(--ds-space-3);
  padding: var(--ds-space-3) 0;
  border-bottom: 1px solid var(--ds-border);
}
.detail-row:last-child {
  border-bottom: none;
}
.detail-row .detail-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--ds-slate-100);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--ds-text-muted);
}
:root[data-theme='dark'] .detail-row .detail-icon {
  background: rgba(255, 255, 255, 0.06);
}
.detail-row .detail-label {
  font-size: 0.78rem;
  color: var(--ds-text-muted);
}
.detail-row .detail-value {
  font-weight: 700;
}

/* ---------------- Promo banner (image + overlay text) ---------------- */

.promo-banner {
  position: relative;
  border-radius: var(--ds-radius-lg);
  overflow: hidden;
  min-height: 130px;
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: flex-end;
  padding: var(--ds-space-4);
  margin: var(--ds-space-4) 0;
}
.promo-banner::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0) 35%, rgba(15, 23, 42, 0.8) 100%);
}
.promo-banner .promo-text {
  position: relative;
  z-index: 1;
  color: #fff;
  font-weight: 800;
  font-family: var(--ds-font-display);
  font-size: 1.05rem;
}
.promo-banner .promo-underline {
  width: 36px;
  height: 3px;
  background: var(--ds-accent);
  margin-bottom: 8px;
}

/* ---------------- Admin mobile shell (screen-08 style, forced dark) ---------------- */

.admin-mobile-shell {
  min-height: 100vh;
  background: #0f172a;
  color: #fff;
  padding: var(--ds-space-4);
  padding-bottom: calc(var(--ds-bottom-nav-height) + var(--ds-space-4));
}
.admin-mobile-shell h1 {
  color: #fff;
  font-size: 1.15rem;
  margin-bottom: var(--ds-space-3);
}
.admin-mobile-shell .text-muted {
  color: #a8b3c7 !important;
}
.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: calc(var(--ds-space-4) * -1) calc(var(--ds-space-4) * -1) var(--ds-space-4);
  padding: var(--ds-space-3) var(--ds-space-4);
}
.admin-topbar .brand {
  display: flex;
  align-items: center;
  gap: var(--ds-space-2);
}
.admin-topbar .brand img {
  height: 22px;
  display: block;
}
.admin-topbar .icon-btn {
  color: #fff;
}
.admin-topbar .admin-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.35);
}
.admin-avatar-initial {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-weight: 800;
  font-size: 0.8rem;
  font-family: var(--ds-font-display);
}
.admin-topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--ds-space-2);
}

/* Screen 08 groups the six admin destinations into ONE panel separated by
   hairline dividers, rather than six detached cards. */
.admin-menu-list {
  display: flex;
  flex-direction: column;
  margin-top: var(--ds-space-4);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--ds-radius-lg);
  overflow: hidden;
}
.admin-menu-item {
  display: flex;
  align-items: center;
  gap: var(--ds-space-3);
  background: none;
  border: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 0;
  padding: 0.7rem var(--ds-space-3);
  color: inherit;
}
.admin-menu-list .admin-menu-item:last-child {
  border-bottom: 0;
}
.admin-menu-item:hover {
  background: rgba(255, 255, 255, 0.06);
  text-decoration: none;
}
.admin-menu-item .admin-menu-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.admin-menu-item .admin-menu-title {
  font-weight: 700;
  font-size: 0.88rem;
  color: #fff;
}
.admin-menu-item .admin-menu-sub {
  font-size: 0.72rem;
  color: #a8b3c7;
}
.admin-menu-item .chevron {
  margin-left: auto;
  color: #64748b;
  flex-shrink: 0;
}

/* Screen 08 (Admin Dashboard) keeps the same light bottom bar as the public
   screens even though the admin shell itself is forced-dark, so this variant
   inherits the light treatment rather than inverting it. */
.bottom-tab-bar-dark,
:root[data-theme='dark'] .bottom-tab-bar-dark {
  background: #fff;
  border-top-color: rgba(15, 23, 42, 0.07);
}
.bottom-tab-bar-dark a,
:root[data-theme='dark'] .bottom-tab-bar-dark a {
  color: var(--ds-slate-600);
}
.bottom-tab-bar-dark a.active,
:root[data-theme='dark'] .bottom-tab-bar-dark a.active {
  color: var(--ds-slate-900);
}

/* ---------------- Misc admin CRUD helpers ---------------- */

.badge-status {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: var(--ds-radius-pill);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: capitalize;
  background: var(--ds-slate-100);
  color: var(--ds-text-muted);
}
:root[data-theme='dark'] .badge-status {
  background: rgba(255, 255, 255, 0.08);
}
.badge-status.status-completed, .badge-status.status-paid, .badge-status.status-active, .badge-status.status-ongoing, .badge-status.status-registered {
  background: rgba(22, 163, 74, 0.14);
  color: var(--ds-success);
}
.badge-status.status-scheduled, .badge-status.status-upcoming, .badge-status.status-draft, .badge-status.status-waitlisted, .badge-status.status-unpaid {
  background: rgba(217, 119, 6, 0.14);
  color: var(--ds-warning);
}
.badge-status.status-cancelled, .badge-status.status-voided {
  background: rgba(220, 38, 38, 0.14);
  color: var(--ds-danger);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ds-space-3);
  margin-bottom: var(--ds-space-4);
  flex-wrap: wrap;
}

/* ---------------- Home hero (mockup screens 01 / 02) ----------------
   The photo runs behind the top bar; the season picker floats over its
   lower edge and the stat tiles straddle the boundary between photo and
   page, which is what gives the screen its layered look. */

.home-hero {
  position: relative;
  background-size: cover;
  background-position: center;
  padding: 4.25rem var(--ds-space-4) 3.25rem;
  min-height: 330px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.home-hero-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(6, 12, 22, 0.35) 0%, rgba(6, 12, 22, 0.55) 55%, rgba(6, 12, 22, 0.88) 100%);
}
.home-hero-body {
  position: relative;
  z-index: 1;
  padding-left: 0;
  padding-right: 0;
}
.home-hero-body h1 {
  color: #fff;
  font-size: 1.85rem;
  line-height: 1.12;
  margin-bottom: var(--ds-space-2);
}
.home-hero-body p {
  color: #dbe3ef;
  font-size: 0.95rem;
  line-height: 1.45;
  margin-bottom: var(--ds-space-4);
}
/* Stat tiles overlap the hero's lower edge. */
.home-body {
  position: relative;
  z-index: 2;
  margin-top: -2.25rem;
}

.season-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.85rem;
  border-radius: var(--ds-radius-pill);
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(6px);
  color: #fff;
}
.season-pill select {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: 0;
  color: #fff;
  font-family: var(--ds-font-body);
  font-weight: 600;
  font-size: 0.82rem;
  padding: 0 0.1rem;
  cursor: pointer;
  outline: none;
}
.season-pill select option {
  color: var(--ds-slate-900);
  background: #fff;
}
.season-pill svg {
  transform: rotate(90deg);
  flex-shrink: 0;
  opacity: 0.85;
}

/* Quiet inline links ("View All") — the mockup keeps these muted, not lime. */
.link-quiet {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ds-text-muted);
}
.link-quiet:hover {
  color: var(--ds-text);
  text-decoration: none;
}

/* Match rows: one avatar cluster, title, relative date, affordance. */
/* Real doubles pairings are longer than the mockup's "Team A vs Team B",
   so the title wraps to a second line rather than truncating a name. */
.match-card .match-title {
  font-weight: 700;
  font-size: 0.88rem;
  line-height: 1.25;
  color: var(--ds-text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.match-card .match-title .vs {
  color: var(--ds-text-muted);
  font-weight: 600;
}
.match-card .match-sub {
  font-size: 0.76rem;
  color: var(--ds-text-muted);
  margin-top: 1px;
}
.match-card .match-score {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.match-card:hover {
  text-decoration: none;
  border-color: var(--ds-accent);
}
.match-card .avatar {
  width: 34px;
  height: 34px;
}
.match-card .avatar-stack .avatar {
  margin-left: -11px;
}
.match-card .avatar-stack .avatar:first-child {
  margin-left: 0;
}

/* Date strip header: month + steppers grouped left, calendar right. */
.date-strip-nav {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
}
.date-strip-month {
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0 0.2rem;
}
.date-strip-header .icon-btn {
  width: 30px;
  height: 30px;
}

/* ---------------- Outlined select pill (leaderboard format picker) ------- */

.select-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.28rem 0.7rem;
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-pill);
  background: var(--ds-surface);
  color: var(--ds-text);
}
.select-pill select {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: 0;
  outline: none;
  color: inherit;
  font-family: var(--ds-font-body);
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
}
.select-pill svg:last-child {
  transform: rotate(90deg);
  opacity: 0.7;
}
.select-pill svg:first-child {
  opacity: 0.6;
}

/* ---------------- Leaderboard podium + table ---------------- */

.podium-spot .podium-name {
  font-weight: 700;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.podium-spot .podium-psr {
  font-family: var(--ds-font-display);
  font-weight: 800;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.podium-spot.rank-1 .podium-psr {
  font-size: 1.2rem;
}
.podium-spot .podium-psr-label {
  font-size: 0.68rem;
  color: var(--ds-text-muted);
}
/* Crowns are drawn from the icon set so they inherit the medal colour,
   instead of an emoji glyph that renders differently on every platform. */
.podium-spot .crown {
  display: block;
  line-height: 1;
  margin-bottom: 2px;
}
.podium-spot .crown svg { fill: currentColor; }
.podium-spot.rank-1 .crown { color: #eab308; }
.podium-spot.rank-2 .crown { color: #94a3b8; }
.podium-spot.rank-3 .crown { color: #c2703d; }
.podium-spot.rank-2 .avatar { border: 3px solid #94a3b8; }
.podium-spot.rank-3 .avatar { border: 3px solid #c2703d; }

/* The reliability column was being pushed off-screen on narrow viewports;
   the name cell is the only flexible one, so it gets the squeeze. */
.leaderboard-table {
  table-layout: fixed;
  width: 100%;
}
.leaderboard-table th,
.leaderboard-table td {
  padding-left: 0.4rem;
  padding-right: 0.4rem;
}
.leaderboard-table th:first-child,
.leaderboard-table td:first-child {
  width: 30px;
  padding-left: 0;
  color: var(--ds-text-muted);
  font-size: 0.85rem;
}
.leaderboard-table th.num,
.leaderboard-table td.num {
  text-align: right;
  white-space: nowrap;
  width: 72px;
  font-variant-numeric: tabular-nums;
}
.leaderboard-table td:last-child,
.leaderboard-table th:last-child {
  padding-right: 0;
}
.lb-player {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  min-width: 0;
}
.lb-player:hover { text-decoration: none; color: var(--ds-text); }
.lb-player .avatar {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border-width: 0;
}
.lb-player span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------- Player profile (screen 06) ---------------- */

/* Caption above figure on the PSR / Reliability pair. */
.stat-grid-stacked .stat-tile {
  text-align: center;
  padding: var(--ds-space-3);
}
.stat-grid-stacked .stat-label {
  margin-top: 0;
  margin-bottom: 2px;
  font-size: 0.72rem;
}
.stat-grid-stacked .stat-value {
  font-size: 1.3rem;
}

/* The three attribute chips sit on a single row. */
.attribute-row {
  overflow-x: auto;
  flex-wrap: nowrap;
  justify-content: center;
  margin-bottom: var(--ds-space-4);
}
.attribute-chip {
  padding: 0.3rem 0.7rem;
  font-size: 0.74rem;
  font-weight: 600;
  flex-shrink: 0;
}

.profile-header .avatar {
  width: 88px;
  height: 88px;
  border: 3px solid var(--ds-surface);
  box-shadow: 0 0 0 1px var(--ds-border);
}
.profile-header .profile-name {
  font-size: 1.2rem;
  font-family: var(--ds-font-display);
  font-weight: 800;
}
.verified-badge {
  color: var(--ds-accent-fg);
  background: var(--ds-accent);
  border-radius: 50%;
  width: 19px;
  height: 19px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.verified-badge svg { width: 12px; height: 12px; stroke-width: 3; }

/* Format switch + range switch share one row. */
.chart-controls {
  display: flex;
  align-items: center;
  gap: var(--ds-space-3);
  margin-bottom: var(--ds-space-3);
}
.range-row {
  display: flex;
  gap: 0.15rem;
  margin-left: auto;
}
.range-chip {
  border: 0;
  background: none;
  color: var(--ds-text-muted);
  font-family: var(--ds-font-body);
  font-weight: 600;
  font-size: 0.76rem;
  padding: 0.25rem 0.45rem;
  border-radius: var(--ds-radius-sm, 8px);
  cursor: pointer;
}
.range-chip.active {
  color: var(--ds-text);
  background: var(--ds-slate-100);
}
:root[data-theme='dark'] .range-chip.active {
  background: rgba(255, 255, 255, 0.10);
}

/* Four career figures in one divided panel. */
.career-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--ds-surface);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-lg);
  margin-top: var(--ds-space-4);
  overflow: hidden;
}
.career-strip > div {
  text-align: center;
  padding: var(--ds-space-3) 0.2rem;
  border-right: 1px solid var(--ds-border);
}
.career-strip > div:last-child { border-right: 0; }
.career-strip .stat-value {
  font-family: var(--ds-font-display);
  font-weight: 800;
  font-size: 1.05rem;
  line-height: 1.2;
  color: var(--ds-text);
}
.career-strip .stat-label {
  font-size: 0.68rem;
  color: var(--ds-text-muted);
}

/* Screen 07: the tagline stacks one word per line under the CTA row. */
.tournament-tagline {
  line-height: 1.25;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  color: #e8eef7;
}
.tournament-hero h1 {
  font-size: 1.45rem;
  line-height: 1.15;
}
.tournament-hero .btn {
  padding: 0.55rem 1.2rem;
  font-size: 0.9rem;
}

/* ---------------- PWA install prompt + offline (screens 09 / 10) -------- */

/* Screen 09 puts the icon and copy on the first row and drops the two
   buttons onto their own right-aligned row beneath. */
.install-banner {
  flex-wrap: wrap;
  row-gap: var(--ds-space-3);
  border-radius: var(--ds-radius-lg);
}
.install-copy {
  flex: 1 1 60%;
}
.install-actions {
  margin-left: auto;
}
.install-copy strong {
  font-family: var(--ds-font-display);
  font-weight: 800;
}

/* Screen 10 shows the slashed-wifi glyph on its own, with no filled disc. */
.offline-icon,
:root[data-theme='dark'] .offline-icon {
  width: auto;
  height: auto;
  background: none;
  color: var(--ds-text-muted);
  margin-bottom: var(--ds-space-1);
}
.offline-icon svg {
  width: 44px;
  height: 44px;
  stroke-width: 1.8;
}
.offline-page h1 {
  font-size: 1.25rem;
  margin-bottom: 0;
}
.offline-page p {
  max-width: 21rem;
  font-size: 0.9rem;
  margin: 0;
}
