/* Captions take their ivory and ink colours from the equipment illustrations. */
:is(#openingChronicle, #finaleOverlay) {
  --ink: #101e2a;
  --paper: #fff9e9;
  --caption-size: clamp(1.65rem, 3.15vw, 3.5rem);
  font-family: "Yu Gothic UI", "Hiragino Kaku Gothic ProN", Meiryo, "Segoe UI", sans-serif;
}
#openingCaption, #finaleOverlay #finaleCaption {
  margin: 0 auto;
  color: var(--paper);
  font-size: var(--caption-size);
  font-weight: 750;
  line-height: 1.45;
  letter-spacing: .035em;
  text-align: center;
  text-wrap: balance;
  overflow-wrap: anywhere;
  line-break: strict;
  text-shadow: 0 2px var(--ink), 1px 3px var(--ink);
}
/* The photograph, masks, drift and sky use the same rules as the ending.
   Reserve the lower frame for subtitles, independently of photo dimensions. */
.opening-film {
  position: relative;
  z-index: 3;
  min-height: 100svh;
  margin: 0;
  padding: 70svh max(3vw, env(safe-area-inset-right)) max(1.25rem, env(safe-area-inset-bottom)) max(3vw, env(safe-area-inset-left));
}
#openingMedia {
  position: absolute;
  inset: 6svh 0 auto;
  height: 63svh;
}
#openingMedia .finale-memory-photo {
  width: min(var(--memory-w, min(57vw, 790px)), calc(var(--memory-height, 52svh) * var(--archive-ratio, 1.776833)));
}
@starting-style {
  #openingMedia .finale-memory-photo.is-current { opacity: 0; }
}
#openingSubtitles {
  position: relative;
  text-align: center;
  animation-duration: .6s;
  animation-timing-function: ease-out;
}
#openingSubtitles[data-cue="even"] { animation-name: finale-discovery-a; }
#openingSubtitles[data-cue="odd"] { animation-name: finale-discovery-b; }
#openingDate {
  display: block;
  margin: 0 auto .55em;
  color: #b2c9d9;
  font-size: clamp(.85rem, 1.25vw, 1.15rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: .1em;
}
#openingCaption {
  max-width: 37em;
  color: #f3f7fa;
  white-space: pre-line;
}
#openingCaption:focus { outline: none; }
.opening-controls {
  position: absolute;
  z-index: 4;
  inset: max(.4rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) auto auto;
  display: flex;
  gap: .75rem;
}
.opening-controls :is(a, button) {
  display: inline-grid;
  place-items: center;
  min-height: 44px;
  min-width: 44px;
  padding: 0 .45rem;
  border: 0;
  background: transparent;
  color: #a5bbc9;
  font: inherit;
  font-size: .875rem;
  text-decoration: none;
}
.opening-controls :is(a, button):is(:hover, :focus-visible) { color: #f3f7fa; }
.opening-controls :is(a, button):focus-visible { outline: 2px solid currentColor; outline-offset: 1px; }
.finale-memory-paused #openingSubtitles { animation-play-state: paused; }
.finale-reduced-motion #openingSubtitles { animation: none; }
@media (prefers-reduced-motion: reduce) { #openingSubtitles { animation: none; } }
@media (max-width: 600px) {
  .opening-film { padding-top: 60svh; }
  #openingMedia { top: 6svh; height: 54svh; }
}
@media (max-height: 500px) and (min-aspect-ratio: 3/2) {
  .opening-film { padding-top: 55svh; }
  #openingMedia { top: 5svh; height: 47svh; }
  #openingCaption { font-size: clamp(1.18rem, 4.5svh, 1.45rem); }
}

#finaleOverlay #finaleCaption {
  width: min(92vw, 32em);
  max-width: none;
  -webkit-text-stroke: .65px #d8bb82;
  paint-order: stroke fill;
  text-shadow: 0 2px 3px var(--ink), 0 0 10px #e0bf7833, 0 0 22px #d2a95c1f;
}
#finaleOverlay #finaleResults {
  border: 1px solid #c6a66c80;
  box-shadow: inset 0 0 12px #dcc38b0b, 0 0 18px #d5ac601a;
}
#finaleOverlay #finaleTitle { color: var(--paper); font-weight: 700; }
#finaleOverlay #finaleTitle::after,
#finaleOverlay .finale-world-label {
  font-size: clamp(.95rem, 1.45vw, 1.25rem);
  font-weight: 600;
}
#finaleOverlay .finale-score-grid span { font-size: clamp(.85rem, 1.1vw, 1rem); }
#finaleOverlay .finale-score-grid b { font-size: clamp(1.35rem, 2.5vw, 2rem); }
#finaleOverlay .finale-last-line { font-size: clamp(1rem, 1.4vw, 1.25rem); }

/* Opening the original score panel extends the same scene down the page.
   Anchor the final shot to its first viewport so it scrolls with the results. */
.finale-with-memories.finale-showing-scores #finaleMemories { display: contents; position: static; }
.finale-with-memories.finale-showing-scores :is(#finaleTitle, #finaleMemoryStage, #finaleWorld) { position: absolute; }
.finale-with-memories.finale-showing-scores #finaleMemoryStage { height: 100svh; }
.finale-with-memories.finale-showing-scores #finaleWorld { top: 50svh; }
.finale-world-group.finale-showing-scores #finaleWorld { top: 54svh; }
.finale-with-memories.finale-showing-scores #finaleResults { margin-top: 88svh; scroll-margin-bottom: 5.25rem; }
.finale-with-memories.finale-showing-scores #finaleMemoryControls {
  position: static;
  order: 1;
  margin-top: 1rem;
}
@media (max-width: 600px) {
  .finale-with-memories.finale-showing-scores #finaleWorld { top: 48svh; }
  .finale-world-group.finale-showing-scores #finaleWorld { top: 38svh; }
}

#modelHistoryList{list-style:none;margin:0;padding:0}
#modelHistoryList li+li{border-top:1px solid #54768c44;margin-top:10px;padding-top:2px}
#modelHistoryNext{font-variant-numeric:tabular-nums}
