:root {
  color-scheme: dark;
  font-family: Arial, "Noto Sans TC", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: #162342;
  color: #e5e3d5;
}

.fullscreen-page {
  --desktop-background: none;
  --mobile-background: none;
  position: relative;
  display: flex;
  width: 100vw;
  height: 100vh;
  height: 100svh;
  min-height: 0;
  overflow: hidden;
  align-items: flex-end;
  justify-content: center;
  padding: 0 max(24px, env(safe-area-inset-right)) max(52px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  background-color: var(--placeholder-color);
  background-image: var(--desktop-background);
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
}

.page-1 {
  --placeholder-color: #162342;
  --desktop-background: url("/backgrounds/page-1-poster.jpeg");
  background-size: contain;
}

.page-2 {
  --placeholder-color: #162342;
  --desktop-background: url("/backgrounds/page-2.png");
  background-size: cover;
}

.page-3 {
  --placeholder-color: #162342;
  --desktop-background: url("/backgrounds/page-3.png");
  background-size: cover;
}

.page-4 {
  --placeholder-color: #162342;
  --desktop-background: url("/backgrounds/page-4.png");
  background-size: cover;
}

.page-5 {
  --placeholder-color: #162342;
  --desktop-background: url("/backgrounds/page-5.png");
  background-size: cover;
}

.page-button {
  position: relative;
  z-index: 1;
  display: inline-flex;
  min-width: 148px;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(229, 227, 213, 0.72);
  border-radius: 999px;
  padding: 14px 30px;
  background: rgba(143, 40, 83, 0.92);
  color: #e5e3d5;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-decoration: none;
  box-shadow: 0 10px 28px rgba(85, 17, 47, 0.3);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  transition: transform 160ms ease, background-color 160ms ease;
}

.page-actions {
  position: absolute;
  z-index: 3;
  left: 50%;
  display: flex;
  width: min(420px, calc(100vw - 48px));
  flex-direction: column;
  align-items: center;
  gap: 12px;
  transform: translateX(-50%);
}

.page-2 .page-actions {
  top: 78%;
}

.page-3 .page-actions,
.page-4 .page-actions {
  bottom: max(40px, calc(env(safe-area-inset-bottom) + 16px));
}

.page-3 .page-actions {
  transform: translateX(-50%);
}

.page-5 .page-actions {
  top: 61%;
}

@media (min-width: 768px) and (min-aspect-ratio: 16 / 9) {
  .page-3 .page-actions,
  .page-4 .page-actions {
    top: min(calc(50vh + 20.25vw), calc(100vh - 64px));
    bottom: auto;
  }
}

.page-actions .page-button {
  min-width: 220px;
  opacity: 0;
  pointer-events: none;
  transform: none;
  transition: opacity 2000ms ease, background-color 160ms ease;
}

.page-actions .page-button.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.page-actions .page-button:hover,
.page-button:hover {
  background: #84254c;
}

.page-button:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 4px;
}

.background-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
}

.home-hourglass {
  position: absolute;
  z-index: 2;
  top: 22%;
  left: 50%;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  opacity: 0;
  color: #e5e3d5;
  filter: drop-shadow(0 0 8px rgba(229, 227, 213, 0.5));
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.9);
  transition: opacity 420ms ease, transform 420ms ease;
}

.home-hourglass svg {
  width: 28px;
  height: 28px;
  animation: hourglass-turn 1200ms cubic-bezier(0.65, 0, 0.35, 1) infinite;
}

.home-hourglass.is-visible {
  opacity: 0.88;
  transform: translate(-50%, -50%) scale(1);
}

@keyframes hourglass-turn {
  0%, 40% { transform: rotate(0deg); }
  60%, 100% { transform: rotate(180deg); }
}

.page-1 .page-button {
  position: absolute;
  top: 57.5%;
  left: 50%;
  width: 120px;
  height: 120px;
  min-width: 120px;
  min-height: 120px;
  flex-direction: column;
  padding: 18px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, calc(-50% + 14px));
  border: 1.5px solid rgba(229, 227, 213, 0.9);
  border-radius: 50%;
  background: rgba(143, 40, 83, 0.9);
  box-shadow: 0 10px 28px rgba(85, 17, 47, 0.34);
  transition: opacity 1300ms ease, transform 1300ms cubic-bezier(0.22, 1, 0.36, 1), background-color 160ms ease;
}

.page-1 .page-button::before {
  content: "";
  position: absolute;
  inset: -10px;
  border: 1.5px solid rgba(229, 227, 213, 0.72);
  border-top-color: transparent;
  border-left-color: rgba(229, 227, 213, 0.26);
  border-radius: 48% 52% 50% 46%;
  pointer-events: none;
  animation: gravity-orbit 12s linear infinite;
}

.page-1 .page-button::after {
  content: "";
  position: absolute;
  top: -14px;
  left: calc(50% - 4px);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e5e3d5;
  box-shadow: 0 0 12px rgba(229, 227, 213, 0.72);
  pointer-events: none;
}

