/* Jadeite Toy Co. — one stylesheet, no build. Tokens first, then screens. */
@font-face { font-family: "Fredoka"; src: url("assets/fonts/Fredoka.woff2") format("woff2"); font-weight: 300 700; font-display: swap; }
@font-face { font-family: "Nunito"; src: url("assets/fonts/Nunito.woff2") format("woff2"); font-weight: 200 1000; font-display: swap; }
@font-face { font-family: "Caveat"; src: url("assets/fonts/Caveat.woff2") format("woff2"); font-weight: 400 700; font-display: swap; }

:root {
  --jade: #2F7D5B; --jade-deep: #1D5C44; --jade-tint: #DDEBE3;
  --paper: #F2F5F1; --paper-2: #E4ECE6; --card: #FFFFFF;
  --ink: #1E2A26; --ink-2: #51625B; --line: rgba(30, 42, 38, .12);
  --tag: #FFD54A; --tag-ink: #4A3A00; --wood: #C8A072; --wood-dark: #9A744A;
  --danger: #C0392B;
  --shadow: 0 10px 24px -14px rgba(20, 40, 30, .45);
  --radius: 18px;
  --display: "Fredoka", "Nunito", system-ui, sans-serif;
  --body: "Nunito", system-ui, sans-serif;
  --hand: "Caveat", cursive;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --jade: #5FBF93; --jade-deep: #2F7D5B; --jade-tint: #1B2A23;
    --paper: #121A16; --paper-2: #1B2620; --card: #1F2C26;
    --ink: #E8EFEA; --ink-2: #A9B8B0; --line: rgba(232, 239, 234, .12);
    --wood: #7A5A3A; --wood-dark: #4F3A24;
    --shadow: 0 10px 24px -14px rgba(0, 0, 0, .8);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --jade: #5FBF93; --jade-deep: #2F7D5B; --jade-tint: #1B2A23;
  --paper: #121A16; --paper-2: #1B2620; --card: #1F2C26;
  --ink: #E8EFEA; --ink-2: #A9B8B0; --line: rgba(232, 239, 234, .12);
  --wood: #7A5A3A; --wood-dark: #4F3A24;
  --shadow: 0 10px 24px -14px rgba(0, 0, 0, .8);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 16px/1.45 var(--body); min-height: 100dvh;
  -webkit-tap-highlight-color: transparent; overscroll-behavior-y: contain;
}
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; line-height: 1.1; margin: 0; letter-spacing: -.01em; }
a { color: var(--jade); }
:focus-visible { outline: 3px solid var(--tag); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }

#app { max-width: 600px; margin: 0 auto; padding: 0 0 calc(84px + env(safe-area-inset-bottom)); min-height: 100dvh; }
#loading { text-align: center; color: var(--ink-2); padding: 40vh 16px 0; font-family: var(--display); }

/* Buttons */
.btn { border: 0; border-radius: 999px; padding: 12px 20px; font-family: var(--display); font-weight: 600; font-size: 16px; background: var(--paper-2); color: var(--ink); transition: transform .12s, filter .12s; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--jade); color: #fff; }
.btn.ghost { background: transparent; box-shadow: inset 0 0 0 2px var(--line); }
.btn.small { padding: 8px 14px; font-size: 14px; }
.btn.danger { background: transparent; color: var(--danger); box-shadow: inset 0 0 0 2px var(--danger); position: relative; overflow: hidden; }
.btn.danger.is-holding::after { content: ""; position: absolute; inset: 0; background: var(--danger); opacity: .25; transform-origin: left; animation: fill 1.6s linear forwards; }
@keyframes fill { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.btn:disabled { opacity: .45; cursor: default; transform: none; }

/* Tab bar */
.tabbar { position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: min(600px, 100%); display: flex; gap: 4px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); background: color-mix(in oklab, var(--paper) 88%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--line); z-index: 20; }
.tabbar button { flex: 1; border: 0; background: transparent; border-radius: 14px; padding: 10px 0 8px; font-family: var(--display); font-weight: 600; font-size: 15px; color: var(--ink-2); position: relative; }
.tabbar button.is-active { color: var(--jade); background: var(--jade-tint); }
.tabbar button.is-active::after { content: ""; position: absolute; left: 50%; bottom: 4px; width: 6px; height: 6px; margin-left: -3px; border-radius: 50%; background: var(--jade); }

#toast { position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 999px; font-weight: 700; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 50; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#app.screen-opening ~ #toast { bottom: auto; top: calc(70px + env(safe-area-inset-top)); }
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60; }

/* ---------- Wall ---------- */
.shop-sign { position: relative; background: var(--jade); color: #fff; padding: 28px 20px 30px; text-align: center; overflow: hidden; }
.shop-sign::before { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 28px, rgba(255, 255, 255, .08) 28px 56px); }
.shop-sign::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 14px; background: radial-gradient(circle at 14px -2px, transparent 13px, var(--paper) 14px) 0 0 / 28px 16px repeat-x; }
.shop-sign h1 { font-size: clamp(30px, 8vw, 40px); font-weight: 700; letter-spacing: .02em; position: relative; }
.shop-sign h1 span { display: inline-block; padding: 4px 18px; border: 3px solid rgba(255, 255, 255, .85); border-radius: 14px; box-shadow: 0 0 0 4px var(--jade), 0 0 0 6px rgba(255, 255, 255, .35); background: var(--jade-deep); }
.sign-tag { margin: 12px 0 0; font-family: var(--hand); font-size: 20px; opacity: .95; position: relative; }

