@import url("https://fonts.googleapis.com/css2?family=Google+Sans:wght@400;500;600;700&display=swap");
@import url("./lib/clusterize/clusterize.css");

/* ============================================
   THEME TOKENS
   ============================================ */
html[data-theme="dark"] {
  --color-bg: #111111;
  --color-bg-rgb: 17, 17, 17;
  --color-surface: #161616;
  --color-text: #fbfbfb;
  --color-muted: #666666;
  --color-subtle: #aaaaaa;
  --color-border: #333333;
  --color-shadow: #000000;
  --color-link: #fbfbfb;
  --color-row-odd: #111111;
  --color-row-even: #161616;
  --sticky-shadow-solid: #000000;
  --sticky-shadow-fade: rgba(0, 0, 0, 0.9);
  --sticky-shadow-fade-mobile: rgba(0, 0, 0, 0.98);
  --tooltip-bg: #222222;
  --tooltip-text: #cccccc;
  --tooltip-muted: #9ca3af;
  --tooltip-title-sub: #b8c0cc;
  --tooltip-hover: #2e2e2e;
  --pill-bg: #222222;
  --icon-hover-bg: #1a1a1a;
  --dropdown-item-hover: #1a1a1a;
  --search-active-line: #eeeeee;
  --feedback-trigger-bg: rgba(255, 255, 255, 0.05);
  --feedback-trigger-border: rgba(255, 255, 255, 0.1);
  --feedback-trigger-text: rgba(255, 255, 255, 0.5);
  --feedback-trigger-hover-bg: rgba(255, 255, 255, 0.1);
  --feedback-trigger-hover-border: rgba(255, 255, 255, 0.2);
  --feedback-trigger-hover-text: #ffffff;
  --feedback-trigger-hover-shadow: rgba(0, 0, 0, 0.3);
  --feedback-overlay-bg: rgba(0, 0, 0, 0.7);
  --feedback-modal-bg: rgba(20, 20, 20, 0.85);
  --feedback-modal-border: rgba(255, 255, 255, 0.1);
  --feedback-modal-shadow: rgba(0, 0, 0, 0.8);
  --feedback-title-text: #ffffff;
  --feedback-label-text: #999999;
  --feedback-body-text: #cccccc;
  --feedback-control-bg: rgba(255, 255, 255, 0.05);
  --feedback-control-border: rgba(255, 255, 255, 0.1);
  --feedback-control-focus-border: rgba(255, 255, 255, 0.3);
  --feedback-control-text: #ffffff;
  --feedback-submit-bg: rgb(219, 219, 219);
  --feedback-submit-hover-bg: rgb(235, 235, 235);
  --feedback-submit-text: #000000;
  --feedback-toast-text: #ffffff;
  --dropdown-panel-shadow: 20px 20px 27px 17px rgb(0 0 0 / 67%);
}

html[data-theme="light"] {
  --color-bg: #f6f7fb;
  --color-bg-rgb: 246, 247, 251;
  --color-surface: #ffffff;
  --color-text: #111827;
  --color-muted: #667085;
  --color-subtle: #475467;
  --color-border: #d0d5dd;
  --color-shadow: #98a2b3;
  --color-link: #0f172a;
  --color-row-odd: #ffffff;
  --color-row-even: #f9fafb;
  --sticky-shadow-solid: #cbd5e1;
  --sticky-shadow-fade: rgba(148, 163, 184, 0.6);
  --sticky-shadow-fade-mobile: rgba(148, 163, 184, 0.75);
  --tooltip-bg: #ffffff;
  --tooltip-text: #111827;
  --tooltip-muted: #667085;
  --tooltip-title-sub: #475467;
  --tooltip-hover: #f2f4f7;
  --pill-bg: #f2f4f7;
  --icon-hover-bg: #eaecf0;
  --dropdown-item-hover: #f2f4f7;
  --search-active-line: #667085;
  --feedback-trigger-bg: rgba(15, 23, 42, 0.06);
  --feedback-trigger-border: rgba(15, 23, 42, 0.16);
  --feedback-trigger-text: rgba(15, 23, 42, 0.7);
  --feedback-trigger-hover-bg: rgba(15, 23, 42, 0.1);
  --feedback-trigger-hover-border: rgba(15, 23, 42, 0.24);
  --feedback-trigger-hover-text: #0f172a;
  --feedback-trigger-hover-shadow: rgba(15, 23, 42, 0.2);
  --feedback-overlay-bg: rgba(15, 23, 42, 0.35);
  --feedback-modal-bg: rgba(255, 255, 255, 0.94);
  --feedback-modal-border: rgba(15, 23, 42, 0.16);
  --feedback-modal-shadow: rgba(15, 23, 42, 0.28);
  --feedback-title-text: #0f172a;
  --feedback-label-text: #667085;
  --feedback-body-text: #475467;
  --feedback-control-bg: rgba(15, 23, 42, 0.04);
  --feedback-control-border: rgba(15, 23, 42, 0.16);
  --feedback-control-focus-border: rgba(15, 23, 42, 0.34);
  --feedback-control-text: #0f172a;
  --feedback-submit-bg: #111827;
  --feedback-submit-hover-bg: #0f172a;
  --feedback-submit-text: #ffffff;
  --feedback-toast-text: #0f172a;
  --dropdown-panel-shadow: 18px 18px 24px 10px rgb(15 23 42 / 18%);
}

/* ============================================
   CSS RESET (Tailwind Preflight equivalent)
   ============================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  border-width: 0;
  border-style: solid;
  border-color: #e5e7eb;
}

html {
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  tab-size: 4;
}

body {
  margin: 0;
  line-height: inherit;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-size: inherit;
  font-weight: inherit;
  margin: 0;
}

p {
  margin: 0;
}

a {
  color: inherit;
  text-decoration: inherit;
}

table {
  text-indent: 0;
  border-color: inherit;
  border-collapse: collapse;
}

button,
input {
  font-family: inherit;
  font-size: 100%;
  font-weight: inherit;
  line-height: inherit;
  color: inherit;
  margin: 0;
  padding: 0;
}

/* ============================================
   BASE STYLES
   ============================================ */
* {
  font-family: "Google Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
  background-color: var(--color-bg);
  color: var(--color-text);
  cursor: default;
}

a {
  color: var(--color-link);
}

.marketplace-link {
  color: var(--color-link);
  transition: color 0.15s ease;
}

.marketplace-link:hover {
  color: var(--color-text);
}

.theme-switch {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 13000;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface);
  backdrop-filter: blur(6px);
}

.theme-switch-btn {
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-muted);
  border-radius: 999px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.theme-switch-icon {
  width: 16px;
  height: 16px;
}

.theme-cycle-btn {
  display: none;
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-muted);
  border-radius: 999px;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.theme-cycle-btn:hover {
  background: var(--color-surface);
  color: var(--color-text);
}

.theme-cycle-btn:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--color-text) 60%, transparent);
  outline-offset: 1px;
}

.theme-cycle-icon {
  width: 16px;
  height: 16px;
  display: none;
}

.theme-switch[data-theme-choice="dark"] .theme-cycle-icon--dark {
  display: inline-block;
}

.theme-switch[data-theme-choice="light"] .theme-cycle-icon--light {
  display: inline-block;
}

.theme-switch-btn:hover {
  background: var(--color-surface);
  color: var(--color-text);
}

.theme-switch-btn.active {
  background: var(--color-text);
  color: var(--color-surface);
  border-color: var(--color-text);
}

.theme-switch-btn:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--color-text) 60%, transparent);
  outline-offset: 1px;
}

