/* ---------- Design tokens (clean/minimal with warmth) ---------- */
  :root {
    --bg: #fbf9f5;            /* warm off-white */
    --surface: #ffffff;
    --surface-2: #f4f1ea;
    --border: #e8e2d4;
    --border-strong: #d4ccb8;
    --ink: #1f1d18;
    --ink-2: #5a544a;
    --ink-3: #8c8578;
    --accent: #b8521a;        /* warm terracotta */
    --accent-soft: #f3dfd0;
    --positive: #2f7a3e;
    --negative: #b03a2e;
    --shadow: 0 1px 2px rgba(31, 29, 24, 0.04), 0 1px 3px rgba(31, 29, 24, 0.06);
    --shadow-lg: 0 4px 12px rgba(31, 29, 24, 0.08);
    --radius: 8px;
    --radius-sm: 5px;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  }

  * { box-sizing: border-box; }
  html, body { margin: 0; padding: 0; }
  body {
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }

  /* ---------- Password gate ---------- */
  .gate {
    position: fixed; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg);
    z-index: 100;
  }
  .gate-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px 36px;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow);
  }
  .gate-card h1 {
    margin: 0 0 4px;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.01em;
  }
  .gate-card .subtitle {
    margin: 0 0 24px;
    font-size: 13px;
    color: var(--ink-3);
  }
  .gate-card label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--ink-2);
    margin-bottom: 6px;
  }
  .gate-card input[type="password"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-family: var(--mono);
    font-size: 13px;
    background: var(--bg);
    color: var(--ink);
    transition: border-color 120ms ease;
  }
  .gate-card input[type="password"]:focus {
    outline: none;
    border-color: var(--accent);
  }
  .gate-card button {
    margin-top: 16px;
    width: 100%;
    padding: 10px 14px;
    background: var(--ink);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 120ms ease;
  }
  .gate-card button:hover { background: #2c2925; }
  .gate-error {
    margin-top: 12px;
    color: var(--negative);
    font-size: 12px;
    min-height: 16px;
  }

  /* ---------- App shell ---------- */
  .app { display: none; }
  .app.visible { display: block; }

  header.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 14px 28px;
    display: flex; align-items: center; justify-content: space-between;
  }
  .brand {
    display: flex; align-items: baseline; gap: 10px;
  }
  .brand .logo {
    font-size: 16px; font-weight: 600; letter-spacing: -0.01em;
  }
  .brand .tag {
    font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em;
  }
  .topbar .meta {
    font-size: 12px; color: var(--ink-3);
  }

  main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 28px;
  }

  .page-title {
    margin: 0 0 4px;
    font-size: 22px; font-weight: 600; letter-spacing: -0.01em;
  }
  .page-subtitle {
    margin: 0 0 20px;
    font-size: 13px; color: var(--ink-3);
  }

  /* ---------- Toolbar (search + filters) ---------- */
  .toolbar {
    display: flex; gap: 12px; align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
  }
  .search {
    flex: 1; min-width: 240px;
    position: relative;
  }
  .search input {
    width: 100%;
    padding: 9px 12px 9px 34px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: var(--surface);
    color: var(--ink);
    transition: border-color 120ms ease;
  }
  .search input:focus { outline: none; border-color: var(--accent); }
  .search svg {
    position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
    color: var(--ink-3);
    pointer-events: none;
  }
  .toolbar select {
    padding: 9px 28px 9px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: var(--surface);
    color: var(--ink);
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'><path d='M2 4l3 3 3-3' stroke='%238c8578' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
    cursor: pointer;
  }

  .stats-pill {
    font-size: 12px;
    color: var(--ink-3);
    padding: 6px 10px;
    background: var(--surface-2);
    border-radius: 999px;
  }
  .stats-pill strong { color: var(--ink); font-weight: 600; }

  /* ---------- Table ---------- */
  .table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
  }
  table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
  }
  thead th {
    text-align: left;
    padding: 11px 14px;
    font-weight: 500;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-3);
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    position: sticky; top: 0;
    user-select: none;
  }
  thead th.sortable { cursor: pointer; transition: color 120ms ease; }
  thead th.sortable:hover { color: var(--ink); }
  thead th .sort-arrow { display: inline-block; margin-left: 4px; opacity: 0.5; }
  thead th.active { color: var(--accent); }
  thead th.active .sort-arrow { opacity: 1; }
  tbody td {
    padding: 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
  }
  tbody tr:last-child td { border-bottom: none; }
  tbody tr.project-row { cursor: pointer; }
  tbody tr:hover { background: rgba(184, 82, 26, 0.025); }

  .game-name { font-weight: 500; color: var(--ink); }
  .game-meta { font-size: 11px; color: var(--ink-3); margin-top: 2px; }
  .creator { color: var(--ink-2); }
  .creator-stats { font-size: 11px; color: var(--ink-3); margin-top: 2px; font-variant-numeric: tabular-nums; }
  .num { font-variant-numeric: tabular-nums; text-align: right; }
  .delta { font-variant-numeric: tabular-nums; text-align: right; font-weight: 500; }
  .delta.pos { color: var(--positive); }
  .delta.neg { color: var(--negative); }
  .delta.zero { color: var(--ink-3); }

  /* ---------- Sparkline ---------- */
  .sparkline { display: block; }
  .sparkline-cell { width: 130px; padding-right: 18px !important; }

  /* ---------- Pagination ---------- */
  .pagination {
    display: flex; align-items: center; justify-content: space-between;
    margin-top: 16px;
    font-size: 13px;
    color: var(--ink-2);
  }
  .pagination .controls { display: flex; gap: 6px; }
  .pagination button {
    padding: 6px 12px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--ink-2);
    cursor: pointer;
    transition: all 120ms ease;
  }
  .pagination button:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
  }
  .pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

  /* ---------- States ---------- */
  .state {
    padding: 60px 20px; text-align: center; color: var(--ink-3);
  }
  .state.error { color: var(--negative); }
  .skel-row td { padding: 14px; }
  .skel { display: inline-block; height: 12px; background: var(--surface-2); border-radius: 3px; }
  @keyframes pulse { 0%, 100% { opacity: 1 } 50% { opacity: 0.5 } }
  .skel { animation: pulse 1.4s ease-in-out infinite; }

  /* ---------- Tooltip on sparkline ---------- */
  .spark-tooltip {
    position: absolute;
    background: var(--ink);
    color: #fff;
    padding: 5px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-family: var(--mono);
    pointer-events: none;
    opacity: 0;
    transition: opacity 120ms ease;
    z-index: 50;
    white-space: nowrap;
  }
  .spark-tooltip.visible { opacity: 1; }
