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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #23263a;
  --border: #2e3250;
  --accent: #6366f1;
  --accent-hover: #4f52cc;
  --accent-light: #e0e1ff;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --text: #e8eaf6;
  --muted: #8b92b8;
  --radius: 10px;
  --font: 'Inter', system-ui, sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ── Login screen ─────────────────────────── */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.hero {
  text-align: center;
  padding: 2rem;
}
.hero h1 {
  font-size: 3.5rem;
  font-weight: 800;
  letter-spacing: -1px;
  background: linear-gradient(135deg, #6366f1, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.tagline {
  color: var(--muted);
  margin: 1rem 0 2.5rem;
  line-height: 1.6;
  font-size: 1.1rem;
}

/* ── Buttons ──────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: .875rem;
  font-weight: 600;
  padding: .5rem 1rem;
  transition: background .15s, opacity .15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { opacity: .85; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }
.btn-sm { font-size: .8rem; padding: .35rem .75rem; }
.btn-lg { font-size: 1rem; padding: .8rem 2rem; border-radius: 12px; }

/* ── Header ───────────────────────────────── */
header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .85rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-brand {
  font-size: 1.1rem;
  font-weight: 800;
  background: linear-gradient(135deg, #6366f1, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  min-width: 100px;
}
nav {
  display: flex;
  gap: .25rem;
  flex: 1;
}
.nav-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: .875rem;
  font-weight: 500;
  padding: .4rem .85rem;
  border-radius: 7px;
  transition: all .15s;
}
.nav-btn:hover { color: var(--text); background: var(--surface2); }
.nav-btn.active { color: var(--accent-light); background: var(--surface2); }
.header-user {
  display: flex;
  align-items: center;
  gap: .75rem;
  font-size: .85rem;
  color: var(--muted);
}
.credits-badge {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: .2rem .65rem;
  font-size: .8rem;
  font-weight: 700;
  color: var(--yellow);
}

/* ── Tabs ─────────────────────────────────── */
.tab { padding: 2rem 1.5rem; max-width: 900px; margin: 0 auto; }
.tab h2 { font-size: 1.5rem; font-weight: 700; margin-bottom: .35rem; }
.tab h3 { font-size: 1rem; font-weight: 600; margin: 1.5rem 0 .75rem; color: var(--muted); }
.subtitle { color: var(--muted); margin-bottom: 1.5rem; }

/* ── Cards ────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: .75rem;
}
.listing-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  transition: border-color .15s;
}
.listing-card:hover { border-color: var(--accent); }
.listing-letter {
  font-size: 2.5rem;
  font-weight: 800;
  text-align: center;
  color: var(--accent-light);
  line-height: 1;
  padding: .5rem 0;
}
.listing-meta {
  font-size: .78rem;
  color: var(--muted);
  text-align: center;
}
.listing-price {
  text-align: center;
  font-size: .95rem;
  font-weight: 700;
  color: var(--yellow);
}

/* ── Sell form ────────────────────────────── */
.sell-form { display: flex; flex-direction: column; gap: .85rem; margin-bottom: 2rem; }
.sell-form label { font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: .95rem;
  padding: .55rem .85rem;
  width: 100%;
  max-width: 180px;
  outline: none;
  transition: border-color .15s;
}
.input:focus { border-color: var(--accent); }

.letter-picker { display: flex; flex-wrap: wrap; gap: .5rem; }
.letter-chip {
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 700;
  padding: .4rem .75rem;
  transition: all .15s;
  color: var(--text);
  position: relative;
}
.letter-chip:hover { border-color: var(--accent); color: var(--accent-light); }
.letter-chip.selected { border-color: var(--accent); background: var(--accent); color: #fff; }
.letter-chip .count {
  font-size: .65rem;
  font-weight: 600;
  color: var(--muted);
  position: absolute;
  top: 2px;
  right: 4px;
}
.letter-chip.selected .count { color: rgba(255,255,255,.7); }

.msg { font-size: .875rem; border-radius: 7px; padding: .5rem .85rem; }
.msg.success { background: rgba(34,197,94,.12); color: var(--green); border: 1px solid rgba(34,197,94,.3); }
.msg.error   { background: rgba(239,68,68,.12);  color: var(--red);   border: 1px solid rgba(239,68,68,.3); }

/* ── Leaderboard ──────────────────────────── */
.lb-table { width: 100%; border-collapse: collapse; }
.lb-table th, .lb-table td {
  padding: .75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.lb-table th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
.lb-table tr:hover td { background: var(--surface); }
.lb-table tr.me td { color: var(--accent-light); font-weight: 600; }
.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 50%;
  font-size: .8rem;
  font-weight: 700;
  background: var(--surface2);
  color: var(--muted);
}
.rank-1 { background: #ffd700; color: #000; }
.rank-2 { background: #c0c0c0; color: #000; }
.rank-3 { background: #cd7f32; color: #000; }

/* ── Toast ────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1.25rem;
  font-size: .875rem;
  z-index: 100;
  animation: slidein .2s ease;
}
@keyframes slidein {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.empty-state { color: var(--muted); font-style: italic; padding: 1rem 0; }

/* My Name tab */
.name-current { margin: 0 0 1rem; color: var(--muted); }
.name-actions { display: flex; gap: .5rem; align-items: center; margin-top: .5rem; }
#name-input { letter-spacing: .04em; }
