:root {
  --bg-color-1: rgb(108, 142, 186);
  --bg-color-2: rgb(214, 190, 156);
  --bg-color-3: rgb(200, 112, 64);
  --bg-blur: 28px;
  --text-color: #3b2c22;
  --frame-ivory: rgba(252, 243, 230, 0.95);
  --glass: rgba(255, 255, 255, 0.22);
  --touch-x: 50%;
  --touch-y: 50%;
  --touch-offset-x: 0px;
  --touch-offset-y: 0px;
  --touch-opacity: 0;
  --touch-color: 232 160 98;
  --open-max-width: 720px;
  --open-max-height: 640px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  border-radius: 0 !important;
}

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: "STZhongsong", "Songti SC", "STSong", "SimSun", serif;
  font-weight: 700;
  color: var(--text-color);
  background: #e3cdb1;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
}

.app {
  position: relative;
  height: 100vh;
  width: 100vw;
  opacity: 0;
  transition: opacity 0.6s ease;
}

.app.ready {
  opacity: 1;
}

.app.is-sliding {
  --bg-blur: 46px;
}

.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

.bg-gradient {
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(1200px circle at 18% 12%, rgba(255, 255, 255, 0.65), transparent 60%),
    radial-gradient(900px circle at 78% 76%, rgba(255, 255, 255, 0.35), transparent 55%),
    linear-gradient(135deg, var(--bg-color-1), var(--bg-color-2), var(--bg-color-3));
  filter: blur(var(--bg-blur));
  transform: translateZ(0);
  animation: floatGlow 16s ease-in-out infinite alternate;
  transition: filter 0.4s ease, background 0.9s ease;
}

.bg-interaction {
  position: absolute;
  inset: -10%;
  background:
    radial-gradient(
      340px circle at calc(var(--touch-x) + var(--touch-offset-x))
      calc(var(--touch-y) + var(--touch-offset-y)),
      rgb(var(--touch-color) / 0.45),
      transparent 70%
    ),
    radial-gradient(
      260px circle at var(--touch-x) var(--touch-y),
      rgba(255, 255, 255, 0.55),
      transparent 70%
    );
  opacity: var(--touch-opacity);
  filter: blur(20px) saturate(115%);
  mix-blend-mode: screen;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.bg-haze {
  position: absolute;
  inset: 0;
  backdrop-filter: blur(26px) saturate(110%);
  background: rgba(255, 255, 255, 0.18);
}

.bg-noise {
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140' viewBox='0 0 140 140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.25'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
  opacity: 0.5;
}

.start-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(18px);
  z-index: 6;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

.start-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  text-align: center;
}

.start-text {
  font-size: clamp(16px, 4vw, 22px);
  letter-spacing: 4px;
}

.start-arrow {
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: rotate(0deg);
  transition: transform 0.4s ease;
}

.start-arrow-shift {
  position: relative;
  width: 100%;
  height: 100%;
  animation: arrowPulse 1.6s ease-in-out infinite;
}

.arrow-line {
  position: absolute;
  left: 50%;
  top: 22px;
  bottom: 22px;
  width: 2px;
  background: rgba(90, 70, 50, 0.6);
  transform: translateX(-50%);
}

.arrow-head {
  position: absolute;
  left: 50%;
  width: 16px;
  height: 16px;
  border-top: 2px solid rgba(90, 70, 50, 0.7);
  border-right: 2px solid rgba(90, 70, 50, 0.7);
}

.arrow-head.up {
  top: 16px;
  transform: translateX(-50%) rotate(-45deg);
}

.arrow-head.down {
  bottom: 16px;
  transform: translateX(-50%) rotate(135deg);
}

.app.mode-open .start-arrow {
  transform: rotate(90deg);
}

.app.show-start .start-overlay {
  opacity: 1;
  pointer-events: auto;
}

@keyframes arrowPulse {
  0% {
    transform: translateY(0);
    opacity: 0.6;
  }
  50% {
    transform: translateY(10px);
    opacity: 1;
  }
  100% {
    transform: translateY(0);
    opacity: 0.6;
  }
}

