:root {
  color-scheme: light;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #edf1f9;
  --border: #dbe2ef;
  --text: #1b2130;
  --muted: #55607a;
  --accent: #4f46e5;
  --accent-2: #7c3aed;
  --accent-soft: #eceeff;
  --yt: #c0392b;
  --yt-hover: #e74c3c;
  --mark: #fde68a;
  --c-basic: #4f46e5;
  --c-rules: #0d9488;
  --c-history: #d97706;
  --c-sources: #2563eb;
  --c-links: #db2777;
  --header-grad:
      radial-gradient(circle at 14% 130%, rgba(124, 58, 237, 0.13), transparent 45%),
      radial-gradient(circle at 86% -25%, rgba(79, 70, 229, 0.15), transparent 50%),
      radial-gradient(circle at 72% 125%, rgba(13, 148, 136, 0.09), transparent 42%),
      linear-gradient(135deg, #eef1fd 0%, #f7f3fe 55%, #fdf6f0 100%);
  --header-border: #dfe3f3;
  --shadow: 0 6px 18px rgba(30, 41, 82, 0.08);
}

[data-theme="dark"] {
  color-scheme: dark;
  /* dark, but not pitch black: soft dark slate blue */
  --bg: #232937;
  --surface: #2c3347;
  --surface-2: #333b52;
  --border: #414a66;
  --text: #eef1f8;          /* high contrast for readability */
  --muted: #aab3c9;
  --accent: #9aa6ff;
  --accent-2: #c4b5fd;
  --accent-soft: #39415c;
  --yt: #e0604f;
  --yt-hover: #f07a6a;
  --mark: #7a6420;
  --c-basic: #a5b0ff;
  --c-rules: #5eead4;
  --c-history: #fcd34d;
  --c-sources: #93c5fd;
  --c-links: #f9a8d4;
  --header-grad:
      radial-gradient(circle at 14% 130%, rgba(154, 166, 255, 0.10), transparent 45%),
      radial-gradient(circle at 86% -25%, rgba(196, 181, 253, 0.12), transparent 50%),
      linear-gradient(135deg, #262d3e 0%, #2a2f49 100%);
  --header-border: #3a4258;
  --shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;              /* one step larger for readability */
  line-height: 1.7;
  transition: background-color 0.25s ease, color 0.25s ease;
}

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 20px; }

.site-header {
  background: var(--header-grad);
  border-bottom: 1px solid var(--header-border);
  padding: 32px 0;
}

.header-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }

.brand {
  font-size: 31px;
  font-weight: 800;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}
a.brand:hover { color: var(--accent); }

.subtitle { color: var(--muted); margin-top: 4px; font-size: 15px; }

.stats-line { color: var(--muted); font-size: 13px; margin: 4px 0 0; }

.header-actions { display: flex; align-items: center; gap: 10px; }

.theme-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 19px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  transition: transform 0.15s, background 0.15s, border-color 0.15s;
}
.theme-btn:hover { border-color: var(--accent); transform: scale(1.08); }

.btn {
  display: inline-block;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, color 0.15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }

.share-wrap { position: relative; display: inline-block; }

.share-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 170px;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 60;
}
.share-menu a,
.share-menu .share-copy {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border: none;
  background: none;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  text-decoration: none;
  border-radius: 6px;
  cursor: pointer;
}
.share-menu a:hover,
.share-menu .share-copy:hover { background: var(--accent-soft); color: var(--accent); }

@media (max-width: 640px) {
  .share-menu { right: auto; left: 0; }
}

.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 22px 0 14px;
}

.search-wrap { flex: 1; min-width: 200px; max-width: 440px; }

#searchInput {
  width: 100%;
  padding: 10px 15px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#searchInput:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

#resultCount { color: var(--muted); font-size: 14px; }

.badge {
  margin-left: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
.badge strong { color: var(--accent); }

.reset-filters {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.reset-filters:hover { color: var(--accent-2); }

.alpha-bar { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 14px; }

.tag-bar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }

.tag-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  padding: 5px 12px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.tag-chip:hover { border-color: var(--accent); color: var(--accent); }
.tag-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }

