:root {
  color-scheme: dark;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #000;
}

#stage, #three-stage, #film, #flash, #preview-end {
  position: fixed;
  inset: 0;
}

#stage { overflow: hidden; background: #000; }

#three-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  transition: opacity .32s ease;
}

#three-stage.film-on canvas { opacity: 0; }

#film {
  z-index: 2;
  display: grid;
  place-items: center;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transition: opacity .12s ease, visibility .12s ease;
  background: #000;
}

#film.on { opacity: 1; visibility: visible; }

#film-frame {
  position: relative;
  width: min(100vw, 100vh);
  aspect-ratio: 1;
  overflow: hidden;
  isolation: isolate;
  background: #000;
  background-image: url("./assets/nailong-first-frame.png");
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  transform-origin: 83.889% 57.778%;
  transition: transform .72s cubic-bezier(.16, .72, .25, 1);
}

#film-frame.exit-zoom { transform: scale(1.38); }

#film-canvas, #fallback-gif, #still-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: auto;
}

#film-canvas, #fallback-gif { visibility: hidden; }
#film.sprite-mode #film-canvas, #film.gif-fallback #fallback-gif { visibility: visible; }

#fallback-gif {
  position: absolute;
  inset: 0;
}

#still-image {
  position: absolute;
  inset: 0;
  visibility: hidden;
}

#still-image.on { visibility: visible; }

.film-grain {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 2;
  opacity: .17;
  background: repeating-linear-gradient(0deg, transparent 0 2px, #0006 2px 3px);
  mix-blend-mode: multiply;
}

#flash {
  z-index: 5;
  pointer-events: none;
  background: #fff;
  clip-path: circle(0 at var(--flash-x, 50%) var(--flash-y, 50%));
  transition: clip-path .68s cubic-bezier(.24, .8, .3, 1);
}

#flash.on { clip-path: circle(150vmax at var(--flash-x, 50%) var(--flash-y, 50%)); }

#preview-end {
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #fff;
  color: #111;
}

#preview-end[hidden] { display: none; }

.end-card {
  width: min(100%, 470px);
  text-align: center;
}

.end-eyebrow {
  display: inline-block;
  padding: 7px 12px;
  border: 1px solid #111;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
}

.end-card h1 {
  margin: 22px 0 10px;
  font-size: clamp(2.2rem, 9vw, 4.5rem);
  line-height: 1.07;
  letter-spacing: -.04em;
}

.end-card p { margin: 0; color: #515151; line-height: 1.7; }
.end-card strong { color: #111; }

.end-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 30px 0 18px;
}

.end-actions button, .end-actions a {
  min-height: 46px;
  padding: 12px 18px;
  border: 1px solid #111;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.end-actions button { background: #111; color: #fff; }
.end-actions a { background: #fff; color: #111; }
.end-actions button:hover { background: #333; }
.end-actions a:hover { background: #f3f3f3; }
.end-card small { color: #777; }

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

@media (max-aspect-ratio: 3/4) {
  #film-frame { box-shadow: 0 0 50px #0009; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; }
}