@media (max-width: 650px) {
  .theme-switch {
    top: 8px;
    right: 8px;
    padding: 0;
    border: 0;
    background: transparent;
    backdrop-filter: none;
  }

  .theme-switch-btn {
    display: none;
  }

  .theme-cycle-btn {
    display: inline-flex;
    width: 28px;
    height: 28px;
  }

  .theme-cycle-icon {
    width: 14px;
    height: 14px;
  }
}

.tab-button {
  border: 1px solid var(--color-border);
  position: relative;
}

/* Table border */
.rounded-lg.border {
  border-color: var(--color-border) !important;
}

/* Table container */
#rankings-table-container {
  /* overflow moved to .clusterize-scroll */
  border-top-right-radius: 0;
  position: relative;
}

/* Right-edge fade overlay for horizontal-scroll affordance.
   Render above rows to avoid zebra-striping artifacts. */
#rankings-table-container::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 14px;
  pointer-events: none;
  z-index: 12100;
  background: linear-gradient(to left, rgba(var(--color-bg-rgb), 0.95), rgba(var(--color-bg-rgb), 0));
}

/* Stronger horizontal-scroll affordance on mobile */
@media (max-width: 900px) {
  #rankings-table-container::after {
    width: 34px;
    background: linear-gradient(
      to left,
      rgba(var(--color-bg-rgb), 1) 0%,
      rgba(var(--color-bg-rgb), 0.92) 35%,
      rgba(var(--color-bg-rgb), 0.65) 65%,
      rgba(var(--color-bg-rgb), 0) 100%
    );
  }
}

/* Ensure thead background is applied */
/* Header row: same background as odd rows (transparent, shows body var(--color-bg)) */
thead.bg-muted,
thead.bg-muted th,
thead.bg-muted tr {
  background-color: transparent;
}

/* Page layout: flex column so table area takes remaining space.
   Uses min-height so the page scrolls naturally when viewport is too short. */
.ranks-page-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
}

.ranks-page-layout > #rankings-table-container {
  flex: 1 1 0;
  min-height: 300px;
  display: flex;
  flex-direction: column;
  overflow: visible;
}

/* Boot/loading gate:
   hide table area until JSON + URL state are applied, and freeze controls. */
body.ranks-booting #rankings-table-container {
  visibility: hidden;
  pointer-events: none;
}

body.ranks-booting .search-row {
  visibility: hidden;
  pointer-events: none;
}

body.ranks-booting #ranking-tabs .tab-button,
body.ranks-booting #period-toggle .period-button,
body.ranks-booting .category-dropdown-button {
  pointer-events: none;
  color: var(--color-muted);
  border-color: var(--color-border);
}

body.ranks-booting #ranking-tabs .tab-button.active,
body.ranks-booting #period-toggle .period-button.active,
body.ranks-booting .category-dropdown-button.active {
  background-color: transparent;
  color: var(--color-muted);
  border-color: var(--color-border);
}

.ranks-page-layout > #rankings-table-container > .table-wrapper {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.clusterize-scroll {
  flex: 1 1 0;
  max-height: none;
  overflow: auto;
}

.clusterize-content tr:nth-child(even) {
  background: var(--color-surface);
}

.clusterize-content tr:nth-child(odd) {
  background: var(--color-bg);
}

/* Rank badges (crowns/medals) should not push rank numbers */
.rank-with-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.rank-with-badge .rank-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.rank-with-badge .rank-badge {
  position: absolute;
  left: -18px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.rank-with-badge .rank-badge.rank-crown-badge {
  color: #f4b400;
}

.rank-with-badge .rank-badge.rank-crown-badge svg {
  width: 16px;
  height: 16px;
  display: block;
}

.medal-svg {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.medal-svg svg {
  display: block;
}

/* Show sparkline datapoint labels */
.sparkline,
.sparkline svg {
  overflow: visible;
}

.sparkline svg text {
  display: block;
}

/* Ensure table columns align with fixed widths */
#rankings-table {
  table-layout: fixed;
  width: 100%;
  user-select: none;
}

/* The table containing clusterize-content tbody needs table-layout: fixed */
#clusterize-scroll > table {
  table-layout: fixed;
  width: 100%;
}

/* Table sizing model:
   - Fixed-width utility columns
   - Name column stretches to consume remaining width
   - Horizontal scroll starts only when Name would drop below its minimum */
:root {
  --ranks-fixed-cols-width: 671px; /* rank+change+trend+price+img+medals+author */
  --ranks-name-min-width: 170px;
  --ranks-table-min-width: calc(var(--ranks-fixed-cols-width) + var(--ranks-name-min-width));
}

/* Table horizontal-scroll behavior: global (no max-width media query) */
.ranks-page-layout > #rankings-table-container {
  overflow: hidden;
}

/* Keep header/body/footer column widths aligned while scrolling */
#rankings-table,
#clusterize-scroll > table {
  width: 100%;
  min-width: var(--ranks-table-min-width);
  border-collapse: separate;
  border-spacing: 0;
}

.tfoot-spacer-row {
  opacity: 0;
  pointer-events: none;
}

.tfoot-spacer-row td {
  height: 0;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  line-height: 0 !important;
  font-size: 0 !important;
}

/* Creator mode uses content-driven columns; allow shrink-to-fit layout. */
.creators-table #rankings-table,
.creators-table #clusterize-scroll > table {
  width: auto;
  min-width: 580px;
}

/* Vertical scroll remains in Clusterize viewport; horizontal in container */
.clusterize-scroll {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scrollbar-gutter: stable;
}

@supports (scrollbar-width: auto) {
  .clusterize-scroll {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.35) rgba(255, 255, 255, 0.08);
  }
}

@supports selector(::-webkit-scrollbar) {
  .clusterize-scroll::-webkit-scrollbar {
    width: 10px;
    height: 10px;
  }

  .clusterize-scroll::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.08);
  }

  .clusterize-scroll::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.35);
    border: 2px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
  }

  .clusterize-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.55);
  }
}

/* Sticky first column in the actual table scroll context. */
#rankings-table thead th.col-rank {
  position: sticky;
  left: 0;
  z-index: 12030;
  background: var(--color-bg);
  box-shadow: none;
  border-right: 1px solid var(--color-border);
}

#clusterize-content td.rank-cell {
  position: sticky;
  left: 0;
  z-index: 9000;
  background: var(--color-bg);
  box-shadow: none;
  border-right: 1px solid var(--color-border);
}

#rankings-tfoot td {
  position: sticky;
  bottom: 0;
  z-index: 15000;
  padding: 4px;
  font-size: 11px;
  color: var(--color-subtle);
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
  box-shadow: 0 -5px 10px var(--color-bg);
}

/* Sticky first footer cell (rank). */
#rankings-tfoot td.col-rank {
  position: sticky;
  left: 0;
  z-index: 15010;
  background: var(--color-bg);
  box-shadow: none;
  border-right: 1px solid var(--color-border);
}

@media (max-width: 900px) {
  #rankings-table thead th.col-rank,
  #clusterize-content td.rank-cell,
  #rankings-tfoot td.col-rank {
    box-shadow: none;
    border-right: 1px solid var(--color-border);
  }
}

/* Shared tfoot/stats change column styles */
.tfoot-change-positive {
  color: #4ade80;
}

.tfoot-change-negative {
  color: #f87171;
}

.tfoot-change-zero {
  color: var(--color-muted);
}

.tfoot-change-events {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
}

.tfoot-change-new {
  color: #9ce929;
}

.tfoot-change-comeback {
  color: #facc15;
}

.tfoot-change-price {
  color: #a78bfa;
}

.tfoot-change-sep {
  color: #555;
}

