/* =========================================================================
   GameFi Rails — design system v2 "obsidian arcade"
   Financial infrastructure for Web3 games. The look: a pro trading desk set
   inside a game world — deep space-indigo glass, one violet→cyan gradient
   used sparingly as the brand thread, gold reserved for the game economy,
   tabular numerals everywhere money appears.
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
  /* Surfaces — near-black violet, each step lifting toward purple */
  --bg: #070510;
  --surface: #0d0a1a;
  --surface-2: #131024;
  --surface-3: #1a1533;
  --line: #2a2350;
  --line-soft: #1d1838;

  /* Text */
  --text: #f0eef8;
  --text-dim: #9a96b8;
  --text-faint: #605c82;

  /* Brand + semantics */
  --accent: #8b5cf6;
  --accent-hot: #a78bfa;
  --accent-2: #e879f9;
  --accent-dim: #3b2f6b;
  --gold: #f6c945;
  --up: #2ee6a8;
  --down: #ff5d78;
  --warn: #f5a742;

  --up-soft: rgba(46, 230, 168, 0.12);
  --down-soft: rgba(255, 93, 120, 0.12);
  --accent-soft: rgba(139, 92, 246, 0.13);
  --gold-soft: rgba(246, 201, 69, 0.13);

  /* The one gradient. Brand mark, primary buttons, headline highlights,
     active-nav underline — and nothing else, or it stops meaning anything. */
  --grad: linear-gradient(115deg, #a78bfa 0%, #8b5cf6 45%, #e879f9 100%);

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 18px;

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.45), 0 10px 32px -14px rgba(0, 0, 0, 0.7);
  --shadow-lg: 0 32px 80px -28px rgba(0, 0, 0, 0.85);
  --glow-accent: 0 0 28px -8px rgba(139, 92, 246, 0.55);

  --font: 'Inter', -apple-system, 'Segoe UI', system-ui, sans-serif;
  --display: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', Consolas, monospace;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --spring: cubic-bezier(0.22, 1.2, 0.36, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  position: relative;
  min-height: 100vh;
}

/* Atmosphere: two faint colour fields + a fine grid, fixed behind everything.
   Cheap (pure gradients), and it makes flat pages feel like one deep space. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 55% 42% at 12% -8%, rgba(139, 92, 246, 0.11), transparent 65%),
    radial-gradient(ellipse 50% 40% at 95% 6%, rgba(232, 121, 249, 0.06), transparent 60%),
    radial-gradient(ellipse 70% 50% at 50% 108%, rgba(139, 92, 246, 0.06), transparent 60%);
  pointer-events: none;
}

::selection {
  background: rgba(139, 92, 246, 0.35);
}

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

h1, h2, h3, .page-title, .stat-value, .book-mid {
  font-family: var(--display);
}

/* Money, quantities, IDs — never let digits jitter. */
.num,
td.num,
.stat-value,
.book-table td {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
}

.mono {
  font-family: var(--mono);
  font-size: 0.92em;
  letter-spacing: -0.01em;
}

/* ── Scrollbars ────────────────────────────────────────────────────────── */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
}
*::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}
*::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: 99px;
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--line);
}
*::-webkit-scrollbar-track {
  background: transparent;
}

/* =========================================================================
   Top navigation — a floating glass bar, shared across every surface
   ========================================================================= */

/* Floating glass capsule, detached from the page edge. The bar is fixed, so
   the body compensates with padding — see the rule right below. */
.topnav {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 18px;
  height: 58px;
  width: min(1160px, calc(100% - 24px));
  padding: 0 10px 0 16px;
  border-radius: 999px;
  background: rgba(10, 8, 20, 0.66);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid rgba(139, 92, 246, 0.22);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.03) inset;
  transition: background 0.3s var(--ease), border-color 0.3s var(--ease), box-shadow 0.3s var(--ease);
}

body { padding-top: 82px; }

/* A sheen that travels around the capsule's border — game-menu energy,
   but slow and quiet enough for a financial product. */
