/* ── Tokens ───────────────────────────────────────────── */
:root {
  --bg:        #0d0f1a;
  --surface:   #151828;
  --border:    #252a42;
  --accent:    #f5c518;
  --accent2:   #e84040;
  --text:      #e8eaf6;
  --muted:     #7b82a8;
  --radius:    14px;
  --card-w:    180px;
  --theme-transition: background 0.25s, color 0.25s, border-color 0.25s;
}
html.light {
  --bg:      #f0f2f8;
  --surface: #ffffff;
  --border:  #d4d8ec;
  --text:    #1a1d2e;
  --muted:   #6b7094;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
* { -webkit-tap-highlight-color: transparent; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  min-height: 100dvh;
  transition: var(--theme-transition);
  padding-bottom: env(safe-area-inset-bottom);
}

/* ── Header ───────────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  padding-left: max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 58px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-family: 'Exo 2', sans-serif;
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.5px;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo span { color: var(--accent2); }
.logo img {
  width: 36px; height: 36px;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.35));
}

.tab-bar {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border-radius: 8px;
  padding: 3px;
}
.tab-bar button {
  background: none; border: none;
  color: var(--muted);
  font-family: 'Exo 2', sans-serif;
  font-weight: 600; font-size: 0.8rem;
  padding: 5px 12px; border-radius: 6px;
  cursor: pointer; transition: all 0.15s;
  white-space: nowrap;
}
.tab-bar button.active { background: var(--surface); color: var(--text); }

.collection-count {
  font-family: 'Exo 2', sans-serif;
  font-weight: 600; font-size: 0.8rem;
  color: var(--muted);
}
.collection-count strong { color: var(--accent); }

.theme-toggle {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px; cursor: pointer;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  transition: border-color 0.15s, background 0.25s;
  flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--accent); }

/* ── Main Layout ──────────────────────────────────────── */
main { max-width: 960px; margin: 0 auto; padding: 24px 16px; }

/* ── Search Mode Toggle ───────────────────────────────── */
.search-mode-row { display: flex; gap: 6px; margin-bottom: 10px; }
.mode-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px; color: var(--muted);
  font-family: 'Exo 2', sans-serif;
  font-weight: 600; font-size: 0.78rem;
  padding: 5px 14px; cursor: pointer; transition: all 0.15s;
}
.mode-btn.active {
  border-color: var(--accent); color: var(--accent);
  background: rgba(245,197,24,0.08);
}

/* ── Search Bar ───────────────────────────────────────── */
.search-row { display: flex; gap: 10px; margin-bottom: 24px; }
.search-wrap { position: relative; flex: 1; }
.search-wrap svg {
  position: absolute; left: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--muted); pointer-events: none;
}
input[type="search"] {
  width: 100%; background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  font-size: 16px;
  padding: 12px 14px 12px 44px;
  outline: none; transition: border-color 0.15s;
  -webkit-appearance: none;
}
input[type="search"]:focus { border-color: var(--accent); }
input[type="search"]::placeholder { color: var(--muted); }

button.search-btn {
  background: var(--accent); border: none;
  border-radius: var(--radius); color: #000;
  font-family: 'Exo 2', sans-serif;
  font-weight: 700; font-size: 0.9rem;
  padding: 0 20px; cursor: pointer;
  transition: opacity 0.15s; white-space: nowrap;
}
button.search-btn:hover { opacity: 0.88; }
button.search-btn:disabled { opacity: 0.45; cursor: not-allowed; }

button.random-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1.2rem;
  width: 46px; height: 46px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: border-color 0.15s, transform 0.15s;
}
button.random-btn:hover { border-color: var(--accent); transform: rotate(20deg); }
button.random-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
@keyframes dice-spin {
  0%   { transform: rotate(0deg) scale(1); }
  50%  { transform: rotate(180deg) scale(1.2); }
  100% { transform: rotate(360deg) scale(1); }
}
button.random-btn.spinning { animation: dice-spin 0.5s ease-in-out; }