/* tfoot rank column styles */
.tfoot-rank-total {
  font-size: 12px;
}

.tfoot-rank-breakdown {
  font-size: 9px;
}

/* Elements with title attribute get help cursor */
[title] {
  cursor: help;
}

/* tfoot price column styles */
.tfoot-price-label {
  font-size: 9px;
  color: var(--color-subtle);
}

/* Hide image column when container has images-hidden class */
.images-hidden .image-column {
  display: none;
}

/* Pictures are always on now; hide the toggle control on all screen sizes. */
.show-pictures-toggle {
  display: none;
}

/* Add min-height to table rows */
.clusterize-content tr td {
  min-height: 32px;
  height: 32px;
}

#clusterize-content td {
  font-size: 14px;
  padding-top: 6px;
  padding-bottom: 6px;
}

/* No data row padding */
.clusterize-no-data td {
  padding-top: 12px;
  padding-bottom: 10px;
}

.ranks-no-results .ranks-no-results-message {
  color: #9ca3af;
}

.creators-head,
.creators-foot {
  display: none;
}

.creators-table .standard-head,
.creators-table .standard-foot {
  display: none;
}

.creators-table .creators-head,
.creators-table .creators-foot {
  display: table-row;
}

/* ============================================
   SPAN-BASED VIEW TOGGLE (New Unified System)
   ============================================ */
/* Column widths for new 2-column rank/change layout */
.col-rank {
  width: 80px;
}

.col-change {
  width: 90px;
}

.col-trend {
  width: 96px;
}

/* In category view, hide the entire 7-day Trend column (header + body + footer). */
.category-view th.col-trend,
.category-view td.trend-cell,
.category-view #clusterize-content td.col-trend,
.category-view #tfoot .col-trend,
.category-view #rankings-tfoot .col-trend {
  display: none !important;
}

.col-price {
  width: 70px;
}

.price-content {
  position: relative;
  display: inline-block;
}

.price-previous {
  position: absolute !important;
  left: 100%;
  right: auto;
  margin-left: 2px;
  top: 50%;
  transform: translateY(-50%);
  margin-top: 1px;
  font-size: 10px;
  line-height: 1;
  white-space: nowrap;
  pointer-events: auto;
  color: #9ca3af;
  z-index: 99999;
}

.price-prev-arrow {
  display: inline-flex;
  width: 6px;
  height: 6px;
  margin-right: 2px;
  vertical-align: middle;
}

.price-prev-arrow svg {
  display: block;
  width: 100%;
  height: 100%;
}

.delta-marker {
  display: inline-flex;
  width: 7px;
  height: 7px;
  margin-right: 2px;
  vertical-align: middle;
}

.change-cell .delta-marker {
  margin-top: -1px;
}

.delta-marker svg {
  display: block;
  width: 100%;
  height: 100%;
}

.delta-marker.delta-down {
  transform: rotate(180deg);
}

.col-img {
  width: 70px;
}

.col-name {
  width: auto;
  min-width: var(--ranks-name-min-width);
}

.col-medals {
  width: 100px;
}

.col-author {
  width: 165px;
}

/* Hide all spans by default - CSS handles visibility */
.rank-cell > span,
.change-cell > span,
.trend-cell > span {
  display: none;
}

/* View: alltime-all */
.view-alltime-all .rank-cell .r-alltime-all,
.view-alltime-all .change-cell .c-alltime-all {
  display: inline;
}

/* View: alltime-free */
.view-alltime-free .rank-cell .r-alltime-free,
.view-alltime-free .change-cell .c-alltime-free {
  display: inline;
}

/* View: alltime-paid */
.view-alltime-paid .rank-cell .r-alltime-paid,
.view-alltime-paid .change-cell .c-alltime-paid {
  display: inline;
}

/* View: lastWeek-all */
.view-lastWeek-all .rank-cell .r-lastWeek-all,
.view-lastWeek-all .change-cell .c-lastWeek-all {
  display: inline;
}

/* View: lastWeek-free */
.view-lastWeek-free .rank-cell .r-lastWeek-free,
.view-lastWeek-free .change-cell .c-lastWeek-free {
  display: inline;
}

/* View: lastWeek-paid */
.view-lastWeek-paid .rank-cell .r-lastWeek-paid,
.view-lastWeek-paid .change-cell .c-lastWeek-paid {
  display: inline;
}

/* Category views - dynamically match category IDs */
/* Using attribute selector to match any view-{categoryId} class */
[class*="view-"] .rank-cell span[class^="r-"],
[class*="view-"] .change-cell span[class^="c-"],
[class*="view-"] .trend-cell span[class^="t-"] {
  display: none;
}

/* Override: show matching spans based on container class */
/* This works because we set view-{categoryId} on the container */
/* and each span has class r-{categoryId} or c-{categoryId} */
/* For category views, we use JS to add a style tag with specific rules */
/* OR use this clever CSS trick with attribute matching */
/* Fallback for categories: show spans where class matches container's view */
.view-alltime-all .r-alltime-all {
  display: inline !important;
}

.view-alltime-all .c-alltime-all {
  display: inline !important;
}

.view-alltime-all .t-alltime-all {
  display: inline !important;
}

.view-alltime-free .r-alltime-free {
  display: inline !important;
}

.view-alltime-free .c-alltime-free {
  display: inline !important;
}

.view-alltime-free .t-alltime-free {
  display: inline !important;
}

.view-alltime-paid .r-alltime-paid {
  display: inline !important;
}

.view-alltime-paid .c-alltime-paid {
  display: inline !important;
}

.view-alltime-paid .t-alltime-paid {
  display: inline !important;
}

/* Question mark tooltip icon */
.tooltip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 12px;
  height: 12px;
  font-size: 9px;
  font-weight: 600;
  color: #777;
  border: 1px solid #555;
  vertical-align: text-top;
  border-radius: 50%;
  margin-right: 5px;
  position: relative;
  top: 1px;
  margin-left: -15px;
}

.tab-button .tooltip-icon {
  background: none;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: auto;
  height: auto;
  display: block;
  border-radius: 0;
  margin: 0;
  position: absolute;
  pointer-events: auto;
  border: none;
  color: transparent;
}

.tab-button .tooltip-icon::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 8px;
  width: 90px;
  padding: 4px 8px;
  outline: 1px solid var(--color-border);
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  font-size: 10px;
  text-align: center;
  border-radius: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 100;
}

.tab-button:hover .tooltip-icon::after {
  opacity: 1;
}

/* Style search input clear button */
#rankings-search::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  height: 14px;
  width: 14px;
  background: var(--color-text);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3E%3Cline x1='18' y1='6' x2='6' y2='18'%3E%3C/line%3E%3Cline x1='6' y1='6' x2='18' y2='18'%3E%3C/line%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3E%3Cline x1='18' y1='6' x2='6' y2='18'%3E%3C/line%3E%3Cline x1='6' y1='6' x2='18' y2='18'%3E%3C/line%3E%3C/svg%3E");
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}

/* Style sort arrows */
.sort-arrows-container {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
  vertical-align: middle;
}

.sort-arrow {
  display: inline-block;
  color: var(--color-subtle);
}

.sort-arrow svg {
  width: 7px;
  height: 5px;
  display: block;
}

.sort-arrow-down {
  transform: rotate(180deg);
  margin-top: 1px;
  margin-bottom: -1px;
}

.sort-arrow.active {
  color: var(--color-text);
}

/* When active arrow is present, inactive arrow should be darker */
.sort-arrows-container:has(.sort-arrow.active) .sort-arrow:not(.active) {
  color: var(--color-muted);
}