.topnav::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(110deg, transparent 20%, rgba(139, 92, 246, 0.6) 42%,
              rgba(232, 121, 249, 0.5) 56%, transparent 78%);
  background-size: 250% 100%;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: nav-sheen 8s linear infinite;
  pointer-events: none;
  opacity: 0.65;
}

@keyframes nav-sheen { to { background-position: -250% 0; } }

/* Scrolled: the capsule "powers up" — denser glass, brighter ring. */
.topnav.scrolled {
  background: rgba(8, 6, 16, 0.86);
  border-color: rgba(139, 92, 246, 0.38);
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.6), var(--glow-accent);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 15.5px;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

/* The mark sits on its own dark tile (matches /brand/gamefi-rails-mark-tile.svg)
   so the gradient bars stay legible on any surface. */
.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--surface-2);
  box-shadow: 0 0 0 1px var(--line) inset, var(--glow-accent);
}

.brand-mark svg {
  width: 26px;
  height: 26px;
}

.brand-word em {
  font-style: normal;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
}

.nav-links a {
  position: relative;
  padding: 8px 13px;
  border-radius: 999px;
  color: var(--text-dim);
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: color 0.15s var(--ease), background 0.15s var(--ease);
}

.nav-links a:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

/* Active link is a lit gradient pill — selected-quest energy. */
.nav-links a.active {
  color: #fff;
  background: linear-gradient(120deg, rgba(139, 92, 246, 0.3), rgba(232, 121, 249, 0.18));
  box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.38) inset, 0 0 18px -6px rgba(139, 92, 246, 0.7);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

/* ── XP chip: the visitor's real Dragon Arena XP, worn like a HUD badge ── */
.nav-xp {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 5px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 650;
  color: var(--text-dim);
  white-space: nowrap;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.nav-xp b { color: var(--gold); font-weight: 750; }

.nav-xp .ring {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: conic-gradient(var(--gold) var(--p, 0%), rgba(255, 255, 255, 0.09) 0);
  display: grid;
  place-items: center;
}

.nav-xp .ring i {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface-3);
  display: grid;
  place-items: center;
  font-style: normal;
  font-size: 9.5px;
  font-weight: 800;
  color: var(--gold);
}

.nav-xp:hover {
  color: var(--text);
  border-color: rgba(246, 201, 69, 0.45);
  box-shadow: 0 0 16px -6px rgba(246, 201, 69, 0.6);
}

/* ── Burger + dropdown sheet (mobile) ──────────────────────────────────── */
.nav-burger {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface-2);
  cursor: pointer;
  place-items: center;
  flex-shrink: 0;
}

.nav-burger span {
  display: block;
  width: 16px;
  height: 2px;
  border-radius: 2px;
  background: var(--text-dim);
  transition: transform 0.25s var(--ease), opacity 0.2s var(--ease);
}

.nav-burger span + span { margin-top: 4px; }

.topnav.open .nav-burger span:nth-child(1) { transform: translateY(3px) rotate(45deg); }
.topnav.open .nav-burger span:nth-child(2) { transform: translateY(-3px) rotate(-45deg); }

.nav-sheet {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  right: 0;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  border-radius: 22px;
  /* Near-opaque on purpose: the sheet sits over hero copy, and a see-through
     menu is unreadable. (Nested backdrop-filter inside the blurred capsule
     doesn't reliably blur anyway.) */
  background: #0b0817;
  border: 1px solid rgba(139, 92, 246, 0.26);
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.65);
}

.nav-sheet a {
  padding: 12px 16px;
  border-radius: 14px;
  color: var(--text-dim);
  font-size: 14.5px;
  font-weight: 550;
}

.nav-sheet a:active { background: rgba(255, 255, 255, 0.05); }

.nav-sheet a.active {
  color: #fff;
  background: linear-gradient(120deg, rgba(139, 92, 246, 0.3), rgba(232, 121, 249, 0.16));
  box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.35) inset;
}

