/* ── Design tokens ── */
:root {
  --sun: #FFD700; --sun2: #FFA500; --sun3: #CC8800;
  --bg: #0D0D1A;  --bg2: #12122A; --bg3: #1A1A3A;
  --panel: #1E1E40; --panel2: #252550;
  --border: #3A3A7A;
  --text: #E8E8FF; --muted: #9898CC;
  --green: #39FF6E; --red: #FF4466;
  --blue: #4488FF; --cyan: #00FFEE; --pink: #FF2D78;
  --silver: #C0C0C0; --bronze: #CD7F32;
  --gold-glow: rgba(255, 215,   0, .35);
  --silver-glow: rgba(192, 192, 192, .25);
  --bronze-glow: rgba(205, 127,  50, .25);
  --sidebar-w: 216px;
  --sidebar-col: 52px;
  --topbar-h: 54px;
}

/* ── Reset ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body, #root { height: 100%; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
}

/* scanline overlay */
body::after {
  content: '';
  position: fixed; inset: 0;
  background: repeating-linear-gradient(
    0deg, transparent, transparent 2px,
    rgba(0,0,0,0.06) 2px, rgba(0,0,0,0.06) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

/* scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--sun3); }

@media (prefers-reduced-motion: reduce) {
  .lb-rank-1, .lb-empty-icon, .lb-skeleton,
  .reveal-up, .typewriter-cursor,
  .count-up, .confetti-px {
    animation: none !important;
  }
}

/* ── Animations ── */
@keyframes rotateSun { to { transform: rotate(360deg); } }
.topbar-logo svg { animation: rotateSun 10s linear infinite; flex-shrink: 0; }
@keyframes blink { 0%,100% { opacity:1; } 50% { opacity:0; } }
@keyframes glow { 0%,100% { box-shadow:0 0 8px rgba(255,215,0,.3); } 50% { box-shadow:0 0 22px rgba(255,215,0,.65); } }
@keyframes slideInRight { from { transform: translateX(110%); } to { transform: translateX(0); } }
@keyframes fadeUp { from { opacity:0; transform:translateY(12px); } to { opacity:1; transform:translateY(0); } }
@keyframes claimPulse {
  0%,100% { box-shadow: 3px 3px 0 var(--sun3), 5px 5px 0 rgba(0,0,0,.5), 0 0 0px rgba(255,215,0,0); }
  50%      { box-shadow: 3px 3px 0 var(--sun3), 5px 5px 0 rgba(0,0,0,.5), 0 0 22px rgba(255,215,0,0.75); }
}
.daily-claim-pulse { animation: claimPulse 1.6s ease-in-out 3; }
@keyframes modalPopIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes crtOpen {
  from { transform: scaleY(0.04); }
  to   { transform: scaleY(1); }
}
@keyframes tabGlitchIn {
  0%   { opacity: 0; transform: translateX(-8px); }
  100% { opacity: 1; transform: translateX(0); }
}
@keyframes metricActivate {
  0%   { box-shadow: none; }
  50%  { box-shadow: inset 0 0 0 1px rgba(255,215,0,.9), 0 0 18px rgba(255,215,0,.55); }
  100% { box-shadow: inset 0 0 0 1px rgba(255,215,0,.35); }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes podiumRise {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes goldPulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--bg), 4px 4px 0 var(--sun3), 0 0 18px var(--gold-glow); }
  50%      { box-shadow: 0 0 0 3px var(--bg), 4px 4px 0 var(--sun3), 0 0 40px rgba(255,215,0,.7); }
}
@keyframes scanBeam {
  from { transform: translateY(-100%); }
  to   { transform: translateY(100%);  }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ── Phase 0 primitives ── */
@keyframes fadeUp { from { opacity:0; transform:translateY(12px); } to { opacity:1; transform:translateY(0); } }
.reveal-up {
  opacity: 0;
  animation: fadeUp .42s ease forwards;
  animation-delay: var(--reveal-delay, 0ms);
}

.typewriter-cursor {
  display: inline-block;
  width: 6px;
  height: 1em;
  background: var(--cyan);
  animation: blink .8s step-end infinite;
  margin-left: 2px;
}

.stat-tile {
  background: var(--bg);
  border: 2px solid var(--border);
  padding: 10px 14px;
  min-width: 100px;
}
.stat-tile-label {
  font-size: 8px;
  color: var(--muted);
  letter-spacing: 1px;
  margin-bottom: 4px;
  white-space: nowrap;
}
.stat-tile-value {
  font-family: 'VT323', monospace;
  font-size: 26px;
  line-height: 1;
}
.stat-tile-trend {
  font-family: 'VT323', monospace;
  font-size: 13px;
  margin-top: 4px;
  line-height: 1;
}
.stat-tile-trend-up   { color: var(--green); }
.stat-tile-trend-down { color: var(--red); }
.stat-tile-trend-flat { color: var(--muted); }
.stat-tile-sub {
  font-family: 'VT323', monospace;
  font-size: 13px;
  color: var(--muted);
  margin-top: 3px;
}

.wallet-tile {
  background: var(--bg);
  border: 2px solid var(--border);
  padding: 10px 16px;
  min-width: 110px;
  transition: opacity .1s;
}
.wallet-tile-label {
  font-size: 7px;
  color: var(--muted);
  margin-bottom: 4px;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.wallet-tile-badge {
  font-size: 6px;
  background: rgba(255,215,0,.15);
  border: 1px solid rgba(255,215,0,.25);
  color: var(--sun);
  padding: 1px 4px;
  margin-left: auto;
}
.wallet-tile-value {
  font-family: 'VT323', monospace;
  font-size: 26px;
  line-height: 1;
}

@media (prefers-reduced-motion: reduce) {
  .reveal-up,
  .typewriter-cursor { animation: none !important; }
}

/* ── Profile hero (Phase 1) ── */
.profile-hero {
  position: relative;
  overflow: hidden;
}
.profile-hero.crt-open {
  animation: crtOpen 240ms steps(12, end) forwards;
  transform-origin: center;
}

.profile-hero-stars {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
.hero-star {
  position: absolute;
  width: 3px;
  height: 3px;
  background: rgba(255, 255, 255, 0.6);
  animation: twinkle var(--dur, 3s) infinite;
}
@keyframes twinkle { 0%,100% { opacity: 1; } 50% { opacity: 0.1; } }

.avatar-ring {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.avatar-ring-spin {
  position: absolute;
  inset: -6px;
  background: conic-gradient(
    var(--sun) 0 12.5%, transparent 12.5% 25%,
    var(--sun2) 25% 37.5%, transparent 37.5% 50%,
    var(--sun) 50% 62.5%, transparent 62.5% 75%,
    var(--sun2) 75% 87.5%, transparent 87.5% 100%
  );
  animation: rotateSun 14s linear infinite;
  filter: drop-shadow(0 0 6px rgba(255,215,0,.35));
  pointer-events: none;
}
.avatar-ring-inner {
  position: absolute;
  inset: 0;
  background: var(--bg);
  border: 4px solid var(--sun);
  box-shadow: 4px 4px 0 var(--sun3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 42px;
  overflow: hidden;
}
.avatar-ring-inner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
}

.hero-bootline {
  display: block;
  margin-bottom: 8px;
  min-height: 1.4em;
}

.wallet-row {
  /* flexWrap already handled by parent */
}

@media (prefers-reduced-motion: reduce) {
  .profile-hero.crt-open { animation: none; }
  .avatar-ring-spin { animation: none; }
  .hero-star { animation: none; }
}

/* ── Daily Bonus Card (Phase 2) ── */
.daily-bonus-card {
  background: var(--panel2);
}
.daily-layout {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  gap: 20px;
  align-items: center;
}
.daily-streak-col {
  text-align: center;
}
.daily-streak-num {
  font-family: 'VT323', monospace;
  font-size: 32px;
  color: var(--sun);
  line-height: 1;
  margin-bottom: 4px;
}
.daily-streak-label {
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 1px;
}
.daily-warning {
  font-size: 8px;
  color: var(--red);
  margin-top: 8px;
  padding: 6px;
  background: rgba(255, 68, 102, 0.1);
  border: 1px solid var(--red);
  letter-spacing: 0.5px;
}

.daily-cooldown-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cooldown-bar {
  position: relative;
  height: 24px;
  background: var(--bg);
  border: 2px solid var(--border);
  overflow: hidden;
}
.cooldown-bar-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: var(--pct-remaining, 100%);
  background: var(--sun3);
  transition: width .1s linear;
}
.cooldown-bar-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'VT323', monospace;
  font-size: 14px;
  color: var(--text);
  mix-blend-mode: difference;
  z-index: 1;
}
.daily-sublabel {
  font-size: 8px;
  color: var(--muted);
  text-align: center;
  letter-spacing: 1px;
}

.daily-bonus-desc {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.daily-bonus-desc > div:first-child {
  font-family: 'VT323', monospace;
  font-size: 14px;
  color: var(--muted);
}
.web-bonus-ribbon {
  font-family: 'VT323', monospace;
  font-size: 14px;
  color: var(--sun);
  background: rgba(255,215,0,.08);
  border: 1px solid rgba(255,215,0,.25);
  padding: 4px 8px;
  text-align: center;
}

.daily-cta-col {
  display: flex;
  justify-content: flex-end;
}

@keyframes confettiFly {
  to { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; }
}
.confetti-px {
  position: fixed;
  width: 8px;
  height: 8px;
  pointer-events: none;
  z-index: 3000;
  animation: confettiFly 1.2s cubic-bezier(.2,.7,.4,1) forwards;
}

@media (max-width: 960px) {
  .daily-layout {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .daily-streak-col { order: 1; }
  .daily-cooldown-col { order: 2; }
  .daily-cta-col { order: 3; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  .daily-claim-pulse { animation: none !important; }
  .confetti-px { animation: none !important; }
}

/* ── Since-Last-Visit Ribbon (Phase 3) ── */
.slvr-ribbon {
  background: var(--panel);
  border: 2px solid var(--sun);
  border-left: 4px solid var(--sun);
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  animation: slideInRight .3s ease;
  box-shadow: 4px 4px 0 rgba(0,0,0,.6);
}
.slvr-content {
  flex: 1;
}
.slvr-title {
  display: block;
  font-size: 9px;
  color: var(--sun);
  margin-bottom: 4px;
  letter-spacing: 1px;
  font-weight: bold;
}
.slvr-deltas {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-family: 'VT323', monospace;
  font-size: 14px;
  color: var(--green);
}
.slvr-x {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  padding: 0 4px;
  flex-shrink: 0;
  transition: color .1s;
}
.slvr-x:hover {
  color: var(--sun);
}

/* ── Rank Showcase (Phase 4) ── */
.rank-showcase-card {
  /* inherited .card styles */
}
.rank-showcase-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.rank-chip {
  background: var(--bg);
  border: 2px solid var(--border);
  padding: 12px 10px;
  text-align: center;
  cursor: pointer;
  transition: all .1s;
  position: relative;
}
.rank-chip:hover {
  border-color: var(--sun);
  transform: translate(-2px, -2px);
  box-shadow: 4px 4px 0 rgba(0,0,0,.6);
}

.rank-chip-label {
  font-size: 8px;
  color: var(--muted);
  margin-bottom: 6px;
  letter-spacing: 1px;
  white-space: nowrap;
}
.rank-chip-value {
  font-family: 'VT323', monospace;
  font-size: 28px;
  line-height: 1;
  margin-bottom: 4px;
}
.rank-chip-delta {
  font-family: 'VT323', monospace;
  font-size: 12px;
  margin-top: 4px;
}
.rank-chip-delta.up { color: var(--green); }
.rank-chip-delta.down { color: var(--red); }

@media (max-width: 960px) {
  .rank-showcase-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 640px) {
  .rank-showcase-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Login screen ── */
.login-screen {
  height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.login-card {
  background: var(--panel2); border: 4px solid var(--sun);
  box-shadow: 8px 8px 0 var(--sun3), 0 0 40px rgba(255,215,0,0.15);
  width: 100%; max-width: 420px; text-align: center;
}
.login-header {
  background: var(--sun); color: var(--bg);
  padding: 16px 24px; display: flex; align-items: center; justify-content: center; gap: 14px;
}
.login-header-title { font-size: 14px; letter-spacing: 2px; }
.login-body { padding: 32px 28px; }
.login-tagline {
  fontFamily: 'VT323', monospace; font-size: 18px;
  color: var(--muted); line-height: 1.7; margin-bottom: 28px;
}
.login-btn {
  display: inline-flex; align-items: center; gap: 10px;
  background: #5865F2; color: #fff;
  border: 3px solid #4752c4;
  box-shadow: 3px 3px 0 #4752c4;
  font-family: 'Press Start 2P', monospace; font-size: 9px;
  padding: 12px 20px; cursor: pointer; text-decoration: none;
  transition: all 0.1s;
}
.login-btn:hover { transform: translate(-2px,-2px); box-shadow: 5px 5px 0 #4752c4; }
.login-error {
  font-family: 'VT323', monospace; font-size: 16px; color: var(--red);
  margin-bottom: 16px;
}

/* ── Loading spinner ── */
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--sun);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.loading-screen {
  height: 100vh; display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 16px;
}
.loading-label { font-size: 8px; color: var(--muted); letter-spacing: 2px; }

/* ── TopBar ── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg2);
  border-bottom: 3px solid var(--border);
  display: flex; align-items: center;
  padding: 0 18px; gap: 12px;
  flex-shrink: 0;
  box-shadow: 0 4px 0 rgba(0,0,0,.55);
  z-index: 100;
}
.sidebar-hamburger {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 18px; padding: 4px 6px;
  line-height: 1; flex-shrink: 0;
}
.sidebar-hamburger:hover { color: var(--sun); }
.topbar-logo {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--sun);
  text-shadow: 2px 2px 0 var(--sun3);
  letter-spacing: 2px; white-space: nowrap; flex-shrink: 0;
}
.guild-select {
  background: var(--panel); border: 2px solid var(--border);
  color: var(--text); font-family: 'Press Start 2P', monospace;
  font-size: 8px; padding: 6px 10px; cursor: pointer; outline: none;
}
.guild-select:focus { border-color: var(--sun); }
.notif-btn {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 18px; position: relative; padding: 4px;
  flex-shrink: 0;
}
.notif-btn:hover { color: var(--sun); }
.notif-badge {
  position: absolute; top: 0; right: 0;
  background: var(--red); color: #fff;
  font-family: 'Press Start 2P', monospace; font-size: 6px;
  width: 14px; height: 14px;
  display: flex; align-items: center; justify-content: center;
}
.user-pill {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 2px solid var(--border);
  padding: 4px 10px; cursor: pointer; flex-shrink: 0;
}
.user-pill:hover { border-color: var(--sun); }
.user-avatar {
  width: 28px; height: 28px;
  background: var(--sun);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; overflow: hidden;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-name { font-size: 8px; }
.badge-inline {
  font-size: 7px; padding: 2px 6px;
  border: 1px solid; font-family: 'Press Start 2P', monospace;
}
.badge-inline.gold { color: var(--sun); border-color: var(--sun3); background: rgba(255,215,0,.1); }
.logout-btn {
  background: none; border: 2px solid var(--border);
  color: var(--muted); font-family: 'Press Start 2P', monospace;
  font-size: 7px; padding: 6px 10px; cursor: pointer; flex-shrink: 0;
}
.logout-btn:hover { border-color: var(--red); color: var(--red); }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 3px solid var(--border);
  display: flex; flex-direction: column;
  transition: width 0.18s ease;
  flex-shrink: 0; overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-col); }
.nav-group { border-bottom: 2px solid var(--border); padding: 8px 0; }
.nav-group-label {
  font-size: 7px; color: var(--muted); padding: 6px 14px;
  letter-spacing: 2px; white-space: nowrap;
  transition: opacity 0.12s;
}
.sidebar.collapsed .nav-group-label { opacity: 0; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; cursor: pointer; width: 100%;
  color: var(--muted); font-size: 8px; white-space: nowrap;
  border: none; background: none; text-align: left;
  font-family: 'Press Start 2P', monospace;
  transition: background 0.1s, color 0.1s;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active {
  background: var(--panel); color: var(--sun);
  border-left-color: var(--sun);
  box-shadow: inset 0 0 24px rgba(255,215,0,.05);
}
.nav-icon { font-size: 15px; width: 22px; text-align: center; flex-shrink: 0; }
.nav-label { white-space: nowrap; overflow: hidden; }
.sidebar.collapsed .nav-label { display: none; }

/* ── Main layout ── */
.main-content {
  flex: 1; overflow-y: auto; padding: 24px;
  animation: fadeUp 0.25s ease;
}

/* ── Page header ── */
.page-header { margin-bottom: 22px; }
.page-label {
  font-size: 8px; color: var(--green);
  letter-spacing: 3px; margin-bottom: 8px;
  display: flex; align-items: center; gap: 6px;
}
.page-label::before { content: '> '; color: var(--sun); }
.page-title { font-size: 18px; color: var(--text); text-shadow: 2px 2px 0 rgba(0,0,0,.6); }

/* ── Card ── */
.card {
  background: var(--panel);
  border: 3px solid var(--border);
  box-shadow: 4px 4px 0 rgba(0,0,0,.6);
  padding: 20px;
}
.card-title { font-size: 9px; color: var(--sun); margin-bottom: 14px; letter-spacing: 1px; }

/* ── Grids ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }

/* ── Stat card ── */
.stat-card {
  background: var(--panel); border: 3px solid var(--border);
  box-shadow: 4px 4px 0 rgba(0,0,0,.6);
  padding: 16px; display: flex; flex-direction: column; gap: 6px;
}
.stat-card-label { font-size: 7px; color: var(--muted); letter-spacing: 1px; }
.stat-card-value { font-family: 'VT323', monospace; font-size: 34px; color: var(--sun); }
.stat-card-sub   { font-family: 'VT323', monospace; font-size: 14px; color: var(--muted); }

/* ── Pixel button ── */
.px-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px; padding: 10px 16px;
  border: 3px solid; cursor: pointer; display: inline-flex;
  align-items: center; gap: 6px; transition: all 0.1s;
  text-decoration: none; background: none;
}
.px-btn.sm { font-size: 7px; padding: 7px 11px; }
.px-btn.gold {
  background: var(--sun); color: var(--bg); border-color: var(--sun3);
  box-shadow: 3px 3px 0 var(--sun3), 5px 5px 0 rgba(0,0,0,.5);
}
.px-btn.gold:hover { transform: translate(-2px,-2px); box-shadow: 5px 5px 0 var(--sun3), 7px 7px 0 rgba(0,0,0,.5); }
.px-btn.gold:active { transform: translate(3px,3px); box-shadow: none; }
.px-btn.ghost {
  background: var(--panel2); color: var(--text); border-color: var(--border);
  box-shadow: 3px 3px 0 rgba(0,0,0,.5);
}
.px-btn.ghost:hover { border-color: var(--sun); color: var(--sun); transform: translate(-1px,-1px); }
.px-btn.danger { background: var(--panel2); color: var(--red); border-color: var(--red); box-shadow: 3px 3px 0 rgba(0,0,0,.5); }
.px-btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none !important; }

/* ── Badge ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 7px; padding: 3px 8px;
  border: 2px solid; font-family: 'Press Start 2P', monospace;
}
.badge.gold  { color: var(--sun);   border-color: var(--sun);   background: rgba(255,215,0,.1);  }
.badge.green { color: var(--green); border-color: var(--green); background: rgba(57,255,110,.1); }
.badge.red   { color: var(--red);   border-color: var(--red);   background: rgba(255,68,102,.1); }
.badge.blue  { color: var(--blue);  border-color: var(--blue);  background: rgba(68,136,255,.1); }
.badge.cyan  { color: var(--cyan);  border-color: var(--cyan);  background: rgba(0,255,238,.1);  }

/* ── Tabs ── */
.tabs { display: flex; border-bottom: 3px solid var(--border); margin-bottom: 20px; }
.tab-btn {
  font-family: 'Press Start 2P', monospace; font-size: 8px;
  padding: 10px 14px; background: none; border: none; cursor: pointer;
  color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -3px;
  transition: all 0.1s;
}
.tab-btn:hover { color: var(--text); background: rgba(255,255,255,.03); }
.tab-btn.active { color: var(--sun); border-bottom-color: var(--sun); background: var(--panel); }

/* ── Table ── */
.table-wrap { overflow-x: auto; }
.px-table { width: 100%; border-collapse: collapse; }
.px-table th {
  font-size: 7px; color: var(--sun); padding: 8px 10px;
  border-bottom: 2px solid var(--border); text-align: left; letter-spacing: 1px;
}
.px-table td {
  font-family: 'VT323', monospace; font-size: 17px;
  padding: 8px 10px; border-bottom: 1px solid rgba(255,255,255,.04);
}
.px-table tr:hover td { background: rgba(255,255,255,.03); }
.px-table tr.highlight td { background: rgba(255,215,0,.06); border-left: 3px solid var(--sun); }
.lb-th {
  cursor: pointer; user-select: none;
  transition: color .1s;
}
.lb-th:hover { color: var(--text); }
.lb-th.is-active { color: var(--sun); }
.lb-th-glyph {
  display: inline-block; min-width: 12px;
  font-family: 'VT323', monospace; font-size: 14px;
  color: var(--muted); margin-left: 4px;
}
.lb-th.is-active .lb-th-glyph { color: var(--sun); }

/* ── Achievements ── */
.achievement-grid { display: grid; grid-template-columns: repeat(5,1fr); gap: 10px; }
.ach-item {
  background: var(--panel2); border: 2px solid var(--border);
  padding: 12px 8px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  transition: border-color 0.1s;
}
.ach-item.unlocked { border-color: var(--sun); box-shadow: 0 0 10px rgba(255,215,0,.18); }
.ach-item.locked   { opacity: 0.55; filter: grayscale(0.7); }
.ach-icon { font-size: 22px; }
.ach-name { font-family: 'Press Start 2P', monospace; font-size: 8px; color: var(--text); line-height: 1.4; }
.ach-hint { font-family: 'VT323', monospace; font-size: 11px; color: var(--muted); line-height: 1.2; }
.ach-progress-bar {
  width: 100%; height: 4px; background: var(--border); border: 1px solid var(--border);
  overflow: hidden;
}
.ach-progress-fill { height: 100%; background: var(--green); transition: width 0.2s; }
.ach-strip {
  margin-bottom: 16px; padding-bottom: 12px; border-bottom: 2px solid var(--border);
}
.ach-strip-label {
  font-family: 'VT323', monospace; font-size: 10px; color: var(--muted); letter-spacing: 1px;
  margin-bottom: 8px; text-transform: uppercase;
}
.ach-strip-items {
  display: flex; gap: 10px; flex-wrap: wrap;
}
.ach-strip-items .ach-item { flex: 0 0 calc(20% - 8px); min-width: 80px; }
.ach-category-tabs {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.ach-tab {
  background: var(--panel); border: 2px solid var(--border);
  color: var(--text); padding: 6px 12px;
  cursor: pointer; transition: all 0.15s;
}
.ach-tab:hover { border-color: var(--sun); }
.ach-tab.active { border-color: var(--sun); background: var(--panel2); box-shadow: 0 0 8px rgba(255,215,0,.2); }

/* ── Inventory ── */
.inv-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; }
.inv-item {
  position: relative;
  background: var(--panel2); border: 2px solid var(--border);
  padding: 16px 12px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  transition: border-color 0.1s;
}
.inv-item:hover { border-color: var(--sun); }
.inv-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%; transform: translateX(-50%);
  background: var(--bg); border: 2px solid var(--sun);
  padding: 8px 10px;
  font-family: 'VT323', monospace; font-size: 14px; color: var(--text);
  white-space: normal; text-align: left;
  width: 180px; z-index: 100; pointer-events: none;
  box-shadow: 4px 4px 0 var(--sun3);
}
.inv-item:hover .inv-tooltip { display: block; }
.inv-icon { font-size: 30px; }
.inv-name { font-size: 7px; color: var(--sun); }
.inv-desc { font-family: 'VT323', monospace; font-size: 13px; color: var(--muted); line-height: 1.4; }
.inv-qty  { font-family: 'VT323', monospace; font-size: 20px; color: var(--green); }

/* ── Shop ── */
.shop-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }
.shop-card {
  background: var(--panel); border: 3px solid var(--border);
  box-shadow: 4px 4px 0 rgba(0,0,0,.6);
  padding: 20px; display: flex; flex-direction: column; gap: 10px;
  transition: border-color 0.1s, transform 0.1s;
}
.shop-card:hover { border-color: var(--sun); transform: translate(-2px,-2px); }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--panel); border: 3px solid var(--sun);
  padding: 14px 20px; font-size: 8px; color: var(--sun);
  box-shadow: 5px 5px 0 rgba(0,0,0,.7);
  z-index: 2000;
  animation: slideInRight 0.2s ease;
}

/* ── Toggle ── */
.tweak-toggle {
  width: 36px; height: 18px; background: var(--border);
  border: 2px solid var(--border); cursor: pointer; position: relative; flex-shrink: 0;
}
.tweak-toggle.on { background: var(--sun3); border-color: var(--sun); }
.tweak-toggle::after {
  content: ''; position: absolute; top: 1px; left: 1px;
  width: 12px; height: 12px; background: var(--muted); transition: left 0.12s;
}
.tweak-toggle.on::after { left: 19px; background: var(--bg); }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.75); z-index: 500;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-box {
  background: var(--panel2); border: 3px solid var(--sun);
  box-shadow: 6px 6px 0 var(--sun3); width: 100%; max-width: 540px;
  max-height: 90vh; overflow: auto;
}
.modal-header {
  background: var(--bg2); border-bottom: 2px solid var(--border);
  padding: 14px 20px; display: flex; align-items: center; justify-content: space-between;
}
.modal-close {
  background: none; border: none; color: var(--muted);
  font-size: 18px; cursor: pointer; font-family: 'Press Start 2P', monospace;
}
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 16px; }

