:root {
  color-scheme: dark;
  --cream: #fff8e8;
  --ink: #332923;
  --rose: #f39ba7;
  --coral: #ff755f;
  --sun: #ffd36b;
  --mint: #8edcc5;
  --sky: #91c9ff;
  --night: #201b24;
  --glass: rgba(255, 248, 232, 0.88);
  --glass-strong: rgba(255, 248, 232, 0.94);
  --shadow: rgba(33, 22, 24, 0.38);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--night);
}

body {
  color: var(--cream);
}

.stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-width: 960px;
  min-height: 540px;
  overflow: hidden;
  background:
    radial-gradient(circle at 10% 16%, rgba(255, 211, 107, 0.2), transparent 24%),
    radial-gradient(circle at 88% 18%, rgba(142, 220, 197, 0.2), transparent 24%),
    linear-gradient(135deg, #2e2532 0%, #302230 42%, #1f2530 100%);
}

.stage.is-finale {
  background:
    radial-gradient(circle at 16% 20%, rgba(255, 211, 107, 0.34), transparent 28%),
    radial-gradient(circle at 86% 18%, rgba(243, 155, 167, 0.3), transparent 28%),
    radial-gradient(circle at 50% 90%, rgba(142, 220, 197, 0.22), transparent 26%),
    linear-gradient(135deg, #332230 0%, #3a2631 45%, #26363a 100%);
}

.backdrop {
  position: absolute;
  inset: -24px;
  overflow: hidden;
}

.backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(25, 18, 26, 0.42), rgba(25, 18, 26, 0.14) 42%, rgba(25, 18, 26, 0.52)),
    radial-gradient(circle at center, transparent 0%, rgba(23, 18, 22, 0.58) 76%);
}

.backdrop img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(28px) saturate(1.18) brightness(0.82);
  transform: scale(1.08);
  opacity: 0.74;
  transition: opacity 900ms ease;
}

.photo-stage {
  position: absolute;
  inset: 3vh 4vw;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.photo {
  position: absolute;
  max-width: 92vw;
  max-height: 94vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border: 1px solid rgba(255, 248, 232, 0.4);
  box-shadow: 0 30px 90px var(--shadow);
  opacity: 0;
  transform: scale(1.015);
  transition: opacity 1100ms ease, transform 9600ms ease-out;
}

.photo.is-active {
  opacity: 1;
  transform: scale(1.065) translate3d(var(--pan-x, 0), var(--pan-y, 0), 0);
}

.topbar {
  position: absolute;
  top: 26px;
  left: 34px;
  right: 34px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  text-shadow: 0 2px 18px rgba(20, 16, 18, 0.5);
}

.identity {
  display: grid;
  gap: 4px;
}

.identity .kicker,
.timeline-meta,
.age-card span,
.chapter,
.info-card span,
.qr-card span,
.finale-card span {
  font-size: 15px;
  line-height: 1.1;
  letter-spacing: 0;
}

.identity .kicker {
  color: rgba(255, 248, 232, 0.74);
  text-transform: uppercase;
  font-weight: 800;
}

.chapter {
  min-width: 178px;
  max-width: 310px;
  padding: 12px 16px;
  border-radius: 8px;
  color: var(--ink);
  background: var(--glass);
  box-shadow: 0 16px 46px rgba(0, 0, 0, 0.18);
  text-align: center;
  font-weight: 800;
}

.nav-button {
  position: absolute;
  top: 50%;
  z-index: 8;
  width: 82px;
  height: 168px;
  display: grid;
  place-items: center;
  transform: translateY(-50%);
  border: 0;
  border-radius: 8px;
  color: rgba(255, 248, 232, 0.86);
  background: rgba(255, 248, 232, 0.1);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  opacity: 0.42;
  transition: opacity 180ms ease, background 180ms ease, transform 180ms ease;
}

.nav-button span {
  display: block;
  margin-top: -4px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 78px;
  line-height: 1;
}

.nav-button:hover,
.nav-button:focus-visible {
  opacity: 0.92;
  background: rgba(255, 248, 232, 0.18);
  outline: none;
}

.nav-button:active {
  transform: translateY(-50%) scale(0.98);
}

.nav-button-left {
  left: 30px;
}

.nav-button-right {
  right: 30px;
}

.age-card {
  position: absolute;
  right: 34px;
  bottom: 184px;
  width: 308px;
  display: grid;
  gap: 8px;
  padding: 18px 20px;
  border-radius: 8px;
  color: var(--ink);
  background: linear-gradient(135deg, rgba(255, 248, 232, 0.94), rgba(255, 239, 206, 0.86));
  box-shadow: 0 18px 60px rgba(18, 14, 16, 0.28);
}

.age-card span {
  color: rgba(51, 41, 35, 0.7);
  font-weight: 800;
  text-transform: uppercase;
}

.age-card strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 35px;
  line-height: 1;
  letter-spacing: 0;
}