/* Mobile styles */
@media (max-width: 768px) {
  body {
    font-size: 12px;
  }

  .mx-auto.max-w-\[1000px\] {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    padding-top: 1rem;
    padding-bottom: 1rem;
  }

  h1 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
  }

  .mb-8 {
    margin-bottom: 1rem;
  }

  .rankings-container {
    /* flex-direction: column; */
    /* gap: 0.5rem; */
  }

  .rankings-label {
    text-align: center;
    width: 100%;
    order: -1;
  }

  .tab-button {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    min-width: 100px;
  }

  .px-4 {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
}

/* Small-screen filter/title layout tweaks (non-table) */
@media (max-width: 650px) {
  .rankings-container {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 8px;
  }

  .search-field-checkboxes {
    /* display: flex !important; */
    right: 0;
    top: 100%;
    margin: 0;
    transform-origin: right;
    transform: scale(0.9);
    box-shadow: 0px 2px 5px 2px black;
  }

  .search-container {
    /* width: auto !important; */
    /* max-width: none !important; */
  }

  #table-title-subtitle {
    position: relative;
    background: none;
    padding: 0;
    border: none;
    height: auto;
    top: auto;
    left: auto;
    margin: 0;
  }

  #table-title-subtitle:before {
    visibility: hidden;
  }

  .sort-arrows-container {
    margin-top: -2px;
  }
}

/* ============================================
   CATEGORY DROPDOWN STYLES
   ============================================ */
/* Dropdown button styling */
.category-dropdown-button .dropdown-arrow {
  display: inline-block;
  margin-left: 6px;
  font-size: 10px;
  transition: transform 0.2s ease;
}

/* Category dropdown panel - positioned below the button */
.category-dropdown-panel {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 13100;
  margin-top: 8px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: var(--dropdown-panel-shadow);
  min-width: 250px;
  user-select: none;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transition: opacity 100ms ease-in;
  background: var(--color-bg);
}

/* ============================================
   CATEGORY TREE STYLES
   ============================================ */
.category-tree {
  /* padding: 8px 0; */
  max-height: 500px;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

@supports (scrollbar-width: auto) {
  .category-tree {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.35) rgba(255, 255, 255, 0.08);
  }
}

/* Category Tree Nodes */
.category-node {
  user-select: none;
}

.category-item {
  display: flex;
  align-items: center;
  padding: 6px 12px;
  cursor: pointer;
  position: relative;
  transition: background-color 0.15s ease;
  font-size: 13px;
  color: var(--color-subtle);
}

.category-item:hover {
  background-color: var(--dropdown-item-hover);
}

.category-item:active {
  opacity: 0.5;
  /* background: none; */
}

.category-item.selected {
  background-color: var(--dropdown-item-hover);
  color: var(--color-text);
}

/* Expand/Collapse Icon */
.category-expand-icon {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 6px;
  flex-shrink: 0;
  transition: background 200ms;
  font-size: 10px;
  color: var(--color-muted);
  border-radius: 3px;
  position: relative;
}

.category-expand-icon:after {
  content: "";
  position: absolute;
  left: -5px;
  right: -5px;
  top: -5px;
  bottom: -5px;
  background: none;
  opacity: 0;
}

.category-item.selected .category-expand-icon {
  color: var(--color-text);
}

.category-item:hover .category-expand-icon {
  background: var(--icon-hover-bg);
}

.category-item .category-expand-icon:hover {
  /* transform: scale(1.2); */
  color: var(--color-text);
  border: 1px solid var(--color-border);
  outline: none;
  background: var(--icon-hover-bg);
}

.category-item .category-expand-icon:active {
  background: none;
}

.category-expand-icon.expanded {
  transform: rotate(90deg);
}

.category-expand-icon.hidden {
  visibility: hidden;
  display: block;
}

/* Category label */
.category-label-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.category-item:hover .category-label-text {
  color: var(--color-text);
}

.category-expand-icon:hover + .category-label-text {
  color: var(--color-text);
}

/* Nested categories */
.category-children {
  display: none;
}

.category-children.expanded {
  display: block;
}

/* Indentation for tree levels */
.category-level-1 .category-item {
  padding-left: 8px;
}

.category-level-2 .category-item {
  padding-left: 36px;
}

.category-level-3 .category-item {
  padding-left: 56px;
}

/* Scrollbar styling for category panel */
.category-tree::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.category-tree::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.08);
}

.category-tree::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.35);
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
}

.category-tree::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.55);
}

/* ============================================
   SHARED TABLE TITLE SECTION
   ============================================ */
.table-title-section {
  padding: 16px 20px;
  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  position: relative;
  border-bottom-left-radius: 0;
}

.table-title-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.table-title-main {
  margin: 0;
  font-size: 24px;
  line-height: 1.4;
  min-height: 1.4em;
}

.table-title-main .category-title-link {
  transition: opacity 0.15s ease;
  color: var(--color-text);
}

.table-title-main .category-title-link:hover {
  opacity: 0.8;
  text-decoration: none;
}

.table-title-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.subtitle-icon {
  display: inline-block;
  vertical-align: middle;
  margin-right: 0px;
  margin-top: -2px;
}

.table-title-subtitle {
  font-size: 14px;
  color: var(--color-subtle);
  letter-spacing: 0.02em;
  min-height: 1.2em;
  position: absolute;
  top: 100%;
  margin-top: -1px;
  width: calc(100% - 208px);
  background: var(--color-bg);
  height: 32px;
  border: 1px solid var(--color-border);
  left: -1px;
  border-top: 0;
  padding-left: 16px;
  padding-top: 0;
  border-bottom-right-radius: 8px;
  border-bottom-left-radius: 8px;
}

.table-title-subtitle:before {
  content: "";
  width: 20px;
  height: 20px;
  position: absolute;
  top: 1px;
  right: -20px;
  border: 1px solid var(--color-border);
  border-right: 0;
  border-bottom: 0;
  box-shadow: -5px -5px 0px 2px var(--color-bg);
  border-top-left-radius: 12px;
}

.title-rank-label {
  color: var(--color-muted);
  font-weight: 400;
}

.table-title-subtitle span {
  display: inline;
}

.subtitle-period {
  color: #7cacf8;
}

.subtitle-pricing {
  color: #7cacf8;
}

.subtitle-count {
  color: var(--color-muted);
}

.subtitle-sep {
  color: var(--color-muted);
}

.table-title-meta {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--color-muted);
}

.table-title-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.table-title-meta-item::before {
  content: "•";
  margin-right: 4px;
}

.table-title-meta-item:first-child::before {
  display: none;
}

/* ============================================
   BUTTON STATE CLASSES (Consolidated)
   ============================================ */
/* Base button styles - shared by all toggle buttons */
.toggle-btn {
  min-width: 100px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  font-size: 13px;
  line-height: 32px;
  text-align: center;
  display: inline-block;
  cursor: pointer;
  transition: none;
  background-color: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  position: relative;
  user-select: none;
  /* font-weight: bold; */
  letter-spacing: 0.5px;
}

.toggle-btn:active {
  opacity: 0.5;
}

/* Active button state */
.toggle-btn.active {
  background-color: var(--color-text);
  color: var(--color-surface);
  border-color: var(--color-text);
}

/* Tab button specific - smaller width for "All" */
.toggle-btn.tab-btn-all {
  min-width: 95px;
  width: 95px;
}

/* Tab button disabled state */
.toggle-btn.tab-disabled {
  /* opacity: .4; */
  pointer-events: none;
  /* filter: brightness(0.5); */
  color: var(--color-muted);
  border-color: var(--color-border);
}

