/* play & learn ♡ — cards: the album, the pack room, the ceremony and the big moments (SPEC §7, rc §11–14, ux 5.6–5.7).
   Tiers: :root[data-layout="phone|tablet|desk"], data-short, data-motion="calm", data-big. No inline styles:
   the screens pass numbers through CSSOM custom properties (--deg, --i, --p, --flip-ms, --roll-ms, --flash). */

/* ---------- shared bits ---------- */

.card-art { display: block; flex: none; }
.chip-mini {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px 5px;
  font: 800 var(--fs-small)/1 var(--font-ui);
  color: var(--ink);
  white-space: nowrap;
  background: var(--white);
  border: 2px solid var(--ink);
  border-radius: 999px;
}
.quiet-link {
  min-height: var(--target);
  padding: 0 14px;
  font: 800 var(--fs-ui)/1 var(--font-ui);
  color: var(--ink-soft);
  text-decoration: underline;
  text-underline-offset: 3px;
  background: none;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}

/* rarity colours (rc §4.1) */
[data-rarity="c"] { --rar: var(--milk); }
[data-rarity="u"] { --rar: var(--mint); }
[data-rarity="r"] { --rar: var(--sky); }
[data-rarity="e"] { --rar: var(--lavender); }
[data-rarity="l"] { --rar: var(--nose); }

/* =====================================================================================
   album (ux 5.6)
   ===================================================================================== */

.sheet-inner.album { max-width: 760px; gap: 12px; }
:root[data-layout="desk"] .sheet-inner.album { max-width: 1040px; }

.album-top { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.album-top .sheet-hint { flex: 1 1 auto; text-align: left; }
.album-peek { gap: 10px; flex: 1 1 auto; min-width: 0; }
.album-peek .kitty { --kitty: 28px; }
.album-peek .bubble {
  max-width: none;
  min-height: 0;
  padding: 6px 12px 7px;
  font: 800 var(--fs-small)/1.35 var(--font-ui);
  border-width: 2px;
  border-radius: 16px;
  box-shadow: 0 3px 0 var(--ink);
}
.album-peek .bubble::before { left: -11px; margin-top: -7px; border-width: 7px 11px 7px 0; }
.album-peek .bubble::after { left: -7px; margin-top: -5px; border-width: 5px 8px 5px 0; }
.album-hint:empty { display: none; }

.album-grid { display: flex; flex-direction: column; gap: 12px; }
.album-side, .album-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
:root[data-layout="desk"] .album-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 28px; align-items: start; }
:root[data-layout="desk"] .album-side { position: sticky; top: 0; }

/* binderTabs: six tabs, the set icon and "14/20"; 8 px between neighbours (ux 7.6), never under 44 wide.
   Six across needs 6 × 44 + 5 × 8 + 11 = 315 px, more than a 320 phone has: under 360 (414 in big letters, whose
   "16/20" wants a 55 px tab to clear the selected ring) the tabs go 3 × 2, as on desk */
.binder-tabs {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  padding: 3px;
  background: var(--white);
  border: 2.5px solid var(--ink);
  border-radius: 22px;
  box-shadow: 0 3px 0 var(--ink);
}
:root[data-layout="desk"] .binder-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 359px) { .binder-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 413px) { :root[data-big="true"] .binder-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.binder-tab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  min-height: 56px;
  margin: 0;
  padding: 4px 2px 3px;
  font: 800 calc(12px * var(--k-small))/1 var(--font-ui);
  color: var(--ink-soft);
  background: transparent;
  border: 0;
  border-radius: 16px;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.15s;
}
.binder-tab .tab-icon { display: block; width: 26px; height: 26px; }
.binder-tab[aria-selected="true"] { color: var(--ink); background: color-mix(in srgb, var(--subj) 45%, white); box-shadow: inset 0 0 0 2px var(--ink); }
.binder-tab.is-gold { box-shadow: inset 0 -4px 0 var(--nose); }
.binder-tab.is-gold[aria-selected="true"] { box-shadow: inset 0 0 0 2px var(--ink), inset 0 -6px 0 var(--nose); }
.binder-tab .tab-dot {
  top: 2px;
  right: 2px;
  width: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 4px;
  font: 800 var(--fs-small)/15px var(--font-ui);
  color: var(--white);
  text-align: center;
  background: var(--bow-deep);             /* white on bow-deep: 6.9:1 */
}
/* wish mode counts what a wish can pick: a nose pill with the wish star, never the red "new" badge */
.binder-tab .tab-dot.is-wish { color: var(--ink); background: var(--nose); }
.binder-tab:focus-visible { outline-offset: 1px; }

/* set header */
.set-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.set-progress {
  padding: 7px 14px 8px;
  font: 400 calc(17px * var(--k-title))/1 var(--font-display);
  color: var(--ink);
  background: color-mix(in srgb, var(--subj) 30%, white);
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 3px 0 var(--ink);
}
.set-stamps { display: inline-flex; gap: 6px; }
.stamp {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  font: 400 17px/1 var(--font-display);
  color: var(--white);
  text-decoration: none;
  border: 2.5px solid var(--ink);
  border-radius: 50%;
  box-shadow: 0 0 0 3px var(--white), 0 3px 0 3px var(--ink);
}
.stamp-half { background: var(--subj); color: var(--ink); }   /* ink on every set colour ≥ 3.8:1 (white on sky was 1.6) */
.stamp-gold { width: var(--target); height: var(--target); background: var(--nose); color: var(--ink); }
.set-titles { flex-basis: 100%; font: 800 var(--fs-small)/1.2 var(--font-ui); color: var(--bow-deep); }

