:root {
  color-scheme: dark;
  --bg-dark: #05070d;
  --bg-deep: #0a0f1e;
  --bg-soft: #19102a;
  --text-main: rgba(244, 239, 232, 0.92);
  --text-soft: rgba(233, 226, 214, 0.72);
  --accent: rgba(228, 208, 182, 0.86);
  --font-poem: "Cormorant Infant", "Cormorant Garamond", serif;
  --font-ui: "IBM Plex Sans", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-poem);
  overflow: hidden;
}

#app {
  position: relative;
  width: 100%;
  height: 100vh;
  overflow: hidden;
  --parallax-x: 0px;
  --parallax-y: 0px;
}

.bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(1200px 800px at 20% 10%, rgba(48, 28, 70, 0.55), transparent 65%),
    radial-gradient(900px 700px at 85% 80%, rgba(92, 40, 68, 0.45), transparent 60%),
    linear-gradient(180deg, var(--bg-deep), var(--bg-dark) 65%, #030408 100%);
  z-index: 0;
}

.decor {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(700px 500px at 80% 20%, rgba(186, 112, 142, 0.22), transparent 70%),
    radial-gradient(900px 700px at 20% 80%, rgba(110, 74, 138, 0.2), transparent 70%);
  z-index: 0;
  pointer-events: none;
}

.decor::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cg fill='rgba(255,195,210,0.35)'%3E%3Cpath d='M40 52c0-10 8-18 18-18 6 0 12 3 15 8 3-5 9-8 15-8 10 0 18 8 18 18 0 20-33 34-33 34S40 72 40 52z'/%3E%3Cpath d='M92 118c0-7 5-12 12-12 4 0 8 2 10 5 2-3 6-5 10-5 7 0 12 5 12 12 0 13-22 22-22 22s-22-9-22-22z'/%3E%3Cpath d='M20 110c0-6 5-11 11-11 4 0 7 2 9 5 2-3 5-5 9-5 6 0 11 5 11 11 0 12-20 20-20 20s-20-8-20-20z'/%3E%3C/g%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 180px 180px;
  opacity: 0.2;
  mix-blend-mode: soft-light;
}

.photo-stage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(72vw, 900px);
  height: min(70vh, 720px);
  transform: translate(-50%, -50%);
  z-index: 1;
  border-radius: 28px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 30px 80px rgba(6, 8, 16, 0.5);
  pointer-events: none;
}

.photo-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(140deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.2));
  opacity: 0.25;
  z-index: 1;
}

.photo-layer {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity var(--fade-duration, 1.6s) ease-in-out;
  transform: translate3d(var(--parallax-x), var(--parallax-y), 0);
}

.photo-image {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  filter: blur(2.2px) contrast(0.86) saturate(0.9);
  transform: scale(1.04);
  will-change: transform;
  z-index: 0;
}

.photo-layer.ken-in .photo-image {
  animation: kenIn var(--ken-duration, 18s) ease-in-out forwards;
}

.photo-layer.ken-out .photo-image {
  animation: kenOut var(--ken-duration, 18s) ease-in-out forwards;
}

.blackout {
  position: absolute;
  inset: 0;
  background: #04060b;
  opacity: 0;
  transition: opacity 6s ease-in-out;
  z-index: 2;
  pointer-events: none;
}

.blackout.visible {
  opacity: 0.95;
}

.grain {
  position: absolute;
  inset: -120%;
  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.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.4'/%3E%3C/svg%3E");
  background-repeat: repeat;
  opacity: 0.08;
  mix-blend-mode: soft-light;
  animation: grain 10s steps(10) infinite;
  z-index: 3;
  pointer-events: none;
}

.vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 35%, rgba(0, 0, 0, 0.7) 100%);
  opacity: 0.85;
  z-index: 4;
  pointer-events: none;
}

.stage {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8vw;
  text-align: center;
}

.scene {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 0 6vw;
  gap: 0.6rem;
  opacity: 0;
  transition: opacity 1.6s ease-in-out;
  pointer-events: none;
}

.scene.is-active {
  opacity: 1;
}

.line {
  margin: 0;
  font-size: clamp(1.6rem, 3.4vw, 2.8rem);
  line-height: 1.4;
  letter-spacing: 0.02em;
  font-weight: 400;
  font-style: italic;
  font-optical-sizing: auto;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 2.6s ease-in-out, transform 2.6s ease-in-out;
}

