:root {
  color-scheme: dark;
  --ink: #17211f;
  --muted: rgba(255, 250, 242, 0.72);
  --line: rgba(255, 250, 242, 0.26);
  --rose: #e58d8f;
  --moss: #93c5b5;
  --lake: #9db8df;
  --sun: #f0ca72;
  --white: #fffaf2;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  background: var(--ink);
  color: var(--white);
}

button {
  font: inherit;
}

[hidden] {
  display: none !important;
}

.gate-screen {
  width: 100%;
  height: 100svh;
  min-height: 100svh;
  padding: 24px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 22% 18%, rgba(255, 250, 242, 0.48), transparent 28%),
    linear-gradient(135deg, #ffd1df 0%, #f8a9c1 48%, #ee7fa5 100%);
  color: #4b1727;
}

/* The ice and fire penguins stand either side of the sign-in questions. */
.gate-screen {
  position: relative;
}

.gate-card {
  position: relative;
  z-index: 4;
  width: min(520px, 100%);
  display: grid;
  gap: 18px;
  text-align: center;
}

.gate-eyebrow {
  margin: 0;
  color: rgba(75, 23, 39, 0.72);
  font-size: 0.78rem;
  line-height: 1.4;
  font-weight: 760;
  letter-spacing: 0;
  text-transform: uppercase;
}

.gate-title {
  max-width: none;
  margin: 0;
  color: #4b1727;
  font-size: clamp(2.25rem, 8vw, 5.4rem);
  line-height: 0.98;
  text-shadow: none;
}

.gate-label {
  color: rgba(75, 23, 39, 0.82);
  font-size: 0.95rem;
  font-weight: 680;
}

.gate-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.nickname-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.nickname-grid label {
  display: grid;
  gap: 8px;
  color: rgba(75, 23, 39, 0.82);
  font-size: 0.92rem;
  font-weight: 760;
  text-align: left;
}

.gate-row input,
.gate-row button,
.nickname-grid input,
.gate-wide-button {
  min-height: 58px;
  border: 1px solid rgba(75, 23, 39, 0.18);
  border-radius: 8px;
}

.gate-row input,
.nickname-grid input {
  min-width: 0;
  width: 100%;
  padding: 0 16px;
  background: rgba(255, 250, 252, 0.82);
  color: #4b1727;
  font-size: 1.05rem;
  outline: none;
}

.gate-row input:focus,
.nickname-grid input:focus {
  border-color: rgba(75, 23, 39, 0.52);
  box-shadow: 0 0 0 4px rgba(255, 250, 252, 0.42);
}

.gate-row button,
.gate-wide-button {
  padding: 0 22px;
  background: #4b1727;
  color: #fffafc;
  cursor: pointer;
  transition:
    transform 160ms ease,
    background 160ms ease;
}

.gate-row button:hover,
.gate-row button:focus-visible,
.gate-wide-button:hover,
.gate-wide-button:focus-visible {
  background: #6f253e;
  outline: none;
}

.gate-row button:active,
.gate-wide-button:active {
  transform: translateY(1px);
}

.gate-message {
  min-height: 22px;
  margin: 0;
  color: #7c1f3d;
  font-size: 0.95rem;
  line-height: 1.45;
}

.shell {
  width: 100%;
  height: 100svh;
  min-height: 100svh;
  overflow: hidden;
}

.stage {
  position: relative;
  width: 100%;
  height: 100svh;
  min-height: 100svh;
  overflow: hidden;
  isolation: isolate;
  background: var(--ink);
}

.stage[data-layout="intro"],
.stage[data-layout="message"],
.stage[data-layout="connect"],
.stage[data-layout="question"],
.stage[data-layout="photo"],
.stage[data-layout="memories"] {
  background:
    radial-gradient(circle at 24% 18%, rgba(255, 250, 252, 0.56), transparent 26%),
    linear-gradient(135deg, #ffd1df 0%, #f8a9c1 48%, #ee7fa5 100%);
}

.stage[data-layout="sad"] {
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 250, 252, 0.16), transparent 28%),
    linear-gradient(135deg, #4e5967 0%, #2f3744 52%, #171c25 100%);
}

.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(90deg, rgba(15, 23, 21, 0.88) 0%, rgba(15, 23, 21, 0.7) 36%, rgba(15, 23, 21, 0.2) 72%, rgba(15, 23, 21, 0.42) 100%),
    linear-gradient(180deg, rgba(15, 23, 21, 0.12), rgba(15, 23, 21, 0.5));
  pointer-events: none;
}

.stage[data-layout="intro"]::after,
.stage[data-layout="message"]::after,
.stage[data-layout="connect"]::after,
.stage[data-layout="question"]::after,
.stage[data-layout="photo"]::after,
.stage[data-layout="memories"]::after,
.stage[data-layout="sad"]::after {
  display: none;
}

.stage[data-layout="sad"] .side-avatar {
  display: none;
}

.side-avatar {
  position: absolute;
  top: 50%;
  z-index: 3;
  width: clamp(160px, 20vw, 270px);
  display: grid;
  justify-items: center;
  gap: 10px;
  color: #6d253e;
  transform: translateY(-50%);
  pointer-events: none;
}