.album-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.album-tools .chip { min-height: var(--target); }
.dust-chip, .jar-chip { cursor: default; }
.jar-chip { background: linear-gradient(90deg, #fff 0%, #fff3c4 100%); }
.wish-pill { animation: jelly-loop 3s ease-in-out 1.2s infinite; }

.album-filters { align-self: flex-start; }
.album-filters button { min-width: 56px; }   /* 4 × 56 + 3 × 8 + 11 = 259: one row at 320 (ux 7.6) */
.filter-line { min-height: 0; font: 800 var(--fs-small)/1.3 var(--font-ui); color: var(--ink-soft); }
.filter-line:empty { display: none; }

/* wish mode (rc §6.3): a nose-yellow banner over the page */
.wish-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  padding: 8px 10px 8px 14px;
  font: 800 var(--fs-ui)/1.3 var(--font-ui);
  color: var(--ink);
  background: var(--nose);
  border: 2.5px solid var(--ink);
  border-radius: 20px;
  box-shadow: 0 4px 0 var(--ink);
}
.wish-banner .wish-text { flex: 1 1 160px; }
.wish-banner .wish-star { font: 400 20px/1 var(--font-display); }
.wish-banner[data-kind="shiny"] { background: linear-gradient(100deg, #ffd966, #ff9fbd 45%, #9fd9ff); }

/* the binder: a white page with two rows of five */
.binder {
  position: relative;
  display: flex;
  justify-content: center;
  gap: 0;
  padding: 12px 8px 10px;
  background: var(--white);
  border: 2.5px solid var(--ink);
  border-radius: 24px;
  box-shadow: 0 4px 0 var(--ink);
  touch-action: pan-y;
  perspective: 1400px;
}
.binder::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 2px dashed color-mix(in srgb, var(--subj) 70%, white);
  border-radius: 18px;
  pointer-events: none;
}
.binder-page {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, 60px);
  justify-content: center;
  gap: 10px 10px;
  list-style: none;
  margin: 0;
  padding: 0;
  transform-style: preserve-3d;
}
.binder[data-size="M"] .binder-page { grid-template-columns: repeat(5, 125px); gap: 14px 12px; }
.binder.is-spread { gap: 0; padding: 14px 10px 12px; }
.binder.is-spread .binder-page { gap: 10px 8px; }
.binder-rings {
  flex: none;
  width: 24px;
  margin: 6px 0;
  background:
    radial-gradient(circle at 50% 12%, var(--white) 0 5px, var(--ink) 5.5px 7.5px, transparent 8px),
    radial-gradient(circle at 50% 50%, var(--white) 0 5px, var(--ink) 5.5px 7.5px, transparent 8px),
    radial-gradient(circle at 50% 88%, var(--white) 0 5px, var(--ink) 5.5px 7.5px, transparent 8px),
    linear-gradient(90deg, transparent 10px, var(--dash) 10px 14px, transparent 14px);
}
.page-ctl { display: flex; align-items: center; justify-content: center; gap: 14px; }
.page-text { min-width: 7em; font: 800 var(--fs-ui)/1 var(--font-ui); text-align: center; color: var(--ink-soft); }
:root[data-layout="tablet"]:not([data-short="true"]) .page-ctl .page-text { min-width: 0; }

/* cardSlot */
.slot-cell { position: relative; list-style: none; }
.slot {
  --drop: 0 3px 0 rgba(91, 42, 60, 0.35);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 60px;
  min-height: 102px;
  margin: 0;
  padding: 0;
  color: var(--ink);
  background: none;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  touch-action: manipulation;
  transition: opacity 0.2s ease, translate 0.12s;
}
.slot[data-size="M"] { width: 125px; min-height: 196px; gap: 4px; }
.slot-art { position: relative; display: block; border-radius: 9px; box-shadow: var(--drop); transition: transform 0.2s var(--boing); }
.slot[data-size="M"] .slot-art { border-radius: 16px; }
@media (hover: hover) { .slot:hover .slot-art { transform: translateY(-3px) rotate(-1.5deg); } }
.slot:active .slot-art { transform: scale(0.96); }
.slot:focus-visible { outline-offset: 2px; box-shadow: none; }
.slot-no {
  position: absolute;
  top: 6px;
  left: 0;
  right: 0;
  font: 800 var(--fs-small)/1 var(--font-ui);   /* captions stay ≥ 12 px (ux 0.3): the number a child reads off the wanted list */
  text-align: center;
  color: var(--ink);
}
.slot[data-size="M"] .slot-no { top: 12px; font-size: 14px; }
.slot-sym { position: absolute; top: 64px; left: 0; right: 0; font: 400 var(--fs-small)/1 var(--font-display); text-align: center; color: var(--ink); }
.slot[data-size="M"] .slot-sym { top: 138px; font-size: 15px; }
.slot-quest {
  position: absolute;
  top: 28px;
  left: 1px;
  right: 1px;
  padding: 2px 0;
  font: 800 var(--fs-small)/1.05 var(--font-ui);
  text-align: center;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.86);
  border-radius: 6px;
}
.slot-quest span { display: block; }
.slot[data-size="M"] .slot-quest { top: 104px; font-size: 13px; left: 8px; right: 8px; }
/* the badges stay inside the slot's box (ux 5.6; ≥ 8 px clear between neighbours)
   the new! ribbon: on the art window's top-left corner, under the name banner (S banner ends at 18 %, M at 15 %),
   at the 12 px caption floor (13.8 in big letters); on an S slot it ends 1 px short of the shiny badge */
.slot-ribbon {
  position: absolute;
  top: 17px;
  left: 1px;
  display: none;
  padding: 1px 3px 2px;
  font: 800 var(--fs-small)/1 var(--font-ui);
  letter-spacing: -0.3px;
  color: var(--ink);                       /* berry on pink: 5.3:1 (white on bow-pink is 2.9) */
  background: var(--pink);
  border: 2px solid var(--ink);
  border-radius: 999px;
  rotate: -8deg;
  box-shadow: 0 2px 0 var(--ink);
  pointer-events: none;
}
.slot.is-new .slot-ribbon { display: block; }
:root[data-big="true"] .slot:not([data-size="M"]) .slot-ribbon { padding: 1px 2px 2px 3px; letter-spacing: -0.6px; rotate: -6deg; }
.slot[data-size="M"] .slot-ribbon { padding: 3px 8px 4px; top: 31px; left: 4px; letter-spacing: 0; rotate: -12deg; }
/* the shiny badge: the art window's top-right corner, opposite the ribbon */
.slot-shiny {
  position: absolute;
  top: 17px;
  right: 1px;
  display: none;
  width: 17px;
  height: 17px;
  font: 400 12px/13px var(--font-display);
  text-align: center;
  color: var(--ink);
  background: linear-gradient(135deg, #ffd966, #ff9fbd, #9fd9ff);
  border: 2px solid var(--ink);
  border-radius: 50%;
}
.slot.is-shiny .slot-shiny { display: block; }
:root[data-big="true"] .slot:not([data-size="M"]) .slot-shiny { right: 0; }
.slot[data-size="M"] .slot-shiny { top: 30px; right: 5px; width: 24px; height: 24px; font-size: 14px; line-height: 20px; }
.slot-count {
  position: absolute;
  top: 62px;
  left: 3px;
  font: 800 var(--fs-small)/1 var(--font-ui);
  color: var(--ink);
  text-shadow: var(--ring-lite);
}
.slot[data-size="M"] .slot-count { top: 110px; left: 8px; font-size: 14px; }
.slot-count:empty { display: none; }
.slot-hug { min-height: 14px; font: 800 var(--fs-small)/14px var(--font-ui); color: var(--bow-deep); letter-spacing: -1px; white-space: nowrap; }
/* "max hugs" at 12 px just fits an S slot (52 + 6 px); with big letters it wraps inside its own nose chip */
.slot-hug.is-max { max-width: 100%; padding: 0 3px; letter-spacing: -0.5px; text-align: center; color: var(--ink); background: var(--nose); border-radius: 999px; }
:root[data-big="true"] .slot-hug.is-max { padding: 1px 4px; line-height: 1.05; letter-spacing: 0; white-space: normal; border-radius: 8px; }
.slot[data-size="M"] .slot-hug { font-size: 15px; }
.slot.is-faded { opacity: 0.2; }
.slot.is-dim { opacity: 0.35; cursor: default; }
/* eligible slots glow with a nose ring drawn inside the card's own edge (an ink line, the nose band, a soft glow
   inward), so neighbours never touch across the 10 px gap; the pulse lives on the banner's star only (ux 1.4) */
.slot.is-wishable .slot-art::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 0 0 2px var(--ink), inset 0 0 0 5px var(--nose), inset 0 0 10px 6px rgba(255, 207, 63, 0.7);
}
.slot.is-wishable:focus-visible .slot-art::after,
.slot.is-wishable:hover .slot-art::after { box-shadow: inset 0 0 0 2px var(--ink), inset 0 0 0 6px var(--nose), inset 0 0 16px 10px rgba(255, 207, 63, 0.85); }
.slot[data-size="M"].is-wishable .slot-art::after { box-shadow: inset 0 0 0 2.5px var(--ink), inset 0 0 0 7px var(--nose), inset 0 0 18px 10px rgba(255, 207, 63, 0.7); }
.slot-wish {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  display: none;
  width: max-content;
  max-width: 58px;
  padding: 3px 3px 4px;
  font: 800 var(--fs-small)/1.1 var(--font-ui);   /* "wish / for me?" on two lines at 12 px */
  text-align: center;
  color: var(--ink);
  background: var(--nose);
  border: 2px solid var(--ink);
  border-radius: 10px;
  box-shadow: 0 2px 0 var(--ink);
  translate: -50% -50%;
  pointer-events: none;
}
.slot[data-size="M"] .slot-wish { max-width: 116px; font-size: calc(13px * var(--k-small)); padding: 4px 10px 5px; white-space: nowrap; border-radius: 999px; }
.slot.is-wishable:focus-visible .slot-wish { display: block; }
@media (hover: hover) { .slot.is-wishable:hover .slot-wish { display: block; } }
.wish-banner .wish-star { display: inline-block; animation: twinkle 1.6s ease-in-out infinite; }
:root[data-motion="calm"] .wish-banner .wish-star { animation: none; }
:root[data-motion="calm"] .wish-pill { animation: none; }