@keyframes floatGlow {
  0% {
    transform: scale(1) translate3d(0, 0, 0);
  }
  100% {
    transform: scale(1.06) translate3d(2%, -2%, 0);
  }
}

.loader {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(140deg, #e6d3b3, #b7c7de);
  z-index: 20;
  transition: opacity 0.6s ease;
}

.loader.hidden {
  opacity: 0;
  pointer-events: none;
}

.loader-card {
  width: min(78vw, 360px);
  padding: 28px 26px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(180, 160, 130, 0.35);
  box-shadow: 0 20px 50px rgba(120, 90, 60, 0.18);
  text-align: center;
  backdrop-filter: blur(16px);
}

.loader-title {
  font-size: 18px;
  letter-spacing: 2px;
  margin-bottom: 16px;
}

.loader-bar {
  width: 100%;
  height: 8px;
  background: rgba(180, 160, 130, 0.2);
  overflow: hidden;
}

.loader-bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #c6d7e8, #f2e4cd, #e6a76a);
  transition: width 0.3s ease;
}

.loader-text {
  margin-top: 12px;
  font-size: 14px;
  letter-spacing: 2px;
}

.content {
  position: relative;
  height: 100%;
  width: 100%;
  z-index: 2;
}

.scene {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: clamp(14px, 3vw, 26px);
  padding: clamp(24px, 5vw, 64px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

.app.mode-closed .closed-scene {
  opacity: 1;
  pointer-events: auto;
}

.app.mode-open .open-scene {
  opacity: 1;
  pointer-events: auto;
}

.stack {
  position: relative;
  width: min(78vw, 520px);
  aspect-ratio: 4 / 3;
}

.photo-card {
  position: absolute;
  inset: 0;
  background: #ffb49d;
  border: 1px solid var(--frame-ivory);
  box-shadow: 0 18px 38px rgba(90, 70, 50, 0.452);
  overflow: hidden;
  transition: transform 0.75s ease, opacity 0.75s ease, filter 0.75s ease;
}

.photo-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #ffb49d;
}

.open-scene {
  justify-content: center;
}

.open-viewport {
  width: 100%;
  max-width: 1280px;
  overflow: hidden;
}

.open-track {
  display: flex;
  gap: clamp(20px, 5vw, 42px);
  align-items: center;
  padding: 0 8vw;
  transition: transform 0.8s ease;
}

.open-card {
  width: clamp(220px, 38vw, 420px);
  height: clamp(280px, 65vh, 520px);
  background: #ffb49d;
  border: 1px solid var(--frame-ivory);
  box-shadow: 0 18px 42px rgba(90, 70, 50, 0.22);
  overflow: hidden;
  flex: 0 0 auto;
  transition: transform 0.8s ease, opacity 0.8s ease;
}

.open-card-inner {
  width: 100%;
  height: 100%;
}

.open-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #ffb49d;
}

.open-card:nth-child(odd) {
  transform: translateY(-18px);
}

.open-card:nth-child(even) {
  transform: translateY(18px);
}

.open-card.active {
  transform: translateY(0) scale(1.02);
}

.timeline {
  position: absolute;
  left: 8vw;
  right: 8vw;
  bottom: clamp(24px, 5vh, 60px);
  height: 30px;
  display: flex;
  align-items: center;
}

.timeline-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: rgba(100, 80, 60, 0.25);
}

.timeline-dots {
  position: relative;
  display: flex;
  justify-content: space-between;
  width: 100%;
}

.timeline-dots span {
  width: 8px;
  height: 8px;
  background: rgba(100, 80, 60, 0.3);
  transition: transform 0.3s ease, background 0.3s ease;
}

.timeline-dots span.active {
  background: #b46c3e;
  transform: scale(1.6);
}