.side-avatar-left {
  left: clamp(22px, 4vw, 58px);
}

.side-avatar-right {
  right: clamp(22px, 4vw, 58px);
}

.side-avatar img {
  width: 100%;
  display: block;
  filter: drop-shadow(0 18px 28px rgba(109, 37, 62, 0.2));
}

.side-avatar span {
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 250, 252, 0.62);
  box-shadow: 0 8px 20px rgba(109, 37, 62, 0.1);
  font-size: 0.82rem;
  font-weight: 760;
}

.media-pane {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: #203532;
}

.stage[data-layout="intro"] .media-pane,
.stage[data-layout="message"] .media-pane,
.stage[data-layout="connect"] .media-pane,
.stage[data-layout="question"] .media-pane,
.stage[data-layout="photo"] .media-pane,
.stage[data-layout="memories"] .media-pane,
.stage[data-layout="sad"] .media-pane {
  display: none;
}

.media-pane::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(255, 250, 242, 0.06) 0,
      rgba(255, 250, 242, 0.06) 1px,
      transparent 1px,
      transparent 34px
    );
  opacity: 0.8;
  pointer-events: none;
}

.media-pane[data-tone="start"] {
  background: #284942;
}

.media-pane[data-tone="sorry"] {
  background: #6f3e45;
}

.media-pane[data-tone="memory"] {
  background: #4a668b;
}

.media-pane[data-tone="future"] {
  background: #667145;
}

.media-pane[data-tone="close"] {
  background: #2f3439;
}

#scene-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transform: scale(1.015);
  transition:
    opacity 240ms ease,
    transform 420ms ease;
}

#scene-image.is-loaded {
  opacity: 1;
  transform: scale(1);
}

.media-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  align-items: center;
  justify-items: end;
  padding: clamp(22px, 8vw, 96px);
  color: rgba(255, 250, 242, 0.72);
}

.media-fallback span {
  width: min(36vw, 360px);
  min-width: 190px;
  aspect-ratio: 4 / 5;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 250, 242, 0.34);
  font-family: "Lora", Georgia, serif;
  font-size: clamp(4rem, 12vw, 9rem);
  line-height: 1;
}

.story-pane {
  position: relative;
  z-index: 2;
  width: min(650px, 100%);
  height: 100svh;
  min-height: 100svh;
  margin-left: clamp(0px, 7vw, 92px);
  padding: clamp(22px, 5vw, 64px);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: clamp(22px, 4svh, 38px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 250, 242, 0.34) transparent;
}

.stage[data-layout="intro"] .story-pane,
.stage[data-layout="message"] .story-pane,
.stage[data-layout="connect"] .story-pane,
.stage[data-layout="question"] .story-pane,
.stage[data-layout="photo"] .story-pane,
.stage[data-layout="memories"] .story-pane,
.stage[data-layout="sad"] .story-pane {
  width: 100%;
  max-width: min(720px, calc(100% - 500px));
  margin: 0 auto;
  padding: clamp(28px, 6vw, 72px);
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #4b1727;
}

.stage[data-layout="sad"] .story-pane {
  max-width: min(780px, calc(100% - 48px));
  color: #fffafc;
}

.stage[data-layout="photo"] .story-pane {
  max-width: min(600px, calc(100% - 500px));
  gap: clamp(14px, 2.6svh, 22px);
}

.stage[data-layout="memories"] .story-pane {
  max-width: min(560px, calc(100% - 500px));
  gap: clamp(12px, 2svh, 18px);
}

.stage[data-layout="intro"] .topline,
.stage[data-layout="message"] .topline,
.stage[data-layout="connect"] .topline,
.stage[data-layout="intro"] #screen-body,
.stage[data-layout="message"] #screen-body,
.stage[data-layout="intro"] .route-bar,
.stage[data-layout="message"] .route-bar,
.stage[data-layout="connect"] .route-bar,
.stage[data-layout="question"] .topline,
.stage[data-layout="question"] #screen-body,
.stage[data-layout="question"] .route-bar,
.stage[data-layout="photo"] .topline,
.stage[data-layout="photo"] .route-bar,
.stage[data-layout="memories"] .topline,
.stage[data-layout="memories"] .route-bar,
.stage[data-layout="sad"] .topline,
.stage[data-layout="sad"] #screen-body,
.stage[data-layout="sad"] .route-bar {
  display: none;
}

.stage[data-layout="memories"] h1 {
  max-width: min(14ch, 90vw);
  color: #4b1727;
  font-size: clamp(2.15rem, 4.8vw, 4.4rem);
  line-height: 0.98;
  text-align: center;
}

.stage[data-layout="intro"] h1,
.stage[data-layout="question"] h1,
.stage[data-layout="photo"] h1 {
  max-width: min(16ch, 92vw);
  color: #4b1727;
  font-size: clamp(2.2rem, 6.4vw, 5.8rem);
  line-height: 1.04;
  text-shadow: none;
}

.stage[data-layout="photo"] h1 {
  max-width: 18ch;
  font-size: clamp(1.55rem, 3.5vw, 3rem);
  line-height: 1.04;
}

