/* ============================================================
   PS99Hub — dark-first, teal-brand, finance/trading aesthetic
   (modeled on the layered-navy-surface look of ps99rap.com).
   Teal is the brand accent; green/red are strictly semantic
   (rising / falling); pink/red tags mark Huge/Titanic rarity.
   ============================================================ */

:root {
  --bg: #0b1220;
  --bg-elevated: #0f172a;
  --bg-elevated-2: #151f36;
  --bg-hover: #1c2742;
  --bg-inset: #070d19;
  --ink: #f1f5fb;
  --ink-dim: #c2ccdc;
  --ink-faint: #8a94a8;
  --accent: #46ddda;
  --accent-ink: #062927;
  --rising: #4ade80;
  --falling: #f87171;
  --rule: rgba(255, 255, 255, 0.06);
  --rule-strong: rgba(255, 255, 255, 0.12);
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.4), 0 12px 32px -16px rgba(0, 0, 0, 0.6);

  --rarity-huge: #ec4899;
  --rarity-titanic: #f43f5e;
  --rarity-gargantuan: #a855f7;
  --rarity-exclusive: #46ddda;

  --font-display: "Outfit", "Segoe UI", system-ui, sans-serif;
  --font-body: "Outfit", -apple-system, "Segoe UI", system-ui, sans-serif;
  --font-mono: "Outfit", "Segoe UI", system-ui, sans-serif;
}

/* Light theme kept only as an explicit opt-in; the site is dark-first. */
:root[data-theme="light"] {
  --bg: #f4f6fa; --bg-elevated: #ffffff; --bg-elevated-2: #eaeef6; --bg-hover: #dfe6f2; --bg-inset: #ffffff;
  --ink: #131b2c; --ink-dim: #47536b; --ink-faint: #7c869c;
  --accent: #0e9490; --accent-ink: #eafffe;
  --rising: #15803d; --falling: #b91c1c;
  --rule: rgba(19, 27, 44, 0.09); --rule-strong: rgba(19, 27, 44, 0.16);
  --shadow: 0 1px 0 rgba(19, 27, 44, 0.03), 0 12px 32px -18px rgba(19, 27, 44, 0.25);
}

* { box-sizing: border-box; }

/* form controls don't inherit fonts by default - force Outfit everywhere */
button, select, input, textarea { font-family: var(--font-body); }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  margin: 0;
  min-height: 100vh;
}

.shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 2rem;
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
}
.wordmark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
  display: flex;
  align-items: baseline;
  gap: 0.15rem;
}
.wordmark .accent { color: var(--accent); }
.tabs { display: flex; gap: 0.25rem; margin-left: auto; }
.tabs a {
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-dim);
  text-decoration: none;
  padding: 0.5rem 0.85rem;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
}
.tabs a:hover { color: var(--ink); background: var(--bg-elevated-2); }
.tabs a.active {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 40%, transparent);
}

/* ---------- headings ---------- */
h1.page-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.015em;
  text-wrap: balance;
  margin: 0 0 0.35rem;
}
.page-sub {
  color: var(--ink-dim);
  font-size: 0.95rem;
  margin: 0 0 2rem;
}
.page-sub a { color: var(--ink-dim); }

/* ---------- ticker ---------- */
.ticker-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--bg-elevated);
  margin: 1.25rem 0 2.5rem;
  padding: 0.6rem 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
/* Closes the dead gap between the ticker and the hero's glow - the glow
   should read as almost touching the ticker, not floating well below it. */
.ticker-wrap:has(+ .drops-hero) { margin-bottom: 0.75rem; }
.ticker-wrap::-webkit-scrollbar { display: none; }
.ticker-track {
  display: flex;
  width: max-content;
}
.ticker-item {
  display: inline-flex;
  align-items: baseline;
  gap: 0.45rem;
  padding: 0 1.5rem;
  font-size: 0.85rem;
}
.ticker-label { color: var(--ink-faint); font-weight: 600; }
.ticker-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  font-weight: 600;
}
.ticker-sep { color: var(--rule-strong); padding: 0 0.5rem; }

/* ---------- hero stat strip (home) ---------- */
.hero {
  padding: 2.5rem 0 3rem;
}
.hero-with-mascot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}
.hero-with-mascot p { margin-bottom: 0; }
.mascot {
  width: 96px;
  height: 96px;
  border-radius: 16px;
  flex-shrink: 0;
  object-fit: cover;
  box-shadow: var(--shadow);
}
@media (max-width: 640px) {
  .hero-with-mascot { flex-direction: column; align-items: flex-start; }
}
.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 4vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  text-wrap: balance;
  margin: 0 0 0.6rem;
}
.hero p {
  color: var(--ink-dim);
  font-size: 1.05rem;
  max-width: 42ch;
  margin: 0 0 2rem;
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 2.5rem;
}
.stat {
  background: var(--bg-elevated);
  padding: 1.1rem 1.25rem;
}
.stat .label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.stat .value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--accent);
  margin-top: 0.2rem;
}

/* ---------- odometer/split-flap number tick (hubTickText) ---------- */
.index-value, .stat .value { perspective: 240px; }
.tick-char {
  display: inline-block;
  white-space: pre;
  transform-origin: 50% 100%;
}
/* rotateX needs a `perspective` on an ancestor (added above) to actually
   render as a 3D flip - without it the rotation just looks like a subtle
   vertical squish, which read as "barely moving". */
.tick-flip { animation: tickFlip 0.65s cubic-bezier(.34,1.5,.4,1); }
@keyframes tickFlip {
  0%   { transform: translateY(-120%) rotateX(110deg); opacity: 0; }
  50%  { transform: translateY(14%) rotateX(-25deg); opacity: 1; }
  75%  { transform: translateY(-4%) rotateX(8deg); }
  100% { transform: translateY(0) rotateX(0); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .tick-flip { animation: none; }
}

/* ---------- feature panels (home) ---------- */
.panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}
.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 1.5rem;
  text-decoration: none;
  color: var(--ink);
  box-shadow: var(--shadow);
  transition: border-color 0.15s, transform 0.15s;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.panel:hover { border-color: var(--rule-strong); transform: translateY(-2px); }
.panel .glyph {
  width: 2.25rem; height: 2.25rem;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}
.panel h3 { font-family: var(--font-display); font-size: 1.05rem; margin: 0.25rem 0 0; }
.panel p { color: var(--ink-dim); font-size: 0.88rem; margin: 0; line-height: 1.4; }

/* ---------- account status card ---------- */
.account-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 1.1rem 1.4rem;
  margin-bottom: 2.5rem;
}
.account-card .label { font-size: 0.8rem; color: var(--ink-dim); }
.account-card .who { font-family: var(--font-mono); font-weight: 600; margin-top: 0.15rem; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.1rem;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 0.9rem;
  text-decoration: none;
  white-space: nowrap;
  transition: filter 0.15s;
}
.btn:hover { filter: brightness(1.08); }
.btn-outline {
  background: transparent; color: var(--ink);
  border: 1px solid var(--rule-strong);
}
.btn-outline:hover { background: var(--bg-elevated-2); filter: none; }

