/* ── Design tokens — dark (default) ─────────────────────────────────────────── */
:root {
  --bg:           #14161c;
  --bg-surface:   #1b1e27;
  --bg-elevated:  #262a37;
  --bg-hover:     #313648;
  --border:       rgba(255,255,255,.08);
  --border-acc:   rgba(255,138,61,.35);

  --accent:       #ff8a3d;
  --accent-dim:   #d96f2c;
  --accent-glow:  rgba(255,138,61,.18);
  --accent-ink:   #201005;
  --text:         #eef0f4;
  --text-dim:     #aab0c4;
  --text-muted:   #7a8098;
  --up:           #33c17a;
  --down:         #ff4d5e;
  --new:          #8b7bff;

  --header-top:   #1c1f28;
  --header-shadow:rgba(0,0,0,.6);
  --logo-sub:     #aab0c4;

  --header-h:    68px;
  --sidebar-w:   190px;
  --radius:      10px;
  --radius-sm:   6px;
  --font-sans:   'Nunito Sans', system-ui, sans-serif;
  --font-display:'Baloo 2', 'Nunito Sans', sans-serif;
}

/* ── Design tokens — light ───────────────────────────────────────────────────── */
[data-theme="light"] {
  --bg:           #faf6ee;
  --bg-surface:   #ffffff;
  --bg-elevated:  #f2ecdd;
  --bg-hover:     #eae1cb;
  --border:       rgba(30,20,10,.10);
  --border-acc:   rgba(191,79,17,.35);

  --accent:       #d9591c;
  --accent-dim:   #b84a15;
  --accent-glow:  rgba(217,89,28,.14);
  --accent-ink:   #ffffff;
  --text:         #221f1a;
  --text-dim:     #55524a;
  --text-muted:   #86816f;
  --up:           #1f8f52;
  --down:         #d1293b;
  --new:          #5b4bd1;

  --header-top:   #ffffff;
  --header-shadow:rgba(30,20,10,.10);
  --logo-sub:     #55524a;
}

/* ── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html {
  scroll-behavior: smooth;
  transition: background-color .25s, color .25s;
}
html.no-transition, html.no-transition * { transition: none !important; }

body {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; font-weight: 700; }
a:hover { color: var(--accent-dim); text-decoration: none; }

/* ── Header ─────────────────────────────────────────────────────────────────── */
#header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--header-top);
  border-bottom: 3px solid var(--accent);
  box-shadow: 0 4px 20px var(--header-shadow);
}

.header-inner {
  max-width: 1120px;
  margin: 0 auto;
  height: 100%;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Logo */
.logo a { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.logo-tag {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 1px;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  text-transform: uppercase;
  line-height: 1.4;
}
.logo-main {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 19px;
  letter-spacing: 0.3px;
  color: var(--accent);
  text-transform: uppercase;
  line-height: 1;
  white-space: nowrap;
  -webkit-text-stroke: 0.4px var(--accent-dim);
}

/* Search */
.search-form {
  display: flex;
  align-items: center;
  gap: 8px;
  /* Narrower than it wants to be, and the only item in the row allowed to
     shrink: the nav and the BGG badge are rigid, so pressure from a narrower
     viewport is absorbed here rather than overflowing the header */
  flex: 1 1 0;
  min-width: 0;
  max-width: 240px;
}
.search-form input {
  flex: 1;
  height: 34px;
  font-size: 13px;
  font-weight: 600;
  padding: 0 12px;
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  transition: border-color .2s;
}
.search-form input:focus { border-color: var(--accent); }
.search-form input::placeholder { color: var(--text-muted); font-weight: 600; }
.search-form button {
  height: 34px;
  width: 34px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--accent-ink);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s;
}
.search-form button:hover { background: var(--accent-dim); }

/* Nav */
.main-nav {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 2px;
  white-space: nowrap;
}
.main-nav a {
  color: var(--text-dim);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: color .2s, background .2s;
}
.main-nav a:hover { color: var(--accent-ink); background: var(--accent); }
.main-nav .sep { color: var(--border-acc); padding: 0 2px; }

.nav-dropdown { position: relative; }
.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 0;
  min-width: 180px;
  z-index: 200;
  box-shadow: 0 10px 28px var(--header-shadow);
}
.nav-dropdown:hover .nav-dropdown-menu { display: block; }
.nav-dropdown-menu a {
  display: block;
  padding: 8px 14px;
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.3px;
  white-space: nowrap;
  border-radius: 0;
}
.nav-dropdown-menu a:hover { background: var(--bg-hover); color: var(--accent); }
.nav-dropdown-menu a.filter-active { color: var(--accent); font-weight: 800; }

#theme-toggle {
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 15px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color .2s, color .2s;
  flex-shrink: 0;
}
#theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* Powered by BGG — in the sticky header as well as the footer, so the
   attribution stays on screen while scrolling a 500-row list */
.header-bgg-logo-link {
  margin-left: auto;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  opacity: 0.85;
  transition: opacity .2s;
}
.header-bgg-logo-link:hover { opacity: 1; }
.header-bgg-logo { height: 22px; width: auto; display: block; }

