dialog#modal.paper-open {
  position: fixed;
  inset: auto;
  margin: 0;
  width: min(1280px, calc(100vw - 32px));
  height: min(940px, calc(100vh - 32px));
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 28px;
  overflow: hidden;
  background: #6a4128;
  color: #3a2a1a;
  box-shadow: 0 28px 80px #1a1008cc;
}
dialog#modal.paper-open.is-dragging,
dialog#modal.paper-open.is-resizing { user-select: none; }
dialog#modal.paper-open.is-dragging .book-cover { cursor: grabbing; }
dialog#modal.paper-open .paper-restore {
  position: absolute;
  z-index: 9;
  top: 14px;
  right: 64px;
  white-space: nowrap;
  padding: 6px 12px;
  border: 3px solid #3a2a1a;
  border-radius: 999px;
  background: #fff8e8;
  color: #3a2a1a;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 3px 3px 0 #f0d56a;
  cursor: pointer;
}
dialog#modal.paper-open .paper-resize {
  position: absolute;
  z-index: 12;
  right: 10px;
  bottom: 10px;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 3px solid #3a2a1a;
  border-radius: 9px;
  background:
    linear-gradient(135deg, transparent 0 42%, #3a2a1a 42% 50%, transparent 50% 58%, #3a2a1a 58% 66%, transparent 66%),
    #f0d56a;
  box-shadow: 2px 2px 0 #fff8e8;
  cursor: nwse-resize;
  touch-action: none;
}
dialog.paper-open::backdrop { background: #1b2428b8; }
dialog#modal:not(.paper-open) .paper-restore,
dialog#modal:not(.paper-open) .paper-fold,
dialog#modal:not(.paper-open) .paper-resize { display: none !important; }
dialog#modal.hub-open {
  position: fixed !important;
  inset: auto !important;
  transform: none !important;
  margin: 0 !important;
  background: #fffdf6;
  color: #294c43;
  border: 1px solid #dce5d3;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 30px 120px #123c3b44;
}
dialog#modal.hub-open .modal-top {
  position: relative;
  inset: auto;
  cursor: grab;
  touch-action: none;
}
dialog#modal.hub-open .modal-top > span {
  position: static;
  width: auto;
  height: auto;
  overflow: visible;
  clip: auto;
  pointer-events: none;
}
dialog#modal.hub-open.is-dragging .modal-top { cursor: grabbing; }
dialog#modal.hub-open.is-dragging { user-select: none; }
dialog#modal.hub-open .paper-restore,
dialog#modal.hub-open .paper-fold,
dialog#modal.hub-open .paper-resize,
dialog#modal.hub-open .diorama,
dialog#modal.hub-open .actor-pop,
dialog#modal.hub-open .book-cover { display: none !important; }
dialog#modal.hub-open #modal-content { height: auto; max-height: calc(100% - 58px); overflow: auto; }
dialog.paper-open .modal-top {
  position: absolute;
  top: 12px;
  right: 12px;
  left: auto;
  z-index: 8;
  padding: 0;
  border: 0;
  background: transparent;
}
dialog.paper-open .modal-top > span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
dialog.paper-open #close-modal {
  width: 38px;
  height: 38px;
  border: 3px solid #3a2a1a;
  background: #fff8e8;
  color: #3a2a1a;
  font-weight: 800;
  box-shadow: 3px 3px 0 #f0d56a;
}
dialog.paper-open #modal-content {
  height: 100%;
  padding: 0;
  overflow: hidden;
}
#paper-logic { display: none !important; }
.paper-stage { height: 100%; }
.paper-desk {
  position: relative;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 12px 12px 46px;
  border-radius: 28px;
  overflow: hidden;
  background:
    radial-gradient(circle at 12% 8%, #d59a62 0 18%, transparent 40%),
    repeating-linear-gradient(90deg, #a86d3e 0 18px, #8f572c 18px 21px, #c4844e 21px 46px);
}
.paper-book {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  margin: 8px 10px 0;
  border-radius: 24px 28px 26px 24px;
  background: linear-gradient(90deg, #fbf6e8 0 49.2%, #d7c4a0 49.2% 50.8%, #f3e6cc 50.8%);
  box-shadow:
    0 0 0 10px var(--cover, #9c2430),
    0 0 0 14px #e8c56a,
    0 0 0 18px var(--cover-deep, #6e141c),
    0 16px 0 #5a3018,
    0 24px 28px #28140a55;
  overflow: hidden;
  transform-origin: center bottom;
  animation: bookOpen .55s cubic-bezier(.2, 1, .3, 1) both;
}
.paper-stage.is-turning .paper-book { animation: bookShut .42s ease forwards; }
.book-cover {
  position: absolute;
  z-index: 5;
  top: 0;
  left: 0;
  right: 0;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 8px 168px 8px 16px;
  cursor: grab;
  touch-action: none;
  user-select: none;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--cover, #9c2430) 70%, white) 0%, var(--cover, #9c2430) 46%, var(--cover-deep, #6e141c) 100%);
  border-bottom: 3px solid #e8c56a;
  box-shadow: inset 0 1px 0 #ffffff66, 0 8px 0 #00000014;
}
.foil {
  font-size: clamp(20px, 2.4vw, 30px);
  font-weight: 900;
  letter-spacing: .14em;
  line-height: 1.2;
  background: linear-gradient(185deg, #fff8dc 0%, #ffe7a3 18%, #e2ae3c 46%, #fff6d0 58%, #b8860b 80%, #f8e7a2 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 1px 0 #5a3d0a) drop-shadow(0 -1px 0 #fff8dc);
}
.book-cover small {
  flex: 0 1 auto;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  color: #f8e7b2;
  text-shadow: 0 1px 0 #3a2408;
}
.paper-stamp {
  position: absolute;
  z-index: 5;
  top: 68px;
  right: 18px;
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
  text-align: center;
  border: 3px dashed #c4554a;
  border-radius: 50%;
  color: #c4554a;
  background: #fff8e8cc;
  transform: rotate(8deg);
}
.paper-stamp b { font-size: 22px; line-height: 1; }
.paper-stamp small, .paper-stamp em { display: block; font-style: normal; font-size: 10px; font-weight: 700; }
.travel-banner {
  position: absolute;
  z-index: 6;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%) rotate(-2deg);
  padding: 10px 18px;
  background: #fff8e8;
  border: 4px solid #3a2a1a;
  border-radius: 14px;
  box-shadow: 4px 4px 0 #f0d56a;
  font-weight: 800;
  animation: bannerPop .7s .15s both, bannerAway .45s 2.1s forwards;
}

.paper-book { perspective: 1400px; }
.diorama {
  position: absolute;
  inset: 64px 10px 8px;
  perspective: 1100px;
  transform-style: preserve-3d;
  background:
    linear-gradient(180deg, transparent 0 62%, #00000010 100%);
}
.layer {
  position: absolute;
  transform-style: preserve-3d;
}
.layer svg, .cut svg { width: 100%; height: 100%; overflow: visible; display: block; }
.layer.sky {
  inset: 0 0 22% 0;
  animation: sceneSwap .5s steps(5, end) both;
}
.layer.hill {
  inset: auto 0 18% 0;
  height: 42%;
  animation: risePaper .55s steps(4, end) .05s both;
}
.cut {
  position: absolute;
  z-index: 3;
  transform-origin: center bottom;
  filter: drop-shadow(8px 14px 0 #5a3c2233);
  animation: cutPop .62s steps(5, end) both;
}
.cut-tree { right: 24%; bottom: 20%; width: min(210px, 26%); height: 46%; animation-delay: .08s; }
.cut-prop { left: 6%; bottom: 16%; width: min(420px, 48%); height: 52%; animation-delay: .12s; }
.ground-card {
  position: absolute;
  z-index: 1;
  left: 3%;
  right: 3%;
  bottom: 3%;
  height: 48%;
  border: 12px solid #fff;
  border-radius: 18px 18px 12px 12px;
  box-shadow: 0 12px 0 #eadcc4, 0 18px 0 #5a3c2226, inset 0 0 0 3px #3a2a1a18;
  transform: rotateX(24deg);
  transform-origin: center bottom;
  background:
    radial-gradient(circle at 16% 48%, #ffffff99 0 3px, transparent 4px),
    radial-gradient(circle at 38% 64%, #0000001c 0 4px, transparent 5px),
    radial-gradient(circle at 61% 42%, #00000016 0 3px, transparent 4px),
    radial-gradient(circle at 84% 60%, #ffffff73 0 3px, transparent 4px),
    var(--floor, #9dce78);
  animation: popStand .7s steps(6, end) .08s both;
}
.ground-card i {
  position: absolute;
  bottom: 22%;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 18px solid #ffffffd0;
}
.ground-card i:nth-child(1) { left: 10%; }
.ground-card i:nth-child(2) { left: 24%; transform: scale(.75); }
.ground-card i:nth-child(3) { left: 46%; }
.ground-card i:nth-child(4) { left: 68%; transform: scale(.8); }
.ground-card i:nth-child(5) { left: 86%; transform: scale(.65); }
.paper-bits { position: absolute; inset: 0; z-index: 4; pointer-events: none; overflow: hidden; }
.paper-bits b {
  position: absolute;
  top: 8%;
  width: 14px;
  height: 18px;
  background: #e39a3a;
  border: 2px solid #fff;
  border-radius: 0 80% 0 80%;
  animation: leafDrift 3.6s steps(8, end) infinite;
}
.paper-bits b:nth-child(1) { left: 18%; background: #e07a4a; animation-duration: 3.2s; }
.paper-bits b:nth-child(2) { left: 36%; background: #7fbf62; animation-duration: 4.1s; animation-delay: .4s; }
.paper-bits b:nth-child(3) { left: 52%; background: #f0d56a; animation-duration: 3.5s; animation-delay: .8s; }
.paper-bits b:nth-child(4) { left: 68%; background: #e85d4c; animation-duration: 4.4s; animation-delay: .2s; }
.paper-bits b:nth-child(5) { left: 80%; background: #8ed36a; animation-duration: 3.8s; animation-delay: 1s; }
.paper-bits b:nth-child(6) { left: 28%; width: 10px; height: 14px; background: #f4e7cf; animation-duration: 4.6s; animation-delay: .6s; }
.page-leaf {
  position: absolute;
  z-index: 7;
  top: 64px;
  right: 0;
  bottom: 0;
  left: 50%;
  background:
    linear-gradient(90deg, #c4a36a, #fffdf8 8%, #fff8ea 80%, #e7d3b0);
  transform-origin: left center;
  animation: leafTurn .85s ease forwards;
  pointer-events: none;
  box-shadow: -8px 0 0 #5a3c2222;
}
.diorama[data-scene="factory"] .layer.front { background: #8ea497; }
.diorama[data-scene="lab"] .layer.front { background: #d7fff4; }
.diorama[data-scene="library"] .layer.front { background: #c9a27a; }
.actor-pop {
  position: absolute;
  right: 14%;
  bottom: 16%;
  width: min(200px, 24%);
  z-index: 5;
  transform: translateZ(80px);
  transform-style: preserve-3d;
  animation: popStand .55s steps(5, end) .2s both;
}
.actor-pop.is-entering { animation: paperEnter .72s cubic-bezier(.16, .9, .3, 1) both; }
.paper-stand {
  display: block;
  width: 78%;
  height: 16px;
  margin: -6px auto 0;
  background: #f7f1e4;
  border: 4px solid #fff;
  border-radius: 50%;
  box-shadow: 0 7px 0 #5a3c2226;
}
.stage-clue {
  position: absolute;
  left: 7%;
  bottom: 30%;
  width: 148px;
  height: 188px;
  z-index: 4;
  padding: 0;
  border: 0;
  background: transparent;
  perspective: 700px;
  cursor: pointer;
}
.stage-clue[hidden] { display: none !important; }
.stage-clue-front, .stage-clue-back {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 10px;
  backface-visibility: hidden;
  background: #fffdf8;
  border: 8px solid #fff;
  border-radius: 6px;
  box-shadow: 8px 0 0 #f3e6cf, 12px 0 0 #d7c4a0, 6px 10px 0 #5a3c2224;
  color: #3a2a1a;
  text-align: left;
  transition: transform .55s cubic-bezier(.2, .8, .2, 1);
}
.stage-clue-front small, .stage-clue em { font-style: normal; font-size: 12px; font-weight: 800; color: #8a5a3a; }
.stage-clue-front b { font-size: 22px; }
.stage-clue-back { transform: rotateY(180deg); overflow: auto; font-size: 12px; font-weight: 700; line-height: 1.45; }
.stage-clue-back p { margin: 0 0 6px; }
.stage-clue.is-open .stage-clue-front { transform: rotateY(180deg); }
.stage-clue.is-open .stage-clue-back { transform: rotateY(360deg); }
.paper-pages-mode .diorama { bottom: 48%; }
.paper-pages-mode .actor-pop { width: 100px; top: 38%; bottom: auto; }
.paper-stage.paper-board-quest .paper-pages-slot { display: none; }
.paper-stage.paper-board-quest .diorama { inset: 70px 16px 18px; bottom: 18px; }
.paper-stage.paper-board-quest .actor-pop { width: 146px; top: auto; bottom: 42px; }
.paper-board-quest .paper-overlay { bottom: 168px; max-height: 42%; }
.paper-board-quest .paper-tray { max-height: 250px; }
.paper-board-quest .story-choices > button > span { width: auto; min-width: 46px; padding: 0 5px; font-size: 11px; }
.paper-clue {
  position: absolute;
  z-index: 4;
  top: 78px;
  left: 18px;
  max-width: 46%;
  padding: 10px 12px;
  background: #fffef8;
  border: 3px solid #fff;
  border-radius: 8px;
  box-shadow: 4px 4px 0 #ead9b8, 7px 10px 0 #5a3c2222;
  color: #3a2a1a;
  font-weight: 800;
  line-height: 1.45;
  transform: rotate(-2deg);
}
.paper-clue small { display: block; font-weight: 700; color: #8a5a3a; margin-bottom: 4px; }
.paper-clue .paper-clue-hint { margin: 6px 0 0; font-weight: 600; line-height: 1.5; color: #5a6b4a; }
.paper-stage.paper-play.paper-board-quest .diorama { grid-row: 2 / 4; }
.paper-stage.paper-play.paper-board-quest .paper-side .paper-overlay,
.paper-stage.paper-play.paper-board-quest .paper-side .paper-tray { max-height: none; bottom: auto; }
.paper-stage.paper-board-quest .paper-side > .paper-clue {
  position: static;
  max-width: none;
  transform: none;
  margin: 0;
}
.paper-stage.paper-board-quest .paper-tray:has(.story-choices)::before { content: "選擇文據"; }
.paper-stage.paper-play.paper-board-quest .actor-pop { height: 40%; }
.quest-file { display: grid; gap: 2px; text-align: left; }
.quest-file-meta { display: block; margin-top: 2px; font-size: 11px; font-weight: 600; color: #8a7a5a; }
.paper-pages-slot {
  position: absolute;
  z-index: 5;
  left: 16px;
  right: 16px;
  bottom: 12px;
  height: 50%;
}
.paper-stage.paper-full .diorama { display: none; }
.paper-stage.paper-full .paper-pages-slot {
  top: 70px;
  height: auto;
}
.paper-stage.paper-full .paper-pages { border-radius: 18px; }
dialog.paper-open .paper-fold {
  position: absolute;
  z-index: 9;
  top: 14px;
  right: 168px;
  z-index: 9;
  white-space: nowrap;
  border: 3px solid #3a2a1a;
  border-radius: 999px;
  background: #fff8e8;
  color: #3a2a1a;
  font-weight: 800;
  padding: 6px 12px;
}
dialog.paper-open.is-collapsed {
  height: 74px !important;
  min-height: 0 !important;
  overflow: hidden;
}
dialog.paper-open.is-collapsed .paper-resize { display: none; }
.paper-pages {
  height: 100%;
  overflow: auto;
  padding: 14px 16px 18px;
  background: #fffdf8f2;
  border: 4px solid #fff;
  border-radius: 14px;
  box-shadow: 5px 6px 0 #ead9b8, 8px 14px 0 #5a3c2226;
  color: #3a2a1a;
}
.paper-pages h2, .paper-pages h3, .paper-pages p, .paper-pages li, .paper-pages small, .paper-pages label, .paper-pages summary { color: #3a2a1a; }
.paper-pages .story-document, .paper-pages .evidence-bag article, .paper-pages .season-journal button, .paper-pages .transcript-list button {
  border: 3px solid #3a2a1a;
  border-radius: 12px;
  background: #fffef8;
  box-shadow: 3px 3px 0 #f0d56a;
  color: #3a2a1a;
}
.paper-actor {
  transform-origin: center bottom;
  padding: 0;
  background: transparent;
  border-radius: 0;
  filter: drop-shadow(10px 12px 0 #5a3c2233);
  animation: none;
}
.actor-pop.is-talking .paper-actor { animation: none; }
.actor-pop.is-pointing .paper-actor { animation: pointFrame .72s steps(4, end) both; }
.actor-pop.is-nod .paper-actor { animation: nodFrame .64s steps(4, end) both; }
.paper-actor svg { display: block; background: transparent; overflow: visible; }
.paper-actor.is-flipping, .paper-portrait.is-flipping { animation: flipCard .42s steps(4, end); }
.doc-slot {
  position: absolute;
  left: 7%;
  bottom: 8%;
  width: 176px;
  z-index: 3;
  transform: translateZ(64px) rotate(-7deg);
  animation: paperRise .55s .2s both;
  cursor: pointer;
}
.doc-slot[hidden] { display: none !important; }
.doc-slot .story-document {
  margin: 0;
  max-height: 112px;
  overflow: hidden;
  padding: 10px 12px;
  border: 3px solid #fff;
  border-radius: 4px;
  background: #fffef8;
  box-shadow: 4px 4px 0 #ead9b8, 8px 12px 0 #5a3c2224;
}
.doc-slot .story-document h3 { font-size: 13px; margin: 4px 0; color: #3a2a1a; }
.doc-slot .story-document li, .doc-slot .story-document small { font-size: 10px; line-height: 1.45; color: #5c4a38; }
.doc-slot .examine {
  position: absolute;
  right: -10px;
  top: -12px;
  width: 28px;
  height: 28px;
  border: 3px solid #3a2a1a;
  border-radius: 50%;
  background: #f0d56a;
  font-weight: 800;
  box-shadow: 2px 2px 0 #fff;
  animation: blink 1.1s steps(2, end) infinite;
}
.doc-slot.is-reading {
  width: min(480px, 68%);
  z-index: 6;
  transform: translateZ(120px) rotate(-1deg);
}
.doc-slot.is-reading .story-document { max-height: 230px; overflow: auto; }
.doc-slot.is-reading .examine { animation: none; }

.paper-tools {
  position: absolute;
  left: 14px;
  right: 52px;
  bottom: 8px;
  z-index: 8;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
}
.paper-tools button, .paper-tray button, .paper-slip .primary, .paper-slip button.primary {
  border: 3px solid #3a2a1a;
  background: #fffdf6;
  color: #3a2a1a;
  border-radius: 12px;
  box-shadow: 3px 3px 0 #f0d56a;
  font-weight: 750;
}
.paper-tools button { padding: 6px 10px; font-size: 12px; background: #fff8e8; }
.paper-overlay {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 142px;
  z-index: 6;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 42%;
}
.paper-tray {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 168px;
  overflow: auto;
}
.paper-tray.is-waiting { display: none; }
.paper-stage .story-choices, .paper-stage .contract-lines, .paper-stage .authored-questions,
.paper-stage .sequence-puzzle, .paper-stage .classification-puzzle, .paper-stage .cost-basket,
.paper-stage .split-board, .paper-stage .asset-scope {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
}
.paper-stage .story-choices > button,
.paper-stage .contract-lines > button,
.paper-stage .authored-questions > button {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  text-align: left;
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  line-height: 1.5;
  color: #3a2a1a;
  background: #fffdf8;
  border: 3px solid #3a2a1a;
  border-radius: 14px;
  box-shadow: 3px 3px 0 #f0d56a;
}
.paper-stage .story-choices > button > span,
.paper-stage .contract-lines > button > span,
.paper-stage .authored-questions > button > span {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e85d4c;
  color: #fffaf0;
  font-size: 12px;
  font-weight: 800;
}
.paper-stage .story-choices > button:disabled,
.paper-stage .contract-lines > button:disabled,
.paper-stage .authored-questions > button:disabled { opacity: .45; }
.paper-stage .position-story, .paper-stage .classification-puzzle, .paper-stage .sequence-puzzle,
.paper-stage .cost-basket, .paper-stage .split-board, .paper-stage .asset-scope, .paper-stage .cross-question {
  background: #fffdf8;
  border: 3px solid #3a2a1a;
  border-radius: 14px;
  padding: 10px 12px;
  color: #3a2a1a;
  box-shadow: 3px 3px 0 #f0d56a;
}
.paper-stage select, .paper-stage input, .paper-stage textarea {
  width: 100%;
  margin-top: 6px;
  padding: 8px 10px;
  border: 3px solid #3a2a1a;
  border-radius: 10px;
  background: #fff;
  color: #3a2a1a;
  font: inherit;
}
.paper-stage input[type="checkbox"],
.paper-stage input[type="radio"] {
  width: 18px;
  height: 18px;
  min-width: 18px;
  margin: 2px 0 0;
  padding: 0;
  flex: 0 0 18px;
  accent-color: #c4554a;
}
.paper-book > .paper-overlay {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 10px;
  top: auto;
  z-index: 5;
  max-height: 34%;
  margin: 0;
  overflow: auto;
  pointer-events: none;
}
.paper-book > .paper-overlay .paper-tray,
.paper-book > .paper-overlay .paper-slip { pointer-events: auto; }
.paper-book > .paper-overlay .paper-tray {
  max-height: none;
  overflow: visible;
  padding: 8px;
  background: #fffdf8f2;
  border: 3px solid #3a2a1a;
  border-radius: 16px;
  box-shadow: 4px 4px 0 #f0d56a;
}
.paper-book > .paper-overlay .paper-tray.is-waiting { display: none; }
.paper-stage .position-formula {
  margin: 0 0 8px;
  padding: 8px 10px;
  color: #3a2a1a;
  font-size: 14px;
  font-weight: 750;
  line-height: 1.5;
  background: #fff6dc;
  border: 3px dashed #c4a36a;
  border-radius: 10px;
}
.paper-stage .position-story > label,
.paper-stage .position-story legend {
  color: #3a2a1a;
  font-size: 14px;
  font-weight: 800;
}
.paper-stage .position-story fieldset {
  margin: 8px 0;
  padding: 8px 10px 4px;
  border: 3px dashed #d7c4a0;
  border-radius: 10px;
}
.paper-stage .position-story fieldset label,
.paper-stage .asset-scope label,
.paper-stage .cost-basket label {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 6px 0;
  color: #3a2a1a;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
}
.paper-stage .verdict-caution {
  margin: 4px 0 8px;
  color: #8a5a3a;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}
.paper-stage.paper-worksheet .paper-book {
  flex: 1 1 auto;
  min-height: 280px;
}
.paper-stage.paper-worksheet .paper-overlay {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 10px;
  top: auto;
  flex: none;
  max-height: 36%;
  margin: 0;
  overflow: auto;
}
.paper-stage.paper-worksheet .paper-slip.is-open { max-height: 150px; }
.paper-stage.paper-worksheet .diorama > .paper-dialogue {
  top: 2%;
  width: min(360px, 46%);
  margin: 0;
  min-height: 0;
  padding: 10px 12px 8px;
}
.paper-stage.paper-worksheet .actor-pop { bottom: 40%; width: min(128px, 18%); }
.paper-stage.paper-worksheet .cut-tree { bottom: 42%; }
.paper-stage.paper-worksheet .cut-prop { bottom: 40%; height: 34%; }
.paper-stage.paper-worksheet .ground-card { height: 26%; }
.paper-stage.paper-worksheet .story-question,
.paper-stage.paper-worksheet .split-board,
.paper-stage.paper-worksheet .split-board p,
.paper-stage.paper-worksheet .split-board label,
.paper-stage.paper-worksheet .cost-basket,
.paper-stage.paper-worksheet .position-story,
.paper-stage.paper-worksheet .classification-puzzle label,
.paper-stage.paper-worksheet .sequence-puzzle label,
.paper-stage.paper-worksheet .cross-question {
  color: #3a2a1a;
  font-size: 16px;
  font-weight: 750;
  line-height: 1.55;
}
.paper-stage.paper-worksheet .split-board,
.paper-stage.paper-worksheet .cost-basket,
.paper-stage.paper-worksheet .position-story,
.paper-stage.paper-worksheet .classification-puzzle,
.paper-stage.paper-worksheet .sequence-puzzle,
.paper-stage.paper-worksheet .asset-scope {
  padding: 12px 14px;
}
.paper-stage.paper-worksheet input[type="number"],
.paper-stage.paper-worksheet select {
  font-size: 18px;
  padding: 8px 12px;
  margin-top: 6px;
}
.paper-stage.paper-worksheet .split-board p { margin: 6px 0; }
.paper-stage.paper-worksheet .worksheet-source-toggle {
  align-self: flex-start;
  margin-bottom: 8px;
  padding: 6px 12px;
  font-size: 13px;
}
.paper-stage.paper-worksheet .worksheet-source {
  max-height: 180px;
  overflow: auto;
  margin-bottom: 8px;
}
.paper-stage.paper-worksheet .worksheet-source[hidden] { display: none; }
.paper-stage .primary {
  background: #e85d4c;
  color: #fffaf0;
  border: 3px solid #3a2a1a;
  border-radius: 12px;
  box-shadow: 3px 3px 0 #f0d56a;
  font-weight: 800;
  padding: 10px 14px;
}
.paper-slip { display: none; }
.paper-slip.is-open {
  display: block;
  max-height: 120px;
  overflow: auto;
  padding: 8px 10px;
  background: #fffdf8;
  border: 3px solid #3a2a1a;
  border-radius: 12px;
  box-shadow: 3px 3px 0 #f0d56a;
}
.paper-slip .primary { position: sticky; bottom: 0; width: 100%; }
.paper-slip .story-feedback { margin: 0; background: transparent; border: 0; padding: 0; }
.paper-slip .learning-feedback { font-size: 12px; }

.diorama > .paper-dialogue {
  position: absolute;
  z-index: 6;
  left: 5%;
  top: 4%;
  width: min(430px, 52%);
  min-height: 0;
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 18px;
  gap: 8px;
  align-items: end;
  padding: 12px 14px 10px;
  cursor: pointer;
  background: #fffdf8;
  border: 4px solid #3a2a1a;
  border-radius: 22px;
  box-shadow: 5px 5px 0 #f0d56a, 8px 12px 0 #5a3c2228;
  transform-origin: 78% 120%;
}
.diorama > .paper-dialogue.is-pop { animation: bubblePop .42s steps(4, end) both; }
.diorama > .paper-dialogue::after {
  content: "";
  position: absolute;
  right: 16%;
  bottom: -15px;
  width: 22px;
  height: 22px;
  background: #fffdf8;
  border-right: 4px solid #3a2a1a;
  border-bottom: 4px solid #3a2a1a;
  transform: rotate(32deg);
}
.diorama .paper-portrait { display: none; }
.diorama .paper-name {
  position: static;
  display: inline-block;
  margin: 0 0 6px;
  top: auto;
  left: auto;
}
.paper-dialogue {
  position: relative;
  flex-shrink: 0;
  z-index: 7;
  display: grid;
  grid-template-columns: 92px 1fr 24px;
  gap: 10px;
  align-items: center;
  margin: 10px 16px 0;
  min-height: 118px;
  padding: 16px 14px 12px;
  cursor: pointer;
  background: linear-gradient(#fffaf0, #fff1cc);
  border: 4px solid #3a2a1a;
  border-radius: 18px;
  box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 6px #f0d56a, 0 8px 0 #5c3a22;
}
.paper-portrait {
  height: 86px;
  border: 3px solid #3a2a1a;
  border-radius: 12px;
  background: #d9efe4;
  overflow: hidden;
  transform-origin: center center;
}
.paper-portrait svg { width: 100%; height: 116%; margin-top: -4px; }
.paper-name {
  position: absolute;
  top: -14px;
  left: 112px;
  padding: 2px 10px;
  background: #e85d4c;
  color: #fffaf0;
  border: 3px solid #3a2a1a;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 800;
}
.paper-role { display: block; font-size: 11px; font-weight: 700; color: #8a5a3a; margin-bottom: 2px; }
.paper-text { margin: 0; font-size: 16px; font-weight: 750; line-height: 1.6; color: #3a2a1a; min-height: 2.8em; }
.paper-next { align-self: end; font-style: normal; font-weight: 900; animation: blink 1s steps(2, end) infinite; }
.paper-stage.is-ready .paper-next { visibility: hidden; }

@keyframes bookOpen { from { transform: rotateX(28deg) scale(.97); opacity: .35; } to { transform: none; opacity: 1; } }
@keyframes bookShut { to { transform: rotateX(36deg) scale(.94); opacity: 0; } }
@keyframes paperRise { from { opacity: 0; transform: rotateX(72deg) translateY(28px); } }
@keyframes paperEnter {
  0% { transform: translate3d(150px, 12px, 96px); opacity: 0; }
  100% { transform: translate3d(0, 0, 96px); opacity: 1; }
}
@keyframes sceneSwap {
  0% { transform: translate3d(-70px, 8px, 0); opacity: 0; }
  100% { transform: none; opacity: 1; }
}
@keyframes leafTurn {
  0% { transform: rotateY(0); }
  100% { transform: rotateY(-188deg); opacity: 0; }
}
@keyframes popStand {
  0% { transform: rotateX(88deg); opacity: .15; }
  100% { opacity: 1; }
}
.paper-book > .paper-overlay:has(.story-choices),
.paper-book > .paper-overlay:has(.authored-questions),
.paper-book > .paper-overlay:has(.contract-lines) {
  left: 18px;
  right: auto;
  width: min(640px, 62%);
  bottom: 14px;
  max-height: none;
  overflow: visible;
  background: transparent;
}
.paper-book > .paper-overlay:has(.story-choices) .paper-tray,
.paper-book > .paper-overlay:has(.authored-questions) .paper-tray,
.paper-book > .paper-overlay:has(.contract-lines) .paper-tray {
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
}
.paper-stage .story-choices > button,
.paper-stage .authored-questions > button,
.paper-stage .contract-lines > button {
  animation: choiceIn .4s steps(3, end) both;
}
.paper-stage .story-choices > button:nth-child(2),
.paper-stage .authored-questions > button:nth-child(2),
.paper-stage .contract-lines > button:nth-child(2) { animation-delay: .08s; }
.paper-stage .story-choices > button:nth-child(3),
.paper-stage .authored-questions > button:nth-child(3),
.paper-stage .contract-lines > button:nth-child(3) { animation-delay: .16s; }
.paper-stage .story-choices > button:nth-child(4),
.paper-stage .authored-questions > button:nth-child(4) { animation-delay: .24s; }
.paper-tray:has(.story-choices)::before,
.paper-tray:has(.authored-questions)::before {
  content: "選擇對話";
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  color: #8a5a3a;
}
.paper-tray.is-attention {
  animation: trayAttention .85s ease;
}
@keyframes trayAttention {
  0%, 100% { transform: translateY(0); box-shadow: 4px 4px 0 #f0d56a; }
  35% { transform: translateY(-3px); box-shadow: 0 0 0 3px #f5cf6a, 4px 4px 0 #f0d56a; }
}
@media (prefers-reduced-motion: reduce) {
  .paper-tray.is-attention { animation: none; }
}
.paper-book .professional-followup {
  max-height: 36px;
  overflow: hidden;
  margin: 0;
  padding: 6px 8px;
}
.paper-book .professional-followup:hover,
.paper-book .professional-followup:focus-within { max-height: 180px; }
@keyframes idleFrame {
  0%, 100% { transform: translateY(0) rotate(-1.5deg); }
  50% { transform: translateY(-6px) rotate(1.5deg); }
}
@keyframes talkFrame {
  0% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-14px) rotate(3deg); }
}
@keyframes pointFrame {
  0% { transform: translateX(0) rotate(0); }
  25% { transform: translateX(-8px) rotate(-4deg); }
  50% { transform: translateX(-20px) rotate(-11deg); }
  100% { transform: translateX(-8px) rotate(-6deg); }
}
@keyframes nodFrame {
  0% { transform: translateY(0) scale(1, 1); }
  35% { transform: translateY(8px) scale(1.04, .9); }
  70% { transform: translateY(-8px) scale(.98, 1.06); }
  100% { transform: translateY(0) scale(1, 1); }
}
@keyframes bubblePop {
  0% { transform: scale(.15) rotate(-8deg); opacity: 0; }
  45% { transform: scale(1.08) rotate(2deg); opacity: 1; }
  100% { transform: scale(1) rotate(-1deg); opacity: 1; }
}
@keyframes choiceIn {
  0% { transform: translateY(18px) scale(.82); opacity: 0; }
  100% { transform: none; opacity: 1; }
}
@keyframes cutPop {
  0% { transform: translateY(36px) scale(.55); opacity: 0; }
  60% { transform: translateY(-8px) scale(1.05); opacity: 1; }
  100% { transform: none; opacity: 1; }
}
@keyframes risePaper {
  0% { transform: translateY(48px); opacity: 0; }
  100% { transform: none; opacity: 1; }
}
@keyframes leafDrift {
  0% { transform: translate(20px, -20px) rotate(-20deg); opacity: 0; }
  15% { opacity: 1; }
  100% { transform: translate(-80px, 280px) rotate(200deg); opacity: .2; }
}
@keyframes flipCard {
  0% { transform: rotateY(0); }
  50% { transform: rotateY(90deg) scaleX(.2); }
  100% { transform: rotateY(0); }
}
@keyframes blink { 50% { opacity: .2; } }
@keyframes bannerPop { from { transform: translate(-50%, -40%) scale(.8); opacity: 0; } }
@keyframes bannerAway { to { opacity: 0; visibility: hidden; } }

@media (max-width: 740px) {
  dialog#modal.paper-open,
  #modal.paper-open {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    margin: 0 !important;
    border-radius: 0 !important;
  }
  .paper-desk { padding: 46px 8px 8px; }
  .actor-pop { width: 96px; }
  .cut-house { width: 120px; }
  .cut-prop { display: none; }
  .diorama > .paper-dialogue { width: 68%; }
  .doc-slot { width: 120px; }
  .paper-dialogue { grid-template-columns: 64px 1fr 16px; min-height: 96px; margin: 8px 4px 0; }
  .diorama > .paper-dialogue { min-height: 0; margin: 0; grid-template-columns: 1fr 16px; }
  .paper-portrait { height: 64px; }
  .paper-text { font-size: 16px; }
  .paper-tray, .paper-slip { margin-left: 8px; margin-right: 8px; }
  .paper-stamp { width: 58px; height: 58px; }
  .paper-stage .story-choices > button,
  .paper-stage .authored-questions > button,
  .paper-stage .contract-lines > button {
    min-height: 48px;
    font-size: 15px;
    padding: 12px 14px;
  }
}
.diorama .live-scene {
  position: absolute;
  z-index: 4;
  left: auto;
  right: 10px;
  bottom: auto;
  top: 88px;
  max-width: min(210px, 32%);
  font-size: 12px;
  margin: 0;
  padding: 8px 10px;
  background: #fffdf8ee;
  border: 3px solid #3a2a1a;
  border-radius: 12px;
  color: #3a2a1a;
  box-shadow: 3px 3px 0 #f0d56a;
}
.diorama .live-scene p, .diorama .live-scene small { color: #3a2a1a; margin: 0; }
.paper-stage .inquiry-lens,
.paper-stage .professional-followup,
.paper-stage .request-scene,
.paper-stage .shown-exhibit {
  background: #fffdf8;
  border: 3px solid #3a2a1a;
  border-radius: 14px;
  color: #3a2a1a;
  box-shadow: 3px 3px 0 #f0d56a;
  padding: 10px 12px;
}
.paper-stage .professional-followup h3,
.paper-stage .professional-followup p,
.paper-stage .inquiry-lens p,
.paper-stage .request-scene p { color: #3a2a1a; }
.paper-stage .professional-followup textarea { min-height: 64px; }
.paper-book > .paper-overlay:has(.professional-followup) { max-height: 52%; bottom: 16px; right: 34%; }
.paper-tray:has(.professional-followup) { max-height: 250px; }
body.case-theater {
  background: #1b2428;
}
body.case-theater > :not(dialog) {
  visibility: hidden;
}
.paper-stage.paper-play .case-brief {
  background: #fff8e6;
  border: 3px solid #3a2a1a;
  border-radius: 14px;
  color: #3a2a1a;
}
.paper-stage.paper-play .case-brief p { margin: 0 0 6px; font-size: 15px; line-height: 1.6; font-weight: 700; }
.paper-stage.paper-play .case-brief p:last-child { margin: 0; }
.paper-stage.paper-play .case-brief b { color: #8a3d32; }
.paper-stage.paper-play .case-brief .case-aim { padding: 6px 10px; background: #fdeec2; border-radius: 10px; }
.paper-stage.paper-play .case-brief .case-person { padding: 6px 10px; background: #e8f0f6; border-radius: 10px; }
.paper-stage.paper-play .case-goals { margin: 0 0 6px; font-size: 14px; line-height: 1.6; font-weight: 600; }
.paper-stage.paper-play .case-goals ol { margin: 2px 0 0; padding-left: 22px; }
.paper-stage.paper-play .actor-pop {
  right: 16%;
  bottom: 2%;
  width: min(128px, 18%);
  max-height: 92%;
}
.paper-stage.paper-play .paper-actor svg { max-height: 220px; }
.paper-stage.paper-play .stage-clue {
  left: 4%;
  bottom: 8%;
  z-index: 4;
}
.paper-stage.paper-play .diorama .live-scene {
  left: 12px;
  right: auto;
  top: 8px;
  max-width: min(340px, 52%);
  overflow: visible;
}
.paper-stage.paper-play .diorama .live-scene p {
  white-space: normal;
  overflow: visible;
}
.paper-stage.paper-play .paper-book > .paper-dialogue {
  position: relative;
  left: auto;
  top: auto;
  right: auto;
  width: auto;
  flex: 0 0 auto;
  margin: 8px 14px 0;
  max-height: none;
  overflow: visible;
  display: grid;
  grid-template-columns: 1fr 22px;
  align-items: end;
}
.paper-stage.paper-play .paper-book > .paper-dialogue::after { display: none; }
.paper-stage.paper-play .paper-book > .paper-dialogue .paper-portrait { display: none; }
.paper-stage.paper-play .paper-book > .paper-dialogue .paper-name {
  position: static;
  display: inline-block;
  margin: 0 0 6px;
  top: auto;
  left: auto;
}
.paper-stage.paper-play .paper-book > .paper-dialogue .paper-text {
  min-height: 0;
  font-size: 18px;
  line-height: 1.55;
}
.paper-stage.paper-play .paper-book > .paper-overlay,
.paper-stage.paper-play .paper-book > .paper-overlay:has(.story-choices),
.paper-stage.paper-play .paper-book > .paper-overlay:has(.authored-questions),
.paper-stage.paper-play .paper-book > .paper-overlay:has(.contract-lines),
.paper-stage.paper-play .paper-book > .paper-overlay:has(.professional-followup) {
  position: relative;
  left: auto;
  right: auto;
  top: auto;
  bottom: auto;
  flex: 0 0 auto;
  width: auto;
  max-height: none;
  overflow: visible;
  margin: 8px 14px 12px;
}
.paper-stage.paper-play.paper-worksheet .paper-book > .paper-overlay {
  flex: 0 1 auto;
  max-height: 42%;
  overflow: auto;
}
.paper-stage.paper-play.paper-worksheet .diorama > .paper-dialogue,
.paper-stage.paper-play .diorama > .paper-dialogue {
  width: auto;
  top: auto;
}
/* Two-page case window: left = stage + short mission, right = dialogue + choices.
   Stack only when the theater window itself is narrow (container), not just the browser chrome. */
.paper-stage.paper-play .paper-desk {
  padding: 18px 20px 24px;
  container-type: inline-size;
  container-name: paper-play;
}
.paper-stage.paper-play .paper-book {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(280px, 0.92fr);
  grid-template-rows: 58px minmax(240px, 1fr) auto auto;
  grid-template-areas:
    "cover cover"
    "stage side"
    "brief side"
    "tools tools";
  margin: 0;
  height: min(820px, calc(100dvh - 36px));
  max-height: calc(100dvh - 24px);
  min-height: 0;
}
.paper-stage.paper-play .paper-book > .case-brief {
  grid-area: brief;
  min-height: 0;
  max-height: 168px;
  overflow-y: auto;
  margin: 0 10px 10px 14px;
  padding: 8px 12px;
}
.paper-stage.paper-play .paper-book > .case-brief.case-mission details { display: none; }
.paper-stage.paper-play .paper-book > .case-brief p { font-size: 13.5px; line-height: 1.55; font-weight: 600; }
.paper-stage.paper-play.bapa-theater .paper-book > .case-brief {
  max-height: 236px;
}
.paper-stage.paper-play.bapa-theater .bapa-meters {
  margin-bottom: 6px;
}
.paper-stage.paper-play.bapa-theater .bapa-meters b { font-size: 15px; }
.paper-stage.paper-play.bapa-theater .paper-book > .case-brief .case-aim,
.paper-stage.paper-play.bapa-theater .paper-book > .case-brief .case-next,
.paper-stage.paper-play.bapa-theater .paper-book > .case-brief .case-person {
  padding: 5px 8px;
  margin-bottom: 4px;
}
.paper-stage.paper-play .book-cover { position: relative; grid-area: cover; }
.paper-stage.paper-play .diorama {
  grid-area: stage;
  position: relative;
  inset: auto;
  min-height: 0;
  height: auto;
  margin: 10px 10px 8px 14px;
  min-height: 200px;
  border-radius: 18px;
  overflow: hidden;
}
.paper-stage.paper-play .paper-stamp {
  top: 10px;
  right: 10px;
  width: 64px;
  height: 64px;
  z-index: 6;
}
.paper-stage.paper-play .paper-stamp b { font-size: 18px; }
.paper-stage.paper-play .travel-banner { top: 50%; z-index: 7; }
.paper-stage.paper-play .diorama .live-scene {
  top: 10px;
  left: 10px;
  right: 84px;
  max-width: none;
  max-height: 30%;
  overflow: auto;
  font-size: 13px;
}
.paper-stage.paper-play .stage-clue {
  left: 12px;
  bottom: 12px;
  height: min(168px, 46%);
  width: auto;
  aspect-ratio: 132 / 168;
}
.paper-stage.paper-play .stage-clue-front b { font-size: clamp(15px, 2vw, 22px); }
.paper-stage.paper-play .doc-slot { left: 12px; bottom: 12px; width: 170px; }
.paper-stage.paper-play .doc-slot.is-reading { width: calc(100% - 24px); }
.paper-stage.paper-play .actor-pop {
  right: 8%;
  bottom: 3%;
  height: 54%;
  width: auto;
  aspect-ratio: 140 / 212;
  max-height: none;
}
.paper-stage.paper-play .paper-actor svg { width: 100%; height: auto; max-height: none; }
.actor-pop[hidden] { display: none !important; }
.paper-stage.is-resume .paper-book,
.paper-stage.is-resume .layer,
.paper-stage.is-resume .cut,
.paper-stage.is-resume .ground-card,
.paper-stage.is-resume .doc-slot,
.paper-stage.is-resume .actor-pop:not(.is-entering) { animation: none; }
.paper-stage.paper-play.has-guest .actor-host { right: auto; left: 34%; height: 48%; }
.paper-stage.paper-play.has-guest .actor-guest { right: 7%; height: 56%; }
.paper-stage.paper-play.has-guest .actor-pop { transition: filter .25s ease, opacity .25s ease; }
.paper-stage.paper-play.has-guest .actor-pop.is-listening { filter: saturate(.7) brightness(.92); opacity: .88; }
.stage-curtain {
  position: absolute;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  overflow: hidden;
}
.stage-curtain i {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 51%;
  background:
    linear-gradient(180deg, #00000000 70%, #00000033),
    repeating-linear-gradient(90deg, var(--cover, #9c2430) 0 22px, var(--cover-deep, #6e141c) 22px 34px);
  border-bottom: 8px solid #e8c56a;
  transform: translateX(-102%);
}
.stage-curtain i + i { left: auto; right: 0; transform: translateX(102%); }
.curtain-card {
  position: absolute;
  left: 50%;
  top: 46%;
  display: grid;
  gap: 2px;
  padding: 10px 18px;
  border: 3px solid #3a2a1a;
  border-radius: 12px;
  background: #fff8e8;
  box-shadow: 4px 4px 0 #f0d56a;
  color: #3a2a1a;
  font-weight: 900;
  text-align: center;
  white-space: nowrap;
  transform: translate(-50%, -50%) rotate(-2deg);
  opacity: 0;
}
.curtain-card small { font-size: 11px; font-weight: 800; color: #8a5a3a; }
.paper-stage.is-leaving .stage-curtain i { transform: none; transition: transform .4s cubic-bezier(.55, 0, .75, .4); }
.paper-stage.is-moved .stage-curtain i { animation: curtainOpen .7s .55s cubic-bezier(.2, .8, .25, 1) both; }
.paper-stage.is-moved .curtain-card { animation: curtainCard 1.15s ease both; }
.paper-stage.is-moved .paper-side,
.paper-stage.is-moved .paper-book > .case-brief { animation: sideIn .45s .25s ease both; }
@keyframes curtainOpen { from { transform: none; } }
@keyframes curtainCard {
  0%, 55% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -60%) rotate(-2deg); }
}
@keyframes sideIn { from { opacity: 0; transform: translateY(8px); } }
.actor-tag {
  position: absolute;
  left: 50%;
  bottom: 18%;
  transform: translateX(-50%) rotate(-2deg);
  white-space: nowrap;
  padding: 2px 8px;
  border: 2px solid #3a2a1a;
  border-radius: 8px;
  background: #fff8e8;
  color: #3a2a1a;
  font-size: 11px;
  font-weight: 800;
  box-shadow: 2px 2px 0 #f0d56a;
}
.paper-stage.paper-play .paper-stand { width: 70%; }
.paper-stage.paper-play.paper-worksheet .actor-pop { bottom: 4%; }
.paper-stage.paper-play.paper-worksheet.has-guest .actor-host { left: 4%; height: 30%; }
.paper-stage.paper-play.paper-worksheet.has-guest .actor-guest { right: 4%; height: 33%; }
.paper-stage.paper-play.paper-worksheet .cut-tree { bottom: 20%; }
.paper-stage.paper-play .paper-side {
  grid-area: side;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 10px 14px 10px 6px;
  padding: 2px 6px 10px 2px;
  scrollbar-gutter: stable;
}
.paper-stage.paper-play .paper-side > .case-brief {
  display: none;
}
.paper-stage.paper-play .paper-side > .paper-dialogue {
  position: relative;
  inset: auto;
  width: auto;
  flex: 0 0 auto;
  margin: 0;
  min-height: 110px;
  max-height: none;
  display: grid;
  grid-template-columns: 1fr 22px;
  align-items: end;
  order: -1;
}
.paper-stage.paper-play .paper-side > .paper-dialogue::after,
.paper-stage.paper-play .paper-side > .paper-dialogue .paper-portrait { display: none; }
.paper-stage.paper-play .paper-side > .paper-dialogue .paper-name { left: 14px; }
.paper-stage.paper-play .paper-side > .paper-dialogue .paper-text { font-size: 17px; line-height: 1.6; min-height: 0; }
.paper-stage.paper-play .paper-side > .paper-overlay,
.paper-stage.paper-play.paper-worksheet .paper-side > .paper-overlay {
  position: relative;
  inset: auto;
  width: auto;
  flex: 0 0 auto;
  max-height: none;
  overflow: visible;
  margin: 0;
  pointer-events: auto;
}
.paper-stage.paper-play .paper-side .paper-tray {
  max-height: none;
  overflow: visible;
  padding: 10px;
  background: #fffdf8;
  border: 3px solid #3a2a1a;
  border-radius: 16px;
  box-shadow: 4px 4px 0 #f0d56a;
  flex: 1 1 auto;
}
.paper-stage.paper-play .paper-side .paper-tray.is-waiting { display: none; }
.paper-stage.paper-play .paper-side .paper-slip.is-open { max-height: none; overflow: visible; }
.paper-stage.paper-play .paper-side .professional-followup { max-height: none; overflow: visible; }
.paper-stage.paper-play .paper-side > .paper-dialogue .paper-text {
  font-size: 16.5px;
  line-height: 1.55;
}
.paper-stage.paper-play .paper-book > .paper-tools {
  grid-area: tools;
  position: relative;
  inset: auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 10px 56px 12px 14px;
  border-top: 3px dashed #d7c4a0;
  background: #f6ecd6;
}
@container paper-play (max-width: 760px) {
  .paper-book {
    grid-template-columns: minmax(0, 1fr);
    /* Narrow theater: stage → short mission → dialogue/choices → tools */
    grid-template-rows: 58px min(38vw, 200px) max-content max-content auto;
    grid-template-areas: "cover" "stage" "brief" "side" "tools";
    height: auto;
    max-height: none;
    min-height: 100%;
    background: #fbf6e8;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .book-cover { position: sticky; top: 0; z-index: 6; }
  .paper-book > .case-brief {
    margin: 8px 10px 0;
    max-height: none;
    overflow: visible;
  }
  .diorama { margin: 10px 10px 0; min-height: 0; }
  .actor-pop { right: 18%; height: 50%; }
  .has-guest .actor-host { left: 42%; height: 46%; }
  .has-guest .actor-guest { right: 16%; height: 50%; }
  .paper-side { margin: 10px; overflow: visible; }
  .stage-clue { width: 104px; height: 132px; }
  .paper-book > .paper-tools {
    position: sticky;
    bottom: 0;
    z-index: 5;
    padding: 10px 12px max(12px, env(safe-area-inset-bottom, 0px));
  }
  .paper-tools button {
    min-height: 44px;
    padding: 10px 12px;
    font-size: 13px;
  }
}
@media (max-width: 760px) {
  dialog#modal.paper-open,
  #modal.paper-open {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    margin: 0 !important;
    border-radius: 0 !important;
  }
  .paper-stage.paper-play .paper-desk {
    padding: max(10px, env(safe-area-inset-top, 0px)) 10px max(18px, env(safe-area-inset-bottom, 0px));
  }
  .modal-top button {
    min-width: 44px;
    min-height: 44px;
  }
  /* Fullscreen on phone/tablet: hide desktop window chrome. */
  dialog.paper-open .modal-top button[aria-label="收合視窗"],
  dialog.paper-open .modal-top button[aria-label="展開視窗"],
  dialog.paper-open .modal-top button[aria-label="回復大小"],
  dialog.paper-open .paper-resize {
    display: none !important;
  }
}
@media (prefers-reduced-motion: reduce) {
  .stage-curtain { display: none; }
  .paper-book, .layer, .actor-pop, .doc-slot, .paper-actor, .paper-next, .examine, .travel-banner, .page-leaf, .stage-clue-front, .stage-clue-back, .cut, .ground-card, .paper-bits b, .paper-dialogue, .story-choices > button, .authored-questions > button { animation: none !important; transition: none !important; }
}

/* plain-language glossary under dialogue and choices */
.paper-terms { display: flex; flex-wrap: wrap; gap: 4px 6px; margin: 8px 0 0; }
.paper-terms[hidden] { display: none; }
.paper-terms span { padding: 3px 8px; border-radius: 8px; background: #fff3cf; border: 1px dashed #c9a24a; color: #5a4630; font-size: 12.5px; font-weight: 600; line-height: 1.5; }
.paper-terms b { margin-right: 4px; color: #8a4a1a; }
.paper-terms b::after { content: '＝'; font-weight: 600; }
.story-choices button .paper-choice-terms, .authored-questions button .paper-choice-terms { display: block; margin-top: 4px; font-size: 12px; font-weight: 600; line-height: 1.5; color: #7a6a50; }

/* layered case brief */
.paper-stage.paper-play .case-brief .case-next { padding: 6px 10px; background: #e9f4e4; border-radius: 10px; }
.paper-stage.paper-play .case-brief details { margin: 0 0 6px; border: 2px solid #e2cfa6; border-radius: 10px; background: #fffdf6; }
.paper-stage.paper-play .case-brief details > summary { cursor: pointer; padding: 6px 10px; font-size: 14px; font-weight: 800; color: #6a3a22; list-style: none; }
.paper-stage.paper-play .case-brief details > summary::-webkit-details-marker { display: none; }
.paper-stage.paper-play .case-brief details > summary::before { content: '▸ '; }
.paper-stage.paper-play .case-brief details[open] > summary::before { content: '▾ '; }
.paper-stage.paper-play .case-brief details > summary:focus-visible { outline: 3px solid #2f6f8f; outline-offset: 2px; }
.paper-stage.paper-play .case-brief details > :not(summary) { margin-left: 10px; margin-right: 10px; }
.paper-stage.paper-play .case-brief details > :last-child { margin-bottom: 8px; }
.paper-stage.paper-play .case-brief ul, .paper-stage.paper-play .case-brief ol { margin: 2px 0 6px; padding-left: 20px; font-size: 13.5px; line-height: 1.6; font-weight: 600; }
.paper-stage.paper-play .case-brief li em { font-style: normal; font-weight: 800; color: #2f6f8f; margin-right: 6px; }
.paper-stage.paper-play .case-brief li small { display: block; color: #7a6a50; font-weight: 600; }
.case-flow { display: block; width: 100%; max-height: 210px; margin: 4px 0 6px; font-family: inherit; }
.paper-stage.paper-play .case-tx { display: grid; grid-template-columns: max-content 1fr; gap: 2px 10px; margin: 4px 10px 8px; font-size: 13.5px; line-height: 1.55; }
.paper-stage.paper-play .case-tx dt { font-weight: 800; color: #8a3d32; }
.paper-stage.paper-play .case-tx dd { margin: 0; font-weight: 600; }
.paper-stage.paper-play .fact-head { display: block; margin-top: 6px; font-size: 13px; }
.paper-stage.paper-play .case-brief .fact-head.is-fact { color: #2f7a52; }
.paper-stage.paper-play .case-brief .fact-head.is-claim { color: #b06a1a; }
.paper-stage.paper-play .case-brief .fact-head.is-open { color: #2f6f8f; }
.paper-stage.paper-play .case-brief .fact-head.is-mine { color: #6a4a9a; }
.paper-stage.paper-play .case-brief .fact-empty { font-size: 13px; color: #7a6a50; font-weight: 600; }
.paper-stage.paper-play .case-evidence details { margin: 4px 0; border-width: 1px; }
.paper-stage.paper-play .case-evidence details > summary { font-size: 13px; font-weight: 700; }
.paper-stage.paper-play .case-evidence details p { font-size: 13px; font-weight: 500; }
.paper-stage.paper-play .case-track ol { list-style: none; padding-left: 4px; }
.paper-stage.paper-play .case-track li { position: relative; padding-left: 22px; }
.paper-stage.paper-play .case-track li::before { content: '○'; position: absolute; left: 0; color: #a99b80; }
.paper-stage.paper-play .case-track li.is-done::before { content: '✓'; color: #2f7a52; font-weight: 900; }
.paper-stage.paper-play .case-track li.is-now::before { content: '▶'; color: #c4553f; }
.paper-stage.paper-play .case-track li.is-now b { color: #c4553f; }
.paper-stage.paper-play .case-track li small { display: inline; margin-left: 6px; }
.paper-stage.paper-play .case-issues { display: flex; flex-wrap: wrap; gap: 4px; }
.paper-stage.paper-play .case-issues span { padding: 1px 8px; border-radius: 999px; background: #f3e6c4; font-size: 12px; font-weight: 700; }
.paper-stage.paper-play .ref-head { display: block; margin-top: 4px; font-size: 13px; }

/* case briefing sheet */
.paper-stage .paper-book { position: relative; }
.paper-casefile { position: absolute; inset: 0; z-index: 40; display: flex; align-items: flex-start; justify-content: center; padding: 14px; background: rgba(40, 28, 18, .45); border-radius: inherit; }
.paper-casefile[hidden] { display: none; }
.casefile-sheet { position: sticky; top: 14px; display: flex; flex-direction: column; width: min(760px, 100%); max-height: min(100%, calc(100dvh - 170px)); border: 3px solid #3a2a1a; border-radius: 16px; background: #fffaf0; box-shadow: 6px 6px 0 #f0d56a; overflow: hidden; animation: sideIn .3s ease both; }
.casefile-sheet header { position: relative; padding: 12px 52px 8px 16px; border-bottom: 2px dashed #d7c4a0; }
.casefile-sheet header small { font-size: 12px; font-weight: 800; color: #8a5a3a; letter-spacing: .04em; }
.casefile-sheet header h3 { margin: 2px 0; font-size: 20px; color: #3a2a1a; }
.casefile-sheet header p { margin: 0; font-size: 14px; font-weight: 700; color: #6a3a22; }
.casefile-close { position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; border: 2px solid #3a2a1a; border-radius: 50%; background: #fff; font-weight: 900; cursor: pointer; }
.casefile-body { overflow: auto; padding: 10px 14px; }
.paper-stage.paper-play .casefile-body.case-brief, .paper-stage.paper-play .casefile-body { max-height: none; }
.casefile-sheet footer { padding: 10px 14px; border-top: 2px dashed #d7c4a0; text-align: right; }
.casefile-go { padding: 9px 18px; border: 3px solid #3a2a1a; border-radius: 12px; background: #3f8f6b; color: #fff; font-weight: 800; font-size: 15px; cursor: pointer; box-shadow: 3px 3px 0 #f0d56a; }
.casefile-go:focus-visible, .casefile-close:focus-visible { outline: 3px solid #2f6f8f; outline-offset: 2px; }
.paper-stage.paper-play .casefile-sheet .case-brief { flex: 1 1 auto; max-height: none; margin: 0; border: 0; border-radius: 0; background: transparent; overflow: auto; }

.casefile-sheet header, .casefile-sheet footer { flex: 0 0 auto; }
@media (max-width: 640px) { .paper-casefile { padding: 48px 4px 6px; } .casefile-sheet { top: 48px; max-height: calc(100dvh - 120px); } }
@media (max-width: 520px) { .paper-stage.paper-play .book-cover { justify-content: flex-start; padding: 8px 214px 8px 12px; } .paper-stage.paper-play .book-cover .foil { min-width: 0; font-size: 16px; letter-spacing: .04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .paper-stage.paper-play .book-cover small { display: none; } }
.issue-lead { margin: 4px 0 10px; font-size: 13px; color: #6b5640; }
.issue-index { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; }
.issue-index li { display: grid; grid-template-columns: minmax(7.5em, 11em) 1fr; gap: 8px; padding: 6px 8px; border: 2px solid #e4d3b2; border-radius: 10px; background: #fffaf0; }
.issue-index b { color: #8a2f1f; font-size: 14px; }
.issue-index span { display: flex; flex-wrap: wrap; gap: 4px; }
.issue-index em { font-style: normal; font-size: 13px; padding: 1px 8px; border-radius: 999px; background: #f1e6cf; }
.issue-index em.is-here { background: #ffd98a; font-weight: 800; }
.issue-refs { margin: 4px 0 10px; padding-left: 1.2em; font-size: 13px; }
@media (max-width: 520px) { .issue-index li { grid-template-columns: 1fr; } }
.case-brief ul.issue-index { padding-left: 0; margin-left: 0; }