/* ---------- "this week's drops" hero (matches db.biggames.io's homepage) ---------- */
.drops-hero {
  position: relative;
  overflow: hidden;
}
.drops-hero-inner {
  display: flex; align-items: center; justify-content: space-between; gap: 2.5rem;
  /* Right padding pulls the art box off the section's clip edge - without
     it the art box's own right edge sits flush against the hero's
     overflow:hidden boundary, leaving the glow zero room to fade before
     getting hard-clipped there. */
  padding: 1.25rem 8rem 1.75rem 0;
}
.drops-hero-text {
  /* Without this, the text column couldn't shrink below its content's
     natural width in the flex layout - at viewports where it doesn't fit
     next to the fixed-width art box, it (and everything in it) would
     overflow. That used to just be visible overflow (ugly but present);
     once overflow:hidden was added to contain the glow, the same overflow
     silently clipped the whole title/buttons out of view instead. */
  min-width: 0;
  position: relative; z-index: 1;
}
.drops-eyebrow {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-size: 0.72rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase;
  color: #f2a93b; text-decoration: none;
}
.drops-eyebrow::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #f2a93b; }
.drops-eyebrow:hover { text-decoration: underline; }
.drops-title {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(2.6rem, 5vw, 4.2rem);
  letter-spacing: -0.02em; line-height: 1.02;
  margin: 0.5rem 0 0.9rem;
}
.drops-sub { color: var(--ink-dim); font-size: 1rem; max-width: 38ch; margin: 0 0 1.6rem; }
.drops-cta { display: flex; gap: 0.75rem; flex-wrap: wrap; }
/* Exact structure/sizing pulled from db.biggames.io's compiled JS: a big
   aspect-square area (max 34rem), no boxes/borders anywhere - just raw
   pet art floating over a blurred glow copy of the featured pet. */
.drops-hero-art {
  position: relative; z-index: 1;
  width: 100%; max-width: 34rem; aspect-ratio: 1;
  margin: 0 auto; flex: none;
  /* Not clipped here - the glow needs room beyond this box to fade
     smoothly. It's clipped by .drops-hero's own overflow:hidden instead,
     which is generously larger (the whole section), so the fade always
     completes well before hitting that boundary. */
}
@media (max-width: 900px) {
  .drops-hero-inner { flex-direction: column; padding-right: 0; }
  /* The 430px/295px ellipse (and the 8rem right-padding trick that gives it
     room) was tuned for the desktop side-by-side layout, where the art box
     sits well right-of-center with a wide section to fade into. In the
     stacked mobile layout the art box is centered and full-width instead,
     often narrower than 430px on its own - the mask never got a chance to
     reach transparent before hitting the section's clip edge, so the right
     side looked hard-cut instead of faded. Scaled down to fit. */
  .drops-glow-bg {
    -webkit-mask-image: radial-gradient(ellipse 150px 190px at center, #000 18%, transparent 100%);
    mask-image: radial-gradient(ellipse 150px 190px at center, #000 18%, transparent 100%);
  }
}
.drops-glow-bg {
  /* Centered (was left:49%/top:41%, off-center enough that the fade ran
     out of room on top before it could complete, while the bottom - with
     more margin - looked fine: an asymmetric cutoff, not a real gradient).
     Sized generously since it's now only clipped by the whole section
     (.drops-hero), not the small art box, so there's real room to be big
     and still fade out completely before hitting any edge. */
  position: absolute; left: 50%; top: 50%;
  width: 300%; height: 300%;
  transform: translate(-50%, -50%);
  object-fit: contain;
  filter: saturate(150%) blur(50px);
  opacity: 0.75;
  pointer-events: none;
  /* Wider than tall on purpose: the right-side padding on .drops-hero-inner
     gives real horizontal room to fade into, but top/bottom room is capped
     by how tight the hero section's own padding is (kept small so the glow
     reads as almost touching the ticker/stat-strip). An ellipse uses each
     budget independently instead of being capped by whichever is smaller. */
  -webkit-mask-image: radial-gradient(ellipse 380px 295px at center, #000 18%, transparent 100%);
  mask-image: radial-gradient(ellipse 380px 295px at center, #000 18%, transparent 100%);
}
.drops-featured-wrap {
  position: absolute; left: 49%; top: 41%;
  width: 64%; height: 64%;
  margin-left: -32%; margin-top: -32%;
  /* Real site applies the same float animation to the featured pet's
     wrapper as the satellites - it bounces too, not just orbits it.
     Exact values pulled from its live inline style (not a guess): much
     gentler than the satellite defaults, since it's a much bigger element
     and the same drift % would move far more pixels. */
  --float-duration: 14s; --float-delay: 0s;
  --drift-x: -1.2%; --drift-y: -3.5%; --wobble: 1.2deg;
  animation: home-hero-float var(--float-duration) ease-in-out var(--float-delay) infinite;
}
.drops-featured-img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 20px 45px rgba(0,0,0,0.55)); transition: transform 0.3s ease; }
.drops-featured-wrap:hover .drops-featured-img { transform: scale(1.04); }
/* Exact animation pulled from db.biggames.io's own compiled CSS/JS (not a
   guess): asymmetric drift+wobble via 33%/66% keyframe stops, driven by
   per-tile CSS custom properties computed with their exact formulas. */
@keyframes home-hero-float {
  0% { transform: translate(0) rotate(0); }
  33% { transform: translate(var(--drift-x, 1.5%), calc(var(--drift-y, -6%) * 0.6)) rotate(var(--wobble, 2deg)); }
  66% { transform: translate(calc(var(--drift-x, 1.5%) * -0.6), var(--drift-y, -6%)) rotate(calc(var(--wobble, 2deg) * -1)); }
  100% { transform: translate(0) rotate(0); }
}
.drops-mystery {
  position: absolute;
  display: flex; align-items: center; justify-content: center;
  will-change: transform;
  cursor: pointer;
  animation: home-hero-float var(--float-duration, 7s) ease-in-out var(--float-delay, 0s) infinite;
}
.drops-mystery > img:not(.tier-crown):not(.tier-rank) {
  /* Matches db.biggames.io's real markup exactly (confirmed from their
     live DOM): the pet art is flex-centered with max-height/max-width 82%,
     not full-bleed - filling 100% made ours look larger/more cropped. */
  max-width: 82%; max-height: 82%; width: auto; height: auto; object-fit: contain;
  filter: drop-shadow(0 6px 12px rgba(0,0,0,0.4));
  transition: transform 0.3s ease;
}
.drops-mystery .tier-crown, .drops-mystery .tier-rank { transition: transform 0.3s ease; }
/* Badges are separate <img> elements positioned over the pet, not baked
   into it - without their own hover transform they stayed put while the
   pet scaled/rotated underneath them, making them look detached. */
.drops-mystery:hover > img:not(.tier-crown):not(.tier-rank),
.drops-mystery:hover .tier-crown,
.drops-mystery:hover .tier-rank {
  transform: rotate(var(--rot, 0deg)) scale(1.1);
}
/* Their real site ignores prefers-reduced-motion for this decorative
   float (confirmed: it kept animating with the OS setting off) - matching
   that instead of disabling it, since that setting was the actual root
   cause of "not moving" this whole time. */

/* Scroll-reveal transition from the hero into the rest of the landing page */
.reveal-pre { opacity: 0; transform: translateY(28px); transition: opacity 0.6s ease-out, transform 0.6s ease-out; }
.reveal-in { opacity: 1; transform: translateY(0); }
@media (prefers-reduced-motion: reduce) {
  .reveal-pre { opacity: 1; transform: none; transition: none; }
}

/* ---------- data table ---------- */
.data-card {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
/* Real entrance/hover animations pulled from db.biggames.io's compiled
   CSS - table rows fade+slide in when they render or refresh, and cards
   lift slightly on hover, instead of just appearing/sitting static. */
@keyframes leaderboardRowIn {
  0% { opacity: 0; transform: translateY(4px); }
  100% { opacity: 1; transform: translateY(0); }
}
.row-fade-in { animation: leaderboardRowIn 0.36s cubic-bezier(.22,1,.36,1) both; }
.card-hover { transition: transform 0.2s ease, box-shadow 0.2s ease; }
.card-hover:hover { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(99, 102, 241, 0.15); }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 480px; }
thead th {
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--rule-strong);
  background: var(--bg-elevated-2);
}
tbody td {
  padding: 0.75rem 1.1rem;
  border-bottom: 1px solid var(--rule);
  font-size: 0.92rem;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-elevated-2); }