.toggle-btn.plugins-coming-soon {
  color: var(--color-muted);
  border-color: var(--color-border);
  cursor: not-allowed;
}

/* Templates/Components/Creators button overrides */
button#templates-button {
  /* background: none; */
  /* border: none; */
  /* outline: none; */
  /* color: #999; */
  /* cursor: pointer; */
  /* font-size: 16px; */
  /* margin: 0; */
}

button#templates-button.active {
  color: var(--color-text);
}

button#components-button {
  /* color: #999; */
  /* background: none; */
  /* outline: none; */
  /* border: none; */
  /* font-size: 16px; */
  /* cursor: pointer; */
  /* margin: 0; */
}

button#components-button.active {
  color: var(--color-text);
}

button#creators-button {
  /* color: #999; */
  /* background: none; */
  /* outline: none; */
  /* border: none; */
  /* font-size: 16px; */
  /* cursor: pointer; */
}

.data-type-switch .toggle-btn {
  color: var(--color-muted);
  background: none;
  border: none;
  min-width: auto;
  font-size: 16px;
  margin: 0 8px;
}

button#creators-button.active {
  color: var(--color-text);
}

.creators-new-pill {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  padding: 1px 5px;
  border-radius: 4px;
  outline: 1px solid var(--color-border);
  background: var(--pill-bg);
  color: #22c55e;
  font-size: 9px;
  line-height: 1.2;
  letter-spacing: 0.2px;
  pointer-events: none;
  white-space: nowrap;
}

.header-new-pill {
  display: none;
  position: absolute;
  top: 50%;
  bottom: auto;
  right: auto;
  left: -15px;
  transform: translateY(-50%);
  padding: 1px 5px;
  border-radius: 4px;
  outline: 1px solid var(--color-border);
  background: var(--pill-bg);
  color: #22c55e;
  font-size: 9px;
  line-height: 1.2;
  letter-spacing: 0.2px;
  pointer-events: none;
  white-space: nowrap;
  z-index: 12040;
}

.components-table #rankings-table thead th.col-medals .header-new-pill {
  display: inline-flex;
}

/* Category dropdown button */
.category-dropdown-button {
  min-width: 120px;
  width: auto;
  height: 32px;
  background-color: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  padding: 0 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 32px;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  cursor: pointer;
  position: relative;
}

.category-new-pill {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  padding: 1px 5px;
  border-radius: 4px;
  outline: 1px solid var(--color-border);
  background: var(--pill-bg);
  color: #22c55e;
  font-size: 9px;
  line-height: 1.2;
  letter-spacing: 0.2px;
  pointer-events: none;
  white-space: nowrap;
  display: none;
}

.category-dropdown-wrapper.show-component-new-pill .category-new-pill {
  display: inline-block;
}

.category-dropdown-button.active {
  background-color: var(--color-text);
  color: var(--color-surface);
  border-color: var(--color-text);
}

.category-dropdown-button:active {
  opacity: 0.5;
}

.category-dropdown-button:focus,
.category-dropdown-button:focus-visible {
  outline: none;
  box-shadow: none;
}

.category-dropdown-button .dropdown-arrow {
  display: inline-flex;
  align-items: center;
}

.category-clear-btn {
  padding: 10px;
  margin-right: -10px;
  margin-left: -10px;
  cursor: pointer;
  color: inherit;
}

.category-item-all {
  font-weight: 600;
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-border);
}

.category-label-clickable {
  cursor: pointer;
}

.category-item-count {
  color: var(--color-muted);
  font-size: 11px;
}

/* Category dropdown disabled state (Components mode) */
.category-dropdown-wrapper.tab-disabled .category-dropdown-button {
  pointer-events: none;
  color: var(--color-muted);
  border-color: var(--color-border);
}

[data-theme="light"] .toggle-btn.tab-disabled {
  opacity: 0.45;
}

[data-theme="light"] .category-dropdown-wrapper.tab-disabled .category-dropdown-button {
  opacity: 0.45;
}

/* Dropdown panel visibility */

.category-dropdown-panel.open {
  /* display: block; */
  pointer-events: auto;
  opacity: 1;
}

/* Search input styles */

/* Table header sortable column */
.sortable-header {
  border-bottom: 1px dashed var(--color-muted);
}

th.sortable:has(.sort-arrow.active) .sortable-header {
  border-bottom-color: var(--color-text);
}

/* Align all column header content to bottom */
#rankings-table thead th {
  vertical-align: bottom;
  position: sticky;
  top: -1px;
  z-index: 11001;
  background: var(--color-bg);
  overflow: visible;
}

/* Footer link styles */
.footer-link {
  color: var(--color-subtle);
}

/* Checkbox with pointer */
.checkbox-pointer {
  cursor: pointer;
}

/* Label flex row */
.label-flex {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--color-subtle);
}

/* Footer text color */
.footer-text {
  font-size: 0.7rem;
  line-height: 0.9rem;
  color: var(--color-subtle);
  position: relative;
}

/* Category dropdown wrapper */
.category-dropdown-wrapper {
  position: relative;
  z-index: 13100;
  /* transition: all 200ms; */
  /* width: auto; */
  /* min-width: auto; */
  /* overflow: hidden; */
}

.category-dropdown-wrapper.tab-disabled[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 220px;
  padding: 6px 8px;
  border-radius: 6px;
  outline: 1px solid var(--color-border);
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  font-size: 11px;
  line-height: 1.25;
  text-align: center;
  white-space: pre-line;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 13110;
}

.category-dropdown-wrapper.tab-disabled[data-tooltip]:hover::after {
  opacity: 1;
}

@media (max-width: 650px) {
  .category-dropdown-wrapper.tab-disabled[data-tooltip]::after {
    display: none !important;
    content: none !important;
  }
}

.components-mode .category-dropdown-wrapper {
  /* width: 20px; */
  /* min-width: 20px; */
}

/* Table wrapper */
.table-wrapper {
  flex: 1;
}

/* Data type switch (Templates/Components) */
.data-type-switch {
  display: inline-flex;
  margin-top: -5px;
  margin-bottom: 10px;
}

.data-type-switch:before {
  content: "";
  left: 0;
  right: 0;
  height: 1px;
  background: var(--color-border);
  position: absolute;
  margin-top: -10px;
  opacity: 0.5;
}

.data-type-switch:after {
  content: "";
  left: 0;
  right: 0;
  height: 1px;
  background: var(--color-border);
  position: absolute;
  margin-top: 38px;
  opacity: 0.5;
}

/* Media query for width 990px and smaller */
@media (min-width: 1500px) {
  /* Category dropdown panel - positioned below the button */
  .category-dropdown-panel {
    left: auto;
    right: 100%;
    top: 0;
    margin: 0;
    margin-right: 8px;
    box-shadow: none;
  }
}

/* ============================================
   VANILLA CSS UTILITIES (Tailwind Replacement)
   Place at END so utilities cascade last
   ============================================ */

/* Layout */
.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.inline-flex {
  display: inline-flex;
}

