.school-story-dialogue {
  position: fixed;
  z-index: 76;
  top: auto;
  left: calc(max(8px, env(safe-area-inset-left)) + clamp(126px, 14.5vw, 210px) + clamp(18px, 2vw, 34px));
  right: clamp(600px, 50vw, 1040px);
  bottom: clamp(16px, 2.5vh, 30px);
  opacity: 1;
  transform: translateY(14px);
  transition: transform .34s cubic-bezier(.2, .74, .24, 1);
  pointer-events: none;
}

/* Narrative Ming text keeps only a faint white outer glow, never a dark shadow. */
.school-story-dialogue__text {
  text-shadow:
    0 0 2px rgba(255, 255, 255, .55),
    0 0 .28em rgba(255, 255, 255, .32) !important;
}

/* Project-wide typography rule: text stays flat and shadow-free. */
*,
*::before,
*::after {
  text-shadow: none !important;
}

body.has-school-story-dialogue .panorama-character-dialogue {
  width: min(48vw, 760px);
  height: min(94vh, 60vw, 950px);
}
body.has-school-story-dialogue .panorama-character-portrait { height: 100%; }

/* 對話進行時，立繪只負責呈現人物；不可再作為關閉按鈕。 */
body.has-school-story-dialogue .panorama-character-close {
  pointer-events: none;
}

/* Both fresh head-to-hips poses share a 1122 x 1402 canvas and head scale.
 * Inherit the normal portrait layout on desktop and mobile without size overrides. */

.school-story-dialogue[hidden] { display: none; }

.school-story-dialogue.is-visible {
  transform: translateY(0);
  pointer-events: auto;
}

.school-story-dialogue__advance {
  display: block;
  width: 100%;
  min-height: min(76vh, 620px);
  padding: 0;
  border: 0;
  color: rgba(255, 255, 255, .98);
  background: transparent;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.school-story-dialogue__advance:hover,
.school-story-dialogue__advance:focus,
.school-story-dialogue__advance:focus-visible {
  border: 0;
  outline: none;
  background: transparent;
}

.school-story-dialogue__speaker,
.school-story-dialogue__text {
  display: block;
  font-family: "I.MingCP", "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  font-weight: 600;
  text-shadow:
    0 0 3px rgba(255, 255, 255, .84),
    0 0 10px rgba(244, 248, 255, .5),
    0 2px 8px rgba(0, 0, 0, .68);
}

.school-story-dialogue__speaker {
  display: none;
}

.school-story-dialogue__text {
  width: 100%;
  font-size: clamp(23px, 2.35vw, 38px);
  line-height: 1.72;
  letter-spacing: .12em;
}

.school-story-dialogue .story-dialogue-line {
  color: #fff;
  font-family: "I.MingCP", "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  font-weight: 600;
}

.school-story-dialogue .story-dialogue-line.speaker-wanqing { color: #f3a9c2; }

.school-story-dialogue.speaker-xinling .school-story-dialogue__text {
  color: #fff;
}

.school-story-dialogue.speaker-wanqing .school-story-dialogue__text {
  color: #f3a9c2;
}

.school-story-dialogue__advance small {
  display: block;
  margin-top: .9em;
  color: rgba(255, 255, 255, .7);
  font: 400 13px/1.2 "Microsoft JhengHei", sans-serif;
  letter-spacing: .08em;
  text-align: right;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .72);
}

@media (max-width: 760px) {
  .school-story-dialogue {
    top: max(18px, env(safe-area-inset-top));
    left: max(18px, env(safe-area-inset-left));
    right: max(18px, env(safe-area-inset-right));
    bottom: auto;
    max-height: 48vh;
  }

  .school-story-dialogue__advance {
    min-height: 0;
    padding: .35em 0 .4em;
  }

  .school-story-dialogue__text {
    font-size: clamp(18px, 4.9vw, 23px);
    line-height: 1.46;
    letter-spacing: .06em;
  }

  body.has-school-story-dialogue .panorama-character-dialogue {
    width: min(66vw, 360px);
    height: min(82.5vw, 450px);
    bottom: 0;
  }
  body.has-school-story-dialogue .panorama-character-portrait {
    width: 100%; height: auto;
  }

}

@media (prefers-reduced-motion: reduce) {
  .school-story-dialogue { transition: none; }
}