tbody tr.clickable { cursor: pointer; }
td.num, th.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
td.rank { width: 2.5rem; }

.medal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem; height: 1.6rem;
  border-radius: 50%;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-faint);
}
.medal.r1 { background: color-mix(in srgb, var(--accent) 30%, transparent); color: var(--accent); }
.medal.r2 { background: color-mix(in srgb, var(--ink) 16%, transparent); color: var(--ink-dim); }
.medal.r3 { background: color-mix(in srgb, var(--falling) 18%, transparent); color: color-mix(in srgb, var(--falling) 70%, var(--ink)); }

.search-input {
  width: 100%;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--bg-inset);
  border: 1px solid var(--rule-strong);
  border-radius: 10px;
  padding: 0.7rem 0.9rem;
  margin-bottom: 1.25rem;
}
.search-input::placeholder { color: var(--ink-faint); }
.search-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.range-toggle {
  display: inline-flex;
  background: var(--bg-elevated-2);
  border-radius: 8px;
  padding: 0.2rem;
  gap: 0.15rem;
}
.range-toggle button {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-dim);
  background: none;
  border: none;
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
}
.range-toggle button.active { background: var(--accent); color: var(--accent-ink); }
.range-toggle button:hover:not(.active) { color: var(--ink); }

.tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  background: var(--bg-elevated-2);
  color: var(--ink-dim);
}

/* ---------- loading / empty ---------- */
#loading {
  color: var(--ink-faint);
  padding: 3rem 0;
  text-align: center;
  font-size: 0.9rem;
}

/* ---------- focus & motion ---------- */
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  .panel { transition: none; }
}

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 0.75rem; }
  .tabs { margin-left: 0; }
}

/* ---------- homepage sections (movers + leaderboard snapshot) ---------- */
.section-head {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin: 2.25rem 0 0.9rem;
}
.section-head h2 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin: 0;
}
.section-sub { color: var(--ink-faint); font-size: 0.82rem; }

.movers-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.preview-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
@media (max-width: 900px) {
  .movers-grid, .preview-grid { grid-template-columns: 1fr; }
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.7rem 1rem;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  border-bottom: 1px solid var(--rule);
  background: var(--bg-elevated-2);
}
.card-head.gain { color: var(--rising); }
.card-head.loss { color: var(--falling); }
.view-all { font-size: 0.75rem; font-weight: 500; color: var(--accent); text-decoration: none; }
.view-all:hover { text-decoration: underline; }