.nav-sheet .sheet-cta {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-sheet .sheet-cta .btn { justify-content: center; text-align: center; }

.topnav.open .nav-sheet { display: flex; animation: sheet-in 0.22s var(--ease); }

@keyframes sheet-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}

/* =========================================================================
   Layout
   ========================================================================= */

.page {
  max-width: 1240px;
  margin: 0 auto;
  padding: 30px 22px 72px;
}

.page-wide {
  max-width: 1560px;
  margin: 0 auto;
  padding: 20px 18px 44px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-sub {
  color: var(--text-dim);
  font-size: 13.5px;
  margin-top: 3px;
}

.grid {
  display: grid;
  gap: 14px;
}
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

.row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.row-tight { gap: 6px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }

.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* =========================================================================
   Cards & panels — glass with a top highlight
   ========================================================================= */

.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.022), transparent 42%), var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 17px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

.card-lg {
  padding: 24px;
  border-radius: var(--radius-lg);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 13px;
}

.card-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}

.card-title::before {
  content: '';
  width: 3px;
  height: 11px;
  border-radius: 2px;
  background: var(--grad);
  opacity: 0.9;
}

.card-flush {
  padding: 0;
  overflow: hidden;
}
.card-flush .card-head {
  padding: 14px 16px 0;
  margin-bottom: 10px;
}

/* Stat tile */
.stat {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.022), transparent 42%), var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 16px 17px;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

.stat-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-faint);
}

.stat-value {
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin-top: 6px;
  line-height: 1.12;
}

.stat-value.sm { font-size: 18px; }
.stat-value.gold { color: var(--gold); }
.stat-value.up { color: var(--up); }
.stat-value.down { color: var(--down); }

.stat-note {
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 4px;
}

.stat-accent::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--grad);
}
.stat-accent {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035), 0 0 32px -18px rgba(139, 92, 246, 0.6);
}

/* =========================================================================
   Buttons
   ========================================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 17px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--grad);
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1) inset, 0 8px 24px -10px rgba(139, 92, 246, 0.7);
  transition: filter 0.15s var(--ease), box-shadow 0.15s var(--ease),
    transform 0.06s var(--ease), opacity 0.15s var(--ease);
}

.btn:hover {
  filter: brightness(1.12);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14) inset, 0 10px 30px -10px rgba(139, 92, 246, 0.85);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-ghost {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--text);
  box-shadow: none;
}
.btn-ghost:hover { background: var(--surface-3); border-color: var(--accent-dim); filter: none; box-shadow: none; }

.btn-quiet {
  background: transparent;
  border-color: var(--line);
  color: var(--text-dim);
  box-shadow: none;
}
.btn-quiet:hover { background: var(--surface-2); color: var(--text); filter: none; box-shadow: none; }

.btn-buy {
  background: linear-gradient(120deg, #22d497, var(--up));
  color: #032b1f;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12) inset, 0 8px 24px -10px rgba(46, 230, 168, 0.6);
}
.btn-buy:hover { filter: brightness(1.08); }
.btn-sell {
  background: linear-gradient(120deg, #ff6d85, var(--down));
  color: #fff;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12) inset, 0 8px 24px -10px rgba(255, 93, 120, 0.6);
}
.btn-sell:hover { filter: brightness(1.08); }

.btn-lg { padding: 12px 25px; font-size: 14px; border-radius: var(--radius-sm); }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-block { width: 100%; }

/* =========================================================================
   Forms
   ========================================================================= */

.field { display: block; }

.label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
  margin-bottom: 5px;
}

.input,
.select {
  width: 100%;
  padding: 9px 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.input:focus,
.select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), 0 0 18px -6px rgba(139, 92, 246, 0.5);
}

.input::placeholder { color: var(--text-faint); }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5L6 8l3-3.5' stroke='%23969eb8' stroke-width='1.4' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  padding-right: 28px;
}