.alpha-bar button {
  width: 28px;
  height: 26px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.12s;
}
.alpha-bar button:hover { border-color: var(--accent); color: var(--accent); }
.alpha-bar button.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.alpha-bar button:disabled { opacity: 0.3; cursor: default; }
.alpha-bar button:disabled:hover { border-color: var(--border); color: var(--text); }

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow-x: auto;
  margin-bottom: 40px;
  box-shadow: var(--shadow);
}

table { width: 100%; border-collapse: collapse; }

thead th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
thead th.num, thead th.yt { text-align: center; }

tbody tr { border-bottom: 1px solid var(--border); transition: background 0.1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--accent-soft); }
tbody tr.hidden { display: none; }

td { padding: 10px 14px; vertical-align: top; font-size: 15px; }
td.num { color: var(--muted); font-size: 12px; text-align: center; width: 44px; }
td.sport-name { font-weight: 700; font-size: 16px; width: auto; white-space: nowrap; }
td.sport-name a { color: var(--text); text-decoration: none; }
td.sport-name a:hover { color: var(--accent); text-decoration: underline; }
td.desc { color: var(--muted); }
td.yt { text-align: center; width: 56px; }

td.yt a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 26px;
  background: var(--yt);
  color: #fff;
  font-size: 11px;
  border-radius: 6px;
  text-decoration: none;
  transition: background 0.15s, transform 0.1s;
}
td.yt a:hover { background: var(--yt-hover); transform: scale(1.1); }

mark { background: var(--mark); color: inherit; border-radius: 2px; padding: 0 1px; }

#noResults { display: none; text-align: center; padding: 60px 20px; color: var(--muted); }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 8px 0;
  z-index: 100;
  font-weight: 700;
}
.skip-link:focus { left: 0; }

.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transform-origin: 0 0;
  transform: scaleX(0);
  z-index: 90;
  pointer-events: none;
}

.to-top {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  box-shadow: var(--shadow);
  z-index: 80;
  transition: border-color 0.15s, color 0.15s;
}
.to-top:hover { border-color: var(--accent); color: var(--accent); }
.to-top[hidden] { display: none; }

/* ---------- detail pages ---------- */

.page { padding: 34px 20px 52px; max-width: 880px; overflow-wrap: break-word; }

.page h1 { font-size: 37px; letter-spacing: -0.02em; margin-bottom: 6px; }

.toc { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0 26px; }

.page-meta { color: var(--muted); font-size: 14px; margin: 0 0 18px; }


.toc.pin {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg);
  margin: 0;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}
.toc a {
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 6px 13px;
  border-radius: 999px;
  border-left-width: 5px;
}
.toc a:hover { background: var(--accent-soft); }
.toc a[href="#basic-information"] { color: var(--c-basic); border-left-color: var(--c-basic); }
.toc a[href="#rules"] { color: var(--c-rules); border-left-color: var(--c-rules); }
.toc a[href="#history"] { color: var(--c-history); border-left-color: var(--c-history); }
.toc a[href="#sources"] { color: var(--c-sources); border-left-color: var(--c-sources); }
.toc a[href="#important-links"] { color: var(--c-links); border-left-color: var(--c-links); }

.page section { scroll-margin-top: 64px; }

.page section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px 26px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.page section h2 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 9px;
  padding-left: 12px;
  border-left: 6px solid var(--accent);
}
.page { counter-reset: h2section; }
.copy-anchor {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  margin-left: 2px;
  font-size: 12px;
  text-transform: none;
  letter-spacing: 0;
  vertical-align: middle;
  color: var(--text);
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}
.page section h2:hover .copy-anchor,
.copy-anchor:focus-visible { opacity: 0.45; }
.copy-anchor:hover { opacity: 1; }
.copy-anchor.copied { color: var(--c-rules); opacity: 1; }
.page section h2::before {
  counter-increment: h2section;
  content: counter(h2section);
  display: inline-block;
  width: 22px;
  height: 22px;
  line-height: 22px;
  text-align: center;
  margin-right: 9px;
  border-radius: 50%;
  background: currentColor;
  color: var(--surface);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}
