/* 三类剧情统一使用“全身立绘 + 前景对白遮挡腿部”的视觉小说舞台。 */
.story-portrait {
  display: none;
}

.chapter-briefing[data-story-active="true"] .chapter-card {
  right: 12px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  left: 12px;
  max-height: none;
  padding: 0;
  overflow: visible;
  border: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.chapter-briefing[data-story-active="true"] .chapter-card > small,
.chapter-briefing[data-story-active="true"] .chapter-card > h2,
.chapter-briefing[data-story-active="true"] .chapter-card > h3,
.chapter-briefing[data-story-active="true"] .chapter-card > p,
.chapter-briefing[data-story-active="true"] .chapter-objective,
.chapter-briefing[data-story-active="true"] .chapter-intel-grid,
.chapter-briefing[data-story-active="true"] .chapter-decision,
.chapter-briefing[data-story-active="true"] #commence-battle {
  display: none;
}

.chapter-briefing[data-story-active="true"] > #chapter-hero-image {
  top: 2%;
  left: -6%;
  width: 112%;
  height: 94%;
  object-fit: contain;
  object-position: 50% 0;
  clip-path: none;
  filter: drop-shadow(0 22px 28px rgba(0, 19, 36, 0.58));
  scale: 1.08;
  transform-origin: 50% 0;
}

.chapter-briefing[data-side="enemy"] > #chapter-hero-image {
  left: 2%;
  width: 96%;
  object-position: 65% 0;
  clip-path: none;
  filter: drop-shadow(0 20px 28px rgba(62, 4, 42, 0.66)) drop-shadow(0 0 16px rgba(255, 90, 147, 0.35));
  scale: 1.38;
}

.chapter-story {
  position: relative;
  margin: 0 0 10px;
  padding: 12px;
  overflow: hidden;
  border: 1px solid rgba(152, 242, 232, 0.28);
  border-radius: 14px 5px 14px 5px;
  background: rgba(2, 24, 40, 0.4);
}

.chapter-briefing:not([data-story-active="true"]) .chapter-story {
  display: none;
}

.chapter-briefing[data-story-active="true"] .chapter-story {
  min-height: 238px;
  margin: 0;
  padding: 20px 18px 80px;
  overflow: visible;
  border: 3px solid rgba(255, 255, 255, 0.94);
  border-radius: 24px 7px 24px 7px;
  color: white;
  background: linear-gradient(135deg, rgba(3, 29, 52, 0.99), rgba(7, 73, 92, 0.985));
  box-shadow: 0 24px 58px rgba(0, 10, 28, 0.72), 0 0 0 5px rgba(116, 236, 223, 0.12);
  backdrop-filter: blur(14px);
  animation: dialogue-panel-in 0.34s cubic-bezier(0.18, 0.86, 0.28, 1.08);
  cursor: pointer;
  touch-action: manipulation;
}

.chapter-briefing[data-story-active="true"] .chapter-story::before,
.battle-dialogue > span::before,
.result-story > span::before,
.prologue-dialogue::before {
  position: absolute;
  top: -3px;
  right: 26px;
  left: 26px;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, #ffe178 22%, #9df8ee 78%, transparent);
  box-shadow: 0 0 18px rgba(255, 225, 120, 0.8);
  content: "";
  pointer-events: none;
}

.chapter-story[data-side="enemy"] {
  border-color: rgba(255, 180, 205, 0.9);
  background: linear-gradient(135deg, rgba(83, 15, 52, 0.97), rgba(35, 18, 75, 0.96));
  box-shadow: 0 20px 48px rgba(45, 3, 32, 0.58), inset 0 0 34px rgba(255, 83, 144, 0.1);
}

.chapter-briefing[data-story-active="true"] .story-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  color: #a8eee8;
  font-size: 8px;
  font-weight: 1000;
  letter-spacing: 0.14em;
}

.chapter-briefing[data-story-active="true"] .story-head small,
.chapter-briefing[data-story-active="true"] #story-progress {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid rgba(168, 238, 232, 0.45);
  border-radius: 999px;
  background: rgba(1, 22, 40, 0.58);
}

