:root {
  --ink: #f7f8ff;
  --muted: #9ca7c7;
  --panel: rgba(15, 21, 48, 0.92);
  --panel-2: #141c3e;
  --line: rgba(160, 176, 235, 0.16);
  --accent: #72f0ba;
  --accent-2: #65a7ff;
  --danger: #ff6d91;
  --gold: #ffd64a;
  --rare: #45a6ff;
  --epic: #c063ff;
  --legendary: #ff9f43;
  --mythic: #ffe14d;
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { background: #070a18; }

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 85% 10%, rgba(81, 72, 255, 0.24), transparent 34rem),
    radial-gradient(circle at 10% 30%, rgba(28, 209, 161, 0.12), transparent 28rem),
    linear-gradient(160deg, #090d1d 0%, #070a16 48%, #0b1026 100%);
  min-height: 100vh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0.12;
  background-image:
    linear-gradient(rgba(255,255,255,.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.08) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, #000, transparent 75%);
}

a { color: inherit; }
button, input, select { font: inherit; }
button { color: inherit; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 1.2rem;
  min-height: 72px;
  padding: 0 4vw;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 10, 24, 0.86);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: .65rem;
  text-decoration: none;
  font-weight: 600;
  letter-spacing: .08em;
}

.brand strong { font-weight: 950; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: #081322;
  background: linear-gradient(135deg, #91ffdb, #5b9cff);
  border-radius: 12px 4px 12px 4px;
  box-shadow: 0 0 28px rgba(114, 240, 186, .3);
}

.view-nav {
  display: flex;
  gap: .45rem;
  overflow-x: auto;
  padding: .6rem 0;
  scrollbar-width: none;
}
.view-nav::-webkit-scrollbar { display: none; }
.nav-pill {
  white-space: nowrap;
  padding: .55rem .8rem;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 999px;
  text-decoration: none;
  font-size: .86rem;
  font-weight: 700;
}
.nav-pill:hover, .nav-pill.active {
  color: var(--ink);
  border-color: var(--line);
  background: rgba(255,255,255,.07);
}

main { width: min(1500px, 100%); margin: auto; padding: 2rem 4vw 4rem; }

.hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
  margin: 1rem 0 2rem;
}
.eyebrow {
  margin: 0 0 .45rem;
  color: var(--accent);
  font-size: .75rem;
  font-weight: 900;
  letter-spacing: .18em;
}
h1 {
  margin: 0;
  font-size: clamp(2.25rem, 6vw, 5.8rem);
  line-height: .95;
  letter-spacing: -.06em;
  font-weight: 950;
}
.compact-hero h1, .person-hero h1 { font-size: clamp(2.5rem, 6vw, 5rem); }
.hero-copy { max-width: 48rem; margin: .9rem 0 0; color: var(--muted); font-size: 1rem; }
.hero-total { display: flex; align-items: center; gap: .75rem; flex: 0 0 auto; }
.hero-total > span { font-size: clamp(3.5rem, 8vw, 7rem); line-height: .8; font-weight: 950; color: var(--accent); }
.hero-total small { color: var(--muted); font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }

.progress-orb {
  width: 132px;
  aspect-ratio: 1;
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: auto auto;
  place-content: center;
  align-items: baseline;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(114,240,186,.15), transparent 68%);
  box-shadow: 0 0 40px rgba(114,240,186,.14), inset 0 0 30px rgba(114,240,186,.08);
}
.progress-orb strong { font-size: 2.4rem; line-height: 1; }
.progress-orb span { color: var(--muted); font-weight: 800; }
.progress-orb small { grid-column: 1 / -1; text-align: center; color: var(--muted); text-transform: uppercase; font-size: .65rem; letter-spacing: .12em; }
.editor-badge { display: inline-flex; margin: 1rem 0 0; padding: .45rem .7rem; border-radius: 999px; color: #061a14; background: var(--accent); font-size: .75rem; font-weight: 900; }

.filters {
  display: grid;
  grid-template-columns: minmax(240px, 1.7fr) repeat(2, minmax(150px, .7fr)) auto;
  gap: .75rem;
  align-items: end;
  margin-bottom: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(18, 25, 55, .74);
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
}
.filters label { display: grid; gap: .4rem; }
.filters label span { color: var(--muted); font-size: .7rem; font-weight: 900; text-transform: uppercase; letter-spacing: .1em; }
.filters input, .filters select {
  width: 100%;
  height: 44px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  background: #0b1129;
  padding: 0 .8rem;
}
.filters input:focus, .filters select:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(101,167,255,.13); }
.result-count { margin: 0; height: 44px; display: flex; align-items: center; gap: .35rem; color: var(--muted); white-space: nowrap; }
.result-count strong { color: var(--ink); }