.message-scene {
  text-align: center;
  gap: 12px;
  opacity: 0;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.3);
  padding: 28px 32px;
  border: 1px solid rgba(180, 160, 130, 0.3);
  backdrop-filter: blur(16px);
  box-shadow: 0 16px 38px rgba(90, 70, 50, 0.15);
  transition: opacity 0.8s ease;
}

.message-scene h1 {
  font-size: clamp(28px, 7vw, 46px);
  margin: 0;
  letter-spacing: 6px;
}

.message-scene p {
  margin: 0;
  font-size: clamp(14px, 3.8vw, 20px);
  letter-spacing: 3px;
}

.quote-scene {
  text-align: center;
  gap: 16px;
  opacity: 0;
  pointer-events: none;
  padding: 24px 28px;
  background: rgba(255, 255, 255, 0.32);
  border: 1px solid rgba(180, 160, 130, 0.35);
  box-shadow: 0 16px 38px rgba(90, 70, 50, 0.15);
  backdrop-filter: blur(16px);
}

.quote-lines {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.quote-line {
  margin: 0;
  font-family: "KaiTi", "Kaiti SC", "STKaiti", "KaiTi_GB2312", serif;
  font-size: clamp(20px, 5vw, 34px);
  letter-spacing: 6px;
  opacity: 0;
  transform: translateY(18px);
}

.app.show-quote .quote-scene {
  opacity: 1;
  pointer-events: auto;
}

.app.show-quote .quote-line {
  animation: quoteFade 1.2s ease forwards;
}

.app.show-quote .quote-line:nth-child(2) {
  animation-delay: 1.1s;
}

.app.show-message .message-scene {
  opacity: 1;
  pointer-events: auto;
}

.app.show-message .closed-scene,
.app.show-message .open-scene,
.app.show-quote .closed-scene,
.app.show-quote .open-scene,
.app.show-start .closed-scene,
.app.show-start .open-scene {
  opacity: 0.2;
}

@keyframes quoteFade {
  0% {
    opacity: 0;
    transform: translateY(18px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.controls {
  position: fixed;
  right: calc(env(safe-area-inset-right, 0px) + clamp(12px, 4vw, 40px));
  top: calc(env(safe-area-inset-top, 0px) + clamp(12px, 4vh, 36px));
  bottom: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  z-index: 5;
}

.control-button {
  font-size: clamp(11px, 2.4vw, 14px);
  letter-spacing: 2px;
  padding: clamp(6px, 1.6vw, 10px) clamp(10px, 2.6vw, 16px);
  border: 1px solid rgba(160, 140, 120, 0.4);
  background: rgba(255, 255, 255, 0.55);
  color: var(--text-color);
  backdrop-filter: blur(10px);
  cursor: pointer;
}

.controls,
.controls * {
  touch-action: auto;
}

@media (min-width: 1040px) and (max-width: 1120px) and (min-height: 2360px) and (max-height: 2520px) and (orientation: portrait) {
  :root {
    --open-max-width: 760px;
    --open-max-height: 680px;
  }

  .stack {
    width: min(86vw, 700px);
  }

  .control-button {
    font-size: 16px;
    padding: 10px 18px;
  }

  .controls {
    right: calc(env(safe-area-inset-right, 0px) + 28px);
    top: calc(env(safe-area-inset-top, 0px) + 30px);
  }
}

@media (min-width: 2360px) and (max-width: 2520px) and (min-height: 2160px) and (max-height: 2320px) and (orientation: landscape) {
  :root {
    --open-max-width: 980px;
    --open-max-height: 820px;
  }

  .open-viewport {
    max-width: 2000px;
  }

  .open-track {
    gap: 64px;
    padding: 0 10vw;
  }


  .timeline {
    left: 10vw;
    right: 10vw;
    bottom: 80px;
  }

  .controls {
    right: calc(env(safe-area-inset-right, 0px) + 40px);
    top: calc(env(safe-area-inset-top, 0px) + 34px);
  }
}

@media (max-width: 600px) {
  .controls {
    right: 12px;
    top: 12px;
    bottom: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