.mini-table { min-width: 0; table-layout: fixed; }
.mini-table td {
  padding: 0.45rem 1rem;
  font-size: 0.82rem;
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mini-table tr:last-child td { border-bottom: none; }
.mini-table td.rank { width: 2.6rem; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.mini-table td.num { width: 6.2rem; text-align: right; font-variant-numeric: tabular-nums; font-family: var(--font-mono); font-size: 0.78rem; }
.mini-table a { color: var(--ink); text-decoration: none; }
.mini-table a:hover { color: var(--accent); }
.num.gain { color: var(--rising); }
.num.loss { color: var(--falling); }

/* ---------- items page filter bar ---------- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
}
.filter-bar select {
  background: var(--bg-elevated);
  color: var(--ink);
  border: 1px solid var(--rule-strong);
  border-radius: 10px;
  padding: 0.5rem 0.7rem;
  font-size: 0.82rem;
  font-family: var(--font-body);
}

/* ---------- market index panels ---------- */
.index-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
@media (max-width: 1000px) { .index-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px)  { .index-grid { grid-template-columns: 1fr; } }

.index-panel { padding: 0.9rem 1rem; position: relative; }
.index-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  margin-bottom: 0.3rem;
}
.index-value {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.index-value.gain { color: var(--rising); }
.index-value.loss { color: var(--falling); }
.index-delta { font-size: 0.75rem; margin-top: 0.15rem; font-variant-numeric: tabular-nums; }
.index-delta.gain { color: var(--rising); }
.index-delta.loss { color: var(--falling); }

.spark { position: relative; height: 56px; margin-top: 0.6rem; }
.spark svg { width: 100%; height: 100%; display: block; }
.spark-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.spark-area { fill: color-mix(in srgb, var(--accent) 14%, transparent); stroke: none; }
.spark-dot { fill: var(--accent); stroke: var(--bg-elevated); stroke-width: 2; }
.spark-empty {
  display: flex; align-items: center; justify-content: center;
  height: 100%; font-size: 0.75rem; color: var(--ink-faint);
  border: 1px dashed var(--rule-strong); border-radius: 8px;
}
.spark-tip {
  position: absolute; top: -1.4rem; right: 0;
  font-size: 0.72rem; font-variant-numeric: tabular-nums;
  color: var(--ink-dim); background: var(--bg-elevated-2);
  border: 1px solid var(--rule); border-radius: 6px; padding: 0.1rem 0.4rem;
  pointer-events: none; white-space: nowrap;
}

/* ---------- sentiment ---------- */
.sentiment-bar {
  display: flex; height: 10px; border-radius: 5px; overflow: hidden;
  margin-top: 0.7rem; background: var(--bg-elevated-2);
}
.sentiment-bar .seg.gain { background: var(--rising); }
.sentiment-bar .seg.flat { background: var(--ink-faint); opacity: 0.4; }
.sentiment-bar .seg.loss { background: var(--falling); }
.sentiment-bar .seg + .seg { border-left: 2px solid var(--bg-elevated); }
.sentiment-legend { font-size: 0.72rem; color: var(--ink-dim); margin-top: 0.5rem; }
.sentiment-legend .gain { color: var(--rising); }
.sentiment-legend .loss { color: var(--falling); }

/* ---------- favorites / recents chips ---------- */
.chip-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-bottom: 0.6rem; }
.chip-label { font-size: 0.75rem; color: var(--ink-faint); margin-right: 0.25rem; }
.chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.3rem 0.7rem; border-radius: 999px;
  background: var(--bg-elevated); border: 1px solid var(--rule-strong);
  color: var(--ink); text-decoration: none; font-size: 0.8rem;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- category pill bar (db.biggames-style inventory tabs) ---------- */
.cat-pill-bar {
  display: flex; flex-wrap: nowrap; align-items: center; gap: 0.15rem;
  background: var(--bg-elevated-2);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 0.4rem;
  margin-bottom: 1rem;
  position: relative;
  overflow-x: auto;
  scrollbar-width: none;
}
.cat-pill-bar::-webkit-scrollbar { display: none; }
.cat-pill {
  display: inline-flex; align-items: center; gap: 0.4rem; flex: none;
  position: relative;
  padding: 0.4rem 0.7rem; border-radius: 999px;
  background: transparent; border: none;
  color: var(--ink-dim); font-size: 0.78rem; font-weight: 600;
  cursor: pointer; user-select: none; white-space: nowrap;
}
.cat-pill:hover { background: var(--bg-elevated); color: var(--ink); }
.cat-pill .cp-icon { font-size: 0.95em; line-height: 1; }
.cat-pill .cp-count {
  color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums;
  font-size: 0.72em; background: color-mix(in srgb, var(--accent) 20%, transparent);
  padding: 0.1rem 0.35rem; border-radius: 6px;
}
.cat-pill.active {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
}
.cat-pill.active:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.cat-pill.more-pill .cp-chevron { font-size: 0.7em; transition: transform 0.15s; display: inline-block; }
.cat-pill.more-pill.open .cp-chevron { transform: rotate(180deg); }
/* The bar scrolls horizontally with no visible scrollbar, so "More" can
   scroll out of view and become unreachable - pin it to the right edge. */
.cat-pill.more-pill {
  position: sticky; right: 0; z-index: 5;
  background: var(--bg-elevated-2);
  box-shadow: -10px 0 8px -4px var(--bg-elevated-2);
}
.more-dropdown {
  display: none;
  /* Lives at body level, NOT nested inside the sticky "More" pill - a
     `position: sticky` ancestor creates a new containing block for
     `position: fixed` descendants, which made an embedded dropdown drag
     along with the pill bar's scroll instead of staying put relative to
     the real viewport. JS sets top/right from the button's actual
     screen position (and re-syncs on page scroll) since it opens. */
  position: fixed; z-index: 200;
  min-width: 180px; max-height: 60vh; overflow-y: auto;
  background: var(--bg-elevated); border: 1px solid var(--rule-strong);
  border-radius: 10px; padding: 0.3rem;
  box-shadow: var(--shadow);
}
.more-dropdown.open { display: block; }
.more-opt {
  display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
  padding: 0.4rem 0.55rem; border-radius: 7px;
  font-size: 0.78rem; font-weight: 600; color: var(--ink-dim);
  white-space: nowrap; cursor: pointer;
}
.more-opt:hover { background: var(--bg-elevated-2); color: var(--ink); }
.more-opt .cp-count { color: var(--ink-faint); font-weight: 700; font-size: 0.85em; }

/* ---------- fav star button on detail pages ---------- */
.fav-btn {
  background: none; border: 1px solid var(--rule-strong); border-radius: 10px;
  color: var(--ink-dim); font-size: 1rem; padding: 0.3rem 0.6rem; cursor: pointer;
}
.fav-btn.active { color: var(--accent); border-color: var(--accent); }

/* ---------- 4-up preview grid ---------- */
.preview-grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .preview-grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px)  { .preview-grid-4 { grid-template-columns: 1fr; } }

/* ---------- footer ---------- */
.site-footer {
  margin-top: 3rem; padding: 1.5rem 0 2rem;
  border-top: 1px solid var(--rule);
  display: flex; flex-wrap: wrap; gap: 1rem; align-items: baseline; justify-content: space-between;
  font-size: 0.8rem; color: var(--ink-faint);
}
.site-footer p { margin: 0.25rem 0 0; }
.site-footer nav { display: flex; gap: 1rem; }
.site-footer nav a { color: var(--ink-dim); text-decoration: none; }
.site-footer nav a:hover { color: var(--accent); }
.site-footer .credits { width: 100%; margin-top: 0.5rem; }

/* ---------- rarity tags (Huge / Titanic / Gargantuan / etc.) ---------- */
.rtag {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 0.12rem 0.45rem;
  border-radius: 6px;
  text-transform: uppercase;
}
.rtag.huge       { background: color-mix(in srgb, var(--rarity-huge) 16%, transparent); color: var(--rarity-huge); }
.rtag.titanic    { background: color-mix(in srgb, var(--rarity-titanic) 16%, transparent); color: var(--rarity-titanic); }
.rtag.gargantuan { background: color-mix(in srgb, var(--rarity-gargantuan) 16%, transparent); color: var(--rarity-gargantuan); }
.rtag.exclusive  { background: color-mix(in srgb, var(--rarity-exclusive) 16%, transparent); color: var(--rarity-exclusive); }
.rtag.shiny      { background: color-mix(in srgb, #fbbf24 16%, transparent); color: #fbbf24; }
.rtag.golden     { background: color-mix(in srgb, #f59e0b 16%, transparent); color: #f59e0b; }
.rtag.rainbow    { background: linear-gradient(90deg, rgba(236,72,153,0.18), rgba(168,85,247,0.18), rgba(70,221,218,0.18)); color: var(--rarity-gargantuan); }

/* ---------- inventory / item image cards ---------- */
.inv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}
.inv-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.15s, background 0.15s;
}
.inv-card:hover { border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: var(--bg-elevated-2); }
.inv-thumb {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 50% 38%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 70%),
    var(--bg-elevated-2);
  border-bottom: 1px solid var(--rule);
}
.inv-thumb img { width: 74%; height: 74%; object-fit: contain; image-rendering: auto; }
.inv-thumb .placeholder { font-size: 1.6rem; opacity: 0.35; }
/* Matches their real structure: badges are inset inside a padded inner
   wrapper, not pinned to the outer thumb edge - that's what keeps them
   tucked into the corners instead of overlapping the pet art. */
.pet-tile-grid .inv-thumb-inner {
  position: absolute; inset: 0.5rem;
  display: flex; align-items: center; justify-content: center;
}
.inv-count {
  position: absolute;
  top: 0.4rem; right: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.55);
  color: var(--ink);
}

/* ---------- player inventory grid (db.biggames-style pet tiles) - scoped
   to .pet-tile-grid so items.html/eggs.html's plain cards are untouched ---------- */
/* Exact positions/sizes from db.biggames.io's real markup - two badges at
   once for Titanic+ (crown + rank), rank alone for Huge. Global, not
   scoped to .pet-tile-grid - used on the homepage hero satellites too,
   which was the same scoping mistake .pet-img had. */
