:root {
  color-scheme: light dark;
  font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", system-ui, sans-serif;
  background: #111;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #111;
  touch-action: none;
}

button {
  font: inherit;
}

.experience {
  position: relative;
  display: grid;
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 35%, #292929 0, #151515 48%, #080808 100%);
}

.book {
  --turn: 0;
  --fold-x: 100%;
  --fold-tilt: -1.5deg;
  position: relative;
  width: min(100vw, 75dvh, 75vh);
  height: min(100dvh, 100vh, 133.333vw);
  aspect-ratio: 3 / 4;
  max-width: 100vw;
  max-height: 100dvh;
  overflow: hidden;
  isolation: isolate;
  background: #eeeae1;
  box-shadow: 0 0 52px rgb(0 0 0 / 55%);
  perspective: 1500px;
  perspective-origin: 50% 50%;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

@media (orientation: landscape) {
  .book {
    width: min(75dvh, 75vh);
    height: min(100dvh, 100vh);
  }
}

.page,
.page__face,
.page__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.book::after {
  position: absolute;
  z-index: 7;
  inset: 0;
  content: "";
  visibility: hidden;
  opacity: 0;
  background: rgb(0 0 0 / 58%);
  transition: opacity 360ms ease, visibility 360ms;
  pointer-events: none;
}

.book.has-ticket::after {
  visibility: visible;
  opacity: 1;
}

.page {
  overflow: hidden;
}

.page--under {
  z-index: 1;
  transform: none;
  filter: brightness(calc(.72 + var(--turn) * .28));
}

.book.is-settling .page--under {
  z-index: 5;
  transform: none;
  filter: none;
}

.book.is-settling .page--under::after {
  opacity: 0;
}

.page--under::after {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
  background: linear-gradient(90deg, rgb(0 0 0 / 22%), transparent 22%);
  opacity: calc(1 - var(--turn));
}

.book.is-backward .page--under::after {
  background: linear-gradient(270deg, rgb(0 0 0 / 22%), transparent 22%);
}

.book.is-curling .page--under::after {
  display: none;
}

.page--turning {
  z-index: 3;
  overflow: visible;
  will-change: opacity;
}

.book.is-curling .page--turning {
  opacity: 0;
}

.curl-canvas {
  position: absolute;
  z-index: 4;
  inset: 0;
  width: 100%;
  height: 100%;
  visibility: hidden;
  pointer-events: none;
}

.book.is-curling .curl-canvas {
  visibility: visible;
}

.book.is-curling .book__fold-shadow {
  display: none;
}

.page__face {
  overflow: hidden;
}

.page__face--front {
  z-index: 2;
}

.page__video {
  display: block;
  object-fit: cover;
  pointer-events: none;
  background: #eeeae1;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.population-bubble {
  position: absolute;
  z-index: 4;
  top: 72.5%;
  left: 3.2%;
  display: none;
  width: 63%;
  aspect-ratio: 4574 / 648;
  filter: drop-shadow(4px 5px 0 rgb(0 0 0 / 28%));
  pointer-events: none;
}

.population-bubble.is-visible {
  display: block;
  animation: bubble-enter 520ms 280ms both;
}

.population-bubble img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.population-bubble__number {
  position: absolute;
  z-index: 1;
  top: 40.5%;
  left: 35.5%;
  color: #acf651;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
  font-size: clamp(17px, 4.8vw, 38px);
  font-weight: 800;
  line-height: .86;
  letter-spacing: -.04em;
  text-shadow:
    .7px .7px 0 #111,
    -.7px .7px 0 #111,
    .7px -.7px 0 #111,
    -.7px -.7px 0 #111;
  transform: translate(-50%, -50%);
}

.page__edge,
.page__face--back {
  display: none;
}

.page__back-art {
  position: absolute;
  inset: -3%;
  background:
    linear-gradient(18deg, transparent 47%, rgb(58 58 58 / 18%) 48% 49%, transparent 50%) 0 0 / 42% 23%,
    radial-gradient(circle, rgb(20 20 20 / 19%) 0 1px, transparent 1.4px) 0 0 / 5px 5px,
    repeating-linear-gradient(0deg, transparent 0 8%, rgb(80 80 80 / 13%) 8.3% 8.8%),
    #e8e5dd;
  filter: grayscale(1) contrast(.72) opacity(.62);
  transform: scaleX(-1);
}

.page__back-shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgb(0 0 0 / 32%), transparent 16%, rgb(255 255 255 / 48%) 54%, rgb(0 0 0 / 12%));
  mix-blend-mode: multiply;
}