/* ── Page body ───────────────────────────────────────────────────────────────── */
#page-body {
  max-width: 1120px;
  margin: 20px auto;
  padding: 0 20px;
}

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--sidebar-w);
  gap: 16px;
  align-items: start;
}

/* ── Sidebars ────────────────────────────────────────────────────────────────── */
.sidebar-left,
.sidebar-right {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.thumb-wrap {
  text-align: center;
}
.thumb-img {
  width: 100%;
  max-width: 190px;
  border-radius: var(--radius);
  display: block;
  margin: 0 auto;
  border: 3px solid var(--border);
  box-shadow: 0 6px 18px rgba(0,0,0,.25);
}

.sidebar-section {
  background: var(--bg-surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: 0 3px 10px rgba(0,0,0,.08);
}

.sidebar-section h3 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 3px solid var(--border-acc);
}

.sidebar-sub {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
  margin: 10px 0 4px;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.stats-table tr + tr td,
.stats-table tr + tr th {
  border-top: 1px solid var(--border);
}
.stats-table th {
  text-align: left;
  padding: 5px 6px 5px 0;
  color: var(--text-dim);
  font-weight: 600;
}
.stats-table td {
  text-align: right;
  padding: 5px 0 5px 6px;
  color: var(--text);
  white-space: nowrap;
}
/* Free-text cells (designers, publishers): the nowrap above suits dates and
   numbers, but a game with fifteen publishers has to be allowed to wrap */
.stats-table td.cell-names {
  white-space: normal;
  text-align: left;
  overflow-wrap: anywhere;
  line-height: 1.5;
}
.stats-table td.cell-names .sidebar-more-btn { margin-top: 5px; }

.stats-table strong { color: var(--accent); font-weight: 800; }
.stats-table a { color: var(--text-dim); font-weight: 600; }
.stats-table a:hover { color: var(--accent); }

.no-stats {
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 0;
  font-style: italic;
}

.sidebar-more-btn {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 5px 0;
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-sans);
  letter-spacing: 0.3px;
  cursor: pointer;
  text-align: center;
  transition: color .2s, border-color .2s;
}
.sidebar-more-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ── Chart ──────────────────────────────────────────────────────────────────── */
.rank-chart-wrap {
  padding: 16px 20px 8px;
  border-bottom: 1px solid var(--border);
}

/* ── Main content area ───────────────────────────────────────────────────────── */
.main-content {
  background: var(--bg-surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 500px;
  box-shadow: 0 4px 16px rgba(0,0,0,.10);
}

/* ── Snapshot header ─────────────────────────────────────────────────────────── */
.snapshot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 16px;
  border-bottom: 3px solid var(--border-acc);
  background: linear-gradient(135deg, var(--bg-elevated) 0%, var(--bg-surface) 100%);
}

.snapshot-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 24px;
  color: var(--text);
  letter-spacing: 0.3px;
}
.snapshot-title .year {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-dim);
  margin-left: 8px;
}

/* Date nav */
.date-nav { display: flex; gap: 6px; align-items: center; }
.date-nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  transition: all .2s;
}
.date-nav-btn:hover {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.date-nav-btn.disabled { opacity: .25; cursor: default; pointer-events: none; }

.bgg-link-large {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 4px;
}
.bgg-link-large:hover { color: var(--accent); }

.show-all-btn {
  display: block;
  margin: 10px auto 0;
  padding: 7px 18px;
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 700;
  cursor: pointer;
  font-size: 0.85rem;
}
.show-all-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Ranked table ─────────────────────────────────────────────────────────── */
.top250-table {
  width: 100%;
  border-collapse: collapse;
}

.top250-table thead th {
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 11px 10px;
  border-bottom: 2px solid var(--border);
  text-align: left;
}

.top250-table tbody td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.top250-table tbody tr { transition: background .15s; }
.top250-table tbody tr:hover { background: var(--bg-hover) !important; }
.top250-table tbody tr:last-child td { border-bottom: none; }

.row-norm { background: var(--bg-surface); }
.row-alt  { background: var(--bg-elevated); }
.row-new  { background: rgba(139,123,255,.08); }

/* Column widths */
.col-rank   { width: 52px;  text-align: center; }
.col-change { width: 40px;  text-align: center; }
.col-rating { width: 64px;  text-align: center; }
.col-title  { }
.col-votes  { width: 100px; text-align: right; }
.col-links  { width: 56px;  text-align: center; }
/* Wide enough that a nowrap date cannot spill into the next column */
.col-date   { width: 108px; white-space: nowrap; }

/* Sortable table headers */
.top250-table thead th.sorted { color: var(--accent); }
.sort-link {
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}
.sort-link:hover { color: var(--accent); }
.sort-arrow { display: inline-block; width: 10px; text-align: right; }

.col-date a { color: var(--text-dim); font-size: 12px; }
.col-date a:hover { color: var(--accent); }
.date-note { color: var(--text-muted); font-size: 12px; }

.table-note {
  margin-top: 14px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.6;
}

.col-rank b {
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--text-dim);
  font-weight: 700;
}

.col-rating {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.3px;
}
.rating-up   { color: var(--up)   !important; }
.rating-down { color: var(--down) !important; }