.tier-crown {
  position: absolute; left: 3%; top: 3%; z-index: 4;
  width: 30% !important; height: auto !important; object-fit: contain; pointer-events: none;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.55));
}
.tier-rank {
  position: absolute; right: 4%; bottom: 4%; z-index: 4;
  width: 50% !important; height: auto !important; object-fit: contain; pointer-events: none;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.6));
}
.pet-tile-grid .variant-badge {
  position: absolute; top: 0.4rem; left: 0.4rem; z-index: 2;
  font-size: 0.6rem; font-weight: 800; letter-spacing: 0.03em;
  padding: 0.15rem 0.5rem; border-radius: 999px; text-transform: uppercase;
}
.pet-tile-grid .variant-badge.shiny { background: #34c6e0; color: #06232b; }
.pet-tile-grid .variant-badge.rainbow { background: linear-gradient(90deg, #ff5f6d, #ffc371, #4fd1c5, #7f5af0); color: #fff; }
/* Not overlaid on the image - a normal row below the name/category, gap+1
   center dot, matching their real markup exactly. */
.pet-tile-grid .inv-stats-row {
  display: flex; align-items: center; gap: 0.3rem;
  padding: 0 0.65rem 0.6rem;
  font-size: 0.68rem; font-weight: 600; color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
}
.pet-tile-grid .inv-stats-row span { display: inline-flex; align-items: center; gap: 0.2rem; }
.pet-tile-grid .inv-stats-row .ss-cnt { color: #fbbf24; }
.pet-tile-grid .inv-stats-row .ss-val { color: #60a5fa; }
.pet-tile-grid .inv-stats-row .ss-sep { color: var(--ink-faint); }
.pet-tile-grid .inv-stats-row .ss-icon { width: 0.75rem; height: 0.75rem; }
/* Base drop-shadow works anywhere .pet-img is used (mini table icons,
   battle reward art, item hero art), not just inside the pet grid - the
   grid adds its own sizing/hover-scale on top for its own layout. */
.pet-img { filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.45)); }
.pet-tile-grid .pet-img {
  width: 82%; height: 82%;
  transition: transform 0.2s;
}
.pet-tile-grid .inv-card:hover .pet-img { transform: scale(1.05); }
@keyframes petRainbowHue {
  from { filter: hue-rotate(0deg) drop-shadow(0 6px 14px rgba(0, 0, 0, 0.45)); }
  to { filter: hue-rotate(360deg) drop-shadow(0 6px 14px rgba(0, 0, 0, 0.45)); }
}
.rainbow-hue { animation: petRainbowHue 3s linear infinite; }
@keyframes petShinyGlow {
  0%, 100% { filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.45)) drop-shadow(0 0 6px rgba(34, 211, 238, 0.25)); }
  50% { filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.45)) drop-shadow(0 0 14px rgba(34, 211, 238, 0.65)); }
}
.shiny-glow { animation: petShinyGlow 2.2s ease-in-out infinite; }
.pet-tile-grid .inv-name { padding-top: 0.55rem; }
.pet-tile-grid .inv-cat-label { color: var(--ink-faint); font-size: 0.72rem; }
.inv-info { padding: 0.55rem 0.65rem 0.65rem; display: flex; flex-direction: column; gap: 0.2rem; }
.inv-name {
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2em;
}
.inv-rap {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  color: var(--accent);
  font-weight: 600;
}
.inv-sub { font-size: 0.68rem; color: var(--ink-faint); }

/* ---------- player profile hero ---------- */
.profile-hero {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: fit-content;
  min-width: 320px;
  padding: 1rem 1.6rem 1rem 1.1rem;
  background:
    radial-gradient(120% 160% at 0% 0%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 55%),
    var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 16px;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}
