/* ==========================================================================
   ApexClub — Design System (v2)
   Barlow + Barlow Condensed · Dark theme · No shadows · Rounded corners
   Loads AFTER Bootstrap 5 CSS.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. DESIGN TOKENS
   -------------------------------------------------------------------------- */

:root {
  /* --- Backgrounds --- */
  --color-bg: #0a0a0a;
  --color-surface: #111111;
  --color-surface-2: #1a1a1a;
  --color-surface-3: #222222;

  /* --- Borders --- */
  --color-border: rgba(255, 255, 255, 0.08);
  --color-border-hover: rgba(255, 255, 255, 0.18);
  --color-border-focus: rgba(200, 255, 0, 0.4);

  /* --- Text --- */
  --color-text: #ffffff;
  --color-text-secondary: rgba(255, 255, 255, 0.65);
  --color-text-muted: rgba(255, 255, 255, 0.4);

  /* --- Accent --- */
  --color-accent: #c8ff00;
  --color-accent-dim: rgba(200, 255, 0, 0.1);
  --color-accent-border: rgba(200, 255, 0, 0.25);
  --color-accent-hover: #d4ff1a;

  /* --- Semantic --- */
  --color-success: #22c55e;
  --color-success-dim: rgba(34, 197, 94, 0.12);
  --color-warning: #f59e0b;
  --color-warning-dim: rgba(245, 158, 11, 0.12);
  --color-error: #ef4444;
  --color-error-dim: rgba(239, 68, 68, 0.12);
  --color-info: #3b82f6;
  --color-info-dim: rgba(59, 130, 246, 0.12);

  /* --- Sport-specific --- */
  --color-gold: #ffd700;
  --color-silver: #c0c0c0;
  --color-bronze: #cd7f32;
  --color-joker: #8b5cf6;
  --color-joker-dim: rgba(139, 92, 246, 0.12);

  /* --- Spacing --- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;

  /* --- Border Radius --- */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 100px;

  /* --- Typography Scale --- */
  /* Display — Barlow Condensed 900 uppercase */
  --text-display-xl: 72px;
  --text-display-lg: 48px;
  --text-display-md: 32px;
  --text-display-sm: 24px;
  --text-display-xs: 18px;

  /* UI — Barlow Condensed 700-800 uppercase */
  --text-ui-lg: 17px;
  --text-ui-md: 14px;
  --text-ui-sm: 11px;

  /* Body — Barlow 400-600 */
  --text-body-lg: 17px;
  --text-body-md: 15px;
  --text-body-sm: 14px;
  --text-body-xs: 13px;

  /* --- Fonts --- */
  --font-display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --font-body: 'Barlow', Arial, sans-serif;
  --font-mono: 'Courier New', ui-monospace, monospace;

  /* --- Transitions --- */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.2s ease;

  /* --- Layout --- */
  --chrome-height: 160px;

  /* =======================================================================
     LEGACY ALIASES — kept so templates don't break during migration.
     These map old --f1-* names to the new tokens.
     ======================================================================= */
  --f1-primary: #1c1c1c;
  --f1-primary-dark: #0a0a0a;
  --f1-primary-light: #282828;
  --f1-accent: var(--color-accent);
  --f1-accent-hover: var(--color-accent-hover);
  --f1-accent-yellow: #FCD34D;

  --f1-surface: var(--color-surface);
  --f1-surface-muted: var(--color-surface-2);
  --f1-surface-dark: var(--color-bg);
  --f1-body-bg: var(--color-bg);

  --f1-slate-50: var(--color-surface-2);
  --f1-slate-100: var(--color-surface-3);
  --f1-slate-200: rgba(255, 255, 255, 0.1);
  --f1-slate-300: var(--color-text-muted);
  --f1-slate-400: var(--color-text-muted);
  --f1-slate-500: var(--color-text-secondary);
  --f1-slate-600: var(--color-text-secondary);
  --f1-slate-700: rgba(255, 255, 255, 0.8);
  --f1-slate-800: rgba(255, 255, 255, 0.9);
  --f1-slate-900: var(--color-text);

  --f1-green-100: var(--color-success-dim);
  --f1-green-500: var(--color-success);
  --f1-green-600: var(--color-success);
  --f1-orange-100: var(--color-warning-dim);
  --f1-orange-500: var(--color-warning);
  --f1-orange-700: var(--color-warning);
  --f1-red-100: var(--color-error-dim);
  --f1-red-500: var(--color-error);
  --f1-red-600: var(--color-error);
  --f1-blue-100: var(--color-info-dim);
  --f1-blue-500: var(--color-info);
  --f1-blue-600: var(--color-info);

  --f1-gold: var(--color-gold);
  --f1-silver: var(--color-silver);
  --f1-bronze: var(--color-bronze);

  --f1-font-display: var(--font-display);
  --f1-font-sans: var(--font-body);
  --f1-font-mono: var(--font-mono);

  --f1-text-xs: 0.75rem;
  --f1-text-sm: 0.875rem;
  --f1-text-base: 1rem;
  --f1-text-lg: 1.125rem;
  --f1-text-xl: 1.25rem;
  --f1-text-2xl: 1.5rem;
  --f1-text-3xl: 1.875rem;
  --f1-text-4xl: 2.25rem;
  --f1-text-5xl: 3rem;

  --f1-space-1: 0.25rem;
  --f1-space-2: 0.5rem;
  --f1-space-3: 0.75rem;
  --f1-space-4: 1rem;
  --f1-space-5: 1.25rem;
  --f1-space-6: 1.5rem;
  --f1-space-8: 2rem;
  --f1-space-10: 2.5rem;
  --f1-space-12: 3rem;

  --f1-radius-sm: var(--radius-sm);
  --f1-radius-md: var(--radius-md);
  --f1-radius-lg: var(--radius-lg);
  --f1-radius-xl: var(--radius-xl);
  --f1-radius-2xl: var(--radius-xl);
  --f1-radius-3xl: var(--radius-xl);
  --f1-radius-full: var(--radius-full);

  --f1-transition: all var(--transition-normal);
  --f1-transition-slow: all 0.3s ease;

  --f1-chrome-height: var(--chrome-height);

  /* Legacy new token aliases */
  --color-surface-raised: var(--color-surface-2);
  --color-surface-alt: var(--color-surface-3);
  --color-accent-fg: #000000;
  --color-danger: var(--color-error);
  --color-text-primary: var(--color-text);

  /* --- Theme-aware neutrals (used for backdrops, overlays) --- */
  --color-backdrop: rgba(10, 10, 10, 0.95);
  --color-backdrop-heavy: rgba(10, 10, 10, 0.98);
  --color-overlay: rgba(0, 0, 0, 0.3);

  /* --- Avatar palette (theme-aware) --- */
  --avatar-bg-1: #1a2a3a; --avatar-fg-1: #64C8FF;
  --avatar-bg-2: #2a1a3a; --avatar-fg-2: #B088FF;
  --avatar-bg-3: #2a3a1a; --avatar-fg-3: #c8ff00;
  --avatar-bg-4: #3a2a1a; --avatar-fg-4: #FF8C42;
  --avatar-bg-5: #1a3a2a; --avatar-fg-5: #52D18A;
  --avatar-bg-6: #2a1a1a; --avatar-fg-6: #FF6B6B;

  /* --- Scrollbar --- */
  --scrollbar-thumb: rgba(255, 255, 255, 0.15);
  --scrollbar-thumb-hover: rgba(255, 255, 255, 0.25);
}


/* --------------------------------------------------------------------------
   1b. LIGHT THEME TOKENS
   -------------------------------------------------------------------------- */