/* Leaderboard player modal */
.lb-player-modal-overlay { background: rgba(0,0,0,0.65); backdrop-filter: blur(4px); }
.lb-player-modal-box {
  width: min(100%, 360px);
  min-width: 300px;
}
.lb-player-modal-enter {
  animation: crtOpen 240ms steps(12, end) forwards;
  transform-origin: center;
}
.lb-player-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.lb-player-metric {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 8px 12px;
  transition: border-color 120ms steps(3, end), opacity 120ms ease, transform 120ms steps(3, end);
}
.lb-player-metric.is-active {
  border-color: var(--sun);
  transform: translateY(-1px);
  animation: metricActivate 350ms ease-out 100ms both;
}
.lb-player-metric.is-muted {
  opacity: 0.5;
}
.lb-player-metric-label {
  font-family: 'VT323', monospace;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 2px;
}
.lb-player-metric-value {
  font-family: 'VT323', monospace;
  font-size: 20px;
  color: var(--sun);
}
.lb-player-metric.is-active .lb-player-metric-value {
  color: var(--text);
  text-shadow: 0 0 10px rgba(255,215,0,.35);
}
.lb-player-metric-secondary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
  font-family: 'VT323', monospace;
  font-size: 13px;
}
.lb-player-metric-secondary-label { color: var(--muted); }
.lb-player-metric-secondary-value { color: var(--cyan); }
.lb-player-metric.is-muted .lb-player-metric-value,
.lb-player-metric.is-muted .lb-player-metric-secondary-value {
  color: var(--muted);
}
.lb-player-metric.is-muted {
  opacity: 0.65;
}