/* ── Filter chips ─────────────────────────────────────── */
.filter-row {
  display: flex; gap: 8px;
  flex-wrap: nowrap; overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none; margin-bottom: 20px;
}
.filter-row::-webkit-scrollbar { display: none; }
.filter-row > span { flex-shrink: 0; font-size: 0.78rem; color: var(--muted); align-self: center; }
.chip {
  flex-shrink: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; color: var(--muted);
  font-size: 0.78rem; font-weight: 500;
  padding: 5px 14px; cursor: pointer; transition: all 0.15s;
}
.chip.active { border-color: var(--accent); color: var(--accent); }
.chip:hover:not(.active) { border-color: var(--muted); color: var(--text); }

/* ── Set picker ───────────────────────────────────────── */
.set-list {
  margin-top: 8px;
  max-height: 260px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.set-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.set-item:hover { border-color: var(--accent); }
.set-item.active { border-color: var(--accent); background: rgba(245,197,24,0.07); }
.set-item img {
  width: 32px; height: 32px;
  object-fit: contain; flex-shrink: 0;
}
.set-item-info { flex: 1; min-width: 0; }
.set-item-name {
  font-family: 'Exo 2', sans-serif; font-weight: 600; font-size: 0.88rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.set-item-meta { font-size: 0.72rem; color: var(--muted); margin-top: 1px; }
.set-item-count {
  font-family: 'Exo 2', sans-serif; font-weight: 600;
  font-size: 0.75rem; color: var(--muted); flex-shrink: 0;
}
.set-series-label {
  font-size: 0.7rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.07em;
  padding: 6px 4px 2px;
  font-family: 'Exo 2', sans-serif;
}

/* ── Results toolbar ──────────────────────────────────── */
.results-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 10px;
}
.results-count {
  font-size: 0.82rem;
  color: var(--muted);
  font-family: 'Exo 2', sans-serif;
  font-weight: 600;
  white-space: nowrap;
}
.results-count strong { color: var(--text); }
.add-all-btn {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-family: 'Exo 2', sans-serif;
  font-weight: 600; font-size: 0.78rem;
  padding: 6px 14px;
  cursor: pointer; white-space: nowrap;
  transition: all 0.15s;
  flex-shrink: 0;
}
.add-all-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.add-all-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.add-all-btn.done { border-color: #3ddc84; color: #3ddc84; }

/* ── Collections bar ──────────────────────────────────── */
.collections-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.collections-bar::-webkit-scrollbar { display: none; }

.col-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  flex-shrink: 0;
}
.col-tab:hover { border-color: var(--muted); }
.col-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
}
.col-tab-name {
  font-family: 'Exo 2', sans-serif;
  font-weight: 600; font-size: 0.82rem;
}
.col-tab-count {
  font-size: 0.7rem;
  background: rgba(0,0,0,0.15);
  border-radius: 999px;
  padding: 1px 7px;
  font-weight: 600;
}
.col-tab.active .col-tab-count { background: rgba(0,0,0,0.2); }

.col-menu-btn {
  background: none; border: none;
  color: var(--muted); font-size: 1.1rem;
  cursor: pointer; padding: 4px 6px;
  border-radius: 6px; line-height: 1;
  transition: color 0.15s;
  flex-shrink: 0;
}
.col-menu-btn:hover { color: var(--text); }

.new-col-btn {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-family: 'Exo 2', sans-serif;
  font-weight: 600; font-size: 0.82rem;
  padding: 6px 14px;
  cursor: pointer; white-space: nowrap;
  transition: all 0.15s; flex-shrink: 0;
}
.new-col-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Collection drag-to-reorder ───────────────────────── */
.col-tab[draggable="true"] { cursor: grab; }
.col-tab[draggable="true"]:active { cursor: grabbing; }
.col-tab.dragging {
  opacity: 0.35;
  pointer-events: none;
}
.col-tab.long-press-ready {
  transform: scale(1.05);
  border-color: var(--accent);
  transition: transform 0.15s, border-color 0.15s;
}
.col-tab.drop-before {
  box-shadow: -3px 0 0 0 var(--accent);
}
.col-tab.drop-after {
  box-shadow: 3px 0 0 0 var(--accent);
}
.touch-drag-clone {
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  border-color: var(--accent) !important;
}

