:root {
  --primary: #d32f2f;
  --primary-hover: #b71c1c;
  --primary-light: #fee2e2;
  --bg-page: #f4f6f8;
  --bg-card: #ffffff;
  --text-main: #1f2937;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  
  --gold: #f59e0b;
  --silver: #9ca3af;
  --bronze: #b45309;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.container {
  width: 100%;
  padding: 0 16px;
}
@media (min-width: 1600px) {
  .container { padding: 0 24px; }
}

/* TOPBAR */
.topbar {
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.topbar-inner {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  height: 68px;
  gap: 36px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text-main);
  flex-shrink: 0;
}
.logo-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}
.logo-text { line-height: 1.15; }
.topbar-updated {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1.2;
}
.topbar-updated strong {
  color: var(--text-main);
  font-weight: 700;
}
.brand-logo {
  height: 44px;
  width: auto;
  object-fit: contain;
}

/* TOP NAV */
.top-nav {
  display: flex;
  gap: 8px;
}
.nav-btn {
  background: transparent;
  border: none;
  padding: 8px 16px;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
}
.nav-btn:hover {
  background: var(--bg-page);
  color: var(--text-main);
}
.nav-btn.is-active {
  background: var(--primary-light);
  color: var(--primary);
}

@media (max-width: 600px) {
  .topbar-inner {
    height: auto;
    padding-block: 12px;
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }
  .logo {
    justify-content: center;
    align-items: center;
    font-size: 1.15rem;
  }
  .logo-copy { align-items: center; }
  .topbar-updated { font-size: 0.72rem; }
  .brand-logo { height: 32px; }
  .top-nav {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    width: 100%;
  }
  .nav-btn {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
    padding: 9px 2px;
    font-size: 0.78rem;
    text-align: center;
    white-space: nowrap;
  }
  .nav-btn svg { display: none; }
}

/* MAIN LAYOUT */
.layout-main {
  padding: 24px 16px 64px;
}

/* VIEW: DASHBOARD */
.filter-section { margin-bottom: 24px; }
.category-header-wrap {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.category-tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.category-tabs button {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 10px 20px;
  font-size: 0.9375rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}
.category-tabs button:hover {
  border-color: #cbd5e1;
  color: var(--text-main);
  background: #f8fafc;
}
.category-tabs button.is-active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 4px 6px rgba(211, 47, 47, 0.2);
}

.toolbar { margin-bottom: 32px; }

.content-grid {
  display: grid;
  gap: 24px;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 16px;
  color: var(--text-main);
}

