.intro-player {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.intro-player::backdrop { background: transparent; }
.intro-player[data-ending] { animation: intro-out .22s ease-in both; }
@keyframes intro-out { to { opacity: 0; } }

.intro-player-controls {
  position: absolute;
  top: max(.75rem, env(safe-area-inset-top));
  right: max(.75rem, env(safe-area-inset-right));
  z-index: 1;
  display: flex;
  gap: .4rem;
}
.intro-control {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  box-sizing: border-box;
  padding: .45rem .9rem;
  border: 1px solid #d8c6e8;
  border-radius: 999px;
  background: #fffafc;
  color: #53376b;
  font: 750 .9rem/1.2 "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  text-decoration: none;
  cursor: pointer;
}
.intro-control:hover { background: #f2e5fc; }
.intro-control:focus-visible, .intro-card-art:focus-visible { outline: 3px solid #7c49b1; outline-offset: 3px; }
.intro-control:disabled { opacity: .55; cursor: default; }

.intro-scene {
  position: absolute;
  inset: 0;
  overflow: hidden;
  isolation: isolate;
  container-type: size;
  background: var(--intro-sky);
  user-select: none;
  pointer-events: none;
}
.intro-backdrop { position: absolute; inset: 0; background: var(--intro-backdrop); }
.intro-art {
  position: absolute;
  top: 52%;
  left: 50%;
  width: min(92cqw, 120cqh);
  height: min(85cqh, 115cqw);
  translate: -50% -50%;
}
.intro-set, .intro-glints, .intro-ground { position: absolute; inset: 0; }
.intro-set i, .intro-glints i { position: absolute; display: block; }
.intro-glints i {
  top: var(--y);
  left: var(--x);
  translate: -50% -50%;
  color: var(--glint);
  opacity: .76;
  font: 700 min(5cqw, 6cqh)/1 system-ui, sans-serif;
  text-shadow: 0 0 .5em var(--glint-shadow);
}
.intro-glints i:nth-child(1) { --x: 11%; --y: 37%; --glint-delay: .46s; }
.intro-glints i:nth-child(2) { --x: 21%; --y: 28%; --glint-delay: .62s; }
.intro-glints i:nth-child(3) { --x: 91%; --y: 46%; --glint-delay: .72s; }
.intro-glints i:nth-child(4) { --x: 78%; --y: 31%; --glint-delay: .94s; }
.intro-glints i:nth-child(5) { --x: 92%; --y: 74%; --glint-delay: 1.05s; }
.intro-glints i:nth-child(6) { --x: 7%; --y: 68%; --glint-delay: 1.12s; }
.intro-glints i:nth-child(7) { --x: 52%; --y: 53%; --glint-delay: 1.22s; }
.intro-glints i:nth-child(8) { --x: 50%; --y: 72%; --glint-delay: 1.32s; }
.intro-ground {
  inset: auto 14% 1% 14%;
  height: 9%;
  background: radial-gradient(ellipse, var(--ground) 0%, transparent 72%);
}
.intro-child {
  position: absolute;
  bottom: 4%;
  left: 50%;
  height: 66%;
  aspect-ratio: 560 / 1024;
  overflow: hidden;
  transform-origin: 50% 95%;
  filter: drop-shadow(0 .25cqh .4cqh #2b163939);
}
.intro-child img {
  position: absolute;
  top: 0;
  left: var(--sprite-offset);
  width: 274.286%;
  max-width: none;
  height: 100%;
}
.intro-girl { --sprite-offset: -19%; --side: -1; --entrance-delay: .28s; translate: -106% 0; }
.intro-boy { --sprite-offset: -160%; --side: 1; --entrance-delay: .47s; translate: 6% 0; }
.intro-title {
  position: absolute;
  inset: 2% 0 auto;
  display: block;
  width: min(96%, 105cqh);
  height: auto;
  margin-inline: auto;
  filter: drop-shadow(0 .45cqh .55cqh #27122c55);
}
/* Facing paper pages, a gold corner frame and a leaf that turns away. */
[data-intro="storybook"] {
  --intro-sky: #ffe6a9;
  --intro-backdrop: radial-gradient(ellipse at 50% 46%, #fff1ca 24%, #f9c78b 73%, #cc8263 135%);
  --glint: #fffbdf;
  --glint-shadow: #bb741c;
  --ground: #a7684d70;
  --child-entry: intro-step;
}
[data-intro="storybook"] .intro-set {
  inset: -3% -10% -1%;
  border: max(2px, .55cqh) solid #bb744c;
  border-radius: 11% 11% 5% 5% / 6% 6% 4% 4%;
  background:
    linear-gradient(90deg, #b7753729, transparent 9% 45%, #78451625 49.6%, #a766332f 50%, #fff8df96 50.6%, transparent 55% 92%, #ac673422),
    radial-gradient(ellipse at 51% 32%, #fff8de, #fee9ae 72%, #f6cca0);
  box-shadow: 0 .7cqh 0 #fee0ae, 0 1.3cqh 0 #a85c41, 0 2.4cqh 4cqh #a65e4664;
}
[data-intro="storybook"] .intro-set i:first-child {
  inset: 4%;
  border: 1px solid #c38748a1;
  border-radius: inherit;
  box-shadow: inset 0 0 0 .42cqh #fff6d185;
}
[data-intro="storybook"] .intro-set i:nth-child(2) {
  inset: 2% 3%;
  border: 1px dashed #c98e507e;
  border-radius: inherit;
}
[data-intro="storybook"] .intro-leaf {
  position: absolute;
  inset: 0 0 0 50%;
  opacity: 0;
  transform-origin: left center;
  background: linear-gradient(100deg, #d79158, #fff0c6 20%, #f9d496 95%, #e5a365);
}

/* Broken pastel streaks cross over the paper before the children hop in. */
[data-intro="rainbow"] {
  --intro-sky: #fff4ec;
  --intro-backdrop:
    radial-gradient(ellipse at 5% 10%, #efb9dba1, transparent 48%),
    radial-gradient(ellipse at 100% 100%, #b1e3ffd1, transparent 45%),
    radial-gradient(ellipse at 94% 0%, #ffe097b0, transparent 44%),
    #fff7ef;
  --glint: #c0599e;
  --glint-shadow: #fffff0;
  --ground: #a95dae50;
  --child-entry: intro-hop;
}
[data-intro="rainbow"] .intro-set { inset: 19% -10% 5%; rotate: -13deg; }
[data-intro="rainbow"] .intro-set i {
  left: var(--left);
  top: var(--top);
  width: var(--width);
  height: 34%;
  border-radius: 13% 9% 14% 8% / 44% 41% 41% 46%;
  background:
    repeating-linear-gradient(1deg, #fff9 0 1px, transparent 1px 4px, #fff4 4px 5px, transparent 5px 8px),
    linear-gradient(90deg, transparent, var(--crayon) 11% 89%, transparent);
  box-shadow: inset 0 .3cqh .32cqh #fff8, inset 0 -.25cqh .45cqh #fff9;
}
[data-intro="rainbow"] .intro-set i:nth-child(1) { --left: 2%; --top: 5%; --width: 94%; --crayon: #f997c4c9; --stroke-delay: 0s; }
[data-intro="rainbow"] .intro-set i:nth-child(2) { --left: 7%; --top: 31%; --width: 92%; --crayon: #ffcb6ace; --stroke-delay: .13s; }
[data-intro="rainbow"] .intro-set i:nth-child(3) { --left: 0%; --top: 58%; --width: 100%; --crayon: #90d9dbd9; --stroke-delay: .24s; }
[data-intro="rainbow"] .intro-boy { --entrance-delay: .35s; }

/* A blue-violet portal with two orbit lines and a halo behind the ring. */
[data-intro="starlight"] {
  --intro-sky: #221947;
  --intro-backdrop:
    radial-gradient(ellipse at 19% 79%, #5a368474, transparent 56%),
    radial-gradient(ellipse at 85% 20%, #284d867a, transparent 62%),
    radial-gradient(ellipse at 50% 44%, #4b3b83, #201439 74%);
  --glint: #ffeab2;
  --glint-shadow: #ffd37e;
  --ground: #ce9bff86;
  --child-entry: intro-float;
}
[data-intro="starlight"] .intro-set i:first-child {
  inset: 18% auto 6%;
  left: 50%;
  translate: -50%;
  aspect-ratio: 1;
  border: .55cqh solid #ecddff;
  border-radius: 50%;
  background: radial-gradient(ellipse at 48% 80%, #c37bf8d9, #7f64dcb8 47%, #50359dae 72%);
  box-shadow: 0 0 1.5cqh #d0a1ff, 0 0 5.5cqh #9b79fb, inset 0 0 2.2cqh #bef6ffd9;
}
[data-intro="starlight"] .intro-set i:nth-child(2),
[data-intro="starlight"] .intro-set i:nth-child(3) {
  inset: 35% 4% 21%;
  rotate: -19deg;
  border: .16cqh solid #cda9ffac;
  border-radius: 50%;
  box-shadow: 0 0 1.2cqh #b693ff82;
}
[data-intro="starlight"] .intro-set i:nth-child(3) { inset: 38% 2% 18%; rotate: 15deg; opacity: .54; }
[data-intro="starlight"] .intro-girl { --entrance-delay: .48s; }
[data-intro="starlight"] .intro-boy { --entrance-delay: .64s; }

@media (prefers-reduced-motion: no-preference) {
  .intro-scene[data-playing] .intro-child { animation: var(--child-entry) 1.46s var(--entrance-delay) both; }
  .intro-scene[data-playing] .intro-title { animation: intro-title-in .81s .94s both; }
  .intro-scene[data-playing] .intro-ground { animation: intro-ground-in .64s .44s both; }
  .intro-scene[data-playing] .intro-glints i { animation: intro-glint 1.32s var(--glint-delay) both; }
  [data-intro="storybook"][data-playing] .intro-set { animation: intro-book .72s both; }
  [data-intro="storybook"][data-playing] .intro-leaf { animation: intro-turn .76s both; }
  [data-intro="rainbow"][data-playing] .intro-set i { animation: intro-pigment .63s var(--stroke-delay) both; }
  [data-intro="starlight"][data-playing] .intro-set { animation: intro-portal .93s both; }
}
@keyframes intro-ground-in { from { opacity: 0; scale: .62; } }
@keyframes intro-book { from { opacity: 0; transform: perspective(65cqh) rotateX(26deg) scale(.83); } }
@keyframes intro-turn {
  0% { opacity: 1; transform: perspective(95cqh) rotateY(0); }
  62% { opacity: 1; }
  100% { opacity: 0; transform: perspective(95cqh) rotateY(-92deg); }
}
@keyframes intro-pigment {
  from { clip-path: inset(0 100% 0 0); opacity: .35; }
  to { clip-path: inset(0); opacity: 1; }
}
@keyframes intro-portal {
  0% { opacity: 0; transform: scale(.28) rotate(-17deg); }
  65% { opacity: 1; transform: scale(1.04) rotate(3deg); }
  100% { transform: none; }
}
@keyframes intro-step {
  0% { opacity: 0; transform: translate(calc(var(--side) * 72%), 13%) rotate(calc(var(--side) * 9deg)); }
  27% { opacity: 1; transform: translate(calc(var(--side) * 27%), -5%) rotate(calc(var(--side) * -5deg)); }
  47% { transform: translate(calc(var(--side) * 7%), 1%) rotate(calc(var(--side) * 3deg)); }
  65% { transform: translateY(-2%) rotate(calc(var(--side) * -3deg)); }
  82% { transform: rotate(calc(var(--side) * 1.4deg)); }
  100% { transform: none; }
}
@keyframes intro-hop {
  0% { opacity: 0; transform: translate(calc(var(--side) * 41%), 43%) scale(.82); }
  31% { opacity: 1; transform: translate(calc(var(--side) * 7%), -9%) rotate(calc(var(--side) * -7deg)); }
  55% { transform: scale(1.04, .965) rotate(calc(var(--side) * 3deg)); }
  72% { transform: translateY(-3%) rotate(calc(var(--side) * -2deg)); }
  100% { transform: none; }
}
@keyframes intro-float {
  0% { opacity: 0; transform: translate(calc(var(--side) * -25%), -33%) scale(.79) rotate(calc(var(--side) * -9deg)); }
  41% { opacity: 1; }
  71% { transform: translateY(1%) rotate(calc(var(--side) * 3deg)); }
  87% { transform: translateY(-1%) rotate(calc(var(--side) * -1.5deg)); }
  100% { transform: none; }
}
@keyframes intro-title-in {
  0% { opacity: 0; transform: translateY(23%) scale(.82); }
  65% { opacity: 1; transform: translateY(-3%) scale(1.035); }
  100% { transform: none; }
}
@keyframes intro-glint {
  0% { opacity: 0; scale: .1; rotate: -32deg; }
  47% { opacity: 1; scale: 1.32; rotate: 7deg; }
  100% { opacity: .76; scale: 1; }
}

/* Preview and startup preference. */
.intro-gallery {
  min-height: 100dvh;
  margin: 0;
  background: radial-gradient(ellipse at 15% 0%, #fff1d9, transparent 52%), #f8f1ff;
  color: #372548;
  font: 400 1rem/1.55 "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
}
.intro-gallery main { width: min(72rem, calc(100% - 2rem)); margin-inline: auto; padding-block: clamp(1.25rem, 5vw, 4.25rem) 2rem; }
.intro-gallery-header { display: flex; justify-content: space-between; align-items: end; flex-wrap: wrap; gap: .75rem; }
.intro-gallery-header p, .intro-gallery-footer p { margin: 0; }
.intro-gallery-brand { display: flex; align-items: center; gap: .45rem; color: #754485; font-weight: 800; }
.intro-gallery h1 { margin: .55rem 0 .2rem; font-size: clamp(1.75rem, 5vw, 3rem); line-height: 1.25; letter-spacing: -.055em; }
.intro-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(.85rem, 2vw, 1.35rem); margin-top: 1.5rem; }
.intro-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  border: 1px solid #e8d5ee;
  border-radius: 1.3rem;
  background: #fffafd;
  box-shadow: 0 12px 28px #58346812;
}
.intro-card-art {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  padding: 0;
  border: 0;
  background: #eee1f0;
  cursor: pointer;
}
.intro-card-art:focus-visible { outline-offset: -4px; }
.intro-card-play {
  position: absolute;
  right: .65rem;
  bottom: .65rem;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid #fffc;
  border-radius: 50%;
  background: #fff9f4ee;
  color: #603b80;
  box-shadow: 0 2px 12px #2e18422e;
}
.intro-card-art:hover .intro-card-play { background: #fff; color: #32154a; }
.intro-card-content { display: flex; flex: 1; flex-direction: column; align-items: start; padding: .9rem 1rem 1rem; }
.intro-card-content h2 { margin: 0; font-size: 1.22rem; }
.intro-card-content p { margin: .28rem 0 .8rem; color: #604d6e; word-break: keep-all; }
.intro-select { margin-top: auto; }
.intro-select[aria-pressed="true"] { border-color: #755196; background: #755196; color: #fff; }
.intro-gallery-footer { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem; margin-top: 1.1rem; }

@media (max-width: 720px) {
  .intro-cards { grid-template-columns: 1fr; }
}
@media (max-aspect-ratio: 4/5) {
  .intro-player .intro-art { top: 50%; }
}