/* ---------- Navigation Tabs ---------- */
.tabs { display: flex; gap: 24px; margin-left: 40px; flex: 1; }
.tabs a { color: var(--ink-3); text-decoration: none; font-weight: 500; font-size: 13px; transition: color 120ms ease; padding-bottom: 2px; }
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--accent); border-bottom: 2px solid var(--accent); }

/* ---------- Creator Details Grid ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 32px; }
.stat-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.stat-box .label { font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 500; margin-bottom: 8px; }
.stat-box .value { font-size: 24px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
/* ---------- Details Panel ---------- */
.details-row {
  display: none;
}
.details-row.visible {
  display: table-row;
}
.details-panel-content {
  padding: 20px;
  background-color: var(--surface-2);
  border-top: 1px solid var(--border);
}
.details-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.details-title {
  font-size: 18px;
  font-weight: 600;
}
.details-link a {
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
}
.details-link a:hover {
  text-decoration: underline;
}
.details-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 20px;
}
.follower-list {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
}
.follower-item {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}
.follower-item:last-child {
  border-bottom: none;
}
.follower-date {
  color: var(--ink-2);
}
.follower-count {
  font-weight: 500;
}

/* ============================================================
   MOBILE — responsive overrides (max-width: 768px)
   ============================================================ */

@media (max-width: 768px) {

  /* --- Topbar: stack brand + nav vertically --- */
  header.topbar {
    flex-direction: column;
    align-items: flex-start;
    padding: 12px 16px 0 16px;
    gap: 0;
  }
  .brand { margin-right: 0; margin-bottom: 10px; }
  .topbar .meta { display: none; } /* hide 'Last refresh' on mobile */

  /* Nav: horizontal scrollable strip */
  .tabs {
    margin-left: 0;
    flex: unset;
    width: calc(100% + 32px);
    margin-left: -16px;
    padding: 0 16px;
    gap: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    border-top: 1px solid var(--border);
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a {
    flex-shrink: 0;
    padding: 10px 14px;
    font-size: 13px;
    border-bottom: 2px solid transparent;
  }
  .tabs a.active {
    border-bottom: 2px solid var(--accent);
  }

  /* --- Main padding --- */
  main {
    padding: 16px;
  }
  .page-title { font-size: 18px; }
  .page-subtitle { margin-bottom: 14px; }

  /* --- Toolbar: stack search above select --- */
  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .search { min-width: unset; }
  .toolbar select { width: 100%; }
  .stats-pill { text-align: center; }

  /* --- Table: hide secondary columns, make it readable --- */
  .table-wrap {
    border-radius: var(--radius-sm);
    overflow-x: hidden;
  }
  table { font-size: 13px; }

  /* Hide: creator, 30d delta, sparkline, launch date */
  thead th:nth-child(2),
  thead th:nth-child(4),
  thead th:nth-child(6),
  thead th:nth-child(7),
  tbody td:nth-child(2),
  tbody td:nth-child(4),
  tbody td:nth-child(6),
  tbody td:nth-child(7) {
    display: none;
  }

  /* Visible columns: Project(1), 7d Δ(3), Followers(5) */
  tbody td, thead th {
    padding: 12px 10px;
  }
  .game-name { font-size: 13px; }
  .game-meta { font-size: 11px; }

  /* Numbers right-aligned, give them breathing room */
  td:nth-child(3), td:nth-child(5),
  th:nth-child(3), th:nth-child(5) {
    text-align: right;
    padding-right: 14px;
  }

  /* --- Details panel --- */
  .details-grid {
    grid-template-columns: 1fr;
  }
  .follower-list { max-height: 200px; }

  /* --- Pagination --- */
  .pagination {
    flex-direction: column;
    gap: 10px;
    align-items: center;
    text-align: center;
  }
  .pagination .controls { width: 100%; justify-content: center; }
  .pagination button { flex: 1; padding: 10px; font-size: 13px; }

  /* --- Stats grid on other pages --- */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .stat-box .value { font-size: 20px; }
}

/* Extra small phones (< 400px) */
@media (max-width: 400px) {
  .stats-grid { grid-template-columns: 1fr; }
  .tabs a { padding: 10px 10px; font-size: 12px; }
}

/* ============================================================
   Platform badges (KS / GF)
   ============================================================ */

.badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .05em;
  padding: 2px 5px;
  border-radius: 4px;
  vertical-align: middle;
  margin-right: 5px;
  line-height: 1.4;
  flex-shrink: 0;
}
.badge-ks {
  background: #e8f0fe;
  color: #1a5cad;
  border: 1px solid #bcd0f7;
}
.badge-gf {
  background: #fff3e0;
  color: #b45309;
  border: 1px solid #fcd59a;
}
.badge-bk {
  background: #fce8d8;
  color: #923b10;
  border: 1px solid #f4b88a;
}
.game-name-row {
  display: flex;
  align-items: center;
}
.game-name-row .game-name {
  flex: 1;
  min-width: 0;
}