/* phone: one page of 60 × 84 slots (5 × 60 + 4 × 10 = 340 ≤ 358) */
:root[data-layout="phone"]:not([data-short="true"]) .binder { padding: 12px 4px 10px; }
/* narrower binders (320–384 px screens, 400 % zoom): the gaps give way first (never under 3 px), then the page
   drops to rows of four, centred; the slots keep their 60 px and their 12 px labels (§10.2 reflow, no 2D scroll) */
.binder { container: binder / inline-size; }
@container binder (max-width: 339px) {
  .binder[data-size="S"]:not(.is-spread) .binder-page { column-gap: max(3px, calc((100cqw - 300px) / 4)); }
}
@container binder (max-width: 311px) {
  .binder[data-size="S"]:not(.is-spread) .binder-page { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; max-width: 270px; }
}
/* tablet: both pages as a spread (2 × 340 + 24 = 704) */
:root[data-layout="tablet"] .sheet-inner.album { max-width: 740px; }
/* short landscape: header column left (it gives way first), one page right, never under its 361 px
   (5 × 60 + 4 × 10 + 2 × 8 padding + 2 × 2.5 border) */
:root[data-short="true"] .album-grid { display: grid; grid-template-columns: minmax(0, 300px) minmax(361px, 1fr); gap: 14px; align-items: start; }
:root[data-short="true"] .binder-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
:root[data-short="true"] .binder-tab { min-height: 48px; }
/* too narrow for a 270 px column beside the page (+ the 2 × 16 gutter): 640 × 400 (1280 × 800 at 200 %), 667 × 375,
   568 × 320 stack as on a phone */
@media (max-width: 679px) {
  :root[data-short="true"] .album-grid { display: flex; align-items: stretch; }
  :root[data-short="true"] .album-side { flex-flow: row wrap; align-items: center; gap: 10px 12px; }
  :root[data-short="true"] .binder-tabs { flex: 1 1 100%; grid-template-columns: repeat(6, minmax(0, 1fr)); }
  :root[data-short="true"] .album-filters { align-self: center; }
  :root[data-short="true"] .filter-line { flex-basis: 100%; }
}
:root[data-short="true"] .set-progress { font-size: 15px; }
:root[data-short="true"] .album-top { min-height: 0; }

