:root {
  --bg: #0f1020;
  --bg-soft: #1a1c33;
  --surface: #20223d;
  --surface-2: #2a2d4f;
  --border: #34375e;
  --text: #eef0ff;
  --muted: #9aa0c7;
  --primary: #6c5ce7;
  --primary-2: #8b7bf0;
  --accent: #00d2a8;
  --danger: #ff5d6c;
  --warning: #ffb547;
  --gold: #f1c40f;
  --rare: #3aa0ff;
  --limited: #ff6bd6;
  --radius: 16px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 50% -10%, #23264a 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
}

#root {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent 120px);
}

/* --- Header --- */
header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(15, 16, 32, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.logo { font-weight: 800; font-size: 20px; letter-spacing: 0.3px; display: flex; align-items: center; gap: 8px; }
.logo .mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: grid; place-items: center; font-size: 18px;
}
header .spacer { flex: 1; }
.icon-btn {
  position: relative; border: none; cursor: pointer;
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--surface); color: var(--text); font-size: 18px;
  display: grid; place-items: center;
}
.icon-btn .dot {
  position: absolute; top: 6px; right: 6px; min-width: 16px; height: 16px;
  padding: 0 4px; border-radius: 8px; background: var(--danger);
  font-size: 10px; font-weight: 700; display: grid; place-items: center;
}

/* --- Main --- */
main { flex: 1; padding: 16px 16px 96px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 18px 2px 10px; }