/* TABLE */
.table-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.table-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}
.table-title-text { 
  margin: 0; 
  font-size: 1.25rem; 
  font-weight: 700; 
  color: var(--text-main); 
}
.table-wrap {
  overflow: auto;
  height: calc(100vh - 220px);
  min-height: 500px;
}
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
  font-size: 0.875rem;
  white-space: nowrap;
}
#rankingTable.is-athletes td:nth-child(2),
#rankingTable.is-athletes td:nth-child(3) { width: 25%; }
#rankingTable.is-clubs td:nth-child(2) { width: 18%; }
th {
  background: var(--bg-card);
  position: sticky;
  top: 0;
  z-index: 10;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 700;
}
th::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 1px; background: var(--border);
}
tbody tr { transition: background 0.15s; }
tbody tr:nth-child(even) { background: #fcfcfc; }
tbody tr:hover { background: #f1f5f9; }

.rank { font-weight: 700; color: var(--text-muted); }
tbody tr:nth-child(1) .rank { color: var(--gold); }
tbody tr:nth-child(2) .rank { color: var(--silver); }
tbody tr:nth-child(3) .rank { color: var(--bronze); }
.points { font-weight: 700; }
.performance { text-align: center; }
.mobile-card-toggle { display: none; }
.empty { color: #9ca3af; font-style: italic; }

@keyframes highlightRow {
  0% { background-color: #fef08a; } /* light yellow */
  80% { background-color: #fef08a; }
  100% { background-color: transparent; }
}
tbody tr.highlight-target {
  animation: highlightRow 5s ease-out forwards;
}
tbody tr.highlight-target:nth-child(even) {
  animation: highlightRow 5s ease-out forwards;
}

/* VIEW 2: SEARCH PAGE */
.search-hero {
  max-width: 800px;
  margin: 40px auto 60px;
  text-align: center;
}
.page-title {
  font-size: 3rem;
  margin-bottom: 32px;
  color: var(--text-main);
  font-weight: 800;
  letter-spacing: -0.02em;
}
.giant-search-wrapper {
  position: relative;
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-lg);
}
.search-icon-giant {
  position: absolute;
  left: 24px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}
.giant-search-input {
  width: 100%;
  padding: 24px 24px 24px 64px;
  font-size: 1.5rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  color: var(--text-main);
}
.giant-search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
}

.search-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  max-width: 1000px;
  margin: 0 auto;
}
.search-result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.search-result-card:hover {
  transform: translateY(-4px);
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}
.result-info h4 { margin: 0 0 6px; font-size: 1.25rem; color: var(--text-main); }
.result-info p { margin: 0; font-size: 0.875rem; color: var(--text-muted); }
.result-score { font-size: 1.5rem; font-weight: 800; color: var(--primary); }
.no-results { text-align: center; color: var(--text-muted); font-size: 1.25rem; grid-column: 1 / -1; }

/* VIEW 3: ATHLETE PAGE */
.athlete-page-nav { margin-bottom: 32px; }
.btn-back {
  background: transparent;
  border: none;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px 0;
  transition: color 0.2s;
}
.btn-back:hover { color: var(--primary); }

.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 700;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: transparent;
  color: var(--text-main);
  border: 1px solid var(--border);
  padding: 10px 16px;
  font-size: 0.9375rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
  display: block;
  width: 100%;
  text-align: center;
}
.btn-secondary:hover {
  background: var(--bg-page);
  border-color: #cbd5e1;
}

.athlete-profile-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 48px;
  box-shadow: var(--shadow-md);
  max-width: 900px;
  margin: 0 auto;
}
.athlete-huge-name {
  font-size: 3.5rem;
  margin: 0 0 16px;
  letter-spacing: -0.02em;
  color: var(--text-main);
  line-height: 1.1;
}
.meta-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 40px;
}
.meta-chips span {
  background: var(--bg-page);
  padding: 8px 16px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  font-weight: 600;
  color: var(--text-main);
}
.warning-banner {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  padding: 16px 24px;
  border-radius: var(--radius-md);
  margin-bottom: 32px;
  font-weight: 600;
}
.athlete-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-bottom: 48px;
}
.stat-card {
  background: var(--bg-page);
  padding: 24px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  text-align: center;
}
.stat-label {
  display: block;
  font-size: 0.875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: 8px;
}
.stat-value {
  display: block;
  font-size: 3rem;
  color: var(--primary);
  line-height: 1;
  font-weight: 800;
}
.mt-8 { margin-top: 48px; }
.events-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.event-line-large {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px;
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.event-line-large strong:first-child { flex: 1; font-size: 1.125rem; color: var(--text-main); }
.event-line-large span { color: var(--text-muted); font-size: 1.125rem; }
.event-line-large strong:last-child { font-size: 1.5rem; color: var(--primary); min-width: 100px; text-align: right; }

button.athlete-link {
  background: transparent;
  border: none;
  padding: 0;
  color: var(--primary);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
button.athlete-link:hover { text-decoration: underline; }
.mobile-inline-tags { display: none; }
.mobile-inline-tag {
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 3px 9px;
  background: #f8fafc;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.1;
}

/* VIEW 4: RULES PAGE */
.rules-page {
  max-width: 1180px;
  margin: 0 auto;
}

.rules-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 28px;
  align-items: center;
  margin-bottom: 18px;
  padding: 28px;
  border-radius: var(--radius-md);
  color: #fff;
  background:
    linear-gradient(120deg, rgba(17, 24, 39, 0.98) 0%, rgba(31, 41, 55, 0.94) 62%, rgba(211, 47, 47, 0.9) 100%);
  border: 1px solid rgba(17, 24, 39, 0.16);
  box-shadow: var(--shadow-md);
}

.rules-kicker {
  display: inline-flex;
  margin-bottom: 12px;
  padding: 5px 10px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #fee2e2;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.rules-hero h1 {
  margin: 0 0 12px;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1.05;
}

.rules-hero p {
  margin: 0;
  max-width: 720px;
  color: rgba(255, 255, 255, 0.86);
  font-size: 1.05rem;
}

.rules-logo {
  width: 100%;
  max-width: 260px;
  justify-self: end;
  padding: 12px;
  border-radius: var(--radius-md);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.rules-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.rules-summary article,
.rules-intro,
.rule-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.rules-summary article {
  padding: 16px;
  border-left: 4px solid var(--primary);
}

.rules-summary span {
  display: block;
  margin-bottom: 5px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.rules-summary strong {
  display: block;
  line-height: 1.25;
}

.rules-intro {
  margin-bottom: 18px;
  padding: 24px;
}

.rules-intro h2,
.rules-detail h2 {
  margin: 0 0 12px;
  color: var(--text-main);
  font-size: 1.5rem;
}

.rules-intro p {
  margin: 0;
  max-width: 940px;
  color: var(--text-muted);
}

.rules-intro p + p { margin-top: 10px; }

.rules-detail h2 { margin-top: 26px; }

.rules-list {
  display: grid;
  gap: 10px;
}

.rule-item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 16px;
  padding: 18px;
}

.rule-number {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}

.rule-item h3 {
  margin: 3px 0 8px;
  color: var(--text-main);
  font-size: 1.05rem;
}

.rule-item p {
  margin: 0;
  color: var(--text-muted);
}

.rule-item p + p { margin-top: 10px; }

body.has-onboarding { overflow: hidden; }

.onboarding-modal[hidden] { display: none; }

.onboarding-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
}

.onboarding-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(2px);
  z-index: 0;
}