.inline-block {
  display: inline-block;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.justify-center {
  justify-content: center;
}

.justify-end {
  justify-content: flex-end;
}

.gap-2 {
  gap: 0.5rem;
}

/* Sizing */
.w-full {
  width: 100%;
}

.w-4 {
  width: 1rem;
}

.h-auto {
  height: auto;
}

.h-4 {
  height: 1rem;
}

.h-8 {
  height: 2rem;
}

.max-w-\[200px\] {
  max-width: 200px;
}

.max-w-\[1000px\] {
  max-width: 1000px;
}

/* Spacing - Margin */
.mx-auto {
  margin-left: auto;
  margin-right: auto;
}

.mt-2 {
  margin-top: 0.5rem;
}

.mb-2 {
  margin-bottom: 0.5rem;
}

.mb-6 {
  margin-bottom: 1.5rem;
}

.my-3 {
  margin-top: 0.75rem;
  margin-bottom: 0.75rem;
}

.ml-1 {
  margin-left: 0.25rem;
}

.-mt-0\.5 {
  margin-top: -0.125rem;
}

/* Spacing - Padding */
.p-1 {
  padding: 0.25rem;
}

.px-4 {
  padding-left: 1rem;
  padding-right: 1rem;
}

.pt-8 {
  padding-top: 2rem;
}

.py-2 {
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.py-4 {
  padding-top: 1rem;
  padding-bottom: 1rem;
}

/* Typography - Size */
.text-xs {
  font-size: 0.8rem;
  line-height: 1rem;
}

.text-lg {
  font-size: 1.125rem;
  line-height: 1.75rem;
}

.text-4xl {
  font-size: 2.25rem;
  line-height: 2.5rem;
}

/* Typography - Alignment */
.text-center {
  text-align: center;
}

.text-left {
  text-align: left;
}

.text-right {
  text-align: right;
}

/* Typography - Weight & Style */
.font-bold {
  font-weight: 700;
}

.font-medium {
  font-weight: 500;
}

.whitespace-nowrap {
  white-space: nowrap;
}

.underline {
  text-decoration: underline;
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
}

/* Colors - Background */
.bg-background {
  background-color: var(--color-bg);
}

/* bg-muted: NOT defined - inherits transparent (matches Tailwind CDN behavior) */

/* Colors - Text */
.text-foreground {
  color: var(--color-text);
}

.text-muted-foreground {
  color: var(--color-muted);
}
.text-gray-400 {
  color: #9ca3af;
}

.text-gray-500 {
  color: #6b7280;
}

/* text-primary: NOT defined - links inherit white from body (matches Tailwind CDN behavior) */
.text-green-600 {
  color: #16a34a;
}

.text-red-600 {
  color: #dc2626;
}

.text-amber-500 {
  color: #f59e0b;
}

.text-lime-400 {
  color: #9ce929;
}

.text-purple-400 {
  color: #a78bfa;
}

/* Borders & Effects */
.border {
  border-width: 1px;
  border-style: solid;
  border-color: var(--color-border);
}

.rounded {
  border-radius: 0.25rem;
}

.rounded-md {
  border-radius: 0.375rem;
}

.rounded-lg {
  border-radius: 0.5rem;
}

.shadow-xs {
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

/* Positioning */
.relative {
  position: relative;
}

.absolute {
  position: absolute;
}

.z-50 {
  z-index: 50;
}

.top-1\/2 {
  top: 50%;
}

.left-\[14px\] {
  left: 14px;
}

.-translate-y-1\/2 {
  transform: translateY(-50%);
}

/* Interactivity */
.cursor-pointer {
  cursor: pointer;
}

.pointer-events-none {
  pointer-events: none;
}

.transition-colors {
  transition-property: color, background-color, border-color;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  transition-duration: 150ms;
}

/* Hover States */
.hover\:text-foreground:hover {
  color: white;
}

.hover\:underline:hover {
  text-decoration: underline;
}

.hover\:bg-muted\/50:hover {
  background-color: rgba(26, 26, 26, 0.5);
}

/* Table row links - dim on hover like category title */
.table-link {
  transition: opacity 0.15s ease;
}

.table-link-underline {
  text-decoration: underline;
}

.table-link:hover {
  opacity: 0.8;
}

.search-row {
  margin-bottom: -2px;
  margin-top: 10px;
}

.search-container {
  z-index: 99999;
}

.mobile-category-slot {
  display: none;
}

input#rankings-search {
  border-radius: 8px;
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 0;
  border-bottom: 0;
  background-color: var(--color-bg);
  padding-left: 40px;
  padding-right: 10px;
  outline: none;
}

.search-container:has(.search-active) svg {
  color: var(--color-text);
}

.search-container:before {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  height: 1px;
  background: var(--color-border);
  bottom: 0;
}

.search-container:has(.search-active):before {
  background: var(--search-active-line);
}

.search-container:after {
  content: "";
  width: 20px;
  height: 20px;
  /* background: var(--color-bg); */
  position: absolute;
  left: -19px;
  bottom: 1px;
  border-bottom-right-radius: 12px;
  border: 1px solid var(--color-border);
  border-top: 0;
  border-left: 0;
  box-shadow: 5px 5px 0px 2px var(--color-bg);
}

/* Crown Icon Styling */
.crown-wrapper {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  gap: 4px;
  padding-right: 8px;
  min-width: 0;
}

.crown-wrapper .table-link {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
}

.thumbnail-image {
  display: block;
  width: 40px;
  height: 30px;
  margin: 0 auto;
  object-fit: cover;
  border-radius: 6px;
}

.thumbnail-placeholder {
  display: block;
  width: 40px;
  height: 30px;
  margin: 0 auto;
  border-radius: 6px;
  border: 1px solid #333;
  background: #1b1b1b;
  color: #8a8a8a;
  font-size: 10px;
  line-height: 30px;
  text-align: center;
}

.crown-icon {
  color: #f4b400;
  margin-left: 2px;
  margin-right: 0;
  flex: 0 0 auto;
}

/* When medals column is hidden (components), keep spacing before creator column */
.components-table .crown-wrapper {
  padding-right: 12px;
}

.crown-with-tooltip {
  display: inline-flex;
  align-items: center;
}

/* Medals Cell Styling */
.medals-cell {
  width: 100px;
  font-size: 12px;
  text-align: left;
  padding: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  position: relative;
  z-index: 1;
}

.medals-cell:hover {
  background: rgba(255, 255, 255, 0.06);
  z-index: 12020;
}

.creators-col-metric {
  width: 110px;
}

.creators-col-name {
  width: 500px;
  min-width: 200px;
  max-width: 500px;
  padding-left: 50px;
}

@media (min-width: 651px) {
  .creators-table #creators-thead-row th.creators-col-metric,
  .creators-table #clusterize-content td.creator-cell-number.creators-col-metric,
  .creators-table #creators-tfoot-row td.creators-col-metric {
    width: 170px;
    min-width: 170px;
    max-width: 170px;
  }
}

.creator-cell-name {
  text-align: left;
  position: relative;
  padding-left: 50px;
}

.creator-cell-number {
  text-align: center;
}

.creators-table td.creator-cell-number {
  white-space: nowrap;
}

.creators-table #clusterize-content td.creator-cell-name,
.creators-table #clusterize-content td.creator-cell-number {
  padding-top: 10px;
  padding-bottom: 10px;
}

/* Creators: keep Name sticky like the main rank column pattern. */
.creators-table #creators-thead-row th.creators-col-name,
.creators-table #clusterize-content td.creator-cell-name.creators-col-name,
.creators-table #creators-tfoot-row td.creators-col-name {
  width: 500px;
  min-width: 200px;
  max-width: 500px;
}

.creators-table #creators-thead-row th.creators-col-name {
  position: sticky;
  left: 0;
  z-index: 12036;
  background: var(--color-bg);
  box-shadow: none;
  border-right: 1px solid var(--color-border);
}

.creators-table #clusterize-content td.creator-cell-name {
  position: sticky;
  left: 0;
  z-index: 9002;
  background: inherit;
  box-shadow: none;
  border-right: 1px solid var(--color-border);
}

.creators-table #creators-tfoot-row td.creators-col-name {
  position: sticky;
  left: 0;
  z-index: 15014;
  background: var(--color-bg);
  box-shadow: none;
  border-right: 1px solid var(--color-border);
}