.chapter-briefing[data-story-active="true"] .chapter-story[data-side="enemy"] .story-head {
  color: #ffc1d8;
}

.chapter-briefing[data-story-active="true"] .chapter-story > b {
  display: inline-block;
  padding: 4px 10px;
  border-left: 4px solid #ffe178;
  border-radius: 0 8px 8px 0;
  color: #ffe18a;
  background: rgba(0, 18, 34, 0.5);
  font-size: 18px;
  font-weight: 1000;
}

.chapter-briefing[data-story-active="true"] .chapter-story > p {
  min-height: 76px;
  margin: 10px 0 0;
  color: #f4fffc;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.68;
  text-shadow: 0 2px 7px rgba(0, 10, 22, 0.72);
}

.chapter-briefing[data-story-active="true"] .story-next {
  position: absolute;
  right: 14px;
  bottom: 13px;
  left: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: auto;
  min-height: 56px;
  padding: 0 15px;
  border: 2px solid rgba(255, 255, 255, 0.86);
  border-radius: 15px 5px 15px 5px;
  color: #17394c;
  background: linear-gradient(135deg, #ffe178, #f1ae63);
  box-shadow: 0 5px 0 rgba(117, 70, 42, 0.82), 0 0 22px rgba(255, 213, 105, 0.3);
  font-size: 16px;
  font-weight: 1000;
  cursor: pointer;
}

.chapter-briefing[data-story-active="true"] .story-next b {
  font-size: 22px;
}

.battle-dialogue {
  position: absolute;
  z-index: 80;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  color: white;
  background:
    linear-gradient(180deg, rgba(5, 34, 56, 0.16) 0 38%, rgba(4, 25, 45, 0.94) 70%, rgba(2, 18, 34, 0.995) 100%),
    linear-gradient(rgba(3, 23, 38, 0.12), rgba(3, 23, 38, 0.26)),
    var(--battle-scene, url("./assets/scene-coral.webp")) center / cover no-repeat;
  backdrop-filter: blur(2px) saturate(0.82);
  animation: dialogue-stage-in 0.3s ease-out;
  cursor: pointer;
  touch-action: manipulation;
}

.battle-dialogue[data-side="enemy"] {
  background:
    linear-gradient(180deg, rgba(61, 8, 42, 0.14) 0 42%, rgba(47, 8, 41, 0.91) 78%, rgba(25, 4, 36, 0.99) 100%),
    linear-gradient(rgba(35, 5, 30, 0.1), rgba(35, 5, 30, 0.28)),
    var(--battle-scene, url("./assets/scene-coral.webp")) center / cover no-repeat;
}

.battle-dialogue::before,
.result-story::before {
  position: absolute;
  z-index: 0;
  inset: 0;
  background: radial-gradient(circle at 50% 36%, rgba(142, 241, 229, 0.23), transparent 42%);
  content: "";
  pointer-events: none;
}

.battle-dialogue[data-side="enemy"]::before,
.result-story[data-side="enemy"]::before {
  background: radial-gradient(circle at 68% 35%, rgba(255, 88, 151, 0.27), transparent 40%);
}

.battle-dialogue > img,
.result-story > img {
  position: absolute;
  z-index: 1;
  top: 2%;
  left: -6%;
  width: 112%;
  height: 94%;
  object-fit: contain;
  object-position: 48% 0;
  clip-path: none;
  filter: drop-shadow(0 20px 24px rgba(0, 13, 28, 0.66));
  scale: 1.08;
  transform-origin: 50% 0;
  pointer-events: none;
}

.battle-dialogue[data-side="enemy"] > img,
.result-story[data-side="enemy"] > img {
  left: 2%;
  width: 96%;
  object-position: 67% 0;
  clip-path: none;
  filter: drop-shadow(0 20px 24px rgba(45, 3, 34, 0.7)) drop-shadow(0 0 14px rgba(255, 82, 145, 0.45));
  scale: 1.38;
}

.battle-dialogue > span,
.result-story > span {
  position: absolute;
  z-index: 3;
  right: 14px;
  bottom: calc(92px + env(safe-area-inset-bottom));
  left: 14px;
  min-height: 168px;
  padding: 20px 18px;
  border: 3px solid rgba(255, 255, 255, 0.94);
  border-radius: 24px 7px 24px 7px;
  background: linear-gradient(135deg, rgba(3, 29, 52, 0.99), rgba(7, 73, 92, 0.985));
  box-shadow: 0 24px 58px rgba(0, 10, 28, 0.74), 0 0 0 5px rgba(116, 236, 223, 0.12);
  text-align: left;
  backdrop-filter: blur(13px);
}

.battle-dialogue[data-side="enemy"] > span,
.result-story[data-side="enemy"] > span {
  border-color: rgba(255, 183, 207, 0.9);
  background: linear-gradient(135deg, rgba(84, 15, 52, 0.98), rgba(37, 17, 75, 0.97));
}

.battle-dialogue > span b,
.result-story > span b {
  display: inline-block;
  padding: 4px 10px;
  border-left: 4px solid #ffe178;
  border-radius: 0 8px 8px 0;
  color: #ffe18a;
  background: rgba(0, 18, 34, 0.52);
  font-size: 19px;
  font-weight: 1000;
}

.battle-dialogue > span p,
.result-story > span p,
.battle-result .result-story p {
  min-height: 78px;
  margin: 10px 0 0;
  color: #f3fffc;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.68;
  text-shadow: 0 2px 7px rgba(0, 10, 22, 0.72);
}

.battle-dialogue > button,
.result-story > button {
  position: absolute;
  z-index: 4;
  right: 14px;
  bottom: calc(17px + env(safe-area-inset-bottom));
  left: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  padding: 0 16px;
  border: 2px solid rgba(255, 255, 255, 0.88);
  border-radius: 15px 5px 15px 5px;
  color: #17394c;
  background: linear-gradient(135deg, #ffe178, #f1ae63);
  box-shadow: 0 5px 0 rgba(115, 68, 42, 0.86), 0 0 22px rgba(255, 213, 105, 0.3);
  font-size: 16px;
  font-weight: 1000;
  cursor: pointer;
}

.battle-dialogue > button b,
.result-story > button b {
  font-size: 22px;
}

.battle-result {
  max-height: calc(100svh - 136px);
  /* 结算徽章会越过卡片上沿；滚动容器会把它裁成半圆。 */
  overflow: visible;
}

.battle-result[data-story-active="true"] {
  display: none !important;
}

.battle-result[data-story-active="true"] > .result-emblem,
.battle-result[data-story-active="true"] > h2,
.battle-result[data-story-active="true"] > #result-body,
.battle-result[data-story-active="true"] > .unlocked-hero-card,
.battle-result[data-story-active="true"] > .secondary-cta {
  display: none !important;
}

.result-story {
  position: absolute;
  z-index: 81;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border: 0;
  color: white;
  background:
    linear-gradient(180deg, rgba(12, 72, 83, 0.12) 0 38%, rgba(4, 31, 49, 0.95) 72%, rgba(2, 20, 35, 0.995) 100%),
    linear-gradient(rgba(3, 23, 38, 0.08), rgba(3, 23, 38, 0.24)),
    var(--battle-scene, url("./assets/scene-coral.webp")) center / cover no-repeat;
  text-align: left;
  animation: dialogue-stage-in 0.32s ease-out;
  cursor: pointer;
  touch-action: manipulation;
}

.result-story[data-side="enemy"] {
  background:
    linear-gradient(180deg, rgba(97, 13, 55, 0.12) 0 42%, rgba(50, 8, 43, 0.93) 80%, rgba(26, 4, 36, 0.99) 100%),
    linear-gradient(rgba(35, 5, 30, 0.08), rgba(35, 5, 30, 0.26)),
    var(--battle-scene, url("./assets/scene-coral.webp")) center / cover no-repeat;
}

.result-story-head {
  position: absolute;
  z-index: 4;
  top: calc(18px + env(safe-area-inset-top));
  right: 14px;
  left: 14px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 2px solid rgba(255, 255, 255, 0.76);
  border-radius: 13px 4px 13px 4px;
  background: rgba(4, 31, 50, 0.9);
  box-shadow: 0 11px 28px rgba(0, 17, 32, 0.48);
  backdrop-filter: blur(10px);
}

.result-story[data-side="enemy"] .result-story-head {
  background: rgba(74, 12, 53, 0.76);
}

.result-story-head small {
  padding: 4px 7px;
  border-radius: 8px 3px 8px 3px;
  color: #17354a;
  background: #ffe18a;
  font-size: 12px;
  font-weight: 1000;
  letter-spacing: 0.08em;
}

.result-story[data-side="enemy"] .result-story-head small {
  color: white;
  background: #b7376d;
}

.result-story-head strong {
  overflow: hidden;
  color: #fff9dc;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-story-head em {
  color: rgba(255, 255, 255, 0.82);
  font-size: 13px;
  font-style: normal;
  font-weight: 1000;
}

#chapter-hero-image.is-entering,
.battle-dialogue > img.is-entering,
.result-story > img.is-entering {
  animation: story-portrait-in 0.38s cubic-bezier(0.16, 0.82, 0.24, 1.08) both,
    story-portrait-breathe 4.2s 0.4s ease-in-out infinite;
}

[data-side="enemy"] > #chapter-hero-image.is-entering,
.battle-dialogue[data-side="enemy"] > img.is-entering,
.result-story[data-side="enemy"] > img.is-entering {
  animation-name: story-enemy-in, story-portrait-breathe;
}

@keyframes dialogue-stage-in {
  from { opacity: 0; }
}

@keyframes dialogue-panel-in {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
}

@keyframes dialogue-continue-pulse {
  50% { filter: brightness(1.08); transform: translateY(-2px); }
}

.chapter-briefing[data-story-active="true"] .story-next,
.battle-dialogue > button,
.result-story > button,
.prologue-next {
  animation: dialogue-continue-pulse 1.8s ease-in-out infinite;
}

@keyframes story-portrait-in {
  from { opacity: 0; transform: translate3d(-10%, 2%, 0) scale(0.96); }
  to { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}

@keyframes story-enemy-in {
  from { opacity: 0; transform: translate3d(10%, 2%, 0) scale(0.96); }
  to { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}

@keyframes story-portrait-breathe {
  50% { transform: translate3d(0, -6px, 0) scale(1.012); }
}

@media (max-height: 700px) {
  .chapter-briefing[data-story-active="true"] > #chapter-hero-image,
  .battle-dialogue > img,
  .result-story > img {
    top: 2%;
    height: 96%;
  }

  .chapter-briefing[data-story-active="true"] .chapter-story {
    min-height: 210px;
    padding: 14px 14px 72px;
  }

  .battle-dialogue > span,
  .result-story > span {
    min-height: 152px;
    padding: 14px 15px;
  }

  .battle-dialogue > span p,
  .result-story > span p,
  .battle-result .result-story p {
    min-height: 66px;
    font-size: 15px;
  }
}

@media (max-width: 380px) {
  .chapter-briefing[data-story-active="true"] .chapter-card,
  .battle-dialogue > span,
  .result-story > span,
  .battle-dialogue > button,
  .result-story > button {
    right: 10px;
    left: 10px;
  }

  .chapter-briefing[data-story-active="true"] .chapter-card {
    bottom: calc(10px + env(safe-area-inset-bottom));
  }

  .chapter-story > p,
  .battle-dialogue > span p,
  .result-story > span p,
  .battle-result .result-story p {
    font-size: 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chapter-briefing[data-story-active="true"] .chapter-story,
  .battle-dialogue,
  .battle-result[data-story-active="true"],
  #chapter-hero-image.is-entering,
  .battle-dialogue > img.is-entering,
  .result-story > img.is-entering,
  .chapter-briefing[data-story-active="true"] .story-next,
  .battle-dialogue > button,
  .result-story > button,
  .prologue-next {
    animation: none !important;
  }
}