/* --- Bottom nav --- */
nav.bottom {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 520px; z-index: 40;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(20, 22, 42, 0.95); backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
nav.bottom button {
  border: none; background: none; color: var(--muted); cursor: pointer;
  padding: 10px 4px 14px; font-size: 11px; display: flex; flex-direction: column;
  align-items: center; gap: 3px; transition: color 0.15s;
}
nav.bottom button .ico { font-size: 20px; }
nav.bottom button.active { color: var(--primary-2); }

/* --- Cards grid --- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.card {
  position: relative; border-radius: 14px; padding: 10px 8px 9px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); overflow: hidden;
  transition: transform 0.12s, border-color 0.12s; text-align: center;
}
.card:active { transform: scale(0.96); }
.card.owned { border-color: var(--accent); }
.card.missing { opacity: 0.5; filter: grayscale(0.6); }
.card .emoji { font-size: 30px; line-height: 1.1; }
.card .num { position: absolute; top: 6px; left: 8px; font-size: 10px; color: var(--muted); font-weight: 700; }
.card .name { font-size: 11px; font-weight: 600; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .team { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .qty {
  position: absolute; top: 6px; right: 6px; background: var(--accent); color: #042b22;
  font-size: 10px; font-weight: 800; border-radius: 8px; padding: 1px 6px;
}
.card .qty.dupe { background: var(--warning); color: #3a2600; }
.rarity-strip { position: absolute; bottom: 0; left: 0; right: 0; height: 4px; }
.r-common { background: #565a86; }
.r-rare { background: var(--rare); }
.r-gold { background: var(--gold); }
.r-limited { background: linear-gradient(90deg, var(--limited), var(--primary)); }

/* Очертания стикера (Panini-style placeholder) */
.card-art { line-height: 0; }
.card-art .sticker { width: 100%; height: auto; display: block; border-radius: 8px; filter: drop-shadow(0 3px 6px rgba(0,0,0,0.35)); }
.card-sticker { padding: 5px; }
.listing-photo { width: 42px; height: 58px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); flex-shrink: 0; }
.card-art .real-card { width: 100%; height: auto; display: block; border-radius: 9px; filter: drop-shadow(0 3px 6px rgba(0,0,0,0.35)); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge.common { background: #565a8633; color: #b9bce0; }
.badge.rare { background: #3aa0ff22; color: var(--rare); }
.badge.gold { background: #f1c40f22; color: var(--gold); }
.badge.limited { background: #ff6bd622; color: var(--limited); }

/* --- Panels / buttons --- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.btn {
  border: none; cursor: pointer; border-radius: 12px; padding: 12px 16px; font-weight: 700; font-size: 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; transition: opacity .15s, transform .1s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn.accent { background: linear-gradient(135deg, var(--accent), #2bd4ff); color: #042b22; }
.btn.danger { background: var(--danger); }
.btn.sm { padding: 8px 12px; font-size: 13px; border-radius: 10px; }

input, select {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--bg-soft); color: var(--text); font-size: 15px; outline: none;
}
input:focus, select:focus { border-color: var(--primary); }
label.field { display: block; margin-bottom: 12px; }
label.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }

.progress { height: 12px; border-radius: 999px; background: var(--bg-soft); overflow: hidden; border: 1px solid var(--border); }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--primary)); border-radius: 999px; transition: width .4s; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 7px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border);
  color: var(--muted); font-size: 13px; cursor: pointer; white-space: nowrap;
}
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.tabs { display: flex; gap: 6px; background: var(--bg-soft); padding: 4px; border-radius: 12px; margin-bottom: 14px; }
.tabs button { flex: 1; border: none; background: none; color: var(--muted); padding: 9px; border-radius: 9px; font-weight: 600; cursor: pointer; font-size: 13px; }
.tabs button.active { background: var(--primary); color: #fff; }

.muted { color: var(--muted); }
.center { text-align: center; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.empty .big { font-size: 44px; margin-bottom: 8px; }

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--bg-soft); border-radius: 12px; padding: 12px; text-align: center; }
.stat .v { font-size: 22px; font-weight: 800; }
.stat .l { font-size: 11px; color: var(--muted); }

.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: none; }
.avatar { width: 40px; height: 40px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; font-size: 22px; flex-shrink: 0; }
.rank { width: 28px; text-align: center; font-weight: 800; color: var(--muted); }
.rank.top { color: var(--gold); }

/* trade match card */
.match { display: flex; align-items: center; gap: 10px; }
.match .vs { font-size: 12px; color: var(--muted); }
.mini-card { display: flex; flex-direction: column; align-items: center; background: var(--bg-soft); border-radius: 12px; padding: 8px; min-width: 80px; }
.mini-card .emoji { font-size: 26px; }
.mini-card .t { font-size: 10px; margin-top: 2px; text-align: center; }

/* ad banner */
.ad {
  border: 1px dashed var(--border); border-radius: 12px; padding: 10px 14px; text-align: center;
  font-size: 12px; color: var(--muted); background: repeating-linear-gradient(45deg, transparent, transparent 8px, rgba(255,255,255,0.02) 8px, rgba(255,255,255,0.02) 16px);
  margin-bottom: 14px;
}

/* --- Auth screen --- */
.auth-wrap { padding: 32px 22px; display: flex; flex-direction: column; min-height: 100vh; justify-content: center; }
.auth-hero { text-align: center; margin-bottom: 26px; }
.auth-hero .big-mark { width: 84px; height: 84px; margin: 0 auto; filter: drop-shadow(0 8px 20px rgba(108,92,231,0.45)); }
.auth-hero .big-mark svg { display: block; }
.auth-hero h1 { margin: 8px 0 4px; font-size: 28px; }
.auth-hero p { color: var(--muted); margin: 0; }

/* --- Public collection (share link) --- */
.public-hero { display: flex; align-items: center; gap: 14px; }
.pub-h { margin: 20px 0 10px; font-size: 16px; }

/* --- Modal --- */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 60; display: grid; place-items: end center; }
.modal {
  width: 100%; max-width: 520px; background: var(--surface); border-radius: 20px 20px 0 0;
  border: 1px solid var(--border); padding: 20px 18px 28px; max-height: 88vh; overflow-y: auto;
  animation: slideup .22s ease;
}
@keyframes slideup { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal h3 { margin: 0 0 14px; }
.modal .close { position: absolute; }

/* --- Toast --- */
#toasts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; width: 92%; max-width: 460px; }
.toast { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow); font-size: 14px; animation: pop .2s; }
.toast.ok { border-left: 4px solid var(--accent); }
.toast.err { border-left: 4px solid var(--danger); }
@keyframes pop { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* --- Chat --- */
.chat-box { max-height: 52vh; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 6px 2px; }
.bubble { max-width: 80%; padding: 8px 12px; border-radius: 14px; font-size: 14px; line-height: 1.35; word-break: break-word; }
.bubble.mine { align-self: flex-end; background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; border-bottom-right-radius: 4px; }
.bubble.theirs { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 4px; }
.bubble .who { font-size: 10px; color: var(--muted); margin-bottom: 2px; }
.bubble .flag { font-size: 10px; opacity: 0.8; margin-top: 3px; }
.chat-input-row { display: flex; gap: 8px; margin-top: 12px; }
.chat-input-row input { flex: 1; }
.chat-note { font-size: 11px; color: var(--muted); text-align: center; margin: 6px 0 2px; }

/* --- Stars / reputation --- */
.stars { color: var(--gold); font-size: 13px; white-space: nowrap; }
.stars .muted { color: var(--muted); }
.star-pick { font-size: 30px; cursor: pointer; color: var(--border); transition: color .1s; }
.star-pick.on { color: var(--gold); }

.hidden { display: none !important; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