/* ============================================================
   Category filter pills (All / Tabletop / TTRPG)
   ============================================================ */

.category-pills {
  display: flex;
  gap: 4px;
  align-items: center;
}
.cat-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.cat-pill:hover {
  background: var(--surface-2, #f5f5f7);
  color: var(--ink-1);
}
.cat-pill.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ============================================================
   Platform filter pills (All platforms / Kickstarter / Gamefound)
   ============================================================ */

.platform-pills {
  display: flex;
  gap: 4px;
  align-items: center;
}
.plat-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.plat-pill:hover {
  background: var(--surface-2, #f5f5f7);
  color: var(--ink-1);
}
.plat-pill.active[data-plat="all"] {
  background: var(--ink-2);
  color: var(--bg);
  border-color: var(--ink-2);
}
.plat-pill.active[data-plat="kickstarter"] {
  background: #1a5cad;
  color: #fff;
  border-color: #1a5cad;
}
.plat-pill.active[data-plat="gamefound"] {
  background: #b45309;
  color: #fff;
  border-color: #b45309;
}
.plat-pill.active[data-plat="backerkit"] {
  background: #923b10;
  color: #fff;
  border-color: #923b10;
}

/* Disabled category pill (e.g. Tabletop when GF selected) */
.cat-pill.disabled,
.cat-pill:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}
