:root {
  --bg: #0d0b1a;
  --bg-2: #14122a;
  --panel: #1b1838;
  --panel-2: #221d44;
  --line: #322c5e;
  --text: #eceaff;
  --muted: #9d97c6;
  --you: #38e1c8;
  --friend: #ff7ad9;
  --accent: #7c5cff;
  --good: #4ade80;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0,0,0,.45);
  --scale: 1; /* sprite size, driven by the slider */
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(124,92,255,.20), transparent 60%),
    radial-gradient(1000px 500px at 100% 0%, rgba(255,122,217,.14), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  padding-bottom: 60px;
}

a { color: var(--you); }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px; flex-wrap: wrap;
  padding: 16px clamp(16px, 4vw, 40px);
  background: rgba(13,11,26,.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  font-size: 26px; line-height: 1;
  background: linear-gradient(135deg, var(--you), var(--accent), var(--friend));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 10px rgba(124,92,255,.5));
}
.brand h1 {
  font-size: clamp(18px, 2.4vw, 26px); margin: 0; letter-spacing: .5px;
  text-transform: uppercase; font-weight: 800;
}

.people { display: flex; gap: 14px; flex-wrap: wrap; }
.person {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 10px 14px; min-width: 190px;
}
.who { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-weight: 700; }
.dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.you-dot { background: var(--you); box-shadow: 0 0 10px var(--you); }
.friend-dot { background: var(--friend); box-shadow: 0 0 10px var(--friend); }
.name-input {
  background: transparent; border: none; color: var(--text);
  font: inherit; font-weight: 700; padding: 2px 4px; width: 130px;
  border-bottom: 1px dashed transparent;
}
.name-input:focus { outline: none; border-bottom-color: var(--you); }
.name-static { font-weight: 700; }
.link-btn {
  margin-left: auto; background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: 13px; padding: 2px 6px; border-radius: 6px;
}
.link-btn:hover { color: var(--friend); background: rgba(255,122,217,.1); }

