:root {
  --bg: #140f1f;
  --surface: #1e1630;
  --raised: #2b2142;
  --ink: #f7f2fc;
  --steel: #a397b8;
  --line: #352a4d;
  --accent: #ff7ac3; /* Mew pink */
  --accent-soft: rgb(255 122 195 / 0.16);
  --psychic: #a77bff; /* Mewtwo purple */
  --warn: #ffc65c;
  --display: 'Fredoka', 'Trebuchet MS', sans-serif;
  --body: 'Nunito Sans', system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg) radial-gradient(120% 60% at 50% -10%, #2a1747 0%, transparent 70%) no-repeat;
  color: var(--ink);
  font: 400 16px/1.45 var(--body);
  -webkit-tap-highlight-color: transparent;
}
body.scanning { overflow: hidden; }
html, body { overflow-x: clip; } /* a card sliding in never widens the page */

main { max-width: 40rem; margin: 0 auto; padding: 1.25rem 1rem 8rem; }

h1, h2, h3 { font-family: var(--display); font-weight: 600; line-height: 1.1; margin: 0; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.2rem; }
/* The MewDex wordmark: rounded, "Dex" in pink. */
.brand { font-weight: 700; font-size: 2.2rem; letter-spacing: -0.01em; }
.brand span { color: var(--accent); }

p { margin: 0; }
.muted { color: var(--steel); }
.small { font-size: 0.85rem; }
.accent { color: var(--accent); }
.warn { color: var(--warn); }

a { color: inherit; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  min-height: 2.9rem; padding: 0 1.1rem;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--raised); color: var(--ink);
  font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #2a0b1d; }
.btn.quiet { background: transparent; }
.btn.wide { width: 100%; }
.btn.small { min-height: 2.4rem; padding: 0 0.9rem; font-size: 0.85rem; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 1.1rem; }
.note { background: var(--raised); border-radius: 14px; padding: 0.8rem 1rem; margin: 0 0 1rem; }
.empty { text-align: center; padding: 3rem 0; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.topbar .back { text-decoration: none; font-weight: 600; min-height: 2.9rem; display: inline-flex; align-items: center; }

/* Summary: how far the collection is, and what it's worth. */
.summary { display: grid; gap: 0.6rem; margin-bottom: 1rem; }
.count { display: flex; align-items: baseline; gap: 0.4rem; font-family: var(--display); }
.count strong { font-size: 2.6rem; font-weight: 700; line-height: 1; }
.count span { color: var(--steel); font-size: 1.1rem; }
.bar { height: 10px; border-radius: 99px; background: var(--raised); overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--psychic), var(--accent)); }
.worth { display: grid; border-top: 1px solid var(--line); padding-top: 0.7rem; margin-top: 0.2rem; }
.worth strong { font: 700 1.7rem var(--display); color: var(--accent); }

.chips { display: flex; gap: 0.5rem; margin-bottom: 1.25rem; position: sticky; top: 0; z-index: 2; padding: 0.5rem 0; background: var(--bg); }
.chip { min-height: 2.5rem; padding: 0 1rem; border-radius: 999px; border: 1px solid var(--line); background: transparent; font-weight: 600; cursor: pointer; }
a.chip { display: inline-flex; align-items: center; text-decoration: none; }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }

/* Sets, oldest first, each a grid of card tiles. */
.set { margin-bottom: 1.75rem; }
.set-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.6rem; }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.75rem 0.6rem; }
@media (min-width: 34rem) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.tile { display: grid; gap: 0.3rem; min-width: 0; }
.pic { display: block; text-decoration: none; aspect-ratio: 63 / 88; border-radius: 6% / 4.3%; overflow: hidden; background: var(--raised); }
.pic img { width: 100%; height: 100%; object-fit: cover; display: block; filter: grayscale(0.85) brightness(0.55); transition: filter 0.2s; }
.tile.have .pic img { filter: none; }
.tile.have .pic { box-shadow: 0 0 0 2px var(--accent), 0 6px 18px rgb(255 122 195 / 0.25); }
.noimg { display: grid; place-items: center; height: 100%; padding: 0.5rem; text-align: center; font-size: 0.8rem; color: var(--steel); }
.meta { display: flex; justify-content: space-between; gap: 0.25rem; font-size: 0.75rem; color: var(--steel); }
.meta .price { color: var(--ink); font-weight: 600; }
.pills { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.pill {
  min-height: 1.9rem; min-width: 2.2rem; padding: 0 0.45rem; border-radius: 8px;
  border: 1px dashed var(--line); background: transparent; color: var(--steel);
  font-size: 0.75rem; font-weight: 800; cursor: pointer;
}
.pill.on { border: 1px solid var(--accent); background: var(--accent-soft); color: var(--accent); }

.actions { display: flex; gap: 0.4rem; }

/* Binder: pages of 3 × 3 pockets, filled ones in colour. */
.binder-intro { margin-bottom: 1rem; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.6rem; }
.pager .btn { min-width: 3rem; font-size: 1.3rem; }
.pager .btn:disabled { opacity: 0.3; }
.page-no { font: 600 1.05rem var(--display); }
.pages {
  display: flex; overflow-x: auto; overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory; scrollbar-width: none;
}
.pages::-webkit-scrollbar { display: none; }
.page { flex: 0 0 100%; scroll-snap-align: start; scroll-snap-stop: always; padding: 0 0.15rem; }
.pockets {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.45rem;
  padding: 0.6rem; border-radius: 14px; background: #0e0a16; border: 1px solid var(--line);
}
.pocket { position: relative; display: block; aspect-ratio: 63 / 88; border-radius: 6% / 4.3%; overflow: hidden; text-decoration: none; background: var(--raised); outline: 1px dashed var(--line); }
.pocket img { width: 100%; height: 100%; object-fit: cover; display: block; filter: grayscale(1) brightness(0.35); }
.pocket.have { outline: none; }
.pocket.have img { filter: none; }
.pocket.move { outline: 3px solid var(--warn); }
.pocket .label {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 0.15rem 0.3rem;
  background: rgb(0 0 0 / 0.65); font-size: 0.7rem; font-weight: 800; color: var(--ink); text-align: center;
}
.pocket.have .label { background: rgb(0 0 0 / 0.45); }
.moves { display: grid; gap: 0.6rem; margin-bottom: 1.25rem; border-color: var(--warn); }
.moves ol { margin: 0; padding-left: 1.3rem; display: grid; gap: 0.5rem; font-size: 0.9rem; }

.fab {
  position: fixed; left: 50%; bottom: calc(1.25rem + env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 0.5rem; z-index: 5;
  min-height: 3.5rem; padding: 0 1.6rem; border: 0; border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--psychic)); color: #1d0b26;
  font: 700 1.1rem var(--display); cursor: pointer; box-shadow: 0 10px 30px rgb(0 0 0 / 0.45);
}
.fab svg { width: 1.4rem; height: 1.4rem; fill: currentColor; }