.counter { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: stretch; padding: 16px 16px 4px; }
.allowance { background: var(--tag); color: var(--tag-ink); border-radius: 14px; padding: 10px 14px; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 12px; align-items: center; position: relative; box-shadow: var(--shadow); }
.allowance::before { content: ""; position: absolute; top: -6px; left: 18px; width: 10px; height: 10px; border-radius: 50%; background: var(--paper); box-shadow: inset 0 1px 2px rgba(0, 0, 0, .2); }
.allowance-n { grid-row: 1 / 3; font-family: var(--display); font-weight: 700; font-size: 44px; line-height: 1; }
.allowance-text { font-weight: 700; font-size: 14px; }
.allowance.is-empty { background: var(--paper-2); color: var(--ink-2); }
.thirds { display: flex; gap: 4px; }
.thirds i { width: 14px; height: 6px; border-radius: 3px; background: rgba(0, 0, 0, .15); }
.thirds i.on { background: var(--tag-ink); }
.mystery { border: 0; background: var(--card); border-radius: 14px; padding: 8px 12px; display: grid; justify-items: center; gap: 2px; font-family: var(--display); font-weight: 600; font-size: 13px; box-shadow: var(--shadow); min-width: 96px; }
.mystery svg { width: 44px; animation: wiggle 3s ease-in-out infinite; }
.mystery.is-used { opacity: .5; }
.mystery.is-used svg { animation: none; }
@keyframes wiggle { 0%, 80%, 100% { transform: rotate(0); } 85% { transform: rotate(-6deg); } 90% { transform: rotate(6deg); } 95% { transform: rotate(-3deg); } }

.aisle { padding: 18px 0 6px; }
.aisle h2 { padding: 0 16px; font-size: 22px; display: flex; align-items: baseline; gap: 10px; }
.aisle h2 small { font-family: var(--body); font-weight: 600; font-size: 13px; color: var(--ink-2); }
.shelf-row { display: flex; gap: 10px; overflow-x: auto; padding: 14px 16px 22px; scroll-snap-type: x proximity; scrollbar-width: none; position: relative;
  background: linear-gradient(to top, var(--wood-dark) 0 6px, var(--wood) 6px 18px, transparent 18px) no-repeat bottom; }
