@keyframes effect-arrival { from { opacity: 0; } }
[data-recent-completion] .complete-label { animation: stamp-in .42s .2s ease-out both; }
[data-new-episode] { position: relative; }
[data-new-episode]::after {
  position: absolute;
  inset: 2px;
  border: 2px solid #fcca55;
  border-radius: inherit;
  box-shadow: 0 0 13px #eec050, inset 0 0 0 2px #fff1b1;
  pointer-events: none;
  opacity: 0;
  content: "";
  animation: unlock-glow .66s .2s ease-out both;
}
@keyframes unlock-glow {
  0% { opacity: 0; transform: scale(.97); }
  30%, 55% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.045); }
}
@keyframes stamp-in {
  from { opacity: 0; transform: translateY(-.35rem) scale(1.23); }
  70% { transform: translateY(.04rem) scale(.95); }
  to { opacity: 1; transform: none; }
}

.fill-effect {
  pointer-events: none;
  position: absolute;
  z-index: 1;
  width: 33px;
  height: 33px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--fill-color), 0 0 0 3px #694a9260;
  opacity: 0;
  animation: fill-ring .38s ease-out both;
}
.fill-dot { width: 17px; height: 17px; background: #ffffffa0; animation-duration: .25s; }
.fill-spark { width: 38px; height: 38px; animation-duration: .42s; }
.fill-spark i { position: absolute; color: #fff6ba; text-shadow: 0 1px 2px #633a92; font-style: normal; }
.fill-spark i:nth-child(1) { top: -11px; right: -6px; }
.fill-spark i:nth-child(2) { top: 15px; left: -12px; }
.fill-spark i:nth-child(3) { bottom: -11px; right: 0; }
@keyframes fill-ring {
  from { opacity: 1; transform: translate(-50%, -50%) scale(.36); }
  to { opacity: 0; transform: translate(-50%, -50%) scale(1.75); }
}

.celebration { position: absolute; z-index: 2; inset: 0; border-radius: inherit; pointer-events: none; }
.celebration-frame, .celebration-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.celebration-frame {
  border: clamp(3px, .7vw, 7px) solid #f9c66a;
  border-radius: inherit;
  box-shadow: inset 0 0 0 2px #fff5b4;
  animation: effect-arrival .25s ease-out both;
}
.celebration[data-finale="true"] .celebration-frame {
  border-color: #ff92b8 #a998fa #a3e7c2 #ffe182;
}
@supports (mask-composite: exclude) {
  .celebration[data-finale="true"] .celebration-frame {
    border-color: transparent;
    background: linear-gradient(115deg, #ff92b8, #ffe182, #a3e7c2, #a998fa) border-box;
    mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
  }
}
.celebration-badge {
  position: absolute;
  top: clamp(.55rem, 1.7vw, 1.2rem);
  left: 50%;
  display: flex;
  gap: .42em;
  align-items: center;
  padding: .38em .8em;
  border: 2px solid #db9d39;
  border-radius: 1rem;
  background: linear-gradient(#fff9d5, #ffe291);
  color: #5e346b;
  box-shadow: 0 3px 11px #42265046, inset 0 0 0 1px #fff8d8;
  font-size: clamp(.94rem, 2.9vw, 1.65rem);
  font-weight: 900;
  white-space: nowrap;
  transform: translateX(-50%);
  animation: badge-arrival .40s cubic-bezier(.17,.72,.30,1.35) both;
}
.celebration-badge > span { color: #a26212; }
@keyframes badge-arrival { from { opacity: 0; transform: translate(-50%, -.65rem) scale(.8); } }
.studio-actions [data-action="undo"] span { display: inline-block; }
.download-check {
  position: absolute;
  top: .3rem;
  right: .4rem;
  display: none;
  width: 1.1rem;
  height: 1.1rem;
  place-items: center;
  border-radius: 50%;
  background: #e1f2d5;
  color: #2a694d;
  font-size: .8rem;
}
[data-png-ready] .download-check { display: grid; }
.capture-shutter { display: none; }
.sheet[data-capturing] .capture-shutter {
  position: absolute;
  z-index: 6;
  inset: 0;
  display: block;
  pointer-events: none;
}
.capture-shutter::before, .capture-shutter::after {
  position: absolute;
  inset: 0 0 auto;
  height: 50.5%;
  background: linear-gradient(#48345f, #281836);
  transform: translateY(var(--shutter-offset));
  animation: capture-shutter-slide var(--capture-duration) ease-in-out both;
  content: "";
}
.capture-shutter::before { --shutter-offset: -100%; }
.capture-shutter::after {
  --shutter-offset: 100%;
  inset: auto 0 0;
  background: linear-gradient(#281836, #48345f);
}
@keyframes capture-shutter-slide {
  0%, 100% { transform: translateY(var(--shutter-offset)); }
  40%, 56% { transform: translateY(0); }
}
.progress-spark {
  position: absolute;
  top: 0;
  left: clamp(.6rem, var(--painted-percent, 0%), calc(100% - .6rem));
  color: #be7a12;
  text-shadow: 0 0 5px #ffd77a, 0 0 9px #fff1a4;
  pointer-events: none;
  opacity: 0;
  animation: progress-sparkle .53s ease-out both;
}
.progress-spark[data-progress-feedback="first"] { font-size: .85em; }
@keyframes progress-sparkle {
  0% { opacity: 0; transform: translate(-50%, 5px) scale(.5); }
  30%, 55% { opacity: 1; transform: translate(-50%, -4px) scale(1.2); }
  100% { opacity: 0; transform: translate(-50%, -13px) scale(.85); }
}
.story-teaser { display: flex; gap: .55rem; align-items: center; }
.story-teaser img {
  width: clamp(67px, 19vw, 95px);
  height: auto;
  flex: none;
  border: 1px solid #d8bbee;
  border-radius: .5rem;
  background: #fff;
}
.scene-story:not([hidden]) { animation: story-open .27s ease-out both; transform-origin: center bottom; }
@keyframes story-open {
  from { opacity: .35; transform: translate(-50%, .6rem) scale(.975); }
}
.story-ending[data-unlocked] h3 { color: #713a8c; }
.story-ending[data-unlocked] .story-teaser img {
  outline: 2px solid #f8d47c;
  animation: next-picture-in .4s .08s ease-out both;
}
@keyframes next-picture-in {
  from { opacity: .35; transform: translateX(-.35rem) scale(.92); }
}

.sheet[data-episode-departure], .studio-page[data-episode-arrival] .sheet {
  --sketch-turn-out: .50s;
  --sketch-turn-in: .40s;
  perspective: 1350px;
  perspective-origin: 50% 0;
  background: linear-gradient(105deg, #fffaf0, #f5edf9 90%);
}
.sheet[data-episode-departure] .page-surface {
  animation: sketch-page-out var(--sketch-turn-out) calc(var(--episode-advance-delay) - var(--sketch-turn-out)) ease-in both;
}
.studio-page[data-episode-arrival] .sheet .page-surface { opacity: 0; }
.studio-page[data-episode-arrival] .sheet[aria-busy="false"]:not([data-episode-departure]) .page-surface {
  animation: sketch-page-in var(--sketch-turn-in) cubic-bezier(.2,.65,.28,1) both;
}
@keyframes sketch-page-out {
  from { transform: none; }
  to { transform: rotateX(89deg); }
}
@keyframes sketch-page-in {
  from { opacity: .42; transform: rotateX(-67deg); }
  to { opacity: 1; transform: none; }
}

.sheet[data-episode-departure] .page-surface::after,
.studio-page[data-episode-arrival] .page-surface::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(#62437878, #b583a933 32%, #fff5d16b);
  opacity: 0;
  pointer-events: none;
  content: "";
}
.sheet[data-episode-departure] .page-surface::after {
  animation: sketch-shade-out var(--sketch-turn-out) calc(var(--episode-advance-delay) - var(--sketch-turn-out)) ease-in both;
}
.studio-page[data-episode-arrival] .sheet[aria-busy="false"]:not([data-episode-departure]) .page-surface::after {
  animation: sketch-shade-in var(--sketch-turn-in) ease-out both;
}
@keyframes sketch-shade-out { from { opacity: 0; } to { opacity: .85; } }
@keyframes sketch-shade-in { from { opacity: .8; } to { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .studio-page[data-episode-arrival] .sheet .page-surface { opacity: 1; }
}
