/* エンディングの会話の窓と結末の一文（src/ui/story.js） */
.story-dialog {
  position: fixed;
  left: 50%;
  bottom: calc(36px + env(safe-area-inset-bottom, 0px) + var(--tb, 0px));
  transform: translateX(-50%);
  z-index: 70;
  width: min(720px, calc(100vw - 32px));
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.story-box {
  position: relative;
  padding: 16px 20px 18px;
  background: rgba(14, 17, 25, 0.94);
  border: 1px solid var(--brass-dim, #8b6a2c);
  border-bottom: 2px solid var(--stone-ledge, #080a0f);
  border-radius: var(--radius-outer, 3px);
  box-shadow: 0 6px 0 var(--stone-ledge, #080a0f), 0 18px 40px rgba(0, 0, 0, 0.5);
}

.story-name {
  display: inline-block;
  margin-bottom: 6px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #161108;
  background: var(--brass, #d6a646);
  border-radius: 2px;
}

.story-dialog.is-narration .story-name {
  display: none;
}

.story-text {
  margin: 0;
  min-height: 2.6em;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.6;
  letter-spacing: 0.04em;
  color: var(--ink-main, #f0e7d5);
}

.story-next {
  position: absolute;
  right: 14px;
  bottom: 8px;
  font-size: 11px;
  color: var(--brass, #d6a646);
  opacity: 0;
}

.story-dialog.is-ready .story-next {
  opacity: 1;
  animation: storyNext 0.9s ease-in-out infinite;
}

@keyframes storyNext {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(3px); }
}

.story-epilogue {
  position: fixed;
  inset: 0;
  z-index: 75;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(4, 5, 8, 0.82);
  opacity: 0;
  transition: opacity 0.6s ease;
  cursor: pointer;
}

.story-epilogue.visible {
  opacity: 1;
}

.story-epilogue p {
  margin: 0;
  max-width: 28em;
  font-size: clamp(20px, 3.4vw, 30px);
  font-weight: 800;
  line-height: 1.7;
  letter-spacing: 0.1em;
  text-align: center;
  color: var(--ink-main, #f0e7d5);
  text-shadow: 0 3px 0 #05070a;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

/* 結末ごとの色：怪物は朱、勇者は真鍮 */
#ending-overlay.is-monster #ending-heading {
  color: #e8665a;
}

#ending-overlay.is-hero #ending-heading {
  color: var(--brass-bright, #e7be6a);
}

@media (max-width: 760px) {
  .story-dialog {
    bottom: calc(24px + env(safe-area-inset-bottom, 0px) + var(--tb, 0px));
  }
  .story-text {
    font-size: 15px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .story-dialog.is-ready .story-next { animation: none; }
  .story-epilogue { transition: none; }
}