.shelf-row::-webkit-scrollbar { display: none; }
.stack { flex: 0 0 auto; width: 128px; border: 0; background: transparent; padding: 0; text-align: left; scroll-snap-align: start; display: grid; gap: 4px; position: relative; color: var(--ink); }
.stack.is-small { width: 104px; }
.stack-art { display: block; position: relative; height: 150px; }
.stack.is-small .stack-art { height: 120px; }
.stack-art .box { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: auto; filter: drop-shadow(0 8px 8px rgba(0, 0, 0, .18)); transition: transform .2s; }
.stack-art .box:nth-child(1) { transform: translate(10px, -10px) scale(.96); opacity: .85; }
.stack-art .box:nth-child(2) { transform: translate(5px, -5px) scale(.98); opacity: .95; }
.stack:active .stack-art .box:nth-child(3) { transform: translateY(-4px) rotate(-2deg); }
.stack.is-locked .stack-art .box { filter: grayscale(.4) opacity(.8); }
.stack-name { font-family: var(--display); font-weight: 600; font-size: 15px; line-height: 1.15; padding-top: 6px; }
.stack-count { font-size: 12px; color: var(--ink-2); font-weight: 700; }
.badges { position: absolute; top: 0; left: -4px; display: grid; gap: 3px; z-index: 2; }
.badge { font-style: normal; font-family: var(--display); font-weight: 700; font-size: 10px; letter-spacing: .04em; padding: 3px 7px; border-radius: 6px; background: var(--ink); color: var(--paper); transform: rotate(-4deg); width: max-content; box-shadow: 0 2px 4px rgba(0, 0, 0, .2); }
.badge.new { background: #E8457A; color: #fff; }
.badge.done { background: var(--jade); color: #fff; }
.badge.pick { background: var(--tag); color: var(--tag-ink); }
.badge.soon { background: var(--wood-dark); color: #fff; }
.badge.today { background: #EF476F; color: #fff; }
.badge.mini { background: var(--paper-2); color: var(--ink-2); }

.collectors { padding: 20px 16px 8px; }
.collectors h2 { font-size: 22px; margin-bottom: 10px; }
.collector-row { display: grid; gap: 12px; }
.collector { display: grid; grid-template-columns: 72px 1fr; gap: 12px; background: var(--card); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); border-left: 6px solid var(--c); }
.collector-face { width: 72px; height: 72px; border-radius: 50%; background: radial-gradient(circle at 50% 35%, #fff, color-mix(in oklab, var(--c) 35%, var(--paper-2))); object-fit: cover; box-shadow: inset 0 0 0 3px var(--c); }
.collector-body strong { font-family: var(--display); font-size: 18px; }
.collector-body small { color: var(--ink-2); font-size: 13px; }
.bubble { margin: 6px 0 2px; background: var(--paper-2); padding: 8px 12px; border-radius: 14px 14px 14px 4px; font-weight: 600; }
.aside { margin: 4px 0; font-size: 13px; color: var(--ink-2); font-style: italic; }
.want { display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 8px; margin-top: 8px; }
.want img { width: 44px; height: 44px; }
.want span { font-size: 14px; font-weight: 700; line-height: 1.1; }
.want em { display: block; font-style: normal; font-weight: 600; color: var(--ink-2); font-size: 12px; }
.wall-foot { text-align: center; color: var(--ink-2); font-size: 13px; padding: 12px; }

/* ---------- Series ---------- */
.series-head { position: relative; text-align: center; padding: 24px 16px 10px; background: linear-gradient(180deg, color-mix(in oklab, var(--box) 70%, var(--paper)) 0%, var(--paper) 100%); }
.back { position: absolute; left: 10px; top: 10px; width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--card); font-size: 30px; line-height: 1; box-shadow: var(--shadow); font-family: var(--display); }
.hero { position: relative; width: 230px; height: 250px; margin: 0 auto; }
.hero-box { position: absolute; left: 0; top: 0; width: 170px; perspective: 800px; }
.hero-box .box { width: 100%; height: auto; filter: drop-shadow(0 18px 18px rgba(0, 0, 0, .22)); animation: sway 7s ease-in-out infinite; transform-origin: 50% 90%; }
.hero-fig { position: absolute; right: 0; bottom: 0; }
.hero-fig .fig-sprite { filter: drop-shadow(0 10px 10px rgba(0, 0, 0, .18)); }
@keyframes sway { 0%, 100% { transform: rotateY(-14deg) rotateZ(-1deg); } 50% { transform: rotateY(14deg) rotateZ(1deg); } }
.series-head h1 { font-size: 30px; margin-top: 14px; }
.tagline { margin: 2px 0 0; font-family: var(--hand); font-size: 21px; color: var(--ink-2); }
.homage { margin: 6px auto 0; max-width: 40ch; font-size: 13px; color: var(--ink-2); }
.series-meta { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin: 10px 0 0; font-size: 13px; font-weight: 700; }
.series-meta span { background: var(--card); padding: 4px 10px; border-radius: 999px; box-shadow: var(--shadow); }
.tabs { display: flex; gap: 6px; padding: 10px 16px; position: sticky; top: 0; background: var(--paper); z-index: 5; }
.tabs button { flex: 1; border: 0; background: var(--paper-2); border-radius: 12px; padding: 10px; font-family: var(--display); font-weight: 600; font-size: 15px; color: var(--ink-2); }
.tabs button[aria-selected="true"] { background: var(--ink); color: var(--paper); }
.tabs button:disabled { opacity: .4; }
.tab-body { padding: 6px 16px 20px; }

.lineup-note, .carton-note, .swap-note { font-size: 14px; color: var(--ink-2); margin: 6px 0 12px; }
.carton-note span { display: inline-block; background: var(--tag); color: var(--tag-ink); padding: 1px 8px; border-radius: 6px; font-weight: 700; margin-left: 4px; }
.lineup-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.lineup-card { background: var(--card); border-radius: 14px; padding: 10px 6px 8px; display: grid; justify-items: center; gap: 4px; box-shadow: var(--shadow); position: relative; }
.lineup-card.is-owned { cursor: pointer; }
.lineup-card.rarity-secret.is-owned { background: linear-gradient(160deg, var(--card), color-mix(in oklab, var(--tag) 35%, var(--card))); }
.lineup-name { font-family: var(--display); font-weight: 600; font-size: 13px; text-align: center; line-height: 1.1; }
.is-missing .lineup-name { color: var(--ink-2); }
.stars { color: #E0A82E; font-size: 12px; letter-spacing: .1em; }

.tray { display: grid; grid-template-columns: repeat(var(--cols, 4), 1fr); gap: 8px; background: var(--wood); padding: 12px; border-radius: 14px; box-shadow: inset 0 0 0 6px var(--wood-dark), var(--shadow); }
.slot { border: 0; background: transparent; padding: 0; position: relative; border-radius: 10px; transition: transform .15s; }
.slot .sealed { display: block; position: relative; width: 100%; transform: rotate(var(--tilt)); filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .25)); transition: transform .15s, filter .15s; }
.slot .sealed .box { width: 100%; height: auto; display: block; }
.slot .seal-q { position: absolute; left: 50%; top: 44%; width: 34%; aspect-ratio: 1; margin-left: -17%; border-radius: 50%; background: var(--tag); color: var(--tag-ink); display: grid; place-items: center; font-style: normal; font-family: var(--display); font-weight: 700; font-size: clamp(12px, 3.2vw, 18px); box-shadow: 0 2px 4px rgba(0, 0, 0, .3), inset 0 0 0 2px #fff8; transform: rotate(-8deg); }
.slot.is-picked .sealed { transform: translateY(-10px) scale(1.1) rotate(var(--tilt)); filter: drop-shadow(0 12px 10px rgba(0, 0, 0, .35)); }
.slot.is-open .sealed { filter: grayscale(1) opacity(.4); }
.slot.is-open .seal-q { background: var(--jade); color: #fff; }
.slot.is-wait { opacity: .55; }
.slot.is-shaking .sealed { animation: shake .45s ease-in-out; }
@keyframes shake { 0%, 100% { transform: translateY(-10px) scale(1.1) rotate(0); } 20% { transform: translateY(-10px) scale(1.1) rotate(-9deg); } 40% { transform: translateY(-10px) scale(1.1) rotate(9deg); } 60% { transform: translateY(-10px) scale(1.1) rotate(-6deg); } 80% { transform: translateY(-10px) scale(1.1) rotate(6deg); } }
.slot-n { position: absolute; top: 2px; left: 4px; font-style: normal; font-family: var(--display); font-weight: 700; font-size: 12px; background: var(--card); border-radius: 6px; padding: 0 5px; }
.carton-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; margin-top: 14px; }

.swap-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
.swap-card { background: var(--card); border-radius: 14px; padding: 10px 6px; display: grid; justify-items: center; gap: 6px; box-shadow: var(--shadow); }
.empty { color: var(--ink-2); text-align: center; padding: 30px 16px; }

/* ---------- Figures ---------- */
.fig { --size: 72px; position: relative; width: var(--size); display: grid; justify-items: center; align-items: end; }
.fig-body { position: relative; width: var(--size); height: var(--size); display: grid; place-items: end center; z-index: 1; }
.fig-sprite { width: 112%; max-width: none; height: auto; margin-bottom: -6%; user-select: none; -webkit-user-drag: none; }
.fig .base { width: 80%; height: calc(var(--size) * .16); border-radius: 50%; margin-top: calc(var(--size) * -.06); background: radial-gradient(ellipse at 50% 30%, #fff9, transparent 60%), var(--accent, #d8d2c4); box-shadow: 0 2px 0 rgba(0, 0, 0, .1), 0 6px 10px -4px rgba(0, 0, 0, .25); }
.fig-sprite.is-replaced, .fig.is-replaced { display: none; }
.turntable { display: block; touch-action: none; cursor: grab; filter: drop-shadow(0 18px 18px rgba(0, 0, 0, .18)); }
.turntable:active { cursor: grabbing; }
.rarity-rare .base { --accent: #F0C66A; }
.rarity-secret .base { --accent: #B48CF2; box-shadow: 0 0 0 2px #fff6, 0 0 18px 2px #B48CF2aa, 0 3px 0 rgba(0, 0, 0, .12); }
.count { position: absolute; right: -4px; top: -2px; background: var(--ink); color: var(--paper); font-weight: 800; font-size: 11px; padding: 1px 6px; border-radius: 999px; z-index: 2; }
.fig.is-idle .fig-sprite { animation: bob 3.4s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-4%) rotate(1deg); } }
.is-silhouette .fig-sprite { filter: brightness(0) opacity(.18); }
.is-silhouette .base { background: var(--paper-2); box-shadow: none; }
.is-hidden .fig-sprite { filter: brightness(0) opacity(.5) blur(3px); }
.fx-glow .fig-sprite { filter: drop-shadow(0 0 12px #FFE28A); }
/* keyring */
.form-keyring .fig-body { padding-top: 14px; }
.form-keyring .ring { position: absolute; top: -2px; left: 50%; width: 22px; height: 22px; margin-left: -11px; border: 3px solid #C9A227; border-radius: 50%; box-shadow: inset 0 0 0 1px #fff8; z-index: 2; }
.form-keyring .ring::after { content: ""; position: absolute; left: 50%; top: 100%; width: 3px; height: 8px; margin-left: -1.5px; background: #C9A227; }
.form-keyring .fig-sprite { width: 90%; }
/* enamel pin */
.form-pin .fig-body { place-items: center; isolation: isolate; }
.form-pin .enamel { position: absolute; inset: 6%; border-radius: 50%; background: var(--enamel, #333); box-shadow: inset 0 0 0 4px #C9A227, inset 0 0 0 6px #fff6, 0 4px 8px -2px rgba(0, 0, 0, .4); }
.form-pin .fig-sprite { position: relative; width: calc(58% * var(--scale)); mix-blend-mode: screen; filter: none; border-radius: 50%; }
.form-pin.is-silhouette .enamel { background: var(--paper-2); box-shadow: inset 0 0 0 4px var(--line); }
.form-pin.is-silhouette .fig-sprite, .form-pin.is-hidden .fig-sprite { opacity: .25; mix-blend-mode: normal; }

/* ---------- Opening ---------- */
.opening { position: fixed; inset: 0; z-index: 30; background: radial-gradient(ellipse at 50% 30%, color-mix(in oklab, var(--box) 80%, #fff) 0%, color-mix(in oklab, var(--box) 55%, var(--paper)) 70%); display: grid; grid-template-rows: 1fr auto auto auto; overflow: hidden; color: var(--ink); max-width: 600px; margin: 0 auto; padding-bottom: 24px; }
.opening .close { position: absolute; right: 12px; top: calc(12px + env(safe-area-inset-top)); width: 42px; height: 42px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .6); font-size: 18px; z-index: 3; }
.mystery-tag { position: absolute; left: 0; right: 60px; margin: 0; padding: calc(20px + env(safe-area-inset-top)) 16px 0; text-align: center; font-family: var(--display); font-weight: 600; }
.stage { position: relative; display: grid; place-items: center; touch-action: none; user-select: none; outline: none; }
.box-wrap { position: relative; width: min(62vw, 280px); aspect-ratio: 200 / 260; transition: transform .4s; }
.stage.is-revealed .box-wrap { transform: translateY(26%) scale(.75); opacity: .25; }
.box-art { position: absolute; inset: 0; }
.box-art .box { width: 100%; height: 100%; filter: drop-shadow(0 20px 20px rgba(0, 0, 0, .25)); }
/* lid: top slice of the same art, hinged at the back */
.lid { position: absolute; inset: 0; clip-path: inset(0 0 72% 0); transform-origin: 50% 8%; transform: rotateX(calc(var(--p, 0) * -110deg)); transition: transform .05s linear; backface-visibility: hidden; pointer-events: none; }
.lid .box { width: 100%; height: 100%; }
.stage:not([data-step="lift"]):not(.done-lift):not([data-step="unfold"]):not(.done-unfold) .lid { display: none; }
.stage[data-step="lift"] .box-art, .stage.done-lift .box-art, .stage[data-step="unfold"] .box-art, .stage.done-unfold .box-art { clip-path: inset(26% 0 0 0); }
.stage.done-lift .lid, .stage.done-unfold .lid { transform: rotateX(-120deg) translateY(-10%); opacity: 0; transition: .35s; }
/* seal sticker */
.seal { position: absolute; left: 50%; top: 24%; width: 46%; height: 11%; margin-left: -23%; background: var(--tag); color: var(--tag-ink); border-radius: 8px; display: grid; place-items: center; font-family: var(--display); font-weight: 700; font-size: 12px; letter-spacing: .12em; box-shadow: 0 2px 4px rgba(0, 0, 0, .25); transform: translate(calc(var(--p, 0) * 70%), calc(var(--p, 0) * -40%)) rotate(calc(var(--p, 0) * 25deg)); opacity: calc(1 - var(--p, 0) * .5); }
.stage:not([data-step="peel"]):not([data-step="unpin"]) .seal { opacity: 0; }
.stage.done-peel .seal, .stage.done-unpin .seal { opacity: 0; }
/* slide / pry / blow / twist: whole box transforms */
.stage[data-step="slide"] .box-art { transform: translateX(calc(var(--p, 0) * 30%)) rotate(calc(var(--p, 0) * 4deg)); }
.stage.done-slide .box-art { transform: translateX(34%) rotate(5deg); opacity: .6; }
.stage[data-step="pry"] .box-art, .stage[data-step="blow"] .box-art { transform: scale(calc(1 + var(--p, 0) * .06)) rotate(calc(var(--p, 0) * -3deg)); }
.stage[data-step="twist"] .box-art { clip-path: inset(50% 0 0 0); }
.capsule-top { position: absolute; inset: 0; display: none; pointer-events: none; }
.stage[data-step="twist"] .capsule-top, .stage.done-twist .capsule-top { display: block; }
.stage[data-step="twist"] .capsule-top::before, .stage.done-twist .capsule-top::before { content: ""; position: absolute; left: 7%; right: 7%; top: 19%; height: 33%; border-radius: 140px 140px 0 0; background: linear-gradient(180deg, #fff, #e8e8e8); box-shadow: inset 0 -6px 0 #ccc; transform-origin: 50% 100%; transform: rotate(calc(var(--p, 0) * 180deg)) translateY(calc(var(--p, 0) * -40%)); opacity: calc(1 - var(--p, 0)); }
/* foil bag */
.bag { position: absolute; left: 14%; right: 14%; top: 14%; bottom: 10%; background: linear-gradient(135deg, #f7f7f7, var(--foil) 40%, #bdbdbd 60%, #f1f1f1); border-radius: 10px 10px 16px 16px; display: grid; place-items: center; box-shadow: 0 10px 20px -8px rgba(0, 0, 0, .4), inset 0 0 0 2px rgba(255, 255, 255, .5); opacity: 0; transform: translateY(20%) scale(.9); transition: .35s; pointer-events: none; }
.bag::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 10px; border-bottom: 1px dashed rgba(0, 0, 0, .25); }
.bag-logo { font-family: var(--display); font-weight: 700; font-size: 14px; letter-spacing: .14em; color: rgba(0, 0, 0, .4); }
.bag-tear { position: absolute; inset: 0; border-radius: inherit; background: var(--paper); clip-path: polygon(0 0, calc(var(--p, 0) * 100%) 0, calc(var(--p, 0) * 100% - 10%) 12%, calc(var(--p, 0) * 100%) 24%, calc(var(--p, 0) * 100% - 8%) 36%, calc(var(--p, 0) * 100%) 48%, calc(var(--p, 0) * 100% - 12%) 60%, calc(var(--p, 0) * 100%) 72%, calc(var(--p, 0) * 100% - 6%) 84%, calc(var(--p, 0) * 100%) 100%, 0 100%); opacity: .9; }
.stage[data-step="bag"] .bag, .stage.done-bag .bag { opacity: 1; transform: none; }
.stage[data-step="bag"] .box-art, .stage.done-bag .box-art { opacity: .5; }
.stage.done-bag .bag { opacity: 0; transform: translateY(30%) scale(.8); }
.figure-slot { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -46%) scale(.2); opacity: 0; transition: transform .6s cubic-bezier(.2, 1.4, .4, 1), opacity .3s; }
.stage.is-revealed .figure-slot { transform: translate(-50%, -50%) scale(1); opacity: 1; }
.prompt { text-align: center; font-family: var(--display); font-weight: 600; font-size: 20px; margin: 0; min-height: 28px; padding: 0 16px; }
.progress { height: 6px; margin: 10px auto 0; width: 160px; background: rgba(0, 0, 0, .12); border-radius: 3px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--ink); transform-origin: left; transform: scaleX(0); transition: transform .05s linear; }
.reveal { background: var(--card); border-radius: 24px 24px 0 0; padding: 18px 20px calc(20px + env(safe-area-inset-bottom)); text-align: center; animation: up .5s cubic-bezier(.2, 1.2, .4, 1); box-shadow: 0 -10px 30px -20px rgba(0, 0, 0, .4); max-height: 55dvh; overflow: auto; }
@keyframes up { from { transform: translateY(100%); } }
.reveal h2 { font-size: 28px; }
.reveal-tag { display: inline-block; margin: 0 0 6px; font-family: var(--display); font-weight: 700; font-size: 12px; letter-spacing: .08em; padding: 3px 10px; border-radius: 6px; background: var(--paper-2); color: var(--ink-2); }
.reveal-tag.is-new.rarity-rare { background: #F0C66A; color: #4A3A00; }
.reveal-tag.is-new.rarity-secret { background: #B48CF2; color: #fff; }
.reveal-tag.is-new.rarity-common { background: var(--jade); color: #fff; }
.reveal-series { margin: 0; color: var(--ink-2); font-weight: 700; font-size: 14px; }
.reveal-line { margin: 10px auto 0; max-width: 34ch; font-size: 17px; }
.reveal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.peek-complete { margin: 10px 0 0; font-family: var(--display); font-weight: 600; color: var(--jade); }
.reveal-memory { text-align: left; margin-top: 12px; }
.reveal-memory summary { font-family: var(--display); font-weight: 600; cursor: pointer; }
.memory { margin: 8px 0 0; }
.memory img { border-radius: 12px; max-height: 40vh; object-fit: cover; width: 100%; }
.memory figcaption, .memory.note { font-family: var(--hand); font-size: 22px; line-height: 1.25; color: var(--ink); margin-top: 6px; }
.memory.note { background: #FFF8C7; color: #3B3000; padding: 14px 16px; border-radius: 4px 14px 14px 14px; transform: rotate(-.6deg); box-shadow: var(--shadow); }

/* ---------- Dialogs ---------- */
dialog.peek { border: 0; border-radius: 22px; padding: 22px 20px; background: var(--card); color: var(--ink); width: min(92vw, 400px); text-align: center; box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .5); }
dialog.peek::backdrop { background: rgba(10, 20, 15, .5); backdrop-filter: blur(4px); }
.peek-body { display: grid; place-items: center; min-height: 170px; }
.peek-name { font-family: var(--display); font-weight: 600; font-size: 24px; margin: 8px 0 0; }
.peek-line { margin: 6px auto 14px; max-width: 32ch; }
.photo-dialog img { border-radius: 12px; max-height: 60vh; margin: 0 auto 10px; }

/* ---------- Shelf ---------- */
.shelf-head, .plain-head { padding: 22px 16px 8px; }
.shelf-head h1, .plain-head h1 { font-size: 30px; }
.plain-head p { margin: 4px 0 0; color: var(--ink-2); }
.shelf-tools { display: flex; gap: 10px; align-items: center; margin-top: 10px; }
.select { flex: 1; display: grid; gap: 2px; font-size: 12px; font-weight: 700; color: var(--ink-2); }
.select select { font: inherit; font-size: 15px; font-weight: 700; color: var(--ink); background: var(--card); border: 0; border-radius: 10px; padding: 8px 10px; box-shadow: var(--shadow); }
.shelf-hint { margin: 0; padding: 0 16px 10px; font-size: 13px; color: var(--ink-2); }
.shelf-board { margin: 0 12px; border-radius: 20px; padding: 18px 12px 6px; background: var(--bd); box-shadow: inset 0 0 0 8px rgba(255, 255, 255, .25), var(--shadow); min-height: 300px; }
.shelf-rowc { margin-bottom: 20px; }
.shelf-rowc h2 { font-size: 15px; color: rgba(0, 0, 0, .55); background: rgba(255, 255, 255, .5); display: inline-block; padding: 2px 10px; border-radius: 999px; margin: 0 0 6px 4px; backdrop-filter: blur(4px); }
.plank { display: flex; gap: 6px; align-items: flex-end; overflow-x: auto; padding: 10px 8px 0; scrollbar-width: none; position: relative;
  border-bottom: 14px solid var(--wood); box-shadow: 0 14px 0 -8px var(--wood-dark), 0 18px 12px -10px rgba(0, 0, 0, .35); border-radius: 0 0 3px 3px; }
.plank::-webkit-scrollbar { display: none; }
.plank .fig { flex: 0 0 auto; cursor: pointer; border-radius: 12px; transition: transform .15s; }
.plank .fig.is-selected { transform: translateY(-8px); outline: 3px solid var(--tag); outline-offset: 4px; }
.plank .gap { flex: 0 0 auto; width: 58px; height: 15px; border-radius: 50%; background: rgba(0, 0, 0, .12); box-shadow: inset 0 2px 4px rgba(0, 0, 0, .15); margin: 0 5px 2px; }
.has-orbit .plank .fig:not(.fx-orbit) { animation: lean 6s ease-in-out infinite; }
@keyframes lean { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-4deg) translateX(3px); } }
.fx-orbit .fig-sprite { animation: spin 14s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.fig.has-ring::after { content: "✦ ✦ ✦ ✦"; position: absolute; left: 50%; bottom: 4px; transform: translateX(-50%); color: #FFE28A; font-size: 12px; letter-spacing: .3em; white-space: nowrap; text-shadow: 0 0 6px #FFD54A; animation: twinkle 2s ease-in-out infinite; }
@keyframes twinkle { 50% { opacity: .4; } }
.fx-glow.rarity-secret .fig-body::before { content: ""; position: absolute; inset: 10% 15% 5%; border-radius: 50%; background: radial-gradient(circle, rgba(255, 226, 138, .55), transparent 70%); animation: twinkle 3s ease-in-out infinite; z-index: -1; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .fx-glow .fig-sprite { filter: drop-shadow(0 0 14px #7FD1FF) drop-shadow(0 0 4px #fff); } }
:root[data-theme="dark"] .fx-glow .fig-sprite { filter: drop-shadow(0 0 14px #7FD1FF) drop-shadow(0 0 4px #fff); }

/* ---------- Album, Settings ---------- */
.album-card { display: grid; grid-template-columns: 84px 1fr; gap: 14px; margin: 0 16px 12px; background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.album-text h2 { font-size: 20px; }
.album-text h2 small { display: block; font-family: var(--body); font-size: 13px; color: var(--ink-2); font-weight: 700; }
.settings section { padding: 10px 16px; }
.settings h2 { font-size: 20px; margin-bottom: 8px; }
.opts { display: grid; gap: 8px; }
.row { display: flex; justify-content: space-between; align-items: center; background: var(--card); padding: 12px 14px; border-radius: 14px; box-shadow: var(--shadow); font-weight: 700; }
.row input { width: 22px; height: 22px; accent-color: var(--jade); }
.seg { display: flex; gap: 4px; background: var(--paper-2); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 6px 10px; border-radius: 8px; font-weight: 700; font-size: 13px; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.stickers { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.sticker { background: var(--card); border-radius: 14px; padding: 10px 6px; display: grid; justify-items: center; gap: 2px; text-align: center; opacity: .4; filter: grayscale(1); box-shadow: var(--shadow); }
.sticker.is-got { opacity: 1; filter: none; transform: rotate(-2deg); }
.sticker img { width: 56px; height: 56px; }
.sticker span { font-family: var(--display); font-weight: 600; font-size: 13px; }
.sticker small { font-size: 11px; color: var(--ink-2); line-height: 1.2; }
.credits { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.credits small { color: var(--ink-2); }
.fine { font-size: 13px; color: var(--ink-2); max-width: 46ch; }
.closed { text-align: center; padding: 30vh 20px; }

/* ---------- Cinematics ---------- */
.cinema { position: fixed; inset: 0; z-index: 40; background: #0B1410; color: #F2F5F1; display: grid; place-items: center; padding: 24px; text-align: center; outline: none; }
.cinema::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 100%; background: repeating-linear-gradient(180deg, #2a3a32 0 22px, #1d2a24 22px 26px); transform: translateY(-100%); transition: transform .9s cubic-bezier(.6, 0, .4, 1); }
.cinema.shutter-up::after { transform: translateY(-100%); }
.cinema.intro::after { transform: translateY(-100%); }
.cinema.shutter-up { animation: fadeout .9s forwards; }
@keyframes fadeout { to { opacity: 0; } }
.cinema-stage { max-width: 520px; width: 100%; }
.cinema-line { font-family: var(--display); font-size: clamp(22px, 5.6vw, 30px); line-height: 1.3; min-height: 3em; margin: 0; opacity: 0; }
.cinema-line.in { animation: fadein .5s forwards; }
@keyframes fadein { to { opacity: 1; } }
.cinema-line em { font-style: normal; font-family: var(--hand); font-size: 1.15em; color: #CFE4D8; }
.who { display: block; font-size: 14px; letter-spacing: .08em; color: var(--c); margin-bottom: 8px; font-weight: 700; }
.who img { display: inline-block; width: 36px; height: 36px; vertical-align: middle; margin-right: 6px; }
.cinema-hint { position: absolute; bottom: calc(24px + env(safe-area-inset-bottom)); left: 0; right: 0; font-size: 13px; color: #8FA89C; animation: twinkle 2s infinite; }
.sign { display: inline-block; font-family: var(--display); font-weight: 700; font-size: clamp(30px, 9vw, 52px); padding: 10px 22px; border: 4px solid #5FBF93; border-radius: 18px; box-shadow: 0 0 30px #5FBF9366, inset 0 0 20px #5FBF9333; color: #fff; }
.sign i { font-style: normal; opacity: 0; animation: lightup .3s forwards; animation-delay: calc(var(--i) * .07s); text-shadow: 0 0 14px #5FBF93; }
@keyframes lightup { 50% { opacity: .3; } 100% { opacity: 1; } }
.cinema-line small { display: block; margin-top: 10px; font-family: var(--hand); font-size: 22px; color: #CFE4D8; }
.launch-kicker { margin: 0; font-weight: 800; letter-spacing: .1em; font-size: 13px; color: #8FA89C; }
.launch-title { font-size: clamp(34px, 9vw, 52px); font-weight: 700; color: var(--tag); margin: 6px 0 10px; text-shadow: 0 4px 0 rgba(0, 0, 0, .4); }
.launch-line { margin: 0 auto; max-width: 38ch; font-size: 17px; color: #D8E4DE; }
.launch-boxes { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 10px 8px; margin: 18px 0 64px; }
.launch-box { min-width: 0; font-family: var(--display); font-size: 11px; line-height: 1.15; font-weight: 600; animation: drop .6s cubic-bezier(.2, 1.4, .4, 1) both; animation-delay: calc(var(--i) * .08s); }
.launch-box .box { width: 100%; height: auto; filter: drop-shadow(0 8px 10px rgba(0, 0, 0, .5)); }
.launch-box span { display: block; margin-top: 4px; color: #D8E4DE; }
@keyframes drop { from { transform: translateY(-60px) rotate(-8deg); opacity: 0; } }

/* ---------- Laptop widths ---------- */
@media (min-width: 700px) {
  body { background: var(--paper-2); }
  #app { background: var(--paper); box-shadow: 0 0 0 1px var(--line); min-height: 100dvh; }
  .shelf-row { padding-inline: 20px; }
  .stack { width: 140px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .hero-box .box, .mystery svg, .fig.is-idle .fig-sprite { animation: none; }
}

/* ---------- Surface and depth ----------
   The 3D shop is lit and textured; the flat UI around it gets the same hand: a paper tooth on the
   page and on cards, and buttons and pills that sit up off the surface with a lit top edge. */
:root {
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .45 0 0 0 0 .4 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='.38'/%3E%3C/svg%3E");
  --lift: 0 1px 0 rgba(255, 255, 255, .55) inset, 0 -2px 0 rgba(0, 0, 0, .10) inset, 0 6px 14px -8px rgba(20, 40, 30, .5), 0 1px 2px rgba(20, 40, 30, .18);
  --lift-dark: 0 1px 0 rgba(255, 255, 255, .25) inset, 0 -2px 0 rgba(0, 0, 0, .22) inset, 0 6px 14px -8px rgba(10, 30, 20, .7), 0 1px 2px rgba(10, 30, 20, .3);
}
body { background-image: var(--grain); background-attachment: fixed; }
.collector, .sheet-body, .dio-sheet, .map-item { background-image: var(--grain); }
.btn, .hud-btn, .hud-aim, .hud-pill, .dio-btn.chip, .mystery, .allowance { box-shadow: var(--lift); }
.btn { background-image: linear-gradient(180deg, rgba(255, 255, 255, .22), rgba(255, 255, 255, 0) 55%, rgba(0, 0, 0, .04)); }
.btn.primary, .hud-map, .tabbar button.is-active { background-image: linear-gradient(180deg, rgba(255, 255, 255, .2), rgba(255, 255, 255, 0) 50%, rgba(0, 0, 0, .1)); }
.btn.primary, .hud-map { box-shadow: var(--lift-dark); }
.btn.ghost, .btn.danger { background-image: none; }
.btn:active, .hud-btn:active, .dio-btn.chip:active { box-shadow: 0 1px 0 rgba(255, 255, 255, .3) inset, 0 2px 4px rgba(0, 0, 0, .18) inset; }
.hud-allow { background-image: linear-gradient(180deg, rgba(255, 255, 255, .35), rgba(255, 255, 255, 0) 60%), var(--grain); }
.tabbar { box-shadow: 0 -1px 0 rgba(255, 255, 255, .5) inset, 0 -8px 20px -16px rgba(0, 0, 0, .35); }
.badge { box-shadow: 0 1px 0 rgba(255, 255, 255, .3) inset, 0 2px 4px -1px rgba(0, 0, 0, .3); }
.collector-face { box-shadow: 0 0 0 3px var(--card), 0 6px 12px -6px rgba(0, 0, 0, .45); }
