/* Narrative rules added after v3: reveal accumulates; full node remains readable. */
.dialogue {
  max-height: min(61dvh, 530px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(211, 167, 96, .45) transparent;
  padding-bottom: calc(38px + env(safe-area-inset-bottom));
}

.narrative p {
  margin: 0 0 11px;
}

.narrative p:last-child {
  margin-bottom: 0;
}

.scene-art,
.ending-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}

.scene:has(.scene-art) .scene-arches,
.scene:has(.scene-art) .scene-light {
  display: none;
}

.ending-scene .ending-art { object-position: center 35%; }

.story-action {
  position: sticky;
  bottom: 0;
  z-index: 2;
  padding-top: 6px;
  background: linear-gradient(to bottom, transparent, rgba(9, 11, 18, .98) 22%);
}

.story-action .choices {
  padding-bottom: 4px;
}

.narrative .stat-line {
  margin: 19px 0;
  padding: 10px 13px 11px;
  border-left: 2px solid var(--gold);
  background: linear-gradient(90deg, rgba(188, 137, 68, .17), transparent);
  color: #f0d49e;
  font-family: Georgia, "Songti SC", "Noto Serif CJK SC", serif;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: .05em;
  line-height: 1.2;
  text-shadow: 0 0 20px rgba(211, 167, 96, .18);
}

.narrative .impact-number {
  margin: 20px 0;
  padding: 11px 14px 12px;
  border-left: 2px solid var(--gold);
  background: linear-gradient(90deg, rgba(188, 137, 68, .19), transparent 82%);
  color: #f0d49e;
  font-family: Georgia, "Songti SC", "Noto Serif CJK SC", serif;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: .06em;
  line-height: 1.25;
  text-shadow: 0 0 20px rgba(211, 167, 96, .18);
}

.narrative .impact-quote {
  margin: 24px 0;
  color: #f3dca9;
  font-size: 21px;
  line-height: 1.55;
  letter-spacing: .08em;
  text-align: center;
  text-shadow: 0 0 22px rgba(211, 167, 96, .14);
}

.narrative .quote:not(.impact-quote) {
  margin: 17px 0;
  padding-left: 14px;
  border-left: 1px solid rgba(211, 167, 96, .52);
  color: rgba(245, 234, 215, .93);
}

.narrative .impact-line {
  margin: 20px 0;
  color: #f0d49e;
  font-size: 18px;
  line-height: 1.65;
  letter-spacing: .075em;
}

.narrative .impact-line strong,
.narrative .impact-quote strong { font-weight: 500; }

.narrative .time-card,
.narrative .location-card {
  display: inline-block;
  margin: 14px 0 17px;
  padding: 6px 10px;
  border: 1px solid rgba(211, 167, 96, .34);
  color: rgba(232, 207, 155, .9);
  font-size: 11px;
  letter-spacing: .14em;
  line-height: 1.4;
}

.narrative .location-card { background: rgba(211, 167, 96, .08); }

.narrative .impact-sequence {
  margin: 20px 0;
  padding: 11px 0 11px 14px;
  border-left: 2px solid rgba(211, 167, 96, .7);
  color: #ead6ae;
  font-size: 17px;
  line-height: 1.7;
}

.ending-intro-screen {
  display: flex;
  min-height: 100dvh;
  flex-direction: column;
  justify-content: center;
  padding: calc(32px + env(safe-area-inset-top)) 28px calc(24px + env(safe-area-inset-bottom));
  background: radial-gradient(90% 58% at 78% 19%, rgba(129, 61, 82, .32), transparent 60%), #0b0d16;
}

.ending-intro-copy { max-width: 305px; }
.ending-intro-copy h1 { margin: 13px 0 20px; color: var(--cream); font: 32px/1.28 Georgia, "Songti SC", serif; font-weight: 400; }
.ending-intro-copy p:last-of-type { margin: 0; color: rgba(232, 222, 208, .83); font: 16px/1.9 "STSong", "Songti SC", serif; letter-spacing: .055em; }
.ending-intro-copy span { display: block; width: 34px; height: 2px; margin-top: 26px; background: var(--gold); }
.ending-continue { margin-top: auto; }

.ending-core-screen {
  overflow-y: auto;
  justify-content: flex-start;
  padding: 0 0 calc(14px + env(safe-area-inset-bottom));
}

.ending-core-copy {
  max-width: 320px;
  padding-top: 26px;
}

.ending-core-copy h1 { margin-bottom: 18px; }

.ending-narrative {
  display: grid;
  gap: 11px;
  padding-top: 18px;
  border-top: 1px solid rgba(211, 167, 96, .35);
}

.ending-narrative p {
  margin: 0;
  color: rgba(241, 233, 221, .9);
  font: 15px/1.88 "STSong", "Songti SC", serif;
  letter-spacing: .045em;
}

