/* Pokémon Hunters — holographic card styles */
:root {
  --bg-0: #06070d;
  --bg-1: #0e1020;
  --bg-2: #161a30;
  --ink: #f5f7ff;
  --ink-dim: #b4b8d4;
  --ink-faint: #6b6f8e;
  --gold: #ffd86b;
  --neon: #7df9ff;
  --pink: #ff5ea8;
  --card-w: 280px;
  --card-h: 400px;
}

[data-theme="light"] {
  --bg-0: #f4f6ff;
  --bg-1: #e8ecff;
  --bg-2: #d6deff;
  --ink: #0d1030;
  --ink-dim: #3a4070;
  --ink-faint: #7a80a0;
}

* { box-sizing: border-box; }
html, body, #root { margin: 0; padding: 0; min-height: 100%; }
body {
  background: var(--bg-0);
  color: var(--ink);
  font-family: 'Fredoka', ui-sans-serif, system-ui, sans-serif;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Sparkle decorations */
.sparkle { position: absolute; pointer-events: none; color: #fde047; filter: drop-shadow(0 0 8px #fde047); animation: sparkPop 2.6s ease-in-out infinite; font-size: 22px; }
@keyframes sparkPop {
  0%,100% { transform: scale(.6) rotate(0deg); opacity: .3; }
  50% { transform: scale(1.15) rotate(20deg); opacity: 1; }
}

/* ─────────── Animated starfield + aurora ─────────── */
.bg-stage {
  position: fixed; inset: 0; z-index: -1; overflow: hidden;
  background: radial-gradient(ellipse at top, #1a1f4a 0%, var(--bg-0) 55%);
}
[data-theme="light"] .bg-stage {
  background: radial-gradient(ellipse at top, #e0e7ff 0%, var(--bg-0) 55%);
}
.aurora {
  position: absolute; inset: -20%;
  background:
    radial-gradient(40% 35% at 20% 30%, rgba(125,249,255,.18), transparent 60%),
    radial-gradient(35% 30% at 80% 20%, rgba(255,94,168,.16), transparent 60%),
    radial-gradient(45% 35% at 60% 80%, rgba(132,204,22,.14), transparent 60%),
    radial-gradient(30% 25% at 10% 70%, rgba(129,140,248,.18), transparent 60%);
  filter: blur(40px);
  animation: aurora 28s ease-in-out infinite alternate;
}
[data-theme="light"] .aurora { opacity: .55; }
@keyframes aurora {
  0%   { transform: translate3d(0,0,0) scale(1); }
  50%  { transform: translate3d(-3%,2%,0) scale(1.05); }
  100% { transform: translate3d(2%,-3%,0) scale(1.08); }
}
.stars {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(1px 1px at 12% 18%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 47% 62%, #cfd6ff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 78% 31%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 23% 88%, #b4baff 50%, transparent 51%),
    radial-gradient(1px 1px at 68% 12%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 92% 73%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 35% 45%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 5% 50%, #aab0ff 50%, transparent 51%),
    radial-gradient(1px 1px at 85% 90%, #fff 50%, transparent 51%);
  background-size: 100% 100%;
  opacity: .65;
  animation: twinkle 6s ease-in-out infinite alternate;
}
[data-theme="light"] .stars { opacity: 0; }
@keyframes twinkle { from { opacity: .35; } to { opacity: .8; } }

/* ─────────── Hero ─────────── */
.hero {
  padding: 88px 32px 32px;
  text-align: center;
  position: relative;
}
.hero .titlewrap { position: relative; display: inline-block; }
.hero .titlewrap .sparkle.s1 { top: -10px; left: -34px; font-size: 28px; animation-delay: 0s; }
.hero .titlewrap .sparkle.s2 { top: 18px; right: -30px; font-size: 20px; animation-delay: .8s; }
.hero .titlewrap .sparkle.s3 { bottom: -6px; left: 12%; font-size: 16px; animation-delay: 1.4s; }
.hero .titlewrap .sparkle.s4 { top: -22px; right: 22%; font-size: 18px; animation-delay: 2s; }
.hero h1 {
  font-family: 'Titan One', cursive;
  font-size: clamp(56px, 11vw, 156px);
  line-height: 1;
  letter-spacing: .005em;
  margin: 0 0 12px;
  padding: 0;
  vertical-align: middle;
  color: #FFD86B;
  -webkit-text-stroke: 5px #1a2f7a;
  paint-order: stroke fill;
  white-space: pre-line;
  text-shadow:
    0 4px 0 #1a2f7a,
    0 8px 0 #1a2f7a,
    0 12px 0 #102055,
    0 16px 0 #102055,
    0 22px 36px rgba(0,0,0,.55);
  transform: rotate(-1deg);
  display: inline-block;
  animation: heroBob 4s ease-in-out infinite;
}
@keyframes heroBob {
  0%,100% { transform: rotate(-1deg) translateY(0); }
  50%     { transform: rotate(-1deg) translateY(-6px); }
}
[data-theme="light"] .hero h1 {
  color: #FFD86B;
  -webkit-text-stroke: 5px #1d3fa8;
  text-shadow:
    0 4px 0 #1d3fa8,
    0 8px 0 #1d3fa8,
    0 12px 0 #102873,
    0 16px 0 #102873,
    0 22px 26px rgba(0,0,0,.25);
}
.hero .sub {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(11px, 1.4vw, 16px);
  letter-spacing: .04em;
  color: var(--gold);
  margin: 0 0 8px;
  text-transform: uppercase;
  text-shadow: 0 2px 0 #6b3a00, 0 0 18px rgba(255,216,107,.6);
}
.hero .tag { color: var(--ink-dim); font-size: 16px; max-width: 720px; margin: 0 auto 32px; line-height: 1.5; }

.counter {
  display: inline-flex; align-items: center; gap: 16px;
  padding: 14px 22px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 999px;
  backdrop-filter: blur(12px);
}
[data-theme="light"] .counter { background: rgba(0,0,0,.04); border-color: rgba(0,0,0,.08); }
.counter .num { font-family: 'Press Start 2P', monospace; font-size: 14px; letter-spacing: .02em; }
.counter .num em { font-style: normal; color: var(--neon); }
.counter .bar { width: 220px; height: 10px; background: rgba(255,255,255,.08); border-radius: 999px; overflow: hidden; position: relative; }
.counter .bar > i {
  display: block; height: 100%;
  background: linear-gradient(90deg,#7df9ff,#84cc16,#fde047,#fb923c,#ff5ea8);
  background-size: 300% 100%;
  animation: shimmer 4s linear infinite;
  box-shadow: 0 0 20px rgba(125,249,255,.6);
}
@keyframes shimmer { from { background-position: 0% 50%; } to { background-position: 300% 50%; } }

/* ─────────── Filter bar ─────────── */
.filterbar {
  position: sticky; top: 8px; z-index: 50;
  margin: 24px auto;
  max-width: 1280px;
  padding: 14px;
  background: rgba(14,16,32,.72);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 18px;
  backdrop-filter: blur(20px) saturate(160%);
  display: grid; gap: 12px;
}
[data-theme="light"] .filterbar { background: rgba(255,255,255,.7); border-color: rgba(0,0,0,.08); }
.filterbar .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filterbar .label { font-family: 'Press Start 2P', monospace; font-size: 9px; text-transform: uppercase; letter-spacing: .04em; color: var(--gold); margin-right: 4px; text-shadow: 0 1px 0 #6b3a00; }
.search {
  flex: 1; min-width: 240px;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 12px;
}
[data-theme="light"] .search { background: rgba(0,0,0,.04); border-color: rgba(0,0,0,.1); }
.search input {
  flex: 1; background: transparent; border: 0; outline: 0;
  color: var(--ink); font-size: 13px;
  font-family: 'Fredoka', sans-serif; font-weight: 500;
}
.search input::placeholder { color: var(--ink-faint); }
.chip {
  appearance: none; border: 0; cursor: pointer;
  padding: 8px 12px; border-radius: 999px; font-size: 9px;
  background: rgba(255,255,255,.06);
  color: var(--ink-dim);
  border: 1px solid rgba(255,255,255,.08);
  transition: all .15s ease;
  font-family: 'Press Start 2P', monospace;
  letter-spacing: .04em;
  text-transform: uppercase;
}
[data-theme="light"] .chip { background: rgba(0,0,0,.04); border-color: rgba(0,0,0,.08); }
.chip:hover { background: rgba(255,255,255,.12); color: var(--ink); }
.chip.on {
  color: #06070d;
  background: linear-gradient(135deg,#7df9ff,#84cc16);
  border-color: transparent;
  box-shadow: 0 0 14px rgba(125,249,255,.4);
}
.sortsel {
  appearance: none; padding: 9px 12px; border-radius: 10px;
  background: rgba(255,255,255,.06); color: var(--ink);
  border: 1px solid rgba(255,255,255,.1);
  font-family: 'Press Start 2P', monospace; font-size: 9px;
  text-transform: uppercase; letter-spacing: .03em;
}
[data-theme="light"] .sortsel { background: rgba(0,0,0,.04); border-color: rgba(0,0,0,.1); }

/* ─────────── Grid ─────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(4, var(--card-w));
  gap: 28px 24px;
  justify-content: center;
  max-width: 1280px;
  margin: 12px auto 80px;
  padding: 0 16px;
}
@media (max-width: 1100px) { .grid { grid-template-columns: repeat(3, var(--card-w)); } }
@media (max-width: 820px)  { .grid { grid-template-columns: repeat(2, var(--card-w)); } }
@media (max-width: 600px)  { .grid { grid-template-columns: var(--card-w); } }

.empty {
  grid-column: 1/-1;
  text-align: center; padding: 80px 20px; color: var(--ink-faint);
}

/* ─────────── Card ─────────── */
.card-wrap {
  width: var(--card-w); height: var(--card-h);
  perspective: 1400px;
  position: relative;
  opacity: 0; transform: translateY(20px);
  animation: cardin .55s cubic-bezier(.2,.8,.2,1) forwards;
}
@keyframes cardin { to { opacity: 1; transform: translateY(0); } }

.card {
  position: relative;
  width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform .7s cubic-bezier(.2,.8,.2,1);
  cursor: pointer;
  --rx: 0deg; --ry: 0deg;
  transform: rotateX(var(--rx)) rotateY(var(--ry));
}
.card.flipped { transform: rotateY(180deg) rotateX(var(--rx)) rotateY(var(--ry)); }

.face {
  position: absolute; inset: 0;
  border-radius: 20px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
  background: #11132a;
  /* gradient border via padding+inner */
  padding: 4px;
  background-image: var(--grad);
  box-shadow: 0 14px 40px rgba(0,0,0,.45),
              0 0 0 1px rgba(255,255,255,.06) inset,
              0 0 30px -8px var(--accent);
}
.face.back { transform: rotateY(180deg); }

.inner {
  width: 100%; height: 100%;
  background: linear-gradient(180deg,#161a30 0%,#0c0e22 100%);
  border-radius: 16px;
  position: relative;
  display: flex; flex-direction: column;
  overflow: hidden;
}
[data-theme="light"] .inner { background: linear-gradient(180deg,#fff 0%,#eef2ff 100%); }

/* Holo overlay */
.holo {
  position: absolute; inset: 0; pointer-events: none; mix-blend-mode: color-dodge;
  background:
    conic-gradient(from var(--ang,0deg) at 50% 50%,
      rgba(255,94,168,.0) 0deg,
      rgba(255,94,168,.45) 50deg,
      rgba(125,249,255,.45) 110deg,
      rgba(132,204,22,.40) 170deg,
      rgba(253,224,71,.45) 230deg,
      rgba(251,146,60,.40) 290deg,
      rgba(255,94,168,.0) 360deg);
  opacity: 0;
  transition: opacity .25s ease;
  border-radius: 16px;
}
.card-wrap:hover .holo { opacity: .55; animation: rot 6s linear infinite; }
@keyframes rot { to { --ang: 360deg; } }
@property --ang { syntax: '<angle>'; inherits: false; initial-value: 0deg; }

.shine {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(115deg, transparent 35%, rgba(255,255,255,.18) 50%, transparent 65%);
  background-size: 250% 100%;
  background-position: 200% 0;
  border-radius: 16px;
  opacity: 0;
  transition: opacity .25s;
}
.card-wrap:hover .shine { opacity: 1; animation: shineMove 2.4s ease-in-out infinite; }
@keyframes shineMove { 0% { background-position: 200% 0; } 100% { background-position: -100% 0; } }

/* Card top header */
.cardhdr {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 12px 14px 8px; gap: 8px;
  position: relative; z-index: 2;
}
.cardname {
  font-family: 'Press Start 2P', monospace;
  font-size: 9.5px; line-height: 1.4;
  margin: 0;
  letter-spacing: 0;
  color: #fff;
  text-shadow: 0 1px 0 #000, 0 2px 0 rgba(0,0,0,.7), 0 0 12px rgba(255,255,255,.25);
  word-wrap: break-word;
  flex: 1;
  min-width: 0;
}
.collno {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: var(--gold);
  background: rgba(0,0,0,.55);
  border: 1px solid rgba(255,216,107,.35);
  padding: 5px 7px; border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: .04em;
  text-shadow: 0 1px 0 #6b3a00;
}
[data-theme="light"] .collno { background: rgba(255,255,255,.6); border-color: rgba(0,0,0,.08); color: #444; }

.badges {
  display: flex; flex-wrap: wrap; gap: 5px;
  padding: 0 14px 8px;
  position: relative; z-index: 2;
}
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 7px 3px;
  border-radius: 4px;
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  letter-spacing: .04em;
  text-transform: uppercase;
  background: rgba(0,0,0,.55);
  color: #fff;
  border: 1px solid rgba(255,255,255,.18);
  box-shadow: 0 2px 0 rgba(0,0,0,.5);
  text-shadow: 0 1px 0 #000;
}
[data-theme="light"] .badge { background: rgba(255,255,255,.85); color: #1a1a2e; border-color: rgba(0,0,0,.06); }
.badge .e { font-size: 11px; font-family: 'Fredoka', sans-serif; }

/* Image area */
.photo {
  flex: 1; min-height: 0;
  position: relative;
  margin: 0 12px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--grad);
  border: 1px solid rgba(255,255,255,.08);
}
.photo img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.photo .placeholder {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-family: 'Fredoka', sans-serif;
  font-size: 64px;
  color: rgba(255,255,255,.92);
  text-shadow: 0 4px 16px rgba(0,0,0,.4);
  background: var(--grad);
}
.photo .placeholder small {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px; font-weight: normal;
  letter-spacing: .04em; text-transform: uppercase;
  margin-top: 12px; padding: 0 12px;
  color: rgba(255,255,255,.95);
  text-align: center; line-height: 1.5;
  text-shadow: 0 1px 0 rgba(0,0,0,.4);
}

.imgtag {
  position: absolute; right: 6px; bottom: 6px;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 7px 4px;
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  letter-spacing: .04em;
  text-transform: uppercase;
  background: rgba(0,0,0,.78);
  color: #fff;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,.18);
  cursor: pointer;
  backdrop-filter: blur(6px);
  box-shadow: 0 2px 0 rgba(0,0,0,.5);
}
.imgtag.original {
  background: linear-gradient(135deg,#7df9ff,#84cc16);
  color: #06070d;
  border-color: transparent;
}
.imgtag:hover { transform: translateY(-1px); }

.editbtn {
  position: absolute; right: 8px; top: 8px;
  width: 28px; height: 28px;
  background: rgba(0,0,0,.6);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 14px;
  backdrop-filter: blur(6px);
  color: #fff;
  opacity: 0;
  transition: opacity .15s;
}
.card-wrap:hover .editbtn { opacity: 1; }

/* Bottom strip */
.cardfoot {
  padding: 8px 12px 12px;
  position: relative; z-index: 2;
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  letter-spacing: .04em;
  color: var(--ink-dim);
  display: flex; justify-content: space-between; gap: 8px;
  text-transform: uppercase;
}
.cardfoot .where { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60%; }

/* ─────────── Back of card ─────────── */
.back .inner {
  background:
    radial-gradient(ellipse at top right, rgba(125,249,255,.18), transparent 50%),
    radial-gradient(ellipse at bottom left, rgba(255,94,168,.15), transparent 50%),
    linear-gradient(180deg,#0c0e22 0%,#161a30 100%);
  padding: 18px;
  display: flex; flex-direction: column; gap: 12px;
}
[data-theme="light"] .back .inner {
  background:
    radial-gradient(ellipse at top right, rgba(8,145,178,.12), transparent 50%),
    radial-gradient(ellipse at bottom left, rgba(190,24,93,.1), transparent 50%),
    linear-gradient(180deg,#fff 0%,#eef2ff 100%);
}
.back .name {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px; line-height: 1.4; margin: 0;
  color: var(--gold);
  text-shadow: 0 2px 0 #6b3a00;
  word-wrap: break-word;
}
.back .sci {
  font-family: 'Fredoka', sans-serif;
  font-style: italic; font-size: 13px; color: var(--ink-dim); margin: 2px 0 0;
}
.back .factlist { list-style: none; padding: 0; margin: 4px 0; display: flex; flex-direction: column; gap: 8px; }
.back .factlist li {
  font-family: 'Fredoka', sans-serif; font-weight: 500;
  font-size: 12.5px; line-height: 1.45;
  color: var(--ink); padding-left: 18px; position: relative;
}
.back .factlist li::before {
  content: ""; position: absolute; left: 0; top: 6px;
  width: 8px; height: 8px; border-radius: 2px;
  background: var(--grad);
  transform: rotate(45deg);
}
.back .meta {
  margin-top: auto;
  border-top: 1px dashed rgba(255,255,255,.18);
  padding-top: 10px;
  font-family: 'Press Start 2P', monospace;
  font-size: 7px; line-height: 1.6;
  letter-spacing: .04em;
  color: var(--ink-dim);
  display: flex; flex-direction: column; gap: 5px;
  text-transform: uppercase;
}
.back .meta .pin { display: inline-flex; align-items: center; gap: 6px; }
[data-theme="light"] .back .meta { border-top-color: rgba(0,0,0,.1); }

/* ─────────── Theme toggle ─────────── */
.themetoggle {
  position: fixed; top: 18px; right: 18px; z-index: 100;
  width: 42px; height: 42px;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  backdrop-filter: blur(12px);
  color: var(--ink);
  cursor: pointer; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
}
[data-theme="light"] .themetoggle { background: rgba(0,0,0,.05); border-color: rgba(0,0,0,.1); }

/* ─────────── Footer ─────────── */
.footer {
  text-align: center;
  padding: 60px 20px 40px;
  color: var(--ink-faint);
  font-size: 14px;
  border-top: 1px solid rgba(255,255,255,.06);
}
.footer .heart {
  font-family: 'Titan One', cursive;
  font-size: 26px;
  letter-spacing: .01em;
  color: #FFD86B;
  -webkit-text-stroke: 2px #1a2f7a;
  paint-order: stroke fill;
  text-shadow: 0 3px 0 #1a2f7a, 0 5px 0 #102055;
  display: inline-block;
  transform: rotate(-1deg);
}
.footer { font-family: 'Fredoka', sans-serif; }
[data-theme="light"] .footer { border-top-color: rgba(0,0,0,.08); }
