:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface2: #334155;
  --border: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --dim: #64748b;
  --accent: #f59e0b;
  --accent2: #fbbf24;
  --green: #22c55e;
  --red: #ef4444;
  --blue: #3b82f6;
  --gold: #eab308;
  --radius: 12px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.hidden { display: none !important; }

/* ── Auth ─────────────────────────────────────────────────────────────────── */

.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
}

.auth-card h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
}

.auth-card .subtitle {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 24px;
}

.auth-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border-radius: 8px;
  padding: 4px;
  margin-bottom: 20px;
}

.auth-tabs button {
  flex: 1;
  padding: 8px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
}

.auth-tabs button.active {
  background: var(--surface2);
  color: var(--text);
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-group input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 15px;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #1a1a1a; width: 100%; }
.btn-primary:hover:not(:disabled) { background: var(--accent2); }
.btn-secondary { background: var(--surface2); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-green { background: var(--green); color: #fff; }
.btn-red { background: var(--red); color: #fff; }

.error-msg {
  color: var(--red);
  font-size: 13px;
  margin-top: 12px;
  text-align: center;
}

/* ── App shell ────────────────────────────────────────────────────────────── */

.app { display: flex; flex-direction: column; min-height: 100vh; }

header.app-header {
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

header.app-header h1 {
  font-size: 18px;
  font-weight: 700;
}

header .user-info {
  font-size: 13px;
  color: var(--muted);
}

.progress-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent2);
}

nav.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

nav.tabs button {
  flex: 1;
  min-width: 0;
  padding: 12px 8px;
  border: none;
  background: transparent;
  color: var(--dim);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

nav.tabs button.active {
  color: var(--accent2);
  border-bottom-color: var(--accent);
}

main.content {
  flex: 1;
  padding: 16px;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
  padding-bottom: 80px;
}

/* ── Cards & sets ─────────────────────────────────────────────────────────── */

.set-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
}

.set-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
}

.set-header:hover { background: rgba(255,255,255,0.02); }

.set-header h3 {
  font-size: 14px;
  font-weight: 600;
}

.set-header .set-meta {
  font-size: 12px;
  color: var(--muted);
}

.set-progress {
  font-size: 12px;
  font-weight: 700;
  color: var(--green);
}

.set-progress.incomplete { color: var(--muted); }

.set-body {
  border-top: 1px solid var(--border);
  padding: 8px;
}

.sticker-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 8px;
}

.sticker-row:hover { background: rgba(255,255,255,0.03); }

.sticker-name {
  flex: 1;
  font-size: 14px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sticker-name.missing { color: var(--dim); }

.stars {
  display: flex;
  gap: 1px;
  font-size: 11px;
  color: var(--gold);
  flex-shrink: 0;
}

.stars.gold-card { color: var(--gold); filter: drop-shadow(0 0 2px rgba(234,179,8,0.5)); }

.qty-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.sticker-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.have-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--dim);
  border-radius: 8px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.have-btn.owned {
  border-color: var(--green);
  background: #22c55e22;
  color: var(--green);
}

.dup-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.dup-controls.disabled {
  opacity: 0.35;
  pointer-events: none;
}

.dup-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--dim);
  letter-spacing: 0.04em;
  margin-right: 2px;
}

.qty-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 8px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qty-btn:active { background: var(--surface2); }

.qty-display {
  width: 28px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
}

.qty-display.has { color: var(--green); }
.qty-display.dupe { color: var(--accent2); min-width: 20px; }

/* ── Friends & matches ──────────────────────────────────────────────────────── */

.friend-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  cursor: pointer;
}

.friend-card:hover { border-color: var(--accent); }

.friend-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 8px; }

.friend-stats {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--muted);
}

.friend-stats strong { color: var(--text); }

.match-banner {
  background: linear-gradient(135deg, #1e3a5f, #1e293b);
  border: 1px solid #2563eb44;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}

.match-banner h3 { font-size: 14px; margin-bottom: 6px; }

.match-banner p { font-size: 13px; color: var(--muted); }

.section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--dim);
  margin: 20px 0 10px;
}

.card-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 6px;
  font-size: 14px;
}

.card-list-item .card-info { flex: 1; min-width: 0; }
.card-list-item .card-set { font-size: 11px; color: var(--muted); }

/* ── Trades ───────────────────────────────────────────────────────────────── */

.trade-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.trade-card .trade-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.trade-status {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 4px;
}

.trade-status.pending { background: #f59e0b22; color: var(--accent2); }
.trade-status.accepted { background: #22c55e22; color: var(--green); }
.trade-status.declined, .trade-status.cancelled { background: #ef444422; color: var(--red); }

.trade-side { margin-bottom: 8px; }
.trade-side h4 { font-size: 12px; color: var(--muted); margin-bottom: 4px; }

.trade-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* ── Share panel ──────────────────────────────────────────────────────────── */

.share-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.share-url {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.share-url input {
  flex: 1;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
}

/* ── Filters ──────────────────────────────────────────────────────────────── */

.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-bar input {
  flex: 1;
  min-width: 140px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
}

.filter-bar select {
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}

.empty-state p { font-size: 14px; margin-top: 8px; }

/* ── Modal ────────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

@media (min-width: 520px) {
  .modal-overlay { align-items: center; }
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 20px;
}

.modal h2 { font-size: 18px; margin-bottom: 16px; }

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.modal-actions .btn { flex: 1; }

.invite-code {
  background: var(--bg);
  border: 1px dashed var(--accent);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent2);
  margin: 12px 0;
  word-break: break-all;
}

/* ── Share page ─────────────────────────────────────────────────────────────── */

.share-page {
  max-width: 560px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.share-page h1 { font-size: 22px; margin-bottom: 4px; }
.share-page .album-name { color: var(--muted); font-size: 14px; margin-bottom: 20px; }

.badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--gold);
  color: #1a1a1a;
  margin-left: 6px;
  vertical-align: middle;
}
