/* === Base layout === */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: system-ui, sans-serif;
  background: #fff;
}

/* Sticky header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: #111827;
  color: #e5e7eb;
}

/* Inner layout */
.site-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

/* Brand */
.brand-link {
  color: #f9fafb;
  font-weight: 600;
  text-decoration: none;
}

/* Main nav list */
.main-nav ul {
  list-style: none;
  display: flex;
  gap: 0.75rem;
  padding: 0;
  margin: 0;
}

/* Nav links */
.nav-link {
  color: #e5e7eb;
  text-decoration: none;
  font-size: 0.95rem;
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
}

.nav-link:hover {
  background: #1f2937;
}

.nav-link-active {
  background: #2563eb;
  color: #f9fafb;
}

/* Right side (login/logout) */
.nav-right {
  display: flex;
  gap: 0.5rem;
}

/* Admin subnav */
.admin-subnav {
  border-top: 1px solid #1f2937;
  background: #0f172a;
}

.admin-subnav ul {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.25rem 1rem;
  list-style: none;
  display: flex;
  gap: 0.5rem;
}

.trainer-subnav {
  border-top: 1px solid #1f2937;
  background: #0f172a;
}

.trainer-subnav ul {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.25rem 1rem;
  list-style: none;
  display: flex;
  gap: 0.5rem;
}

.subnav-link {
  color: #9ca3af;
  text-decoration: none;
  font-size: 0.85rem;
  padding: 0.2rem 0.5rem;
  border-radius: 0.375rem;
}

.subnav-link:hover {
  background: #111827;
  color: #e5e7eb;
}

.subnav-link.nav-link-active {
  background: #374151;
  color: #f9fafb;
}

/* Mobile: hamburger */
.nav-toggle {
  display: none;
}

.nav-toggle-label {
  display: none;
  cursor: pointer;
}

/* Burger icon bars */
.nav-toggle-label span,
.nav-toggle-label span::before,
.nav-toggle-label span::after {
  display: block;
  background: #e5e7eb;
  height: 2px;
  width: 22px;
  border-radius: 999px;
  position: relative;
}

.nav-toggle-label span::before,
.nav-toggle-label span::after {
  content: "";
  position: absolute;
  left: 0;
}

.nav-toggle-label span::before {
  top: -6px;
}

.nav-toggle-label span::after {
  top: 6px;
}

/* Mobile layout */
@media (max-width: 768px) {
  .site-header-inner {
    flex-wrap: wrap;
  }

  .main-nav {
    width: 100%;
    order: 2;
  }

  .main-nav ul {
    flex-direction: column;
    align-items: flex-start;
    margin-top: 0.5rem;
    display: none; /* hidden by default on mobile */
    background: #111827;      /* match .site-header */
  }

  .nav-right {
    order: 1;
  }

  .nav-toggle-label {
    display: block;
  }

  /* Show menu when checkbox is checked */
  .nav-toggle:checked ~ .main-nav ul {
    display: flex;
  }
}

/* Constrain main page content */
.container {
  max-width: 900px;
  margin: 2rem auto;
  padding: 6rem 1rem 2rem;
}

.card{border:1px solid #e5e7eb;background:#f9fafb;padding:1rem;margin-top:1rem}

/* Buttons */
.btn {
  display: inline-block;
  padding: .6rem .9rem;
  border: 1px solid #e5e7eb;
  border-radius: .5rem;
  text-decoration: none;
  color: inherit;
}

/* Headings / spacing */
h1, h2, h3 {
  margin: 0 0 .75rem;
  line-height: 1.2;
}

p { margin: .5rem 0; }

/* Simple tables */
table {
  border-collapse: collapse;
  width: 100%;
  margin: 1rem 0;
}
th, td {
  border: 1px solid #e5e7eb;
  padding: .5rem;
  text-align: left;
}

/* Info / error boxes */
.alert-ok {
  padding: .6rem;
  background: #ecfdf5;
  border: 1px solid #bbf7d0;
  margin-bottom: 1rem;
}
.alert-err {
  padding: .6rem;
  background: #fff5f5;
  border: 1px solid #fecaca;
  margin-bottom: 1rem;
}

/* Simple forms */
form { display: grid; gap: .6rem; }
input, button, select {
  padding: .5rem;
  font-size: 1rem;
}

/* === Events tables === */
.events-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.95rem;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  overflow: hidden; /* keeps rounded corners on header/rows */
}

.events-table th {
  background: #f3f4f6;
  text-align: left;
  padding: .6rem .75rem;
  font-weight: 600;
  border-bottom: 1px solid #e5e7eb;
}

