/* Final epilogue only. The game chapters remain in game.css. */

.finale-background::after {
  transition: opacity 1.35s ease;
}

.finale-overlay.has-ending-quest .finale-background::after,
.finale-overlay.is-quest-accepted .finale-background::after {
  opacity: 0.34;
}

.finale-panel {
  transition: opacity 0.9s ease, filter 0.9s ease, transform 0.9s ease;
}

.finale-overlay.is-quest-accepted .finale-panel {
  opacity: 0;
  filter: blur(9px);
  pointer-events: none;
  transform: translateY(-18px) scale(0.985);
}

.ending-quest-notification {
  position: absolute;
  z-index: 12;
  top: clamp(22px, 5vh, 54px);
  right: clamp(22px, 5vw, 74px);
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  width: min(430px, calc(100vw - 44px));
  padding: 14px 16px;
  border: 1px solid rgba(255, 233, 160, 0.52);
  border-radius: 5px 19px 5px 13px;
  color: #fff;
  background: linear-gradient(135deg, rgba(4, 24, 27, 0.94), rgba(14, 52, 48, 0.88));
  box-shadow: 0 21px 64px rgba(0, 0, 0, 0.43), inset 0 1px rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(15px);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-28px) scale(0.95);
  transition: opacity 0.5s ease, transform 0.72s cubic-bezier(0.16, 1.18, 0.3, 1);
}

.ending-quest-notification.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

.ending-envelope-icon {
  position: relative;
  width: 44px;
  height: 31px;
  border: 2px solid #ffe39a;
  border-radius: 3px;
  box-shadow: 0 0 21px rgba(255, 215, 103, 0.3);
}

.ending-envelope-icon::before,
.ending-envelope-icon::after {
  content: "";
  position: absolute;
  top: 4px;
  width: 27px;
  height: 2px;
  background: #ffe39a;
}

.ending-envelope-icon::before { left: 0; transform: rotate(34deg); }
.ending-envelope-icon::after { right: 0; transform: rotate(-34deg); }

.ending-notification-copy small,
.ending-notification-copy strong { display: block; }

.ending-notification-copy small {
  color: #8dd9d0;
  font-family: Georgia, serif;
  font-size: 9px;
  letter-spacing: 0.16em;
}

.ending-notification-copy strong {
  margin-top: 4px;
  color: #f5e7bd;
  font-size: 15px;
}

.ending-quest-notification button {
  border: 1px solid rgba(255, 238, 176, 0.72);
  border-radius: 999px;
  padding: 8px 13px;
  color: #102426;
  background: linear-gradient(135deg, #ffeca5, #dea443);
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
}

.ending-envelope-overlay {
  position: absolute;
  z-index: 15;
  inset: 0;
  display: grid;
  place-items: center;
  padding: clamp(18px, 3vw, 38px);
  background: rgba(2, 13, 15, 0);
  backdrop-filter: blur(0);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease, background 0.65s ease, backdrop-filter 0.65s ease;
}

.ending-envelope-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
  background: rgba(2, 13, 15, 0.58);
  backdrop-filter: blur(7px);
}