.input-affix {
  position: relative;
}
.input-affix .affix {
  position: absolute;
  right: 11px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: var(--text-faint);
  pointer-events: none;
  font-weight: 600;
}
.input-affix .input { padding-right: 54px; }

/* Segmented control (buy/sell, order type) */
.segment {
  display: grid;
  grid-auto-flow: column;
  gap: 3px;
  padding: 3px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.segment button {
  padding: 7px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.segment button:hover { color: var(--text); }
.segment button[aria-selected='true'] { background: var(--surface-3); color: var(--text); }
.segment button[aria-selected='true'][data-side='Buy'] { background: var(--up-soft); color: var(--up); box-shadow: 0 0 12px -4px rgba(46, 230, 168, 0.5); }
.segment button[aria-selected='true'][data-side='Sell'] { background: var(--down-soft); color: var(--down); box-shadow: 0 0 12px -4px rgba(255, 93, 120, 0.5); }

/* =========================================================================
   Badges, pills, tags
   ========================================================================= */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2.5px 9px;
  border-radius: 99px;
  background: var(--surface-3);
  border: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.badge-live { background: var(--up-soft); border-color: rgba(46, 230, 168, 0.25); color: var(--up); }
.badge-warn { background: rgba(245, 167, 66, 0.13); border-color: rgba(245, 167, 66, 0.25); color: var(--warn); }
.badge-down { background: var(--down-soft); border-color: rgba(255, 93, 120, 0.25); color: var(--down); }
.badge-accent { background: var(--accent-soft); border-color: rgba(139, 92, 246, 0.3); color: var(--accent-hot); }

.dot {
  width: 6px;
  height: 6px;
  border-radius: 99px;
  background: currentColor;
  flex: none;
}

.dot-pulse { animation: pulse 2s var(--ease) infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* =========================================================================
   Tables
   ========================================================================= */

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  padding: 8px 14px;
  text-align: left;
  font-size: 10.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
}

.table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
}

.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: rgba(255, 255, 255, 0.025); }
.table .right { text-align: right; }

.table-empty {
  padding: 26px 14px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
}

/* =========================================================================
   Order book — depth shading behind the numbers
   ========================================================================= */

.book-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.book-table th {
  padding: 5px 12px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  text-align: right;
}
.book-table th:first-child { text-align: left; }

.book-table td {
  padding: 3.5px 12px;
  text-align: right;
  position: relative;
  font-family: var(--mono);
  font-size: 12px;
}
.book-table td:first-child { text-align: left; font-weight: 600; }

/* Depth shading is a row-level background gradient set inline from cumulative
   volume — see renderBook(). */
.book-row { cursor: pointer; }
.book-row:hover td { background: rgba(255, 255, 255, 0.04); }

.book-spread {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  padding: 10px 12px;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
}