.events-table td {
  padding: .6rem .75rem;
  border-bottom: 1px solid #f1f5f9;
}

.events-table tr:nth-child(even) td:not(.pt-highlight) {
  background: #fafafa;
}

.events-table tr:hover td {
  background: #eef2ff;
}

/* 2-column layout (public: Date + Title) */
table.events-table th:first-child,
table.events-table td:first-child {
  width: 130px;           /* fixed date column width */
  white-space: nowrap;
}
table.events-table th:nth-child(2),
table.events-table td:nth-child(2) {
  width: auto;            /* title fills remaining */
}

/* 3-column layout (admin: Date + Title + Actions) */
table.events-table th:nth-child(3),
table.events-table td:nth-child(3) {
  width: 120px;           /* actions column width */
  text-align: center;     /* looks cleaner */
}
/* 3-column layout (admin: Date + Title + Actions) */
table.events-table th:nth-child(4),
table.events-table td:nth-child(4) {
  width: 120px;           /* actions column width */
  text-align: center;     /* looks cleaner */
}

table.events-table td form button {
  padding: .35rem .65rem;
  font-size: .85rem;
  white-space: nowrap;
}

/* badges */
.badge {
  display:inline-block; font-size:.8rem; padding:.15rem .45rem;
  border:1px solid #e5e7eb; border-radius:.5rem; vertical-align:middle;
  margin-left: .4rem; 
}
.badge-registered { background:#ecfdf5; border-color:#bbf7d0; }
.badge-played { background:#eff6ff; border-color:#bfdbfe; } /* soft blue */

/* Stats */
.stats-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
      gap: 0.75rem;
      margin: 1rem 0 1.5rem;
    }
    .stat-card {
      border: 1px solid #e5e7eb;
      border-radius: 0.75rem;
      padding: 0.75rem 0.9rem;
      background: #f9fafb;
    }
    .stat-label {
      font-size: 0.8rem;
      color: #6b7280;
      margin-bottom: 0.2rem;
    }
    .stat-value {
      font-weight: 600;
      font-size: 1.1rem;
    }
    .stat-sub {
      font-size: 0.8rem;
      color: #6b7280;
      margin-top: 0.1rem;
    }
    .stat-bar {
      margin-top: 0.5rem;
      background: #e5e7eb;
      border-radius: 999px;
      height: 8px;
      overflow: hidden;
    }
    .stat-bar-inner {
      height: 100%;
      background: #f97316; /* paid in */
    }
    .stat-bar-inner.win {
      background: #16a34a; /* winnings */
    }
    .profit-positive { color: #16a34a; }
    .profit-negative { color: #b91c1c; }

    /* Achievements */
    .profile-card {
      border: 1px solid #e5e7eb;
      border-radius: 0.75rem;
      padding: 0.75rem 1rem;
      background: #f9fafb;
      margin-bottom: 1rem;
    }
    .achievements-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
      gap: 0.75rem;
      margin-top: 1rem;
    }
    .season-card {
      border: 1px solid #e5e7eb;
      border-radius: 0.75rem;
      padding: 0.75rem 0.9rem;
      background: #ffffff;
    }
    .season-title {
      font-weight: 600;
      margin-bottom: 0.25rem;
    }
    .season-meta {
      font-size: 0.8rem;
      color: #6b7280;
      margin-bottom: 0.35rem;
    }
    .ach-chips {
      display: flex;
      flex-wrap: wrap;
      gap: 0.25rem;
      margin-top: 0.25rem;
    }
    .ach-chip {
      font-size: 0.75rem;
      border-radius: 999px;
      padding: 0.15rem 0.5rem;
      border: 1px solid #e5e7eb;
      background: #f3f4f6;
      white-space: nowrap;
    }
    .ach-chip-icon {
  margin-right: 0.25rem;
  font-size: 0.9em;
}
    .ach-empty {
      font-size: 0.8rem;
      color: #9ca3af;
      margin-top: 0.25rem;
    }

  .home-hero {
    background: #f8fafc;
    padding: 2.5rem 1.5rem;
    border-radius: 1rem;
    margin-bottom: 2rem;
  }
  .home-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    margin-top: 1.5rem;
  }
  .btn-big {
    padding: .7rem 1.1rem;
    font-size: 1rem;
    border-radius: .5rem;
  }

    .rules-box {
      background: #f9fafb;
      border: 1px solid #e5e7eb;
      border-radius: .75rem;
      padding: 1.25rem 1.5rem;
      margin-bottom: 1.5rem;
    }

/* === Leaderboard layout: two tables side by side === */

/* Outer wrapper: names + scores */
.lb-wrapper {
  display: flex;
  align-items: stretch;
  gap: 0.1rem;
  margin-top: 1rem;
}

/* Left: player names (fixed) */
.lb-names {
  flex: 0 0 auto;
}

.lb-names-table {
  border-collapse: collapse;
  border-spacing: 0;
}

/* Override global first-column width so it auto-sizes to longest name */
.lb-names-table th:first-child,
.lb-names-table td:first-child {
  width: auto;
}

/* Keep names on a single line */
.lb-names-table th,
.lb-names-table td {
  white-space: nowrap;
  text-align: left;
}

/* Right: scrollable scores */
.lb-scroll {
  flex: 1 1 auto;
  overflow-x: auto;
  padding-left: 0;
  margin-left: 0;
}

/* Inner wrapper for scores table */
.lb-table {
  min-width: 0;
}

/* Scores table */
.lb-scores-table {
  width: 100%;
  min-width: 720px;      /* keeps the wide layout so we get horizontal scroll */
  border-collapse: collapse;
  margin-left: 0;
  border-spacing: 0;
}

/* Per-cell / point formatting */
.pt-cell {
  text-align: center;
  white-space: nowrap;
}

.pt-bonus {
  background: #f1ffed;
  border-radius: .35rem;
  padding: .1rem .35rem;
  display: inline-block;
  margin-left: .3rem;
  font-size: .8rem;
  border: 1px solid #fed7aa;
}

.pt-highlight {
  background: #fffbeb; /* cell highlight when bonus>0 */
}

.col-total {
  font-weight: 600;
  text-align: right;
}

/* Key chips */
.key {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin: .5rem 0;
}

.key .chip {
  border: 1px solid #e5e7eb;
  border-radius: .5rem;
  padding: .2rem .5rem;
}

/* Make event headers centered and allow wrapping */
.lb-scores-table th.lb-header {
  text-align: center;
  vertical-align: middle;
  padding: .6rem .5rem;
  white-space: normal;
  font-weight: 600;
}

/* MOBILE: ensure scores table can scroll horizontally */
@media (max-width: 768px) {
  .lb-scores-table {
    min-width: 700px;
  }
}

/* DESKTOP: widen the leaderboard content area */
.container-leaderboard {
  max-width: 1300px;    /* wider than default 900px */
  margin: 2rem auto;
  padding: 6rem 1rem 2rem;
}

.lb-names-table tr,
.lb-scores-table tr {
  height: auto;           /* allow JS to override */
}

.lb-names-table th,
.lb-names-table td,
.lb-scores-table th,
.lb-scores-table td {
  padding: .5rem .5rem;
  vertical-align: middle;
}

/* Line between qualifying players and the rest */
.lb-names-table tr.lb-cut,
.lb-scores-table tr.lb-cut {
  border-top: 2px solid #2563eb;  /* blue line; tweak to taste */
}

/* Light background for qualifying players */
.lb-names-table tbody tr:nth-child(-n+var(--qual-top-n)),
.lb-scores-table tbody tr:nth-child(-n+var(--qual-top-n)) {
  background: #eff6ff;
}

.lb-header-players {
  font-size: 0.75rem;
  color: #6b7280;      /* soft gray */
  margin-top: 0.15rem;
  white-space: nowrap; /* keep on one line if possible */
}

/* Card suit colours */
.card-heart,
.card-diamond {
  color: #dc2626;   /* nice red */
}

.card-spade,
.card-club {
  color: #111827;   /* dark (almost black) */
}

.card {
  display:inline-block;
  padding:2px 6px;
  border-radius:6px;
  border:1px solid #e5e7eb;
  margin-right:3px;
  font-weight:600;
}
.card-full {
  width: 100%;
}
.vs-wrapper {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}
.vs-players {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1rem;
}

.vs-player {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: .75rem;
  padding: .75rem 1rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.vs-player h3 {
  margin-bottom: .75rem;
}

.vs-cards {
  display: flex;
  justify-content: center;
  gap: .4rem;
  font-size: 1.15rem;
  font-weight: 600;
}

/* VS badge – fixed size circle */
.vs-badge {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;

  font-weight: 800;
  font-size: .9rem;
  letter-spacing: .08em;

  background: #111827;
  color: #fff;

  /* prevent it stretching */
  justify-self: center;
  align-self: center;
  flex: 0 0 auto;
}

/* Mobile */
@media (max-width: 640px) {
  .vs-wrapper {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .vs-badge {
    margin: 0 auto;
  }
}