.ending-narrative p:last-child { color: #f0d6a0; font-size: 16px; }

.ending-inline-scene {
  height: 30dvh;
  min-height: 214px;
  margin-top: 28px;
  position: relative;
  overflow: hidden;
  background: radial-gradient(circle at 70% 22%, rgba(220, 164, 94, .36), transparent 26%), linear-gradient(152deg, #2f1d2c, #0a1420);
}

.ending-core-screen .ending-inline-scene {
  width: 100%;
  height: 36dvh;
  min-height: 272px;
  margin-top: 0;
}

.ending-core-screen .ending-core-copy {
  width: 100%;
  max-width: none;
  padding: 26px 28px 0;
}

.ending-core-screen .ending-summary-copy {
  padding: 24px 28px calc(28px + env(safe-area-inset-bottom));
}

.ending-inline-scene:after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 58%;
  background: linear-gradient(transparent, #0b0d16);
}

.ending-inline-scene .ending-art { object-position: center 35%; }
.ending-inline-scene > p { position: absolute; z-index: 2; left: 20px; bottom: 20px; margin: 0; color: #cbc1b7; font-size: 10px; letter-spacing: .16em; }
.ending-inline-scene .cg-slot { z-index: 1; }
.ending-summary-copy { padding-top: 24px; }
.ending-summary-copy h2 { margin: 9px 0 16px; font: 26px Georgia, "Songti SC", serif; font-weight: 400; }

.ending-generation-screen {
  display: flex;
  min-height: 100dvh;
  padding: calc(26px + env(safe-area-inset-top)) 24px calc(28px + env(safe-area-inset-bottom));
  background: radial-gradient(80% 55% at 80% 20%, rgba(117, 61, 94, .28), transparent 65%), #0a0c14;
}

.ending-generation-copy { width: 100%; margin: auto 0; }
.ending-generation-copy h1 { margin: 15px 0 34px; font: 36px/1.24 Georgia, "Songti SC", serif; font-weight: 400; }
.ending-status { display: grid; gap: 11px; border-left: 1px solid rgba(211, 167, 96, .48); padding-left: 13px; color: rgba(229, 219, 207, .73); font-size: 12px; letter-spacing: .08em; }
.ending-status p { margin: 0; }
.ending-progress { height: 2px; margin-top: 30px; overflow: hidden; background: rgba(255, 255, 255, .14); }
.ending-progress i { display: block; width: 40%; height: 100%; background: linear-gradient(90deg, transparent, var(--gold), #f4dfa8); animation: ending-load 2s cubic-bezier(.2, .7, .2, 1) forwards; }

@keyframes ending-load { from { transform: translateX(-110%); } to { transform: translateX(280%); } }

.ending-details { display: grid; gap: 13px; margin: 20px 0 24px; }
.ending-details p { margin: 0; padding-left: 12px; border-left: 1px solid rgba(211, 167, 96, .52); color: #d5cec5; font-size: 13px; line-height: 1.8; }

.ending-summary-copy h1 { margin-bottom: 16px; }

.narrative {
  min-height: 84px;
  font-family: "STSong", "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", serif;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.9;
  letter-spacing: .055em;
  text-rendering: optimizeLegibility;
}

.story-back {
  min-width: 72px;
  white-space: nowrap;
}

.text-page-back {
  position: absolute;
  top: 15px;
  right: 20px;
  z-index: 1;
  min-height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  color: rgba(230, 215, 193, .68);
  font-size: 10px;
  letter-spacing: .08em;
}

.text-page-back:hover,
.text-page-back:focus-visible {
  color: var(--gold);
}

.text-page-back + .dialogue-line {
  margin-top: 25px;
}

.choice-title {
  margin: 19px 0 8px;
  font-family: Georgia, "Songti SC", serif;
  font-size: 25px;
  font-weight: 400;
  line-height: 1.2;
  color: var(--cream);
  letter-spacing: .04em;
}

.page-reveal {
  animation: page-arrive 1.35s cubic-bezier(.16, .84, .24, 1) both;
}

.page-reveal p {
  opacity: 1;
  transform: none;
  animation: none;
}

.page-reveal.settled p {
  opacity: 1;
  transform: none;
  animation: none;
}

.continue-subtle {
  display: flex;
  width: 100%;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-top: 20px;
  padding: 8px 0 0;
  border: 0;
  background: transparent;
  color: rgba(228, 210, 173, .76);
  font-size: 11px;
  letter-spacing: .15em;
  animation: soft-prompt 1.9s ease-in-out infinite;
}

.continue-subtle:hover,
.continue-subtle:focus-visible {
  color: var(--gold);
  animation-play-state: paused;
}

.reading-cue {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 48px;
  padding: 17px 13px 5px;
}

.reading-cue i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--gold);
  opacity: .35;
  animation: reading-dot 1s ease-in-out infinite;
}

.reading-cue i:nth-child(2) { animation-delay: .15s; }
.reading-cue i:nth-child(3) { animation-delay: .3s; }

.choice {
  opacity: 0;
  animation: choice-arrive .34s cubic-bezier(.2, .8, .2, 1) forwards;
  animation-delay: var(--choice-delay);
}

@keyframes page-arrive {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes sentence-arrive {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes choice-arrive {
  from { opacity: 0; transform: translateY(12px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes reading-dot {
  0%, 100% { opacity: .24; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-3px); }
}

@keyframes soft-prompt {
  0%, 100% { opacity: .56; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(3px); }
}

@media (max-height: 720px) {
  .dialogue { max-height: 57dvh; }
}

@media (prefers-reduced-motion: reduce) {
  .page-reveal,
  .page-reveal p,
  .choice,
  .reading-cue i,
  .continue-subtle { animation: none; opacity: 1; transform: none; }
}

/* Full-viewport presentation and supplied core art. */
html,
body,
#app {
  width: 100%;
  height: 100%;
  min-height: 100%;
}

body { min-height: 100dvh; }

.phone {
  width: 100%;
  height: 100dvh;
  min-height: 100dvh;
  margin: 0;
}

.home-screen { background: #080b12; }

.home-cover,
.home-cover-veil {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.home-cover {
  z-index: 0;
  object-fit: cover;
  object-position: center;
}

.home-cover-veil {
  z-index: 1;
  background: linear-gradient(180deg, rgba(5, 7, 13, .36), rgba(6, 7, 12, .12) 34%, rgba(5, 6, 11, .78) 78%, #080b12);
}

.home-screen .film-grain { z-index: 2; }

.home-screen > .home-top,
.home-screen > .title-block,
.home-screen > .home-foot {
  position: relative;
  z-index: 3;
}

.roles-screen { overflow-y: auto; }

.role-card {
  height: clamp(174px, 29dvh, 250px);
  background: #1b1925;
}

.female-card { background: #321724; }
.male-card { background: #10202a; }

.role-poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  object-fit: cover;
  object-position: center;
  opacity: .86;
}

.role-card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(8, 10, 16, .9), rgba(8, 10, 16, .23) 70%), linear-gradient(0deg, rgba(6, 8, 13, .78), transparent 55%);
}

.role-index {
  position: relative;
  z-index: 2;
}

.role-arrow { z-index: 2; }

.story-back {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: rgba(230, 215, 193, .78);
  font-size: 11px;
  letter-spacing: .08em;
  white-space: nowrap;
}

.story-back:hover,
.story-back:focus-visible { color: var(--gold); }

.dialogue { max-height: 68dvh; }

@media (min-width: 550px) {
  .phone { box-shadow: none; }
}

/* Core cover composition: keep the supplied artwork visible before the title. */
.home-cover { object-position: center top; }

.title-block {
  margin-top: 34dvh;
  margin-bottom: auto;
}

.roles-screen {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.role-posters {
  width: 100%;
  flex: 1;
  min-height: 0;
  margin: 0;
  gap: 12px;
  align-content: center;
  justify-items: center;
}

.role-posters .role-card {
  width: min(100%, calc((100dvh - 100px) * 2 / 3));
  height: auto;
  min-height: 0;
  padding: 0;
  border: 0;
  aspect-ratio: 4 / 3;
  flex: 0 0 auto;
  background: #080b12;
}

.role-posters .role-card::after,
.role-posters .role-index,
.role-posters .role-text,
.role-posters .role-arrow {
  display: none;
}

.role-posters .role-poster {
  object-fit: contain;
  object-position: center;
  opacity: 1;
}

.roles-screen {
  overflow: hidden;
}

.ending-reason {
  margin: 0 0 20px;
  padding: 13px 14px;
  border: 1px solid rgba(211, 167, 96, .28);
  background: rgba(135, 97, 48, .10);
}

.ending-reason p {
  margin: 0 0 7px;
  color: var(--gold);
  font-size: 11px;
  letter-spacing: .12em;
}

.ending-reason span {
  color: rgba(239, 228, 209, .88);
  font: 13px/1.75 "STSong", "Songti SC", serif;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-height: 690px) {
  .title-block { margin-top: 29dvh; }
}

/* Mobile phone viewport frame: full height on a phone, portrait canvas in desktop preview. */
#app {
  display: flex;
  justify-content: center;
  align-items: stretch;
}

.phone {
  width: min(100%, 46.21dvh);
  height: 100dvh;
  min-height: 100dvh;
  aspect-ratio: 390 / 844;
  margin: 0 auto;
}

/* Preserve the authored cover exactly; its letterboxing blends into the frame. */
.home-screen {
  background: linear-gradient(180deg, #070b15 0%, #151623 47%, #210e12 100%);
}

.home-cover-entry {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  pointer-events: none;
}

.home-cover {
  object-fit: contain;
  object-position: center;
}

.home-cover-veil {
  background: linear-gradient(180deg, rgba(5, 8, 16, .48) 0%, rgba(5, 8, 16, .08) 22%, rgba(18, 11, 16, .04) 67%, rgba(29, 10, 15, .52) 100%);
}

.home-foot {
  width: 100%;
  margin-top: auto;
}

.music-toggle {
  display: grid;
  width: 44px;
  min-width: 44px;
  height: 44px;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: rgba(242, 234, 220, .78);
}

.music-toggle svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.music-toggle:hover,
.music-toggle:focus-visible { color: var(--gold); }

/* Mobile is a true edge-to-edge app viewport. The portrait frame below is
   deliberately limited to desktop previews only. */
html,
body,
#app {
  width: 100%;
  height: 100%;
  min-height: 100%;
}

body {
  min-height: 100svh;
  min-height: 100dvh;
  overflow: hidden;
}

.phone {
  width: 100vw;
  height: 100svh;
  height: 100dvh;
  min-height: 100svh;
  min-height: 100dvh;
  aspect-ratio: auto;
  margin: 0;
}

/* Give every narrative choice a legible, thumb-friendly target. */
.choice {
  min-height: 56px;
  padding: 12px 14px;
}

.choice b { font-size: 14px; }

.choice span {
  font-size: 16px;
  line-height: 1.45;
}

.male-story .choice:hover,
.male-story .choice:focus-visible {
  background: rgba(23, 64, 93, .92);
  border-color: rgba(102, 185, 222, .88);
}

.male-story .choice:active {
  background: rgba(31, 85, 120, .96);
}

/* Safari may preserve :hover after a touch. Keep the selected-looking
   treatment exclusive to a real mouse, while :active still gives tap feedback. */
.choice {
  -webkit-tap-highlight-color: transparent;
}

@media (hover: none) {
  .choice:hover,
  .male-story .choice:hover {
    background: rgba(26, 24, 34, .8);
    border-color: rgba(255, 255, 255, .23);
    transform: none;
  }
}

@media (min-width: 550px) {
  .phone {
    width: min(100%, 46.21dvh);
    height: 100dvh;
    min-height: 100dvh;
    aspect-ratio: 390 / 844;
    margin: 0 auto;
  }
}

/* M17: the screen itself becomes the main composition, not a small inset window. */
.claude-screen {
  overflow: hidden;
  padding: calc(12px + env(safe-area-inset-top)) 14px calc(18px + env(safe-area-inset-bottom));
}

.claude-art {
  position: absolute;
  z-index: -2;
  width: 142%;
  height: 142%;
  left: -21%;
  top: -14%;
  object-fit: cover;
  object-position: center 31%;
}

.claude-screen .terminal-bg {
  z-index: -1;
  opacity: .12;
}

.claude-head {
  position: relative;
  z-index: 2;
  margin-bottom: 0;
}

.claude-screen .terminal {
  position: absolute;
  z-index: 1;
  top: 14%;
  left: 4.5%;
  right: 4.5%;
  height: 72%;
  overflow: auto;
  box-shadow: 0 18px 48px rgba(0, 0, 0, .48);
  background: rgba(5, 13, 25, .86);
}

.claude-screen .terminal-bar {
  height: 32px;
  padding: 0 10px;
  background: rgba(7, 16, 28, .94);
}

.claude-screen .terminal-body { padding: 10px 12px 12px; }
.claude-screen .system-message { margin-bottom: 8px; font-size: 11px; }
.claude-screen .calculation { gap: 3px; margin-bottom: 9px; padding: 8px; }
.claude-screen .calculation strong { font-size: 17px; }
.claude-screen .calculation em,
.claude-screen .terminal-question p,
.claude-screen .terminal-answer p { font-size: 11px; line-height: 1.4; }
.claude-screen .terminal-question,
.claude-screen .terminal-answer { margin: 7px 0; }
.claude-screen .terminal-answer.first p { font-size: 13px; }
.claude-screen .claude-prompts,
.claude-screen .claude-decisions { gap: 5px; margin-top: 9px; }
.claude-screen .claude-prompts button,
.claude-screen .claude-decisions button { padding: 7px 8px; font-size: 10px; }

.ending-music {
  position: absolute;
  z-index: 5;
  top: calc(12px + env(safe-area-inset-top));
  right: 16px;
}

.home-music,
.roles-music {
  position: absolute;
  z-index: 5;
  top: calc(12px + env(safe-area-inset-top));
  right: 16px;
}

.share-button {
  margin-bottom: 10px;
  background: rgba(211, 167, 96, .14);
  color: #ead6ae;
}
