/* Pocket: layout, components and motion. Mobile first; desktop reflows the same parts. */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

.motion-off *, .motion-off *::before, .motion-off *::after { animation: none !important; transition: none !important; }

html { background: var(--c-cobalt); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--c-cobalt);
  color: var(--c-white);
  font: 400 var(--fs-body)/1.4 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
img { display: block; }
h1, h2, h3, p, dl, dd { margin: 0; }

.icons { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: 3px solid var(--c-focus); outline-offset: 3px; }
.sheet :focus-visible, .pile :focus-visible { outline-color: var(--c-focus-light); }

/* ---------- App grid (phone) ---------- */
.app {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto minmax(360px, 1fr) auto auto auto;
  grid-template-areas: "bar" "boosters" "stage" "pile" "actions" "tabs";
  overflow-x: hidden;
  overflow-x: clip;
}

/* ---------- Top bar ---------- */
.bar {
  grid-area: bar;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: var(--bar-h);
  padding: max(4px, env(safe-area-inset-top)) calc(var(--gutter) - 6px) 0 var(--gutter);
}
.brand {
  margin-right: auto;
  font: var(--w-title) 23px/1 var(--font-display);
  letter-spacing: -.035em;
}
.tools { display: flex; align-items: center; gap: 2px; }
.tool {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-width: var(--hit); height: var(--hit); padding: 0 12px;
  border: 0; border-radius: var(--r-pill);
  background: transparent; color: var(--c-white);
  font-size: var(--fs-small); font-weight: 600;
  cursor: pointer;
}
.tool svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.tool[aria-pressed="true"] { background: var(--c-veil); }
.tool[aria-pressed="false"] { color: var(--c-muted); }
.tool[aria-pressed="true"] .slash { display: none; }
.tool-label { display: none; }
.variants-link {
  display: inline-flex; align-items: center; min-height: var(--hit);
  padding: 0 6px 0 10px;
  color: var(--c-muted); font-size: 13px; font-weight: 600;
  text-decoration: underline; text-decoration-color: rgb(199 208 255 / .45); text-underline-offset: 3px;
  border-radius: 8px; white-space: nowrap;
}
.variants-link:hover { color: var(--c-white); }

/* ---------- Booster chips ---------- */
.boosters { grid-area: boosters; min-width: 0; }
.side-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.chips {
  display: flex; gap: 8px;
  overflow-x: auto; overscroll-behavior-x: contain;
  padding: 6px var(--gutter) 8px;
  scroll-padding-inline: var(--gutter);
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  position: relative;
  flex: none;
  display: inline-flex; align-items: center; gap: 9px;
  height: var(--hit); padding: 0 16px 0 14px;
  border: 0; border-radius: var(--r-pill);
  background: var(--c-veil); color: var(--c-white);
  font-size: 15px; font-weight: 650;
  scroll-snap-align: start;
  cursor: pointer;
  transition: background-color .2s, color .2s;
}
.chip:hover { background: var(--c-veil-strong); }
.chip-swatch { width: 14px; height: 14px; border-radius: 50%; background: var(--swatch); box-shadow: 0 0 0 2px rgb(255 255 255 / .85); flex: none; }
.chip-text { display: flex; flex-direction: column; min-width: 0; }
.chip-name { white-space: nowrap; }
.chip-number { display: none; }
.chip-progress { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--c-muted); }
.chip[aria-current="true"] { background: var(--c-white); color: var(--c-ink); }
.chip[aria-current="true"] .chip-progress { color: var(--c-ink-soft); }
.chip[data-state="done"] .chip-progress { color: inherit; }
.chip:focus-visible { outline-offset: 2px; }

/* ---------- Stage ---------- */
.stage-wrap { grid-area: stage; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  place-items: center;
  container-type: size;
  --card-h: min(100cqh - 36px, (100cqw - 96px) * 1.4, var(--card-max-h));
  --card-w: calc(var(--card-h) / 1.4);
}
.stage > * { grid-area: 1 / 1; }
.hint {
  min-height: 22px;
  padding: 0 var(--gutter) 2px;
  text-align: center;
  color: var(--c-muted);
  font-size: var(--fs-small);
  font-weight: 550;
}