.book-mid {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.book-spread-val {
  font-size: 11.5px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

/* =========================================================================
   Event feed
   ========================================================================= */

.feed {
  max-height: 320px;
  overflow-y: auto;
}

.feed-item {
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12.5px;
  color: var(--text-dim);
  animation: feed-in 0.3s var(--ease);
}

.feed-item:last-child { border-bottom: 0; }
.feed-time { color: var(--text-faint); font-size: 11px; font-variant-numeric: tabular-nums; flex: none; font-family: var(--mono); }
.feed-item.hot { color: var(--text); }
.feed-item.hot .feed-body { font-weight: 560; }

@keyframes feed-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

/* =========================================================================
   Balances
   ========================================================================= */

.balance {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
}
.balance:last-child { border-bottom: 0; }

.balance-asset { display: flex; align-items: center; gap: 9px; font-weight: 560; }

.asset-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: var(--surface-3);
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 13px;
  flex: none;
}
.asset-icon.gold { background: var(--gold-soft); border-color: rgba(246, 201, 69, 0.25); }
.asset-icon.usd { background: var(--up-soft); border-color: rgba(46, 230, 168, 0.2); }

.balance-amount { text-align: right; font-variant-numeric: tabular-nums; font-weight: 620; }
.balance-held { font-size: 11px; color: var(--text-faint); font-weight: 500; }

/* =========================================================================
   Code
   ========================================================================= */

.code {
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 16px 18px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.65;
  overflow-x: auto;
  color: #c8d0e6;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.code .k { color: #c792ea; }   /* keyword */
.code .s { color: #a8e07e; }   /* string  */
.code .f { color: #82aaff; }   /* fn      */
.code .c { color: var(--text-faint); font-style: italic; }
.code .n { color: var(--gold); }   /* number  */

.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0;
  font-size: 11.5px;
  color: var(--text-dim);
  font-family: var(--mono);
}
.code-head + .code { border-radius: 0 0 var(--radius) var(--radius); }

kbd {
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
}

/* =========================================================================
   Toasts
   ========================================================================= */

.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  min-width: 260px;
  max-width: 380px;
  padding: 12px 15px;
  background: rgba(17, 21, 39, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  animation: toast-in 0.25s var(--spring);
}

.toast.ok { border-left-color: var(--up); }
.toast.err { border-left-color: var(--down); }
.toast.out { animation: toast-out 0.2s var(--ease) forwards; }
.toast-title { font-weight: 620; }
.toast-body { color: var(--text-dim); font-size: 12.5px; margin-top: 1px; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: none; }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateX(16px); }
}

/* =========================================================================
   Utilities
   ========================================================================= */

.dim { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.gold { color: var(--gold); }
.up { color: var(--up); }
.down { color: var(--down); }
.accent { color: var(--accent-hot); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.bold { font-weight: 640; }
.center { text-align: center; }
.right { text-align: right; }
.hide { display: none !important; }
.divider { height: 1px; background: var(--line-soft); border: 0; }
.mt { margin-top: 12px; }
.mt-lg { margin-top: 24px; }
.mb { margin-bottom: 12px; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Gradient text — headline highlights only */
.grad-text {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 5px;
  color: transparent !important;
}

@keyframes shimmer {
  to { background-position: -200% 0; }
}

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

@media (max-width: 780px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .page, .page-wide { padding: 16px 14px 40px; }
}

/* Mid widths: tighten before folding into the burger. */
@media (max-width: 1120px) {
  .topnav { gap: 10px; }
  .nav-links a { padding: 8px 9px; font-size: 13px; }
  .nav-xp .lbl { display: none; }
}

/* Nav goes burger below 900px — links and desktop CTAs fold into the sheet;
   the XP chip stays out, because it's the fun part. */
@media (max-width: 900px) {
  .topnav { gap: 10px; height: 54px; padding: 0 8px 0 12px; top: 10px; }
  body { padding-top: 74px; }
  .topnav > .nav-links, .topnav > .nav-right .btn { display: none; }
  .nav-burger { display: grid; }
  .nav-xp { padding-right: 10px; }
  .nav-xp .lbl { display: none; } /* ring + level only — the label is noise at this size */
}

/* =========================================================================
   Motion layer — the gamified feel, kept on a leash.
   Rules: money numbers never bounce for fun (they flash on CHANGE), motion
   respects prefers-reduced-motion, and nothing loops loudly enough to make
   a trading screen feel like a slot machine.
   ========================================================================= */

/* ── Rarity (loot) ─────────────────────────────────────────────────────── */
:root {
  --rar-common: #9aa4b8;
  --rar-rare: #4da3ff;
  --rar-epic: #b465ff;
  --rar-legendary: #f5a742;
}

.rarity-common    { --rar: var(--rar-common); }
.rarity-rare      { --rar: var(--rar-rare); }
.rarity-epic      { --rar: var(--rar-epic); }
.rarity-legendary { --rar: var(--rar-legendary); }

.loot-card.rarity-rare,
.loot-card.rarity-epic,
.loot-card.rarity-legendary {
  border-color: color-mix(in srgb, var(--rar) 55%, var(--line));
  box-shadow: 0 0 14px -6px var(--rar);
}
.loot-card .loot-name { color: color-mix(in srgb, var(--rar, var(--text)) 70%, var(--text)); }
.loot-card.rarity-legendary {
  animation: legendary-pulse 2.6s var(--ease) infinite;
}
@keyframes legendary-pulse {
  0%, 100% { box-shadow: 0 0 14px -6px var(--rar); }
  50% { box-shadow: 0 0 22px -4px var(--rar); }
}
.rarity-tag {
  font-size: 9.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--rar, var(--text-dim));
}

/* ── Price / value flashes: signal CHANGE, then get out of the way ─────── */
@keyframes flash-up   { 0% { color: var(--up); text-shadow: 0 0 12px rgba(46,230,168,.55); } 100% { color: inherit; text-shadow: none; } }
@keyframes flash-down { 0% { color: var(--down); text-shadow: 0 0 12px rgba(255,93,120,.55); } 100% { color: inherit; text-shadow: none; } }
.flash-up   { animation: flash-up 0.9s var(--ease); }
.flash-down { animation: flash-down 0.9s var(--ease); }

@keyframes row-flash-up   { from { background: var(--up-soft); } to { background: transparent; } }
@keyframes row-flash-down { from { background: var(--down-soft); } to { background: transparent; } }
.row-flash-up   td { animation: row-flash-up 0.8s var(--ease); }
.row-flash-down td { animation: row-flash-down 0.8s var(--ease); }

/* ── Button shine sweep on hover ───────────────────────────────────────── */
.btn { position: relative; overflow: hidden; }
.btn::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,.18) 50%, transparent 60%);
  transform: translateX(-120%);
  pointer-events: none;
}
.btn:hover::after { transition: transform .55s var(--ease); transform: translateX(120%); }