.matrix-shell { border: 1px solid var(--line); border-radius: 18px; overflow: hidden; background: rgba(10, 15, 34, .8); }
.matrix-scroll { overflow: auto; max-height: calc(100vh - 210px); }
.swipe-hint { display: none; margin: 0; padding: .65rem 1rem; color: var(--muted); font-size: .75rem; border-bottom: 1px solid var(--line); }
.collection-matrix { width: 100%; min-width: 790px; table-layout: fixed; border-collapse: separate; border-spacing: 0; }
.collection-matrix col.sprite-column { width: 330px; }
.collection-matrix col.person-column { width: 92px; }
.collection-matrix th, .collection-matrix td { border-bottom: 1px solid var(--line); }
.collection-matrix thead th {
  position: sticky;
  top: 0;
  z-index: 6;
  min-width: 88px;
  padding: .8rem .45rem;
  background: #121a39;
  text-align: center;
}
.collection-matrix thead .sprite-heading { left: 0; z-index: 8; min-width: 330px; text-align: left; padding-left: 1rem; }
.person-avatar { display: grid; place-items: center; width: 34px; height: 34px; margin: 0 auto .35rem; color: #071320; background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-radius: 11px 4px 11px 4px; font-weight: 950; }
.person-name { display: block; font-size: .76rem; }
.person-progress { display: block; margin-top: .18rem; color: var(--muted); font-size: .68rem; }
.sprite-cell {
  position: sticky;
  left: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: .8rem;
  min-width: 330px;
  padding: .55rem .8rem;
  background: #0e1430;
  text-align: left;
}
.sprite-cell img { width: 58px; height: 58px; flex: 0 0 auto; object-fit: contain; border-radius: 11px; background: radial-gradient(circle, rgba(255,255,255,.16), rgba(255,255,255,.02)); }
.sprite-meta { min-width: 0; display: grid; gap: .12rem; }
.sprite-meta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .94rem; }
.sprite-meta > span { color: var(--muted); font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.sprite-meta small { overflow: hidden; color: #7f8bab; font-size: .68rem; text-overflow: ellipsis; white-space: nowrap; max-width: 230px; }
.rarity-dot { display: inline-block; width: 7px; height: 7px; margin-right: .3rem; border-radius: 50%; background: var(--rare); }
.rarity-epic .rarity-dot { background: var(--epic); }
.rarity-legendary .rarity-dot { background: var(--legendary); }
.rarity-mythic .rarity-dot { background: var(--mythic); }
.rarity-special .rarity-dot { background: linear-gradient(135deg, var(--gold), #ff6dd1); }
.state-cell { padding: .4rem; text-align: center; }
.collection-toggle {
  border: 0;
  cursor: default;
}
.state-cell .collection-toggle {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin: auto;
  border: 1px solid rgba(160,176,235,.2);
  border-radius: 12px;
  background: rgba(255,255,255,.025);
}
.state-cell .collection-toggle span { opacity: 0; transform: scale(.5); font-size: 1.25rem; }
.state-cell .collection-toggle.collected { color: #071913; border-color: var(--accent); background: var(--accent); box-shadow: 0 0 20px rgba(114,240,186,.22); }
.state-cell .collection-toggle.collected span { opacity: 1; transform: scale(1); }
.collection-toggle.is-editable { cursor: pointer; }
.collection-toggle.is-editable:hover { border-color: var(--accent); transform: translateY(-1px); }
.collection-toggle.is-saving { opacity: .55; pointer-events: none; }

.sprite-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .8rem; }
.sprite-card { position: relative; overflow: hidden; min-height: 310px; border: 1px solid var(--line); border-radius: 18px 6px 18px 6px; background: linear-gradient(160deg, rgba(29,38,78,.92), rgba(10,15,35,.95)); box-shadow: 0 20px 50px rgba(0,0,0,.18); }
.sprite-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: var(--rare); }
.sprite-card.rarity-epic::before { background: var(--epic); }
.sprite-card.rarity-legendary::before { background: var(--legendary); }
.sprite-card.rarity-mythic::before { background: var(--mythic); }
.sprite-card.rarity-special::before { background: linear-gradient(90deg, var(--gold), #fd6ee5, #6ba8ff); }
.sprite-card.is-collected { border-color: rgba(114,240,186,.55); box-shadow: 0 18px 55px rgba(35,211,158,.12); }
.card-toggle { width: 100%; height: 100%; min-height: 310px; display: grid; grid-template-rows: 170px 1fr; padding: 0; text-align: left; background: transparent; }
.image-stage { position: relative; display: grid; place-items: center; padding: .5rem; background: radial-gradient(circle, rgba(111,130,255,.28), transparent 65%); }
.image-stage img { width: 160px; height: 160px; object-fit: contain; filter: drop-shadow(0 18px 14px rgba(0,0,0,.36)); transition: transform .18s ease; }
.is-editable:hover .image-stage img { transform: scale(1.04) translateY(-2px); }
.card-copy { display: grid; align-content: start; gap: .35rem; padding: .9rem 1rem 1rem; }
.card-copy small { color: var(--muted); text-transform: uppercase; font-size: .66rem; font-weight: 900; letter-spacing: .08em; }
.card-copy strong { font-size: 1.05rem; }
.card-copy > span { color: var(--muted); font-size: .75rem; line-height: 1.35; }
.card-check { position: absolute; top: .7rem; right: .7rem; z-index: 2; display: grid; place-items: center; width: 34px; height: 34px; opacity: 0; color: #071913; background: var(--accent); border-radius: 50%; transform: scale(.65); box-shadow: 0 0 25px rgba(114,240,186,.3); }
.card-toggle.collected .card-check { opacity: 1; transform: scale(1); }

[data-filter-item][hidden] { display: none !important; }
.toast { position: fixed; z-index: 80; right: 1rem; bottom: 1rem; display: flex; align-items: center; gap: 1rem; max-width: min(420px, calc(100vw - 2rem)); padding: .85rem 1rem; border: 1px solid rgba(114,240,186,.4); border-radius: 14px; background: #111936; box-shadow: 0 20px 70px rgba(0,0,0,.45); }
.toast[hidden] { display: none; }
.toast button { padding: .45rem .7rem; border: 0; border-radius: 8px; color: #071913; background: var(--accent); font-weight: 900; cursor: pointer; }

.site-footer { width: min(1000px, calc(100% - 8vw)); margin: 0 auto; padding: 2.2rem 0 3rem; color: #76809e; border-top: 1px solid var(--line); font-size: .7rem; line-height: 1.5; text-align: center; }
.site-footer p { margin: .25rem 0; }
.site-footer a { color: #aab8e4; }

@media (max-width: 800px) {
  .site-header { min-height: 64px; padding: 0 .8rem; gap: .65rem; }
  .brand > span:last-child { font-size: .82rem; }
  .brand-mark { width: 34px; height: 34px; }
  .nav-pill { padding: .5rem .65rem; font-size: .78rem; }
  main { padding: 1rem .7rem 3rem; }
  .hero { align-items: flex-start; margin: .7rem 0 1.4rem; }
  .hero-total { display: none; }
  .person-hero { align-items: center; }
  .progress-orb { width: 102px; }
  .progress-orb strong { font-size: 1.8rem; }
  .filters { grid-template-columns: 1fr 1fr; padding: .7rem; }
  .filters label:first-child { grid-column: 1 / -1; }
  .result-count { height: auto; align-self: center; justify-self: end; }
  .swipe-hint { display: block; }
  .matrix-scroll { max-height: calc(100vh - 230px); }
  .collection-matrix { width: 540px; min-width: 540px; table-layout: fixed; }
  .collection-matrix col.sprite-column { width: 190px; }
  .collection-matrix col.person-column { width: 70px; }
  .collection-matrix thead .sprite-heading, .sprite-cell { min-width: 190px; max-width: 190px; }
  .sprite-cell { gap: .45rem; padding: .4rem .45rem; }
  .sprite-cell img { width: 48px; height: 48px; }
  .sprite-meta small { display: none; }
  .sprite-meta strong { max-width: 128px; font-size: .8rem; }
  .sprite-meta > span { font-size: .6rem; }
  .collection-matrix thead th { width: 70px; min-width: 70px; }
  .person-name { font-size: .66rem; }
  .state-cell .collection-toggle { width: 44px; height: 44px; }
  .sprite-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
  .sprite-card, .card-toggle { min-height: 260px; }
  .card-toggle { grid-template-rows: 145px 1fr; }
  .image-stage img { width: 135px; height: 135px; }
  .card-copy { padding: .75rem; }
  .card-copy > span { display: none; }
}

@media (max-width: 420px) {
  .person-hero h1 { font-size: 2.35rem; }
  .progress-orb { width: 88px; }
  .progress-orb strong { font-size: 1.45rem; }
  .filters { grid-template-columns: 1fr 1fr; }
  .sprite-card, .card-toggle { min-height: 235px; }
  .card-toggle { grid-template-rows: 130px 1fr; }
  .image-stage img { width: 120px; height: 120px; }
  .card-copy strong { font-size: .9rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
