/* O mesmo enquadramento da porta fechada mantém o zoom consistente. */
.locked-door {
  height: auto;
  aspect-ratio: .82;
  background: linear-gradient(#0000, #0009), url('assets/locked-door-v1.png') center 48% / cover no-repeat;
}
.unlock-card {
  text-align: center;
  margin: auto;
  max-width: 570px;
  padding-top: 15px;
}
.unlock-card h1 { font-size: clamp(2.6rem, 11vw, 4.1rem); }
.unlock-card > p:not(.overline) {
  font: 600 1.15rem/1.3 var(--serif);
  max-width: 370px;
  margin: 15px auto;
}

/* Na transição aparece a ilustração da porta já aberta, em uma única imagem. */
.open-door {
  overflow: hidden;
  position: relative;
  isolation: isolate;
  height: auto;
  width: min(100%, 340px);
  aspect-ratio: .82;
  border: 10px solid #695c3e;
  border-radius: 150px 150px 8px 8px;
  background: url('assets/open-door-v1.png') center 48% / cover no-repeat;
  box-shadow: 0 0 35px #edbe5b77, inset 0 0 0 4px #251c18, 0 9px 26px #0009;
  animation: door-reveal .72s cubic-bezier(.16,.8,.25,1) both;
}
.open-door .door-light {
  position: absolute;
  z-index: 1;
  inset: 0;
  background: radial-gradient(ellipse at 50% 43%, rgba(255, 249, 213, .7) 0%, rgba(255, 225, 151, .32) 38%, transparent 73%);
  opacity: 0;
  transition: opacity .5s ease;
}
.open-door.is-opening .door-light { opacity: 1; }
#open-final:disabled { opacity: .65; cursor: wait; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .open-door .door-light { transition-duration: .01ms; }
}

@keyframes door-reveal {
  from { opacity: .5; transform: scale(.97); filter: brightness(.72); }
  to { opacity: 1; transform: none; filter: brightness(1); }
}