[data-theme="light"] {
  /* --- Backgrounds --- */
  --color-bg: #f5f5f5;
  --color-surface: #ffffff;
  --color-surface-2: #f0f0f0;
  --color-surface-3: #e5e5e5;

  /* --- Borders --- */
  --color-border: rgba(0, 0, 0, 0.10);
  --color-border-hover: rgba(0, 0, 0, 0.20);
  --color-border-focus: rgba(74, 120, 0, 0.5);

  /* --- Text --- */
  --color-text: #1a1a1a;
  --color-text-secondary: rgba(0, 0, 0, 0.6);
  --color-text-muted: rgba(0, 0, 0, 0.55);

  /* --- Accent (darker for contrast on light) --- */
  --color-accent: #4a7800;
  --color-accent-dim: rgba(74, 120, 0, 0.08);
  --color-accent-border: rgba(74, 120, 0, 0.25);
  --color-accent-hover: #5a9000;

  /* --- Semantic --- */
  --color-success: #16a34a;
  --color-success-dim: rgba(22, 163, 74, 0.10);
  --color-warning: #d97706;
  --color-warning-dim: rgba(217, 119, 6, 0.10);
  --color-error: #dc2626;
  --color-error-dim: rgba(220, 38, 38, 0.08);
  --color-info: #2563eb;
  --color-info-dim: rgba(37, 99, 235, 0.08);

  /* --- Sport-specific --- */
  --color-gold: #b8860b;
  --color-silver: #6b7280;
  --color-bronze: #92400e;
  --color-joker: #7c3aed;
  --color-joker-dim: rgba(124, 58, 237, 0.08);

  /* --- Legacy aliases that need light overrides --- */
  --f1-primary: #e5e5e5;
  --f1-primary-dark: #f5f5f5;
  --f1-primary-light: #d4d4d4;
  --f1-accent: var(--color-accent);
  --f1-accent-hover: var(--color-accent-hover);

  --f1-surface: var(--color-surface);
  --f1-surface-muted: var(--color-surface-2);
  --f1-surface-dark: var(--color-bg);
  --f1-body-bg: var(--color-bg);

  --f1-slate-50: var(--color-surface-2);
  --f1-slate-100: var(--color-surface-3);
  --f1-slate-200: rgba(0, 0, 0, 0.06);
  --f1-slate-300: var(--color-text-muted);
  --f1-slate-400: var(--color-text-muted);
  --f1-slate-500: var(--color-text-secondary);
  --f1-slate-600: var(--color-text-secondary);
  --f1-slate-700: rgba(0, 0, 0, 0.7);
  --f1-slate-800: rgba(0, 0, 0, 0.8);
  --f1-slate-900: var(--color-text);

  --f1-green-100: var(--color-success-dim);
  --f1-green-500: var(--color-success);
  --f1-green-600: var(--color-success);
  --f1-orange-100: var(--color-warning-dim);
  --f1-orange-500: var(--color-warning);
  --f1-orange-700: var(--color-warning);
  --f1-red-100: var(--color-error-dim);
  --f1-red-500: var(--color-error);
  --f1-red-600: var(--color-error);
  --f1-blue-100: var(--color-info-dim);
  --f1-blue-500: var(--color-info);
  --f1-blue-600: var(--color-info);

  --f1-gold: var(--color-gold);
  --f1-silver: var(--color-silver);
  --f1-bronze: var(--color-bronze);

  --color-surface-raised: var(--color-surface-2);
  --color-surface-alt: var(--color-surface-3);
  --color-accent-fg: #ffffff;
  --color-danger: var(--color-error);
  --color-text-primary: var(--color-text);

  /* --- Theme-aware neutrals --- */
  --color-backdrop: rgba(255, 255, 255, 0.95);
  --color-backdrop-heavy: rgba(255, 255, 255, 0.98);
  --color-overlay: rgba(0, 0, 0, 0.1);

  /* --- Avatar palette (lighter backgrounds for light mode) --- */
  --avatar-bg-1: #dbeafe; --avatar-fg-1: #1d4ed8;
  --avatar-bg-2: #ede9fe; --avatar-fg-2: #7c3aed;
  --avatar-bg-3: #ecfccb; --avatar-fg-3: #4a7800;
  --avatar-bg-4: #ffedd5; --avatar-fg-4: #c2410c;
  --avatar-bg-5: #d1fae5; --avatar-fg-5: #059669;
  --avatar-bg-6: #fee2e2; --avatar-fg-6: #dc2626;

  /* --- Scrollbar --- */
  --scrollbar-thumb: rgba(0, 0, 0, 0.15);
  --scrollbar-thumb-hover: rgba(0, 0, 0, 0.30);
}

/* Light mode overrides for elements that can't use CSS vars (SVG data URIs) */
[data-theme="light"] .form-select-f1,
[data-theme="light"] .select-dark,
[data-theme="light"] .predict-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='rgba(0,0,0,0.4)' viewBox='0 0 16 16'%3E%3Cpath d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
}


/* --------------------------------------------------------------------------
   2. BASE / RESET
   -------------------------------------------------------------------------- */

body {
  font-family: var(--font-body) !important;
  color: var(--color-text) !important;
  background-color: var(--color-bg) !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

a {
  color: var(--color-text-secondary);
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-text);
}

/* Slim scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }

/* Selection */
::selection {
  background: var(--color-accent);
  color: var(--color-accent-fg);
}


/* --------------------------------------------------------------------------
   3. BOOTSTRAP OVERRIDES
   -------------------------------------------------------------------------- */

.container,
.container-fluid {
  --bs-gutter-x: 1.5rem;
}

/* --- Alerts --- */
.alert {
  background-color: var(--color-surface) !important;
  border: 1px solid var(--color-border) !important;
  color: var(--color-text-secondary) !important;
  border-radius: var(--radius-md) !important;
}

.alert-success {
  background-color: var(--color-success-dim) !important;
  border-color: rgba(34, 197, 94, 0.2) !important;
  color: var(--color-success) !important;
}

.alert-danger {
  background-color: var(--color-error-dim) !important;
  border-color: rgba(239, 68, 68, 0.2) !important;
  color: var(--color-error) !important;
}

.alert-info {
  background-color: var(--color-info-dim) !important;
  border-color: rgba(59, 130, 246, 0.2) !important;
  color: var(--color-info) !important;
}

.alert a {
  color: inherit;
  text-decoration: underline;
}

/* --- Cards --- */
.card,
.f1-card {
  background-color: var(--color-surface) !important;
  border-color: var(--color-border) !important;
  color: var(--color-text) !important;
  border-radius: var(--radius-lg) !important;
}

.card-body {
  color: inherit;
}

/* --- Forms --- */
.form-control {
  background-color: var(--color-surface-2) !important;
  color: var(--color-text) !important;
  border-color: var(--color-border) !important;
  border-radius: var(--radius-md) !important;
}

.form-control:focus {
  background-color: var(--color-surface-2) !important;
  color: var(--color-text) !important;
  border-color: var(--color-border-focus) !important;
  box-shadow: 0 0 0 3px rgba(200, 255, 0, 0.06) !important;
}

.form-control:disabled {
  background-color: var(--color-surface-3) !important;
  color: var(--color-text-muted) !important;
}

.form-control::placeholder {
  color: var(--color-text-muted) !important;
}

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

.form-select {
  background-color: var(--color-surface-2) !important;
  color: var(--color-text) !important;
  border-color: var(--color-border) !important;
  border-radius: var(--radius-md) !important;
}

.form-select:focus {
  border-color: var(--color-border-focus) !important;
  box-shadow: 0 0 0 3px rgba(200, 255, 0, 0.06) !important;
}

.form-check-input {
  background-color: var(--color-surface-2) !important;
  border-color: var(--color-border) !important;
}

.form-check-input:checked {
  background-color: var(--color-accent) !important;
  border-color: var(--color-accent) !important;
}

/* --- Nav --- */
.nav-link {
  color: var(--color-text-muted) !important;
}

.nav-link:hover {
  color: var(--color-text) !important;
}

/* --- Collapse --- */
.collapse:not(.show) {
  display: none;
}

.collapse.show {
  display: block;
}

/* --- Text --- */
.text-muted {
  color: var(--color-text-muted) !important;
}

/* --- Table --- */
.table {
  color: var(--color-text);
}


/* --------------------------------------------------------------------------
   4. TYPOGRAPHY UTILITIES
   -------------------------------------------------------------------------- */

.text-xs   { font-size: var(--f1-text-xs) !important; }
.text-sm   { font-size: var(--f1-text-sm) !important; }
.text-base { font-size: var(--f1-text-base) !important; }
.text-lg   { font-size: var(--f1-text-lg) !important; }
.text-xl   { font-size: var(--f1-text-xl) !important; }
.text-2xl  { font-size: var(--f1-text-2xl) !important; }
.text-3xl  { font-size: var(--f1-text-3xl) !important; }
.text-4xl  { font-size: var(--f1-text-4xl) !important; }
.text-5xl  { font-size: var(--f1-text-5xl) !important; }


/* --------------------------------------------------------------------------
   5. COLOR UTILITIES
   -------------------------------------------------------------------------- */

/* --- Text --- */
.text-accent        { color: var(--color-accent) !important; }
.text-slate-300     { color: var(--color-text-muted) !important; }
.text-slate-400     { color: var(--color-text-muted) !important; }
.text-slate-500     { color: var(--color-text-secondary) !important; }
.text-slate-700     { color: var(--f1-slate-700) !important; }
.text-slate-800     { color: var(--f1-slate-800) !important; }
.text-slate-900     { color: var(--color-text) !important; }

/* --- Backgrounds --- */
.bg-accent        { background-color: var(--color-accent) !important; }