.creator-avatar-slot {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  min-width: 50px;
  max-width: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.creator-avatar {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  object-fit: cover;
  display: inline-block;
  vertical-align: middle;
}

.creator-avatar-fallback {
  border: 1px solid var(--color-border);
  color: #888;
  font-size: 9px;
  line-height: 18px;
  text-align: center;
}

/* Medal icons */
.medals-cell .with-tooltip {
  display: flex;
  align-items: center;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  padding: 4px 8px;
  cursor: default;
  position: relative;
  z-index: 12021;
}

.medals-summary {
  display: flex;
  width: 100%;
}

.medals-summary .medal-slot {
  flex: 1 1 33.333%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 0;
}

.medals-summary .medal-slot.is-empty {
  opacity: 0;
}

.medals-summary .medal-icon {
  line-height: 1;
  display: inline-flex;
  align-items: center;
}

.medals-summary .medal-count {
  font-size: 10px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}

/* Generic Tooltip System */
.with-tooltip {
  position: relative;
}

.with-tooltip .tooltip {
  position: absolute;
  padding: 0;
  outline: 1px solid var(--color-border);
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  font-size: 11px;
  text-align: left;
  border-radius: 4px;
  display: none;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 14000;
  white-space: nowrap;
  min-width: 120px;
  overflow: visible;
}

/* Position: right */
.with-tooltip .tooltip.right {
  top: 0;
  left: 100%;
  transform: none;
  margin-left: 0;
}

/* Change-column header tooltip: render to the left to avoid clipping by next header cells. */
.change-header-tooltip {
  display: inline-flex;
  position: relative;
}

.change-header-tooltip .tooltip.right {
  left: 100%;
  right: auto;
  margin-left: 8px;
  margin-right: 0;
  top: 0;
  transform: none;
  z-index: 14100;
}

.change-header-tooltip .tooltip.right::before {
  left: -8px;
  right: auto;
}

/* Mobile: disable change-header tooltip on tap */
@media (max-width: 900px) {
  .change-header-tooltip .tooltip {
    display: none !important;
  }

  .price-previous {
    z-index: auto;
  }

  .medals-cell:hover {
    background: transparent;
  }

  .medals-cell .with-tooltip.tooltip-open .tooltip {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }
}

/* Keep the change header above adjacent sticky header cells when tooltip is open. */
#rankings-table thead th.col-change {
  z-index: 12020;
}

/* Hover bridge so moving cursor from medals to tooltip does not close it */
.with-tooltip .tooltip.right::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 0;
  width: 8px;
  height: 100%;
}

.medals-cell .tooltip.right:after {
  content: "";
  position: absolute;
  left: -30px;
  width: 100px;
  height: calc(100% - 40px);
  background: none;
  display: block;
  transform: skew(30deg, 0deg);
  top: 36px;
  z-index: -1;
  max-height: 80px;
}

/* Position: top (default) */
.with-tooltip .tooltip.top,
.with-tooltip .tooltip:not([class*="right"]):not([class*="bottom"]):not([class*="left"]) {
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 8px;
}

/* Position: bottom */
.with-tooltip .tooltip.bottom {
  top: 100%;
  bottom: auto;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 8px;
  margin-bottom: 0;
}

/* Position: left */
.with-tooltip .tooltip.left {
  top: 50%;
  right: 100%;
  bottom: auto;
  left: auto;
  transform: translateY(-50%);
  margin-right: 8px;
}

.crown-with-tooltip .tooltip.left {
  margin-right: 1px;
}

@media (min-width: 901px) {
  .with-tooltip:hover .tooltip {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }
}

/* Tooltip content items */
.with-tooltip .tooltip .tooltip-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
}

.with-tooltip .tooltip button.tooltip-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
  border-radius: 0;
  min-height: 30px;
  padding: 6px 10px;
}

.with-tooltip .tooltip .tooltip-item-text {
  display: inline-flex;
  flex-direction: column;
  gap: 1px;
}

.with-tooltip .tooltip .tooltip-item-main {
  line-height: 1.25;
}

.with-tooltip .tooltip .tooltip-item-sub {
  font-size: 10px;
  color: var(--tooltip-muted);
  line-height: 1.1;
}

.with-tooltip .tooltip button.tooltip-item:hover {
  background: var(--tooltip-hover);
}

/* Medals tooltip rows: center icon/text vertically */
.medals-cell .tooltip button.tooltip-item {
  align-items: center;
}

.with-tooltip .tooltip .tooltip-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--tooltip-muted);
  padding: 6px 10px 4px;
  line-height: 1.2;
}

.with-tooltip .tooltip .tooltip-title .tooltip-title-sub {
  display: inline-block;
  margin-top: 2px;
  color: var(--tooltip-title-sub);
}

/* ============================================ */
/* FEEDBACK MODAL (Premium Glass) */
/* ============================================ */

.floating-feedback-btn {
  position: fixed;
  right: 15px;
  bottom: 15px;
  background: var(--feedback-trigger-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--feedback-trigger-border);
  color: var(--feedback-trigger-text);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 11px;
  text-decoration: none;
  z-index: 9999;
  transition: all 0.2s ease;
  text-transform: none;
  letter-spacing: 0.05em;
  font-weight: 500;
}

.floating-feedback-btn:hover {
  background: var(--feedback-trigger-hover-bg);
  border-color: var(--feedback-trigger-hover-border);
  color: var(--feedback-trigger-hover-text);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--feedback-trigger-hover-shadow);
}

.floating-feedback-btn-footer {
  display: none;
  position: absolute;
  right: auto;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  bottom: auto;
  font-size: 10px;
  text-transform: none;
  padding: 4px 12px;
  background: none;
}

.floating-feedback-btn-footer:hover {
  transform: translate(-50%, -50%);
}

@media (max-width: 1300px) {
  #feedback-trigger {
    display: none;
  }

  .floating-feedback-btn-footer {
    display: inline-block;
  }
}

.feedback-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--feedback-overlay-bg);
  backdrop-filter: blur(8px);
  z-index: 999999999;
  display: none;
  /* JS will set to flex */
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.feedback-overlay.open {
  display: flex !important;
  opacity: 1;
}