.onboarding-panel {
  position: relative;
  z-index: 1;
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: linear-gradient(180deg, #ffffff 0%, #fbfcfd 100%);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 16px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.26);
  padding: 28px 28px 24px;
  scrollbar-width: thin;
  animation: modalEnter 0.32s ease-out both;
}

.onboarding-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: #f8fafc;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.onboarding-close svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  fill: none;
}

.onboarding-close:hover {
  color: var(--primary);
  border-color: var(--primary-light);
  background: var(--primary-light);
  transform: translateY(-1px);
}

.onboarding-close:focus-visible,
.onboarding-primary:focus-visible {
  outline: 3px solid rgba(211, 47, 47, 0.24);
  outline-offset: 3px;
}

.onboarding-copy {
  max-width: 520px;
  margin: 0;
  padding-right: 34px;
}

.onboarding-kicker {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-full);
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.onboarding-copy h2 {
  margin: 10px 0 6px;
  font-size: clamp(1.7rem, 4vw, 2.05rem);
  line-height: 1.1;
  color: var(--text-main);
}

.onboarding-copy p {
  margin: 0;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.55;
}

.onboarding-demo {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 210px;
  gap: 18px;
  align-items: center;
  min-height: 174px;
  margin: 20px 0 18px;
  padding: 24px;
  border-radius: 14px;
  background:
    radial-gradient(circle at 88% 18%, rgba(211, 47, 47, 0.16), transparent 34%),
    linear-gradient(135deg, #f8fafc 0%, #ffffff 55%, #fff1f2 100%);
  border: 1px solid var(--border);
  overflow: hidden;
}

.demo-stage {
  position: relative;
  min-height: 112px;
  display: flex;
  align-items: center;
}

.demo-row {
  width: 100%;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.demo-rank {
  color: var(--gold);
  font-weight: 800;
  font-size: 1.15rem;
}

.demo-name {
  position: relative;
  color: var(--primary);
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.demo-name::after {
  content: "";
  position: absolute;
  inset: -4px -8px;
  border: 2px solid rgba(211, 47, 47, 0.34);
  border-radius: 999px;
  opacity: 0;
  transform: scale(0.94);
  animation: namePulse 3.2s ease-in-out infinite;
}

.demo-score {
  color: var(--primary);
  font-weight: 800;
  font-size: 1.2rem;
}

.demo-click-ring {
  position: absolute;
  left: 43%;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translate(-50%, -50%) scale(0.4);
  border-radius: var(--radius-full);
  border: 2px solid var(--primary);
  opacity: 0;
  pointer-events: none;
  animation: clickRing 3.2s ease-in-out infinite;
}

.demo-cursor {
  position: absolute;
  left: 10%;
  top: 78%;
  width: 28px;
  height: 28px;
  z-index: 2;
  filter: drop-shadow(0 10px 12px rgba(15, 23, 42, 0.22));
  animation: cursorClick 3.2s ease-in-out infinite;
}

.demo-cursor::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--text-main);
  clip-path: polygon(5% 0, 5% 88%, 32% 66%, 48% 100%, 64% 93%, 49% 60%, 86% 60%);
}

.demo-cursor::after {
  content: "";
  position: absolute;
  inset: 2px 3px 5px 3px;
  background: #fff;
  clip-path: polygon(5% 0, 5% 88%, 32% 66%, 48% 100%, 64% 93%, 49% 60%, 86% 60%);
}

.demo-profile {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid rgba(211, 47, 47, 0.22);
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateX(14px) scale(0.97);
  animation: profileReveal 3.2s ease-in-out infinite;
}

.demo-profile strong {
  color: var(--text-main);
  font-size: 1.05rem;
}

.demo-profile span {
  color: var(--text-muted);
  font-size: 0.86rem;
}

.demo-profile-label {
  align-self: flex-start;
  padding: 4px 8px;
  border-radius: var(--radius-full);
  background: #fee2e2;
  color: var(--primary) !important;
  font-size: 0.72rem !important;
  font-weight: 800;
  text-transform: uppercase;
}

.demo-profile-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.demo-profile-meta span {
  padding: 4px 8px;
  border-radius: var(--radius-full);
  background: #f8fafc;
  border: 1px solid var(--border);
}

.demo-profile-stat,
.demo-profile-event {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.demo-profile-stat strong,
.demo-profile-event strong {
  color: var(--primary);
  font-size: 0.95rem;
}

.onboarding-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  border: none;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: #fff;
  padding: 14px 18px;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(211, 47, 47, 0.22);
  transition: background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.onboarding-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 14px 24px rgba(211, 47, 47, 0.24);
}

@keyframes modalEnter {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes namePulse {
  0%, 34%, 100% { opacity: 0; transform: scale(0.94); }
  44%, 72% { opacity: 1; transform: scale(1.02); }
}

@keyframes cursorClick {
  0%, 12% {
    left: 10%;
    top: 78%;
    opacity: 0;
    transform: rotate(-12deg) scale(1);
  }
  22% { opacity: 1; }
  42%, 47% {
    left: 43%;
    top: 50%;
    opacity: 1;
    transform: rotate(-12deg) scale(1);
  }
  52% {
    left: 43%;
    top: 50%;
    opacity: 1;
    transform: rotate(-12deg) scale(0.82);
  }
  60%, 100% {
    left: 43%;
    top: 50%;
    opacity: 1;
    transform: rotate(-12deg) scale(1);
  }
}

@keyframes clickRing {
  0%, 45%, 100% { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
  52% { opacity: 0.9; transform: translate(-50%, -50%) scale(1); }
  68% { opacity: 0; transform: translate(-50%, -50%) scale(2.6); }
}

@keyframes profileReveal {
  0%, 50% { opacity: 0; transform: translateX(14px) scale(0.97); }
  64%, 92% { opacity: 1; transform: translateX(0) scale(1); }
  100% { opacity: 0; transform: translateX(8px) scale(0.98); }
}

@media (prefers-reduced-motion: reduce) {
  .demo-name::after,
  .demo-click-ring,
  .demo-cursor,
  .demo-profile {
    animation: none;
  }

  .demo-name::after {
    opacity: 1;
    transform: scale(1);
  }

  .demo-click-ring {
    display: none;
  }

  .demo-cursor {
    left: 43%;
    top: 50%;
    opacity: 1;
    transform: rotate(-12deg);
  }

  .demo-profile {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 760px) {
  .container { padding: 0 12px; }
  .layout-main { padding: 16px 0 40px; }

  .filter-section { margin-bottom: 20px; }
  .category-header-wrap { gap: 12px; }
  .category-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 8px;
  }
  .category-tabs button {
    width: 100%;
    padding: 11px 8px;
    font-size: 0.92rem;
  }
  .content-grid { gap: 20px; }
  .section-title {
    font-size: 1.4rem;
    margin-bottom: 12px;
  }

  .rules-hero {
    grid-template-columns: 1fr;
    gap: 18px;
    padding: 22px;
  }
  .rules-logo {
    justify-self: start;
    max-width: 210px;
  }
  .rules-summary {
    grid-template-columns: 1fr;
  }
  .rules-intro,
  .rule-item {
    padding: 16px;
  }
  .rule-item {
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 12px;
  }
  .rule-number {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
  }

  .table-card {
    border: none;
    background: transparent;
    box-shadow: none;
    overflow: visible;
  }
  .table-header {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    margin-bottom: 10px;
    padding: 14px 16px;
  }
  .table-title-text { font-size: 1.2rem; }
  .table-wrap {
    height: auto;
    min-height: 0;
    overflow: visible;
  }
  #rankingTable,
  #rankingTable thead,
  #rankingTable tbody,
  #rankingTable tr,
  #rankingTable th,
  #rankingTable td {
    display: block;
    width: 100%;
  }
  #rankingTable thead { display: none; }
  #rankingTable tbody {
    display: grid;
    gap: 12px;
  }
  #rankingTable.is-athletes tbody tr,
  #rankingTable.is-athletes tbody tr:nth-child(even) {
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr) auto;
    grid-template-areas:
      "place name total"
      "events events events"
      "toggle toggle toggle";
    gap: 8px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 14px;
    overflow: hidden;
  }
  #rankingTable.is-clubs tbody tr,
  #rankingTable.is-clubs tbody tr:nth-child(even) {
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr) auto;
    grid-template-areas:
      "place club total";
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 14px;
  }
  #rankingTable tbody tr:hover { background: var(--bg-card); }
  #rankingTable td {
    border: 0;
    padding: 0;
    white-space: normal;
    font-size: 0.9rem;
  }
  #rankingTable td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
  }
  #rankingTable.is-athletes td:nth-child(1) {
    grid-area: place;
    align-self: start;
  }
  #rankingTable.is-athletes td:nth-child(1)::before,
  #rankingTable.is-athletes td:nth-child(2)::before,
  #rankingTable.is-athletes td:nth-child(3)::before,
  #rankingTable.is-athletes td:nth-child(5)::before {
    display: none;
  }
  #rankingTable.is-athletes td:nth-child(1) {
    font-size: 1.45rem;
    line-height: 1.1;
  }
  #rankingTable.is-athletes td:nth-child(2) {
    grid-area: name;
    width: auto;
    min-width: 0;
    max-width: none;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px 7px;
  }
  #rankingTable.is-athletes td:nth-child(2) .athlete-link {
    display: inline;
    font-size: 1.05rem;
    line-height: 1.2;
    text-align: left;
    white-space: normal;
    overflow-wrap: normal;
    word-break: normal;
    hyphens: none;
  }
  #rankingTable.is-athletes .mobile-inline-tags {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
  }
  #rankingTable.is-athletes .mobile-inline-tag {
    font-size: 0.72rem;
    padding: 2px 7px;
  }
  #rankingTable.is-athletes td:nth-child(3),
  #rankingTable.is-athletes td:nth-child(4) {
    display: none;
  }
  #rankingTable.is-athletes td:nth-child(4)::before { display: none; }
  #rankingTable.is-athletes td:nth-child(4).is-single::after {
    content: " wedstrijd";
    font-weight: 500;
  }
  #rankingTable.is-athletes td:nth-child(4).is-multiple::after {
    content: " wedstrijden";
    font-weight: 500;
  }
  #rankingTable.is-athletes td:nth-child(5) {
    grid-area: total;
    align-self: center;
    text-align: right;
    font-size: 1.55rem;
    color: var(--primary);
  }
  #rankingTable.is-athletes td:nth-child(5)::after {
    content: " ptn";
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 700;
    line-height: 1;
  }
  #rankingTable.is-athletes.is-kanben tbody tr,
  #rankingTable.is-athletes.is-kanben tbody tr:nth-child(even) {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "name";
  }
  #rankingTable.is-athletes.is-kanben td:nth-child(1) {
    grid-area: name;
    width: auto;
    min-width: 0;
    max-width: none;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px 7px;
    font-size: 0.9rem;
    line-height: 1.2;
  }
  #rankingTable.is-athletes.is-kanben td:nth-child(1) .athlete-link {
    display: inline;
    font-size: 1.05rem;
    line-height: 1.2;
    text-align: left;
    white-space: normal;
    overflow-wrap: normal;
    word-break: normal;
    hyphens: none;
  }
  #rankingTable.is-athletes.is-kanben td:nth-child(2),
  #rankingTable.is-athletes.is-kanben td:nth-child(3) {
    display: none;
  }
  #rankingTable.is-athletes td:nth-child(n+6):not(.mobile-card-toggle) {
    display: grid;
    grid-template-columns: minmax(82px, 1fr) auto;
    grid-column: 1 / -1;
    gap: 12px;
    align-items: center;
    padding: 8px 0;
    border-top: 1px solid var(--border);
    text-align: right;
  }
  #rankingTable.is-athletes tr:not(.is-expanded) td:nth-child(n+6):not(.mobile-card-toggle) {
    display: none;
  }
  #rankingTable.is-athletes td.mobile-card-toggle {
    display: block;
    grid-area: toggle;
    width: auto;
    padding-top: 8px;
    border-top: 1px solid var(--border);
  }
  #rankingTable.is-athletes td.mobile-card-toggle::before {
    display: none;
  }
  .mobile-card-toggle-button {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 38px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: #f8fafc;
    color: var(--primary);
    font: inherit;
    font-weight: 800;
    cursor: pointer;
  }
  .toggle-arrow {
    width: 16px;
    height: 16px;
    display: block;
    flex: 0 0 16px;
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
    transition: transform 0.18s ease;
  }
  #rankingTable.is-athletes tr.is-expanded .toggle-arrow {
    transform: rotate(180deg);
  }
  #rankingTable.is-athletes tr.is-expanded td.mobile-card-toggle {
    margin-top: -2px;
  }
  #rankingTable.is-athletes td:nth-child(6) {
    margin-top: 6px;
  }
  #rankingTable.is-athletes td:nth-child(n+6):not(.mobile-card-toggle)::before {
    margin: 0;
    font-size: 0.76rem;
    color: var(--text-main);
    text-align: left;
  }

  #rankingTable.is-clubs td:nth-child(1) {
    grid-area: place;
    font-size: 1.35rem;
    line-height: 1;
  }
  #rankingTable.is-clubs td:nth-child(1)::before,
  #rankingTable.is-clubs td:nth-child(2)::before,
  #rankingTable.is-clubs td:nth-child(3)::before {
    display: none;
  }
  #rankingTable.is-clubs td:nth-child(2) {
    grid-area: club;
    font-size: 1.05rem;
    font-weight: 800;
  }
  #rankingTable.is-clubs td:nth-child(3) {
    grid-area: total;
    text-align: right;
    font-size: 1.45rem;
    color: var(--primary);
  }
  #rankingTable.is-clubs td:nth-child(3)::after {
    content: " ptn";
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 700;
    line-height: 1;
  }
  #rankingTable.is-clubs td:nth-child(n+4) {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) auto;
    grid-column: 1 / -1;
    gap: 12px;
    align-items: center;
    padding: 8px 0;
    border-top: 1px solid var(--border);
    text-align: right;
  }
  #rankingTable.is-clubs td:nth-child(4) {
    margin-top: 4px;
  }
  #rankingTable.is-clubs td:nth-child(n+4)::before {
    margin: 0;
    font-size: 0.76rem;
    color: var(--text-main);
    text-align: left;
  }
  #rankingTable.is-clubs td:nth-child(7) {
    overflow-wrap: anywhere;
  }
  .performance { text-align: right; }
}