.col-title a {
  color: var(--text);
  font-weight: 800;
  font-size: 13px;
  transition: color .15s;
}
.col-title a:hover { color: var(--accent); }
.col-title .year {
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  margin-left: 6px;
}

.col-votes { color: var(--text-muted); font-size: 12px; font-weight: 700; }

/* Change indicators — bold filled badges */
.change-up, .change-down, .change-same, .change-new {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
  padding: 2px 6px;
  border-radius: 999px;
  line-height: 1.6;
}
.change-up   { color: #fff; background: var(--up); }
.change-down { color: #fff; background: var(--down); }
.change-new  { color: #fff; background: var(--new); font-size: 12px; }
.change-same { color: var(--text-muted); background: transparent; }

/* "no longer in the list" marker in sidebar lists */
.tag-gone {
  color: var(--text-muted);
  font-size: 10px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-left: 5px;
}

/* BGG link badge */
.bgg-link {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--accent-ink);
  background: var(--accent);
  padding: 3px 8px;
  border-radius: 999px;
  transition: background .2s;
}
.bgg-link:hover { background: var(--accent-dim); color: var(--accent-ink); }

.empty {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-style: italic;
}

/* ── History table ──────────────────────────────────────────────────────────── */
.history-table {
  width: 100%;
  border-collapse: collapse;
}
.history-table thead th {
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 11px 16px;
  border-bottom: 2px solid var(--border);
  text-align: left;
}
.history-table tbody td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.history-table tbody tr:hover { background: var(--bg-hover); }
.history-table tbody tr:last-child td { border-bottom: none; }
.view-link { font-size: 12px; font-weight: 700; color: var(--text-muted); }
.view-link:hover { color: var(--accent); }

/* ── No data page ────────────────────────────────────────────────────────────── */
.no-data-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  text-align: center;
  padding: 60px 40px;
}
.no-data-page h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 30px;
  color: var(--text-dim);
  letter-spacing: 0.5px;
  margin-bottom: 16px;
}
.no-data-page p { color: var(--text-muted); margin-bottom: 20px; font-size: 14px; }
.no-data-page code {
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  color: var(--accent-dim);
  font-size: 12px;
}

/* ── Section headings within main content ────────────────────────────────────── */
.section-heading {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 14px 20px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}
.section-heading:not(:first-child) { border-top: 3px solid var(--border-acc); }
.section-count {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0;
  font-family: var(--font-sans);
  font-weight: 700;
}

.row-disappeared { background: rgba(255,77,94,.05); }

.full-list-toggle {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}
.full-list-toggle button {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--accent-ink);
  padding: 8px 20px;
  cursor: pointer;
  transition: background .2s;
}
.full-list-toggle button:hover { background: var(--accent-dim); }

/* ── Row filter ──────────────────────────────────────────────────────────────── */
.row-filtered-out { opacity: 0.12; }

.sidebar-filter { color: var(--text-dim); font-weight: 600; }
.sidebar-filter:hover { color: var(--accent); }
.sidebar-filter.filter-active { color: var(--accent) !important; font-weight: 800; }

.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 20px;
  background: var(--accent-glow);
  border-bottom: 2px solid var(--border-acc);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
}
.filter-bar strong { color: var(--accent); }
#filter-clear {
  background: var(--bg-surface);
  border: 2px solid var(--border-acc);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  cursor: pointer;
  transition: color .2s, border-color .2s;
}
#filter-clear:hover { color: var(--accent); border-color: var(--accent); }

/* ── Sources page ────────────────────────────────────────────────────────────── */
.sources-body {
  padding: 24px 28px;
  max-width: 740px;
}
.sources-section {
  margin-bottom: 32px;
}
.sources-section h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 3px solid var(--border-acc);
}
.sources-url {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 10px;
}
.sources-url a { color: var(--accent); }
.sources-section p {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  line-height: 1.7;
  margin-bottom: 10px;
}

/* ── Footer ──────────────────────────────────────────────────────────────────── */
#footer {
  max-width: 1120px;
  margin: 32px auto 0;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-align: center;
}
#footer a { color: var(--accent); }
#footer a:hover { color: var(--accent-dim); }

.footer-bgg-logo-link {
  display: inline-block;
  margin-bottom: 10px;
  opacity: 0.9;
  transition: opacity .2s;
}
.footer-bgg-logo-link:hover { opacity: 1; }
.footer-bgg-logo { height: 26px; width: auto; display: block; }
.logo-bgg-light { display: none; }
[data-theme="light"] .logo-bgg-dark  { display: none; }
[data-theme="light"] .logo-bgg-light { display: block; }

/* ── Responsive ──────────────────────────────────────────────────────────────── */
/* Below this the nav and the badge start fighting for the same row; the footer
   badge still carries the attribution */
@media (max-width: 1040px) {
  .header-bgg-logo-link { display: none; }
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar-left,
  .sidebar-right {
    display: none;
  }
  .main-nav { display: none; }
  /* Nav is gone, so the badge fits again — and it is the only attribution
     visible without scrolling to the bottom */
  .header-bgg-logo-link { display: flex; }
}