.page__back-shade::after {
  position: absolute;
  inset: -8% -16%;
  content: "";
  background:
    radial-gradient(ellipse at 86% 50%, transparent 0 38%, rgb(0 0 0 / 24%) 62%, transparent 76%);
  transform: rotate(-2deg);
}

.book.is-backward .page__back-shade::after {
  background:
    radial-gradient(ellipse at 14% 50%, transparent 0 38%, rgb(0 0 0 / 24%) 62%, transparent 76%);
  transform: rotate(2deg);
}

.book__fold-shadow {
  position: absolute;
  z-index: 2;
  top: 0;
  left: 0;
  width: clamp(40px, 16vw, 130px);
  height: 100%;
  opacity: calc(var(--turn) * .85);
  background: linear-gradient(90deg, rgb(0 0 0 / 48%), rgb(0 0 0 / 12%) 55%, transparent);
  filter: blur(2px);
  pointer-events: none;
}

.book.is-backward .book__fold-shadow {
  left: auto;
  right: 0;
  background: linear-gradient(270deg, rgb(0 0 0 / 48%), rgb(0 0 0 / 12%) 55%, transparent);
}

.progress {
  position: absolute;
  z-index: 8;
  top: max(18px, env(safe-area-inset-top));
  right: max(18px, env(safe-area-inset-right));
  display: flex;
  gap: 7px;
}

.progress__dot {
  width: 9px;
  height: 9px;
  padding: 0;
  border: 1.5px solid #171717;
  border-radius: 50%;
  background: #efede6;
  box-shadow: 0 1px 0 rgb(255 255 255 / 55%);
  transition: transform 180ms ease, background 180ms ease;
}

.progress__dot.is-active {
  transform: scale(1.12);
  background: #91d627;
}

.sound {
  position: absolute;
  z-index: 8;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  display: grid;
  width: 38px;
  height: 38px;
  padding: 8px;
  border: 2px solid #151515;
  border-radius: 50%;
  color: #151515;
  background: rgb(239 237 230 / 92%);
  place-items: center;
  cursor: pointer;
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  -webkit-tap-highlight-color: transparent;
}

@supports (backdrop-filter: blur(5px)) or (-webkit-backdrop-filter: blur(5px)) {
  .sound {
    background: rgb(239 237 230 / 78%);
  }
}

.sound:focus-visible {
  outline: 3px solid #91d627;
  outline-offset: 4px;
}