@media (max-width: 768px) {
  .onboarding-modal { padding: 10px; align-items: end; }
  .onboarding-panel {
    width: 100%;
    max-height: calc(100vh - 20px);
    padding: 22px 16px 14px;
    border-radius: 16px 16px 0 0;
  }
  .onboarding-close {
    top: 10px;
    right: 10px;
  }
  .onboarding-copy {
    padding-right: 40px;
    margin-bottom: 14px;
  }
  .onboarding-copy h2 { font-size: 1.65rem; }
  .onboarding-demo {
    grid-template-columns: 1fr;
    gap: 10px;
    min-height: 0;
    margin: 14px 0;
    padding: 14px;
  }
  .demo-stage { min-height: 98px; }
  .demo-row { padding: 12px; grid-template-columns: 28px minmax(0, 1fr) auto; }
  .demo-cursor { width: 24px; height: 24px; }
  .demo-profile { padding: 16px; }
  .onboarding-primary {
    margin-top: 2px;
  }
  .athlete-profile-card { padding: 24px; }
  .athlete-stats-grid { grid-template-columns: 1fr; }
  .athlete-huge-name { font-size: 2.5rem; }
  .giant-search-input { font-size: 1.25rem; padding: 20px 20px 20px 52px; }
  .page-title { font-size: 2.25rem; }
  .search-results-grid { grid-template-columns: 1fr; }
}