.info-card {
  position: absolute;
  left: 34px;
  top: 74px;
  width: min(476px, 42vw);
  display: grid;
  gap: 8px;
  padding: 18px 20px 20px;
  border-radius: 8px;
  color: var(--ink);
  background: linear-gradient(135deg, rgba(255, 248, 232, 0.94), rgba(245, 255, 244, 0.84));
  box-shadow: 0 18px 60px rgba(18, 14, 16, 0.28);
  opacity: 1;
  transform: translateY(0);
  transition: opacity 360ms ease, transform 360ms ease;
}

.stage.is-finale .info-card {
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
}

.info-card span {
  color: rgba(51, 41, 35, 0.68);
  font-weight: 900;
  text-transform: uppercase;
}

.info-card strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 28px;
  line-height: 1.02;
  letter-spacing: 0;
}

.info-card p {
  margin: 0;
  color: rgba(51, 41, 35, 0.78);
  font-size: 18px;
  line-height: 1.28;
  font-weight: 750;
}

.qr-card {
  position: absolute;
  right: 34px;
  top: 84px;
  z-index: 6;
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 12px;
  align-items: center;
  width: 252px;
  padding: 12px;
  border-radius: 8px;
  color: var(--ink);
  background: var(--glass-strong);
  box-shadow: 0 18px 60px rgba(18, 14, 16, 0.24);
}

.qr-card img {
  width: 86px;
  height: 86px;
  border-radius: 6px;
  background: #fff;
}

.qr-card span {
  display: block;
  color: rgba(51, 41, 35, 0.64);
  font-weight: 900;
  text-transform: uppercase;
}

.qr-card strong {
  display: block;
  margin-top: 5px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 23px;
  line-height: 1;
  letter-spacing: 0;
}

.finale-card {
  position: absolute;
  left: 50%;
  top: 96px;
  z-index: 7;
  width: min(620px, 48vw);
  padding: 22px 26px 24px;
  border-radius: 8px;
  color: var(--ink);
  background: linear-gradient(135deg, rgba(255, 248, 232, 0.96), rgba(255, 235, 210, 0.9));
  box-shadow: 0 28px 90px rgba(18, 14, 16, 0.34);
  opacity: 0;
  transform: translate(-50%, -12px);
  pointer-events: none;
  transition: opacity 500ms ease, transform 500ms ease;
}

.stage.is-finale .finale-card {
  opacity: 1;
  transform: translate(-50%, 0);
}

.finale-card span {
  display: block;
  color: rgba(51, 41, 35, 0.68);
  font-weight: 900;
  text-transform: uppercase;
}

.finale-card strong {
  display: block;
  margin-top: 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 42px;
  line-height: 0.98;
  letter-spacing: 0;
}

.finale-card p {
  margin: 13px 0 0;
  color: rgba(51, 41, 35, 0.78);
  font-size: 20px;
  line-height: 1.32;
  font-weight: 760;
}

.timeline-panel {
  position: absolute;
  left: 34px;
  right: 34px;
  bottom: 28px;
  display: grid;
  grid-template-columns: 360px 1fr;
  grid-template-rows: auto auto;
  gap: 10px 22px;
  align-items: center;
  padding: 17px 18px 18px;
  border-radius: 8px;
  color: var(--ink);
  background: var(--glass);
  box-shadow: 0 24px 80px rgba(18, 14, 16, 0.28);
}

.timeline-meta {
  display: grid;
  gap: 4px;
  color: rgba(51, 41, 35, 0.68);
  font-weight: 800;
  text-transform: uppercase;
}

.timeline-meta strong {
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 28px;
  line-height: 1;
  letter-spacing: 0;
  text-transform: none;
}

.timeline {
  position: relative;
  height: 64px;
  padding-top: 22px;
}

.timeline::before,
.timeline-fill {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 28px;
  height: 8px;
  border-radius: 999px;
}