/* ── Card hover: lift + accent glow (opt-in via .card-game) ────────────── */
.card-game { transition: transform .18s var(--ease), border-color .18s var(--ease), box-shadow .18s var(--ease); }
.card-game:hover {
  transform: translateY(-2px);
  border-color: var(--accent-dim);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.035), 0 0 28px -12px rgba(139, 92, 246,.7);
}

/* ── XP bar ────────────────────────────────────────────────────────────── */
.xp-bar { position: relative; height: 10px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.xp-fill {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--gold), #ffdf8a);
  transition: width .6s var(--spring);
  box-shadow: 0 0 10px rgba(246,201,69,.45);
}
.xp-fill::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 30%, rgba(255,255,255,.35) 50%, transparent 70%);
  animation: xp-shimmer 2.2s linear infinite;
}
@keyframes xp-shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

.level-badge {
  display: inline-grid; place-items: center; width: 34px; height: 34px; flex: none;
  border-radius: 10px; font-weight: 800; font-size: 15px; color: #241a02;
  font-family: var(--display);
  background: linear-gradient(140deg, #ffdf8a, var(--gold));
  box-shadow: 0 0 14px -2px rgba(246,201,69,.5), inset 0 0 0 1px rgba(255,255,255,.35);
}

@keyframes level-up-pop {
  0% { transform: scale(1); } 35% { transform: scale(1.35) rotate(-4deg); } 100% { transform: scale(1); }
}
.level-up { animation: level-up-pop .7s cubic-bezier(.22, 1.4, .36, 1); }

/* ── Combo counter ─────────────────────────────────────────────────────── */
.combo {
  position: absolute; right: 16px; bottom: 14px; pointer-events: none;
  font-family: var(--display);
  font-weight: 700; font-size: 26px; letter-spacing: -.02em;
  color: var(--gold); text-shadow: 0 2px 16px rgba(246,201,69,.5);
  opacity: 0; transform: scale(.8);
}
.combo.show { animation: combo-in .3s cubic-bezier(.22, 1.4, .36, 1) forwards; }
@keyframes combo-in { to { opacity: 1; transform: scale(1); } }

/* ── Scroll reveal (landing) ───────────────────────────────────────────── */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .6s var(--ease), transform .6s var(--ease); }
.reveal.in { opacity: 1; transform: none; }
.reveal-d1 { transition-delay: .08s; } .reveal-d2 { transition-delay: .16s; } .reveal-d3 { transition-delay: .24s; }