.gravity-button-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  line-height: 1.22;
  white-space: nowrap;
}

.page-1 .page-button.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%);
}

.page-1 .page-button:hover {
  transform: translate(-50%, calc(-50% - 2px));
}

@keyframes gravity-orbit {
  to { transform: rotate(360deg); }
}

.page-transition {
  position: fixed;
  z-index: 20;
  inset: 0;
  background-color: #162342;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  pointer-events: none;
  opacity: 0;
  backface-visibility: hidden;
  transform-style: preserve-3d;
  will-change: clip-path, transform, opacity;
}

.page-transition--page-1 {
  background-image: url("/backgrounds/page-2.png");
  clip-path: circle(0 at 50% 57.5%);
}

.page-transition--page-2 {
  background-image: url("/backgrounds/page-3.png");
  transform: perspective(1600px) rotateY(-88deg);
  transform-origin: right center;
}

.page-transition--page-3 {
  background-image: url("/backgrounds/page-4.png");
  transform: perspective(1600px) rotateY(88deg);
  transform-origin: left center;
}

.page-transition--page-4 {
  background-image: url("/backgrounds/page-5.png");
  transform: perspective(1600px) rotateX(-88deg);
  transform-origin: center bottom;
}

.page-transition--page-1.is-active {
  opacity: 1;
  animation: berry-circle-reveal 1560ms cubic-bezier(0.65, 0, 0.25, 1) forwards;
}

.page-transition--page-2.is-active {
  opacity: 1;
  animation: page-turn-from-right 1560ms cubic-bezier(0.65, 0, 0.25, 1) forwards;
}

.page-transition--page-3.is-active {
  opacity: 1;
  animation: page-turn-from-left 1560ms cubic-bezier(0.65, 0, 0.25, 1) forwards;
}

.page-transition--page-4.is-active {
  opacity: 1;
  animation: page-turn-from-bottom 1560ms cubic-bezier(0.65, 0, 0.25, 1) forwards;
}

@keyframes berry-circle-reveal {
  from { clip-path: circle(0 at 50% 57.5%); }
  to { clip-path: circle(150vmax at 50% 57.5%); }
}

@keyframes page-turn-from-right {
  from { opacity: 0.2; transform: perspective(1600px) rotateY(-88deg); }
  to { opacity: 1; transform: perspective(1600px) rotateY(0deg); }
}

@keyframes page-turn-from-left {
  from { opacity: 0.2; transform: perspective(1600px) rotateY(88deg); }
  to { opacity: 1; transform: perspective(1600px) rotateY(0deg); }
}

@keyframes page-turn-from-bottom {
  from { opacity: 0.2; transform: perspective(1600px) rotateX(-88deg); }
  to { opacity: 1; transform: perspective(1600px) rotateX(0deg); }
}

@media (max-width: 767px) {
  .fullscreen-page {
    height: 100svh;
    min-height: 0;
    background-image: var(--mobile-background);
    padding-bottom: max(48px, calc(env(safe-area-inset-bottom) + 24px));
  }

  .page-1 {
    --mobile-background: url("/backgrounds/page-1-poster.jpeg");
    background-position: center;
    background-size: cover;
  }

  .page-transition {
    background-position: center;
    background-size: cover;
  }

  .page-2 { --mobile-background: url("/backgrounds/page-2.png"); }
  .page-3 { --mobile-background: url("/backgrounds/page-3.png"); }
  .page-4 { --mobile-background: url("/backgrounds/page-4.png"); }
  .page-5 { --mobile-background: url("/backgrounds/page-5.png"); }

  .page-2,
  .page-3,
  .page-4,
  .page-5 {
    background-position: center;
    background-size: cover;
  }

  .page-actions {
    width: calc(100vw - 40px);
    gap: 10px;
  }

  .page-2 .page-actions { top: 78%; }

  .page-3 .page-actions,
  .page-4 .page-actions {
    bottom: max(36px, calc(env(safe-area-inset-bottom) + 12px));
  }

  .page-5 .page-actions { top: 61%; }

  .page-actions .page-button {
    min-width: 210px;
    transform: none;
  }

  .page-1 .page-button {
    width: 108px;
    height: 108px;
    min-width: 108px;
    min-height: 108px;
    padding: 14px;
    font-size: 15px;
  }

  .home-hourglass {
    width: 30px;
    height: 30px;
  }

  .home-hourglass svg {
    width: 25px;
    height: 25px;
  }

  .page-button {
    min-width: 136px;
    min-height: 50px;
    padding: 13px 26px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .page-button { transition: none; }
  .page-1 .page-button::before { animation: none; }
  .home-hourglass svg { animation: none; }
  .page-actions .page-button { transition-duration: 1ms; }
  .page-transition.is-active { animation-duration: 1ms; }
}
