.market-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(450px, 36vw, 700px);
  bottom: clamp(16px, 2.5vh, 30px);
  opacity: 1;
  transform: translateY(14px);
  transition: transform .34s cubic-bezier(.2, .74, .24, 1);
  pointer-events: none;
}

/* Keep the faint Jiayu-home glow on Ming text; Shuhui's sans text stays flat. */
.market-story-dialogue:not(.speaker-shuhui) .market-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-market-story-dialogue .panorama-character-dialogue {
  width: min(48vw, 760px);
}

/* Match the closer framing of the normal portraits without enlarging files.
   Individual transforms preserve the shared mobile centering transform. */
body.has-market-story-dialogue .panorama-character-portrait[data-market-pose] {
  transform-origin: 50% 0;
  scale: var(--market-pose-scale);
}
body.has-market-story-dialogue .panorama-character-portrait[data-market-pose="shuhui-offer"] {
  --market-pose-scale: 1.22;
  translate: 0 1.39%;
}
body.has-market-story-dialogue .panorama-character-portrait[data-market-pose="meiling-embarrassed"] {
  --market-pose-scale: 1.14;
  translate: 0 -1.77%;
}
@media (max-width: 760px) and (orientation: portrait) {
  body.has-market-story-dialogue .panorama-character-portrait[data-market-pose] {
    scale: none;
    transform: translateX(50%) scale(var(--market-pose-scale));
  }
}

body.has-market-story-dialogue .panorama-character-close {
  pointer-events: none;
}

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

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

.market-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;
}

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

.market-story-dialogue__speaker,
.market-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);
}

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

.market-story-dialogue__text {
  position: relative;
  z-index: 0;
  width: 100%;
  max-width: 100%;
  font-size: clamp(23px, 2.35vw, 38px);
  line-height: 1.72;
  letter-spacing: .12em;
}

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

.market-story-dialogue .story-dialogue-line.speaker-meiling { color: #c9eaff; }
.market-story-dialogue .story-dialogue-line.speaker-mingfen { color: #bce9c3; }
.market-story-dialogue .story-dialogue-line.speaker-xiuqin {
  color: #ffaaa7;
  font-family: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", sans-serif;
  font-weight: 700;
}
.market-story-dialogue .story-dialogue-line.speaker-shuhui {
  color: #66d5d2;
  font-family: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", sans-serif;
  font-weight: 700;
}

.market-story-dialogue__text::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -.22em -.55em -.28em;
  border-radius: .78em;
  background: rgba(255, 255, 255, .62);
  box-shadow: 0 0 1.05em .42em rgba(255, 255, 255, .48);
  filter: blur(.34em);
  opacity: 0;
  pointer-events: none;
}

.market-story-dialogue.speaker-shuhui .market-story-dialogue__text::before,
.market-story-dialogue.speaker-xiuqin .market-story-dialogue__text::before {
  opacity: 1;
}

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

.market-story-dialogue.speaker-meiling .market-story-dialogue__text {
  color: #c9eaff;
}

.market-story-dialogue.speaker-xiuqin .market-story-dialogue__text {
  color: #ffaaa7;
  font-family: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", sans-serif;
  font-weight: 700;
}

.market-story-dialogue.speaker-shuhui .market-story-dialogue__text {
  color: #66d5d2;
  font-family: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", sans-serif;
  font-weight: 700;
}

.market-story-dialogue.speaker-mingfen .market-story-dialogue__text {
  color: #bce9c3;
}

.market-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) {
  .market-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;
  }

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

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

  body.has-market-story-dialogue .panorama-character-dialogue { width: min(66vw, 360px); }
}

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