/* ── Ambient canvas layers ─────────────────────────────────────────────── */
.ambient {
  position: absolute; inset: 0; pointer-events: none; z-index: 0;
}

/* ── Live ticker strip ─────────────────────────────────────────────────── */
.ticker-strip {
  display: flex; gap: 34px; overflow: hidden; white-space: nowrap;
  mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}
.ticker-track { display: flex; gap: 34px; animation: ticker-scroll 28s linear infinite; }
@keyframes ticker-scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.ticker-item { display: inline-flex; gap: 8px; align-items: baseline; font-size: 12.5px; color: var(--text-dim); }
.ticker-item b { color: var(--text); font-variant-numeric: tabular-nums; font-family: var(--mono); }

/* ── Respect reduced motion: kill the sugar, keep the meaning ──────────── */
@media (prefers-reduced-motion: reduce) {
  .topnav::before { animation: none; }
  .topnav.open .nav-sheet { animation: none; }
  .btn::after, .xp-fill::after { display: none; }
  .loot-card.rarity-legendary, .ticker-track { animation: none; }
  .reveal { opacity: 1; transform: none; transition: none; }
  * { animation-duration: .001s !important; transition-duration: .001s !important; }
}

/* =========================================================================
   Icons — inline SVG on currentColor, sized by the element that holds them.
   ========================================================================= */
.ico {
  width: 1.15em; height: 1.15em;
  flex: none;
  display: inline-block;
  vertical-align: -0.19em;
}
.ico-lg { width: 20px; height: 20px; }
.ico-sm { width: 14px; height: 14px; }

/* Icon tile — the square badge a module or asset icon sits in */
.ico-tile {
  display: grid; place-items: center;
  width: 40px; height: 40px; flex: none;
  border-radius: 11px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-dim);
  color: var(--accent-hot);
}
.ico-tile .ico { width: 20px; height: 20px; }
.ico-tile.gold { background: var(--gold-soft); border-color: rgba(246,201,69,.28); color: var(--gold); }
.ico-tile.up   { background: var(--up-soft);   border-color: rgba(46,230,168,.28);  color: var(--up); }
.ico-tile.neutral { background: var(--surface-3); border-color: var(--line); color: var(--text-dim); }
.ico-tile.sm { width: 28px; height: 28px; border-radius: 9px; }
.ico-tile.sm .ico { width: 15px; height: 15px; }

/* Brand switcher — the white-label proof */
.brand-swatches { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.swatch {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 9px 15px 9px 11px; border-radius: 99px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line);
  color: var(--text-dim); font-family: inherit; font-size: 13px; font-weight: 560;
  transition: border-color .15s var(--ease), color .15s var(--ease), transform .12s var(--ease);
}
.swatch:hover { color: var(--text); transform: translateY(-1px); }
.swatch[aria-pressed='true'] { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }
.swatch .dab {
  width: 17px; height: 17px; border-radius: 99px; flex: none;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.22);
}

/* =========================================================================
   Mobile — measured with scripts/mobile-audit.mjs at 375×812, not guessed.
   ========================================================================= */