/* --- Direct --- */
.text-white { color: #fff !important; }
.text-black { color: #000 !important; }


/* --------------------------------------------------------------------------
   6. BORDER RADIUS UTILITIES
   -------------------------------------------------------------------------- */

.rounded-lg  { border-radius: var(--radius-lg) !important; }
.rounded-xl  { border-radius: var(--radius-xl) !important; }

/* --------------------------------------------------------------------------
   7. LAYOUT HELPERS
   -------------------------------------------------------------------------- */

/* Page content containers — replace per-page .rd-content, .st-content, etc. */
.page-content    { max-width: 1100px; margin: 0 auto; padding: 0 var(--space-6); }
.page-content-sm { max-width: 480px; margin: 0 auto; padding: 0 var(--space-6); }
.page-content-md { max-width: 800px; margin: 0 auto; padding: 0 var(--space-6); }
.page-content-lg { max-width: 1000px; margin: 0 auto; padding: 0 var(--space-6); }

@media (min-width: 768px) {
  .page-content,
  .page-content-sm,
  .page-content-md,
  .page-content-lg {
    padding: 0 var(--space-8);
  }
}


/* --------------------------------------------------------------------------
   8. COMPONENT: App Card (replaces .ld-card, .lb-card, .us-card, etc.)
   -------------------------------------------------------------------------- */

.app-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.app-card-header {
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.app-card-body {
  padding: var(--space-4) var(--space-5);
}


/* --------------------------------------------------------------------------
   9. COMPONENT: Navbar
   -------------------------------------------------------------------------- */

.f1-navbar {
  background-color: var(--color-backdrop);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
  height: 56px;
}

@media (max-width: 767.98px) {
  .f1-navbar { height: 52px; }
}

.f1-navbar .nav-link {
  font-family: var(--font-display);
  font-size: var(--text-ui-md);
  font-weight: 700;
  line-height: 1;
  color: var(--color-text-muted) !important;
  position: relative;
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
  transition: color var(--transition-fast);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.f1-navbar .nav-link:hover {
  color: var(--color-text) !important;
}
button.nav-f1geek-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}
.nav-ai-badge {
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--color-accent);
  color: var(--color-accent-fg);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  line-height: 1.4;
  vertical-align: middle;
  position: relative;
  top: -1px;
}

.f1-navbar .nav-link.active {
  color: var(--color-text) !important;
}

.f1-navbar .nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: var(--color-accent);
  border-radius: 2px;
}

.navbar-brand-text {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 20px;
  line-height: 1;
  color: var(--color-accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}


/* --------------------------------------------------------------------------
   10. COMPONENT: Page Hero
   -------------------------------------------------------------------------- */

.page-hero {
  background-color: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  margin: -1.5rem -0.75rem 0;
  padding: 1.5rem 1.5rem 1.25rem;
  position: relative;
  overflow: hidden;
}

.page-hero-inner {
  max-width: 1200px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.page-hero-center { text-align: center; }


/* --------------------------------------------------------------------------
   10b. COMPONENT: Page Header (banner-style, no background panel)
   Used on Race Calendar, Race Detail, My Leagues, League Detail.
   Sits directly on --color-bg with no card/surface behind it.
   -------------------------------------------------------------------------- */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: var(--space-4) 0 0;
  margin-bottom: var(--space-4);
}

.page-header .header-left { flex: 1; min-width: 0; }
.page-header .header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  padding-top: 4px;
}

.page-header .eyebrow {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}

.page-header .page-title {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -0.01em;
  line-height: 1;
  color: var(--color-text);
  margin: 0;
}

.page-header .page-title em {
  font-style: normal;
  color: var(--color-accent);
}

/* Detail pages: em forces a line break for multi-word accent */
.page-header .page-title-split { line-height: 0.95; font-size: 40px; margin-bottom: 8px; }
.page-header .page-title-split em { display: block; }

.page-header .page-meta {
  font-size: 14px;
  color: var(--color-text-muted);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.page-header .page-meta .meta-sep {
  color: var(--color-border-hover);
}

@media (max-width: 767.98px) {
  .page-header {
    flex-direction: column;
    gap: 12px;
    padding-top: var(--space-3);
  }
  .page-header .page-title { font-size: 28px; }
  .page-header .page-title-split { font-size: 30px; }
  .page-header .header-right { width: 100%; padding-top: 0; }
}


/* --------------------------------------------------------------------------
   11. COMPONENT: Cards
   -------------------------------------------------------------------------- */

.card-f1 {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  transition: background var(--transition-normal);
}

.card-f1:hover {
  background: var(--color-surface-2);
}


/* --------------------------------------------------------------------------
   12. COMPONENT: Buttons
   -------------------------------------------------------------------------- */

/* Primary — accent fill, one per screen max */
.btn-primary,
.btn-f1-accent {
  background-color: var(--color-accent) !important;
  color: var(--color-accent-fg) !important;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-ui-md);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: var(--radius-md);
  padding: 9px 18px;
  border: none;
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.btn-primary:hover,
.btn-f1-primary:hover,
.btn-f1-accent:hover {
  background-color: var(--color-accent-hover) !important;
  color: var(--color-accent-fg) !important;
  transform: translateY(-1px);
}

.btn-primary:active,
.btn-f1-primary:active,
.btn-f1-accent:active {
  transform: translateY(0);
}

.btn-primary:disabled,
.btn-f1-primary:disabled,
.btn-f1-accent:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* Ghost — secondary actions */
.btn-ghost,
.btn-f1-outline,
.btn-f1-ghost {
  background: none !important;
  color: var(--color-text-secondary) !important;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-ui-md);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid var(--color-border) !important;
  border-radius: var(--radius-md);
  padding: 9px 18px;
  cursor: pointer;
  transition: border-color var(--transition-fast), color var(--transition-fast);
}

.btn-ghost:hover,
.btn-f1-outline:hover,
.btn-f1-ghost:hover {
  border-color: var(--color-border-hover) !important;
  color: var(--color-text) !important;
  background: none !important;
}

/* Danger — destructive actions */
.btn-danger,
.btn-f1-danger {
  background: none !important;
  color: var(--color-error) !important;
  border: 1px solid rgba(239, 68, 68, 0.25) !important;
  border-radius: var(--radius-md);
  padding: 8px 16px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.btn-danger:hover,
.btn-f1-danger:hover {
  background: var(--color-error-dim) !important;
  border-color: rgba(239, 68, 68, 0.5) !important;
}

/* Size variants */
.btn-f1-lg {
  padding: 14px 28px;
  font-size: var(--text-ui-lg);
}


/* --------------------------------------------------------------------------
   13. COMPONENT: Badges / Status Pills
   -------------------------------------------------------------------------- */

.badge-f1 {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-family: var(--font-display);
  font-size: var(--text-ui-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

.badge-sprint {
  background-color: var(--color-info-dim);
  color: var(--color-info);
  border: 1px solid rgba(59, 130, 246, 0.25);
  font-weight: 700;
}

.badge-public { background-color: var(--color-success-dim); color: var(--color-success); border: 1px solid rgba(34, 197, 94, 0.25); }

/* Form badges (standings) */
.badge-form-hot { background: var(--color-error-dim); color: var(--color-error); }
.badge-form-rising { background: var(--color-info-dim); color: var(--color-info); }
.badge-form-consistent { background: var(--color-info-dim); color: var(--color-info); }
.badge-form-new { background: var(--color-info-dim); color: var(--color-text-muted); }

/* Streak badges */
.badge-streak { background: rgba(245, 158, 11, 0.12); color: #d97706; font-size: 0.55rem; padding: 0 0.375rem; }
.badge-streak-hot { background: var(--color-error-dim); color: var(--color-error); font-size: 0.55rem; padding: 0 0.375rem; }

.status-dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
}

.status-dot-green  { background-color: var(--color-success); }
.status-dot-orange { background-color: var(--color-warning); }
.status-dot-red    { background-color: var(--color-error); }
.status-dot-blue   { background-color: var(--color-info); }

.score-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: var(--f1-text-sm);
  font-weight: 700;
  background-color: var(--color-accent-dim);
  color: var(--color-accent);
}



/* --------------------------------------------------------------------------
   15. COMPONENT: Rankings / Standings
   -------------------------------------------------------------------------- */

.rank-badge {
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: var(--f1-text-sm);
  font-weight: 900;
}

.rank-badge-1 { background-color: rgba(255, 215, 0, 0.15); color: var(--color-gold); }
.rank-badge-2 { background-color: rgba(192, 192, 192, 0.12); color: var(--color-silver); }
.rank-badge-3 { background-color: rgba(205, 127, 50, 0.15); color: var(--color-bronze); }
.rank-badge-default { background-color: var(--color-surface-2); color: var(--color-text-muted); }


/* --------------------------------------------------------------------------
   16. COMPONENT: Forms (custom)
   -------------------------------------------------------------------------- */

.form-control-f1 {
  background-color: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 11px 14px;
  font-family: var(--font-body);
  font-size: var(--text-body-sm);
  font-weight: 500;
  color: var(--color-text);
  transition: border-color var(--transition-fast);
}

.form-control-f1:hover {
  border-color: var(--color-border-hover);
}

.form-control-f1:focus {
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px rgba(200, 255, 0, 0.06);
  outline: none;
  background-color: var(--color-surface-2);
  color: var(--color-text);
}

.form-control-f1::placeholder {
  color: var(--color-text-muted);
}

.form-control-f1:disabled {
  background-color: var(--color-surface-3);
  color: var(--color-text-muted);
  cursor: not-allowed;
}

.form-select-f1 {
  background-color: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 11px 2.5rem 11px 14px;
  font-family: var(--font-body);
  font-size: var(--text-body-sm);
  font-weight: 500;
  color: var(--color-text);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='rgba(255,255,255,0.3)' viewBox='0 0 16 16'%3E%3Cpath d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 1rem;
  transition: border-color var(--transition-fast);
}

.form-select-f1:focus {
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px rgba(200, 255, 0, 0.06);
  outline: none;
}

.form-select-f1 option {
  background: var(--color-surface-2);
}

.form-label-f1 {
  font-family: var(--font-body);
  font-size: var(--text-ui-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-1);
}

.input-icon-wrapper { position: relative; }

.input-icon-wrapper .input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  pointer-events: none;
}

.input-icon-wrapper .form-control-f1,
.input-icon-wrapper .form-select-f1 {
  padding-left: 2.75rem;
}


/* --------------------------------------------------------------------------
   17. COMPONENT: Back Link
   -------------------------------------------------------------------------- */

.back-link {
  font-family: var(--font-body);
  font-size: var(--text-body-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.back-link:hover {
  color: var(--color-text);
}



/* --------------------------------------------------------------------------
   19. COMPONENT: Invite Code
   -------------------------------------------------------------------------- */

.invite-code {
  letter-spacing: 0.2em;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: var(--f1-text-2xl);
  color: var(--color-accent);
}


/* --------------------------------------------------------------------------
   20. COMPONENT: CTA Banner
   -------------------------------------------------------------------------- */

.cta-banner {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  color: #fff;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--color-border);
}


/* --------------------------------------------------------------------------
   21. COMPONENT: Footer
   -------------------------------------------------------------------------- */

.f1-footer {
  background-color: var(--color-surface);
  border-top: 1px solid var(--color-border);
}

.f1-footer a {
  font-size: var(--text-body-sm);
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.f1-footer a:hover {
  color: var(--color-text);
}

.footer-brand {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 20px;
  color: var(--color-accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}


/* --------------------------------------------------------------------------
   22. ANIMATIONS
   -------------------------------------------------------------------------- */

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}


/* --------------------------------------------------------------------------
   23. COMPONENT: Auth Pages
   -------------------------------------------------------------------------- */

.auth-bg-shapes {
  display: none;
}

.auth-wrapper {
  min-height: calc(100vh - var(--chrome-height));
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}

.password-field-wrap {
  position: relative;
}

.auth-toggle-pw {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 2px 4px;
  font-size: var(--f1-text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: color var(--transition-fast);
}

.auth-toggle-pw:hover { color: var(--color-text-secondary); }

.auth-divider-or {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--color-text-muted);
  font-size: var(--text-body-sm);
  margin: 1.25rem 0;
}

.auth-divider-or::before,
.auth-divider-or::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  font-weight: 500;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: background var(--transition-fast), border-color var(--transition-fast);
  width: 100%;
}

.btn-google:hover {
  background: var(--color-surface-2);
  border-color: var(--color-border-hover);
  color: var(--color-text-secondary);
}

.btn-google img {
  width: 1.125rem;
  height: 1.125rem;
}


/* --------------------------------------------------------------------------
   24. COMPONENT: Section Card
   -------------------------------------------------------------------------- */

.section-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--color-border);
}

.section-body { padding: var(--space-4) var(--space-5); }

.section-icon {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--f1-text-sm);
  flex-shrink: 0;
}

.section-icon-green  { background: var(--color-success-dim); color: var(--color-success); }
.section-icon-blue   { background: var(--color-info-dim); color: var(--color-info); }
.section-icon-sprint { background: var(--color-info-dim); color: var(--color-info); }
.section-icon-race   { background: var(--color-info-dim); color: var(--color-info); }
.section-icon-joker  { background: var(--color-joker-dim); color: var(--color-joker); }


/* --------------------------------------------------------------------------
   25. COMPONENT: Position Badges
   -------------------------------------------------------------------------- */

.pos-circle {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 900;
  flex-shrink: 0;
}

.pos-1       { background: rgba(255, 215, 0, 0.15); color: var(--color-gold); }
.pos-2       { background: rgba(192, 192, 192, 0.12); color: var(--color-silver); }
.pos-3       { background: rgba(205, 127, 50, 0.15); color: var(--color-bronze); }
.pos-default { background: var(--color-surface-2); color: var(--color-text-muted); }
.pos-pole    { background: var(--color-accent-dim); color: var(--color-accent); }

/* Joker position badge */
.joker-badge { background: var(--color-joker-dim); color: var(--color-joker); }


/* --------------------------------------------------------------------------
   26. COMPONENT: Race Card + Status Badge
   -------------------------------------------------------------------------- */

.race-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
  height: 100%;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  position: relative;
}