.feedback-modal {
  background: var(--feedback-modal-bg);
  border: 1px solid var(--feedback-modal-border);
  box-shadow: 0 8px 32px 0 var(--feedback-modal-shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 16px;
  width: 90%;
  max-width: 450px;
  padding: 24px;
  transform: translateY(20px);
  transition: transform 0.3s ease;
}

.feedback-overlay.open .feedback-modal {
  transform: translateY(0);
}

.feedback-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

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

.feedback-close-btn {
  background: none;
  border: none;
  color: var(--feedback-label-text);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.feedback-close-btn:hover {
  color: var(--feedback-title-text);
}

.feedback-form-group {
  margin-bottom: 16px;
}

.feedback-label {
  display: block;
  font-size: 0.85rem;
  color: var(--feedback-label-text);
  margin-bottom: 6px;
}

.feedback-textarea {
  width: 100%;
  min-height: 120px;
  background: var(--feedback-control-bg);
  border: 1px solid var(--feedback-control-border);
  border-radius: 8px;
  color: var(--feedback-control-text);
  padding: 12px;
  font-size: 0.9rem;
  resize: vertical;
  transition: border-color 0.2s ease;
}

.feedback-textarea:focus {
  outline: none;
  border-color: var(--feedback-control-focus-border);
}

.feedback-prompt {
  font-size: 0.85rem;
  color: var(--feedback-body-text);
  margin-bottom: 20px;
  line-height: 1.4;
}

.feedback-dm-line {
  margin: 24px 0 0;
  text-align: center;
  font-size: 0.85rem;
  color: var(--feedback-body-text);
}

.feedback-dm-line .footer-link {
  margin-left: 3px;
  font-size: 1.15em;
}

.feedback-input {
  width: 100%;
  background: var(--feedback-control-bg);
  border: 1px solid var(--feedback-control-border);
  border-radius: 8px;
  color: var(--feedback-control-text);
  padding: 10px 12px;
  font-size: 0.9rem;
  transition: border-color 0.2s ease;
}

.feedback-input:focus {
  outline: none;
  border-color: var(--feedback-control-focus-border);
}

.feedback-select {
  width: 100%;
  background: var(--feedback-control-bg);
  border: 1px solid var(--feedback-control-border);
  border-radius: 8px;
  color: var(--feedback-control-text);
  padding: 8px 12px;
  font-size: 0.9rem;
  cursor: pointer;
}

.feedback-submit-btn {
  width: 100%;
  background: var(--feedback-submit-bg);
  color: var(--feedback-submit-text);
  border: none;
  border-radius: 8px;
  padding: 12px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 8px;
}

.feedback-submit-btn:hover {
  background: var(--feedback-submit-hover-bg);
  transform: translateY(-1px);
}

.feedback-submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Toast Notification */
.feedback-toast {
  position: fixed;
  bottom: 54px;
  right: -10px;
  background: none;
  color: var(--feedback-toast-text);
  padding: 12px 24px;
  border-radius: 0;
  font-size: 14px;
  font-weight: 600;
  box-shadow: none;
  z-index: 9999999;
  transform: translateX(500px);
  transition: transform 0.4s ease-in-out;
}

.feedback-toast.show {
  transform: translateY(0);
}

.footer-feedback-link {
  margin-right: 12px;
  color: var(--color-muted);
  text-decoration: none;
  font-size: 0.75rem;
  transition: color 0.2s ease;
}

.footer-feedback-link:hover {
  color: #fbbf24;
}

.feedback-honeypot {
  display: none;
}

.medal-rank-1 {
  color: #f4b400;
}

.medal-rank-2 {
  color: #c0c7d1;
}

.medal-rank-3 {
  color: #c97a33;
}

/* Mobile-only density adjustments */
@media (max-width: 650px) {
  #rankings-table-container {
    min-height: 500px;
  }

  .col-name {
    width: 140px;
    min-width: 140px;
  }

  .creators-table #rankings-table,
  .creators-table #clusterize-scroll > table {
    min-width: 490px; /* 100 name + 50 avatar slot + 3*110 metrics */
  }

  .category-tree {
    max-height: 300px;
  }

  /* Prevent desktop slot from reserving space before JS re-parents the dropdown. */
  .filters-row .category-dropdown-wrapper {
    display: none !important;
  }

  .search-row .mobile-category-slot .category-dropdown-wrapper {
    display: block !important;
    visibility: visible !important;
  }

  .search-row {
    justify-content: flex-start;
    align-items: center;
    gap: 8px;
  }

  .search-row .mobile-category-slot {
    display: block;
    flex: 0 0 auto;
    margin-top: -12px;
  }

  .search-row .mobile-category-slot .category-new-pill {
    top: 50%;
    bottom: auto;
    left: auto;
    right: -37px;
    transform: translateY(-50%);
  }

  .search-row .search-container {
    margin-left: auto;
  }

  #table-title-subtitle {
    width: auto;
  }

  #clusterize-content td {
    padding-top: 6px !important;
    padding-bottom: 6px !important;
  }

  .creators-table #clusterize-content td.creator-cell-name,
  .creators-table #clusterize-content td.creator-cell-number {
    padding-top: 10px !important;
    padding-bottom: 10px !important;
  }

  #clusterize-content td.medals-cell {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  .category-item {
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .medals-cell .with-tooltip {
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .creators-table #creators-thead-row th.creators-col-name,
  .creators-table #clusterize-content td.creator-cell-name {
    width: 150px;
    min-width: 150px;
    max-width: 150px;
  }

  .creators-table #creators-thead-row th.creators-col-metric,
  .creators-table #clusterize-content td.creator-cell-number.creators-col-metric {
    width: 100px;
    min-width: 100px;
    max-width: 100px;
  }

  .creators-table #creators-tfoot-row td.creators-col-name {
    width: auto;
    min-width: 0;
    max-width: none;
  }

  .creators-table #creators-tfoot-row td.creators-col-metric {
    width: 100px;
    min-width: 100px;
    max-width: 100px;
  }

  .creators-table #creators-thead-row th.creators-col-name {
    position: sticky;
    left: 0;
    z-index: 12036;
    background: var(--color-bg);
    box-shadow: none;
    border-right: 1px solid var(--color-border);
  }

  .creators-table #clusterize-content td.creator-cell-name {
    position: sticky;
    left: 0;
    z-index: 9002;
    background: inherit;
    padding-right: 10px;
    box-shadow: none;
    border-right: 1px solid var(--color-border);
  }

  .creators-table #creators-tfoot-row td.creators-col-name {
    position: sticky;
    left: 0;
    z-index: 15014;
    background: var(--color-bg);
    box-shadow: none;
    border-right: 1px solid var(--color-border);
  }

  .with-tooltip .tooltip .tooltip-item,
  .with-tooltip .tooltip button.tooltip-item {
    min-height: 36px;
    padding-top: 8px;
    padding-bottom: 8px;
  }
}

/* Below 800px, place category on row 1 and pricing+period on row 2. */
@media (max-width: 799px) {
  .ranks-page-layout p.mb-6 {
    margin-bottom: 1rem !important;
  }

  .category-dropdown-button {
    font-size: 12px;
  }

  .filters-row.rankings-container {
    flex-direction: row !important;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: flex-start !important;
    margin-top: 2px !important;
    row-gap: 8px;
    column-gap: 8px;
  }

  .filters-row .filters-left {
    display: contents;
  }

  .filters-row .category-dropdown-wrapper {
    order: 1;
    flex: 0 0 100%;
    margin-top: 0;
    margin-bottom: 3px;
  }

  .filters-row #ranking-tabs {
    order: 2;
    gap: 6px;
    margin-top: 2px;
  }

  .filters-row #period-toggle {
    order: 3;
    margin-left: auto;
    gap: 6px;
    margin-top: 2px;
  }

  .filters-row #ranking-tabs .toggle-btn,
  .filters-row #period-toggle .toggle-btn {
    min-width: 84px;
    height: 28px;
    line-height: 28px;
    font-size: 12px;
    padding: 0 8px;
    border-radius: 7px;
  }

  .filters-row #ranking-tabs .toggle-btn.tab-btn-all {
    min-width: 84px;
    width: auto;
  }
}

@media (max-width: 500px) {
  .data-type-switch .toggle-btn {
    margin: 0 4px;
  }

  .table-title-section {
    padding: 12px;
  }

  #marketplace-link,
  .table-title-main .category-title-link {
    display: block;
  }

  .filters-row #ranking-tabs,
  .filters-row #period-toggle {
    gap: 4px;
  }

  .filters-row #ranking-tabs .toggle-btn,
  .filters-row #period-toggle .toggle-btn {
    min-width: 60px;
    width: 60px;
    min-height: 36px;
    height: auto;
    line-height: 1.05;
    padding: 5px 6px;
    white-space: normal;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
  }

  .filters-row #ranking-tabs .toggle-btn.tab-btn-all {
    min-width: 60px;
    width: 60px;
  }
}