/* One card */
.detail { display: grid; gap: 0.75rem; }
.stepper { margin: 0; }
.stepper .page-no { min-width: 4.5rem; text-align: center; font-size: 0.95rem; }
.detail.from-right { animation: slide-in-right 0.22s ease-out; }
.detail.from-left { animation: slide-in-left 0.22s ease-out; }
@keyframes slide-in-right { from { transform: translateX(18%); opacity: 0; } }
@keyframes slide-in-left { from { transform: translateX(-18%); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .detail.from-right, .detail.from-left { animation: none; } }
.detail .big { width: min(100%, 22rem); height: auto; justify-self: center; border-radius: 4.5% / 3.3%; box-shadow: 0 12px 40px rgb(0 0 0 / 0.5); }
.detail .big.noimg { aspect-ratio: 63 / 88; background: var(--raised); }
.variants { list-style: none; margin: 0.5rem 0; padding: 0; display: grid; gap: 0.6rem; }
.variant { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 0.9rem; display: grid; gap: 0.7rem; }
.variant.have { border-color: var(--accent); }
.variant.focus { border-width: 2px; border-color: var(--psychic); }
.variant.focus.have { border-color: var(--accent); }
.focus-tag { font-size: 0.75rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--psychic); }
.variant.focus.have .focus-tag { color: var(--accent); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.own-price { display: grid; gap: 0.3rem; }
.own-price input { flex: 1; min-width: 0; min-height: 2.9rem; padding: 0 0.9rem; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); }

/* Scanner: full-screen camera with a card-shaped guide. */
.scanner { position: fixed; inset: 0; z-index: 10; background: #000; overflow: hidden; }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scanner .frame {
  position: absolute; left: 50%; top: 46%; width: 72%; aspect-ratio: 63 / 88; transform: translate(-50%, -50%);
  border: 3px solid var(--accent); border-radius: 4.5% / 3.3%; box-shadow: 0 0 0 100vmax rgb(0 0 0 / 0.45);
}
.scanner .hint { position: absolute; top: calc(1rem + env(safe-area-inset-top)); left: 1rem; right: 1rem; text-align: center; font-weight: 700; text-shadow: 0 1px 4px #000; }
.scanner .controls {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom));
}
.shutter { width: 4.5rem; height: 4.5rem; border-radius: 50%; border: 5px solid #fff; background: var(--accent); cursor: pointer; }
.shutter:disabled { opacity: 0.3; }
.scanner .results {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; max-height: 75%; overflow: auto;
  background: var(--surface); border-radius: 22px 22px 0 0; padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom));
  display: grid; gap: 0.75rem;
}
.picks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.6rem; }
.pick { display: grid; gap: 0.25rem; padding: 0; border: 0; background: none; text-align: left; cursor: pointer; }
.pick img { width: 100%; aspect-ratio: 63 / 88; object-fit: cover; border-radius: 6% / 4.3%; }
.pick strong { font-size: 0.85rem; line-height: 1.2; }

.toast {
  position: fixed; left: 50%; bottom: calc(5.5rem + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20;
  background: var(--ink); color: var(--bg); padding: 0.7rem 1.1rem; border-radius: 999px; font-weight: 600; max-width: 90vw;
}

/* Login */
.login { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 1rem; text-align: center; }
.login .mark { width: 5rem; height: 5rem; }
.login form { display: grid; gap: 0.75rem; width: min(20rem, 85vw); }
.login input { min-height: 3rem; padding: 0 1rem; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); text-align: center; }
.login .error { color: var(--warn); min-height: 1.4em; }