.race-card:hover {
  border-color: var(--color-border-hover);
  transform: translateY(-2px);
}

.race-card-top {
  padding: 14px 16px 12px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.race-round-num {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text-muted);
}

.race-badges {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.race-card-body {
  padding: 0 16px 14px;
  flex: 1;
}

.race-name {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  line-height: 1.05;
  margin-bottom: 4px;
  color: var(--color-text);
}

.race-location {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

.race-date {
  font-size: 13px;
  color: var(--color-text-muted);
}

/* Card footer — always present, pinned to bottom */
.race-card-footer {
  border-top: 1px solid var(--color-border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
}
.race-card-action {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}
.race-card-action-accent {
  color: var(--color-accent);
}
.race-card:hover .race-card-action {
  color: var(--color-text-secondary);
}
.race-card-open:hover .race-card-action-accent,
.race-card:hover .race-card-action-accent {
  color: var(--color-accent-hover);
}

/* "Opens in X days" hint */
.opens-soon {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 6px;
  font-style: italic;
}

/* Legacy round-badge kept for non-card contexts */
.round-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: var(--text-ui-sm);
  font-weight: 700;
  background: var(--color-surface-2);
  color: var(--color-text-muted);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 3px 8px;
  border-radius: 100px;
  white-space: nowrap;
}

.status-completed {
  background-color: var(--color-success-dim);
  color: var(--color-success);
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.status-open {
  background-color: var(--color-accent-dim);
  color: var(--color-accent);
  border: 1px solid var(--color-accent-border);
}

.status-upcoming {
  background-color: var(--color-info-dim);
  color: var(--color-info);
  border: 1px solid rgba(59, 130, 246, 0.15);
}

.status-awaiting {
  background-color: var(--color-warning-dim);
  color: var(--color-warning);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.status-sprint {
  background-color: var(--color-info-dim);
  color: var(--color-info);
  border: 1px solid rgba(59, 130, 246, 0.22);
}


/* --------------------------------------------------------------------------
   27. COMPONENT: Season Select
   -------------------------------------------------------------------------- */

.select-dark {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  border-radius: var(--radius-md);
  padding: 0.5rem 2.25rem 0.5rem 1rem;
  font-family: var(--font-display);
  font-size: var(--text-ui-md);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='rgba(255,255,255,0.3)' viewBox='0 0 16 16'%3E%3Cpath d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 0.875rem;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.select-dark:focus {
  outline: none;
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px var(--color-accent-dim);
}

.select-dark option {
  color: var(--color-text);
  background: var(--color-surface-2);
}

.select-dark-sm {
  padding: 9px 2rem 9px 0.875rem;
  font-size: var(--text-ui-md);
  background-position: right 0.625rem center;
  background-size: 0.75rem;
}


/* --------------------------------------------------------------------------
   28. COMPONENT: Next Race Card
   -------------------------------------------------------------------------- */

.next-race-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-accent);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  color: var(--color-text);
  position: relative;
  overflow: hidden;
  transition: background var(--transition-normal);
}

.next-race-card:hover {
  background: var(--color-surface-2);
}

.next-label {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-family: var(--font-display);
  font-size: var(--text-ui-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  background: var(--color-accent-dim);
  color: var(--color-accent);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-accent-border);
}


/* --------------------------------------------------------------------------
   29. COMPONENT: Standings Table
   -------------------------------------------------------------------------- */

.standings-table {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.standings-table-header {
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--color-border);
}

.st-head {
  display: flex;
  align-items: center;
  padding: 0.625rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

.st-row {
  display: flex;
  align-items: center;
  padding: 0.875rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
  transition: background var(--transition-normal);
  text-decoration: none;
  color: inherit;
}

.st-row:last-child { border-bottom: none; }

.st-row:hover {
  background-color: var(--color-surface-2);
  color: inherit;
}

.st-row-you {
  background-color: var(--color-accent-dim);
  border-left: 3px solid var(--color-accent);
}

.st-row-you:hover {
  background-color: var(--color-accent-dim);
}

.st-col-rank   { width: 4rem; flex-shrink: 0; }
.st-col-player { flex: 1; min-width: 0; }
.st-col-races  { width: 5rem; text-align: center; flex-shrink: 0; }
.st-col-points { width: 5.5rem; text-align: right; flex-shrink: 0; }
.st-col-action { width: 5rem; text-align: right; flex-shrink: 0; }

/* Guest masked names */
.standings-masked {
  font-style: italic;
  color: var(--color-text-muted) !important;
}


/* --------------------------------------------------------------------------
   30. (reserved — old share buttons removed, see Share Card in section 46+)
   -------------------------------------------------------------------------- */


/* --------------------------------------------------------------------------
   31. COMPONENT: Cookie Banner
   -------------------------------------------------------------------------- */

.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1050;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: 1rem 0;
}


/* --------------------------------------------------------------------------
   32. COMPONENT: User Avatar
   -------------------------------------------------------------------------- */

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 900;
  flex-shrink: 0;
}

/* Deterministic color assignment by initial */
.user-avatar[data-initial="A"], .user-avatar[data-initial="B"],
.user-avatar[data-initial="C"], .user-avatar[data-initial="D"] { background: var(--avatar-bg-1); color: var(--avatar-fg-1); }
.user-avatar[data-initial="E"], .user-avatar[data-initial="F"],
.user-avatar[data-initial="G"], .user-avatar[data-initial="H"] { background: var(--avatar-bg-2); color: var(--avatar-fg-2); }
.user-avatar[data-initial="I"], .user-avatar[data-initial="J"],
.user-avatar[data-initial="K"], .user-avatar[data-initial="L"] { background: var(--avatar-bg-3); color: var(--avatar-fg-3); }
.user-avatar[data-initial="M"], .user-avatar[data-initial="N"],
.user-avatar[data-initial="O"], .user-avatar[data-initial="P"] { background: var(--avatar-bg-4); color: var(--avatar-fg-4); }
.user-avatar[data-initial="Q"], .user-avatar[data-initial="R"],
.user-avatar[data-initial="S"], .user-avatar[data-initial="T"] { background: var(--avatar-bg-5); color: var(--avatar-fg-5); }
.user-avatar[data-initial="U"], .user-avatar[data-initial="V"],
.user-avatar[data-initial="W"], .user-avatar[data-initial="X"],
.user-avatar[data-initial="Y"], .user-avatar[data-initial="Z"] { background: var(--avatar-bg-6); color: var(--avatar-fg-6); }

/* Fallback when no data-initial */
.user-avatar:not([data-initial]) { background: var(--color-accent-dim); color: var(--color-accent); }

/* Nav avatar size */
.nav-auth-group .user-avatar { width: 2.25rem; height: 2.25rem; }
.nav-user-dropdown-toggle .user-avatar { width: 2.25rem; height: 2.25rem; }


/* --------------------------------------------------------------------------
   33. COMPONENT: Legal Pages
   -------------------------------------------------------------------------- */

.legal-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 2rem 2.5rem;
}

.legal-section {
  padding-top: 1.5rem;
  margin-top: 1.5rem;
  border-top: 1px solid var(--color-border);
}

.legal-section:first-child {
  padding-top: 0;
  margin-top: 0;
  border-top: none;
}

.legal-section h2 {
  font-size: var(--f1-text-lg);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.legal-section h2 .section-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--color-accent);
  color: var(--color-accent-fg);
  font-size: var(--f1-text-xs);
  font-weight: 700;
  flex-shrink: 0;
}

.legal-section h3 {
  font-size: var(--f1-text-base);
  font-weight: 600;
  color: var(--color-text);
  margin: 1rem 0 0.5rem;
}