/* Full pane width so the photo / reel card centres under the title. */
.stage[data-layout="photo"] #screen-body,
.stage[data-layout="memories"] #screen-body {
  width: 100%;
  max-width: 100%;
  display: grid;
  place-items: center;
}

.center-photo {
  width: min(100%, 300px);
  max-height: 44svh;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 18px;
  border: 8px solid rgba(255, 250, 252, 0.78);
  box-shadow: 0 24px 56px rgba(109, 37, 62, 0.22);
}

.memory-card {
  position: relative;
  width: min(100%, 360px);
  margin: 0;
}

.memory-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 24px;
  pointer-events: none;
  box-shadow: 0 24px 60px rgba(109, 37, 62, 0.2);
}

.memory-media-wrap {
  position: relative;
  width: 100%;
  height: min(58svh, 560px);
  display: grid;
  /* One full-size cell, so tall images and videos fit inside instead of being cropped. */
  grid-template: 100% / 100%;
  place-items: center;
  overflow: hidden;
  border-radius: 24px;
  background: rgba(255, 250, 252, 0.9);
  border: 1px solid rgba(75, 23, 39, 0.1);
  background: #120910;
}

/* A single landscape video (the "two worlds" film) gets a wider 16:9 card. */
.stage[data-layout="memories"] #screen-body:has(.is-wide) {
  width: 100%;
  max-width: 100%;
}

.stage .memory-card.is-wide {
  width: min(100%, 880px);
}

.memory-card.is-wide .memory-media-wrap {
  height: auto;
  aspect-ratio: 16 / 9;
  background: #000;
}

.stage[data-layout="memories"] .story-pane:has(.is-wide) {
  max-width: min(920px, calc(100% - 640px));
}

.memory-card.is-shot .memory-media-wrap {
  aspect-ratio: var(--media-ratio);
}

.memory-card.is-wide .memory-volume-hint {
  display: none;
}

.memory-card.is-wide figcaption {
  position: static;
  min-height: 0;
  padding: 12px 4px 0;
  background: none;
  grid-template-columns: 1fr;
  color: #4b1727;
  text-align: center;
  text-shadow: none;
}

@media (max-width: 760px) {
  .stage[data-layout="memories"] .story-pane:has(.is-wide) {
    max-width: 100%;
    padding: 18px 16px 104px;
  }
}

.memory-media {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.memory-play-button {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 6;
  min-width: clamp(116px, 15vw, 150px);
  min-height: clamp(74px, 9vw, 92px);
  border: 2px solid rgba(255, 250, 252, 0.82);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 22px;
  background: rgba(75, 23, 39, 0.86);
  color: #fffafc;
  box-shadow: 0 22px 54px rgba(18, 9, 16, 0.44);
  font-size: clamp(1rem, 2.4vw, 1.25rem);
  font-weight: 820;
  line-height: 1;
  transform: translate(-50%, -50%);
  cursor: pointer;
  backdrop-filter: blur(12px);
}

.memory-play-button span {
  font-size: clamp(1.55rem, 3.2vw, 2.25rem);
  line-height: 1;
}

.memory-play-button strong {
  font: inherit;
}

.memory-play-button:hover,
.memory-play-button:focus-visible {
  outline: none;
  background: rgba(111, 37, 62, 0.84);
  box-shadow: 0 24px 60px rgba(18, 9, 16, 0.4);
}

.memory-play-button[hidden] {
  display: none;
}

.memory-card figcaption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  min-height: 72px;
  padding: 24px 16px 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px;
  background: linear-gradient(180deg, rgba(18, 9, 16, 0), rgba(18, 9, 16, 0.76));
  color: #fffafc;
  font-size: clamp(0.84rem, 1.7vw, 1rem);
  font-weight: 760;
  line-height: 1.22;
  text-align: left;
}

.memory-counter {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 250, 252, 0.18);
  font-size: 0.78rem;
  white-space: nowrap;
}

