#stage.is-performing > :not(#draw-flow, #sound-toggle) { visibility: hidden; }
#draw-flow {
  position: absolute; inset: 0; z-index: 8; overflow: hidden; isolation: isolate;
  background-color: #fbf6ef; color: #523d32; font-family: var(--serif);
}
#draw-flow[hidden] { display: none; }
#draw-flow::selection { background: #e0c788; }
.book-art, .book-library, .book-aura, .book-binding, .arrival-art, .arrival-decor {
  position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none;
}
.book-art { overflow: hidden; background: #a48f99; }
.book-library { background: url("../assets/ceremony/library-unrated.webp") center / 100% 100%; }
.book-binding { perspective: 1300px; }
.book-leaf { position: absolute; top: 31.7708%; height: 44.2708%; background-size: 100% 100%; }
.book-leaf.left {
  left: 32.7035%; width: 17.3692%; transform-origin: right center;
  background-image: url("../assets/ceremony/cover-left.webp");
  animation: open-cover-left .9s cubic-bezier(.16,.7,.26,1) both;
}
.book-leaf.right {
  left: 50.0727%; width: 17.2965%; transform-origin: left center;
  background-image: url("../assets/ceremony/cover-right.webp");
  animation: open-cover-right .9s cubic-bezier(.16,.7,.26,1) both;
}
@keyframes open-cover-left { from { transform: rotateY(78deg); filter: brightness(.67); } to { transform: none; filter: none; } }
@keyframes open-cover-right { from { transform: rotateY(-78deg); filter: brightness(.72); } to { transform: none; filter: none; } }
.book-art[data-light="3"] { --book-color: 51, 158, 255; }
.book-art[data-light="4"] { --book-color: 176, 82, 255; }
.book-art[data-light="5"] { --book-color: 255, 165, 37; }
.book-aura { opacity: 0; }
.book-art[data-light] .book-aura {
  opacity: 1; transform-origin: 50% 53%;
  background: radial-gradient(ellipse 25% 37% at 50% 53%, rgba(var(--book-color), .98) 0%, rgba(var(--book-color), .58) 44%, transparent 100%),
    radial-gradient(ellipse 55% 59% at 50% 47%, rgba(var(--book-color), .45), transparent 88%);
  animation: book-bloom .82s cubic-bezier(.16,.75,.24,1) both;
}
.book-art[data-light] .book-aura::before {
  content: ""; position: absolute; inset: 0;
  background: conic-gradient(from -58deg at 50% 54%, transparent, rgba(var(--book-color), .72) 17deg,
    transparent 29deg, rgba(var(--book-color), .95) 39deg, transparent 48deg,
    rgba(var(--book-color), .9) 63deg, transparent 75deg, rgba(var(--book-color), .75) 91deg, transparent 119deg);
  mask-image: radial-gradient(ellipse 37% 57% at 50% 54%, black 10%, transparent 99%);
  filter: blur(4px);
}
.book-art[data-light] .book-binding {
  filter: drop-shadow(0 0 5px rgba(var(--book-color), 1)) drop-shadow(0 0 15px rgba(var(--book-color), .88));
}
.book-art[data-light] .book-binding::after {
  content: ""; position: absolute; inset: 28% 31% 22%; pointer-events: none;
  background: radial-gradient(ellipse 53% 26% at 50% 47%, rgba(var(--book-color), .55), transparent 100%);
  animation: book-bloom .6s ease-out both;
}
@keyframes book-bloom { from { opacity: 0; transform: scale(.58); } to { opacity: 1; transform: scale(1); } }
.book-open, .arrival-next {
  position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: transparent;
  display: flex; padding: 0; color: inherit; text-align: center; align-items: flex-end;
}
.book-open {
  justify-content: center; padding-bottom: 63px; color: #ffe9ad; font-size: 37px; font-weight: 500;
  letter-spacing: .035em; text-shadow: 0 2px 4px #594321, 0 0 12px #8c684c;
}
.book-open[hidden] { display: none; }
.ceremony-skip {
  position: absolute; top: 22px; right: 24px; z-index: 2; min-width: 127px; height: 46px;
  padding: 0 22px; border: 1px solid #bfa883; border-radius: 32px;
  color: #7d654c; background: #fbf6efdf; font-size: 25px;
  box-shadow: inset 0 0 0 3px #fff9f0b3, 0 2px 6px #76627559;
}
.ceremony-skip:hover { background: #fffbef; }
.book-open:focus-visible, .arrival-next:focus-visible { outline-offset: -5px; }
.ceremony-spark {
  position: absolute; left: var(--left); top: var(--top); width: 8px; height: 8px;
  background: url("../assets/chrome/star.png") center / contain no-repeat; pointer-events: none;
  filter: brightness(1.5) drop-shadow(0 0 3px #fff3c5); animation: page-spark 3.2s ease-in-out var(--delay) infinite;
}
@keyframes page-spark {
  0%,100% { opacity: .05; transform: translateY(8px) scale(.6); }
  50% { opacity: .9; transform: translateY(-8px) scale(1.2); }
}
.arrival-art { object-fit: cover; }
.arrival-decor { background: url("../assets/ceremony/watercolor.webp") left top / 34.16% auto no-repeat; }
.arrival-plaque {
  position: absolute; left: 36px; top: 415px; width: 579px; height: 323px;
  padding: 39px 57px 15px 96px; background: url("../assets/ceremony/nameplate.webp") center / 100% 100% no-repeat;
  animation: plaque-arrival .42s ease-out both;
}
@keyframes plaque-arrival { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.arrival-new { position: absolute; left: 155px; top: -51px; width: 208px; height: 97px; background: url("../assets/ceremony/new-seal.webp") center / contain no-repeat; }
.arrival-rating { height: 54px; display: flex; gap: 1px; align-items: center; }
.arrival-rating i { width: 50px; height: 51px; background: url("../assets/ceremony/rating-star.webp") center / contain no-repeat; }
.arrival-plaque h2 {
  font: 500 80px/1 Georgia, var(--serif); letter-spacing: .015em; white-space: nowrap; margin: 1px 0 11px;
  color: #4e382e;
}
.arrival-plaque h2:has(.model-name) { font-size: 53px; }
.arrival-plaque .model-name { font-size: 23px; margin-top: 2px; }
.arrival-role {
  display: inline-block; min-width: 244px; text-align: center; padding: 1px 28px 3px; border: 1px solid #c9bcb1; border-radius: 28px;
  background: #f5eee8d6; box-shadow: inset 0 0 0 2px #fffaf2, 0 2px 5px #715d5973;
  font-size: 24px; line-height: 31px; font-weight: 600;
}
.arrival-plaque p { font-size: 22px; line-height: 1.42; font-weight: 500; margin: 10px 0 0; }
.arrival-next { justify-content: flex-end; padding: 0 34px 22px; font-size: 22px; color: #937b54; text-shadow: 0 1px 4px #fffae3, 0 0 9px #fff8eb; }
#draw-flow[data-view="reveal"] .ceremony-skip { top: 29px; right: 30px; }
#stage:not(.portrait) .gallery-dock { opacity: 0; transition: opacity .2s; }
#stage.show-gallery-tools:not(.portrait) .gallery-dock, #stage:not(.portrait) .gallery-dock:hover, #stage:not(.portrait) .gallery-dock:focus-within { opacity: 1; }
@media (hover: none) { #stage:not(.portrait) .gallery-dock { opacity: .87; } }
.portrait .book-art { width: auto; left: 50%; right: auto; height: 100%; aspect-ratio: 1376/768; transform: translateX(-50%); }
.portrait .book-open { padding-bottom: 12%; font-size: 23px; }
.portrait .ceremony-skip, #stage.portrait #draw-flow .ceremony-skip { top: 17px; right: 15px; min-width: 70px; height: 34px; padding: 0 12px; font-size: 16px; }
.portrait .arrival-art, .portrait .arrival-decor { height: 81%; object-position: 70% center; }
.portrait .arrival-plaque { left: 50%; top: auto; bottom: 51px; width: 400px; height: 224px; padding: 27px 32px 8px 58px; transform: translateX(-50%); animation: none; }
.portrait .arrival-new { left: 108px; width: 144px; height: 67px; top: -35px; }
.portrait .arrival-rating { height: 36px; gap: 0; }
.portrait .arrival-rating i { width: 35px; height: 35px; }
.portrait .arrival-plaque h2 { font-size: 48px; margin: 2px 0 6px; }
.portrait .arrival-plaque h2:has(.model-name) { font-size: 34px; }
.portrait .arrival-plaque .model-name { font-size: 16px; }
.portrait .arrival-role { min-width: 0; font-size: 16px; line-height: 22px; padding-inline: 16px; }
.portrait .arrival-plaque p { font-size: 15px; margin-top: 7px; }
.portrait .arrival-next { padding: 0 22px 20px; font-size: 16px; }
@media (orientation: portrait) {
  .portrait #draw-flow[data-view="book"]::before {
    content: ""; position: absolute; inset: -14px; background: url("../assets/ceremony/library-unrated.webp") center / cover;
    filter: blur(12px) saturate(.72);
  }
  .portrait .book-art {
    width: 240%; height: auto; top: 46%; bottom: auto; aspect-ratio: 1376 / 768;
    transform: translate(-50%, -50%);
    mask-image: linear-gradient(to bottom, transparent, black 16%, black 80%, transparent);
  }
}

/* Use the same vignette as the card for a companion's first meeting. */
.arrival-art.is-companion {
  inset: 0 auto auto 69%; width: auto; height: 100%; transform: translateX(-50%); object-fit: contain;
  mask-image: linear-gradient(90deg, transparent, black 14%, black 87%, transparent),
    linear-gradient(0deg, transparent, black 9%);
  mask-composite: intersect;
  mix-blend-mode: multiply;
}
#draw-flow:has(.arrival-art.is-companion) {
  background: #faf6ee url("../assets/ceremony/watercolor.webp") left top / 39% auto no-repeat;
}
#draw-flow:has(.arrival-art.is-companion)::before {
  content: ""; position: absolute; inset: 0 -18% 0 18%; pointer-events: none;
  background: url("../assets/results/paper-unframed.webp") center / 100% 100%;
  opacity: .71; mask-image: linear-gradient(90deg, transparent, black 22%);
}
.arrival-art.is-companion + .arrival-decor { background: none; }
#draw-flow[data-rarity="3"] .arrival-rating { filter: saturate(.32) hue-rotate(130deg); }
#draw-flow[data-rarity="4"] .arrival-rating { filter: saturate(.57) hue-rotate(247deg); }
.portrait .arrival-art.is-companion {
  inset: 4% 0 auto; width: 100%; height: 75%; transform: none; object-fit: contain; object-position: center;
  mask-image: linear-gradient(to bottom, black 83%, transparent);
}
.portrait #draw-flow:has(.arrival-art.is-companion)::before {
  inset: 0 -64% 20%; background-size: auto 100%; opacity: .5;
}
#draw-flow:has(.arrival-art.is-first-meeting) { background: #faf5e6; }
#draw-flow:has(.arrival-art.is-first-meeting) .arrival-decor { background: none; }
.arrival-art.is-first-meeting {
  transform-origin: 69% 38%;
  animation: first-meeting-camera 3.4s cubic-bezier(.22,.58,.25,1) both;
}
@keyframes first-meeting-camera {
  from { opacity: .12; transform: scale(1.07); }
  to { opacity: 1; transform: scale(1); }
}
#draw-flow:has(.arrival-art.is-first-meeting) .arrival-plaque {
  animation: plaque-arrival .62s .29s ease-out both;
}
#draw-flow:has(.arrival-art.is-first-meeting) .ceremony-spark {
  filter: brightness(1.6) drop-shadow(0 0 3px #f4deb4);
}
#draw-flow:has(.arrival-art.is-first-meeting) .arrival-next { color: #785d39; }
.portrait .arrival-art.is-first-meeting {
  width: 100%; height: 100%; object-fit: cover; object-position: 69% 42%;
}
#stage.portrait #draw-flow:has(.arrival-art.is-first-meeting) .arrival-plaque {
  transform: translateX(-50%); animation: none;
}
@media (prefers-reduced-motion: reduce) {
  .arrival-art.is-first-meeting, #draw-flow:has(.arrival-art.is-first-meeting) .arrival-plaque {
    animation: none;
  }
}

#draw-flow[data-view="inspection"] .ceremony-skip { min-width: 143px; }
.portrait #draw-flow[data-view="inspection"] .ceremony-skip { min-width: 88px; }