/* Win rate bar */
.lb-winbar { display: flex; align-items: center; gap: 6px; font-family: 'VT323', monospace; font-size: 13px; width: 100%; }
.lb-winbar-label { color: var(--muted); flex-shrink: 0; }
.lb-winbar-track { display: inline-flex; gap: 1px; flex: 1; }
.lb-winbar-cell { width: 8px; height: 10px; background: var(--border); }
.lb-winbar-cell.on { background: var(--sun); }
.lb-winbar-pct { color: var(--cyan); flex-shrink: 0; }
.lb-table-enter {
  animation: tabGlitchIn 100ms steps(5, end) forwards;
}

/* ── Podium ── */
.lb-podium {
  display: grid;
  grid-template-columns: 1fr 1.15fr 1fr;
  gap: 14px;
  align-items: end;
  margin-bottom: 22px;
}
.lb-podium-card {
  background: var(--panel2);
  border: 3px solid var(--border);
  box-shadow: 4px 4px 0 rgba(0,0,0,.6);
  padding: 18px 12px 0;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  cursor: pointer; position: relative; overflow: hidden;
  font-family: 'VT323', monospace;
  animation: podiumRise 380ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
.lb-rank-1 { border-color: var(--sun); box-shadow: 0 0 0 3px var(--bg), 4px 4px 0 var(--sun3), 0 0 32px var(--gold-glow); padding-top: 22px; animation: podiumRise 380ms cubic-bezier(0.22, 1, 0.36, 1) 80ms both, goldPulse 2.4s ease-in-out 400ms infinite; }
.lb-rank-1::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(180deg, transparent 0%, rgba(255,215,0,.08) 50%, transparent 100%); animation: scanBeam 3.2s linear infinite; }
.lb-rank-2 { border-color: var(--silver); animation-delay: 0ms; }
.lb-rank-3 { border-color: var(--bronze); animation-delay: 160ms; }
.lb-podium-name { font-size: 16px; color: var(--text); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-podium-value { font-size: 24px; color: var(--sun); font-weight: bold; }
.lb-podium-bar { width: 100%; margin-top: auto; background: var(--border); }
.lb-rank-1 .lb-podium-bar { height: 28px; background: var(--sun3); }
.lb-rank-2 .lb-podium-bar { height: 18px; background: var(--silver); opacity: .5; }
.lb-rank-3 .lb-podium-bar { height: 12px; background: var(--bronze); opacity: .5; }

/* ── Toolbar & Search ── */
.lb-toolbar {
  display: flex; gap: 10px; margin-bottom: 12px;
}
.lb-search-wrap {
  flex: 1; position: relative;
  display: flex; align-items: center;
}
.lb-search {
  width: 100%; box-sizing: border-box;
  padding: 8px 36px 8px 32px;
  background: var(--panel); border: 2px solid var(--border);
  color: var(--text); font-family: 'Press Start 2P', monospace;
  font-size: 8px; outline: none;
  transition: border-color .1s, box-shadow .1s;
}
.lb-search:focus {
  border-color: var(--sun);
  box-shadow: 0 0 0 2px rgba(255,215,0,.2);
}
.lb-search-icon {
  position: absolute; left: 10px;
  font-size: 14px; color: var(--muted); pointer-events: none;
}
.lb-search-clear {
  position: absolute; right: 6px;
  background: none; border: none; color: var(--muted);
  font-size: 14px; cursor: pointer; padding: 4px 8px;
  transition: color .1s;
}
.lb-search-clear:hover { color: var(--sun); }

.lb-refresh { flex-shrink: 0; }
.lb-refresh.is-loading .lb-refresh-icon { animation: spin .6s linear infinite; }

/* ── Skeleton loader ── */
.lb-skeleton {
  background: linear-gradient(90deg,
    var(--panel) 25%, var(--panel2) 50%, var(--panel) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
  border: 2px solid var(--border);
}
.lb-skel-row { height: 38px; margin-bottom: 6px; }
.lb-skel-podium { margin-bottom: 8px; }

/* ── Separator & Empty ── */
.lb-sep-row td { padding: 10px 0 !important; border: none !important; }
.lb-sep { display: flex; align-items: center; gap: 12px; }
.lb-sep-line { flex: 1; height: 0; border-top: 1px dashed var(--border); }
.lb-sep-label {
  font-family: 'Press Start 2P', monospace; font-size: 7px;
  color: var(--muted); letter-spacing: 3px; white-space: nowrap;
}

.lb-empty { padding: 40px 20px; text-align: center; }
.lb-empty-icon { animation: float 3s ease-in-out infinite; display: inline-block; font-size: 48px; margin-bottom: 14px; }
.lb-empty-title { font-family: 'Press Start 2P', monospace; font-size: 11px; color: var(--sun); margin: 0 0 6px; }
.lb-empty-sub { font-family: 'VT323', monospace; font-size: 16px; color: var(--muted); }

@media (max-width: 640px) {
  .lb-podium { grid-template-columns: 1fr; }
  .lb-rank-1 { order: -1; }
  .lb-toolbar { flex-direction: column; }
  .lb-search-wrap { width: 100%; }
}

/* ── Claim pulse ── */
.claim-pulse { animation: claimPulse 1.6s ease-in-out infinite; }

/* ── Responsive ── */
@media (max-width: 960px) {
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .shop-grid { grid-template-columns: repeat(2,1fr); }
  .achievement-grid { grid-template-columns: repeat(4,1fr); }
  .inv-grid { grid-template-columns: repeat(3,1fr); }
}
@media (max-width: 640px) {
  .sidebar { width: var(--sidebar-col); }
  .sidebar .nav-label { display: none; }
  .sidebar .nav-group-label { opacity: 0; }
  .shop-grid { grid-template-columns: 1fr; }
  .achievement-grid { grid-template-columns: repeat(3,1fr); }
  .inv-grid { grid-template-columns: repeat(2,1fr); }
  .lb-player-modal-box { min-width: 0; width: 100%; }
}