/* ── Collection completion bar ────────────────────────── */
.col-completion {
  margin-bottom: 14px;
}
.col-completion-text {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
  font-family: 'Exo 2', sans-serif;
  font-size: 0.8rem;
  color: var(--muted);
}
.col-completion-pct {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
}
.col-completion-bar {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.col-completion-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #3ddc84, #27ae60);
  transition: width 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.col-completion-fill.complete {
  background: linear-gradient(90deg, var(--accent), #e6a817);
}

/* ── Collection toolbar (hide owned toggle) ───────────── */
.col-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 8px;
}
.col-tool-btn {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-family: 'Exo 2', sans-serif;
  font-weight: 600; font-size: 0.78rem;
  padding: 6px 12px; cursor: pointer;
  transition: all 0.15s; white-space: nowrap;
}
.col-tool-btn:hover { border-color: var(--accent); color: var(--accent); }
.hide-owned-btn {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-family: 'Exo 2', sans-serif;
  font-weight: 600; font-size: 0.78rem;
  padding: 6px 14px; cursor: pointer;
  transition: all 0.15s; white-space: nowrap;
}
.hide-owned-btn:hover { border-color: var(--muted); color: var(--text); }
.hide-owned-btn.active {
  background: rgba(245,197,24,0.1);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Section heading ──────────────────────────────────── */
.section-head {
  display: flex; align-items: center;
  justify-content: space-between; margin-bottom: 14px;
}
.section-head h2 {
  font-family: 'Exo 2', sans-serif;
  font-weight: 700; font-size: 1rem;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em;
}

/* ── Card Grid ────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--card-w), 1fr));
  gap: 16px;
}

/* ── Pokemon Card ─────────────────────────────────────── */
.pcard {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  cursor: pointer;
  transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s;
  position: relative;
}
@media (hover: hover) {
  .pcard:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
    box-shadow: 0 8px 32px rgba(245,197,24,0.15);
  }
  .pcard.in-collection:hover {
    border-color: #3ddc84;
    box-shadow: 0 8px 32px rgba(61,220,132,0.15);
  }
}
.pcard.in-collection { border-color: #3ddc84; }

.pcard-img {
  width: 100%; aspect-ratio: 63/88;
  object-fit: cover; display: block; background: var(--bg);
}
.pcard-img.loading {
  background: linear-gradient(120deg, var(--bg) 30%, var(--border) 50%, var(--bg) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.pcard-body { padding: 10px 12px; }
.pcard-name {
  font-family: 'Exo 2', sans-serif;
  font-weight: 700; font-size: 0.88rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 3px;
}
.pcard-set {
  font-size: 0.72rem; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pcard-number {
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

.pcard-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-top: 1px solid var(--border);
}
.rarity-badge {
  font-size: 0.8rem; font-weight: 600; color: var(--muted);
  letter-spacing: 0.02em; cursor: default;
  position: relative;
}
.rarity-badge[data-tooltip] { cursor: default; }

/* Shared tooltip element — positioned via JS to escape overflow:hidden */
.rarity-tooltip {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.7rem; font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  pointer-events: none;
  z-index: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  opacity: 0;
  transition: opacity 0.1s;
}
.price-badge {
  font-family: 'Exo 2', sans-serif;
  font-size: 0.75rem; font-weight: 700;
  color: var(--accent);
}
.collect-btn {
  background: none; border: 1px solid var(--border);
  border-radius: 6px; color: var(--muted);
  font-size: 0.72rem; font-weight: 600;
  padding: 6px 10px; min-height: 32px;
  cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.collect-btn:hover { border-color: var(--accent); color: var(--accent); }
.collect-btn.collected {
  background: rgba(61,220,132,0.12);
  border-color: #3ddc84; color: #3ddc84;
}

.in-collection-badge {
  position: absolute; top: 8px; right: 8px;
  width: 22px; height: 22px; background: #3ddc84;
  border-radius: 50%; display: flex;
  align-items: center; justify-content: center; font-size: 11px;
}

/* ── Empty / loading states ───────────────────────────── */
.state-msg { text-align: center; padding: 60px 20px; color: var(--muted); }
.state-msg .big { font-size: 3rem; margin-bottom: 12px; }
.state-msg h3 {
  font-family: 'Exo 2', sans-serif;
  font-weight: 700; font-size: 1.1rem;
  color: var(--text); margin-bottom: 6px;
}

.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 60px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Pagination ───────────────────────────────────────── */
.pagination {
  display: flex; gap: 8px;
  justify-content: center; align-items: center; margin-top: 32px;
}
.pagination.hidden { display: none; }
.pagination button {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text);
  font-family: 'Exo 2', sans-serif;
  font-weight: 600; font-size: 0.85rem;
  padding: 10px 18px; cursor: pointer; transition: all 0.15s;
}
.pagination button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.pagination button:disabled { opacity: 0.35; cursor: not-allowed; }
.pagination .page-info { color: var(--muted); font-size: 0.85rem; }

/* ── Modal ────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-overlay.hidden { display: none; }

.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; width: 100%; max-width: 560px;
  max-height: 90dvh; overflow-y: auto;
  display: flex; flex-direction: column;
}
.modal-close {
  position: sticky; top: 0;
  display: flex; justify-content: flex-end;
  padding: 14px 16px 0;
  background: var(--surface); z-index: 1;
}
.modal-close button {
  background: var(--border); border: none; color: var(--text);
  width: 40px; height: 40px; border-radius: 50%;
  cursor: pointer; font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
}
.modal-inner {
  padding: 16px 20px 24px;
  display: flex; flex-direction: column;
  align-items: center; gap: 16px;
}
.modal-img {
  width: 220px; border-radius: 10px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}
.modal-title {
  font-family: 'Exo 2', sans-serif;
  font-weight: 800; font-size: 1.5rem; text-align: center;
}
.modal-meta {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px; width: 100%;
}
.meta-item { background: var(--bg); border-radius: 10px; padding: 10px 14px; }
.meta-label {
  font-size: 0.7rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 3px;
}
.meta-value { font-family: 'Exo 2', sans-serif; font-weight: 600; font-size: 0.9rem; }

/* ── Owned shimmer effect ─────────────────────────────── */
.pcard-img-wrap {
  position: relative;
  overflow: hidden;
  display: block;
}
/* The holographic sweep overlay */
.pcard-img-wrap::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(
    115deg,
    transparent 0%,
    transparent 15%,
    rgba(255,255,255,0.15) 28%,
    rgba(180,80,255,0.55) 36%,
    rgba(60,160,255,0.60) 44%,
    rgba(80,255,200,0.55) 52%,
    rgba(255,230,60,0.55) 60%,
    rgba(255,80,120,0.50) 68%,
    rgba(255,255,255,0.15) 78%,
    transparent 88%,
    transparent 100%
  );
  background-size: 250% 100%;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  mix-blend-mode: screen;
}
.pcard.owned .pcard-img-wrap::after {
  animation: holo-periodic 22s ease-in-out infinite;
}
/* Total cycle: 22s
   0–18%  (~4s): first sweep across, visible
   18–22% (~1s): fade out
   22–27% (~1s): fade back in, reset position
   27–45% (~4s): second sweep across, visible
   45–50% (~1s): fade out
   50–100% (~11s): invisible rest */
@keyframes holo-periodic {
  0%   { opacity: 0; background-position: 250% 0; }
  3%   { opacity: 1; }
  18%  { opacity: 1; background-position: -250% 0; }
  22%  { opacity: 0; background-position: -250% 0; }
  23%  { opacity: 0; background-position: 250% 0; }
  27%  { opacity: 1; }
  45%  { opacity: 1; background-position: -250% 0; }
  50%  { opacity: 0; background-position: -250% 0; }
  100% { opacity: 0; background-position: 250% 0; }
}
/* Gold border glow on owned cards */
.pcard.owned {
  box-shadow: 0 0 0 2px rgba(245,197,24,0.7), 0 4px 24px rgba(245,197,24,0.25);
}
@media (hover: hover) {
  .pcard.owned:hover {
    box-shadow: 0 0 0 2px rgba(245,197,24,0.9), 0 6px 32px rgba(245,197,24,0.4);
  }
}

/* Owned star badge */
.owned-badge {
  position: absolute; top: 8px; left: 8px;
  width: 22px; height: 22px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: #000;
  z-index: 2;
}

/* Owned toggle button (in footer) */
.owned-btn {
  background: none; border: 1px solid var(--border);
  border-radius: 6px; color: var(--muted);
  font-size: 0.72rem; font-weight: 600;
  padding: 6px 10px; min-height: 32px;
  cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.owned-btn:hover { border-color: var(--accent); color: var(--accent); }
.owned-btn.is-owned {
  background: rgba(245,197,24,0.12);
  border-color: var(--accent); color: var(--accent);
}

/* Owned toggle button in modal */
.modal-owned-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'Exo 2', sans-serif;
  font-weight: 600; font-size: 0.9rem;
  padding: 12px; cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.modal-owned-btn:hover { border-color: var(--accent); color: var(--accent); }
.modal-owned-btn.is-owned {
  background: rgba(245,197,24,0.1);
  border-color: var(--accent); color: var(--accent);
}

/* ── Share button ─────────────────────────────────────── */
.modal-share-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'Exo 2', sans-serif;
  font-weight: 600; font-size: 0.9rem;
  padding: 12px; cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  text-decoration: none;
}
.modal-share-btn:hover { border-color: var(--accent); color: var(--accent); }
.modal-share-btn.copied { border-color: #3ddc84; color: #3ddc84; }

/* ── Add-to-collection section in modal ───────────────── */
.modal-add-section { width: 100%; }
.modal-add-label {
  font-size: 0.72rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.07em;
  margin-bottom: 10px;
  font-family: 'Exo 2', sans-serif; font-weight: 700;
}
.modal-col-list {
  display: flex; flex-direction: column; gap: 8px;
}
.modal-col-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg); border-radius: 10px;
  padding: 10px 14px;
}
.modal-col-row-name {
  font-family: 'Exo 2', sans-serif;
  font-weight: 600; font-size: 0.9rem;
}
.modal-col-row-count {
  font-size: 0.75rem; color: var(--muted); margin-top: 2px;
}
.modal-add-btn {
  background: var(--accent); border: none;
  border-radius: 8px; color: #000;
  font-family: 'Exo 2', sans-serif;
  font-weight: 700; font-size: 0.82rem;
  padding: 7px 14px; cursor: pointer;
  transition: opacity 0.15s; white-space: nowrap;
}
.modal-add-btn:hover { opacity: 0.85; }
.modal-add-btn.in-col {
  background: rgba(61,220,132,0.15);
  color: #3ddc84;
}

.attacks-list { width: 100%; }
.attacks-list h4 {
  font-family: 'Exo 2', sans-serif;
  font-size: 0.75rem; font-weight: 700;
  color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.07em; margin-bottom: 8px;
}
.attack-item {
  background: var(--bg); border-radius: 8px;
  padding: 10px 14px; margin-bottom: 8px;
}
.attack-name {
  font-family: 'Exo 2', sans-serif;
  font-weight: 700; font-size: 0.88rem;
  display: flex; justify-content: space-between;
}
.attack-damage { color: var(--accent2); }
.attack-text { font-size: 0.78rem; color: var(--muted); margin-top: 3px; }

/* ── Inline name/rename input ─────────────────────────── */
.inline-input {
  background: var(--bg); border: 1px solid var(--accent);
  border-radius: 8px; color: var(--text);
  font-family: 'Exo 2', sans-serif;
  font-weight: 600; font-size: 0.82rem;
  padding: 5px 10px; outline: none;
  width: 130px;
}

/* ── Collection picker (Add all modal) ───────────────── */
.col-picker-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg); border-radius: 10px;
  padding: 10px 14px; gap: 10px;
  cursor: pointer; transition: border-color 0.12s;
  border: 1px solid transparent;
}
.col-picker-row:hover { border-color: var(--accent); }
.col-picker-row-name {
  font-family: 'Exo 2', sans-serif; font-weight: 600; font-size: 0.9rem;
}
.col-picker-row-count { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
.col-picker-row-arrow { color: var(--muted); font-size: 1rem; flex-shrink: 0; }
.col-picker-new {
  display: flex; align-items: center; gap: 10px;
  background: none; border: 1px dashed var(--border);
  border-radius: 10px; padding: 10px 14px;
  color: var(--muted);
  font-family: 'Exo 2', sans-serif; font-weight: 600; font-size: 0.9rem;
  cursor: pointer; transition: all 0.15s; width: 100%; text-align: left;
}
.col-picker-new:hover { border-color: var(--accent); color: var(--accent); }

/* ── Context menu (rename/delete) ─────────────────────── */
.ctx-menu {
  position: fixed;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 6px;
  z-index: 300; min-width: 140px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
.ctx-menu button {
  display: flex; align-items: center; gap: 8px;
  background: none; border: none;
  color: var(--text); font-size: 0.85rem;
  padding: 8px 12px; width: 100%;
  text-align: left; border-radius: 6px;
  cursor: pointer; transition: background 0.1s;
}
.ctx-menu button:hover { background: var(--border); }
.ctx-menu button.danger { color: var(--accent2); }

/* ── Mobile ───────────────────────────────────────────── */
@media (max-width: 480px) {
  :root { --card-w: 148px; }
  .collection-count { display: none; }
  .logo { font-size: 1rem; }
  .logo img { width: 30px; height: 30px; }
  .search-row { flex-wrap: wrap; }
  .search-wrap { flex: 1 1 100%; }
  button.search-btn { flex: 1 1 100%; padding: 12px; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal {
    border-radius: 20px 20px 0 0;
    max-height: 92dvh; width: 100%;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .modal-img { width: 180px; }
}

/* ── Share code display ───────────────────────────────── */
.share-code-display {
  font-family: 'Exo 2', sans-serif;
  font-weight: 800;
  font-size: 2.4rem;
  letter-spacing: 0.25em;
  text-align: center;
  color: var(--accent);
  background: var(--bg);
  border: 2px solid var(--accent);
  border-radius: 14px;
  padding: 18px 24px;
  width: 100%;
  margin: 8px 0;
  cursor: pointer;
  transition: background 0.15s;
}
.share-code-display:hover { background: rgba(245,197,24,0.08); }
.share-code-hint {
  font-size: 0.78rem; color: var(--muted);
  text-align: center; margin-top: 4px;
}
.share-code-input {
  width: 100%;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: 'Exo 2', sans-serif;
  font-weight: 700; font-size: 1.6rem;
  letter-spacing: 0.2em;
  text-align: center;
  padding: 14px;
  outline: none;
  text-transform: uppercase;
  transition: border-color 0.15s;
}
.share-code-input:focus { border-color: var(--accent); }
.share-code-submit {
  width: 100%;
  background: var(--accent); border: none;
  border-radius: var(--radius); color: #000;
  font-family: 'Exo 2', sans-serif;
  font-weight: 700; font-size: 1rem;
  padding: 13px; cursor: pointer;
  transition: opacity 0.15s; margin-top: 8px;
}
.share-code-submit:hover:not(:disabled) { opacity: 0.88; }
.share-code-submit:disabled { opacity: 0.45; cursor: not-allowed; }


/* ── Favourite card showcase ──────────────────────────── */
.fav-showcase {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 28px;
  box-shadow: 0 0 0 1px rgba(245,197,24,0.15), 0 4px 24px rgba(245,197,24,0.1);
}
.fav-showcase-img {
  width: 120px;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  flex-shrink: 0;
  transition: transform 0.2s;
  cursor: zoom-in;
}
.fav-showcase-img:hover { transform: scale(1.03); }
.fav-showcase-info { flex: 1; min-width: 0; }
.fav-showcase-name {
  font-family: 'Exo 2', sans-serif;
  font-weight: 800; font-size: 1.2rem; margin-bottom: 4px;
}
.fav-showcase-set { font-size: 0.78rem; color: var(--muted); margin-bottom: 4px; }
.fav-showcase-rarity { font-size: 0.8rem; color: var(--muted); margin-bottom: 4px; }
.fav-showcase-price {
  font-family: 'Exo 2', sans-serif;
  font-weight: 700; font-size: 1rem; color: var(--accent); margin-bottom: 4px;
}
.fav-empty {
  display: flex; flex-direction: column; align-items: center;
  gap: 12px; padding: 32px 20px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius); margin-bottom: 28px;
}
.fav-empty-icon { font-size: 2.5rem; }
.fav-empty-text { font-size: 0.9rem; color: var(--muted); }
@media (max-width: 480px) {
  .fav-showcase { flex-direction: column; align-items: center; text-align: center; }
  .fav-showcase-info { display: flex; flex-direction: column; align-items: center; }
}

/* ── Stats page ───────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex; flex-direction: column; gap: 4px;
}
.stat-label {
  font-size: 0.7rem; font-weight: 700;
  color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.07em; font-family: 'Exo 2', sans-serif;
}
.stat-value {
  font-family: 'Exo 2', sans-serif;
  font-weight: 800; font-size: 1.6rem;
  color: var(--text); line-height: 1;
}
.stat-value.accent { color: var(--accent); }
.stat-sub {
  font-size: 0.75rem; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.stats-section-title {
  font-family: 'Exo 2', sans-serif;
  font-weight: 700; font-size: 1rem;
  color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.08em; margin-bottom: 12px;
}

.stats-bar-list {
  display: flex; flex-direction: column; gap: 10px;
  margin-bottom: 28px;
}
.stats-bar-row {
  display: flex; flex-direction: column; gap: 4px;
}
.stats-bar-label {
  display: flex; justify-content: space-between;
  font-size: 0.8rem; font-family: 'Exo 2', sans-serif; font-weight: 600;
}
.stats-bar-track {
  height: 8px; background: var(--border); border-radius: 999px; overflow: hidden;
}
.stats-bar-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #e6a817);
  transition: width 0.6s cubic-bezier(0.34,1.56,0.64,1);
}
.stats-bar-fill.green {
  background: linear-gradient(90deg, #3ddc84, #27ae60);
}

.stats-top-list {
  display: flex; flex-direction: column; gap: 8px;
  margin-bottom: 28px;
}
.stats-top-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 14px;
}
.stats-top-rank {
  font-family: 'Exo 2', sans-serif;
  font-weight: 800; font-size: 1rem;
  color: var(--muted); width: 24px; flex-shrink: 0;
}
.stats-top-img {
  width: 40px; border-radius: 4px; flex-shrink: 0;
}
.stats-top-info { flex: 1; min-width: 0; }
.stats-top-name {
  font-family: 'Exo 2', sans-serif;
  font-weight: 600; font-size: 0.88rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stats-top-meta { font-size: 0.75rem; color: var(--muted); }
.stats-top-value {
  font-family: 'Exo 2', sans-serif;
  font-weight: 700; font-size: 0.9rem;
  color: var(--accent); flex-shrink: 0;
}

/* ── Card zoom overlay ────────────────────────────────── */
.zoom-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 500;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(8px);
  touch-action: none;
}
.zoom-overlay.hidden { display: none; }

.zoom-close {
  position: absolute; top: 16px; right: 16px;
  background: rgba(255,255,255,0.12);
  border: none; border-radius: 50%;
  color: #fff; font-size: 1rem;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; z-index: 1;
  transition: background 0.15s;
}
.zoom-close:hover { background: rgba(255,255,255,0.22); }

.zoom-container {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  cursor: zoom-in;
}
.zoom-container.panned { cursor: grab; }
.zoom-container.panned:active { cursor: grabbing; }

.zoom-img {
  max-width: 90vw; max-height: 90dvh;
  border-radius: 12px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
  transform-origin: center center;
  transition: transform 0.2s ease;
  user-select: none; -webkit-user-drag: none;
  will-change: transform;
}

/* ── Collection complete celebration ──────────────────── */
.celebrate-overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 400;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  cursor: pointer;
}
.celebrate-overlay.hidden { display: none; }

#confetti-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}

.celebrate-modal {
  position: relative; z-index: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 40px 32px;
  text-align: center;
  max-width: 340px; width: 90%;
  box-shadow: 0 24px 64px rgba(0,0,0,0.4);
  animation: celebrate-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes celebrate-pop {
  from { transform: scale(0.6); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.celebrate-emoji {
  font-size: 4rem;
  line-height: 1;
  margin-bottom: 16px;
  animation: celebrate-bounce 0.6s 0.3s cubic-bezier(0.34,1.56,0.64,1) both;
}
@keyframes celebrate-bounce {
  from { transform: scale(0.5) rotate(-15deg); }
  to   { transform: scale(1)   rotate(0deg);   }
}

.celebrate-title {
  font-family: 'Exo 2', sans-serif;
  font-weight: 800; font-size: 1.6rem;
  color: var(--accent);
  margin-bottom: 8px;
}

.celebrate-sub {
  font-size: 0.9rem; color: var(--muted);
  margin-bottom: 24px; line-height: 1.5;
}

.celebrate-btn {
  background: var(--accent); border: none;
  border-radius: var(--radius); color: #000;
  font-family: 'Exo 2', sans-serif;
  font-weight: 700; font-size: 1rem;
  padding: 12px 32px; cursor: pointer;
  transition: opacity 0.15s;
}
.celebrate-btn:hover { opacity: 0.88; }