:root { --app-height: min(100vh, var(--visible-height, 100vh)); }
@supports (height: 100dvh) {
  :root { --app-height: min(100dvh, var(--visible-height, 100dvh)); }
}

html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.phone { height: var(--app-height); min-height: 0; overflow: hidden; }
#stage, #stage > section, .reveal, .reveal > .discovery-certificate { height: 100%; min-height: 0; }
.finale-screen hogwarts-finale { --finale-page-height: var(--app-height); }

.screen.examination {
  --exam-choice-size: clamp(10.5px, calc(6.6px + var(--app-height) * .0075 + (100cqw - 372px) * .026), 13.5px);
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  container-type: inline-size;
}
.examination .scene {
  flex: none;
  height: calc(var(--app-height) * 232 / 844);
  aspect-ratio: auto;
  background: var(--base);
}
.phone[data-theme="light"] .examination .scene { background: #1c2023; }
.examination .scene img {
  object-fit: contain;
  object-position: center top !important;
}
.examination .scene .fade { bottom: max(0px, calc(100% - 50cqw)); }
.examination .paperwrap { flex: 1; min-height: 0; margin-bottom: 0; }
.examination .paperwrap .paper {
  --paper-top-edge: 19.64cqw;
  --paper-bottom-edge: 21.875cqw;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  /* Keep copy between the deckled top and the book's lower page stack. */
  padding: calc(var(--paper-top-edge) * .59) 12.5cqw calc(var(--paper-bottom-edge) * .74) 13cqw;
}
.examination .paper::before { border-width: var(--paper-top-edge) 0 var(--paper-bottom-edge); }
.examination .paper .progress { margin-block: clamp(5px, calc(10px + (var(--app-height) - 844px) * .026), 10px); flex: none; }
.examination .paper .question-block,
.examination .paper .choices { display: flex; flex-direction: column; flex: 1 0 auto; }
.examination .paper .choices {
  row-gap: clamp(3px, calc(11px + (var(--app-height) - 844px) * .04), 11px);
}
.examination .paper .question {
  margin: 7px auto 8px;
  font-size: clamp(12.5px, calc(8.5px + var(--app-height) * .0083), 15.5px);
  line-height: 1.33;
  letter-spacing: .015em;
}
.examination .paper .rule { margin-bottom: 2px; }
.examination .paper .choice {
  flex: 1 0 auto;
  align-items: center;
  padding: clamp(2px, calc(4px + (var(--app-height) - 844px) * .013), 4px) 3px;
  font-size: var(--exam-choice-size);
  line-height: clamp(12px, calc(3px + var(--app-height) * .0178), 18px);
}
.examination .paper .choice .letter { font-size: 18px; min-width: 17px; }
.examination .paper .exam-nav { flex: none; margin-top: auto; padding: 4px 3px 0; }
.examination .paper .folio { flex: none; padding-top: 2px; }

.screen.discovery-certificate {
  --certificate-top: calc(47px + env(safe-area-inset-top, 0px));
  --certificate-bottom: max(8px, env(safe-area-inset-bottom, 0px));
  padding-top: var(--certificate-top);
  padding-bottom: var(--certificate-bottom);
  padding-inline: max(8px, env(safe-area-inset-left, 0px)) max(8px, env(safe-area-inset-right, 0px));
  justify-content: center;
}
.discovery-certificate .certificate { flex: none; }
.discovery-certificate .certificate-sheet {
  width: min(calc(100% + 56px), calc((var(--app-height) - var(--certificate-top) - var(--certificate-bottom) - 48px) / 1.5));
  margin-top: 0;
}
.discovery-certificate .review { flex: none; margin-top: 0; }

@media (max-height: 590px) {
  .examination .paper .question { margin-block: 4px; }
}