@media (max-width: 820px) {
  /*
   * THE fix for horizontal scroll. Grid and flex children default to
   * min-width:auto, so anything with wide intrinsic content — a code block,
   * a table, a long chip — refuses to shrink and drags the whole page
   * sideways. The landing page measured 525px wide in a 375px viewport
   * before this line.
   */
  .grid > *, .stack > *, .row > *, .bento > *, .terminal > *, .console > * { min-width: 0; }

  /* Anything that is genuinely wider than a phone scrolls inside itself
     rather than widening the document. */
  pre, .code, table { max-width: 100%; }
  pre, .code { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* A readable floor. 10–11px is fine on a monitor at arm's length and
     unreadable held in one hand. */
  .tiny, .stat-label, .card-title, .label, .badge, .stat-note,
  .balance-held, .feed-time, .book-table th, .table th { font-size: 12px; }
  .small, .book-table td, .table td, .feed-item { font-size: 13px; }
  body { font-size: 15px; }

  /* Cards and page padding tighten so content is not squeezed into a column
     of margins. */
  .page, .page-wide { padding: 16px 14px 40px; }
  .card { padding: 15px; }
  .card-lg { padding: 18px; }
}

/*
 * Touch targets. Keyed on pointer:coarse rather than width so a small laptop
 * window keeps its compact controls while a phone or tablet gets thumbs-sized
 * ones. 44px is the accessibility floor; the audit found 27–36px controls.
 */
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .btn-sm { min-height: 38px; }
  .btn-lg { min-height: 50px; }
  .input, .select { min-height: 44px; }
  .segment button { min-height: 40px; }
  .nav-links a { padding-top: 12px; padding-bottom: 12px; }
  .brand { padding: 8px 0; }
  /* Book rows are tap-to-fill, so they need a real target too. */
  .book-table td { padding-top: 7px; padding-bottom: 7px; }
}

@media (max-width: 640px) {
  /* Phones use the burger sheet (see the 900px block); the capsule keeps
     the full brand and the XP chip — links and CTAs live in the sheet. */
  /* The pair picker's chevron was overlapping the label. */
  .select { padding-right: 34px; }

  /* Secondary labels that were 10–10.5px: still quiet, now legible. */
  .trust-label, .option-tag, .loot-sym, .lp-stat .k,
  .market-stat .stat-label, .rarity-tag { font-size: 11.5px; }
  .mono { font-size: 12px; }

  /* Footer links are pure text; give them a real tap height. */
  footer .stack a { padding: 6px 0; }
}

/* =========================================================================
   Game-feel layer v2 — tilt, magnetic CTA, flying rewards, damage vignette.
   Transform/opacity only; every effect dies under prefers-reduced-motion.
   ========================================================================= */

.tilt {
  position: relative;
  transform-style: preserve-3d;
  transition: transform .35s var(--spring);
  will-change: transform;
}
.tilt-glare {
  position: absolute; inset: 0; z-index: 3;
  border-radius: inherit; pointer-events: none;
  background: transparent;
}

/* Reward particle in flight — fixed so it can travel across the layout. */
.fly-coin {
  position: fixed; left: 0; top: 0; z-index: 240;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  color: var(--gold);
  filter: drop-shadow(0 0 6px rgba(246, 201, 69, .65));
  pointer-events: none;
}
.fly-coin .ico { width: 100%; height: 100%; }

/* The destination acknowledges the arrival. */
@keyframes pulse-target {
  0% { transform: scale(1); }
  40% { transform: scale(1.18); }
  100% { transform: scale(1); }
}
.pulse-target { animation: pulse-target .5s var(--spring); }

/* Damage vignette: an edge flash inside the arena frame. */
.hit-vignette {
  position: absolute; inset: 0; z-index: 4;
  border-radius: inherit; pointer-events: none; opacity: 0;
  box-shadow: inset 0 0 42px 6px rgba(255, 93, 120, .38);
}
.hit-vignette.boss { box-shadow: inset 0 0 64px 12px rgba(255, 93, 120, .55); }
@keyframes vignette-flash { 0% { opacity: 1; } 100% { opacity: 0; } }
.hit-vignette.on { animation: vignette-flash .45s ease-out forwards; }

@media (prefers-reduced-motion: reduce) {
  .tilt { transition: none; transform: none !important; }
  .tilt-glare, .hit-vignette, .fly-coin { display: none; }
  .pulse-target { animation: none; }
}