.sound svg {
  width: 100%;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.sound.is-muted::after {
  position: absolute;
  width: 25px;
  height: 2px;
  content: "";
  transform: rotate(-45deg);
  background: currentColor;
}

.book__hint {
  position: absolute;
  z-index: 7;
  right: 7%;
  bottom: max(28px, calc(env(safe-area-inset-bottom) + 18px));
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 8px 12px 9px;
  border: 2px solid #171717;
  color: #171717;
  background: rgb(244 241 233 / 96%);
  box-shadow: 3px 3px 0 rgb(23 23 23 / 78%);
  font-size: clamp(11px, 3.2vw, 13px);
  font-weight: 700;
  letter-spacing: .08em;
  opacity: 0;
  pointer-events: none;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

@supports (backdrop-filter: blur(4px)) or (-webkit-backdrop-filter: blur(4px)) {
  .book__hint {
    background: rgb(244 241 233 / 88%);
  }
}

.book__hint span {
  width: 42px;
  height: 18px;
  border-bottom: 2px solid currentColor;
  border-left: 2px solid currentColor;
  transform: skewX(-28deg);
}

.book__hint.is-visible {
  animation:
    hint-in 360ms both,
    hint-float 1.4s 360ms ease-in-out infinite;
}

.start {
  position: absolute;
  z-index: 20;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  width: 100%;
  border: 0;
  color: #f5f2e9;
  background:
    radial-gradient(circle at 50% 42%, rgb(145 214 39 / 16%), transparent 28%),
    #111;
  transition: opacity 500ms ease, visibility 500ms;
}

.start__mark {
  color: #91d627;
  font-size: clamp(70px, 20vw, 132px);
  font-weight: 900;
  line-height: .8;
}

.start__title {
  margin-top: 24px;
  font-size: clamp(26px, 8vw, 48px);
  font-weight: 900;
  letter-spacing: .14em;
  text-indent: .14em;
}

.start__action {
  margin-top: 34px;
  padding: 10px 24px;
  border: 2px solid #91d627;
  color: #91d627;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .2em;
  text-indent: .2em;
}

.start.is-hidden {
  visibility: hidden;
  opacity: 0;
}

.invitation {
  position: absolute;
  z-index: 9;
  left: 50%;
  bottom: max(7.2%, calc(env(safe-area-inset-bottom) + 20px));
  display: none;
  width: min(78%, 620px);
  padding: 0;
  border: 0;
  background: transparent;
  filter: drop-shadow(0 7px 5px rgb(0 0 0 / 28%));
  transform: translateX(-50%);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.invitation img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
}

.invitation.is-visible {
  display: block;
  animation:
    invitation-in 420ms both,
    invitation-float 1.8s 420ms ease-in-out infinite;
}

.invitation:focus-visible {
  outline: 3px solid #91d627;
  outline-offset: 6px;
}

.invitation:active {
  filter: drop-shadow(0 3px 2px rgb(0 0 0 / 24%));
}

.invitation.is-clicked {
  animation:
    invitation-click 320ms ease-out,
    invitation-float 1.8s 320ms ease-in-out infinite;
}

.ending-actions {
  position: absolute;
  z-index: 10;
  left: 50%;
  bottom: max(1.8%, calc(env(safe-area-inset-bottom) + 4px));
  display: none;
  width: 58%;
  gap: 7px;
  transform: translateX(-50%);
}

.ticket-overlay {
  position: absolute;
  z-index: 8;
  inset: 0;
  display: grid;
  visibility: hidden;
  padding: 8% 7% 20%;
  opacity: 0;
  place-items: center;
  pointer-events: none;
  transition: opacity 360ms ease, visibility 360ms;
}

.ticket-overlay.is-visible {
  visibility: visible;
  opacity: 1;
}

.ticket-overlay img {
  display: block;
  width: min(91%, 680px);
  max-height: 74%;
  object-fit: contain;
  filter: drop-shadow(0 12px 20px rgb(0 0 0 / 42%));
}

.ending-actions.is-visible {
  display: grid;
  grid-template-columns: 1fr 1fr;
  animation: ending-actions-in 260ms both;
}

.ending-action {
  min-height: 34px;
  padding: 5px 8px;
  border: 2px solid #151515;
  color: #151515;
  background: #f6f2e8;
  box-shadow: 3px 3px 0 #151515;
  font-size: clamp(10px, 2.8vw, 14px);
  font-weight: 900;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.ending-action:focus-visible {
  outline: 3px solid #91d627;
  outline-offset: 3px;
}

.ending-action--replay {
  background: #acf651;
}

.ending-action:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 #151515;
}

.book.is-turning {
  cursor: grabbing;
}

@keyframes hint-in {
  from { opacity: 0; transform: translateX(18px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes hint-float {
  0%,
  100% { transform: translateX(0); }
  50% { transform: translateX(-8px); }
}

@keyframes bubble-enter {
  from {
    opacity: 0;
    transform: translate(-20px, 8px) scale(.92) rotate(-1deg);
  }
  to {
    opacity: 1;
    transform: translate(0, 0) scale(1) rotate(0);
  }
}

@keyframes invitation-in {
  from { opacity: 0; transform: translate(-50%, 20px) scale(.88); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

@keyframes invitation-float {
  0% { transform: translate(-50%, 0); }
  20% { transform: translate(calc(-50% + 8px), -7px); }
  45% { transform: translate(calc(-50% - 6px), -13px); }
  70% { transform: translate(calc(-50% + 5px), -6px); }
  100% { transform: translate(-50%, 0); }
}

@keyframes invitation-click {
  0% { transform: translate(-50%, 0) scale(1); }
  45% { transform: translate(-50%, 4px) scale(.94); }
  100% { transform: translate(-50%, 0) scale(1); }
}

@keyframes ending-actions-in {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .page--turning,
  .page__face,
  .page--under {
    transition: none !important;
  }

  .book__hint {
    display: none;
  }
}

.rotate-tip {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  color: #f5f2e9;
  background: rgb(17 17 17 / 92%);
  font-size: clamp(14px, 4vw, 18px);
  font-weight: 700;
  letter-spacing: .12em;
  text-align: center;
  pointer-events: none;
}

.rotate-tip::before {
  content: "↺";
  display: block;
  margin-bottom: 18px;
  color: #91d627;
  font-size: clamp(40px, 12vw, 64px);
  animation: rotate-hint 1.6s ease-in-out infinite;
}

@keyframes rotate-hint {
  0%, 100% { transform: rotate(0); }
  50% { transform: rotate(-90deg); }
}

@media (orientation: landscape) and (max-height: 500px) {
  .rotate-tip {
    display: flex;
    flex-direction: column;
  }
}

@media (hover: none) and (pointer: coarse) {
  .sound,
  .ending-action,
  .invitation {
    -webkit-tap-highlight-color: transparent;
  }
}
