/* Sprite Shrine — dark night-shrine aesthetic for a sprite collection altar. */
:root {
  --ink: #0c0a1d;
  --ink-2: #141130;
  --panel: #1a1638;
  --line: #2c2757;
  --text: #eae6ff;
  --text-dim: #9b93c9;
  --aurora: #3ef2c4;
  --aurora-deep: #0fa07c;
  --gold: #f5c04a;
  --gummy: #ff7bbf;
  --galaxy: #9d7bff;
  --gem: #5bd6ff;
  --holofoil: #c8f2e9;
  --cube: #ff5e7e;
  --quack: #ffd93b;
  --radius: 14px;
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Overpass", sans-serif;
  color: var(--text);
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(157, 123, 255, 0.18), transparent 60%),
    radial-gradient(900px 600px at -10% 20%, rgba(62, 242, 196, 0.12), transparent 55%),
    radial-gradient(700px 700px at 50% 110%, rgba(255, 94, 126, 0.10), transparent 60%),
    linear-gradient(180deg, var(--ink) 0%, var(--ink-2) 100%);
  background-attachment: fixed;
}

/* faint noise so the gradients don't band */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* drifting spirit wisps */
.wisps { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.wisps i {
  position: absolute;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--aurora);
  filter: blur(3px);
  opacity: 0;
  animation: drift 16s linear infinite;
}
.wisps i:nth-child(1) { left: 8%;  animation-delay: 0s;   background: var(--aurora); }
.wisps i:nth-child(2) { left: 26%; animation-delay: 5s;   background: var(--galaxy); }
.wisps i:nth-child(3) { left: 45%; animation-delay: 9s;   background: var(--gem); }
.wisps i:nth-child(4) { left: 63%; animation-delay: 2.5s; background: var(--gummy); }
.wisps i:nth-child(5) { left: 78%; animation-delay: 12s;  background: var(--aurora); }
.wisps i:nth-child(6) { left: 92%; animation-delay: 7s;   background: var(--gold); }
@keyframes drift {
  0%   { transform: translateY(105vh) scale(0.6); opacity: 0; }
  10%  { opacity: 0.7; }
  90%  { opacity: 0.4; }
  100% { transform: translateY(-8vh) scale(1.1); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .wisps { display: none; }
  * { animation: none !important; transition: none !important; }
}

/* ---------- header ---------- */
.site-head {
  max-width: 1100px;
  margin: 0 auto;
  padding: 3.5rem 1.25rem 1rem;
  text-align: center;
}
.kicker {
  margin: 0 0 0.4rem;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--aurora);
}
h1 {
  font-family: "Titan One", cursive;
  font-size: clamp(2.6rem, 7vw, 4.5rem);
  margin: 0;
  line-height: 1.05;
  letter-spacing: 0.01em;
  text-shadow: 0 6px 30px rgba(62, 242, 196, 0.25);
}
h1 span {
  background: linear-gradient(120deg, var(--aurora), var(--gem) 55%, var(--galaxy));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.tagline {
  color: var(--text-dim);
  max-width: 46ch;
  margin: 0.9rem auto 1.6rem;
}

.progress-wrap { max-width: 560px; margin: 0 auto; }
.progress-track {
  height: 14px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--aurora-deep), var(--aurora), var(--gem));
  box-shadow: 0 0 14px rgba(62, 242, 196, 0.6);
  transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
.progress-label { margin: 0.5rem 0 0; color: var(--text-dim); font-size: 0.9rem; }
.progress-label strong { color: var(--aurora); font-size: 1.15rem; }

/* ---------- controls ---------- */
.controls {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  justify-content: center;
  max-width: 1100px;
  margin: 1.2rem auto 0;
  padding: 0.75rem 1.25rem;
  backdrop-filter: blur(10px);
  background: rgba(12, 10, 29, 0.75);
  border-bottom: 1px solid var(--line);
}
#search {
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.5rem 1rem;
  min-width: 200px;
  outline: none;
}
#search:focus { border-color: var(--aurora); box-shadow: 0 0 0 3px rgba(62, 242, 196, 0.15); }