.memory-volume-hint {
  position: absolute;
  left: 50%;
  top: calc(50% - 58px);
  z-index: 7;
  margin: 0;
  padding: 7px 13px;
  border-radius: 999px;
  background: rgba(255, 250, 252, 0.88);
  box-shadow: 0 12px 30px rgba(18, 9, 16, 0.24);
  color: #6d253e;
  font-size: clamp(0.78rem, 1.5vw, 0.92rem);
  font-weight: 820;
  line-height: 1.25;
  text-align: center;
  white-space: nowrap;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.memory-volume-hint[hidden] {
  display: none;
}

.stage[data-layout="sad"] h1 {
  max-width: min(18ch, 92vw);
  color: #fffafc;
  font-size: clamp(2rem, 5.2vw, 4.8rem);
  line-height: 1.08;
  text-shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
}

.stage[data-layout="message"] .choices,
.stage[data-layout="connect"] .choices,
.stage[data-layout="intro"] .choices,
.stage[data-layout="question"] .choices,
.stage[data-layout="photo"] .choices,
.stage[data-layout="memories"] .choices {
  width: min(240px, 100%);
}

.stage[data-layout="question"] .story-pane {
  max-width: min(820px, calc(100% - 48px));
}

.stage[data-layout="question"] h1 {
  max-width: min(18ch, 92vw);
  font-size: clamp(2rem, 5vw, 4.4rem);
}

.stage[data-layout="question"] .choices {
  width: min(380px, 100%);
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stage[data-layout="message"] .choice-button,
.stage[data-layout="connect"] .choice-button,
.stage[data-layout="intro"] .choice-button,
.stage[data-layout="question"] .choice-button,
.stage[data-layout="photo"] .choice-button,
.stage[data-layout="memories"] .choice-button {
  min-height: 56px;
  display: flex;
  justify-content: center;
  text-align: center;
}

.stage[data-layout="message"] .choice-button .arrow,
.stage[data-layout="connect"] .choice-button .arrow,
.stage[data-layout="intro"] .choice-button .arrow,
.stage[data-layout="question"] .choice-button .arrow,
.stage[data-layout="photo"] .choice-button .arrow,
.stage[data-layout="memories"] .choice-button .arrow {
  display: none;
}

.topline {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.nav-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 250, 242, 0.08);
  color: var(--white);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.nav-button:hover,
.nav-button:focus-visible {
  border-color: rgba(255, 250, 242, 0.5);
  background: rgba(255, 250, 242, 0.16);
  outline: none;
}

.nav-button:active {
  transform: translateY(1px);
}

.nav-button[hidden] {
  display: none;
}

#eyebrow {
  margin: 0;
  color: var(--moss);
  font-size: 0.78rem;
  line-height: 1.4;
  font-weight: 720;
  letter-spacing: 0;
  text-transform: uppercase;
}

.copy {
  display: grid;
  gap: 18px;
}

h1 {
  margin: 0;
  max-width: min(16ch, 92vw);
  font-family: "Lora", Georgia, serif;
  font-size: clamp(2.2rem, 6.4vw, 5.8rem);
  line-height: 1.04;
  letter-spacing: 0;
  text-wrap: balance;
  text-align: center;
  text-shadow: 0 12px 42px rgba(0, 0, 0, 0.32);
}

#screen-body {
  max-width: min(32ch, 92vw);
  display: grid;
  gap: 14px;
  color: rgba(255, 250, 242, 0.88);
  font-size: clamp(1rem, 1.45vw, 1.16rem);
  line-height: 1.7;
  text-align: center;
  text-wrap: pretty;
}

#screen-body p {
  margin: 0;
}

#screen-body p:only-child {
  font-size: clamp(1.1rem, 1.8vw, 1.34rem);
  line-height: 1.72;
}

.choices {
  display: grid;
  gap: 10px;
}

.choice-button {
  width: 100%;
  min-height: 58px;
  border: 1px solid rgba(75, 23, 39, 0.18);
  border-radius: 8px;
  padding: 14px 16px;
  background: #4b1727;
  color: #fffafc;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 14px;
  text-align: left;
  cursor: pointer;
  backdrop-filter: blur(14px);
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease,
    background 160ms ease;
}

.choice-button:hover,
.choice-button:focus-visible {
  border-color: rgba(75, 23, 39, 0.32);
  box-shadow: 0 14px 34px rgba(75, 23, 39, 0.22);
  background: #6f253e;
  outline: none;
}

.choice-button:active {
  transform: translateY(1px);
}

.choice-button span:first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.choice-button .arrow {
  color: var(--sun);
  font-size: 1.2rem;
}

.route-bar {
  display: grid;
  gap: 10px;
}

.route-track {
  height: 5px;
  overflow: hidden;
  background: rgba(255, 250, 242, 0.18);
}

#route-progress {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--rose), var(--sun), var(--moss), var(--lake));
  transition: width 260ms ease;
}

#route-note {
  min-height: 18px;
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