.profile-hero img.pfp {
  width: 72px; height: 72px;
  border-radius: 18px;
  border: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  background: var(--bg-elevated-2);
}
.profile-hero .p-name {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.015em;
  display: flex; align-items: center; gap: 0.5rem;
}
.profile-hero .p-sub { color: var(--ink-faint); font-size: 0.85rem; margin-top: 0.15rem; }
.profile-hero .p-rap { margin-left: auto; text-align: right; }
.profile-hero .p-rap .label {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-faint);
}
.profile-hero .p-rap .value {
  font-family: var(--font-mono);
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
@media (max-width: 640px) {
  .profile-hero { flex-wrap: wrap; }
  .profile-hero .p-rap { margin-left: 0; text-align: left; width: 100%; }
}

/* ---------- small avatars & thumbs in tables ---------- */
.avatar-sm {
  width: 30px; height: 30px;
  border-radius: 8px;
  vertical-align: middle;
  margin-right: 0.6rem;
  background: var(--bg-elevated-2);
  border: 1px solid var(--rule);
}
.item-thumb-sm {
  width: 32px; height: 32px;
  object-fit: contain;
  vertical-align: middle;
  margin-right: 0.6rem;
}
td.entity { white-space: nowrap; }
td.entity a { color: var(--ink); text-decoration: none; font-weight: 600; }
td.entity a:hover { color: var(--accent); }

/* ============================================================
   ps99rap-style structural shell: full-width app header with
   center search, breadcrumbs, big page headers, sub-tabs,
   and the user/item card grids.
   ============================================================ */
.site-head {
  position: sticky; top: 0; z-index: 60;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--rule);
}
.site-head-inner {
  max-width: 1240px; margin: 0 auto;
  display: flex; align-items: center; gap: 1.25rem;
  padding: 0.6rem 1.5rem;
}
.site-head .logo {
  display: flex; align-items: center; gap: 0.5rem;
  font-family: var(--font-display); font-weight: 800; font-size: 1.1rem;
  color: var(--ink); text-decoration: none;
}
.site-head .logo img { width: 30px; height: 30px; border-radius: 8px; }
.site-head .logo .accent { color: var(--accent); }
.site-nav { display: flex; gap: 0.35rem; }
.site-nav a {
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.88rem; font-weight: 600; color: var(--ink-dim);
  text-decoration: none; padding: 0.45rem 0.7rem; border-radius: 8px;
}
.site-nav a:hover { color: var(--ink); background: var(--bg-elevated-2); }
.site-nav a.active { color: var(--accent); }
.global-search { flex: 1; max-width: 460px; margin: 0 auto; }
.global-search input {
  width: 100%;
  background: var(--bg-inset);
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  color: var(--ink);
  font-size: 0.85rem;
  padding: 0.5rem 1rem;
}
.global-search input::placeholder { color: var(--ink-faint); }
.global-search input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.discord-btn {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  font-size: 0.78rem; font-weight: 700; color: #fff;
  background: #5865F2; border: 1px solid #4752c4; border-radius: 8px;
  padding: 0.45rem 0.7rem; text-decoration: none; white-space: nowrap; flex: none;
  transition: background 0.15s, border-color 0.15s;
}
.discord-btn:hover { background: #4752c4; border-color: #3c45a5; }
.discord-btn .discord-icon { width: 16px; height: 16px; object-fit: contain; filter: brightness(0) invert(1); }
@media (max-width: 860px) {
  .global-search { display: none; }
  .site-head-inner { flex-wrap: wrap; }
}

.crumbs { font-size: 0.8rem; color: var(--ink-faint); margin: 1.1rem 0 0.9rem; }
.crumbs a { color: var(--ink-faint); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }
.crumbs .here { color: var(--accent); }

.page-head h1 {
  font-family: var(--font-display);
  font-size: 2.6rem; font-weight: 800; letter-spacing: -0.02em;
  margin: 0 0 0.4rem;
}
.page-sub { font-weight: 400; }
.page-head .lede { color: var(--ink-dim); font-size: 0.95rem; margin: 0; }
.page-head .lede-sub { color: var(--ink-faint); font-size: 0.85rem; margin: 0.2rem 0 0; }

.subtabs {
  display: flex; gap: 1.6rem;
  border-bottom: 1px solid var(--rule);
  margin: 1.6rem 0 1.2rem;
}
.subtabs button {
  background: none; border: none; cursor: pointer;
  font-family: var(--font-body); font-size: 0.92rem; font-weight: 600;
  color: var(--ink-faint); padding: 0.6rem 0.1rem;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.subtabs button.active { color: var(--ink); border-bottom-color: var(--accent); }
.subtabs button:hover:not(.active) { color: var(--ink-dim); }

.toolbar { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.toolbar select {
  background: var(--bg-elevated); color: var(--ink);
  border: 1px solid var(--rule-strong); border-radius: 999px;
  padding: 0.45rem 0.9rem; font-size: 0.83rem; font-weight: 600;
}
.toolbar .search-input { max-width: 300px; margin-bottom: 0; }

/* ---------- user cards ---------- */
.user-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 0.9rem;
}
.user-card {
  --tint-rgb: 60 75 110;
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.85rem 0.95rem;
  border-radius: 12px;
  border: 1px solid var(--rule);
  text-decoration: none;
  background:
    linear-gradient(115deg,
      rgb(var(--tint-rgb) / 0.5),
      rgb(var(--tint-rgb) / 0.12) 70%),
    var(--bg-elevated);
  transition: border-color 0.15s, transform 0.15s, background 0.3s;
}
.user-card:hover { border-color: color-mix(in srgb, var(--accent) 45%, transparent); transform: translateY(-1px); }
.user-card .uc-avatar {
  width: 46px; height: 46px; flex-shrink: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--rule-strong);
}
.user-card .uc-name {
  color: var(--ink); font-weight: 700; font-size: 0.92rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-card .uc-user {
  color: var(--ink-faint); font-size: 0.78rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-card .uc-rap {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  color: var(--accent); font-weight: 700; font-size: 0.85rem; margin-top: 0.1rem;
}
.user-card > div { min-width: 0; }

/* ---------- item cards (items page grid) ---------- */
.item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.8rem;
}

/* ---------- recently visited / favorites cards ---------- */
.visit-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.7rem;
}
.visit-card {
  --tint-rgb: 60 75 110;
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.65rem 0.8rem;
  border-radius: 11px;
  border: 1px solid var(--rule);
  text-decoration: none;
  background:
    linear-gradient(115deg,
      rgb(var(--tint-rgb) / 0.5),
      rgb(var(--tint-rgb) / 0.12) 70%),
    var(--bg-elevated);
  transition: border-color 0.15s, transform 0.15s, background 0.3s;
}
.visit-card:hover { border-color: color-mix(in srgb, var(--accent) 45%, transparent); transform: translateY(-1px); }
.vc-glyph {
  width: 36px; height: 36px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.05rem;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--rule-strong);
}
.visit-card > span:last-child { min-width: 0; display: flex; flex-direction: column; }
.vc-name {
  color: var(--ink); font-weight: 700; font-size: 0.85rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.vc-kind { color: var(--ink-faint); font-size: 0.72rem; }

/* ---------- users leaderboards tab ---------- */
.boards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.overall-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}
.overall-grid table + table { border-left: 1px solid var(--rule); }
@media (max-width: 900px) {
  .overall-grid { grid-template-columns: 1fr; }
  .overall-grid table + table { border-left: none; }
}

/* ---------- png icons replacing emojis ---------- */
.ico {
  width: 18px; height: 18px;
  object-fit: contain;
  vertical-align: -3px;
  display: inline-block;
}
.site-nav .ico { width: 17px; height: 17px; }
.panel .glyph .ico { width: 22px; height: 22px; }
.vc-glyph .ico { width: 20px; height: 20px; }
.card-head .ico { width: 17px; height: 17px; }

/* ---------- full-page loader ---------- */
#page-loader {
  position: fixed; inset: 0; z-index: 200;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.9rem;
  background: var(--bg);
  transition: opacity 0.4s ease;
}
#page-loader.gone { opacity: 0; pointer-events: none; }
#page-loader img {
  width: 110px; height: 110px;
  border-radius: 22px;
  box-shadow: var(--shadow);
}
#page-loader .pl-name {
  font-family: var(--font-display);
  font-size: 1.4rem; font-weight: 800;
}
#page-loader .pl-name span { color: var(--accent); }
#page-loader .pl-sub {
  color: var(--ink-faint); font-size: 0.82rem;
  animation: pl-pulse 1.4s ease-in-out infinite;
}
@keyframes pl-pulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }

/* ---------- header search typeahead ---------- */
.search-drop {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  z-index: 100;
  background: var(--bg-elevated);
  border: 1px solid var(--rule-strong);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
  max-height: 420px;
  overflow-y: auto;
}
.search-drop a {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.5rem 0.8rem;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.86rem;
  font-weight: 600;
  border-bottom: 1px solid var(--rule);
}
.search-drop a:last-child { border-bottom: none; }
.search-drop a:hover { background: var(--bg-elevated-2); color: var(--accent); }
.search-drop img {
  width: 30px; height: 30px;
  object-fit: contain;
  border-radius: 7px;
  background: var(--bg-elevated-2);
  flex-shrink: 0;
}
/* keep tall glyphs (mono digits) from clipping in meta stat rows */
.stat .value { line-height: 1.35; }

/* ---------- player mastery cards + stat rank ---------- */
.stat .stat-rank {
  font-size: 0.72rem; font-weight: 700; color: var(--accent);
  margin-top: 0.15rem; font-variant-numeric: tabular-nums;
}
.mastery-card { padding: 0.85rem 1rem; }
.mastery-card .m-name { font-weight: 700; font-size: 0.9rem; }
.mastery-card .m-level {
  font-family: var(--font-mono); font-size: 1.05rem; font-weight: 700;
  color: var(--accent); margin-top: 0.2rem;
}
.mastery-card .m-max { color: var(--ink-faint); font-size: 0.8rem; }
.mastery-card .m-bar {
  height: 6px; border-radius: 3px; background: var(--bg-elevated-2);
  overflow: hidden; margin-top: 0.5rem;
}
.mastery-card .m-bar div { height: 100%; background: var(--accent); border-radius: 3px; }
.rank-pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: var(--bg-elevated-2);
  border: 1px solid var(--rule-strong);
  color: var(--ink-dim);
  vertical-align: 2px;
}
.stat .value .rank-pill { margin-left: 0.25rem; }

.flag-img { width: 20px; height: 15px; border-radius: 2px; vertical-align: -2px; }

/* small inline icon wrapper for leaderboard/preview tables - the pet-img/
   rainbow-hue/shiny-glow classes (see #inv-grid rules) handle the actual
   variant effects on the <img> itself now. */