.ending-mission-letter {
  position: relative;
  width: min(760px, 94vw);
  max-height: 90vh;
  padding: clamp(26px, 4vw, 54px);
  overflow: auto;
  color: #273537;
  border: 1px solid rgba(255, 245, 207, 0.9);
  background:
    linear-gradient(90deg, rgba(91, 59, 20, 0.07) 1px, transparent 1px) 0 0 / 42px 100%,
    radial-gradient(circle at 50% -10%, #fff9eb, transparent 48%),
    linear-gradient(145deg, #f3e9d1, #dbc8a6);
  box-shadow: 0 32px 110px rgba(0, 0, 0, 0.64), inset 0 0 44px rgba(101, 65, 19, 0.13);
  clip-path: polygon(1.2% 0, 99% 0.8%, 100% 98%, 97.7% 100%, 1% 99%, 0 2%);
  opacity: 0;
  transform: translateY(34px) scale(0.88) rotateX(8deg);
  transition: opacity 0.45s ease, transform 0.7s cubic-bezier(0.16, 1, 0.3, 1), filter 0.8s ease;
}

.ending-envelope-overlay.is-open .ending-mission-letter {
  opacity: 1;
  transform: none;
}

.ending-mission-letter.is-shaking { animation: ending-letter-shake 0.5s ease; }

.ending-mission-kicker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(40, 50, 52, 0.27);
  color: #496162;
  font-family: Georgia, serif;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.17em;
}

.ending-mission-kicker b {
  padding: 5px 9px;
  border: 1px solid #a16926;
  color: #8d5419;
  letter-spacing: 0.07em;
}

.ending-mission-letter h2 {
  margin: 23px 0 8px;
  color: #173235;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: clamp(34px, 4.8vw, 54px);
  line-height: 1.08;
  letter-spacing: 0.04em;
  text-shadow: none;
}

.ending-mission-summary {
  margin: 0 0 21px;
  color: #596665;
  font-size: 14px;
  line-height: 1.75;
}

.ending-mission-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ending-mission-list li {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 9px 12px;
  border: 1px solid rgba(44, 76, 73, 0.22);
  background: rgba(255, 255, 255, 0.31);
}

.ending-mission-list li:last-child { grid-column: 1 / -1; }

.ending-mission-list i {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: #f9edc5;
  background: #244c4c;
  font-family: Georgia, serif;
  font-size: 9px;
  font-style: normal;
  font-weight: 900;
}

.ending-mission-list strong { font-size: 14px; }
.ending-mission-list b { color: #955c1e; font-family: Georgia, serif; font-size: 12px; }

.ending-mission-reward {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 17px;
  padding: 12px 15px;
  color: #f7e8bc;
  background: linear-gradient(90deg, #183b3d, #275653);
}

.ending-mission-reward span { font-size: 10px; letter-spacing: 0.15em; }
.ending-mission-reward strong { color: #ffe39a; font-size: 13px; }

.ending-mission-actions {
  display: flex;
  justify-content: flex-end;
  gap: 11px;
  margin-top: 20px;
}

.ending-mission-actions button {
  min-width: 126px;
  padding: 11px 17px;
  border: 1px solid #315354;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.ending-reject-task { color: #314546; background: transparent; }

.ending-accept-task {
  color: #102324;
  background: linear-gradient(135deg, #ffedac, #daa13b);
  box-shadow: 0 7px 18px rgba(121, 75, 18, 0.22);
}

.ending-reject-message {
  position: absolute;
  z-index: 17;
  left: 50%;
  bottom: 21px;
  width: min(430px, calc(100vw - 40px));
  padding: 13px 17px;
  border: 1px solid rgba(255, 130, 92, 0.68);
  color: #ffe2d7;
  background: rgba(46, 13, 12, 0.95);
  box-shadow: 0 16px 55px rgba(0, 0, 0, 0.48);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 18px);
  transition: opacity 0.25s ease, transform 0.35s ease;
}

.ending-reject-message.is-visible { opacity: 1; transform: translate(-50%, 0); }
.ending-reject-message strong { display: block; font-size: 16px; }
.ending-reject-message small { display: block; margin-top: 4px; color: #eeb5a4; }

.finale-overlay.is-quest-accepted .ending-envelope-overlay {
  opacity: 0;
  pointer-events: none;
  background: transparent;
  backdrop-filter: blur(0);
}

.finale-overlay.is-quest-accepted .ending-mission-letter {
  filter: blur(8px) brightness(2.7);
  transform: scale(0.12) rotate(8deg);
}

.ending-continuation {
  position: absolute;
  z-index: 13;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 30px;
  background: radial-gradient(circle at 50% 51%, rgba(4, 23, 25, 0.18), transparent 44%);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.87);
  transition: opacity 1s ease 0.95s, transform 1.2s cubic-bezier(0.16, 1, 0.3, 1) 0.95s;
}

.finale-overlay.is-quest-accepted .ending-continuation {
  opacity: 1;
  transform: none;
}

.ending-continuation-copy { position: relative; }

.ending-continuation-title {
  position: relative;
  margin: 0;
  padding: 0.02em 0.18em 0.1em;
  font-family: "STHupo", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  font-weight: 900;
  line-height: 0.98;
  filter: drop-shadow(0 17px 16px rgba(0, 0, 0, 0.56));
  transform: skewX(-4deg);
}

.ending-continuation-title span,
.ending-continuation-title strong {
  display: block;
  color: transparent;
  background: linear-gradient(180deg, #fffbe1 0%, #ffe58f 27%, #f1b84b 55%, #a76319 82%, #f9dc77 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-stroke: clamp(2px, 0.2vw, 4px) #102e32;
  text-shadow: 0 8px 0 #08262b, 0 0 28px rgba(255, 236, 151, 0.58);
}

.ending-continuation-title span {
  font-size: clamp(34px, 5.4vw, 86px);
  letter-spacing: 0.16em;
}

.ending-continuation-title i {
  display: block;
  margin: 0.16em 0 0.05em;
  color: #eafff8;
  font-family: Georgia, serif;
  font-size: clamp(18px, 2.2vw, 32px);
  font-style: normal;
  font-weight: 900;
  letter-spacing: 0.65em;
  text-indent: 0.65em;
  text-shadow: 0 0 18px rgba(189, 255, 239, 0.85), 0 3px 8px rgba(0, 0, 0, 0.7);
}

.ending-continuation-title strong {
  font-size: clamp(74px, 12.5vw, 196px);
  letter-spacing: 0.12em;
}

.ending-continuation-title::after {
  content: "";
  position: absolute;
  left: 7%;
  top: 22%;
  width: 90%;
  height: 11%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.96), transparent);
  mix-blend-mode: screen;
  transform: rotate(-7deg) translateX(-140%);
  animation: ending-title-shine 3.8s ease 1.8s infinite;
}

.ending-continuation-subtitle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 17px;
  margin-top: 16px;
  color: #edffff;
  font-family: Georgia, serif;
  font-size: clamp(10px, 1.2vw, 16px);
  font-weight: 800;
  letter-spacing: 0.46em;
  text-shadow: 0 3px 14px rgba(0, 0, 0, 0.85);
}

.ending-continuation-subtitle::before,
.ending-continuation-subtitle::after {
  content: "";
  width: clamp(30px, 8vw, 120px);
  height: 1px;
  background: linear-gradient(90deg, transparent, #bff7ec);
}

.ending-continuation-subtitle::after { transform: scaleX(-1); }

.ending-continuation-copy > p {
  margin: 20px 0 0;
  color: rgba(236, 255, 250, 0.82);
  font-family: Georgia, serif;
  font-size: 10px;
  letter-spacing: 0.22em;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.78);
}

@keyframes ending-letter-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px) rotate(-0.4deg); }
  40% { transform: translateX(9px) rotate(0.4deg); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
}

@keyframes ending-title-shine {
  0%, 48% { opacity: 0; transform: rotate(-7deg) translateX(-140%); }
  58% { opacity: 1; }
  80%, 100% { opacity: 0; transform: rotate(-7deg) translateX(145%); }
}

@media (max-width: 700px) {
  .ending-quest-notification {
    grid-template-columns: 38px minmax(0, 1fr);
    top: auto;
    right: 18px;
    bottom: max(18px, env(safe-area-inset-bottom));
    width: calc(100vw - 36px);
  }

  .ending-quest-notification button { grid-column: 1 / -1; width: 100%; }
  .ending-mission-letter { padding: 25px 20px; }
  .ending-mission-list { grid-template-columns: 1fr; }
  .ending-mission-list li:last-child { grid-column: auto; }
  .ending-mission-reward { align-items: flex-start; flex-direction: column; gap: 5px; }
  .ending-mission-actions button { flex: 1; min-width: 0; }
  .ending-continuation-title span { font-size: clamp(30px, 9.5vw, 54px); letter-spacing: 0.08em; }
  .ending-continuation-title strong { font-size: clamp(66px, 20vw, 118px); letter-spacing: 0.05em; }
  .ending-continuation-subtitle { gap: 8px; letter-spacing: 0.25em; }
}

@media (prefers-reduced-motion: reduce) {
  .ending-continuation-title::after { animation: none; }
}