.legal-section p,
.legal-section li {
  font-size: var(--text-body-sm);
  color: var(--color-text-secondary);
  line-height: 1.7;
}

.legal-section ul {
  padding-left: 1.25rem;
  margin-bottom: 0.75rem;
}

.legal-section ul li { margin-bottom: 0.25rem; }

.legal-highlight {
  background: var(--color-surface-2);
  border-left: 3px solid var(--color-accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 0.75rem 1rem;
  margin: 0.75rem 0;
}

.legal-highlight p {
  margin-bottom: 0;
  font-size: var(--text-body-sm);
  color: var(--color-text);
}

.toc-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  position: sticky;
  top: 1rem;
}

.toc-card h6 {
  font-family: var(--font-display);
  font-size: var(--text-ui-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
}

.toc-card a {
  display: block;
  font-size: var(--text-body-sm);
  color: var(--color-text-muted);
  text-decoration: none;
  padding: 0.25rem 0;
  border-left: 2px solid transparent;
  padding-left: 0.625rem;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.toc-card a:hover {
  color: var(--color-text);
  border-left-color: var(--color-accent);
}

@media (max-width: 991.98px) {
  .legal-card { padding: 1.25rem 1rem; }
}


/* --------------------------------------------------------------------------
   34. COMPONENT: Mobile Menu Button
   -------------------------------------------------------------------------- */

.mobile-menu-btn {
  width: 44px;
  height: 44px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 0;
  color: var(--color-text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--transition-fast), border-color var(--transition-fast);
  font-size: 1.25rem;
}

.mobile-menu-btn:hover,
.mobile-menu-btn:active {
  background: var(--color-surface-3);
  border-color: var(--color-border-hover);
}

.mobile-nav-link {
  display: block;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-secondary);
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
  text-decoration: none;
}
.mobile-nav-link:last-of-type { border-bottom: none; }
.mobile-nav-link:active { color: var(--color-accent); }


/* --------------------------------------------------------------------------
   35. UTILITIES
   -------------------------------------------------------------------------- */

.min-width-0 { min-width: 0 !important; }
.cursor-pointer { cursor: pointer; }

/* Nav auth group */
.nav-auth-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.nav-auth-divider {
  width: 1px;
  height: 18px;
  background: var(--color-border-hover);
  flex-shrink: 0;
}

.nav-logout-btn {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 4px 0;
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: color var(--transition-fast);
}
.nav-logout-btn:hover { color: var(--color-text); }

.nav-signup-btn {
  background: none;
  border: none;
  color: var(--color-accent);
  cursor: pointer;
  padding: 4px 0;
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-decoration: none;
  transition: color var(--transition-fast);
}
.nav-signup-btn:hover { color: var(--color-accent-hover); }

/* User dropdown (desktop) */
.nav-user-dropdown {
  position: relative;
}
.nav-user-dropdown-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
}
.nav-user-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  padding: 6px 0;
  z-index: 200;
}
.nav-user-dropdown-menu.show {
  display: block;
}
.nav-user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 16px;
  background: none;
  border: none;
  color: var(--color-text-secondary);
  font-size: var(--f1-text-sm);
  font-family: var(--font-body);
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.nav-user-dropdown-item:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}
.nav-user-dropdown-item svg {
  flex-shrink: 0;
  opacity: 0.6;
}
.nav-user-dropdown-divider {
  height: 1px;
  margin: 6px 0;
  background: var(--color-border);
}
.nav-user-dropdown-logout {
  color: var(--color-text-muted);
}
.nav-user-dropdown-logout:hover {
  color: var(--color-danger, #e74c3c);
}

/* Theme toggle button */
.btn-theme-toggle {
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
  transition: color var(--transition-fast);
}
.btn-theme-toggle:hover {
  color: var(--color-text);
}

/* Show sun icon in dark mode, moon icon in light mode */
[data-theme="dark"] .theme-icon-dark,
:root:not([data-theme]) .theme-icon-dark { display: none; }
[data-theme="dark"] .theme-icon-light,
:root:not([data-theme]) .theme-icon-light { display: block; }

[data-theme="light"] .theme-icon-light { display: none; }
[data-theme="light"] .theme-icon-dark { display: block; }


/* --------------------------------------------------------------------------
   36. COMPONENT: Showcase Pages (hero + sticky footer)
   Shared by league invite, shared prediction, and future showcase pages.
   -------------------------------------------------------------------------- */

/* Full-bleed hero with grid background */
.showcase-hero {
  padding-top: 52px;
  position: relative;
  overflow: hidden;
  min-height: 320px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.showcase-hero-bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 0%, var(--color-bg) 100%),
              linear-gradient(135deg, var(--color-surface) 0%, var(--color-surface-2) 50%, var(--color-bg) 100%);
}

.showcase-hero-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 39px, var(--color-border) 39px, var(--color-border) 40px),
    repeating-linear-gradient(90deg, transparent, transparent 39px, var(--color-border) 39px, var(--color-border) 40px);
}

.showcase-hero-content {
  position: relative;
  z-index: 1;
  padding: 28px 24px 24px;
  max-width: 680px;
  margin: 0 auto;
  width: 100%;
  animation: showcase-slideUp 0.45s ease both;
}

/* Sticky CTA footer */
.showcase-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--color-backdrop-heavy);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--color-border);
  padding: 14px 24px 20px;
}
.showcase-footer-dismiss {
  position: absolute;
  top: 8px;
  right: 12px;
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}
.showcase-footer-dismiss:hover { color: var(--color-text); }

.showcase-footer-inner {
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.showcase-cta-row {
  display: flex;
  gap: 10px;
}

/* Showcase page body */
.showcase-body {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 24px 140px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Slide-up animation */
@keyframes showcase-slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Stacked avatar group */
.avatar-stack { display: flex; }
.avatar-stack > * { border: 2px solid var(--color-bg); }
.avatar-stack > *:not(:first-child) { margin-left: -8px; }

/* Full-width primary CTA button (for showcase footers/join cards) */
.btn-showcase-primary {
  flex: 1;
  background: var(--color-accent);
  color: var(--color-accent-fg);
  border: none;
  padding: 14px;
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}

.btn-showcase-primary:hover { background: var(--color-accent-hover); color: var(--color-accent-fg); }

.btn-showcase-ghost {
  background: none;
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: border-color var(--transition-fast), color var(--transition-fast);
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.btn-showcase-ghost:hover { border-color: var(--color-border-hover); color: var(--color-text); }


/* --------------------------------------------------------------------------
   37. COMPONENT: Race Calendar — Next Race Hero & Card Enhancements
   -------------------------------------------------------------------------- */

/* Countdown timer */
.countdown {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.cd-unit {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  text-align: center;
  min-width: 52px;
}
.cd-num {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 900;
  color: var(--color-accent);
  line-height: 1;
  display: block;
}
.cd-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  display: block;
  margin-top: 1px;
}

/* Countdown urgency: < 60 minutes */
.countdown-urgent .cd-num {
  color: var(--color-error);
}
.countdown-urgent .cd-unit {
  border-color: rgba(239, 68, 68, 0.3);
}

/* Countdown critical: < 10 minutes — pulsing */
.countdown-critical .cd-num {
  animation: countdown-pulse 1s ease-in-out infinite;
}
@keyframes countdown-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Countdown expired */
.countdown-expired {
  justify-content: center;
}
.cd-closed-msg {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  padding: 8px 16px;
}

/* Race card accent bars */
.race-card-predicted {
  position: relative;
}
.race-card-predicted::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--color-success);
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}
.race-card-completed-nopred {
  position: relative;
}
.race-card-completed-nopred::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--color-text-muted);
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}

/* Score chip on calendar cards */
.race-score-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-success-dim);
  border: 1px solid rgba(34, 197, 94, 0.22);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
}
.race-score-num {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 900;
  color: var(--color-success);
}
.race-score-label {
  font-size: 12px;
  color: var(--color-text-muted);
}

/* Mini podium picks preview */
.race-mini-picks {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: wrap;
}
.mini-pick {
  background: var(--color-surface-2);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  color: var(--color-text-muted);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100px;
}
.mini-pick-p1 {
  color: var(--color-gold);
  background: rgba(255, 215, 0, 0.08);
}

/* Next race hero footer */
.next-race-footer {
  border-top: 1px solid var(--color-border);
  padding: 12px var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.status-submitted {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-success);
}
.status-submitted::before {
  content: '\2713';
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-success-dim);
  border: 1px solid rgba(34, 197, 94, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 900;
  flex-shrink: 0;
}


/* --------------------------------------------------------------------------
   38. COMPONENT: Race Detail — Window Strip & Action Card
   -------------------------------------------------------------------------- */

/* Window strip */
.window-strip {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.window-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}
.window-label {
  color: var(--color-text-muted);
  font-weight: 500;
}
.window-val {
  color: var(--color-text-secondary);
  font-weight: 600;
}
.window-sep {
  width: 1px;
  height: 16px;
  background: var(--color-border);
}
.window-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-size: var(--text-ui-sm);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-left: auto;
}
.pill-open {
  background: var(--color-accent-dim);
  color: var(--color-accent);
  border: 1px solid var(--color-accent-border);
}
.pill-closed {
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}

/* Prediction action card (detail page hero right side) */
.pred-action-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  min-width: 220px;
  flex-shrink: 0;
}
.pred-action-card.submitted {
  border-color: rgba(34, 197, 94, 0.22);
  background: var(--color-success-dim);
}
.pred-action-card.score-card {
  border-color: var(--color-accent-border);
}
.pred-action-label {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 3px;
}
.pred-action-sub {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-bottom: 14px;
}

/* Calendar section label */
.cal-section-label {
  font-family: var(--font-display);
  font-size: var(--text-ui-sm);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}