.scene.dense .line {
  font-size: clamp(1.3rem, 3vw, 2.2rem);
  line-height: 1.35;
}

.line.show {
  opacity: 1;
  transform: translateY(0);
}

.signature {
  margin: 1.8rem 0 0;
  font-family: var(--font-ui);
  font-size: clamp(0.6rem, 1.4vw, 0.85rem);
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--text-soft);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 2.4s ease-in-out, transform 2.4s ease-in-out;
}

.signature.show {
  opacity: 1;
  transform: translateY(0);
}

.signature.is-hidden {
  display: none;
}

.signature.dot {
  letter-spacing: 0.8em;
}

.ui {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}

.ui-top,
.ui-bottom {
  padding: 1.2rem 1.4rem;
  display: flex;
  justify-content: flex-end;
}

.ui-bottom {
  justify-content: center;
}

.ui-button {
  pointer-events: auto;
  background: rgba(12, 16, 28, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-soft);
  font-family: var(--font-ui);
  font-size: 0.78rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  transition: opacity 0.4s ease, border-color 0.4s ease;
}

.ui-button:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

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

.intro {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: rgba(5, 8, 15, 0.7);
  backdrop-filter: blur(6px);
  transition: opacity 1s ease;
}

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

.intro-card {
  max-width: 420px;
  text-align: center;
  padding: 2.2rem 2rem;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    radial-gradient(240px 120px at 50% 0%, rgba(45, 62, 100, 0.25), transparent 70%),
    rgba(8, 11, 18, 0.75);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.intro-card h1 {
  font-size: 2rem;
  margin: 0 0 0.8rem;
  font-weight: 500;
  color: var(--accent);
}

.intro-card p {
  margin: 0.4rem 0;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--text-soft);
  letter-spacing: 0.02em;
}

.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 1.2rem 0 0.4rem;
  padding: 0.7rem 1.2rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  font-family: var(--font-ui);
  font-size: 0.8rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  color: var(--text-main);
  background: rgba(18, 22, 35, 0.6);
}

.file-button input {
  display: none;
}

.file-button.alt {
  margin-top: 0.8rem;
  border-color: rgba(255, 255, 255, 0.2);
}

.intro-warning {
  opacity: 0;
  transition: opacity 0.6s ease;
  color: rgba(240, 210, 190, 0.9);
}

.intro-warning.visible {
  opacity: 1;
}

.intro-note {
  font-size: 0.78rem;
  color: rgba(206, 200, 190, 0.7);
}

.start {
  margin-top: 1rem;
  padding: 0.65rem 1.8rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(20, 26, 40, 0.7);
  color: var(--text-main);
  font-family: var(--font-ui);
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  transition: opacity 0.4s ease;
}

.start:disabled {
  opacity: 0.4;
  cursor: default;
}

@keyframes kenIn {
  0% { transform: scale(1.02); }
  100% { transform: scale(1.1); }
}

@keyframes kenOut {
  0% { transform: scale(1.1); }
  100% { transform: scale(1.02); }
}

@keyframes grain {
  0% { transform: translate3d(0, 0, 0); }
  10% { transform: translate3d(-5%, -3%, 0); }
  20% { transform: translate3d(4%, 2%, 0); }
  30% { transform: translate3d(-2%, 4%, 0); }
  40% { transform: translate3d(5%, -4%, 0); }
  50% { transform: translate3d(-3%, 3%, 0); }
  60% { transform: translate3d(2%, -2%, 0); }
  70% { transform: translate3d(-4%, 2%, 0); }
  80% { transform: translate3d(3%, -4%, 0); }
  90% { transform: translate3d(-2%, -3%, 0); }
  100% { transform: translate3d(0, 0, 0); }
}

@media (max-width: 720px) {
  .photo-stage {
    width: 84vw;
    height: 62vh;
    border-radius: 22px;
  }

  .intro-card {
    padding: 2rem 1.5rem;
  }

  .signature {
    letter-spacing: 0.26em;
  }
}

@media (prefers-reduced-motion: reduce) {
  .line,
  .signature,
  .scene {
    transition-duration: 0.01ms !important;
  }

  .photo-layer.ken-in .photo-image,
  .photo-layer.ken-out .photo-image {
    animation: none !important;
  }

  .grain {
    animation: none !important;
  }
}
