/* The end of the whole game: a scene, the epilogue, the line of dijkgraven as credits, THE END. */
.finale {
  position: fixed; inset: 0; z-index: 60;
  overflow-y: auto; overflow-x: hidden;
  background: #05070f;
  color: var(--bar-ink);
  text-align: center;
  animation: fin-in 1.2s ease-out;
}
.finale[hidden], .dynasty[hidden] { display: none; } /* both overlays set display: grid */
@keyframes fin-in { from { opacity: 0; } }

.fin-scene {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block;
}
.fin-won .fin-sails { animation: fin-turn 14s linear infinite; }
@keyframes fin-turn { to { rotate: 360deg; } }
.fin-lost .fin-wave { animation: fin-bob 6s ease-in-out infinite alternate; }
.fin-lost .fin-wave.b { animation-duration: 4.5s; }
@keyframes fin-bob { to { translate: -60px 10px; } }
.fin-lost .fin-wolf { animation: fin-rise 3s ease-out both; }
@keyframes fin-rise { from { opacity: 0; translate: 0 60px; } }

.fin-roll {
  position: relative;
  display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center;
  gap: clamp(28px, 5vh, 56px);
  padding-bottom: 80px;
}
/* First screen: the tableau up top, the closing band (the line of dijkgraven, THE END, credits, new game) on the field. */
.fin-stage {
  width: 100%; min-height: 100dvh;
  display: grid; grid-template-rows: auto 1fr; align-items: end;
}
.fin-head {
  position: relative; align-self: start;
  display: grid; justify-items: center; gap: 14px;
  padding: clamp(28px, 6vh, 72px) 20px 24px;
  p { margin: 0; }
}
.fin-kicker { letter-spacing: .3em; text-transform: uppercase; font-size: clamp(.9rem, 1.6vh, 1.1rem); color: #f3d58a; }
.fin-title {
  margin: 0; max-width: 100%;
  font-size: clamp(2rem, min(7vh, 10vw), 5.2rem);
  font-weight: 600; line-height: 1.05; letter-spacing: .01em;
  text-wrap: balance; overflow-wrap: break-word;
  text-shadow: 0 4px 30px rgb(0 0 0 / .55);
}
.fin-lede, .fin-bell {
  max-width: min(46ch, 100%);
  font-size: clamp(1.05rem, 2.2vh, 1.4rem); line-height: 1.45;
  text-wrap: balance;
  text-shadow: 0 2px 12px rgb(0 0 0 / .8);
}
.fin-bell { max-width: min(62ch, 100%); font-style: italic; font-size: clamp(.95rem, 1.9vh, 1.15rem); color: #f1e6c8; }
.fin-page {
  margin: 4px 0 0;
  max-width: min(34ch, 100%);
  padding: 18px 24px 14px;
  background: #f6ecd2;
  color: var(--ink);
  border-radius: 4px;
  rotate: -1.5deg;
  box-shadow: 0 16px 40px rgb(0 0 0 / .5);
  p { font-size: clamp(1rem, 2vh, 1.3rem); font-style: italic; line-height: 1.4; text-shadow: none; }
  cite { display: block; margin-top: 8px; font-size: .85rem; font-style: normal; letter-spacing: .06em; color: #6a5638; }
}
/* Wide screens: the sealed page is pinned beside the headline, clear of the epilogue. */
@media (min-width: 1100px) {
  .fin-page { position: absolute; right: max(5vw, calc(50% - 44rem)); top: calc(clamp(28px, 6vh, 72px) + clamp(2rem, min(7vh, 10vw), 5.2rem) * 2.6); rotate: 3deg; width: 24ch; }
}

/* The closing band: a black strip across the new fields, like the end of a reel. */
.fin-close {
  position: relative;
  display: grid; justify-items: center; gap: clamp(12px, 2vh, 22px);
  padding: clamp(18px, 3vh, 32px) 20px clamp(20px, 3.5vh, 36px);
  background: linear-gradient(rgb(5 7 15 / 0), rgb(5 7 15 / .88) 40px);
  h3 { margin: 0; font-weight: 400; font-size: .85rem; letter-spacing: .3em; text-transform: uppercase; color: #d9cba6; }
}
.fin-reeves {
  --rule: #c9a24a;
  list-style: none; margin: 0; padding: 0;
  width: min(1500px, 100%);
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  li {
    position: relative;
    display: grid; align-content: start; gap: 2px;
    padding: 18px 6px 0;
    border-top: 3px solid var(--rule);
    animation: fin-up .7s ease-out both; animation-delay: calc(.2s + var(--i, 0) * .08s);
  }
  li::before { /* the knot on the line */
    content: ""; position: absolute; top: -8px; left: 50%; translate: -50% 0;
    width: 10px; height: 10px; border-radius: 50%; background: #05070f; border: 3px solid var(--rule);
  }
  li.last::before { background: #f3d58a; }
  b { font-weight: 600; font-size: clamp(1rem, 1.9vh, 1.2rem); line-height: 1.2; }
  em { color: #f3d58a; font-size: .95rem; }
  small { color: #d9cba6; font-variant-numeric: tabular-nums; }
  span { font-size: .85rem; font-style: italic; color: #b9ae94; }
  li.last span { color: #f3d58a; font-style: normal; font-weight: 600; }
}
@keyframes fin-up { from { opacity: 0; translate: 0 10px; } }

.fin-end {
  margin: 0;
  font-size: clamp(2.4rem, 8vh, 5.5rem); line-height: 1;
  letter-spacing: .32em; padding-left: .32em; /* re-centre the tracked word */
  text-transform: uppercase;
  color: #f3d58a;
  text-shadow: 0 0 40px rgb(224 180 82 / .45);
  animation: fin-up .6s ease-out 1s both;
}
.fin-names {
  margin: 0; width: min(1000px, 100%);
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 40px;
  div { display: grid; gap: 2px; }
  dt { font-size: .72rem; letter-spacing: .2em; text-transform: uppercase; color: #b9ae94; }
  dd { margin: 0; font-size: 1rem; }
}
.fin-new {
  font: inherit; font-size: 1.15rem; cursor: pointer;
  padding: .7em 2.2em; border-radius: 999px;
  border: 2px solid var(--gold); background: var(--gold); color: #1c1608;
  &:hover { background: #f3d58a; }
  &:focus-visible { outline: 3px solid #fff; outline-offset: 4px; }
}

.fin-map, .fin-history { position: relative; }
.fin-map .lake-map { width: min(520px, 90vw); display: block; border: 3px solid var(--gold); border-radius: 8px; box-shadow: 0 20px 50px rgb(0 0 0 / .6); }
.fin-history {
  margin: 0; max-width: min(52ch, calc(100% - 40px)); padding: 20px 24px;
  background: rgb(5 7 15 / .82); border-radius: 10px;
  color: #cfc4a8; font-style: italic; line-height: 1.5;
}

body.finale-open .goals, body.finale-open .goal-ribbon { display: none; }

@media (max-width: 760px) {
  .fin-reeves { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 18px; }
  .fin-end { letter-spacing: .18em; padding-left: .18em; }
}
@media (prefers-reduced-motion: reduce) {
  .finale, .fin-reeves li, .fin-end, .fin-lost .fin-wolf { animation: none; }
  .fin-won .fin-sails, .fin-lost .fin-wave { animation: none; }
}