@media (max-width: 575.98px) {
  .countdown { gap: 4px; }
  .cd-unit { padding: 6px 8px; min-width: 44px; }
  .cd-num { font-size: 20px; }
}

/* --------------------------------------------------------------------------
   LEAGUE CARDS & GRID
   -------------------------------------------------------------------------- */

/* League card grid */
.league-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

/* League card */
.league-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  position: relative;
  animation: leagueCardFadeUp 0.35s ease both;
}
.league-card:nth-child(1) { animation-delay: 0.04s; }
.league-card:nth-child(2) { animation-delay: 0.08s; }
.league-card:nth-child(3) { animation-delay: 0.12s; }
@keyframes leagueCardFadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.league-card:hover {
  border-color: var(--color-border-hover);
  transform: translateY(-2px);
}

/* Gold left accent bar for league leader */
.league-card-leading::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--color-gold);
}

/* Card inner — flex row: text left, rank right */
.league-card-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-4) var(--space-3);
}

/* Card header */
.league-card-head {
  flex: 1;
  min-width: 0;
}
.league-card-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  line-height: 1.05;
  color: var(--color-text);
}
.league-card-meta {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 2px;
}
.league-card-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.league-stat {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-secondary);
  background: var(--color-surface-2);
  padding: 1px 8px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}
.league-card-rank {
  display: flex;
  align-items: baseline;
  gap: 1px;
  flex-shrink: 0;
}
.league-card-rank-num {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 900;
  line-height: 1;
  color: var(--color-text-muted);
}
.league-card-rank.p1 .league-card-rank-num { color: var(--color-gold); }
.league-card-rank.p2 .league-card-rank-num { color: var(--color-silver); }
.league-card-rank.p3 .league-card-rank-num { color: var(--color-bronze); }
.league-card-rank-suffix {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text-muted);
}

.league-card-badges {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex-shrink: 0;
}

/* Position strip */
.league-pos-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 var(--space-4) var(--space-3);
}
.league-pos-block {
  display: flex;
  align-items: center;
  gap: 6px;
}
.league-pos-num {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 900;
  line-height: 1;
}
.league-pos-num.p1 { color: var(--color-gold); }
.league-pos-num.p2 { color: var(--color-silver); }
.league-pos-num.p3 { color: var(--color-bronze); }
.league-pos-num.other { color: var(--color-text-muted); }
.league-pos-suffix {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--color-text-muted);
  padding-top: 8px;
}
.league-pos-divider {
  width: 1px;
  height: 28px;
  background: var(--color-border);
}
.league-pts-block {}
.league-pts-num {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
  color: var(--color-text);
  display: block;
}
.league-pts-label {
  font-size: 12px;
  color: var(--color-text-muted);
  font-weight: 500;
}
.league-gap-label {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-left: auto;
  text-align: right;
}
.league-gap-label strong {
  color: var(--color-text-secondary);
  font-weight: 600;
  display: block;
  font-size: 14px;
}

/* Member avatar strip */
.league-card-members {
  padding: 0 var(--space-4) var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.league-member-avatars {
  display: flex;
}
.league-member-av {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--color-surface);
  flex-shrink: 0;
  background: var(--color-surface-3);
  color: var(--color-text-muted);
}
.league-member-av:not(:first-child) { margin-left: -6px; }
.league-member-av.av-0 { background: var(--avatar-bg-1); color: var(--avatar-fg-1); }
.league-member-av.av-1 { background: var(--avatar-bg-2); color: var(--avatar-fg-2); }
.league-member-av.av-2 { background: var(--avatar-bg-3); color: var(--avatar-fg-3); }
.league-member-av.av-3 { background: var(--avatar-bg-4); color: var(--avatar-fg-4); }
.league-member-av.av-4 { background: var(--avatar-bg-5); color: var(--avatar-fg-5); }
.league-member-count {
  font-size: 13px;
  color: var(--color-text-muted);
}

/* Card footer */
.league-card-foot {
  border-top: 1px solid var(--color-border);
  padding: 11px var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
}
.league-card-action {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}
.league-card:hover .league-card-action { color: var(--color-text); }
.league-card-action.open { color: var(--color-accent); }
.league-last-race {
  font-size: 12px;
  color: var(--color-text-muted);
}
.league-last-race strong { color: var(--color-text-secondary); }

/* Action card (browse, join, create) */
.league-action-card {
  background: var(--color-surface);
  border: 1px dashed var(--color-border-hover);
  border-radius: var(--radius-xl);
  padding: var(--space-4);
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}
.league-action-card:hover {
  border-color: var(--color-accent-border);
  background: var(--color-surface-2);
  transform: translateY(-2px);
}
.league-action-card-accent {
  border-style: solid;
  border-color: var(--color-accent-border);
  background: var(--color-accent-dim);
}
.league-action-icon {
  font-size: 1.5rem;
  margin-bottom: 8px;
}
.league-action-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text);
  margin-bottom: 4px;
}
.league-action-sub {
  font-size: 12px;
  color: var(--color-text-muted);
  line-height: 1.5;
  flex: 1;
}
.league-action-arrow {
  font-size: 14px;
  color: var(--color-text-muted);
  margin-top: 8px;
  align-self: flex-end;
  transition: color 0.2s, transform 0.2s;
}
.league-action-card:hover .league-action-arrow {
  color: var(--color-accent);
  transform: translateX(3px);
}


/* --------------------------------------------------------------------------
   LEAGUE DETAIL PAGE
   -------------------------------------------------------------------------- */

/* Header */
.league-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}
.league-detail-left { flex: 1; }
.league-detail-name {
  font-family: var(--font-display);
  font-size: 48px;
  font-weight: 900;
  text-transform: uppercase;
  line-height: 0.95;
  letter-spacing: -0.01em;
  margin-bottom: 10px;
  color: var(--color-text);
}
.league-detail-name em {
  color: var(--color-accent);
  font-style: normal;
  display: block;
}
.league-detail-meta {
  font-size: 14px;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.league-detail-meta-sep { color: var(--color-border-hover); }

/* Your position (top right) */
.league-your-pos {
  flex-shrink: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.league-your-pos-rank {
  flex-shrink: 0;
}
.league-your-pos-num {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 900;
  line-height: 1;
  color: var(--color-text-muted);
}
.league-your-pos-num.p1 { color: var(--color-gold); }
.league-your-pos-num.p2 { color: var(--color-silver); }
.league-your-pos-num.p3 { color: var(--color-bronze); }
.league-your-pos-num sup {
  font-size: 13px;
  font-weight: 700;
}
.league-your-pos-stats {
  display: flex;
  flex-direction: column;
}
.league-your-pos-pts {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 900;
  color: var(--color-text);
}
.league-your-pos-gap {
  font-size: 11px;
  color: var(--color-text-muted);
}
.league-your-pos-gap.leading { color: var(--color-gold); }

/* Share bar (reusable pill: league invite, prediction share, etc.) */
/* Share card */
.share-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}
.share-card-label {
  font-size: var(--text-body-sm);
  color: var(--color-text-secondary);
  font-weight: 600;
  font-style: italic;
}
.share-card-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}
.share-card-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: var(--text-body-xs);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: opacity var(--transition-fast), border-color var(--transition-fast);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-secondary);
}
.share-card-btn:hover { border-color: var(--color-border-hover); color: var(--color-text); }
.share-card-btn-wa { background: #25D366; color: #fff; border-color: #25D366; }
.share-card-btn-wa:hover { opacity: 0.9; color: #fff; }
.share-card-btn-x { color: var(--color-text); }
@media (max-width: 575.98px) {
  .share-card { flex-direction: column; align-items: flex-start; }
  .share-card-actions { margin-left: 0; width: 100%; }
}
@media (max-width: 767.98px) {
  .league-your-pos { width: 100%; }
}

/* Invite strip */
.league-invite-strip {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 14px var(--space-4);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.league-invite-strip-left { flex: 1; min-width: 0; }
.league-invite-strip-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-muted);
  font-weight: 700;
  margin-bottom: 3px;
}
.league-invite-strip-text {
  font-size: 13px;
  color: var(--color-text-secondary);
}
.league-invite-btns {
  display: flex;
  gap: 8px;
}

/* Standings gap line between 1st and 2nd */
.league-standings-gap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 20px;
  border-top: 1px solid var(--color-border);
  background: rgba(184, 134, 11, 0.04);
}
.league-standings-gap-line {
  flex: 1;
  height: 1px;
  background: repeating-linear-gradient(90deg, var(--color-gold) 0, var(--color-gold) 4px, transparent 4px, transparent 8px);
  opacity: 0.3;
}
.league-standings-gap-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-gold);
  font-family: var(--font-display);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Standings rows redesign */
.lb-player-stack {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.lb-name-text {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--color-text);
}
.lb-name-text.you { color: var(--color-accent); }
.lb-pts-value {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 900;
  display: block;
  line-height: 1;
}
.lb-pts-value.you { color: var(--color-accent); }
.lb-last-score {
  font-size: 11px;
  color: var(--color-text-muted);
}
.lb-last-score strong { color: var(--color-text-secondary); }

/* Settings drawer */
.league-settings-drawer {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  margin-bottom: 14px;
}
.league-settings-inner { padding: 20px; }
.league-settings-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-3);
  display: flex;
  align-items: center;
  gap: 8px;
}
.league-danger-zone {
  border: 1px solid rgba(220, 38, 38, 0.2);
  border-radius: var(--radius-xl);
  padding: var(--space-3) var(--space-4);
  margin-top: 8px;
}
.league-danger-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-error);
  opacity: 0.7;
  font-weight: 700;
  margin-bottom: 8px;
}
.league-danger-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.league-danger-desc {
  font-size: 13px;
  color: var(--color-text-muted);
}

