:root {
  --ink: #140e0c;
  --gold: #e6d2a2;
  --gold-deep: #b9924e;
  --paper: #f3efe4;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--ink);
  color: var(--gold);
  font-family: "Songti SC", "STSong", "SimSun", "Noto Serif SC", serif;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

button {
  font-family: inherit;
}

#frame {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
}

#stage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1920px;
  height: 1080px;
  transform-origin: center center;
  overflow: hidden;
}

#track {
  display: flex;
  height: 1080px;
}

body.is-ready #track {
  transition: transform 0.86s cubic-bezier(0.76, 0, 0.18, 1);
}

.page {
  position: relative;
  flex: 0 0 1920px;
  width: 1920px;
  height: 1080px;
  overflow: hidden;
  background: var(--paper);
}

.layer {
  position: absolute;
  left: 0;
  top: 0;
  width: 1920px;
  height: auto;
  opacity: 0;
  pointer-events: none;
  -webkit-user-drag: none;
}

.layer.is-tall {
  top: auto;
  bottom: 0;
  height: auto;
}

.page.is-settled .layer {
  opacity: 1;
  transform: none;
  animation: none;
}

.page.is-active .layer {
  animation-fill-mode: both;
  animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
}

/* 苹果机直接显示，不做进场缩放，避免黑屏 */
body.is-ios .page.is-active .layer,
body.is-ios .page.is-settled .layer {
  opacity: 1;
  transform: none;
  animation: none;
}

.page.is-active .background {
  animation-name: bg-in;
  animation-duration: 1.15s;
  animation-delay: 0s;
}

.page.is-active .character {
  animation-name: character-in;
  animation-duration: 1.12s;
  animation-delay: 0.95s;
}

.page.is-active .text {
  animation-name: text-in;
  animation-duration: 0.92s;
  animation-delay: 1.48s;
}

.page.is-active .book {
  animation-name: book-in;
  animation-duration: 0.86s;
  animation-delay: 1.86s;
}

@keyframes bg-in {
  from { opacity: 0; transform: scale(1.065); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes character-in {
  from { opacity: 0; transform: translate3d(0, 78px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

@keyframes text-in {
  from { opacity: 0; transform: translate3d(0, 26px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

@keyframes book-in {
  from { opacity: 0; transform: translate3d(0, 18px, 0) scale(0.97); }
  to { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}

.arrow {
  position: fixed;
  top: 50%;
  z-index: 5;
  width: 52px;
  height: 52px;
  margin-top: -26px;
  border: 1px solid rgba(230, 210, 162, 0.7);
  border-radius: 50%;
  background: rgba(20, 14, 12, 0.38);
  color: var(--gold);
  cursor: pointer;
  backdrop-filter: blur(6px);
}

.arrow svg {
  width: 28px;
  height: 28px;
  display: block;
  margin: 0 auto;
}

#prev {
  left: calc(12px + constant(safe-area-inset-left));
  left: calc(12px + env(safe-area-inset-left));
}
#next {
  right: calc(12px + constant(safe-area-inset-right));
  right: calc(12px + env(safe-area-inset-right));
}

#top-actions {
  position: fixed;
  top: calc(12px + constant(safe-area-inset-top));
  top: calc(12px + env(safe-area-inset-top));
  right: calc(12px + constant(safe-area-inset-right));
  right: calc(12px + env(safe-area-inset-right));
  z-index: 14;
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  gap: 10px;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

#music,
#scroll-close {
  position: relative;
  top: auto;
  right: auto;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(230, 210, 162, 0.85);
  border-radius: 50%;
  background: rgba(20, 14, 12, 0.55);
  color: var(--gold);
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-appearance: none;
  appearance: none;
}

#music svg {
  width: 22px;
  height: 22px;
  display: block;
  margin: 0 auto;
}

#music.is-on svg {
  animation: music-spin 3.2s linear infinite;
}

#music:not(.is-on) {
  opacity: 0.55;
}

@keyframes music-spin {
  to { transform: rotate(360deg); }
}

.arrow:disabled {
  opacity: 0.28;
  cursor: default;
}

.arrow:not(:disabled):hover {
  background: rgba(20, 14, 12, 0.62);
}

#pager {
  position: fixed;
  left: 50%;
  bottom: calc(16px + constant(safe-area-inset-bottom));
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 5;
  display: flex;
  gap: 8px;
  transform: translateX(-50%);
}

#pager button {
  width: 8px;
  height: 8px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(230, 210, 162, 0.4);
  cursor: pointer;
}

#pager button.is-on {
  width: 22px;
  background: var(--gold);
}

#hint {
  position: fixed;
  left: 50%;
  bottom: 46px;
  z-index: 5;
  margin: 0;
  transform: translateX(-50%);
  color: rgba(243, 239, 228, 0.92);
  font-size: 14px;
  letter-spacing: 0.28em;
  text-indent: 0.28em;
  text-shadow: 0 1px 8px rgba(20, 14, 12, 0.45);
  animation: hint-out 5.2s ease forwards;
  pointer-events: none;
}

