:root {
  --bg: #0b0b0c;
  --panel: #141418;
  --text: #e8e8f0;
  --muted: #a3a3ad;
  --accent: #7c5cff;
  --border: #22222a;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif; }

.topbar { display: flex; align-items: center; gap: 16px; padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: rgba(11,11,12,0.9); backdrop-filter: blur(6px); z-index: 1000; }
.topbar h1 { margin: 0; font-size: 18px; font-weight: 600; }
.topbar .brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 18px; }
.topbar .brand .logo { width: 28px; height: 28px; border-radius: 6px; object-fit: cover; }
.quick-filters { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.quick-filters .chip-wrap { position: relative; display: inline-flex; align-items: center; }
.quick-filters .chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--panel); color: var(--text); text-decoration: none; font-size: 13px; }
.quick-filters .chip:hover { filter: brightness(1.1); }
.quick-filters .chip.active { background: var(--accent); border-color: var(--accent); color: white; }
.quick-filters .chip-reset { position: absolute; top: -6px; right: -6px; width: 16px; height: 16px; border-radius: 50%; background: #ff4d6d; color: white; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; line-height: 1; text-decoration: none; border: 1px solid rgba(0,0,0,0.4); box-shadow: 0 2px 6px rgba(0,0,0,0.35); }
.quick-filters .chip-reset:hover { filter: brightness(1.1); }
.controls { display: flex; gap: 8px; align-items: center; margin-left: 8px; }
.controls input[type="text"], .controls select, .controls input[type="number"] { padding: 8px 10px; background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 8px; }
.controls button { padding: 8px 12px; background: var(--accent); color: white; border: none; border-radius: 8px; cursor: pointer; }
.controls .btn-clear-top { padding: 8px 10px; color: #ffb3c1; text-decoration: none; border: 1px solid var(--border); border-radius: 8px; background: #2a1a22; }
.controls .btn-clear-top:hover { filter: brightness(1.1); }

/* Mobile-only Filters toggle button (hidden on desktop) */
.btn-filters { display: none; padding: 8px 12px; background: #333342; color: white; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }

.filters { padding: 16px; border-bottom: 1px solid var(--border); }
.filters h2 { margin-top: 0; font-size: 16px; }
.filter-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.filter-row select { padding: 8px 10px; background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 8px; }
.filter-row button { padding: 6px 10px; background: #333342; color: white; border: none; border-radius: 8px; cursor: pointer; }
.filter-actions { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.filter-actions .reset { color: var(--muted); text-decoration: none; }

.gallery { padding: 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 220px)); gap: 12px; justify-content: start; align-content: start; align-items: start; }
.search-summary { grid-column: 1 / -1; margin-bottom: 4px; color: var(--muted); }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; height: 310px; position: relative; }
.image-wrap { position: relative; overflow: hidden; }
.card img { width: 100%; height: 220px; object-fit: cover; background: #0f0f12; display: block; }
/* Smooth zoom on hover */
.card .image-wrap img { transition: transform 200ms ease; transform-origin: center; will-change: transform; }
.card:hover .image-wrap img { transform: scale(1.06); }
.card .meta { padding: 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card .title { font-size: 14px; font-weight: 600; }
.card .rank-badge { position: absolute; top: 8px; right: 8px; font-size: 12px; color: white; padding: 4px 8px; border-radius: 999px; border: 1px solid var(--border); font-weight: 600; box-shadow: 0 2px 8px rgba(0,0,0,0.35); }

/* Colors for ranks */
.card .rank-badge.gold { background: linear-gradient(135deg, #f4d03f, #f5b041); border-color: #e0b90f; color: #1b1b1f; }
.card .rank-badge.silver { background: linear-gradient(135deg, #bdc3c7, #95a5a6); border-color: #aeb6bf; color: #16161a; }
.card .rank-badge.bronze { background: linear-gradient(135deg, #cd7f32, #b87333); border-color: #a05a2c; color: #1a1a1e; }

/* 4-10: Royal purple */
.card .rank-badge.tier-4-10 { background: #6c5ce7; border-color: #5a4ad6; }
/* 11-100: Teal */
.card .rank-badge.tier-11-100 { background: #00b894; border-color: #00a383; }
/* 101-500: Blue gray */
.card .rank-badge.tier-101-500 { background: #546e7a; border-color: #455a64; }
/* 501-999: Muted slate */
.card .rank-badge.tier-501-999 { background: #2f3542; border-color: #252b36; }
.card .right-meta { display: inline-flex; align-items: center; gap: 6px; }
.card .club-icons { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; }
.card .club-icon { width: 18px; height: 18px; border-radius: 4px; border: 1px solid var(--border); object-fit: cover; background: #0f0f12; }
.card .details { font-size: 12px; color: white; background: var(--accent); padding: 6px 10px; border-radius: 8px; text-decoration: none; border: 1px solid var(--accent); }
.card .details:hover { filter: brightness(1.05); }

/* Fixed position of club icons at bottom-right, slightly inset */
.card .club-icons-fixed {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Price row under meta */
.price-row { display: flex; align-items: center; gap: 8px; padding: 0 10px 10px 10px; }
.price-row.sold { position: absolute; left: 0; right: 0; bottom: 8px; padding: 0 10px; }
.price-row .token-icon { width: 18px; height: 18px; border-radius: 4px; object-fit: cover; border: 1px solid var(--border); background: #0f0f12; }
.price-row .price-values { display: flex; flex-direction: column; line-height: 1.1; }
.price-row .price-token { font-size: 13px; font-weight: 600; }
.price-row .price-usd { font-size: 12px; color: var(--muted); }

/* Subtle caption for sold rows */
.price-row .price-values.sold { line-height: 1; }
.price-row .price-values.sold .price-inline { font-size: 12px; color: var(--muted); white-space: nowrap; }

.pagination { display: flex; gap: 6px; padding: 12px 16px; justify-content: center; grid-column: 1 / -1; align-items: center; flex-wrap: wrap; }
.pagination a, .pagination span { padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel); color: var(--text); text-decoration: none; }
.pagination .current { background: var(--accent); border-color: var(--accent); color: white; }
.pagination .disabled { opacity: 0.5; }
.pagination .ellipsis { border: none; background: transparent; padding: 0 4px; }

/* Layout with left sidebar */
.layout { display: grid; grid-template-columns: 280px 1fr; gap: 16px; }
.sidebar { padding: 16px; border-right: 1px solid var(--border); position: sticky; top: 56px; height: calc(100vh - 56px); overflow: auto; }
.sidebar h2 { margin: 0 0 2px 0; font-size: 16px; }
.sidebar .sidebar-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.sidebar .clear-all { font-size: 12px; color: #ffb3c1; text-decoration: none; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; background: #2a1a22; white-space: nowrap; }
.sidebar .clear-all:hover { filter: brightness(1.1); }
.hidden { display: none !important; }

.facet-group { border: 1px solid var(--border); background: var(--panel); border-radius: 10px; margin-bottom: 10px; }
/* Make the summary a 4-column grid: title | badge | count | chevron */
.facet-group summary { list-style: none; cursor: pointer; padding: 10px 12px; display: grid; grid-template-columns: 1fr max-content minmax(2ch, 3ch) auto; align-items: center; column-gap: 8px; }
.facet-group summary::marker { display: none; }
.facet-group summary::after { content: '▾'; color: var(--muted); transition: transform 0.2s ease; grid-column: 4; justify-self: end; }
.facet-group[open] summary::after { transform: rotate(-180deg); }
.facet-group .facet-title { font-weight: 600; grid-column: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Right-align and fix a column width for the count so numbers line up */
.facet-group .facet-count { color: var(--muted); font-size: 12px; grid-column: 3; justify-self: end; min-width: 3ch; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.facet-group[open] { border-color: #2a2a33; }

/* Selected badge showing chosen values per category */
.facet-selected-badge {
  grid-column: 2;
  justify-self: end;
  background: #1f7a3b;
  color: #eafff1;
  border: 1px solid #185d2d;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
}

.facet-search { padding: 0 12px 8px 12px; }
.facet-search-input { width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: #0f0f12; color: var(--text); }

.facet-values { margin: 0; padding: 0 8px 10px 8px; list-style: none; max-height: 220px; overflow: auto; }
.facet-values li { padding: 6px 4px; }
.facet-values label { display: flex; align-items: center; gap: 8px; }
.facet-values .val { flex: 1 1 auto; }
/* Right-align counts and give a fixed character width so they line up */
.facet-values .cnt { color: var(--muted); min-width: 3ch; text-align: right; font-variant-numeric: tabular-nums; }

.facet-actions { display: flex; gap: 8px; align-items: center; padding: 8px 0; }
.facet-actions button { padding: 8px 12px; background: var(--accent); color: white; border: none; border-radius: 8px; cursor: pointer; }
.facet-actions .reset { color: var(--muted); text-decoration: none; }
/* Centered variant for the top rarity button */
.sidebar .facet-actions.center { justify-content: center; }

/* Flashy rarity button */
#btn-sort-rarity.btn-flashy {
  background: linear-gradient(135deg, #ff7af5, #7c5cff 40%, #00d1ff);
  color: #0b0b0c;
  font-weight: 800;
  letter-spacing: 0.2px;
  text-shadow: 0 1px 0 rgba(255,255,255,0.2);
  box-shadow: 0 6px 18px rgba(124,92,255,0.35), inset 0 0 0 1px rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.2);
}
#btn-sort-rarity.btn-flashy:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}
#btn-sort-rarity.btn-flashy:active {
  transform: translateY(0);
  filter: brightness(0.98);
}

@media (max-width: 960px) {
  /* Topbar stacks neatly */
  .topbar { flex-wrap: wrap; gap: 10px; }
  .topbar .brand { font-size: 16px; }
  .btn-filters { display: inline-flex; }
  .quick-filters { order: 3; width: 100%; margin-left: 0; gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 6px; }
  .quick-filters::-webkit-scrollbar { display: none; }
  .controls { order: 2; width: 100%; margin-left: 0; flex-wrap: wrap; gap: 6px; }
  .controls input[type="text"], .controls select, .controls input[type="number"] { flex: 1 1 160px; width: 100%; }
  .controls button, .controls .btn-clear-top { flex: 1 1 auto; }

  /* Layout switches to 1 column, sidebar becomes drawer */
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; position: fixed; top: calc(56px + env(safe-area-inset-top, 0px)); left: 0; right: 0; bottom: 0; background: rgba(11,11,12,0.98); border-right: none; border-top: 1px solid var(--border); padding: 16px; height: auto; overflow: auto; z-index: 1001; }
  .sidebar.open { display: block; }

  /* Denser facet UI on mobile */
  .facet-group summary { padding: 10px; grid-template-columns: 1fr max-content minmax(2ch, 3ch) auto; }
  .facet-values { max-height: 240px; }

  /* Gallery cards fit small screens */
  .gallery { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; padding: 12px; }
  .card { height: auto; }
  .card img { height: auto; aspect-ratio: 1 / 1; }
  .card .meta { padding: 8px; }
  .card .title { font-size: 13px; }
  .card .details { padding: 6px 8px; font-size: 12px; }
  .price-row { padding: 0 8px 10px 8px; }
  .price-row.sold { position: static; padding: 0 8px 8px 8px; }
}

@media (max-width: 420px) {
  .gallery { grid-template-columns: repeat(2, 1fr); }
}

/* ===================== */
/* Detail page styling   */
/* ===================== */
.detail-layout { padding: 16px; }
.detail-card { display: grid; grid-template-columns: minmax(260px, 520px) 1fr; gap: 20px; align-items: start; }

.detail-media { position: sticky; top: 72px; align-self: start; }
.detail-image { width: 100%; height: auto; border-radius: 14px; border: 1px solid var(--border); background: #0f0f12; display: block; box-shadow: 0 8px 30px rgba(0,0,0,0.35); }
.detail-media .detail-actions { margin-top: 12px; }
.detail-media .detail-market { margin-top: 8px; }
.detail-media .detail-market-row { margin-top: 12px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.detail-media .detail-market-row .price-row { padding: 8px 10px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; }
.detail-rank-badge { position: absolute; top: 12px; right: 12px; font-size: 13px; color: white; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--border); font-weight: 700; box-shadow: 0 2px 10px rgba(0,0,0,0.4); }
.detail-rank-badge.gold { background: linear-gradient(135deg, #f4d03f, #f5b041); border-color: #e0b90f; color: #1b1b1f; }
.detail-rank-badge.silver { background: linear-gradient(135deg, #bdc3c7, #95a5a6); border-color: #aeb6bf; color: #16161a; }
.detail-rank-badge.bronze { background: linear-gradient(135deg, #cd7f32, #b87333); border-color: #a05a2c; color: #1a1a1e; }
.detail-rank-badge.tier-4-10 { background: #6c5ce7; border-color: #5a4ad6; }
.detail-rank-badge.tier-11-100 { background: #00b894; border-color: #00a383; }
.detail-rank-badge.tier-101-500 { background: #546e7a; border-color: #455a64; }
.detail-rank-badge.tier-501-999 { background: #2f3542; border-color: #252b36; }

.detail-info { display: flex; flex-direction: column; gap: 16px; }
.detail-title { margin: 0; font-size: 28px; line-height: 1.15; letter-spacing: 0.2px; }
.detail-title small { color: var(--muted); font-weight: 600; }

.detail-rarity { color: var(--muted); font-size: 14px; }

.btn-primary { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 10px; background: var(--accent); border: 1px solid var(--accent); color: white; text-decoration: none; font-weight: 700; box-shadow: 0 6px 18px rgba(124,92,255,0.35), inset 0 0 0 1px rgba(255,255,255,0.08); }
.btn-primary:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); filter: brightness(0.98); }

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

.detail-market { display: grid; gap: 8px; }
.detail-market .price-row { padding: 10px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; }

.attributes { margin-top: 8px; }
.attributes h2 { font-size: 16px; margin: 0 0 8px 0; color: var(--muted); letter-spacing: 0.3px; }
.attr-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.attr-item { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 10px; display: grid; grid-template-columns: 1fr; gap: 4px; }
.attr-item .trait { font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: 0.5px; }
.attr-item .value { font-size: 14px; font-weight: 700; }

@media (max-width: 960px) {
  .detail-card { grid-template-columns: 1fr; }
  .detail-media { position: static; }
}