/* Leagues list header */
.leagues-header-title {
  font-family: var(--font-display);
  font-size: 42px;
  font-weight: 900;
  text-transform: uppercase;
  line-height: 1;
  letter-spacing: -0.01em;
  color: var(--color-text);
}
.leagues-header-title em { color: var(--color-accent); font-style: normal; }
.leagues-header-meta {
  font-size: 14px;
  color: var(--color-text-muted);
  margin-top: 5px;
}

@media (max-width: 575.98px) {
  .league-grid { grid-template-columns: 1fr; }
  .leagues-header-title { font-size: 32px; }
  .league-invite-strip { flex-direction: column; align-items: stretch; }
  .league-invite-btns { width: 100%; }
  .league-invite-btns > * { flex: 1; }
}

/* --------------------------------------------------------------------------
   F1 GEEK — AI CHAT PANEL
   -------------------------------------------------------------------------- */

/* Inline "F1 Geek" CTA link — highlighted mention that opens the chat */
.f1geek-cta {
  color: var(--color-accent);
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  border-bottom: 1px dashed var(--color-accent-border);
  transition: border-color var(--transition-fast);
}
.f1geek-cta:hover {
  border-bottom-color: var(--color-accent);
  color: var(--color-accent);
}

/* Toggle button */
.f1geek-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--color-accent);
  color: var(--color-bg);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 1rem;
  box-shadow: 0 4px 16px var(--color-overlay);
  transition: transform var(--transition-fast), background var(--transition-fast);
}
.f1geek-toggle-label {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.f1geek-toggle:hover {
  background: var(--color-accent-hover);
  transform: scale(1.05);
}
.f1geek-toggle.active {
  background: var(--color-surface-3);
  color: var(--color-text);
}

/* Tooltip bubble */
.f1geek-tooltip {
  position: fixed;
  bottom: 72px;
  right: 24px;
  z-index: 301;
  max-width: 260px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 0.75rem 1rem;
  font-size: var(--f1-text-sm);
  color: var(--color-text-secondary);
  box-shadow: 0 8px 24px var(--color-overlay);
  align-items: flex-start;
  gap: 0.5rem;
  animation: f1geekTooltipIn 0.3s ease-out;
}
.f1geek-tooltip::after {
  content: '';
  position: absolute;
  bottom: -6px;
  right: 20px;
  width: 12px;
  height: 12px;
  background: var(--color-surface-2);
  border-right: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  transform: rotate(45deg);
}
.f1geek-tooltip-close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
}
.f1geek-tooltip-close:hover { color: var(--color-text); }
@keyframes f1geekTooltipIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Panel */
.f1geek-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  z-index: 301;
  background: var(--color-bg);
  border-left: 1px solid var(--color-border);
  box-shadow: -4px 0 24px var(--color-overlay);
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-normal) ease;
}
.f1geek-panel.closing {
  transform: translateX(100%);
}

/* Header */
.f1geek-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 56px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  flex-shrink: 0;
}
.f1geek-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--color-text);
}
.f1geek-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--color-accent);
  color: var(--color-bg);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.5px;
}
.f1geek-header-btn {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 40px;
  min-height: 40px;
  transition: color var(--transition-fast), background var(--transition-fast);
}
.f1geek-header-btn:hover {
  color: var(--color-text);
  background: var(--color-surface-2);
}
.f1geek-header-btn svg {
  width: 20px;
  height: 20px;
}
.f1geek-header-btn-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Conversation list */
.f1geek-conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  border-bottom: 1px solid var(--color-border);
}
.f1geek-conv-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--color-text-secondary);
  font-size: var(--f1-text-sm);
  transition: background var(--transition-fast);
}
.f1geek-conv-item:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}
.f1geek-conv-item.active {
  background: var(--color-surface-2);
  color: var(--color-accent);
}
.f1geek-conv-item-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.f1geek-conv-delete {
  opacity: 0;
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 2px;
  border-radius: var(--radius-sm);
  transition: opacity var(--transition-fast), color var(--transition-fast);
}
.f1geek-conv-item:hover .f1geek-conv-delete { opacity: 1; }
.f1geek-conv-delete:hover { color: var(--color-error); }

/* Messages area */
.f1geek-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.f1geek-msg {
  max-width: 90%;
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  font-size: var(--f1-text-sm);
  line-height: 1.5;
  word-wrap: break-word;
}
.f1geek-msg-user {
  align-self: flex-end;
  background: var(--color-accent);
  color: var(--color-bg);
  border-bottom-right-radius: var(--radius-sm);
  user-select: text;
}
.f1geek-msg-user::selection {
  background: rgba(255, 255, 255, 0.35);
  color: #fff;
}
.f1geek-msg-user::-moz-selection {
  background: rgba(255, 255, 255, 0.35);
  color: #fff;
}
.f1geek-msg-assistant {
  align-self: flex-start;
  background: var(--color-surface-2);
  color: var(--color-text);
  border-bottom-left-radius: var(--radius-sm);
}
.f1geek-msg-assistant table {
  display: block;
  overflow-x: auto;
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 12px;
}
.f1geek-msg-assistant th,
.f1geek-msg-assistant td {
  text-align: left;
  padding: 4px 8px;
  border-bottom: 1px solid var(--color-border);
}
.f1geek-msg-assistant th {
  color: var(--color-text-secondary);
  font-weight: 600;
}
.f1geek-msg-assistant code {
  background: var(--color-surface-3);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 12px;
}
.f1geek-msg-assistant strong {
  color: var(--color-accent);
}
.f1geek-msg-assistant h1,
.f1geek-msg-assistant h2,
.f1geek-msg-assistant h3,
.f1geek-msg-assistant h4 {
  font-size: var(--f1-text-sm);
  font-weight: 700;
  color: var(--color-accent);
  margin: 12px 0 4px;
  line-height: 1.3;
}
.f1geek-msg-assistant h1:first-child,
.f1geek-msg-assistant h2:first-child,
.f1geek-msg-assistant h3:first-child,
.f1geek-msg-assistant h4:first-child {
  margin-top: 0;
}
.f1geek-msg-assistant hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 10px 0;
}
.f1geek-msg-assistant ol,
.f1geek-msg-assistant ul {
  margin: 6px 0;
  padding-left: 20px;
}
.f1geek-msg-assistant li {
  margin: 2px 0;
}
.f1geek-msg-assistant pre {
  background: var(--color-surface-3);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 8px 0;
  font-size: 12px;
}
.f1geek-msg-assistant pre code {
  background: none;
  padding: 0;
}

/* Thinking indicator */
.f1geek-thinking {
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 14px;
  background: var(--color-surface-2);
  border-radius: var(--radius-md) var(--radius-md) var(--radius-md) 0;
  max-width: 85%;
}
.f1geek-thinking-dots {
  display: flex;
  gap: 4px;
}
.f1geek-thinking-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-text-muted);
  animation: f1geek-dot 1.4s ease-in-out infinite;
}
.f1geek-thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.f1geek-thinking-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes f1geek-dot {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}
.f1geek-thinking-label {
  font-size: var(--f1-text-xs);
  color: var(--color-text-muted);
  font-style: italic;
  animation: f1geek-thinking-fade 3s ease-in-out infinite;
}
@keyframes f1geek-thinking-fade {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* Reasoning section */
.f1geek-reasoning {
  margin-top: 6px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.f1geek-reasoning-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  background: var(--color-surface-3);
  border: none;
  color: var(--color-text-muted);
  font-size: 11px;
  padding: 4px 8px;
  cursor: pointer;
  text-align: left;
}
.f1geek-reasoning-toggle:hover { color: var(--color-text-secondary); }
.f1geek-reasoning-content {
  display: none;
  padding: 8px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--color-text-secondary);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 200px;
  overflow-y: auto;
}
.f1geek-reasoning.open .f1geek-reasoning-content { display: block; }

/* Error display */
.f1geek-error {
  align-self: center;
  background: var(--color-error-dim);
  color: var(--color-error);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: var(--f1-text-xs);
  text-align: center;
}
.f1geek-retry-btn {
  background: none;
  border: 1px solid var(--color-error);
  color: var(--color-error);
  padding: 2px 10px;
  border-radius: var(--radius-sm);
  font-size: var(--f1-text-xs);
  font-weight: 600;
  cursor: pointer;
  margin-left: 4px;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.f1geek-retry-btn:hover {
  background: var(--color-error);
  color: #fff;
}

/* Input area */
.f1geek-input-area {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  flex-shrink: 0;
}
.f1geek-disclaimer {
  font-size: 11px;
  color: var(--color-text-muted);
  text-align: center;
  line-height: 1.3;
  padding: 0 16px;
}
.f1geek-textarea {
  flex: 1;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: 14px;
  line-height: 1.4;
  font-family: var(--font-body);
  padding: 8px 12px;
  height: 36px; /* 14px * 1.4 + 8px * 2 = ~36px — matches single-line scrollHeight */
  resize: none;
  max-height: 100px;
  overflow-y: hidden;
  outline: none;
  box-sizing: border-box;
  transition: border-color var(--transition-fast);
}
@supports (-webkit-touch-callout: none) {
  /* iOS: keep 16px to prevent auto-zoom on focus */
  .f1geek-textarea { font-size: 16px; height: 38px; }
}
.f1geek-textarea:focus {
  border-color: var(--color-accent);
}
.f1geek-textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.f1geek-textarea::placeholder {
  color: var(--color-text-muted);
}
.f1geek-send-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--color-accent);
  color: var(--color-bg);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition-fast), opacity var(--transition-fast);
}
.f1geek-send-btn:hover:not(:disabled) { background: var(--color-accent-hover); }
.f1geek-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.f1geek-send-btn .f1geek-send-icon { display: inline; }
.f1geek-send-btn .f1geek-send-spinner { display: none; }
.f1geek-send-btn.loading .f1geek-send-icon { display: none; }
.f1geek-send-btn.loading .f1geek-send-spinner { display: inline; }
@keyframes f1geek-spin {
  to { transform: rotate(360deg); }
}
.f1geek-send-spinner svg {
  animation: f1geek-spin 0.8s linear infinite;
}