.profile-wrap { display: inline-flex; gap: 0.35rem; align-items: center; }
.profile-menu { position: relative; display: inline-block; }
#profileBtn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  max-width: 180px;
  cursor: pointer;
  transition: border-color 0.12s;
}
#profileBtn:hover, #profileBtn:focus-visible { border-color: var(--aurora); outline: none; }
#profileBtn .caret { color: var(--aurora); font-size: 0.7rem; transition: transform 0.15s; }
#profileBtn[aria-expanded="true"] .caret { transform: rotate(180deg); }
#profileBtnLabel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* author display beats the UA [hidden] rule, so restate it explicitly */
#profileList[hidden] { display: none; }
#profileList {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  min-width: 100%;
  max-width: 240px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  padding: 0.35rem;
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(5, 4, 14, 0.7), 0 0 18px rgba(62, 242, 196, 0.08);
}
.profile-option {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: left;
  color: var(--text-dim);
  background: transparent;
  border: 0;
  border-radius: 8px;
  padding: 0.45rem 0.7rem;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.profile-option:hover, .profile-option:focus-visible { color: var(--text); background: var(--panel); outline: none; }
.profile-option.active { color: var(--ink); background: var(--aurora); }
#newProfileBtn { padding: 0.4rem 0.7rem; font-weight: 800; }

.field-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 0.7rem 0 0.25rem;
}
#profileName {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
}
.dialog-note { margin-top: 0.7rem; }

.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; justify-content: center; }
.chip {
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.32rem 0.8rem;
  cursor: pointer;
  transition: transform 0.12s, color 0.12s, border-color 0.12s;
}
.chip:hover { transform: translateY(-1px); color: var(--text); }
.chip.active { color: var(--ink); background: var(--aurora); border-color: var(--aurora); }
.chip.active.finish-gold     { background: var(--gold);     border-color: var(--gold); }
.chip.active.finish-gummy    { background: var(--gummy);    border-color: var(--gummy); }
.chip.active.finish-galaxy   { background: var(--galaxy);   border-color: var(--galaxy); }
.chip.active.finish-gem      { background: var(--gem);      border-color: var(--gem); }
.chip.active.finish-holofoil { background: var(--holofoil); border-color: var(--holofoil); }
.chip.active.finish-cube     { background: var(--cube);     border-color: var(--cube); }
.chip.active.finish-quack    { background: var(--quack);    border-color: var(--quack); }

.toggle {
  position: relative;
  display: inline-flex;
  gap: 0.45rem;
  align-items: center;
  color: var(--text-dim);
  font-size: 0.85rem;
  cursor: pointer;
  user-select: none;
}
.toggle:hover { color: var(--text); }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle .track {
  flex: none;
  width: 34px; height: 18px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  position: relative;
  transition: background 0.15s, border-color 0.15s;
}
.toggle .track::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform 0.15s, background 0.15s;
}
.toggle input:checked + .track { background: var(--aurora-deep); border-color: var(--aurora); }
.toggle input:checked + .track::after { transform: translateX(16px); background: var(--ink); }
.toggle input:focus-visible + .track { outline: 2px solid var(--aurora); outline-offset: 2px; }

.ghost-btn {
  font: inherit;
  font-size: 0.85rem;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
}
.ghost-btn:hover { color: var(--text); border-color: var(--aurora); }
.ghost-btn.danger:hover { border-color: var(--cube); color: var(--cube); }

/* ---------- groups & cards ---------- */
main { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }
.loading { text-align: center; color: var(--text-dim); padding: 3rem 0; }