@media (max-width: 760px) {
  .gate-card {
    gap: 16px;
  }

  .gate-row {
    grid-template-columns: 1fr;
  }

  .nickname-grid {
    grid-template-columns: 1fr;
  }

  .gate-row button {
    width: 100%;
  }

  .stage::after {
    background:
      linear-gradient(180deg, rgba(15, 23, 21, 0.04) 0%, rgba(15, 23, 21, 0.42) 38%, rgba(15, 23, 21, 0.9) 100%),
      linear-gradient(90deg, rgba(15, 23, 21, 0.28), rgba(15, 23, 21, 0.18));
  }

  .side-avatar {
    top: auto;
    bottom: 18px;
    width: 94px;
    transform: none;
  }

  .stage[data-layout="message"] .story-pane,
  .stage[data-layout="connect"] .story-pane,
  .stage[data-layout="intro"] .story-pane {
    max-width: 100%;
    padding-inline: 112px;
  }

  .stage[data-layout="question"] .story-pane {
    max-width: 100%;
    padding: 24px 24px 190px;
  }

  /* Keep the text above the avatars, which sit along the bottom on phones. */
  .stage[data-layout="message"] .story-pane,
  .stage[data-layout="connect"] .story-pane {
    max-width: 100%;
    padding: 28px 24px 200px;
    justify-content: center;
  }

  .stage[data-layout="message"] h1 {
    font-size: 1.2rem;
  }

  .stage[data-layout="connect"] h1 {
    font-size: 1.02rem;
  }

  .stage[data-layout="memories"] h1 {
    max-width: 100%;
    font-size: 1.7rem;
    line-height: 1.1;
  }

  .stage[data-layout="photo"] .story-pane {
    max-width: 100%;
    padding: 28px 108px 112px;
    gap: 12px;
  }

  .stage[data-layout="memories"] .story-pane {
    max-width: 100%;
    padding: 18px 112px 104px;
    gap: 12px;
  }

  .media-fallback {
    align-items: start;
    justify-items: center;
    padding-top: 34px;
  }

  .media-fallback span {
    width: min(58vw, 260px);
    min-width: 150px;
  }

  .story-pane {
    width: 100%;
    margin-left: 0;
    padding: 20px;
    gap: 20px;
  }

  h1 {
    max-width: min(15ch, 92vw);
    font-size: clamp(1.95rem, 10vw, 3.6rem);
    line-height: 1.08;
  }

  .stage[data-layout="intro"] h1 {
    max-width: min(15ch, 92vw);
    font-size: clamp(2rem, 9.6vw, 3.8rem);
  }

  .stage[data-layout="question"] h1 {
    max-width: min(16ch, 92vw);
    font-size: clamp(1.85rem, 8.6vw, 3.3rem);
  }

  .stage[data-layout="photo"] h1 {
    max-width: 18ch;
    font-size: clamp(1.35rem, 6.6vw, 2rem);
  }

  .stage[data-layout="photo"] #screen-body {
    width: min(240px, 100%);
  }

  .stage[data-layout="memories"] #screen-body {
    width: min(280px, 100%);
  }

  .center-photo {
    width: min(100%, 220px);
    max-height: 36svh;
    border-width: 6px;
    border-radius: 14px;
  }

  .memory-card {
    width: min(100%, 310px);
    border-radius: 18px;
  }

  .memory-media-wrap {
    height: min(48svh, 410px);
  }

  .memory-card figcaption {
    min-height: 64px;
    padding: 12px 12px 12px;
    gap: 7px;
    font-size: 0.8rem;
  }

  .memory-counter {
    font-size: 0.7rem;
  }

  .stage[data-layout="question"] .choices {
    grid-template-columns: 1fr;
  }

  #screen-body {
    font-size: 0.98rem;
    line-height: 1.62;
  }

  #screen-body p:only-child {
    font-size: clamp(1.04rem, 4.4vw, 1.22rem);
  }

  .choice-button {
    min-height: 54px;
    padding: 12px 14px;
  }
}

@media (max-height: 700px) {
  .story-pane {
    gap: 16px;
    padding-top: 18px;
    padding-bottom: 18px;
  }

  .copy {
    gap: 12px;
  }

  h1 {
    font-size: clamp(2rem, 8svh, 4.8rem);
  }

  #screen-body {
    gap: 10px;
    font-size: 0.95rem;
    line-height: 1.54;
  }

  .choice-button {
    min-height: 48px;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .stage[data-layout="photo"] .story-pane {
    gap: 10px;
  }

  .stage[data-layout="memories"] .story-pane {
    gap: 10px;
  }

  .center-photo {
    max-height: 34svh;
  }

  .memory-media-wrap {
    height: min(45svh, 360px);
  }
}

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

.stage[data-layout="message"] h1 {
  max-width: 26ch;
  color: #4b1727;
  font-size: clamp(1.35rem, 3.2vw, 2.4rem);
  line-height: 1.3;
  text-shadow: none;
}

.music-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 23;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 250, 242, 0.85);
  box-shadow: 0 4px 14px rgba(75, 23, 39, 0.18);
  font-size: 1.2rem;
  cursor: pointer;
}

.soundcloud-backdrop {
  position: fixed;
  inset: 0;
  z-index: 18;
  border: 0;
  background: rgba(255, 190, 214, 0.58);
  backdrop-filter: blur(3px);
  cursor: pointer;
}

.soundcloud-backdrop[hidden] {
  display: none;
}

body.is-soundcloud-open .music-toggle {
  top: max(18px, env(safe-area-inset-top));
  right: max(18px, env(safe-area-inset-right));
  width: 58px;
  height: 58px;
  background: rgba(255, 250, 252, 0.94);
  color: #f6a8c5;
  box-shadow: 0 18px 44px rgba(75, 23, 39, 0.22);
  font-size: 2.15rem;
  font-weight: 500;
}

body.is-soundcloud-open .music-toggle::before {
  content: "Hide ở đây →";
  position: absolute;
  top: 50%;
  right: calc(100% + 14px);
  width: max-content;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 250, 252, 0.92);
  color: #6d253e;
  box-shadow: 0 12px 32px rgba(75, 23, 39, 0.2);
  font-size: clamp(0.88rem, 2vw, 1.05rem);
  font-weight: 820;
  line-height: 1;
  transform: translateY(-50%);
  pointer-events: none;
}

.music-toggle[hidden] {
  display: none;
}

.soundcloud-player {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 22;
  width: min(720px, calc(100vw - 42px));
  padding: clamp(10px, 2vw, 18px);
  border-radius: 24px;
  background: rgba(255, 250, 252, 0.94);
  box-shadow: 0 28px 72px rgba(75, 23, 39, 0.28);
  transform: translate(-50%, -50%);
}

.soundcloud-player iframe {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 10px;
}