@keyframes hint-out {
  0%, 62% { opacity: 1; }
  100% { opacity: 0; }
}

#loader {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 50% 42%, rgba(120, 28, 24, 0.35), transparent 46%),
    var(--ink);
  transition: opacity 0.55s ease, visibility 0.55s ease;
}

#loader.is-done {
  opacity: 0;
  visibility: hidden;
}

.loader-panel {
  text-align: center;
}

.loader-title {
  margin: 0;
  font-size: 40px;
  letter-spacing: 0.42em;
  text-indent: 0.42em;
  color: var(--gold);
}

.loader-text {
  margin: 14px 0 18px;
  font-size: 14px;
  letter-spacing: 0.34em;
  text-indent: 0.34em;
  color: rgba(230, 210, 162, 0.72);
}

.loader-bar {
  width: 180px;
  height: 1px;
  margin: 0 auto;
  background: rgba(230, 210, 162, 0.25);
}

#loader-fill {
  display: block;
  width: 0;
  height: 100%;
  background: var(--gold-deep);
  transition: width 0.25s ease;
}

#rotate {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 30;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: rgba(20, 14, 12, 0.94);
  color: var(--gold);
  letter-spacing: 0.28em;
}

body.need-rotate #rotate {
  display: flex;
}

.phone {
  width: 42px;
  height: 70px;
  border: 2px solid var(--gold);
  border-radius: 8px;
  animation: turn-phone 1.6s ease-in-out infinite;
}

@keyframes turn-phone {
  0%, 30% { transform: rotate(0deg); }
  70%, 100% { transform: rotate(90deg); }
}

.hotspot {
  position: absolute;
  z-index: 4;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.book-hotspot {
  left: 1369px;
  top: 694px;
  width: 454px;
  height: 293px;
}

.sign-hotspot {
  left: 205px;
  top: 522px;
  width: 486px;
  height: 228px;
}

.tap-gif {
  position: absolute;
  left: 50%;
  top: 46%;
  width: 156px;
  height: 218px;
  object-fit: contain;
  opacity: 0;
  transform: translate(-51%, -55%);
  pointer-events: none;
  filter: drop-shadow(0 8px 12px rgba(20, 14, 12, 0.35));
}

.page.is-settled .tap-gif {
  opacity: 1;
}

.page.is-active .book-hotspot .tap-gif {
  animation: gif-in 0.45s ease 2.72s both;
}

.page.is-active .sign-hotspot .tap-gif {
  animation: gif-in 0.45s ease 1.2s both;
}

@keyframes gif-in {
  from { opacity: 0; transform: translate(-51%, -48%); }
  to { opacity: 1; transform: translate(-51%, -55%); }
}

#scroll-pop {
  position: absolute;
  inset: 0;
  z-index: 12;
}

#scroll-pop[hidden] {
  display: none;
}

.scroll-mask {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(12, 8, 6, 0.46);
  cursor: pointer;
}

#scroll-view {
  position: absolute;
  left: 0;
  top: 0;
  width: 1920px;
  height: 1080px;
  pointer-events: none;
}

#scroll-pop.is-open #scroll-view {
  animation: scroll-pop 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes scroll-pop {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

#scroll-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #f6edd4;
  font-size: 28px;
  line-height: 1;
  font-family: Arial, sans-serif;
}

#scroll-close[hidden] {
  display: none !important;
}

body.scroll-open #music {
  opacity: 1;
}

#start-play {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 8;
  width: 340px;
  height: 476px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  transform: translate(-51.3%, -55%);
  cursor: pointer;
  opacity: 0;
}

#start-play[hidden] {
  display: none;
}

body.show-start #start-play {
  animation: start-in 0.55s ease 1.05s forwards;
}

#start-play img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 10px 18px rgba(20, 14, 12, 0.3));
  pointer-events: none;
}

#start-play span {
  position: absolute;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  padding: 8px 22px 8px 28px;
  border-radius: 999px;
  background: rgba(20, 14, 12, 0.72);
  color: #f6edd4;
  font-size: 22px;
  letter-spacing: 0.32em;
  white-space: nowrap;
  pointer-events: none;
}

@keyframes start-in {
  from { opacity: 0; transform: translate(-51.3%, -50%); }
  to { opacity: 1; transform: translate(-51.3%, -55%); }
}

body.is-clean .arrow,
body.is-clean #pager,
body.is-clean #hint,
body.is-clean #start-play,
body.is-clean #top-actions {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  body.is-ready #track,
  .page.is-active .layer,
  #hint,
  .phone,
  #loader,
  #music svg,
  .tap-gif {
    animation: none !important;
    transition: none !important;
  }

  .page.is-active .layer,
  .page .layer {
    opacity: 1;
    transform: none;
  }

  .page.is-active .tap-gif {
    opacity: 1;
  }
}