.timeline::before {
  background: rgba(51, 41, 35, 0.12);
}

.timeline-fill {
  right: auto;
  width: 0%;
  background: linear-gradient(90deg, var(--rose), var(--sun), var(--mint), var(--sky));
  transition: width 800ms ease;
}

.timeline-dot {
  position: absolute;
  top: 20px;
  left: 0%;
  width: 24px;
  height: 24px;
  margin-left: -12px;
  border-radius: 999px;
  background: var(--cream);
  border: 6px solid var(--coral);
  box-shadow: 0 8px 18px rgba(255, 117, 95, 0.35);
  transition: left 800ms ease;
}

.timeline-ticks {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  color: rgba(51, 41, 35, 0.58);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
}

.chapter-rail {
  grid-column: 2;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}

.chapter-rail span {
  min-width: 0;
  padding: 7px 8px;
  border-radius: 7px;
  color: rgba(51, 41, 35, 0.58);
  background: rgba(51, 41, 35, 0.08);
  font-size: 13px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0;
  text-align: center;
  white-space: nowrap;
}

.chapter-rail span.is-active {
  color: var(--ink);
  background: linear-gradient(90deg, rgba(243, 155, 167, 0.38), rgba(255, 211, 107, 0.42));
}

.slide-timer {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 8px;
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(51, 41, 35, 0.1);
}

.stage.is-finale .confetti span {
  opacity: 0.94;
  animation-duration: 10s;
}

.slide-timer div {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--coral);
}

.slide-timer div.is-running {
  animation: timerFill var(--slide-duration, 10s) linear forwards;
}

