/* The story uses the same warm paper and rounded controls as the game. */
.story-read-entry { display: flex; flex-direction: column; gap: 5px; width: 100%; margin: 14px 0 24px; }
.story-read-entry small { display: block; font-size: 12px; font-weight: 500; }
#storyReader { color: #49362e; background: #f8efd9; font-family: 'M PLUS Rounded 1c', sans-serif; }
#storyReader [hidden] { display: none !important; }
#storyReader .reader-button { min-height: 44px; border: 1px solid #785d3b30; border-radius: 14px; padding: 9px 16px; background: #fffaf1; color: #49362e; box-shadow: 0 3px 0 #725b3720; font: 700 14px/1.4 'M PLUS Rounded 1c', sans-serif; cursor: pointer; touch-action: manipulation; }
#storyReader .reader-button:active { transform: translateY(2px); box-shadow: none; }
#storyReader button:focus-visible, #storyReader select:focus-visible, #storyReader .reader-text:focus-visible { outline: 3px solid #368c92; outline-offset: 3px; }
#storyReader button:disabled { opacity: .4; cursor: default; }
.reader-library { max-width: 760px; width: 100%; margin: 0 auto; padding: max(20px,env(safe-area-inset-top)) 22px 36px; overflow-y: auto; position: relative; }
.reader-cover { height: 190px; display: flex; justify-content: center; margin: -10px auto 0; pointer-events: none; }
.reader-cover img { height: 100%; width: 140px; object-fit: contain; }
.reader-kicker { text-align: center; font-size: 12px; letter-spacing: .16em; margin: 5px 0; color: #907653; }
.reader-library h1 { font-size: clamp(26px,5vw,38px); margin: 4px 0 10px; text-align: center; color: #49362e; }
.reader-library-note { text-align: center; font-size: 13px; line-height: 1.7; margin: 0 0 18px; }
#storyReader .reader-resume { display: block; background: #f6cf70; width: 100%; margin-bottom: 18px; font-size: 16px; }
.reader-chapters { display: grid; padding: 0; gap: 10px; list-style: none; }
.reader-chapter { width: 100%; display: flex; gap: 14px; align-items: center; text-align: left; background: #fffaf0; color: #49362e; border: 1px solid #95775633; border-radius: 18px; padding: 17px; cursor: pointer; font-family: inherit; }
.reader-chapter:hover { background: #fff; border-color: #5b9699; }
.reader-chapter-number { font-size: 22px; font-weight: 800; color: #8caaa4; }
.reader-chapter b { display: block; font-size: 17px; margin-bottom: 5px; }
.reader-chapter small { display: block; font-size: 12px; line-height: 1.6; color: #796b5c; }
.reader-read-badge { flex-shrink: 0; margin-left: auto; color: #367e70; font-size: 12px; }
.reader-stage { --dialogue-size: 220px; position: relative; isolation: isolate; width: 100%; height: 100%; min-height: 0; overflow: hidden; background: #bedbd6; }
.reader-scenery { position: absolute; inset: 0; overflow: hidden; z-index: -1; background-color: var(--story-background-fallback,#d6d5bf); background-repeat: no-repeat; background-size: cover; background-position: var(--story-background-position,50% 50%); }
.reader-mountains { position: absolute; width: 85%; height: 72%; top: 20%; left: -22%; border-radius: 55% 55% 0 0; background: #80a591; box-shadow: 48vw 5vh 0 #9cb899; }
.reader-buildings { position: absolute; left: 5%; top: 43%; height: 30%; width: 24%; border-radius: 12px 12px 0 0; background: repeating-linear-gradient(90deg,transparent 0 28%,#a7c4bb 28% 42%,transparent 42% 62%),linear-gradient(#ba8f66 0 12%, #f0dcc0 12%); box-shadow: 42vw 4vh 0 #e1c6a8, 65vw -2vh 0 #f1dfc3; opacity: .7; }
.reader-floor { position: absolute; inset: 72% 0 0; background: linear-gradient(#dec7a5,#f6e8ca); }
.reader-stage:is([data-place="warehouse"],[data-place="meeting"],[data-place="shelter"],[data-place="exhibition"]) .reader-mountains { display: none; }
.reader-stage[data-background-status="loaded"] .reader-scenery { background-image: var(--story-background-image); }
.reader-stage[data-background-status="loaded"] .reader-scenery > * { display: none; }
@media (orientation: portrait) { .reader-scenery { background-position: var(--story-background-position-portrait,50% 50%); } }
.reader-toolbar { position: absolute; inset: max(14px,env(safe-area-inset-top)) 20px auto; display: grid; grid-template-columns: auto minmax(0,1fr) minmax(110px,200px); align-items: center; gap: 14px; z-index: 5; }
.reader-chapter-name { font-size: 14px; font-weight: 700; text-align: center; text-shadow: 0 1px 6px #fff; }
.reader-scene-picker { min-width: 0; width: 100%; min-height: 44px; background: #fff9e8eb; border: 1px solid #785d3b30; border-radius: 12px; color: #49362e; padding: 6px 10px; font: 600 12px/1.4 'M PLUS Rounded 1c',sans-serif; text-overflow: ellipsis; }
.reader-place { position: absolute; left: 50%; top: 80px; transform: translateX(-50%); background: #fff9e8cf; border: 1px solid #fff8; border-radius: 30px; padding: 7px 18px; font-size: 13px; max-width: 80%; text-align: center; white-space: nowrap; }
.reader-actors { position: absolute; left: max(3%,calc((100% - 1050px)/2)); right: max(3%,calc((100% - 1050px)/2)); top: 115px; bottom: calc(var(--dialogue-size) + 34px); display: flex; justify-content: space-around; align-items: flex-end; gap: 0; }
.reader-actors figure { width: 48%; height: 100%; margin: 0; display: flex; position: relative; align-items: flex-end; justify-content: center; transition: filter .18s, transform .18s, opacity .18s; filter: saturate(.55) brightness(.85); transform: translateY(5px) scale(.97); }
.reader-actors figure.is-speaking { filter: none; transform: none; z-index: 2; }
.reader-actors img { height: 100%; width: 100%; object-fit: contain; object-position: center bottom; filter: drop-shadow(0 10px 8px #4f482120); }
.reader-actors figcaption { position: absolute; bottom: 0; font-size: 12px; background: #fff6; padding: 4px 12px; border-radius: 20px; }
.reader-actors .is-speaking figcaption { background: #fff4cd; box-shadow: 0 2px 0 #9c7d3a30; }
.reader-actors .name-only { max-height: 54px; }
.reader-actors figure[data-actor="sumimaru"] img { height: 61%; }
.reader-actors figure[data-actor="child"] img { width: 70%; height: 78%; }
.reader-actors figure[data-actor="dongara"] img { width: 100%; height: 75%; }
.reader-actors figure[data-actor^="mob-soldier-"] img { width: 85%; height: 85%; }
.reader-dialogue { position: absolute; bottom: max(18px,env(safe-area-inset-bottom)); left: max(4%,calc((100% - 1000px)/2)); right: max(4%,calc((100% - 1000px)/2)); height: var(--dialogue-size); box-sizing: border-box; padding: 24px 28px 14px; background: #fffaf0f5; border: 2px solid #a6845840; border-radius: 24px; box-shadow: 0 6px 0 #7d634322,0 12px 30px #78604320; display: flex; flex-direction: column; z-index: 4; }
.reader-speaker { position: absolute; left: 22px; top: -19px; padding: 7px 24px; min-width: 85px; text-align: center; font-size: 16px; font-weight: 800; color: #fff; background: #427d80; border: 2px solid #fff9e8; border-radius: 18px; }
.reader-speaker[data-speaker="koyori"] { background: #bd6557; }
.reader-speaker[data-speaker="sumimaru"] { background: #8d823d; }
.reader-text { font-size: clamp(17px,2vw,21px); line-height: 1.85; flex: 1; min-height: 0; overflow-y: auto; white-space: pre-wrap; overflow-wrap: anywhere; padding: 1px 2px; scrollbar-width: thin; }
.reader-controls { margin-top: 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.reader-position { color: #96836b; font-size: 12px; white-space: nowrap; }
#storyReader .reader-next { background: #f2d179; min-width: 125px; }
.reader-save-error { position: absolute; top: 0; left: 0; right: 0; z-index: 20; margin: 0; background: #fff1c5; color: #674530; padding: 6px; font-size: 12px; text-align: center; }
#storyReader .reader-voice, #storyDialogue .dialogue-voice { position: absolute; z-index: 6; border: 1px solid #a6845840; border-radius: 18px; background: #fffaf0; color: #49362e; box-shadow: 0 2px 0 #725b3720; font: 700 12px/1.4 'M PLUS Rounded 1c',sans-serif; padding: 7px 12px; min-height: 36px; cursor: pointer; touch-action: manipulation; }
#storyReader .reader-voice { top: -19px; right: 14px; }
#storyDialogue .dialogue-voice { right: max(6%,calc((100% - 960px)/2)); bottom: calc(var(--dialogue-height) + max(18px,env(safe-area-inset-bottom)) - 16px); }
#storyDialogue .dialogue-voice[hidden] { display: none; }
#storyDialogue .dialogue-voice:disabled { opacity: .6; cursor: default; }
.reader-voice-credit, .dialogue-voice-credit { color: #796b5c; font: 500 10px/1.4 'M PLUS Rounded 1c',sans-serif; }
.reader-voice-credit { flex: none; text-align: center; margin-top: 4px; }
.dialogue-voice-credit { position: absolute; bottom: max(2px,calc(env(safe-area-inset-bottom) - 15px)); right: 5%; }
#storyReader .reader-toolbar { right: 64px; }
#storyDialogue .dialogue-skip { right: 64px; }
body:has(#storyReader.active, #storyDialogue.active) #soundPill.wait span { display: none; }
body:has(#storyReader.active, #storyDialogue.active) #soundPill { width: 40px; padding: 0; justify-content: center; }
@media (max-width: 600px) {
  .reader-stage { --dialogue-size: 236px; }
  .reader-toolbar { inset: max(12px,env(safe-area-inset-top)) 12px auto; grid-template-columns: auto minmax(0,1fr); gap: 9px; }
  .reader-chapter-name { display: none; }
  .reader-place { top: 72px; font-size: 12px; white-space: normal; width: max-content; max-width: 84%; }
  .reader-actors { top: 108px; left: 0; right: 0; bottom: calc(var(--dialogue-size) + 34px); }
  .reader-actors figure { width: 48%; flex-shrink: 0; }
  .reader-actors figcaption { font-size: 11px; }
  .reader-dialogue { left: 12px; right: 12px; padding: 22px 16px 12px; border-radius: 20px; }
  .reader-text { font-size: 17px; line-height: 1.8; }
  #storyReader .reader-button { padding: 9px 12px; font-size: 12px; }
  #storyReader .reader-next { min-width: 105px; }
  .reader-cover { height: 145px; }
}
@media (max-height: 650px) and (orientation: portrait) {
  .reader-stage { --dialogue-size: 205px; }
  .reader-place { top: 64px; padding: 4px 12px; }
  .reader-actors { top: 98px; }
  .reader-text { font-size: 15px; line-height: 1.65; }
  .reader-dialogue { bottom: 12px; }
}
@media (orientation: landscape) and (max-height: 560px) {
  #storyDialogue .dialogue-voice { top: 10px; bottom: auto; right: calc(26% + 10px); }
  .reader-stage { --dialogue-size: 146px; }
  .reader-toolbar { inset: 8px 12px auto; gap: 10px; }
  .reader-toolbar .reader-button,.reader-scene-picker { min-height: 36px !important; }
  .reader-place { display: none; }
  .reader-actors { top: 48px; bottom: 26px; left: 0; right: 0; justify-content: space-between; }
  .reader-actors figure { width: 27%; }
  .reader-actors figcaption { display: none; }
  .reader-dialogue { left: 24%; right: 24%; bottom: 14px; height: min(70%,240px); padding: 19px 13px 9px; border-radius: 18px; }
  .reader-text { font-size: 15px; line-height: 1.6; }
  .reader-speaker { top: -16px; left: 12px; padding: 4px 18px; font-size: 13px; min-width: 70px; }
  .reader-controls { gap: 5px; margin-top: 6px; }
  #storyReader .reader-controls .reader-button { min-height: 38px; padding: 7px 9px; font-size: 11px; }
  #storyReader .reader-next { min-width: 85px; }
  .reader-position { font-size: 10px; }
  .reader-cover { height: 105px; margin-top: -36px; }
}
@media (prefers-reduced-motion: reduce) { .reader-actors figure { transition: none; } }