.mini-thumb-wrap {
  position: relative; display: inline-block;
  width: 32px; height: 32px;
  vertical-align: middle; margin-right: 0.6rem;
  isolation: isolate;
}
.mini-thumb-wrap img.item-thumb-sm { margin-right: 0; width: 32px; height: 32px; }

/* their numbers are Outfit with tabular figures */
td.num, .num, .index-value, .stat .value, .r-pts, .p-pts { font-variant-numeric: tabular-nums; }

/* ---------- small-screen hardening ---------- */
@media (max-width: 560px) {
  .site-head-inner { gap: 0.6rem; padding: 0.55rem 0.9rem; }
  .site-nav { gap: 0.1rem; }
  .site-nav a { padding: 0.4rem 0.45rem; font-size: 0.78rem; gap: 0.25rem; }
  .shell { padding: 0 0.9rem 3rem; }
  .page-head h1 { font-size: 1.9rem; }
  .item-hero { flex-wrap: wrap; padding: 1.1rem; }
  .clan-row .r-pts { min-width: 0; }
  .profile-hero { min-width: 0; width: 100%; }
  .hero h1 { font-size: 1.7rem; }
  .index-value { font-size: 1.2rem; }
}

/* ---------- QOL: search hotkey hint + theme toggle + help tips ---------- */
.search-slash-hint {
  position: absolute;
  right: 0.8rem; top: 50%; transform: translateY(-50%);
  font-family: var(--font-body);
  font-size: 0.72rem; font-weight: 700;
  color: var(--ink-faint);
  border: 1px solid var(--rule-strong);
  border-radius: 5px;
  padding: 0.05rem 0.4rem;
  pointer-events: none;
}
.theme-toggle {
  background: none;
  border: 1px solid var(--rule-strong);
  border-radius: 9px;
  color: var(--ink-dim);
  padding: 0.4rem 0.5rem;
  cursor: pointer;
  display: flex; align-items: center;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
:root[data-theme="dark"] { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }

.help-tip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 1px solid var(--rule-strong);
  color: var(--ink-faint);
  font-size: 0.62rem; font-weight: 700;
  cursor: help;
  vertical-align: 1px;
  margin-left: 0.25rem;
}

/* equipped section (db.biggames player pages): Pets / Enchants / Ultimate /
   Hoverboard / Booth cards side by side */
.equip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.7rem;
  margin-bottom: 1.4rem;
}
.equip-box {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 0.75rem 0.85rem 0.6rem;
  overflow: hidden;
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
}
.equip-box:hover { transform: translateY(-2px); border-color: color-mix(in srgb, #f2a93b 45%, var(--rule)); background: var(--bg-elevated-2); }
.eq-box-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.68rem; font-weight: 800; letter-spacing: 0.04em;
  color: var(--ink-faint); margin-bottom: 0.55rem;
}
.eq-box-count { font-variant-numeric: tabular-nums; }
.eq-box-body { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.eq-box-body > div:last-child { min-width: 0; flex: 1; }
/* Matches their real markup: thumbnails overlap like a stacked avatar
   group (-space-x-2, i.e. negative margin) instead of sitting side by
   side - that's what leaves room for "View all slots" not to get cramped. */
.eq-mini-row { display: flex; flex: none; }
.eq-mini {
  position: relative;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-elevated-2);
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  isolation: isolate; flex: none;
}
.eq-mini:not(:first-child) { margin-left: -10px; }
.eq-mini img { width: 82%; height: 82%; object-fit: contain; }
.eq-mini .pet-img { filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.45)); }
.eq-view-link {
  display: block;
  font-size: 0.75rem; font-weight: 600; color: var(--ink);
  text-decoration: none; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.eq-view-link:hover { text-decoration: underline; }
.eq-sub {
  font-size: 0.62rem; color: var(--ink-faint); margin-top: 0.15rem;
  text-align: right;
}
.eq-progress {
  height: 4px; border-radius: 2px; margin-top: 0.6rem;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  overflow: hidden;
}
.eq-progress-fill { height: 100%; background: var(--accent); }
.eq-progress.purple .eq-progress-fill { background: #a78bfa; }
.equip-box.single .eq-box-head { margin-bottom: 0.5rem; }
.eq-single-body { display: flex; align-items: center; gap: 0.55rem; }
.eq-single-name { font-size: 0.85rem; font-weight: 700; }
.eq-shiny-tag {
  display: inline-block; margin-top: 0.2rem;
  font-size: 0.6rem; font-weight: 800; letter-spacing: 0.03em;
  color: #241605; background: linear-gradient(180deg, #f2a93b, #e0921f);
  padding: 0.08rem 0.4rem; border-radius: 5px;
}

/* ---------- "View all slots" dialog (matches db.biggames.io's real modal) ---------- */
.slots-modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  padding: 1.5rem;
}
.slots-modal {
  position: relative;
  width: 100%; max-width: 860px; max-height: 80vh;
  display: flex; flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--rule-strong);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.slots-modal-close {
  position: absolute; top: 0.75rem; right: 0.75rem; z-index: 2;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-elevated-2);
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  color: var(--ink-dim);
  cursor: pointer;
}
.slots-modal-close:hover { color: var(--ink); background: var(--bg-hover); }
.slots-modal-head {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 1.25rem 3.5rem 1.1rem 1.25rem;
  border-bottom: 1px solid var(--rule);
  flex: none;
}
.slots-modal-icon {
  width: 48px; height: 48px; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  border-radius: 12px;
  background: color-mix(in srgb, #a78bfa 15%, transparent);
}
.slots-modal-eyebrow { font-size: 0.65rem; font-weight: 800; letter-spacing: 0.15em; text-transform: uppercase; color: var(--ink-faint); }
.slots-modal-title { font-family: var(--font-display); font-size: 1.4rem; font-weight: 800; margin-top: 0.15rem; }
.slots-modal-sub { font-size: 0.78rem; color: var(--ink-dim); margin-top: 0.15rem; }
.slots-modal-body { overflow-y: auto; padding: 1rem; }
.slots-modal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.5rem;
}

/* ---------- clan/league quick-view modal (matches db.biggames.io's
   click-a-leaderboard-row-without-leaving-the-page pattern) ---------- */