.soundcloud-hint {
  position: relative;
  margin: 12px 4px 2px;
  color: #6d253e;
  font-size: clamp(1rem, 2.5vw, 1.28rem);
  font-weight: 750;
  line-height: 1.35;
  text-align: center;
}

.soundcloud-player[hidden] {
  display: none;
}

.stage[data-layout="connect"] h1 {
  max-width: 30ch;
  color: #4b1727;
  font-size: clamp(1.15rem, 2.6vw, 1.9rem);
  line-height: 1.35;
  text-shadow: none;
}

.connect {
  display: grid;
  justify-items: center;
  gap: 14px;
  margin-top: clamp(16px, 4svh, 36px);
}

.connect-globe {
  width: clamp(96px, 16vw, 150px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #d9f1ff, #7cc4ea 60%, #3f8fc0);
  box-shadow: 0 12px 30px rgba(63, 143, 192, 0.3);
  transition: box-shadow 0.4s ease, transform 0.4s ease;
}

.connect-globe svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: rgba(255, 255, 255, 0.85);
  stroke-width: 2.5;
}

.connect-globe.is-connected {
  transform: scale(1.06);
  box-shadow: 0 0 0 10px rgba(255, 143, 177, 0.35), 0 0 46px rgba(255, 112, 160, 0.75);
}

.connect-status {
  margin: 0;
  color: #6d253e;
  font-size: 0.95rem;
  font-weight: 700;
}

.connect-layer {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.connect-layer svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.connect-cable {
  fill: none;
  stroke-width: 8;
  stroke-linecap: round;
  filter: drop-shadow(0 5px 8px rgba(109, 37, 62, 0.16));
}

.connect-cable-anh {
  stroke: #ff6f9f;
}

.connect-cable-em {
  stroke: #3b3642;
}

.connect-layer.is-connected .connect-cable-em {
  stroke: #ff6f9f;
}

.connect-plug {
  position: absolute;
  top: 0;
  left: 0;
  width: 58px;
  height: 42px;
  border: 2px solid rgba(255, 250, 252, 0.68);
  border-radius: 8px 8px 11px 11px;
  background:
    linear-gradient(90deg, #f2c45d 0 8px, transparent 8px 13px, #f2c45d 13px 21px, transparent 21px 26px, #f2c45d 26px 34px, transparent 34px 39px, #f2c45d 39px 47px, transparent 47px),
    linear-gradient(#6b6876, #34343f);
  background-position: 8px 5px, 0 0;
  background-size: 42px 9px, 100% 100%;
  background-repeat: no-repeat;
  box-shadow:
    0 8px 18px rgba(0, 0, 0, 0.26),
    inset 0 -11px 0 rgba(255, 255, 255, 0.1);
  cursor: grab;
  pointer-events: auto;
  touch-action: none;
  animation: plug-nudge 1.6s ease-in-out infinite;
}

.connect-plug::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -9px;
  width: 26px;
  height: 13px;
  border-radius: 5px 5px 2px 2px;
  background: #4a4653;
  transform: translateX(-50%);
}

.connect-plug::after {
  content: "";
  position: absolute;
  left: 11px;
  right: 11px;
  bottom: -7px;
  height: 9px;
  border-radius: 0 0 7px 7px;
  background: #2d2a34;
}

.connect-plug span {
  position: absolute;
  left: 18px;
  right: 18px;
  top: -15px;
  height: 9px;
  border: 2px solid #4a4653;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  transform: skewX(-9deg);
}

.connect-plug i {
  position: absolute;
  top: 18px;
  width: 4px;
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 250, 252, 0.26);
}

.connect-plug i:nth-of-type(1) {
  left: 17px;
}

.connect-plug i:nth-of-type(2) {
  left: 27px;
}

.connect-plug i:nth-of-type(3) {
  left: 37px;
}

.connect-plug.is-dragging {
  cursor: grabbing;
  animation: none;
}

.connect-layer.is-connected .connect-plug {
  animation: none;
  cursor: default;
}

@keyframes plug-nudge {
  50% {
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25), 0 0 0 8px rgba(255, 143, 177, 0.35);
  }
}

.miss-popup {
  position: fixed;
  top: 18%;
  left: 50%;
  z-index: 30;
  margin: 0;
  padding: 14px 24px;
  border-radius: 999px;
  background: #fffafc;
  box-shadow: 0 14px 34px rgba(109, 37, 62, 0.25);
  color: #b0305f;
  font-family: "Lora", Georgia, serif;
  font-size: clamp(1.1rem, 2.4vw, 1.5rem);
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px) scale(0.92);
}

.miss-popup.is-visible {
  animation: miss-popup 3.75s ease forwards;
}

@keyframes miss-popup {
  0% {
    opacity: 0;
    transform: translate(-50%, 12px) scale(0.92);
  }
  10%,
  80% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -8px) scale(0.98);
  }
}

/* ---------- Centring fix ----------
   .copy is a grid; items narrower than the track (h1 with a ch max-width, the
   connect widget) were packed to the start, so they sat left of centre. */
.copy {
  width: 100%;
  justify-items: center;
}

/* ---------- Fluid sizing for laptops and large screens ----------
   Everything scales with the viewport (vw for width, svh for height) so big
   screens are filled, while the centre column always clears the side avatars. */