.confetti {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.confetti span {
  position: absolute;
  top: -9vh;
  width: 9px;
  height: 16px;
  border-radius: 3px;
  opacity: 0.72;
  animation: drift 16s linear infinite;
}

.confetti span:nth-child(4n) {
  background: var(--rose);
}

.confetti span:nth-child(4n + 1) {
  background: var(--sun);
}

.confetti span:nth-child(4n + 2) {
  background: var(--mint);
}

.confetti span:nth-child(4n + 3) {
  background: var(--sky);
}

.confetti span:nth-child(1) { left: 7%; animation-delay: -2s; animation-duration: 18s; }
.confetti span:nth-child(2) { left: 14%; animation-delay: -9s; animation-duration: 19s; }
.confetti span:nth-child(3) { left: 20%; animation-delay: -5s; animation-duration: 15s; }
.confetti span:nth-child(4) { left: 29%; animation-delay: -11s; animation-duration: 21s; }
.confetti span:nth-child(5) { left: 36%; animation-delay: -3s; animation-duration: 18s; }
.confetti span:nth-child(6) { left: 42%; animation-delay: -12s; animation-duration: 16s; }
.confetti span:nth-child(7) { left: 50%; animation-delay: -6s; animation-duration: 22s; }
.confetti span:nth-child(8) { left: 58%; animation-delay: -14s; animation-duration: 18s; }
.confetti span:nth-child(9) { left: 65%; animation-delay: -1s; animation-duration: 17s; }
.confetti span:nth-child(10) { left: 72%; animation-delay: -10s; animation-duration: 21s; }
.confetti span:nth-child(11) { left: 79%; animation-delay: -4s; animation-duration: 19s; }
.confetti span:nth-child(12) { left: 84%; animation-delay: -13s; animation-duration: 16s; }
.confetti span:nth-child(13) { left: 89%; animation-delay: -7s; animation-duration: 23s; }
.confetti span:nth-child(14) { left: 94%; animation-delay: -15s; animation-duration: 20s; }
.confetti span:nth-child(15) { left: 98%; animation-delay: -8s; animation-duration: 18s; }

.status {
  position: absolute;
  left: 50%;
  top: 50%;
  max-width: 620px;
  transform: translate(-50%, -50%);
  padding: 16px 20px;
  border-radius: 8px;
  color: var(--ink);
  background: var(--glass);
  box-shadow: 0 18px 60px rgba(18, 14, 16, 0.24);
  font-size: 20px;
  font-weight: 800;
  opacity: 1;
  transition: opacity 400ms ease;
  text-align: center;
}

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

@keyframes timerFill {
  from { width: 0%; }
  to { width: 100%; }
}

@keyframes drift {
  from {
    transform: translate3d(0, -4vh, 0) rotate(0deg);
  }
  to {
    transform: translate3d(32px, 114vh, 0) rotate(540deg);
  }
}

@media (max-aspect-ratio: 16 / 10) {
  .stage {
    min-width: 0;
    min-height: 0;
  }

  .photo-stage {
    inset: 4vh 3vw;
  }

  .age-card {
    width: 268px;
    bottom: 176px;
  }

  .info-card {
    width: 340px;
    top: 70px;
  }

  .qr-card {
    width: 180px;
    grid-template-columns: 64px 1fr;
    top: 72px;
  }

  .qr-card img {
    width: 64px;
    height: 64px;
  }

  .qr-card strong {
    font-size: 18px;
  }

  .finale-card {
    width: min(440px, 72vw);
    top: 92px;
  }

  .finale-card strong {
    font-size: 32px;
  }

  .finale-card p {
    font-size: 17px;
  }

  .timeline-panel {
    grid-template-columns: 290px 1fr;
  }

  .chapter-rail span {
    font-size: 11px;
    padding: 6px 5px;
  }
}

@media (max-width: 700px) and (orientation: portrait) {
  .stage {
    height: 100dvh;
    min-width: 0;
    min-height: 0;
  }

  .photo-stage {
    inset: 204px 12px 286px;
  }

  .photo {
    max-width: 94vw;
    max-height: 42dvh;
    box-shadow: 0 18px 54px rgba(33, 22, 24, 0.32);
  }

  .topbar {
    top: 12px;
    left: 14px;
    right: 14px;
    gap: 10px;
  }

  .identity .kicker {
    font-size: 12px;
  }

  .chapter {
    min-width: 0;
    max-width: 184px;
    padding: 9px 11px;
    font-size: 12px;
  }

  .qr-card {
    display: none;
  }

  .info-card {
    left: 14px;
    right: 14px;
    top: 54px;
    width: auto;
    gap: 5px;
    padding: 12px 14px 13px;
  }

  .info-card span {
    font-size: 11px;
  }

  .info-card strong {
    font-size: 22px;
  }

  .info-card p {
    font-size: 14px;
    line-height: 1.22;
  }

  .age-card {
    left: 14px;
    right: 14px;
    bottom: 190px;
    width: auto;
    gap: 4px;
    padding: 12px 14px;
  }

  .age-card span {
    font-size: 11px;
  }

  .age-card strong {
    font-size: 26px;
  }

  .timeline-panel {
    left: 10px;
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    gap: 8px;
    padding: 12px 12px 17px;
  }

  .timeline-meta {
    gap: 2px;
    font-size: 11px;
  }

  .timeline-meta strong {
    font-size: 23px;
  }

  .timeline {
    height: 42px;
    padding-top: 13px;
  }

  .timeline::before,
  .timeline-fill {
    top: 18px;
    height: 7px;
  }

  .timeline-dot {
    top: 11px;
    width: 21px;
    height: 21px;
    margin-left: -10px;
    border-width: 5px;
  }

  .timeline-ticks {
    font-size: 11px;
  }

  .chapter-rail {
    grid-column: 1;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
  }

  .chapter-rail span {
    padding: 6px 5px;
    font-size: 10px;
  }

  .slide-timer {
    left: 12px;
    right: 12px;
    bottom: 7px;
  }

  .nav-button {
    width: 42px;
    height: 116px;
    opacity: 0.28;
  }

  .nav-button span {
    font-size: 46px;
  }

  .nav-button-left {
    left: 8px;
  }

  .nav-button-right {
    right: 8px;
  }

  .finale-card {
    left: 14px;
    right: 14px;
    top: 72px;
    width: auto;
    padding: 17px 18px 18px;
    transform: translateY(-12px);
  }

  .stage.is-finale .finale-card {
    transform: translateY(0);
  }

  .finale-card span {
    font-size: 11px;
  }

  .finale-card strong {
    font-size: 31px;
  }

  .finale-card p {
    font-size: 15px;
    line-height: 1.26;
  }

  .status {
    width: calc(100vw - 28px);
    font-size: 16px;
  }
}

@media (max-width: 380px) and (orientation: portrait) {
  .photo-stage {
    inset: 194px 10px 270px;
  }

  .info-card p {
    font-size: 13px;
  }

  .age-card {
    bottom: 178px;
  }

  .timeline-meta strong {
    font-size: 21px;
  }

  .chapter-rail span {
    font-size: 9px;
  }
}