.bar { height: 7px; border-radius: 99px; background: var(--bg-2); overflow: hidden; }
.bar-fill { height: 100%; width: 0; border-radius: 99px; background: var(--you); transition: width .35s ease; }
.friend-fill { background: var(--friend); }
.count { font-size: 12px; color: var(--muted); margin-top: 6px; font-variant-numeric: tabular-nums; }
.count .mstar { color: #ffce4a; }

/* ---------- Banner ---------- */
.banner {
  margin: 14px clamp(16px, 4vw, 40px) 0;
  padding: 10px 16px; border-radius: 12px;
  background: linear-gradient(90deg, rgba(255,122,217,.18), rgba(124,92,255,.14));
  border: 1px solid var(--line); font-size: 14px;
}

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: 18px clamp(16px, 4vw, 40px) 6px;
}
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  background: var(--panel); color: var(--muted); border: 1px solid var(--line);
  padding: 7px 14px; border-radius: 99px; cursor: pointer; font-size: 13px;
  font-weight: 600; transition: .15s;
}
.chip:hover { color: var(--text); border-color: var(--accent); }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 0 16px rgba(124,92,255,.4); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  padding: 9px 16px; border-radius: 10px; cursor: pointer; font-weight: 700; font-size: 14px;
  transition: .15s;
}
.btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.btn.primary { background: linear-gradient(135deg, var(--accent), #b14bff); border-color: transparent; }
.btn.primary:hover { box-shadow: 0 8px 24px rgba(124,92,255,.45); }

/* ---------- Layout width cap (keeps content tidy on very wide screens) ---------- */
.toolbar, .banner { max-width: 1500px; margin-left: auto; margin-right: auto; }

/* ---------- Grid: families laid out as responsive panels ---------- */
/* Masonry-style columns: families pack tightly top-to-bottom, so uneven
   family heights never leave awkward gaps. */
.grid {
  padding: 14px clamp(16px, 4vw, 40px) 48px;
  max-width: 1520px; margin: 0 auto;
  column-width: calc(300px * var(--scale));
  column-gap: 20px;
}
.family {
  break-inside: avoid; -webkit-column-break-inside: avoid;
  margin: 0 0 20px;
  background: rgba(255, 255, 255, .02);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 14px 6px;
}
.family-head {
  display: flex; align-items: center; gap: 12px; margin-bottom: 14px;
}
.family-head .swatch { width: 12px; height: 28px; border-radius: 6px; }
.family-head h2 { margin: 0; font-size: 19px; text-transform: uppercase; letter-spacing: 1px; font-weight: 800; }
.family-head .fcount {
  font-size: 12px; color: var(--muted); background: var(--panel);
  border: 1px solid var(--line); padding: 3px 10px; border-radius: 99px;
  font-variant-numeric: tabular-nums;
}
.family-head .fcount.done { color: var(--good); border-color: rgba(74,222,128,.4); }

.cards {
  display: grid; gap: 12px; width: 100%;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.card {
  position: relative; cursor: pointer; user-select: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: calc(12px * var(--scale)) calc(6px * var(--scale)) calc(10px * var(--scale)); text-align: center;
  transition: transform .12s ease, border-color .15s, background .15s;
}
.card:hover { transform: translateY(-3px); border-color: var(--accent); }
.card .imgwrap {
  position: relative; width: 100%; max-width: calc(84px * var(--scale)); aspect-ratio: 1 / 1; margin: 0 auto calc(8px * var(--scale));
  display: grid; place-items: center;
}
.card img {
  width: 100%; height: 100%; object-fit: contain;
  filter: grayscale(.85) opacity(.42); transition: filter .2s, transform .2s;
}
.card.mine img { filter: none; }
.card:hover img { transform: scale(1.05); }
.card .label { font-size: calc(12px * var(--scale)); color: var(--muted); font-weight: 600; line-height: 1.25; }
/* mastered toggle — a single star */
.card .stars { display: flex; justify-content: center; margin-top: calc(5px * var(--scale)); line-height: 1; }
.star {
  background: none; border: none; cursor: pointer; padding: calc(2px * var(--scale)) calc(6px * var(--scale));
  font-size: calc(15px * var(--scale)); line-height: 1; color: #3a3560;
  transition: color .12s, transform .1s;
}
.star.on { color: #ffce4a; text-shadow: 0 0 calc(7px * var(--scale)) rgba(255,206,74,.6); }
.star:hover { transform: scale(1.2); color: #ffe08a; }
.card.mastered { border-color: rgba(255,206,74,.5); }
.card .vtag {
  display: inline-block; max-width: 100%; font-size: calc(9.5px * var(--scale)); font-weight: 800; letter-spacing: calc(.2px * var(--scale));
  text-transform: uppercase; padding: calc(2px * var(--scale)) calc(5px * var(--scale)); border-radius: 99px; margin-bottom: calc(4px * var(--scale));
  color: #0d0b1a; white-space: nowrap; overflow: hidden; text-overflow: clip;
}

/* Owned-by-me state */
.card.mine {
  background: linear-gradient(180deg, rgba(56,225,200,.12), var(--panel));
  border-color: rgba(56,225,200,.55);
}
.card .check {
  position: absolute; top: calc(8px * var(--scale)); left: calc(8px * var(--scale));
  width: calc(22px * var(--scale)); height: calc(22px * var(--scale)); border-radius: 50%;
  background: var(--bg-2); border: 1px solid var(--line);
  display: grid; place-items: center; font-size: calc(13px * var(--scale)); color: transparent;
}
.card.mine .check { background: var(--you); border-color: var(--you); color: #062b27; box-shadow: 0 0 12px rgba(56,225,200,.6); }

/* Friend ownership badges (one per friend who owns this sprite) */
.fbadges {
  position: absolute; top: calc(7px * var(--scale)); right: calc(7px * var(--scale));
  display: flex; flex-direction: row-reverse; align-items: center;
}
.fbadge {
  width: calc(20px * var(--scale)); height: calc(20px * var(--scale)); border-radius: 50%;
  display: grid; place-items: center; font-size: calc(10px * var(--scale)); font-weight: 800; color: #1a0a14;
  border: 1.5px solid var(--panel); margin-left: calc(-7px * var(--scale));
  box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.fbadge.more { background: var(--panel-2); color: var(--muted); border-color: var(--line); font-size: calc(9px * var(--scale)); }

/* Trade highlight: a friend has it, I don't */
body.has-friend .card.friend-has:not(.mine) {
  border-color: rgba(255,122,217,.5);
}

.empty { color: var(--muted); padding: 40px 0; text-align: center; }

/* ---------- Footer ---------- */
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 24px 20px 32px; }
.foot p { margin: 5px auto; max-width: 680px; line-height: 1.55; }


/* ---------- Modals ---------- */
.modal {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(6,5,14,.7); backdrop-filter: blur(6px);
  display: grid; place-items: center; padding: 20px;
}
.modal-box {
  position: relative; width: min(520px, 100%);
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 26px; box-shadow: var(--shadow);
}
.modal-box h2 { margin: 0 0 8px; }
.modal-close {
  position: absolute; top: 14px; right: 14px; background: none; border: none;
  color: var(--muted); font-size: 16px; cursor: pointer;
}
.muted { color: var(--muted); font-size: 14px; line-height: 1.5; }
.muted.small { margin-top: 18px; font-size: 12px; }
.copy-row { display: flex; gap: 8px; margin-top: 10px; }
.copy-input {
  flex: 1; min-width: 0; background: var(--bg-2); border: 1px solid var(--line);
  color: var(--text); border-radius: 10px; padding: 10px 12px; font: inherit; font-size: 13px;
}
.copy-input:focus { outline: none; border-color: var(--accent); }
.error { color: #ff8080; font-size: 13px; margin-top: 10px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #fff; padding: 12px 22px; border-radius: 99px;
  font-weight: 700; box-shadow: var(--shadow); z-index: 70;
  animation: pop .2s ease;
}
@keyframes pop { from { transform: translate(-50%, 10px); opacity: 0; } }

/* ---------- Friend list (compact chips + collapse) ---------- */
.friends-wrap { display: flex; flex-direction: column; gap: 6px; align-self: center; }
.friends-toggle {
  align-self: flex-start; background: none; border: none; color: var(--muted);
  font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; padding: 2px 4px;
}
.friends-toggle:hover { color: var(--text); }
.friends-toggle .caret { margin-left: 5px; }
.friend-list { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.friend-list.collapsed { display: none; }
.fchip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 99px;
  padding: 6px 8px 6px 12px; font-size: 13px;
}
.fchip .dot { width: 9px; height: 9px; }
.fchip .fname { font-weight: 700; }
.fchip .fnum { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.fchip .fx {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 12px; line-height: 1; padding: 2px 4px; border-radius: 6px;
}
.fchip .fx:hover { color: #ff8080; background: rgba(255,128,128,.12); }

/* ---------- Share/backup modal extras ---------- */
.modal-sep { border: none; border-top: 1px solid var(--line); margin: 20px 0 16px; }
.restore-msg { font-size: 13px; margin-top: 10px; }
.restore-msg.ok { color: var(--good); }
.restore-msg.err { color: #ff8080; }

/* ---------- Missing-list modal (in-game view) ---------- */
.modal-wide { width: min(920px, 100%); }
.pill-count {
  font-size: 14px; color: var(--friend); background: rgba(255,122,217,.12);
  border: 1px solid rgba(255,122,217,.3); padding: 1px 10px; border-radius: 99px; vertical-align: middle;
}
.missing-body { margin-top: 14px; max-height: 68vh; overflow-y: auto; padding-right: 4px; }
.missing-done { text-align: center; color: var(--good); font-size: 18px; padding: 40px 0; }
.mgroup { margin-bottom: 16px; }
.mgroup-head {
  display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 14px;
  text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px;
}
.mgroup-head .swatch { width: 9px; height: 18px; border-radius: 4px; }
.mgroup-n { font-size: 11px; color: var(--muted); font-weight: 700; }
.mtiles { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); }
.mtile {
  position: relative; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 6px 4px 5px; cursor: pointer; text-align: center; transition: .12s;
}
.mtile:hover { border-color: var(--good); transform: translateY(-2px); }
.mtile:active { transform: scale(.95); }
.mtile img { width: 100%; max-width: 52px; aspect-ratio: 1/1; object-fit: contain; display: block; margin: 0 auto 3px; }
.mtile .mtag {
  display: inline-block; font-size: 8px; font-weight: 800; letter-spacing: .3px; text-transform: uppercase;
  padding: 1px 5px; border-radius: 99px; color: #0d0b1a;
}

/* ---------- Sprite-size slider ---------- */
.scale-control {
  display: flex; align-items: center; gap: 9px;
  color: var(--muted); font-size: 12px; font-weight: 700; white-space: nowrap;
}
.scale-control .scale-ic { line-height: 1; }
.scale-control .scale-ic.small { font-size: 11px; }
.scale-control .scale-ic.big { font-size: 17px; }
.scale-control input[type="range"] {
  width: 130px; accent-color: var(--accent); cursor: pointer; height: 4px;
}

@media (max-width: 560px) {
  .grid { column-width: auto; column-count: 1; }
  /* on phones the slider resizes sprites within each family (fewer/larger per row) */
  .cards { grid-template-columns: repeat(auto-fit, minmax(calc(66px * var(--scale)), 1fr)); }
  .card .imgwrap { max-width: calc(76px * var(--scale)); }
  .actions { width: 100%; }
  .actions .btn { flex: 1 1 auto; }
  .friend-list { width: 100%; }
  .friend-list .person { flex: 1 1 130px; }
  .scale-control { width: 100%; justify-content: center; }
  .scale-control input[type="range"] { flex: 1; width: auto; }
  .mtiles { grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); }
}

/* ---------- Cookie consent banner ---------- */
.cookie-banner {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
  background: rgba(20, 18, 42, .97); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); box-shadow: 0 -8px 30px rgba(0,0,0,.4);
  transform: translateY(110%); transition: transform .25s ease;
  padding: 14px clamp(16px, 4vw, 40px);
}
.cookie-banner.show { transform: translateY(0); }
.cookie-inner {
  max-width: 1100px; margin: 0 auto;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap; justify-content: space-between;
}
.cookie-inner p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.5; flex: 1 1 300px; }
.cookie-inner a { color: var(--you); }
.cookie-btns { display: flex; gap: 10px; flex-wrap: wrap; }

/* footer links */
.foot-links { margin-top: 10px !important; }
.foot-links a { color: var(--muted); text-decoration: underline; }
.foot-links a:hover { color: var(--you); }

/* ---------- Legal / privacy page ---------- */
.legal {
  max-width: 760px; margin: 0 auto; padding: 32px clamp(18px, 5vw, 32px) 90px;
  color: var(--text); line-height: 1.65;
}
.legal h1 { font-size: 28px; margin: 8px 0 4px; }
.legal h2 { font-size: 18px; margin: 28px 0 8px; }
.legal p, .legal li { color: var(--muted); font-size: 15px; }
.legal ul { padding-left: 20px; }
.legal li { margin: 6px 0; }
.legal a { color: var(--you); }
.legal code { background: var(--panel); padding: 1px 6px; border-radius: 6px; font-size: 13px; }
.legal .legal-date { opacity: .7; font-size: 13px; margin-top: 0; }
.back-link { color: var(--you); text-decoration: none; font-weight: 600; }
.back-link:hover { text-decoration: underline; }
.legal-foot { margin-top: 32px; }