@media (min-width: 761px) {
  .gate-screen,
  .stage {
    --av-w: clamp(160px, min(15vw, 30svh), 440px);
    --av-x: clamp(22px, 3vw, 96px);
    --side: calc(var(--av-w) + var(--av-x) + clamp(16px, 2vw, 48px));
    --pane-pad-y: clamp(20px, 4svh, 64px);
  }

  .gate-screen {
    padding-inline: var(--side);
  }

  .side-avatar {
    width: var(--av-w);
    gap: clamp(8px, 1svh, 16px);
  }

  .side-avatar-left {
    left: var(--av-x);
  }

  .side-avatar-right {
    right: var(--av-x);
  }

  .side-avatar span {
    padding: clamp(5px, 0.5svh, 9px) clamp(10px, 1vw, 18px);
    font-size: clamp(0.82rem, 0.9vw, 1.35rem);
  }

  .stage[data-layout="intro"] .story-pane,
  .stage[data-layout="message"] .story-pane,
  .stage[data-layout="connect"] .story-pane,
  .stage[data-layout="question"] .story-pane,
  .stage[data-layout="photo"] .story-pane,
  .stage[data-layout="memories"] .story-pane,
  .stage[data-layout="memories"] .story-pane:has(.is-wide) {
    max-width: calc(100% - 2 * var(--side));
    padding: var(--pane-pad-y) clamp(12px, 1.5vw, 40px);
  }

  .stage[data-layout="sad"] .story-pane {
    max-width: min(1500px, calc(100% - 48px));
  }

  .stage[data-layout="intro"] .story-pane,
  .stage[data-layout="message"] .story-pane,
  .stage[data-layout="connect"] .story-pane,
  .stage[data-layout="question"] .story-pane,
  .stage[data-layout="sad"] .story-pane {
    gap: clamp(22px, 4svh, 56px);
  }

  .stage[data-layout="photo"] .story-pane {
    gap: clamp(14px, 2.4svh, 34px);
  }

  .stage[data-layout="memories"] .story-pane {
    gap: clamp(12px, 2svh, 30px);
  }

  /* Titles */
  .stage[data-layout="intro"] h1 {
    max-width: 16ch;
    font-size: clamp(2.2rem, min(5.4vw, 10svh), 9rem);
  }

  .stage[data-layout="question"] h1 {
    max-width: 18ch;
    font-size: clamp(2rem, min(4.4vw, 8.5svh), 7.5rem);
  }

  .stage[data-layout="photo"] h1 {
    max-width: 20ch;
    font-size: clamp(1.55rem, min(3.2vw, 5.6svh), 4.6rem);
  }

  .stage[data-layout="memories"] h1 {
    max-width: 20ch;
    font-size: clamp(2.15rem, min(4vw, 7.5svh), 6.5rem);
  }

  .stage[data-layout="message"] h1 {
    max-width: 30ch;
    font-size: clamp(1.35rem, min(2.5vw, 4.4svh), 3.6rem);
  }

  .stage[data-layout="connect"] h1 {
    max-width: 32ch;
    font-size: clamp(1.15rem, min(2.1vw, 3.6svh), 3rem);
  }

  .stage[data-layout="sad"] h1 {
    max-width: 18ch;
    font-size: clamp(2rem, min(5vw, 10svh), 8rem);
  }

  /* Photo page: the photo takes the height that is left over. */
  .center-photo {
    width: min(100%, 42svh);
    max-height: 56svh;
    border-width: clamp(8px, 0.9svh, 14px);
    border-radius: clamp(18px, 2svh, 30px);
  }

  /* Memory reel: a 3:4 frame sized from the viewport height. */
  .memory-card {
    width: min(100%, calc(62svh * 0.75));
  }

  .memory-media-wrap {
    height: 62svh;
  }

  .memory-card figcaption {
    min-height: clamp(72px, 8svh, 120px);
    padding: clamp(24px, 3svh, 44px) clamp(16px, 1.4vw, 28px) clamp(14px, 1.6svh, 24px);
    font-size: clamp(0.84rem, 1vw, 1.35rem);
  }

  .memory-counter {
    font-size: clamp(0.78rem, 0.8vw, 1.1rem);
  }

  /* Two worlds film: 16:9, as wide as the column and the height allow. */
  .stage .memory-card.is-wide {
    width: min(100%, calc(66svh * 16 / 9));
  }

  /* A screenshot under a long paragraph stays short enough to fit with it. */
  .stage .memory-card.is-wide.is-shot {
    width: min(100%, calc(34svh * var(--media-ratio)));
  }

  .memory-card.is-wide figcaption {
    min-height: 0;
    padding: clamp(10px, 1.4svh, 20px) 4px 0;
  }

  /* Buttons */
  .stage[data-layout="message"] .choices,
  .stage[data-layout="connect"] .choices,
  .stage[data-layout="intro"] .choices,
  .stage[data-layout="photo"] .choices,
  .stage[data-layout="memories"] .choices {
    width: min(100%, clamp(240px, 15vw, 440px));
  }

  .stage[data-layout="question"] .choices {
    width: min(100%, clamp(380px, 30vw, 800px));
    gap: clamp(10px, 1vw, 20px);
  }

  .choice-button,
  .stage[data-layout="message"] .choice-button,
  .stage[data-layout="connect"] .choice-button,
  .stage[data-layout="intro"] .choice-button,
  .stage[data-layout="question"] .choice-button,
  .stage[data-layout="photo"] .choice-button,
  .stage[data-layout="memories"] .choice-button {
    min-height: clamp(56px, 6svh, 92px);
    border-radius: clamp(8px, 0.7vw, 16px);
    font-size: clamp(1rem, 0.55rem + 0.6vw, 1.7rem);
  }

  /* Cable finale */
  .connect-globe {
    width: clamp(96px, min(12vw, 20svh), 280px);
  }

  .connect-status {
    font-size: clamp(0.95rem, 1.1vw, 1.6rem);
  }

  /* Gate steps */
  .gate-card {
    width: min(100%, clamp(520px, 42vw, 1000px));
    gap: clamp(18px, 2.2svh, 36px);
  }

  .gate-eyebrow {
    font-size: clamp(0.78rem, 0.8vw, 1.25rem);
  }

  .gate-title {
    font-size: clamp(2.25rem, min(6vw, 11svh), 8rem);
  }

  .gate-row,
  .nickname-grid {
    gap: clamp(10px, 1vw, 20px);
  }

  .nickname-grid label {
    font-size: clamp(0.92rem, 1vw, 1.45rem);
  }

  .gate-row input,
  .gate-row button,
  .nickname-grid input,
  .gate-wide-button {
    min-height: clamp(58px, 6.5svh, 96px);
    border-radius: clamp(8px, 0.7vw, 16px);
    font-size: clamp(1.05rem, 1.1vw, 1.75rem);
  }

  .gate-row input,
  .nickname-grid input {
    padding: 0 clamp(16px, 1.4vw, 28px);
  }

  .gate-row button,
  .gate-wide-button {
    padding: 0 clamp(22px, 2vw, 40px);
  }

  .gate-message {
    font-size: clamp(0.95rem, 1vw, 1.45rem);
  }
}