#basic-information h2 { color: var(--c-basic); border-left-color: var(--c-basic); }
#rules h2 { color: var(--c-rules); border-left-color: var(--c-rules); }
#history h2 { color: var(--c-history); border-left-color: var(--c-history); }
#sources h2 { color: var(--c-sources); border-left-color: var(--c-sources); }
#important-links h2 { color: var(--c-links); border-left-color: var(--c-links); }

.page section p {
  margin-bottom: 11px;
  text-align: justify;
  -webkit-hyphens: auto;
  hyphens: auto;
}
.page section p:last-child { margin-bottom: 0; }
.page section ul, .page section ol { margin: 0 0 11px 22px; }
.page section li { margin-bottom: 7px; }
.page section h3 { font-size: 18px; margin: 14px 0 8px; }
.page a { color: var(--accent); }
.page a:hover { color: var(--accent-2); }
.page img { max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: 10px; margin: 10px 0; background: var(--surface-2); }
.page img { box-shadow: var(--shadow); }
.page img { cursor: zoom-in; }

body.no-scroll { overflow: hidden; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(10, 12, 20, 0.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 20px;
  cursor: zoom-out;
}
.lightbox[hidden] { display: none; }
.lightbox img {
  max-height: calc(100vh - 110px);
  max-width: 96vw;
  width: auto;
  height: auto;
  border: none;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  cursor: zoom-out;
}
.lightbox-caption { color: #dfe3f3; font-size: 14px; text-align: center; max-width: 92vw; }

.img-pair { margin: 12px 0; min-width: 0; max-width: 100%; }
.img-pair img { margin: 0 0 6px; max-width: 100%; height: auto; }
.img-pair em { display: block; font-size: 13px; color: var(--muted); line-height: 1.5; }

#sources ul { list-style: none; margin-left: 0; }
#sources li { padding-left: 1.4em; text-indent: -1.4em; }

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 18px 0;
  font-size: 13px;
  color: var(--muted);
}
.footer-row { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--accent); }

@media (max-width: 640px) {
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body { font-size: 16px; }
  .site-header { padding: 20px 0; }
  .brand { font-size: 25px; }
  .controls { gap: 8px; }
  .controls .badge { font-size: 12px; padding: 4px 10px; }
  #searchInput { padding: 9px 12px; font-size: 15px; }

  .table-wrap { border-radius: 10px; }
  table { border-collapse: separate; }
  thead th { font-size: 10.5px; padding: 8px 8px; }
  td { padding: 8px; font-size: 13.5px; }
  td.num { width: 26px; font-size: 11px; }
  td.sport-name { white-space: normal; font-size: 14.5px; }
  td.sport-name .name-text { overflow-wrap: anywhere; }
  td.desc { font-size: 12.5px; line-height: 1.45; }
  td.yt { width: 40px; }
  td.yt a { width: 28px; height: 24px; font-size: 10px; }

  .page { padding: 24px 12px 40px; }
  .page h1 { font-size: 24px; line-height: 1.2; letter-spacing: normal; overflow-wrap: anywhere; }
  .page section { padding: 16px 14px; border-radius: 10px; }
  .page section h2 { letter-spacing: 0.04em; }
  .page section p { text-align: left; }

  .header-actions { width: 100%; }
  .tag-bar { gap: 5px; }
  .tag-chip { font-size: 12px; padding: 4px 10px; }
  .alpha-bar { gap: 3px; }
  .alpha-bar button { padding: 5px 8px; font-size: 13px; }
  .toc { gap: 6px; }
  .toc a { font-size: 12.5px; padding: 5px 10px; border-left-width: 4px; }
  .share-menu { min-width: 150px; }
  .footer-row { font-size: 13px; }
}

h1, h2, h3, .brand {
  font-family: "Bricolage Grotesque", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media print {
  .site-header .header-actions,
  .theme-btn,
  .controls,
  .alpha-bar,
  .tag-bar,
  .toc,
  .site-footer,
  .skip-link,
  .progress-bar,
  .to-top,
  .copy-anchor,
  .share-wrap,
  .lightbox { display: none !important; }
  body { background: #fff; color: #000; font-size: 12pt; }
  .page section {
    background: #fff;
    border-color: #bbb;
    box-shadow: none;
    break-inside: avoid;
  }
  .page img { break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
}