.sprite-group { margin: 2.2rem 0; }
.sprite-group h2 {
  font-family: "Titan One", cursive;
  font-size: 1.35rem;
  letter-spacing: 0.02em;
  margin: 0 0 0.8rem;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.6rem;
}
.group-count {
  font-family: "Overpass", sans-serif;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--text-dim);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
}
.sprite-group.complete .group-count { color: var(--ink); background: var(--aurora); border-color: var(--aurora); }

.grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.7rem;
}

.card {
  flex: 0 1 148px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.8rem 0.5rem 0.7rem;
  font: inherit;
  color: var(--text-dim);
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.card:hover { transform: translateY(-3px); border-color: var(--text-dim); }
.card:focus-visible { outline: 2px solid var(--aurora); outline-offset: 2px; }
.card img {
  width: 84px; height: 84px;
  object-fit: contain;
  filter: grayscale(0.85) brightness(0.75);
  transition: filter 0.2s;
}
.card.no-img::before { content: "❔"; font-size: 3rem; line-height: 84px; height: 84px; }
.card-name { font-size: 0.72rem; font-weight: 600; line-height: 1.25; }

.finish-tag {
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  background: var(--ink);
  color: var(--text-dim);
}
.card.finish-gold     .finish-tag { color: var(--gold); }
.card.finish-gummy    .finish-tag { color: var(--gummy); }
.card.finish-galaxy   .finish-tag { color: var(--galaxy); }
.card.finish-gem      .finish-tag { color: var(--gem); }
.card.finish-holofoil .finish-tag { color: var(--holofoil); }
.card.finish-cube     .finish-tag { color: var(--cube); }
.card.finish-quack    .finish-tag { color: var(--quack); }

.pips {
  display: flex;
  gap: 4px;
  margin-top: 0.15rem;
  height: 10px;
  visibility: hidden;
}
.card.owned .pips { visibility: visible; }
.pip {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--ink);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform 0.1s, background 0.12s, border-color 0.12s;
}
.pip:hover { transform: scale(1.35); border-color: var(--aurora); }
.pip.filled { background: var(--aurora); border-color: var(--aurora-deep); }
.card.maxed .pip.filled { background: var(--gold); border-color: var(--gold); }
.card.maxed {
  border-color: var(--gold);
  box-shadow: 0 0 18px rgba(245, 192, 74, 0.22), inset 0 0 24px rgba(245, 192, 74, 0.06);
}
.card.maxed .tick { background: var(--gold); }
.sprite-group.mastered .group-count { color: var(--ink); background: var(--gold); border-color: var(--gold); }
#maxedNote { color: var(--gold); }

.tick {
  position: absolute;
  top: 0.45rem; right: 0.45rem;
  width: 1.25rem; height: 1.25rem;
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--ink);
  background: var(--aurora);
  border-radius: 50%;
  transform: scale(0);
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.card.owned {
  color: var(--text);
  border-color: var(--aurora-deep);
  box-shadow: 0 0 18px rgba(62, 242, 196, 0.18), inset 0 0 24px rgba(62, 242, 196, 0.05);
}
.card.owned img { filter: none; }
.card.owned .tick { transform: scale(1); }

/* ---------- footer & dialog ---------- */
.site-foot {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.25rem 2.5rem;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.8rem;
}
.site-foot a { color: var(--aurora); }
.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
}
.badge.ok { color: var(--aurora); border-color: var(--aurora-deep); }
.badge.warn { color: var(--gold); border-color: var(--gold); }

dialog {
  background: var(--ink-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem;
  max-width: 420px;
  width: calc(100vw - 2rem);
}
dialog::backdrop { background: rgba(5, 4, 14, 0.7); backdrop-filter: blur(4px); }
dialog h2 { font-family: "Titan One", cursive; margin: 0 0 0.5rem; }
dialog p { color: var(--text-dim); font-size: 0.85rem; margin: 0 0 0.8rem; }
#backupText {
  width: 100%;
  font: 0.78rem/1.4 monospace;
  color: var(--text);
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.6rem;
  resize: vertical;
}
.dialog-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 0.8rem; }