/* card detail: a modal with the card at L */
.modal-card.is-detail {
  width: min(380px, 100%);
  max-height: calc(100dvh - 24px);
  gap: 8px;
  padding: 16px 10px 18px;
  overflow-x: hidden;
}
.detail-body { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; }
/* the title and the sub line keep clear of the round ✕ (top right, one target wide) on both sides, so they stay centred */
.detail-title { max-width: calc(100% - 2 * var(--target) - 16px); font: 400 calc(21px * var(--k-title))/1.15 var(--font-display); color: var(--bow-deep); text-shadow: var(--ring); text-wrap: balance; }
.detail-sub { font: 800 var(--fs-small)/1.3 var(--font-ui); color: var(--ink-soft); text-wrap: balance; }
.detail-subs { max-width: calc(100% - 2 * var(--target) - 16px); }
.detail-facts { display: none; }
.detail-stage { position: relative; display: grid; place-items: center; width: 100%; padding: 6px 0; }
.detail-card {
  position: relative;
  display: block;
  width: 250px;
  height: 350px;
  margin: 0;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 22px;
  cursor: pointer;
  transform-style: preserve-3d;
  will-change: transform;
}
.detail-card:disabled { cursor: default; }
.detail-card:focus-visible { outline-offset: 5px; box-shadow: none; }
.detail-face {
  position: absolute;
  inset: 0;
  border-radius: 22px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transition: transform 0.4s var(--boing), opacity 0.2s ease;
}
.detail-front { box-shadow: 0 6px 0 rgba(91, 42, 60, 0.3); }
.detail-back {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  padding: 22px 20px;
  text-align: left;
  transform: rotateY(180deg);
  background-color: var(--milk);
  background-image: linear-gradient(90deg, rgba(255, 143, 177, 0.2) 50%, transparent 50%), linear-gradient(rgba(255, 143, 177, 0.2) 50%, transparent 50%);
  background-size: 28px 28px;
  border: 2.5px solid var(--ink);
  box-shadow: inset 0 0 0 7px var(--white), 0 6px 0 rgba(91, 42, 60, 0.3);
}
.detail-card.is-flipped .detail-front { transform: rotateY(180deg); }
.detail-card.is-flipped .detail-back { transform: rotateY(360deg); }
.back-name { font: 400 calc(18px * var(--k-title))/1.15 var(--font-display); color: var(--bow-deep); text-shadow: var(--ring); }
.back-flavor {
  padding: 10px 12px;
  font: 500 calc(15px * var(--k-body))/1.45 var(--font-ui);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.9);
  border-radius: 14px;
}
.back-row { font: 800 var(--fs-small)/1.35 var(--font-ui); color: var(--ink); }
/* big letters: the L back packs tighter so the longest flavour, a shiny line and a two-line "first found" all fit */
:root[data-big="true"] .detail-back { gap: 6px; padding: 16px 14px; }
:root[data-big="true"] .detail-back .back-flavor { padding: 7px 10px; line-height: 1.3; }
:root[data-big="true"] .detail-back .back-row { line-height: 1.2; }
.detail-rays {
  position: absolute;
  inset: -40px 0;
  z-index: -1;
  background: repeating-conic-gradient(from 0deg, rgba(255, 207, 63, 0.55) 0deg 10deg, rgba(255, 255, 255, 0) 10deg 30deg);
  -webkit-mask: radial-gradient(circle, #000 30%, transparent 70%);
  mask: radial-gradient(circle, #000 30%, transparent 70%);
  animation: rays-spin 18s linear infinite;
  pointer-events: none;
}
.detail-quest { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; }
.detail-quest:empty { display: none; }
.detail-hint { font: 800 var(--fs-small)/1.35 var(--font-ui); color: var(--ink-soft); text-align: center; }
.quest-row { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; }
.quest-line { font: 800 var(--fs-ui)/1.2 var(--font-ui); }
.quest-bar { position: relative; display: block; width: min(240px, 100%); height: 14px; overflow: hidden; background: var(--white); border: 2px solid var(--ink); border-radius: 999px; }
.quest-fill { position: absolute; inset: 0; transform-origin: 0 50%; transform: scaleX(var(--p, 0)); background: linear-gradient(90deg, var(--nose), var(--pink)); }
.detail-actions { display: flex; flex-wrap: nowrap; justify-content: center; gap: 6px; }
.detail-actions .pill.small { padding-left: 11px; padding-right: 12px; }
:root[data-big="true"] .detail-actions { flex-wrap: wrap; }
.detail-actions .pill[disabled] { opacity: 0.45; }
:root[data-short="true"] .modal-card.is-detail { width: min(640px, 100%); }
:root[data-short="true"] .detail-body { display: grid; grid-template-columns: 140px minmax(0, 1fr); grid-template-areas: "card title" "card sub" "card quest" "card actions"; column-gap: 16px; align-items: start; text-align: left; }
:root[data-short="true"] .detail-card { width: 125px; height: 175px; }
:root[data-short="true"] .detail-stage { grid-area: card; }
:root[data-short="true"] .detail-title { grid-area: title; max-width: calc(100% - var(--target) - 8px); }
:root[data-short="true"] .detail-subs { grid-area: sub; max-width: none; display: flex; flex-direction: column; gap: 6px; }
:root[data-short="true"] .detail-quest { grid-area: quest; }
:root[data-short="true"] .detail-actions { grid-area: actions; justify-content: flex-start; }
:root[data-short="true"] .detail-back { padding: 10px; gap: 4px; }
/* the M back is too small for every line at the 12 px floor (the longest flavour is 114 characters): it keeps the
   flavour (in big letters the stat), and the rest reads in the column beside the card, flipped or not, so the
   buttons never move under a finger */
:root[data-short="true"] .detail-back .back-flavor { font-size: var(--fs-small); line-height: 1.25; padding: 5px 6px; }
:root[data-short="true"] .back-name, :root[data-short="true"] .detail-back .back-row, :root[data-short="true"] .detail-back .back-stat { display: none; }
:root[data-short="true"] .back-stat .chip-mini { padding: 3px 6px; white-space: normal; text-align: center; }
:root[data-short="true"] .detail-facts { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
:root[data-short="true"] .detail-facts:empty { display: none; }
.detail-facts .back-stat { margin-bottom: 2px; }
.detail-facts .back-flavor { display: none; margin-bottom: 4px; padding: 0; font: 500 calc(14px * var(--k-body))/1.35 var(--font-ui); background: none; }
:root[data-big="true"] .detail-facts .back-flavor { display: block; }
:root[data-big="true"] .detail-facts .back-stat, :root[data-short="true"][data-big="true"] .detail-back .back-flavor { display: none; }
:root[data-short="true"][data-big="true"] .detail-back .back-stat { display: block; }
:root[data-short="true"] .modal-card.moment { width: min(560px, 100%); }
:root[data-short="true"] .moment-rare .moment-body,
:root[data-short="true"] .moment-epic .moment-body { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 8px 16px; text-align: left; }
:root[data-short="true"] .moment-legend .legend-flavor { display: none; }
:root[data-short="true"] .modal-layer.moment-full .modal-card { padding-top: 12px; padding-bottom: 12px; gap: 6px; }
:root[data-motion="calm"] .detail-face { transition: opacity 0.2s ease !important; }
:root[data-motion="calm"] .detail-card.is-flipped .detail-front { transform: none; opacity: 0; }
:root[data-motion="calm"] .detail-back { transform: none; opacity: 0; }
:root[data-motion="calm"] .detail-card.is-flipped .detail-back { transform: none; opacity: 1; }
:root[data-motion="calm"] .detail-rays { animation: none; }

.wish-body { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.wish-card { padding: 6px; border-radius: 22px; box-shadow: 0 0 0 4px var(--nose), 0 0 18px 6px rgba(255, 207, 63, 0.6); }

/* =====================================================================================
   pack room (rc §11.2, ux 5.7)
   ===================================================================================== */

.pack-body { display: flex; flex-direction: column; }
.pack-room {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "kitty" "last" "shelf" "stage" "side" "empty" "tray";
  gap: 12px;
  flex: 1 0 auto;
  width: 100%;
}
.room-kitty-wrap { grid-area: kitty; min-width: 0; }
.room-kitty .bubble { max-width: 260px; }
.last-pack { grid-area: last; }
.room-shelf { grid-area: shelf; min-width: 0; }
.room-stage { grid-area: stage; }
.room-side { grid-area: side; justify-self: center; }
.room-empty { grid-area: empty; }
.room-tray { grid-area: tray; }

.last-pack {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 10px 12px 10px 16px;
  font: 800 var(--fs-ui)/1.35 var(--font-ui);
  background: var(--white);
  border: 2.5px solid var(--ink);
  border-radius: 20px;
  box-shadow: 0 4px 0 var(--ink);
}

/* the shelf (components.js packShelf in room mode) */
.pack-room .pack-shelf.is-room {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin: 0;
  padding: 10px 12px 12px;
  list-style: none;
  background: linear-gradient(transparent 78%, #f0c2a0 78%, #e8ad86 100%);
  border-radius: 16px;
}
.pack-room .shelf-opt {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 82px;
  min-height: 100px;
  padding: 4px;
  border-radius: 16px;
  cursor: pointer;
  transition: translate 0.2s var(--boing), background-color 0.15s;
}
.pack-room .shelf-opt[aria-selected="true"] { background: rgba(255, 255, 255, 0.75); box-shadow: inset 0 0 0 2.5px var(--ink); translate: 0 -4px; }
.pack-room .shelf-opt .pack-sprite { display: block; width: var(--w, 72px); height: var(--h, 92px); }
.pack-room .shelf-opt canvas { display: block; width: 100%; height: 100%; }
.pack-room .shelf-count {
  position: absolute;
  right: -2px;
  top: -6px;
  padding: 3px 7px 4px;
  font: 800 12px/1 var(--font-ui);
  background: var(--white);
  border: 2px solid var(--ink);
  border-radius: 999px;
}
.pack-room .shelf-ribbon {
  position: absolute;
  left: -4px;
  top: 8px;
  padding: 2px 6px 3px;
  font: 800 var(--fs-small)/1 var(--font-ui);
  color: var(--ink);
  background: var(--pink);
  border: 2px solid var(--ink);
  border-radius: 999px;
  rotate: -10deg;
}

/* the cushion: gingham pillow with the chosen pack breathing on it */
.room-stage { display: grid; place-items: center; width: 100%; min-width: 0; }
.cushion {
  position: relative;
  display: grid;
  place-items: center;
  width: min(300px, 100%);
  min-height: 230px;
  padding: 14px 0 36px;
}
.cushion::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 6px;
  height: 64px;
  z-index: -1;
  background-color: var(--milk);
  background-image: linear-gradient(90deg, rgba(255, 143, 177, 0.35) 50%, transparent 50%), linear-gradient(rgba(255, 143, 177, 0.35) 50%, transparent 50%);
  background-size: 18px 18px;
  border: 2.5px solid var(--ink);
  border-radius: 50%;
  box-shadow: 0 5px 0 var(--ink);
}
.cushion-pack-wrap { display: block; transform-origin: 50% 100%; animation: breathe 1.6s ease-in-out infinite; }
.cushion-pack { display: block; filter: drop-shadow(0 6px 0 rgba(91, 42, 60, 0.25)); }
.cushion-empty { display: block; width: 140px; height: 150px; }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.03); } }

.room-side { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 460px; }

/* the odds card: a sticker-edged note */
.odds-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px 14px;
  background: var(--white);
  border: 2.5px solid var(--ink);
  border-radius: 18px;
  box-shadow: 0 0 0 5px var(--white), 0 0 0 7.5px var(--ink), 0 9px 0 4px var(--ink);
  rotate: -0.6deg;
}
.odds-title { font: 400 calc(16px * var(--k-title))/1.2 var(--font-display); color: var(--bow-deep); text-shadow: var(--ring-lite); }
.odds-head { font: 800 calc(13px * var(--k-ui))/1.45 var(--font-ui); color: var(--ink); text-wrap: pretty; }
.odds-line { padding-top: 6px; font: 800 calc(13px * var(--k-ui))/1.4 var(--font-ui); color: var(--ink-soft); border-top: 2px dashed var(--dash); text-wrap: pretty; }
.odds-card[data-kind="gold"] { background: #fffbea; }
.odds-card[data-kind="rainbow"] { background: linear-gradient(160deg, #fff 60%, #f3efff); }

/* promises: three small meters with their sentences */
.promises { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; background: rgba(255, 255, 255, 0.82); border: 2.5px solid var(--ink); border-radius: 18px; box-shadow: 0 4px 0 var(--ink); }
.promises-title { font: 400 calc(15px * var(--k-title))/1.2 var(--font-display); color: var(--ink); }
.promise { display: grid; grid-template-columns: 70px minmax(0, 1fr); align-items: center; gap: 10px; }
.promise.is-other { opacity: 0.6; }
.promise-bar { position: relative; display: block; height: 14px; overflow: hidden; background: var(--white); border: 2px solid var(--ink); border-radius: 999px; }
.promise-fill { position: absolute; inset: 0; transform-origin: 0 50%; transform: scaleX(var(--p, 0)); background: var(--sky); }
.promise-E .promise-fill { background: var(--lavender); }
.promise-L .promise-fill { background: linear-gradient(90deg, #ff9fbd, #ffd966, #93e4cd, #9fd9ff, #c2aeff); }
.promise-text { font: 800 var(--fs-small)/1.35 var(--font-ui); color: var(--ink); text-wrap: pretty; }

.room-tray {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin: 0 calc(-1 * (var(--sal) + 16px)) calc(-1 * (var(--sab) + 28px));
  padding: 20px 16px calc(var(--sab) + 12px);
  /* a solid band under the thumb: whatever scrolls beneath (the odds card) fades out in 10 px above the button, and
     the band reaches the screen's bottom edge, so no line of text peeks between or under the buttons */
  background: linear-gradient(rgba(255, 227, 236, 0), var(--milk) 10px);
}
:root[data-layout="phone"]:not([data-short="true"]) .room-tray::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  height: calc(var(--sab) + 30px);
  background: var(--milk);
  pointer-events: none;
}

/* tablet + desk: the kitty beside the cushion, the primary under the pack, odds and promises in a column right */
:root:not([data-layout="phone"]) .pack-room {
  grid-template-columns: minmax(0, 1fr) minmax(0, 420px);
  grid-template-areas: "last last" "shelf shelf" "kitty kitty" "stage side" "tray side" "empty empty";
  align-items: start;
  column-gap: 24px;
  max-width: 920px;
}
:root:not([data-layout="phone"]) .cushion { min-height: 300px; }
:root:not([data-layout="phone"]) .room-tray { position: static; margin: 0; padding: 0 0 12px; background: none; }
:root[data-layout="desk"] .pack-room { grid-template-columns: 200px minmax(0, 1fr) minmax(0, 420px); grid-template-areas: "kitty last last" "kitty shelf shelf" "kitty stage side" "kitty tray side" "kitty empty empty"; max-width: 1080px; }
:root[data-layout="desk"] .room-kitty-wrap { align-self: start; position: sticky; top: 0; }
:root[data-layout="desk"] .room-kitty { flex-direction: column; align-items: flex-start; }
:root[data-layout="desk"] .room-kitty .bubble { max-width: 200px; }
:root[data-layout="desk"] .room-kitty .bubble::before { left: 40px; top: -16px; margin: 0; border-width: 0 10px 16px 10px; border-color: transparent transparent var(--ink) transparent; }
:root[data-layout="desk"] .room-kitty .bubble::after { left: 43px; top: -11px; margin: 0; border-width: 0 7px 12px 7px; border-color: transparent transparent var(--white) transparent; }
/* short landscape: shelf a strip left, cushion centre, odds right, the primary in the right column */
:root[data-short="true"] .pack-room {
  grid-template-columns: 96px minmax(0, 1fr) minmax(0, 1.25fr);
  grid-template-areas: "kitty kitty kitty" "last last last" "shelf stage tray" "shelf stage side" "shelf empty empty";
  align-items: start;
  gap: 8px 14px;
}
:root[data-short="true"] .pack-room .pack-shelf.is-room { flex-direction: column; flex-wrap: nowrap; align-items: center; background: none; padding: 0; }
:root[data-short="true"] .cushion { min-height: 170px; padding-bottom: 22px; }
:root[data-short="true"] .cushion::after { height: 40px; }
:root[data-short="true"] .room-tray { position: static; flex-direction: column; justify-content: center; gap: 0; margin: 0; padding: 0; background: none; }
:root[data-short="true"] .pack-room .shelf-opt { min-width: 76px; min-height: 92px; }
:root[data-short="true"] .room-side { max-width: none; }
:root[data-short="true"] .room-tray .btn-wide { width: auto; min-width: 220px; height: 52px; }
:root[data-motion="calm"] .cushion-pack-wrap { animation: none; }

/* the empty shelf (§7.3, ux 5.7): the kitty on top, then an empty cushion with the words, the meter and the way back,
   centred in what is left (short: the cushion beside the words, so the primary is on screen at 844 × 390) */
:root .pack-room.is-empty { grid-template-columns: minmax(0, 1fr); grid-template-areas: "kitty" "last" "empty"; grid-template-rows: auto auto 1fr; }
:root[data-layout="desk"] .pack-room.is-empty { grid-template-columns: 200px minmax(0, 1fr); grid-template-areas: "kitty last" "kitty empty"; grid-template-rows: auto 1fr; }
.room-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px 22px; align-self: center; text-align: center; }
.room-empty-copy { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; }
.room-empty-text { max-width: 30em; font: 800 var(--fs-body)/1.5 var(--font-ui); text-wrap: pretty; }
.room-meter { width: min(360px, 100%); }
:root .cushion.is-empty { width: min(220px, 100%); min-height: 0; padding: 4px 0 30px; }
.cushion.is-empty::after { height: 52px; }
.cushion-empty { display: block; width: 84px; height: 108px; background: #fff6f9; border: 3px dashed var(--dash); border-radius: 16px; }
:root[data-short="true"] .room-empty { flex-direction: row; text-align: left; }
:root[data-short="true"] .room-empty-copy { align-items: flex-start; width: auto; min-width: 0; max-width: 440px; gap: 10px; }
:root[data-short="true"] .room-meter { width: min(320px, 100%); }
:root[data-short="true"] .cushion.is-empty { flex: none; width: 150px; min-height: 0; padding: 0 0 20px; }
:root[data-short="true"] .cushion.is-empty::after { height: 34px; }
:root[data-short="true"] .cushion-empty { width: 62px; height: 80px; }
:root[data-short="true"] .room-empty .btn-wide { width: auto; min-width: 220px; height: 52px; }

/* =====================================================================================
   the ceremony (rc §12): full-bleed, the sheet head hidden
   ===================================================================================== */

.ceremony { position: absolute; inset: 0; z-index: 4; }
.ceremony[hidden] { display: none; }
.cer {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  padding: calc(var(--sat) + 10px) calc(var(--sar) + 12px) calc(var(--sab) + 12px) calc(var(--sal) + 12px);
  background-color: var(--milk);
  background-image:
    radial-gradient(ellipse 70% 50% at 50% 40%, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0) 70%),
    linear-gradient(90deg, var(--gingham) 50%, transparent 50%),
    linear-gradient(var(--gingham) 50%, transparent 50%);
  background-size: 100% 100%, 46px 46px, 46px 46px;
}
.cer-skip { position: absolute; z-index: 6; top: calc(var(--sat) + 12px); right: calc(var(--sar) + 12px); }
.cer.is-lineup .cer-skip, .cer.is-done .cer-skip { visibility: hidden; }
.cer-kitty.is-quiet .bubble, .room-kitty.is-quiet .bubble { opacity: 0; }
.cer-stage {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  min-height: 260px;
  outline: none;
  cursor: pointer;
  touch-action: manipulation;
  perspective: 1100px;
}
.cer-stage:focus-visible { outline: 3px dashed var(--pink); outline-offset: -10px; border-radius: 28px; box-shadow: none; }
.cer-dim { position: absolute; inset: 0; z-index: 0; opacity: 0; pointer-events: none; transition: opacity 0.35s ease; }
.cer-dim.dim-e { opacity: 1; background: rgba(180, 156, 255, 0.25); }
.cer-dim.dim-l { opacity: 1; background: radial-gradient(ellipse at 50% 45%, rgba(180, 156, 255, 0.18), rgba(91, 42, 60, 0.3)); }
.cer-rays {
  position: absolute;
  left: 50%;
  top: 46%;
  z-index: 0;
  width: min(620px, 100%);
  aspect-ratio: 1;
  translate: -50% -50%;
  opacity: 0;
  pointer-events: none;
  background: repeating-conic-gradient(from 0deg, rgba(255, 217, 102, 0.7) 0deg 9deg, rgba(255, 255, 255, 0) 9deg 30deg);
  -webkit-mask: radial-gradient(circle, #000 18%, transparent 66%);
  mask: radial-gradient(circle, #000 18%, transparent 66%);
  transform: scale(0.4);
  transition: opacity 0.6s ease, transform 1.4s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.cer-rays.is-on { opacity: 1; transform: scale(1); animation: rays-spin 12s linear infinite; }
@keyframes rays-spin { to { rotate: 1turn; } }
.cer-flash { position: absolute; inset: 0; z-index: 5; opacity: 0; pointer-events: none; background: var(--flash, #fff); }
.cer-fx { position: absolute; inset: 0; z-index: 4; pointer-events: none; }

/* the pouch: body + its strip (the strip peels at the tear) */
.cer-pack { position: absolute; left: 50%; top: 46%; z-index: 2; translate: -50% -50%; transform-origin: 50% 90%; transition: opacity 0.25s ease, translate 0.32s var(--boing); }
.cer-pack .pack-art { display: block; }
.cer-pack .cer-strip { position: absolute; left: 0; top: 0; transform-origin: 8% 18%; clip-path: inset(0 0 0 0); transition: transform 0.32s cubic-bezier(0.5, 0, 0.75, 0), opacity 0.32s ease, clip-path 0.32s ease; }
.cer[data-beat="wiggle"] .cer-pack { animation: pack-wiggle 0.42s ease-in-out both; }
@keyframes pack-wiggle {
  0% { rotate: 0deg; scale: 1; }
  16% { rotate: -6deg; scale: 1.04; }
  33% { rotate: 6deg; scale: 1.06; }
  50% { rotate: -6deg; scale: 1.06; }
  66% { rotate: 6deg; scale: 1.06; }
  83% { rotate: -4deg; scale: 1.05; }
  100% { rotate: 0deg; scale: 1.06; }
}
.cer[data-beat="tear"] .cer-pack { translate: -50% calc(-50% + 12px); scale: 1.06; }
.cer[data-beat="tear"] .cer-strip,
.cer[data-beat="fan"] .cer-strip,
.cer.is-revealing .cer-strip,
.cer.is-lineup .cer-strip,
.cer.is-done .cer-strip { transform: translate(40px, -70px) rotate(28deg); opacity: 0; clip-path: inset(0 0 0 30%); }
.cer[data-beat="fan"] .cer-pack,
.cer.is-revealing .cer-pack,
.cer.is-lineup .cer-pack,
.cer.is-done .cer-pack { opacity: 0; translate: -50% calc(-50% + 40px); }

/* the fan of backs (3: −14/0/+14 · 4: ±21/±7 · 5: ±28/±14/0) */
.cer-fan { position: absolute; left: 50%; top: 46%; z-index: 1; width: 0; height: 0; }
.fan-card {
  position: absolute;
  left: -62.5px;
  top: -87.5px;
  display: block;
  opacity: 0;
  border-radius: 14px;
  transform-origin: 50% 140%;
  transform: rotate(0deg) scale(0.7);
  transition: transform 0.36s var(--boing), opacity 0.2s ease;
  filter: drop-shadow(0 4px 0 rgba(91, 42, 60, 0.25));
}
.cer[data-beat="fan"] .fan-card,
.cer.is-revealing .fan-card { opacity: 1; transform: rotate(var(--deg, 0deg)) scale(1); transition-delay: calc(var(--i, 0) * 30ms); }
.cer.is-revealing .cer-fan { left: 64px; top: 70px; transform: scale(0.36); transform-origin: 50% 50%; transition: transform 0.3s ease, left 0.3s ease, top 0.3s ease; }
:root:not([data-layout="phone"]) .cer.is-revealing .cer-fan { left: 110px; top: 110px; transform: scale(0.5); }
.fan-card.is-gone { opacity: 0 !important; transform: rotate(var(--deg, 0deg)) translateY(-60px) scale(0.6) !important; }
.cer.is-lineup .cer-fan,
.cer.is-done .cer-fan { display: none; }

/* the card being revealed: back → (roll) → flip → front, at M in the centre */
.cer-card {
  position: absolute;
  left: 50%;
  top: 42%;
  z-index: 3;
  width: 250px;
  height: 350px;
  margin: -175px 0 0 -125px;
  opacity: 0;
  transform-style: preserve-3d;
  pointer-events: none;
  scale: 0.74;
}
:root:not([data-layout="phone"]) .cer-card { scale: 0.86; }
:root[data-short="true"] .cer-card { scale: 0.5; top: 50%; }
.cer.is-revealing .cer-card { opacity: 1; transition: opacity 0.18s ease; }
.cer.is-lineup .cer-card,
.cer.is-done .cer-card { opacity: 0; }
.cer-face { position: absolute; inset: 0; border-radius: 22px; backface-visibility: hidden; -webkit-backface-visibility: hidden; transition: transform var(--flip-ms, 220ms) var(--boing), opacity var(--flip-ms, 220ms) ease; }
.cer-face .face-canvas { display: block; }
.cer-front { transform: rotateY(180deg); }
.cer-card.is-flipped .cer-back { transform: rotateY(-180deg); }
.cer-card.is-flipped .cer-front { transform: rotateY(0deg); }
.cer-card[data-rarity="l"] .cer-face { transition-timing-function: cubic-bezier(0.34, 1.56, 0.64, 1); }
/* the rolls are earned only: a common never shivers (rc §12.2) */
.cer-card.roll-r { animation: shiver 60ms linear infinite; }
.cer-card.roll-r .cer-back::after { content: ""; position: absolute; inset: 0; border-radius: 22px; background: linear-gradient(110deg, transparent 35%, rgba(143, 211, 255, 0.85) 50%, transparent 65%); background-size: 260% 100%; animation: shimmer calc(var(--roll-ms, 700ms) / 2) linear 2; }
.cer-card.roll-e { animation: float-up var(--roll-ms, 1000ms) ease-out both; }
.cer-card.roll-e .cer-back::after { content: ""; position: absolute; inset: -18px; border-radius: 24px; box-shadow: 0 0 22px 10px rgba(180, 156, 255, 0.75); }
.cer-card.roll-l { animation: heartbeat calc(var(--roll-ms, 1400ms) / 2) ease-in-out 2; }
.cer-card.roll-l .cer-back::after { content: ""; position: absolute; inset: -22px; border-radius: 26px; box-shadow: 0 0 28px 14px rgba(255, 207, 63, 0.8); }
@keyframes shiver { 0%, 100% { rotate: -2deg; } 50% { rotate: 2deg; } }
@keyframes shimmer { from { background-position: 130% 0; } to { background-position: -130% 0; } }
@keyframes float-up { to { translate: 0 -10px; } }
@keyframes heartbeat { 0%, 100% { transform: scale(1); } 20% { transform: scale(1.04); } 40% { transform: scale(1); } 60% { transform: scale(1.04); } }
.cer-card.is-shown { translate: 0 0; }
/* corner tags: stacked upward from the card's top-right corner, so they never cover the name banner */
.cer-tags { position: absolute; bottom: calc(100% - 4px); right: -34px; scale: 1.24; transform-origin: 100% 100%; z-index: 2; display: flex; flex-direction: column-reverse; align-items: flex-end; gap: 4px; transform: rotateY(0deg); }
.cer-tag {
  padding: 4px 9px 5px;
  font: 800 var(--fs-small)/1 var(--font-ui);   /* × the 1.24 scale: 15 px on screen */
  white-space: nowrap;
  color: var(--ink);
  background: var(--white);
  border: 2px solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 2px 0 var(--ink);
  rotate: 8deg;
  animation: tag-life 1.2s ease-out both;
}
.tag-new { color: var(--ink); background: var(--pink); }
.tag-again { color: var(--ink-soft); }
.tag-shiny { background: linear-gradient(110deg, #ffd966, #ff9fbd, #9fd9ff, #c2aeff); }
.tag-hug { color: var(--bow-deep); }
@keyframes tag-life { 0% { opacity: 0; transform: scale(0.4); } 15% { opacity: 1; transform: scale(1.1); } 25%, 100% { opacity: 1; transform: scale(1); } }

/* the tray under the stage: revealed cards gather; at the line-up they grow (phone 3 per row at 112 × 157) */
.cer-bottom { position: relative; z-index: 5; display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; padding-bottom: 6px; }
.cer-tray { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; min-height: 84px; margin: 0; padding: 0; list-style: none; }
.cer-tray li { list-style: none; }
.tray-card {
  position: relative;
  display: block;
  margin: 0;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 10px;
  cursor: default;
  animation: chip-in 0.3s var(--boing) both;
}
.tray-card .card-art { filter: drop-shadow(0 3px 0 rgba(91, 42, 60, 0.25)); }
.cer.is-done .tray-card { cursor: pointer; }
.cer.is-lineup .cer-stage,
.cer.is-done .cer-stage { flex: 0 0 auto; min-height: 56px; }
.cer.is-lineup .cer-bottom,
.cer.is-done .cer-bottom { flex: 1 1 auto; justify-content: center; }
.cer.is-lineup .tray-card .card-art,
.cer.is-done .tray-card .card-art { width: 125px !important; height: 175px !important; }
.cer.is-lineup .tray-card, .cer.is-done .tray-card { animation: rise-in 0.3s ease-out both; animation-delay: calc(var(--i, 0) * 60ms); }
.cer.is-skipped .tray-card { animation-delay: calc(var(--i, 0) * 200ms); }
/* the line-up rows are centred (a lone fourth card sits in the middle, not at the left); room above each row for the
   new! stickers on the frame corners */
.cer.is-lineup .cer-tray, .cer.is-done .cer-tray { gap: 18px 8px; padding-top: 10px; }
:root[data-layout="phone"]:not([data-short="true"]) .cer.is-lineup .cer-tray,
:root[data-layout="phone"]:not([data-short="true"]) .cer.is-done .cer-tray { max-width: 352px; }   /* 3 × 112 + 2 × 8: three per row */
:root[data-layout="phone"]:not([data-short="true"]) .cer.is-lineup .tray-card .card-art,
:root[data-layout="phone"]:not([data-short="true"]) .cer.is-done .tray-card .card-art { width: 112px !important; height: 157px !important; }
:root[data-short="true"] .cer.is-lineup .tray-card .card-art,
:root[data-short="true"] .cer.is-done .tray-card .card-art { width: 60px !important; height: 84px !important; }
/* the new! sticker sits on the frame's top-right corner, over the edge and the banner's rarity symbol (the rarity
   word is printed under the art): never on the art or the name */
.tray-ribbon {
  position: absolute;
  top: -8px;
  right: -6px;
  z-index: 1;
  padding: 2px 4px 3px;
  font: 800 var(--fs-small)/1 var(--font-ui);   /* stickers keep the 12 px caption floor too */
  color: var(--ink);                       /* berry on pink: 5.3:1 */
  background: var(--pink);
  border: 2px solid var(--ink);
  border-radius: 999px;
  rotate: 10deg;
  box-shadow: 0 2px 0 var(--ink);
  pointer-events: none;
}
.cer.is-lineup .tray-ribbon, .cer.is-done .tray-ribbon { top: -12px; right: -9px; padding: 3px 8px 4px; font-size: var(--fs-small); }
:root[data-short="true"] .cer.is-lineup .tray-ribbon, :root[data-short="true"] .cer.is-done .tray-ribbon { top: -8px; right: -6px; padding: 1px 4px 2px; font-size: var(--fs-small); }
.cer-summary { min-height: 1.2em; font: 800 var(--fs-body)/1.3 var(--font-ui); text-align: center; color: var(--ink); text-shadow: var(--ring-lite); }
.cer-summary:empty { display: none; }
.cer-done { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; }
.cer-done[hidden] { display: none; }
.cer-done .btn-primary { flex: 1 1 100%; max-width: 340px; }

.cer-kitty { position: absolute; z-index: 5; left: calc(var(--sal) + 10px); bottom: calc(var(--sab) + 116px); pointer-events: none; max-width: min(380px, calc(100% - 20px)); }
.cer-kitty .bubble { max-width: 230px; font-size: 13px; }
/* the kitty stays for the line-up (she poses happy and finishes her line); on a phone the done pills reach her, so she bows out */
:root[data-layout="phone"] .cer.is-done .cer-kitty { opacity: 0; transition: opacity 0.3s ease; }
:root[data-layout="phone"] .cer-kitty { bottom: calc(var(--sab) + 120px); }
:root[data-short="true"] .cer-kitty { display: none; }

/* calm (rc §12.3): fades instead of flips, soft tints instead of rolls, nothing moves */
.cer[data-calm="true"] .fan-card { transform: rotate(var(--deg, 0deg)) scale(1); }
.cer[data-calm="true"] .cer-face { transition: opacity var(--flip-ms, 250ms) ease !important; }
.cer[data-calm="true"] .cer-front { transform: none; opacity: 0; }
.cer[data-calm="true"] .cer-card.is-flipped .cer-back { transform: none; opacity: 0; }
.cer[data-calm="true"] .cer-card.is-flipped .cer-front { transform: none; opacity: 1; }
.cer[data-calm="true"] .cer-card.roll-r,
.cer[data-calm="true"] .cer-card.roll-e,
.cer[data-calm="true"] .cer-card.roll-l { animation: none; }
.cer[data-calm="true"] .cer-card.roll-r .cer-back::after { content: ""; position: absolute; inset: 0; border-radius: 22px; animation: none; background: rgba(143, 211, 255, 0.35); }
.cer[data-calm="true"] .cer-card.roll-e .cer-back::after { inset: 0; border-radius: 22px; box-shadow: none; background: rgba(180, 156, 255, 0.35); }
.cer[data-calm="true"] .cer-card.roll-l .cer-back::after { inset: 0; border-radius: 22px; box-shadow: none; background: rgba(255, 207, 63, 0.4); }
.cer[data-calm="true"] .cer-dim { display: none; }
.cer[data-calm="true"] .cer-rays.is-on { animation: none; transform: scale(1); }
.cer[data-calm="true"] .cer-strip { transition: opacity 0.2s ease !important; }
.cer[data-calm="true"][data-beat="tear"] .cer-strip { transform: none; clip-path: none; }
.cer[data-calm="true"][data-beat="wiggle"] .cer-pack { animation: none; filter: brightness(1.12); }
.cer[data-calm="true"] .cer-tag { animation: none; }
.cer[data-calm="true"] .cer-fan,
.cer[data-calm="true"].is-revealing .cer-fan { transition: none; }

/* =====================================================================================
   big moments (rc §12.4, §14.4)
   ===================================================================================== */

.moment-body { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; }
.modal-card.moment .modal-primary { min-width: 0; max-width: 100%; padding: 0 22px 3px; font-size: calc(19px * var(--k-option)); }
.moment-card { position: relative; display: block; margin: 0; padding: 0; background: none; border: 0; border-radius: 22px; transform-style: preserve-3d; }
.moment-card .card-art { filter: drop-shadow(0 6px 0 rgba(91, 42, 60, 0.3)); }
.modal-card.moment { width: min(380px, 100%); }
.modal-card.moment-rare { box-shadow: 0 0 0 5px var(--sky), 0 6px 0 5px var(--ink); }
.modal-card.moment-epic { box-shadow: 0 0 0 5px var(--lavender), 0 6px 0 5px var(--ink); }

.modal-layer.moment-full .modal-back { background: rgba(255, 214, 228, 0.94); }
.modal-layer.moment-full .modal-card { width: min(560px, 100%); max-height: calc(100dvh - 24px); background-color: var(--milk);
  background-image: radial-gradient(ellipse 70% 50% at 50% 30%, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0) 70%); }
.moment-legend .modal-title { font-size: calc(30px * var(--k-title)); }
.legend-name { font: 400 calc(20px * var(--k-title))/1.2 var(--font-display); color: var(--ink); }
.legend-card { cursor: default; }
.legend-rays {
  position: absolute;
  inset: -70px -40px;
  z-index: -1;
  background: repeating-conic-gradient(from 0deg, rgba(255, 217, 102, 0.75) 0deg 9deg, rgba(255, 255, 255, 0) 9deg 30deg);
  -webkit-mask: radial-gradient(circle, #000 30%, transparent 70%);
  mask: radial-gradient(circle, #000 30%, transparent 70%);
  animation: rays-spin 12s linear infinite;
  pointer-events: none;
}
.legend-flavor { max-width: 30em; }
.modal-card.moment-legend.is-big { position: fixed; inset: 0; width: 100%; max-width: none; max-height: none; border-radius: 0; justify-content: center; }
.moment-legend.is-big .legend-card { scale: 1.6; margin: 120px 0; }
:root[data-layout="phone"] .moment-legend.is-big .legend-card { scale: 1.35; margin: 70px 0; }
.moment-legend.is-big .legend-flavor, .moment-legend.is-big .legend-name, .moment-legend.is-big .modal-title { display: none; }

.moment-fx { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.moment-cascade { display: grid; grid-template-columns: repeat(5, 60px); gap: 8px; justify-content: center; }
.cascade-cell { display: block; animation: rise-in 0.35s var(--boing) both; animation-delay: calc(var(--i, 0) * 40ms); }
/* set complete: the gold stamp thumps onto the moment's own set header, beside "20 of 20", never over the cards */
.moment-set-head { display: flex; align-items: center; justify-content: center; gap: 16px; max-width: 100%; text-align: left; }
.moment-set-head .modal-text { min-width: 0; text-wrap: balance; }
.moment-stamp {
  display: grid;
  flex: none;
  place-items: center;
  width: 60px;
  height: 60px;
  font: 400 28px/1 var(--font-display);
  background: var(--nose);
  border: 3px solid var(--ink);
  border-radius: 50%;
  box-shadow: 0 0 0 5px var(--white), 0 5px 0 5px var(--ink);
  rotate: -12deg;
  animation: stamp-thump 0.45s cubic-bezier(0.3, 1.6, 0.6, 1) 0.9s both;
}
@keyframes stamp-thump { 0% { transform: scale(1.7); opacity: 0; } 55% { opacity: 1; } 100% { transform: none; opacity: 1; } }
:root[data-layout="phone"]:not([data-short="true"]) .modal-layer.moment-full .modal-card.moment-set { padding-left: 14px; padding-right: 14px; }
:root[data-layout="phone"]:not([data-short="true"]) .moment-set .moment-cascade { gap: 8px 6px; }
/* short: the words and pills left, the 20 cards right at 44 × 62, so the primary is on screen */
:root[data-short="true"] .modal-layer.moment-full .modal-card.moment-set {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "title grid" "head grid" "actions grid";
  grid-template-rows: auto auto 1fr;
  align-items: center;
  gap: 8px 18px;
  width: min(640px, 100%);
}
:root[data-short="true"] .moment-set .moment-body { display: contents; }
:root[data-short="true"] .moment-set .modal-title { grid-area: title; }
:root[data-short="true"] .moment-set-head { grid-area: head; justify-content: flex-start; }
:root[data-short="true"] .moment-set .moment-cascade { grid-area: grid; grid-template-columns: repeat(5, 44px); gap: 6px; }
:root[data-short="true"] .moment-set .cascade-cell .card-art { width: 44px !important; height: 62px !important; }
:root[data-short="true"] .moment-set .modal-actions { grid-area: actions; align-self: start; }
:root[data-short="true"] .moment-stamp { width: 46px; height: 46px; font-size: 21px; box-shadow: 0 0 0 4px var(--white), 0 4px 0 4px var(--ink); }
.moment-mosaic { display: block; max-width: 100%; height: auto; border-radius: 10px; }
.moment-kitty { --kitty: 96px; }

.reveal-one .one-stage { position: relative; display: grid; place-items: center; width: 100%; min-height: 220px; perspective: 900px; }
.one-card { position: relative; width: 125px; height: 175px; transform-style: preserve-3d; scale: 1.2; }
.one-card .cer-face { position: absolute; inset: 0; }
.one-card .cer-front { transform: rotateY(180deg); }
.one-card.is-rolling[data-rarity="r"] .cer-back::after,
.one-card.is-rolling[data-rarity="e"] .cer-back::after,
.one-card.is-rolling[data-rarity="l"] .cer-back::after { content: ""; position: absolute; inset: -10px; border-radius: 20px; box-shadow: 0 0 20px 8px var(--glow, rgba(143, 211, 255, 0.8)); }
.one-card[data-rarity="e"] { --glow: rgba(180, 156, 255, 0.8); }
.one-card[data-rarity="l"] { --glow: rgba(255, 207, 63, 0.85); }
.one-card.is-rolling[data-rarity="r"] { animation: shiver 60ms linear infinite; }
.one-card.is-rolling[data-rarity="e"] { animation: float-up var(--roll-ms, 1000ms) ease-out both; }
.one-card.is-rolling[data-rarity="l"] { animation: heartbeat calc(var(--roll-ms, 1400ms) / 2) ease-in-out 2; }
.one-card.is-flipped .cer-back { transform: rotateY(-180deg); }
.one-card.is-flipped .cer-front { transform: rotateY(0deg); }
.one-tag { font: 800 var(--fs-ui)/1 var(--font-ui); color: var(--bow-deep); }
:root[data-motion="calm"] .one-card .cer-face { transition: opacity 0.25s ease !important; }
:root[data-motion="calm"] .one-card .cer-front { transform: none; opacity: 0; }
:root[data-motion="calm"] .one-card.is-flipped .cer-front { opacity: 1; }
:root[data-motion="calm"] .one-card.is-flipped .cer-back { transform: none; opacity: 0; }
:root[data-motion="calm"] .legend-rays,
:root[data-motion="calm"] .cer-rays.is-on { animation: none; }

@media print {
  .ceremony, .cer, .cer-fx, .moment-fx { display: none !important; }
  .binder, .slot-art { box-shadow: none; }
}

/* a stamp earned today thumps on once (rc §14.4) */
.stamp.is-fresh { animation: stamp 0.5s cubic-bezier(0.3, 1.6, 0.6, 1) 0.2s both; }
.device-tilt { margin-top: 2px; }