/* Phones: pull the avatars to the edges so they clear the centre column. */
@media (max-width: 760px) {
  .side-avatar-left {
    left: 10px;
  }

  .side-avatar-right {
    right: 10px;
  }
}


/* Anh's speech bubble above his head on the last page, before and after the cable connects. */
.side-avatar .speech-bubble {
  position: absolute;
  bottom: calc(100% + 14px);
  left: 0;
  z-index: 5;
  width: clamp(220px, 24vw, 380px);
  margin: 0;
  padding: clamp(12px, 1.4vw, 18px) clamp(14px, 1.6vw, 22px);
  border-radius: 22px;
  background: #fffafc;
  color: #4b1727;
  font-family: "Lora", Georgia, serif;
  font-size: clamp(0.95rem, 1.25vw, 1.25rem);
  font-weight: 600;
  line-height: 1.45;
  text-align: left;
  box-shadow: 0 16px 40px rgba(109, 37, 62, 0.25);
  animation: bubble-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.side-avatar .speech-bubble::after {
  content: "";
  position: absolute;
  left: 42px;
  top: 100%;
  border: 12px solid transparent;
  border-top-color: #fffafc;
}

.side-avatar .speech-bubble[hidden] {
  display: none;
}

@keyframes bubble-pop {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.85);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 760px) {
  .side-avatar .speech-bubble {
    width: min(78vw, 320px);
    font-size: 0.9rem;
  }
}

/* Keep Anh (and his bubble) above the cable once the bubble shows. */
.side-avatar:has(.speech-bubble:not([hidden])) {
  z-index: 8;
}

@media (max-width: 760px) {
  /* On phones the bubble takes the place of the small status line. */
  .stage:has(#anh-bubble:not([hidden])) .connect-status {
    visibility: hidden;
  }
}

/* A small, low-resolution photo is shown near its real size instead of being blown up. */
.stage .memory-card.is-small {
  width: min(100%, 300px, calc(46svh * (var(--media-ratio))));
}

.stage .memory-card.is-small .memory-media-wrap {
  height: auto;
  aspect-ratio: var(--media-ratio);
  background: transparent;
}

.stage[data-layout="memories"] h1.is-long,
.stage[data-layout="photo"] h1.is-long {
  font-size: clamp(1.3rem, min(2.6vw, 4.6svh), 2.6rem);
  line-height: 1.2;
}

/* Reel: "Quay lại" and "Tiếp tục" side by side. */
.stage .choices:has(.is-back) {
  width: min(100%, 520px);
  grid-template-columns: 1fr 1fr;
}

.choice-button.is-back {
  background: rgba(255, 250, 252, 0.85);
  color: #4b1727;
}

/* The tiny "no" option under the globe. */
.connect-decline {
  position: relative;
  z-index: 6;
  margin-top: 2px;
  padding: 2px 6px;
  border: 0;
  background: none;
  color: rgba(109, 37, 62, 0.55);
  font: inherit;
  font-size: 0.62rem;
  text-decoration: underline;
  cursor: pointer;
}

.connect-decline[hidden] {
  display: none;
}