/* As metades recortam a mesma composição, sem repetir a porta. */
.encounter-door {
  overflow: hidden;
  isolation: isolate;
  background: url('assets/chapter-scene.png') center / cover no-repeat;
}
.door-leaf, .encounter-light {
  position: absolute;
  inset: 0;
  display: block;
}
.door-leaf {
  z-index: 2;
  background: linear-gradient(#0000, #0009), url('assets/locked-door-v1.png') center 48% / cover no-repeat;
  transition: transform 1.2s cubic-bezier(.22,.65,.3,1);
}
.leaf-left { clip-path: inset(0 50% 0 0); }
.leaf-right { clip-path: inset(0 0 0 50%); }
.is-opening .leaf-left { transform: translateX(-52%); }
.is-opening .leaf-right { transform: translateX(52%); }
.encounter-light {
  z-index: 1;
  background: radial-gradient(ellipse, #fff2b980, #efbf5c20 65%, transparent);
  opacity: 0;
  transition: opacity .8s;
}
.is-opening .encounter-light { opacity: 1; }
#use-key:disabled { cursor: wait; transform: none; }
.ambient.chapter-scene {
  background: linear-gradient(#06111a15, #06111a65), url('assets/chapter-scene.png') center top / cover no-repeat;
  animation: none;
}
.chapter-letter {
  margin: clamp(260px, 56vh, 550px) auto 0;
  padding: 30px clamp(20px, 5vw, 44px);
  background: linear-gradient(#061c23e8, #061c23f5);
  box-shadow: 0 12px 35px #0006;
  backdrop-filter: none;
}
.chapter-letter:before { display: none; }
@media (prefers-reduced-motion: reduce) {
  .door-leaf, .encounter-light { transition: none; }
}

/* Mobile UX: center the content in the actual browser viewport, not 100vh
   plus decorative offsets. Taller content can scroll naturally. */
@media (max-width: 649px) {
  .garden-shell { min-height: 100vh; min-height: 100dvh; overflow: clip; }
  .page {
    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
    padding: max(20px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  }
  .topbar { position: absolute; inset: 8px 12px auto; height: 0; z-index: 3; }
  .topbar .settings { position: absolute; right: 0; top: 0; }
  .page > article {
    width: 100%; min-width: 0; flex: 0 0 auto;
    margin: auto; padding-top: 0;
  }
  .hero-card h1 { font-size: clamp(2.65rem, 13.8vw, 4.45rem); line-height: .96; margin: 12px 0 19px; }
  .hero-card p:not(.overline) { margin: 9px auto; max-width: 34ch; font-size: clamp(1.06rem, 4.6vw, 1.25rem); line-height: 1.35; }
  .hero-card .primary { margin-top: 17px; }
  .intro-card h1 { font-size: clamp(1.85rem, 7.6vw, 2.75rem); }
  .intro-card p { line-height: 1.32; }
  .collection-strip { gap: 5px; margin: 20px auto 22px; }
  .collection-strip img { width: calc((100% - 30px) / 7); max-width: 52px; flex: 0 0 auto; }
  .map-card h1 { font-size: clamp(1.55rem, 6.3vw, 2.2rem); line-height: 1.08; margin: 10px auto 12px; }
  .journey-map { height: 330px; height: clamp(275px, 48svh, 390px); width: 100%; margin: 16px auto 19px; }
  .map-stop img { width: 63px; height: 63px; width: clamp(48px, 10svh, 70px); height: clamp(48px, 10svh, 70px); }
  .map-stop b { margin-top: 3px; padding: 3px 4px; }
  .journey-map .s0 { top: 7%; } .journey-map .s1 { top: 25%; }
  .journey-map .s2 { top: 45%; } .journey-map .s3 { top: 65%; }
  .riddle-image { width: min(100%, 255px); width: min(100%, 40svh, 280px); margin-bottom: 12px; }
  .riddle-card h1 { font-size: clamp(2.25rem, 10vw, 3.2rem); margin: 9px 0 13px; }
  .riddle-card > p:not(.overline):not(.feedback) { margin-bottom: 12px; font-size: clamp(1.05rem, 4.7vw, 1.22rem); }
  .number-pad { margin: 14px auto; gap: 7px; }
  .number-pad button { min-height: 44px; height: 44px; }
  .heart-glow { font-size: 4.5rem; }
  .locked-door,.open-door { width: min(100%, 240px); width: min(100%, 33svh, 255px); border-width: 8px; }
  .locked-card h1,.unlock-card h1,.opening-card h1 { font-size: clamp(2rem, 8.4vw, 2.95rem); line-height: 1.02; margin: 10px auto 13px; }
  .locked-card p:not(.overline),.unlock-card > p:not(.overline) { font-size: clamp(1.03rem, 4.3vw, 1.18rem); line-height: 1.3; margin: 10px auto; }
  .ornament { margin: 16px auto; }
  .primary { min-height: 52px; max-width: 100%; }
  .page > .final-letter { margin: auto; padding: 26px 22px; font-size: clamp(1.12rem, 4.5vw, 1.4rem); line-height: 1.33; }
  .page > .chapter-letter { padding: 26px 22px; }
}
@media (max-width: 649px) and (max-height: 610px) {
  .page { padding-block: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-bottom)); }
  .locked-door,.open-door { width: min(100%, 29svh, 205px); }
  .locked-card p:not(.overline) { margin: 8px auto; }
  .locked-card .ornament,.unlock-card .ornament { margin: 10px auto; }
  .journey-map { height: clamp(235px, 46svh, 290px); margin-block: 12px; }
  .map-stop img { width: clamp(44px, 9svh, 56px); height: clamp(44px, 9svh, 56px); }
}

/* The waiting screen has the longest copy; keep the door and message
   balanced as a single composition instead of forcing an extra scroll. */
@media (max-width: 649px) {
  .locked-card .locked-door { width: min(100%, 205px); width: min(100%, 27svh, 220px); }
  .locked-card .overline { margin: 12px auto 7px; }
  .locked-card h1 { margin: 8px auto 12px; }
  .locked-card .ornament { margin: 12px auto; }
}
@media (max-width: 649px) and (max-height: 610px) {
  .locked-card .locked-door { width: min(100%, 23svh, 185px); }
  .locked-card h1 { font-size: clamp(1.7rem, 7.8vw, 2.1rem); margin: 7px auto 9px; }
  .locked-card p:not(.overline) { margin: 7px auto; line-height: 1.25; }
  .locked-card .ornament { margin: 9px auto; }
}