.entity-modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  padding: 1.5rem;
  overscroll-behavior: contain;
}
.entity-modal {
  position: relative;
  width: 100%; max-width: 640px; max-height: 85vh;
  display: flex; flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--rule-strong);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.entity-modal-content-wrap {
  /* The actual flex item inside .entity-modal - without this being a flex
     column itself (min-height:0 included), it was just a plain block div
     that grew to fit its content (the head/stats/tabs/scrollable body all
     stacked inside it), which meant .entity-modal-body's own flex:1 rules
     had no flex container to apply against and never got height-
     constrained at all - it just rendered at its full content height with
     nothing to scroll internally.
  */
  display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0;
}
.entity-modal-close {
  position: absolute; top: 0.75rem; right: 0.75rem; z-index: 2;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-elevated-2);
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  color: var(--ink-dim);
  cursor: pointer;
}
.entity-modal-close:hover { color: var(--ink); background: var(--bg-hover); }
.entity-modal-view {
  position: absolute; top: 0.75rem; right: 3.6rem; z-index: 2;
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-size: 0.72rem; font-weight: 700; color: var(--ink);
  background: var(--bg-elevated-2); border: 1px solid var(--rule-strong);
  border-radius: 8px; padding: 0.45rem 0.65rem; text-decoration: none;
}
.entity-modal-view:hover { background: var(--bg-hover); }
.entity-modal-head {
  display: flex; align-items: center; gap: 0.9rem;
  padding: 1.25rem 3.5rem 1.1rem 1.25rem;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 10%, transparent), transparent);
  border-radius: 14px 14px 0 0;
  flex: none;
}
.entity-modal-icon {
  width: 56px; height: 56px; flex: none; object-fit: cover;
  border-radius: 12px; border: 1px solid var(--rule-strong);
  background: var(--bg-elevated-2);
}
.entity-modal-name { font-family: var(--font-display); font-size: 1.3rem; font-weight: 800; }
.entity-modal-meta { font-size: 0.78rem; color: var(--ink-dim); margin-top: 0.2rem; display: flex; gap: 0.6rem; flex-wrap: wrap; }
.entity-modal-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px;
  background: var(--rule); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  flex: none;
}
.entity-modal-stats .stat-box { background: var(--bg-elevated); padding: 0.7rem 0.9rem; }
.entity-modal-stats .stat-box .label { font-size: 0.62rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-faint); }
.entity-modal-stats .stat-box .value { font-size: 1.05rem; font-weight: 800; margin-top: 0.15rem; }
.entity-modal-tabs {
  display: flex; gap: 0.25rem; padding: 0.6rem 1rem 0; border-bottom: 1px solid var(--rule); flex: none;
}
.entity-modal-tabs button {
  background: none; border: none; cursor: pointer;
  font-size: 0.82rem; font-weight: 700; color: var(--ink-faint);
  padding: 0.5rem 0.7rem; border-bottom: 2px solid transparent;
}
.entity-modal-tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.entity-modal-body {
  /* Without flex + min-height:0 here, a flex child never shrinks below its
     own content's height - the modal just grew to fit everything instead
     of clipping at max-height, so there was nothing for overflow-y:auto to
     actually do and the scroll wheel fell through to the page instead. */
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; padding: 1rem 1.25rem 1.25rem; text-align: left;
  /* Without this, a wheel scroll over content shorter than the box (e.g. a
     4-member roster) has nothing to scroll internally and chains straight
     through to the page behind the modal instead of just stopping. */
  overscroll-behavior: contain;
}
.entity-modal-section-label {
  font-size: 0.65rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-faint); margin: 0 0 0.5rem;
}
.entity-modal-section-label + .entity-modal-section-label { margin-top: 1rem; }
.entity-modal-owner {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.6rem 0.8rem; border-radius: 10px;
  background: var(--bg-elevated-2); border: 1px solid var(--rule);
  margin-bottom: 0.9rem;
  text-align: left;
}
.entity-modal-row-list { display: flex; flex-direction: column; gap: 0.55rem; }
.entity-modal-row-list .kv { display: flex; justify-content: space-between; align-items: center; font-size: 0.85rem; }
.entity-modal-row-list .kv .k { color: var(--ink-faint); }
.entity-modal-row-list .kv .v { font-weight: 700; }
.entity-modal-owner a.name { font-weight: 700; color: var(--ink); text-decoration: none; }
.entity-modal-owner a.name:hover { color: var(--accent); }
.entity-modal-owner img { width: 34px; height: 34px; border-radius: 50%; background: var(--bg-inset); border: 1px solid var(--rule-strong); flex: none; }
.role-tag { font-size: 0.66rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; padding: 0.2rem 0.55rem; border-radius: 999px; flex: none; }
.role-tag.owner { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent); }
.role-tag.officer { background: color-mix(in srgb, var(--rising) 18%, transparent); color: var(--rising); }
.entity-member-row {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 0.8rem; border-radius: 10px;
  background: var(--bg-elevated-2); border: 1px solid var(--rule);
  margin-bottom: 0.4rem;
  text-align: left;
}
.entity-member-row img { width: 34px; height: 34px; border-radius: 50%; background: var(--bg-inset); border: 1px solid var(--rule-strong); flex: none; }
.entity-member-row .member-info { flex: 1; min-width: 0; text-align: left; }
.entity-member-row .name { font-weight: 700; font-size: 0.86rem; text-align: left; }
.entity-member-row .name a { color: var(--ink); text-decoration: none; }
.entity-member-row .name a:hover { color: var(--accent); }
.entity-member-row .sub { font-size: 0.72rem; color: var(--ink-faint); margin-top: 0.1rem; text-align: left; }
.entity-contrib-row { margin-bottom: 0.7rem; }
.entity-contrib-row .top { display: flex; justify-content: space-between; font-size: 0.82rem; font-weight: 700; margin-bottom: 0.3rem; }
.entity-contrib-row .top .pph { font-weight: 600; color: var(--ink-faint); font-size: 0.72rem; margin-left: 0.4rem; }
.entity-contrib-bar-track { height: 6px; border-radius: 999px; background: var(--bg-inset); overflow: hidden; }
.entity-contrib-bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 60%, #a78bfa)); }
.slot-card {
  display: flex; align-items: center; gap: 0.7rem;
  height: 64px;
  padding: 0.4rem 0.6rem;
  background: var(--bg-elevated-2);
  border: 1px solid var(--rule);
  border-radius: 10px;
  text-decoration: none; color: inherit;
  transition: border-color 0.15s, transform 0.15s;
}
.slot-card:hover { border-color: color-mix(in srgb, #a78bfa 60%, transparent); transform: translateY(-1px); }
.slot-thumb {
  width: 48px; height: 48px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-inset);
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
}
.slot-thumb img { width: 82%; height: 82%; object-fit: contain; }
.slot-info { min-width: 0; }
.slot-num { font-size: 0.62rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-faint); }
.slot-name {
  font-family: var(--font-display); font-size: 0.85rem; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* prev/next entity navigation */
.entity-nav {
  display: flex; align-items: center; gap: 0.4rem;
  margin-left: auto;
}
.entity-nav a {
  display: flex; align-items: center; gap: 0.3rem;
  font-size: 0.78rem; font-weight: 700;
  color: var(--ink-dim); text-decoration: none;
  border: 1px solid var(--rule-strong); border-radius: 9px;
  padding: 0.35rem 0.6rem;
  max-width: 130px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.entity-nav a:hover { color: var(--accent); border-color: var(--accent); }

/* floating tooltip for .help-tip - JS-positioned (position:fixed) so it can
   never be clipped by a card's overflow:hidden */
.tip-pop {
  position: fixed;
  max-width: 260px;
  background: var(--bg-elevated-2);
  border: 1px solid var(--rule-strong);
  color: var(--ink);
  font-size: 0.74rem; font-weight: 500;
  line-height: 1.45; text-transform: none; letter-spacing: normal;
  padding: 0.5rem 0.7rem;
  border-radius: 9px;
  box-shadow: var(--shadow);
  pointer-events: none;
  z-index: 999;
}