/* Empty state */
.f1geek-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 32px;
  text-align: center;
  color: var(--color-text-muted);
  gap: 12px;
}
.f1geek-empty-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 20px;
  color: var(--color-text-secondary);
  text-transform: uppercase;
}
.f1geek-empty-icon {
  color: var(--color-accent);
  opacity: 0.6;
}
.f1geek-empty-hint {
  font-size: var(--f1-text-sm);
  max-width: 260px;
}
.f1geek-empty-suggestion {
  margin-top: 8px;
  padding: 8px 14px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  font-size: var(--f1-text-xs);
  color: var(--color-text-secondary);
  cursor: pointer;
  max-width: 280px;
  transition: border-color var(--transition-fast), color var(--transition-fast);
}
.f1geek-empty-suggestion:hover {
  border-color: var(--color-accent);
  color: var(--color-text);
}
.f1geek-empty-suggestion-label {
  color: var(--color-text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.5px;
}

/* Body scroll lock when chat panel is open on mobile */
body.f1geek-panel-open {
  overflow: hidden;
}

/* Mobile: full-width overlay */
@media (max-width: 575.98px) {
  .f1geek-panel {
    width: 100%;
    height: 100dvh;
    height: 100vh; /* fallback for older browsers */
    height: 100dvh;
  }
  .f1geek-toggle { bottom: 16px; right: 16px; height: 36px; padding: 0 0.75rem; }
  .f1geek-tooltip { bottom: 60px; right: 16px; max-width: 220px; }
}


/* --------------------------------------------------------------------------
   ACCESSIBILITY: Focus-visible
   -------------------------------------------------------------------------- */

*:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Buttons — clear Bootstrap's box-shadow on focus */
.btn-f1-accent:focus-visible,
.btn-f1-outline:focus-visible,
.btn-f1-danger:focus-visible,
.btn-ghost:focus-visible,
.btn:focus-visible {
  box-shadow: none;
}

/* Form controls — border highlight instead of outline */
.form-control:focus-visible,
.form-select:focus-visible,
.select-dark:focus-visible,
.predict-select:focus-visible,
.form-select-f1:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -1px;
  border-color: var(--color-border-focus);
}

/* Nav links — subtle underline */
.nav-link:focus-visible,
.mobile-nav-link:focus-visible {
  outline-offset: 4px;
}

/* Cards acting as links */
a.st-row:focus-visible,
a.league-card:focus-visible,
a.race-card:focus-visible {
  outline-offset: -2px;
  border-radius: var(--radius-md);
}



/* --------------------------------------------------------------------------
   COMPONENT: Driver Picker (Bottom Sheet / Popover)
   -------------------------------------------------------------------------- */

/* ── Slot rows ── */
.dp-slot-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

button.dp-slot-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
  position: relative;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  font-family: inherit;
  font-size: inherit;
  color: var(--color-text);
  text-align: left;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
button.dp-slot-row:hover  { border-color: var(--color-border-hover); background: var(--color-surface-2); }
button.dp-slot-row:active { background: var(--color-surface-3); }
button.dp-slot-row:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
button.dp-slot-row.dp-slot-filled { border-color: var(--color-border-hover); }

button.dp-slot-row .pos-circle {
  width: 28px;
  height: 28px;
  font-size: 13px;
}

.dp-slot-content { flex: 1; min-width: 0; }

.dp-slot-driver {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
}
.dp-slot-placeholder {
  font-weight: 500;
  color: var(--color-text-muted);
  font-size: 15px;
  font-family: var(--font-body);
}

.dp-team-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dp-slot-number {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 1px;
}

.dp-slot-chevron {
  color: var(--color-text-muted);
  flex-shrink: 0;
  font-size: 18px;
  transition: transform var(--transition-fast);
}
button.dp-slot-row:hover .dp-slot-chevron { transform: translateX(2px); }

.dp-slot-clear {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-surface-2);
  border: none;
  color: var(--color-text-muted);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition-fast), color var(--transition-fast);
  line-height: 1;
  padding: 0;
}
.dp-slot-clear:hover { background: var(--color-error-dim); color: var(--color-error); }

/* Pulse animation for next-empty slot */
.dp-slot-pulsing {
  animation: dp-pulse 600ms ease-out;
}
@keyframes dp-pulse {
  0%   { border-color: rgba(200, 255, 0, 0.3); box-shadow: 0 0 0 0 rgba(200, 255, 0, 0.25); }
  40%  { border-color: var(--color-accent);     box-shadow: 0 0 0 6px rgba(200, 255, 0, 0.08); background: rgba(200, 255, 0, 0.04); }
  100% { border-color: var(--color-border);     box-shadow: 0 0 0 0 rgba(200, 255, 0, 0);   background: var(--color-surface); }
}

/* ── Expand to Full Pick button ── */
.dp-expand-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem;
  border: 1px dashed rgba(200, 255, 0, 0.25);
  border-radius: var(--radius-lg);
  cursor: pointer;
  color: var(--color-accent);
  font-size: var(--f1-text-sm);
  font-weight: 600;
  font-family: inherit;
  background: rgba(200, 255, 0, 0.05);
  -webkit-appearance: none;
  appearance: none;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.dp-expand-btn:hover { background: rgba(200, 255, 0, 0.1); border-color: var(--color-accent); }

/* ── Backdrop ── */
.dp-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1040;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms;
}
.dp-backdrop.dp-visible { opacity: 1; pointer-events: all; }

/* ── Bottom sheet (mobile default) ── */
.dp-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 78vh;
  background: var(--color-surface);
  border-radius: 20px 20px 0 0;
  z-index: 1050;
  display: flex;
  pointer-events: none;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 280ms cubic-bezier(0.32, 0.72, 0, 1);
  will-change: transform;
}
.dp-sheet.dp-sheet-open { transform: translateY(0); pointer-events: auto; }

.dp-sheet-handle-area {
  padding: 12px 0 8px;
  display: flex;
  justify-content: center;
  flex-shrink: 0;
  cursor: grab;
}
.dp-sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--color-border-hover);
  border-radius: 99px;
}

.dp-sheet-header {
  padding: 0 16px 14px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.dp-sheet-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.dp-sheet-title em { color: var(--color-accent); font-style: normal; }
.dp-sheet-subtitle { font-size: 12px; color: var(--color-text-muted); margin-top: 2px; }

.dp-sheet-search {
  margin: 12px 16px 0;
  flex-shrink: 0;
}
.dp-search-input {
  width: 100%;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 10px 14px 10px 36px;
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='rgba(255,255,255,0.3)' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.099zm-5.242 1.156a5.5 5.5 0 1 1 0-11 5.5 5.5 0 0 1 0 11z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
}
.dp-search-input::placeholder { color: var(--color-text-muted); }
.dp-search-input:focus { border-color: var(--color-border-hover); }

/* ── Chip grid ── */
.dp-chip-grid {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 24px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-content: start;
}
.dp-chip-grid::-webkit-scrollbar { width: 4px; }
.dp-chip-grid::-webkit-scrollbar-track { background: transparent; }
.dp-chip-grid::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 99px; }

/* ── Driver chip ── */
.dp-chip {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 10px 12px 10px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: border-color var(--transition-fast), background var(--transition-fast), opacity var(--transition-fast);
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  min-height: 52px;
  text-align: left;
  color: var(--color-text);
  font-family: var(--font-body);
  width: 100%;
}
.dp-chip-bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  border-radius: 10px 0 0 10px;
}
.dp-chip:hover:not(.dp-chip-taken):not(.dp-chip-current) {
  border-color: var(--color-border-hover);
  background: var(--color-surface-3);
}
.dp-chip:active:not(.dp-chip-taken):not(.dp-chip-current) {
  background: rgba(255, 255, 255, 0.06);
}
.dp-chip-taken {
  opacity: 0.3;
  pointer-events: none;
  cursor: default;
}
.dp-chip-current {
  border-color: var(--color-accent);
  background: rgba(200, 255, 0, 0.08);
}

.dp-chip-info { flex: 1; min-width: 0; }
.dp-chip-name {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dp-chip-number { font-size: 11px; color: var(--color-text-muted); }

.dp-chip-check {
  color: var(--color-accent);
  font-size: 16px;
  flex-shrink: 0;
  font-weight: 700;
}
.dp-taken-badge {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

/* ── Desktop: popover instead of bottom sheet ── */
@media (min-width: 768px) {
  .dp-sheet {
    position: fixed;
    bottom: auto;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    opacity: 0;
    width: 480px;
    max-width: 90vw;
    height: auto;
    max-height: 70vh;
    border-radius: var(--radius-xl);
    transition: transform 200ms ease, opacity 200ms ease;
  }
  .dp-sheet.dp-sheet-open {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    pointer-events: auto;
  }
  .dp-sheet-handle-area { display: none; }
  .dp-chip-grid { max-height: 50vh; }
}

/* ── Light theme adjustments ── */
[data-theme="light"] button.dp-slot-row { background: var(--color-surface); }
[data-theme="light"] button.dp-slot-row:hover { background: var(--color-surface-2); }
[data-theme="light"] .dp-sheet { background: var(--color-surface); }
[data-theme="light"] .dp-chip { background: var(--color-surface-2); }
[data-theme="light"] .dp-search-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='rgba(0,0,0,0.3)' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.099zm-5.242 1.156a5.5 5.5 0 1 1 0-11 5.5 5.5 0 0 1 0 11z'/%3E%3C/svg%3E");
}

/* --------------------------------------------------------------------------
   ACCESSIBILITY: Reduced motion
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