.burst { position: absolute; left: 50%; top: 50%; translate: -50% -50%; pointer-events: none; border-radius: 50%; }
.burst { width: calc(var(--card-w) * 2.4); aspect-ratio: 1; opacity: 0; }
.burst.is-legendary {
  background: repeating-conic-gradient(from 4deg, var(--glow, #ffd166) 0 7deg, rgb(255 255 255 / 0) 7deg 20deg);
  -webkit-mask: radial-gradient(closest-side, #000 22%, rgb(0 0 0 / 0) 100%);
  mask: radial-gradient(closest-side, #000 22%, rgb(0 0 0 / 0) 100%);
  animation: burst 1.25s var(--ease-out) both;
}
.burst.is-rare {
  background: radial-gradient(closest-side, rgb(255 255 255 / 0) 62%, var(--glow, #9acff0) 64% 71%, rgb(255 255 255 / 0) 73%);
  animation: ring .8s var(--ease-out) both;
}
@keyframes burst {
  0% { opacity: 0; transform: scale(.35) rotate(0deg); }
  14% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.18) rotate(38deg); }
}
@keyframes ring {
  0% { opacity: .9; transform: scale(.45); }
  100% { opacity: 0; transform: scale(1.05); }
}

/* ---------- Pack ---------- */
.pack {
  --booster: #eb51d5;
  --booster-dark: color-mix(in srgb, var(--booster) 78%, var(--c-ink));
  --strip-h: 46px;
  --tooth: 7px;
  position: relative;
  width: calc(var(--card-w) + 22px);
  height: calc(var(--card-h) + 26px);
  container-type: inline-size;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}
.pack.is-held { cursor: grabbing; }
.pack-strip, .pack-body { position: absolute; left: 0; right: 0; }
.pack-strip {
  top: 0;
  height: var(--strip-h);
  border-radius: var(--r-pack) var(--r-pack) 0 0;
  background:
    repeating-linear-gradient(90deg, rgb(255 255 255 / .16) 0 2px, rgb(255 255 255 / 0) 2px 6px) 0 0 / 100% 16px no-repeat,
    var(--booster-dark);
  transform-origin: 0% 100%;
  -webkit-mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 0 0 / calc(var(--tooth) * 2) 100%;
  mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 0 0 / calc(var(--tooth) * 2) 100%;
  z-index: 2;
}
.pack-tab {
  position: absolute; right: 14px; top: 8px;
  width: 30px; height: 22px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--c-white);
  color: var(--c-ink);
}
.pack-tab svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.pack-body {
  top: calc(var(--strip-h) - var(--tooth));
  bottom: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: 16px 18px 42px;
  border-radius: 0 0 var(--r-pack) var(--r-pack);
  background:
    repeating-linear-gradient(90deg, rgb(255 255 255 / .16) 0 2px, rgb(255 255 255 / 0) 2px 6px) 0 100% / 100% 20px no-repeat,
    var(--booster);
  -webkit-mask: conic-gradient(from 135deg at top, #0000, #000 1deg 89deg, #0000 90deg) var(--tooth) 0 / calc(var(--tooth) * 2) 100%;
  mask: conic-gradient(from 135deg at top, #0000, #000 1deg 89deg, #0000 90deg) var(--tooth) 0 / calc(var(--tooth) * 2) 100%;
  box-shadow: var(--shadow-card);
}
.pack-brand {
  flex: 1;
  display: grid; place-items: center;
  font: var(--w-title) 21cqw/1 var(--font-display);
  letter-spacing: -.05em;
  color: var(--c-white);
  rotate: -8deg;
}
.pack-label {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  width: 100%;
  padding: 16px 14px;
  border-radius: 16px;
  background: var(--c-white);
  color: var(--c-ink);
  text-align: center;
}
.pack-name { font: var(--w-title) 22px/1.1 var(--font-display); letter-spacing: -.02em; }
.pack-meta { color: var(--c-ink-soft); font-size: 13.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
/* A soft floor under the pack and the stack */
.pack::after, .stack::after {
  content: "";
  position: absolute; left: 12%; right: 12%; bottom: -18px; height: 22px;
  border-radius: 50%;
  background: rgb(var(--shadow-rgb) / .35);
  filter: blur(8px);
  z-index: -1;
}

/* ---------- Stack and cards ---------- */
.stack {
  position: relative;
  width: var(--card-w);
  height: var(--card-h);
  translate: 0 calc(var(--edge) * -1);
  --lift: 0;
}
.stack.is-shaking { animation: shake .46s linear; }
@keyframes shake {
  0% { transform: none; }
  14% { transform: translate(-10px, 3px) rotate(-1.4deg); }
  30% { transform: translate(9px, -2px) rotate(1.1deg); }
  46% { transform: translate(-6px, 1px) rotate(-.7deg); }
  62% { transform: translate(4px, 0) rotate(.4deg); }
  80% { transform: translate(-2px, 0); }
  100% { transform: none; }
}

.card {
  --depth: 0;
  --d: max(0, var(--depth) - var(--lift, 0));
  position: absolute;
  inset: 0;
  z-index: calc(10 - var(--depth));
  container-type: inline-size;
  perspective: 1500px;
  transform-origin: 50% 100%;
  transform: translateY(calc(var(--d) * var(--edge))) scale(calc(1 - var(--d) * .045));
  transition: transform .55s var(--ease-spring);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.card[data-depth="0"] { cursor: grab; }
.card.is-live, .stack.is-dragging .card { transition: none; }
.card.is-held { cursor: grabbing; }
.card.is-emerging { animation: emerge .7s var(--ease-spring) both; animation-delay: calc(var(--depth) * 45ms + 60ms); }
@keyframes emerge {
  0% { transform: translateY(2%) scale(.94); }
  45% { transform: translateY(-24%) scale(1); }
}
.card-body {
  position: absolute; inset: 0;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
}
.face {
  position: absolute; inset: 0;
  border-radius: var(--r-card);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.card.is-held .face, .fx .card .face { box-shadow: var(--shadow-lift); }
.card .back {
  --leak: 0 0 0 calc(var(--peek, 0) * 5px) var(--glow, transparent), 0 0 calc(var(--peek, 0) * 64px) calc(var(--peek, 0) * 16px) var(--glow, transparent);
  box-shadow: var(--leak), var(--shadow-card);
  transition: box-shadow .35s var(--ease-out);
}
.card.is-held .back {
  box-shadow: var(--leak), var(--shadow-lift);
  transition: none;
}
.back {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4cqw;
  border: 4cqw solid var(--c-white);
  background:
    radial-gradient(circle, rgb(255 255 255 / .16) 0 1.6px, rgb(255 255 255 / 0) 2.2px) 0 0 / 14px 14px,
    var(--c-cobalt-night);
}
.back-mark {
  display: grid; place-items: center;
  width: 30cqw; aspect-ratio: 1;
  border-radius: 50%;
  background: var(--c-white);
  color: var(--c-cobalt);
  font: var(--w-title) 21cqw/1 var(--font-display);
  padding-bottom: 2cqw;
}
.back-word { font: var(--w-title) 7cqw/1 var(--font-display); letter-spacing: -.03em; color: var(--c-white); }
.card-body > .front { transform: rotateX(180deg); }

/* Card front: the rarity color is the frame. Used in stack, sheet and dock. */
.front {
  position: absolute; inset: 0;
  container-type: inline-size;
  padding: 3.4cqw;
  border-radius: var(--r-card);
  background: var(--rarity, #c8c6df);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: var(--shadow-card);
}
.front-inner {
  display: flex; flex-direction: column;
  height: 100%;
  padding: 3.4cqw 3.4cqw 4cqw;
  border-radius: calc(var(--r-card) - 5px);
  background: var(--c-white);
  color: var(--c-ink);
}
.front-art {
  flex: 1 1 auto;
  min-height: 0;
  margin-bottom: 4cqw;
  border-radius: calc(var(--r-card) - 10px);
  overflow: hidden;
  background: color-mix(in srgb, var(--rarity, #c8c6df) 22%, white);
}
.front-art img, .thumb-art img, .tile-art img { width: 100%; height: 100%; object-fit: cover; }
.front-rarity {
  align-self: flex-start;
  padding: .6cqw 3cqw;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--rarity, #c8c6df) 45%, white);
  font-size: max(11px, 4.4cqw); font-weight: 750;
}
.front-name { margin-top: 1.8cqw; font: var(--w-title) max(14px, 8.4cqw)/1.08 var(--font-display); letter-spacing: -.02em; }
.front-desc { margin-top: 1.6cqw; font-size: max(11px, 4.8cqw); line-height: 1.3; color: var(--c-ink-soft); }
.front-serial { margin-top: auto; padding-top: 2cqw; align-self: flex-end; font-size: max(10.5px, 4cqw); font-weight: 650; color: var(--c-ink-soft); font-variant-numeric: tabular-nums; }

/* The docked preview is a framed picture; the text sits beside it */
.dock .front-rarity, .dock .front-name, .dock .front-desc, .dock .front-serial { display: none; }
.dock .front-art { margin-bottom: 0; }
@container (max-width: 200px) {
  .front-desc { display: none; }
}

/* Art direction per image (ids from mock data) */
[data-card="0"] img { object-fit: contain; padding: 9%; background: var(--c-white); }
[data-card="1"] .front-art { background: #888e72; }
[data-card="1"] .front-art img { object-fit: contain; }
[data-card="1"] .thumb-art img, [data-card="1"] .tile-art img { object-position: 50% 30%; }
[data-card="2"] img { object-position: 42% 18%; }
[data-card="2"] .front-art img { object-position: 50% 25%; }

/* Effects layer: flung cards and torn wrappers fly above everything */
.fx { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.fx > * { position: absolute; margin: 0; }
.fx .card { transition: none; }
.fx .pack::after { display: none; }

/* ---------- Done: the pile laid out ---------- */
.done {
  width: min(100%, 720px);
  align-self: center;
  display: flex; flex-direction: column; align-items: center;
  padding: 0 var(--gutter);
  text-align: center;
}
.done-title { font: var(--w-title) var(--fs-display)/1.12 var(--font-display); letter-spacing: -.025em; max-width: 18ch; text-wrap: balance; }
.done-line { margin-top: 8px; color: var(--c-muted); font-size: var(--fs-lead); font-weight: 550; }
.done-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  width: 100%;
  max-width: min(100%, calc((100cqh - 150px) / 1.62 * 3 + 24px));
  margin-top: 22px;
}
.tile {
  display: flex; flex-direction: column; align-items: stretch; gap: 2px;
  min-width: 0;
  padding: 0; border: 0; background: none;
  color: var(--c-white); text-align: left;
  cursor: pointer;
  border-radius: 14px;
}
.tile-art {
  display: block;
  aspect-ratio: 5 / 7;
  margin-bottom: 8px;
  padding: 5px;
  border-radius: 16px;
  background: var(--rarity);
  box-shadow: var(--shadow-card);
  transition: transform .3s var(--ease-spring);
}
.tile-art img { border-radius: 11px; background: var(--c-white); }
.tile:hover .tile-art { transform: translateY(-4px) rotate(-1deg); }
.tile-name { font-weight: 750; font-size: 15px; line-height: 1.2; }
.tile-rarity { color: var(--c-muted); font-size: 13px; font-weight: 600; }

/* ---------- Pile ---------- */
.pile {
  grid-area: pile;
  display: flex; align-items: center; gap: 14px;
  min-width: 0;
  min-height: 84px;
  padding: 6px var(--gutter) 4px;
}
.pile-list { display: flex; align-items: center; padding-left: 6px; min-height: 72px; }
.slot {
  flex: none;
  width: 52px; height: 72px;
  margin-left: -10px;
  border-radius: 12px;
  border: 2px dashed rgb(199 208 255 / .5);
  scale: .8;
}
.thumb {
  position: relative;
  width: 52px; height: 72px;
  margin-left: -10px;
  padding: 3px;
  border: 0;
  border-radius: 12px;
  background: var(--rarity);
  box-shadow: 0 8px 16px -8px rgb(var(--shadow-rgb) / .9);
  rotate: var(--tilt, 0deg);
  cursor: pointer;
  transition: rotate .3s var(--ease-spring), translate .3s var(--ease-spring);
}
.pile-list > :first-child { margin-left: 0; }
.pile-list > :nth-child(1) { --tilt: -5deg; }
.pile-list > :nth-child(2) { --tilt: 3deg; }
.pile-list > :nth-child(3) { --tilt: -2deg; }
.thumb:hover { translate: 0 -4px; rotate: 0deg; z-index: 2; }
.thumb:focus-visible { z-index: 3; outline-color: var(--c-focus); }
.thumb[aria-pressed="true"] { translate: 0 -4px; }
.thumb-art { display: block; width: 100%; height: 100%; border-radius: 9px; overflow: hidden; background: var(--c-white); }
.thumb.is-new { animation: land .5s var(--ease-spring) both; }
@keyframes land {
  0% { transform: translateX(calc(var(--from, 1) * 90px)) scale(.55) rotate(calc(var(--from, 1) * 22deg)); opacity: 0; }
  40% { opacity: 1; }
  100% { transform: none; }
}
.pile-head { min-width: 0; }
.pile-title { font-size: var(--fs-body); font-weight: 750; }
.pile-count { color: var(--c-muted); font-size: var(--fs-small); font-weight: 550; }
.dock { display: none; }
.app[data-phase="done"] .pile { display: none; }

/* ---------- Thumb zone ---------- */
.actions {
  grid-area: actions;
  display: flex; flex-direction: column; align-items: center;
  padding: 4px var(--gutter) 2px;
}
.pill {
  width: 100%;
  min-height: var(--pill-h);
  padding: 8px 24px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--c-sun);
  color: var(--c-ink);
  font: var(--w-title) 19px/1.15 var(--font-display);
  letter-spacing: -.01em;
  box-shadow: var(--shadow-pill);
  cursor: pointer;
  transition: transform .18s var(--ease-spring), background-color .15s;
}
.pill:hover { background: #ffdb5c; }
.pill:active { transform: scale(.965); background: var(--c-sun-press); }
.pill:focus-visible { outline-offset: 4px; }
.secondary {
  min-height: var(--hit);
  padding: 0 22px;
  border: 0; border-radius: var(--r-pill);
  background: none;
  color: var(--c-white);
  font-size: 15px; font-weight: 650;
  cursor: pointer;
}
.secondary:hover { background: var(--c-veil); }
.keys { display: none; }

/* ---------- Tab bar ---------- */
.tabs {
  grid-area: tabs;
  position: sticky; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  margin-top: 6px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  border-radius: 24px 24px 0 0;
  background: var(--c-white);
  box-shadow: var(--shadow-sheet);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 52px;
  border: 0; border-radius: 16px;
  background: none;
  color: var(--c-ink-soft);
  font-size: 12px; font-weight: 650;
  cursor: pointer;
}
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-current="page"] { color: var(--c-cobalt); }
.tab[aria-current="page"] svg { fill: color-mix(in srgb, var(--c-cobalt) 16%, transparent); }
.tab:hover { background: var(--c-mist); }
.tab:focus-visible { outline-color: var(--c-focus-light); outline-offset: -2px; }

/* ---------- Details (sheet on phone, dock on desktop) ---------- */
.detail { color: var(--c-ink); }
.detail-card { position: relative; width: min(64vw, 250px, 34dvh); aspect-ratio: 5 / 7; margin: 0 auto; container-type: inline-size; }
.detail-text { margin-top: 18px; }
.detail-rarity { display: inline-block; padding: 2px 10px; border-radius: var(--r-pill); background: color-mix(in srgb, var(--rarity) 45%, white); font-size: 13px; font-weight: 750; }
.detail-name { margin-top: 6px; font: var(--w-title) 26px/1.1 var(--font-display); letter-spacing: -.02em; }
.detail-desc { margin-top: 6px; font-size: var(--fs-lead); color: var(--c-ink-soft); }
.detail-meta { display: flex; gap: 28px; margin-top: 14px; }
.detail-meta dt { font-size: 13px; color: var(--c-ink-soft); }
.detail-meta dd { font-weight: 700; font-variant-numeric: tabular-nums; }
.gift {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%;
  min-height: 52px;
  margin-top: 18px;
  border: 0; border-radius: var(--r-pill);
  background: var(--c-lilac);
  color: var(--c-ink);
  font-weight: 750; font-size: var(--fs-body);
  cursor: pointer;
}
.gift:hover { background: #bdb5ff; }
.gift svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linejoin: round; }

.sheet .detail-card { width: min(70vw, 290px, 44dvh); }
.sheet .detail-rarity, .sheet .detail-name, .sheet .detail-desc {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.sheet .detail-meta { justify-content: center; margin-top: 0; text-align: center; }
.sheet .detail-text { margin-top: 20px; }

/* Bottom sheet */
.sheet {
  position: fixed;
  inset: auto 0 0 0;
  width: min(100%, 560px);
  max-width: 100%;
  max-height: 94dvh;
  margin: 0 auto;
  padding: 0;
  border: 0;
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  background: var(--c-white);
  color: var(--c-ink);
  box-shadow: var(--shadow-sheet);
  overflow: auto;
  overscroll-behavior: contain;
  transform: translateY(100%);
  transition: transform .46s cubic-bezier(.22, 1.18, .36, 1);
}
.sheet.is-open { transform: translateY(var(--sheet-y, 0px)); }
.sheet.is-held { transition: none; }
.sheet::backdrop { background: var(--c-backdrop); }
.sheet-inner { position: relative; padding: 0 22px calc(22px + env(safe-area-inset-bottom)); }
.sheet-grip {
  display: grid; place-items: center;
  height: 34px;
  margin: 0 -22px 4px;
  touch-action: none;
  cursor: grab;
}
.grip-bar { width: 44px; height: 5px; border-radius: 3px; background: #d4d8f2; }
.sheet-close {
  position: absolute; top: 8px; right: 10px;
  width: var(--hit); height: var(--hit);
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: var(--c-mist);
  color: var(--c-ink);
  cursor: pointer;
  z-index: 2;
}
.sheet-close svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }

/* Toast from the shared kit */
.toast {
  position: fixed; z-index: 80;
  left: 50%; top: calc(var(--bar-h) + 10px);
  transform: translateX(-50%);
  width: max-content; max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border-radius: 18px;
  background: var(--c-ink);
  color: var(--c-white);
  font-size: var(--fs-small); font-weight: 600;
  box-shadow: var(--shadow-pill);
  animation: toast-in .35s var(--ease-spring);
}
@keyframes toast-in { from { transform: translate(-50%, -12px) scale(.96); opacity: 0; } }

/* ---------- Short phones: keep the thumb zone on screen ---------- */
@media (max-width: 959px) and (max-height: 740px) {
  .app { grid-template-rows: auto auto minmax(250px, 1fr) auto auto auto; }
  .hint { display: none; }
  .chips { padding-bottom: 4px; }
  .pile { min-height: 76px; padding-block: 2px; }
}

/* ---------- Tablet ---------- */
@media (min-width: 600px) {
  :root { --gutter: 28px; }
  .actions { width: min(100%, 460px); justify-self: center; }
  .pile { justify-content: center; }
}

/* ---------- Desktop: same parts, three columns ---------- */
@media (min-width: 960px) {
  :root { --card-max-h: 520px; --gutter: 24px; }
  .app {
    height: 100vh; height: 100dvh;
    min-height: 680px;
    grid-template-columns: minmax(250px, 300px) minmax(0, 1fr) minmax(330px, 380px);
    grid-template-rows: 72px minmax(0, 1fr) auto;
    grid-template-areas:
      "bar bar bar"
      "boosters stage pile"
      "boosters actions pile";
    column-gap: 8px;
  }
  .bar { padding: 0 20px 0 28px; }
  .brand { font-size: 26px; }
  .tool-label { display: inline; }
  .tool { padding: 0 16px 0 12px; }

  .tabs {
    grid-area: bar;
    justify-self: center; align-self: center;
    position: static;
    display: flex; gap: 4px;
    margin: 0; padding: 4px;
    border-radius: var(--r-pill);
    background: var(--c-veil);
    box-shadow: none;
  }
  .tab { flex-direction: row; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: var(--r-pill); color: var(--c-white); font-size: 14px; }
  .tab svg { width: 20px; height: 20px; }
  .tab[aria-current="page"] { background: var(--c-white); color: var(--c-cobalt); }
  .tab:not([aria-current]):hover { background: var(--c-veil); }
  .tab:focus-visible { outline-color: var(--c-focus); outline-offset: 2px; }

  .boosters { padding: 18px 0 24px 24px; }
  .side-title { position: static; width: auto; height: auto; overflow: visible; clip: auto; margin: 0 0 12px 4px; font-size: var(--fs-lead); font-weight: 750; }
  .chips { flex-direction: column; gap: 10px; overflow: visible; padding: 0; }
  .chip { height: auto; min-height: 76px; padding: 12px 18px 12px 14px; gap: 14px; border-radius: 22px; text-align: left; }
  .chip-swatch {
    width: 34px; height: 46px; border-radius: 8px;
    box-shadow: none;
    background:
      repeating-linear-gradient(90deg, rgb(255 255 255 / .2) 0 2px, rgb(255 255 255 / 0) 2px 5px) 0 0 / 100% 7px no-repeat,
      repeating-linear-gradient(90deg, rgb(255 255 255 / .2) 0 2px, rgb(255 255 255 / 0) 2px 5px) 0 100% / 100% 7px no-repeat,
      var(--swatch);
  }
  .chip-text { flex: 1; }
  .chip-name { font-size: var(--fs-body); font-weight: 750; white-space: normal; }
  .chip-number { display: block; font-size: 13px; font-weight: 550; color: var(--c-muted); font-variant-numeric: tabular-nums; }
  .chip[aria-current="true"] .chip-number { color: var(--c-ink-soft); }
  .chip-progress { font-size: 15px; }

  .stage-wrap { padding-top: 8px; }
  .hint { padding-bottom: 6px; font-size: 15px; }

  .actions { width: min(100%, 440px); justify-self: center; padding: 6px 0 26px; }
  .keys {
    display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px;
    margin-top: 6px;
    color: var(--c-muted); font-size: 13px; font-weight: 550;
  }
  .keys span { display: inline-flex; align-items: center; gap: 6px; }
  .keys kbd {
    min-width: 26px; padding: 2px 7px;
    border-radius: 7px;
    background: var(--c-veil);
    color: var(--c-white);
    font: 650 12px/1.4 var(--font-ui);
    text-align: center;
  }

  .pile {
    display: flex; flex-direction: column; align-items: stretch; gap: 0;
    margin: 12px 24px 24px 0;
    padding: 20px 22px 22px;
    border-radius: var(--r-panel);
    background: var(--c-white);
    color: var(--c-ink);
    overflow: auto;
    min-height: 0;
    max-height: calc(100% - 36px);
    align-self: start;
    justify-content: flex-start;
  }
  .app[data-phase="done"] .pile { display: flex; }
  .pile-head { order: -1; display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
  .pile-title { font-size: var(--fs-lead); }
  .pile-count { color: var(--c-ink-soft); }
  .pile-list {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
    padding: 0; min-height: 0;
  }
  .thumb { width: auto; height: auto; aspect-ratio: 5 / 7; margin: 0; padding: 4px; border-radius: 14px; rotate: 0deg; box-shadow: var(--shadow-card); }
  .pile-list > :nth-child(n) { --tilt: 0deg; }
  .thumb-art { border-radius: 10px; }
  .thumb[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--c-white), 0 0 0 6px var(--c-cobalt); translate: none; }
  .thumb:focus-visible { outline-color: var(--c-focus-light); outline-offset: 8px; }
  .slot { width: auto; height: auto; aspect-ratio: 5 / 7; margin: 0; border-radius: 14px; border-color: #cfd5f6; scale: none; }
  .dock { display: block; margin-top: 20px; padding-top: 18px; border-top: 2px solid var(--c-mist); }
  .dock-empty { color: var(--c-ink-soft); font-size: 15px; }
  .dock .detail { display: grid; grid-template-columns: 136px 1fr; gap: 18px; align-items: start; }
  .dock .detail-card { width: 100%; margin: 0; }
  .dock .detail-text { margin-top: 0; }
  .dock .detail-name { font-size: 21px; }
  .dock .detail-desc { font-size: 15px; }
  .dock .detail-meta { flex-direction: column; gap: 2px; margin-top: 10px; }
  .dock .detail-meta div { display: flex; gap: 10px; align-items: baseline; }
  .dock .detail-meta dt { min-width: 44px; }
  .dock .gift { margin-top: 14px; min-height: 48px; }

  .done-grid { gap: 20px; margin-top: 28px; }
  .tile-name { font-size: 17px; }
  .tile-rarity { font-size: 14px; }
  .done-title { font-size: 34px; }
}

@media (min-width: 960px) and (max-width: 1279px) {
  .tool-label { display: none; }
  .tool { padding: 0 12px; }
  .keys { min-height: 48px; align-content: flex-start; }
}

@media (min-width: 960px) and (max-height: 760px) {
  .dock .detail { grid-template-columns: 96px 1fr; }
}
