/* Historia Rota · working surface, dialogs and media.
   One cascade: base → wide workspace → classroom → small/short screens. */
html {
  scroll-behavior: auto;
  scroll-padding-top: 12px;
}
body {
  scrollbar-gutter: stable;
}
.app-header {
  position: relative;
  z-index: 50;
  background: #0b1424;
  border-bottom: 1px solid #24334d;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1900px;
  margin: auto;
  padding: 6px 20px;
  gap: 16px;
}
.brand-button {
  display: flex;
  align-items: center;
  background: none;
  padding: 0;
  min-height: 44px;
}
.brand-logo-img {
  width: 44px;
  height: 44px;
  object-fit: contain;
}
.header-controls {
  display: flex;
  align-items: center;
}
.utility-menu {
  position: relative;
}
.utility-toggle {
  min-width: 48px;
  min-height: 44px;
  padding: 4px 16px;
  border: 1px solid #445577;
  border-radius: 12px;
  background: #17243a;
  font-size: 24px;
}
.utility-panel {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: min(340px, calc(100vw - 24px));
  max-height: calc(100dvh - 80px);
  overflow: auto;
  padding: 10px;
  background: #111b2e;
  border: 1px solid #445577;
  border-radius: 16px;
  box-shadow: 0 14px 36px #0005;
}
.utility-menu.open .utility-panel {
  display: grid;
  gap: 6px;
}
.utility-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 10px 12px;
  background: #1a2940;
  border: 1px solid #344665;
  border-radius: 9px;
  font-size: 16px;
  text-align: left;
}
.utility-btn[aria-pressed="true"] {
  border-color: #ad99ff;
}
.board-only-control {
  display: none;
}
.board .board-only-control {
  display: flex;
}
body[data-view="game"] #breadcrumbs,
body[data-view="game"] .app-footer {
  display: none;
}
.game-wrap {
  --play-ui: 17px;
  --play-read: 23px;
  --play-gap: 16px;
  --scene-max-h: 62vh;
  width: min(1800px, calc(100% - 32px));
  max-width: none;
  margin: 12px auto 28px;
  font-size: var(--play-ui);
  line-height: 1.45;
}
.game-wrap *,
.modal * {
  min-width: 0;
}
.game-wrap .btn,
.modal .btn {
  min-height: 48px;
  padding: 11px 16px;
  border-radius: 12px;
  font-size: inherit;
  font-weight: 750;
  line-height: 1.3;
  letter-spacing: normal;
  white-space: normal;
}
.game-wrap .btn.primary,
.modal .btn.primary {
  background: #7754ee;
  color: #fff;
  border: 1px solid #a38cf8;
}
.game-wrap .btn.light,
.modal .btn.light {
  background: #1b2a40;
  color: #eef4ff;
  border: 1px solid #435573;
}
.game-wrap .btn:disabled,
.modal button:disabled {
  opacity: 0.48;
  cursor: default;
}
.game-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 10px;
}
.game-top > span {
  color: #b7c7db;
  font-size: 14px;
  text-align: right;
}
.game-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 0 0 12px;
}
.case-headline {
  flex: 1;
}
.game-wrap .eyebrow {
  margin: 0 0 5px;
  font-size: 13px;
  letter-spacing: 0.07em;
  color: #98ebe0;
}
.game-wrap .game-head h1 {
  margin: 0;
  font-size: clamp(26px, 2.1vw, 42px);
  line-height: 1.16;
  letter-spacing: -0.025em;
}
.game-wrap .display-title::after {
  display: none;
}
.rigorbox {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 155px;
  flex-shrink: 0;
  border: 1px solid #405773;
  border-radius: 12px;
  background: #142335;
  padding: 9px 12px;
}
.rigor-icon {
  color: #92e7d6;
  font-size: 28px;
}
.rigor-copy {
  flex: 1;
}
.rigor-top {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}
.rigor-top small {
  font-size: 11px;
  line-height: 1.25;
}
.rigor-top strong {
  font-size: 23px;
}
.rigor-meter {
  height: 5px;
  margin: 5px 0;
  background: #334660;
  border-radius: 8px;
  overflow: hidden;
}
.rigor-meter span {
  display: block;
  height: 100%;
  background: #91dabb;
  transition: width 0.2s;
}
.rigor-status {
  font-size: 11px;
  letter-spacing: 0.03em;
  color: #bedfce;
}
.rigorbox.low .rigor-meter span {
  background: #e3c07d;
}
.rigorbox.critical .rigor-meter span {
  background: #df8d82;
}
.board-hide-rigor .rigorbox {
  display: none;
}
.archive-progress-strip {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 12px;
  font-size: 12px;
  color: #b7c7db;
}
.archive-progress-copy {
  display: flex;
  gap: 8px;
}
.archive-progress-copy strong {
  color: #a997ff;
}
.archive-progress-strip > small {
  font-size: 12px;
}
.progressbar {
  flex: 1;
  height: 4px;
  border-radius: 6px;
  overflow: hidden;
  background: #283b55;
}
.progressbar > span {
  display: block;
  height: 100%;
  background: #a997ff;
}
.mission-card {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid #344763;
  border-radius: 20px;
  background: #101d30;
  overflow: visible;
}
.mission-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 16px 18px 0;
}
.mission-top h2 {
  margin: 0;
  font-size: 20px;
}
.phase-stack {
  display: grid;
  gap: 4px;
  text-align: right;
  font-size: 13px;
}
.phase-pill {
  color: #c3b4ff;
  font-weight: 800;
}
.error-pill {
  color: #bfcbdd;
}
.mission-instruction {
  padding: 0 18px;
  margin: 10px 0 16px;
  font-size: 1em;
  line-height: 1.45;
  color: #e0e8f5;
}
.workspace {
  display: grid;
  gap: var(--play-gap);
  padding: 0 16px 16px;
  min-height: 0;
}
.document {
  padding: 16px;
  border-radius: 14px;
  background: #0a1424;
  color: #eef4ff;
  min-height: 0;
}
.doc-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 14px;
}
.doc-label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #bbcce2;
}
.game-wrap .text-expand-btn {
  font-size: 13px;
  min-height: 44px;
  padding: 8px 12px;
}
.doc-text {
  margin: 0;
  padding: 22px;
  border: 1px solid #bdc8d8;
  border-radius: 12px;
  background: #f5f8fd;
  color: #1d2939;
  font-size: var(--play-read);
  line-height: 1.8;
  text-align: left;
  overflow-wrap: break-word;
}
.seg {
  padding: 3px 0;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
.seg.selectable {
  cursor: pointer;
  border-bottom: 2px solid #929daf;
  border-radius: 2px;
}
.seg.selectable:hover {
  background: #e4def4;
}
.seg.selected {
  background: #dccfff;
  border-bottom: 3px solid #7554aa;
}
.seg.repaired {
  background: #dbeedc;
  border-bottom: 2px solid #397047;
}
.seg.disabled {
  cursor: default;
}
.seg:focus-visible {
  outline-offset: 2px;
}
[data-text-level="guided"] .doc-text {
  font-size: calc(var(--play-read) + 2px);
  line-height: 1.85;
}
.reading-sentence {
  display: block;
  margin-bottom: 0.7em;
}
.reading-sentence:last-child {
  margin-bottom: 0;
}
[data-text-level="dense"] .doc-text {
  font-size: var(--play-read);
  line-height: 1.55;
}
.dossier-section {
  scroll-margin-top: 12px;
}
.dossier-section + .dossier-section {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid #344763;
}
.section-heading {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}
.section-heading > span {
  font-size: 26px;
  color: #a99bec;
}
.section-heading h4 {
  margin: 0 0 6px;
  font-size: 22px;
}
.section-heading p {
  margin: 0;
  color: #b7c7db;
}
.dossier-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.game-wrap .dossier-nav .btn {
  font-size: 14px;
  min-height: 44px;
  padding: 8px 10px;
}
.visual-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 8px;
}
.visual-head b {
  font-size: 1em;
}
.visual-head > span {
  color: #b7c7db;
  font-size: 0.85em;
}
.scene-note,
.timeline-help,
.museum-note {
  font-size: 0.94em;
  line-height: 1.45;
  margin: 8px 0 12px;
  color: #d2deed;
}
.source-note {
  display: block;
  font-size: 0.88em;
  color: #aabbce;
  margin-top: 6px;
}
.visual-scene {
  position: relative;
  width: min(100%, calc(var(--scene-max-h) * var(--scene-ratio, 1.7778)));
  margin: auto;
  border-radius: 10px;
  overflow: hidden;
  isolation: isolate;
  background: #152239;
  line-height: 0;
}
.visual-scene > img {
  display: block;
  width: 100%;
  height: auto;
}
.hotspot {
  position: absolute;
  background: transparent;
  border: 2px solid transparent;
  border-radius: 6px;
  padding: 0;
  min-width: 0;
  min-height: 0;
  touch-action: manipulation;
}
.hotspot:hover,
.hotspot:focus-visible {
  border-color: #f7eaca;
  background: #ffffff15;
}
.hotspot.selected {
  border: 3px solid #d5bfff;
  background: #b789eb40;
}
.hotspot.repaired {
  border-color: #8be1ad;
}
.hotspot.detected {
  border-color: #f6cd6a;
}
.scene-zoom-btn {
  position: absolute;
  right: 8px;
  bottom: 8px;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid #dbd2ff;
  border-radius: 9px;
  color: #fff;
  background: #17213bf2;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
  z-index: 2;
}
.scene-choice-label {
  margin: 12px 0 6px;
  color: #bed1e5;
  font-size: 0.88em;
}
.scene-inspection {
  margin: 8px 0 0;
  padding: 10px 12px;
  border-left: 3px solid #9480df;
  background: #17273b;
  font-size: 0.95em;
  line-height: 1.5;
}
.timeline-track {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  counter-reset: none;
}
.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 5px 10px;
  padding: 16px;
  border: 1px solid #71819b;
  border-radius: 12px;
  background: #1a2b43;
  color: #f1f6ff;
  text-align: left;
  font-size: 1em;
  line-height: 1.5;
  min-height: 100px;
}
.tl-number {
  grid-row: 1/3;
  color: #b7a4ff;
  font-weight: 800;
}
.tl-era {
  font-weight: 750;
}
.tl-note {
  color: #bfcee1;
  font-size: 0.88em;
}
.museum-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.museum-card {
  display: flex;
  flex-direction: column;
  border: 1px solid #61738f;
  border-radius: 12px;
  overflow: hidden;
  background: #192a40;
  color: #f0f5ff;
  text-align: left;
  padding: 0;
  font-size: 1em;
  line-height: 1.45;
}
.museum-object {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  background: #e6e3df;
}
.museum-object img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.museum-copy {
  display: flex;
  flex-direction: column;
  padding: 14px;
  gap: 8px;
}
.museum-copy small {
  color: #bfaeff;
  font-size: 0.8em;
}
.museum-copy b {
  font-size: 1.1em;
}
.object-observation {
  font-size: 0.9em;
  color: #bccce0;
}
.museum-label {
  display: block;
  padding-top: 10px;
  border-top: 1px solid #4e617c;
}
.timeline-item.selected,
.museum-card.selected {
  background: #30294c;
  border: 2px solid #bca6ff;
}
.timeline-item.repaired,
.museum-card.repaired {
  border-color: #87d3aa;
}
.timeline-item.disabled,
.museum-card.disabled {
  cursor: default;
}
.evidence-wrap {
  margin-top: 18px;
  font-size: 0.9em;
}
.evidence {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}
.evidence span {
  padding: 10px;
  border: 1px solid #496078;
  border-radius: 8px;
  background: #14293a;
}
.investigation-controls {
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 12px;
}
.investigation-controls > .case-flow {
  order: 0;
}
.investigation-controls > .selection-panel {
  order: 1;
}
.investigation-controls > .mission-actions {
  order: 2;
}
.investigation-controls > .debate-banner {
  order: 3;
}
.investigation-controls > .hint-box {
  order: 4;
}
.investigation-controls > .case-feedback {
  order: 5;
}
.investigation-controls > .case-sources {
  order: 6;
}
.case-flow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 10px 0;
}
.flow-step {
  display: flex;
  gap: 6px;
  align-items: center;
  opacity: 0.55;
  font-size: 12px;
}
.flow-step > span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid #7183a0;
}
.flow-step.active,
.flow-step.done {
  opacity: 1;
  color: #cfc2ff;
}
.flow-step.active > span {
  background: #b9a5ff;
  color: #172038;
}
.flow-line {
  flex: 1;
  height: 1px;
  background: #405474;
}
.selection-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 1px solid #59628c;
  border-radius: 14px;
  background: #18253d;
}
.selection-main > b {
  display: block;
  font-size: 1.08em;
}
.selection-guide {
  color: #becee4;
  margin: 6px 0;
  font-size: 0.85em;
}
.selection-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 0;
  max-height: 180px;
  overflow: auto;
  overscroll-behavior: contain;
}
.selection-chip {
  text-align: left;
  color: #ede7ff;
  background: #302b4d;
  border: 1px solid #8f7dbb;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.9em;
  min-height: 44px;
  line-height: 1.4;
}
.selection-empty {
  font-size: 0.85em;
  color: #b6c4d8;
}
.selection-actions {
  display: grid;
  gap: 8px;
}
.game-wrap #resolveBtn {
  order: -1;
}
.mission-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 0;
}
.game-wrap .mission-actions .btn {
  font-size: 0.88em;
}
#debateBtn,
#cleanBtn,
#nextBtn {
  grid-column: 1/-1;
}
.debate-btn {
  display: none;
}
.board .game-wrap .debate-btn {
  display: inline-flex;
  background: #392a62;
  border: 1px solid #9e87e9;
}
.board .game-wrap .debate-btn[aria-pressed="true"] {
  background: #ebbd5c;
  color: #201b13;
}
.next-btn {
  display: none;
}
.next-btn.show {
  display: inline-flex;
}
.hint-box,
.case-feedback,
.debate-banner {
  display: none;
  margin: 0;
  border: 1px solid #776b4c;
  border-radius: 10px;
  padding: 14px;
  font-size: 0.95em;
  line-height: 1.5;
  background: #302c23;
  color: #f7e8c9;
}
.hint-box.show,
.case-feedback.show,
.debate-banner.show {
  display: block;
}
.hint-level {
  display: grid;
  gap: 5px;
}
.hint-level + .hint-level {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #776b4c;
}
.hint-level strong {
  font-size: 0.85em;
}
.case-feedback.success {
  background: #193b32;
  border-color: #548777;
  color: #dbf5e3;
}
.case-feedback.warn {
  background: #3c2e28;
  border-color: #a7835d;
}
.debate-banner span {
  display: block;
  margin-top: 4px;
}
.case-sources {
  font-size: 0.88em;
  color: #bfcce0;
  border-top: 1px solid #344763;
}
.case-sources summary {
  min-height: 44px;
  padding: 10px 0;
}
.quick-accuse {
  display: flex;
  position: fixed;
  right: 16px;
  left: 16px;
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 45;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  width: fit-content;
  max-width: calc(100% - 32px);
  margin: auto;
  padding: 8px;
  border: 1px solid #a894fa;
  border-radius: 16px;
  background: #14233a;
  box-shadow: 0 6px 20px #0006;
  font-size: 15px;
}
.quick-accuse span {
  padding: 0 6px;
  color: #f6f3ff;
}
.quick-accuse .btn {
  min-height: 44px;
  padding: 8px 12px;
  font-size: 15px;
}
.quick-accuse button:disabled {
  opacity: 0.45;
}
.game-wrap {
  padding-bottom: 88px;
}
/* Stable media geometry: loading is explicit and failure has a retry action. */
.image-frame {
  position: relative;
}
.image-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: #17263d;
  color: #dae4f5;
  font-size: 16px;
  line-height: 1.5;
  text-align: center;
  z-index: 3;
}
.image-frame[data-image-state="ready"] > .image-state {
  display: none;
}
.image-frame:not([data-image-state="ready"]) > .hotspot,
.image-frame:not([data-image-state="ready"]) > .scene-zoom-btn {
  visibility: hidden;
}
.image-frame:not([data-image-state="ready"]) > .zoom-hotspots {
  visibility: hidden;
}
.image-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px;
  margin-bottom: 14px;
  border: 1px solid #b49658;
  border-radius: 10px;
  background: #322d22;
  color: #fff1d2;
  font-size: 16px;
}
.image-notice button {
  background: #e8ca8c;
  color: #211b12;
  padding: 10px 14px;
  min-height: 44px;
  border-radius: 8px;
}
/* Dialogs use three rows; only the middle scrolls. No sticky overlays. */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  padding: 18px;
  background: #030813dd;
  overflow: hidden;
  align-items: center;
  justify-content: center;
  overscroll-behavior: contain;
  font-size: 18px;
  line-height: 1.5;
}
.modal.open {
  display: flex;
}
.modal-open {
  overflow: hidden;
}
.modal-card {
  display: flex;
  flex-direction: column;
  width: min(100%, 960px);
  max-height: calc(100vh - 36px);
  max-height: calc(100dvh - 36px);
  margin: auto;
  border: 1px solid #687792;
  border-radius: 18px;
  overflow: hidden;
  background: #132138;
  color: #f0f5ff;
  box-shadow: 0 18px 70px #0006;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex: 0 0 auto;
  padding: 16px 20px;
  border-bottom: 1px solid #394d6d;
}
.modal-head h2 {
  font-size: clamp(24px, 2.3vw, 34px);
  line-height: 1.2;
  margin: 4px 0 0;
}
.modal .eyebrow {
  font-size: 13px;
  margin: 0 0 4px;
  color: #aeeadf;
}
.close {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border: 1px solid #526887;
  border-radius: 10px;
  background: #21354f;
  font-size: 28px;
  line-height: 1;
}
.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 20px;
  overflow: auto;
  overscroll-behavior: contain;
}
.modal-body > :first-child {
  margin-top: 0;
}
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  flex: 0 0 auto;
  padding: 12px 20px;
  border-top: 1px solid #394d6d;
  background: #14243b;
}
#repairModal .modal-card {
  width: min(1400px, 100%);
}
.modal-rigor {
  color: #c0dfd1;
  font-size: 14px;
}
.repair-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.25fr);
  gap: 24px;
  align-items: start;
}
.repair-context > p {
  color: #b9cbe1;
  margin: 0 0 12px;
  font-size: 0.9em;
}
.repair-phrase {
  font-size: 1.1em;
  padding: 18px;
  border-left: 4px solid #b59cff;
  border-radius: 8px;
  background: #2e2947;
  line-height: 1.5;
}
.repair-question {
  font-size: 1em;
  margin: 0 0 12px;
}
.options {
  display: grid;
  gap: 10px;
}
.option {
  display: block;
  width: 100%;
  padding: 16px 18px;
  border: 1px solid #7c90b0;
  border-radius: 12px;
  background: #213653;
  color: #f3f7ff;
  font-size: 1.08em;
  font-weight: 600;
  line-height: 1.4;
  text-align: left;
  min-height: 58px;
}
.option:not(:disabled):hover {
  background: #30476b;
  border-color: #c4b1ff;
}
.modal .option.correct {
  background: #214638;
  border-color: #96d9b0;
  opacity: 1;
}
.modal .option.wrong {
  background: #522e32;
  border-color: #da8c8d;
  opacity: 0.65;
}
.explain {
  display: none;
  margin: 16px 0 0;
  padding: 18px;
  border-left: 4px solid #98d7ae;
  border-radius: 6px;
  background: #1b3d32;
  color: #e2f6e8;
  font-size: 1em;
  line-height: 1.6;
}
.explain.show {
  display: block;
}
.repair-type {
  font-size: 0.8em;
  color: #badac7;
  margin-top: 12px;
}
#repairContinue {
  display: none;
}
#repairContinue.show {
  display: inline-flex;
}
.repair-footer-hint {
  flex: 1;
  color: #bbcae0;
  font-size: 14px;
  margin: 0;
}
.repair-review {
  margin: 12px 0 0;
  color: #c3d2e6;
  font-size: 0.9em;
}
.repair-review summary {
  padding: 10px 0;
}
.repair-review .option + .option {
  margin-top: 8px;
}
.c28-recall-gate {
  padding: 18px;
  border: 1px solid #7b68ae;
  border-radius: 10px;
  background: #2c2842;
}
.c28-recall-gate strong,
.c28-recall-gate span {
  display: block;
}
.c28-recall-gate strong {
  margin-bottom: 10px;
  font-size: 0.9em;
  color: #c6b4ff;
}
.c28-reveal-options {
  margin-top: 8px;
}
.text-expand-card {
  width: min(1760px, 100%);
  height: calc(100dvh - 36px);
}
.text-expand-subtitle {
  font-size: 14px;
  color: #bdcde1;
  margin: 6px 0 0;
}
.text-expand-paper {
  --play-read: 28px;
  min-height: 0;
  flex: 1 1 auto;
  padding: 20px;
  overflow: auto;
  overscroll-behavior: contain;
  background: #f5f8fd;
  color: #1d2939;
}
.text-expand-paper .doc-text {
  padding: 0;
  border: 0;
  border-radius: 0;
  font-size: var(--expand-font-size, var(--play-read));
  line-height: 1.6;
}
.text-expand-section + .text-expand-section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid #bdc8d8;
}
.text-expand-section h3 {
  font-size: 1.2em;
  margin-top: 0;
}
.text-expand-foot > span {
  flex: 1;
  font-size: 14px;
  color: #b9cbe1;
}
.zoom-card {
  width: min(1780px, 100%);
  height: calc(100dvh - 36px);
}
.zoom-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid #394d6d;
}
.zoom-topbar h2 {
  font-size: 24px;
  margin: 0;
}
.zoom-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.zoom-control,
.zoom-fit {
  height: 48px;
  min-width: 48px;
  padding: 8px 12px;
  border: 1px solid #667d9e;
  border-radius: 9px;
  background: #213650;
  font-size: 18px;
}
.zoom-control {
  font-size: 26px;
}
.zoom-level {
  font-size: 15px;
  min-width: 48px;
  text-align: center;
}
.zoom-tip {
  font-size: 14px;
  margin: 10px 18px;
  color: #c0cfe4;
}
.zoom-viewport {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
  background: #070f1c;
  cursor: grab;
}
.zoom-viewport.dragging {
  cursor: grabbing;
}
.zoom-stage {
  position: absolute;
  top: 50%;
  left: 50%;
  transform-origin: center;
}
.zoom-stage > img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
}
.zoom-hotspots {
  position: absolute;
  inset: 0;
}
.zoom-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 18px;
  border-top: 1px solid #394d6d;
}
.zoom-footer > span {
  flex: 1;
  min-width: 180px;
  font-size: 15px;
  color: #c4d3e7;
}
.notes-card {
  width: min(1100px, 100%);
}
.note-lesson {
  padding: 12px 0 22px;
  border-bottom: 1px solid #3e5272;
}
.note-lesson h3 {
  font-size: 26px;
}
.note-key {
  padding: 16px;
  background: #263047;
  border-left: 3px solid #dfbc83;
}
.note-lesson details,
.sources-box {
  color: #bdcde1;
  font-size: 0.94em;
}
.how-steps {
  padding-left: 1.4em;
}
.how-steps li {
  margin-bottom: 18px;
}
.fail-chapter {
  border-radius: 8px;
  background: #332c43;
  padding: 16px;
}
.toast {
  display: none;
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 150;
  max-width: min(600px, calc(100% - 32px));
  padding: 12px 18px;
  border-radius: 10px;
  background: #e6dcff;
  color: #2d2144;
  box-shadow: 0 4px 20px #0004;
  pointer-events: none;
  font-size: 16px;
  text-align: center;
}
.toast.show {
  display: block;
}
.toast.bad {
  background: #ffded7;
  color: #532d26;
}
.toast.good {
  background: #d7f0e1;
  color: #264032;
}
.modal-open .toast {
  top: 10px;
  bottom: auto;
}
.loading-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 90;
  background: #0b1424ee;
  text-align: center;
}
.loading-dot {
  display: block;
  width: 32px;
  height: 32px;
  border: 3px solid #635886;
  border-top-color: #d2bfff;
  border-radius: 50%;
  margin: auto;
  animation: turn 1s linear infinite;
}
#premiumStamp {
  display: none;
}
/* Wide and sufficiently tall displays: independent investigation and control columns. */
@media (min-width: 1050px) and (min-height: 650px) {
  body[data-view="game"] {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  body[data-view="game"] .app-header {
    flex: 0 0 auto;
  }
  body[data-view="game"] #mainContent {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  #gameScreen.active {
    flex: 1;
    min-height: 0;
    display: flex;
  }
  .game-wrap {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto minmax(0, 1fr);
    gap: 10px 20px;
    margin: 10px auto 14px;
    padding: 0;
    min-height: 0;
    --scene-max-h: calc(100dvh - 365px);
  }
  .game-head {
    grid-column: 1;
    grid-row: 1;
    margin: 0;
  }
  .game-top {
    grid-column: 2;
    grid-row: 1;
    margin: 0;
    flex-direction: column;
    justify-content: center;
    align-items: flex-end;
    gap: 4px;
    max-width: 290px;
  }
  .game-top > span {
    font-size: 12px;
  }
  .archive-progress-strip {
    grid-column: 1/-1;
    grid-row: 2;
    margin: 0;
  }
  .mission-card {
    grid-column: 1/-1;
    grid-row: 3;
    min-height: 0;
  }
  .mission-top {
    flex: 0 0 auto;
    padding-top: 12px;
  }
  .mission-instruction {
    flex: 0 0 auto;
    margin-block: 8px 12px;
  }
  .workspace {
    flex: 1;
    grid-template-columns: minmax(0, 1fr) minmax(310px, 27%);
    overflow: hidden;
  }
  .document,
  .investigation-controls {
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
  }
  .investigation-controls {
    padding-right: 5px;
  }
  .selection-panel {
    position: sticky;
    top: 0;
    z-index: 5;
  }
  .selection-chips {
    max-height: min(120px, 16vh);
  }
  .selection-guide {
    display: none;
  }
  .quick-accuse {
    left: auto;
    width: auto;
    max-width: 490px;
  }
}
/* Classroom typography scales with both axes, with a readable scrolling fallback. */
.board .game-wrap {
  --play-ui: clamp(18px, min(1.55vw, 2.65vh), 28px);
  --play-read: clamp(25px, min(2.05vw, 3.5vh), 42px);
}
.board .game-wrap .btn {
  min-height: 54px;
  padding: 12px 16px;
  font-size: 1em;
}
.board .game-wrap .text-expand-btn,
.board .game-wrap .dossier-nav .btn {
  font-size: 0.83em;
}
.board .game-wrap .mission-top h2 {
  font-size: 1.12em;
}
.board .game-wrap .game-head h1 {
  font-size: clamp(28px, min(2.4vw, 4.7vh), 48px);
}
.board .modal {
  font-size: clamp(21px, min(1.75vw, 3.2vh), 32px);
}
.board .modal .btn {
  min-height: 56px;
  font-size: 1em;
}
.board .modal .option {
  min-height: 64px;
  padding: 16px 18px;
}
.board .modal-head h2 {
  font-size: clamp(26px, min(2.5vw, 4.2vh), 42px);
}
.board .text-expand-paper {
  --play-read: 34px;
}
.board .game-wrap .flow-step {
  font-size: 13px;
}
@media (max-width: 1049px), (max-height: 649px) {
  .mission-top {
    align-items: flex-start;
  }
  .workspace {
    grid-template-columns: minmax(0, 1fr);
  }
  .investigation-controls {
    overflow: visible;
  }
  .selection-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .case-flow {
    justify-content: flex-start;
    gap: 12px;
  }
  .flow-line {
    max-width: 80px;
  }
  .selection-panel {
    position: static;
  }
  .visual-scene {
    --scene-max-h: 76vh;
  }
}
@media (max-width: 760px) {
  .game-wrap {
    width: calc(100% - 20px);
    --play-ui: 16px;
    --play-read: 21px;
    --play-gap: 12px;
  }
  .game-top {
    align-items: flex-start;
  }
  .game-top > span {
    max-width: 48%;
  }
  .game-head {
    gap: 10px;
    align-items: flex-start;
  }
  .game-wrap .game-head h1 {
    font-size: 27px;
  }
  .rigorbox {
    width: 116px;
    padding: 8px;
  }
  .rigor-icon {
    display: none;
  }
  .rigor-top strong {
    font-size: 21px;
  }
  .archive-progress-copy > span {
    font-size: 10px;
  }
  .mission-top {
    flex-wrap: wrap;
    padding: 14px 12px 0;
  }
  .phase-stack {
    text-align: left;
    grid-template-columns: 1fr;
  }
  .mission-instruction {
    padding-inline: 12px;
  }
  .workspace {
    padding: 0 8px 10px;
  }
  .document {
    padding: 10px;
  }
  .doc-text {
    padding: 16px;
  }
  .doc-toolbar {
    flex-wrap: wrap;
    gap: 8px;
  }
  .museum-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .museum-card {
    display: grid;
    grid-template-columns: minmax(95px, 0.75fr) minmax(0, 1.25fr);
  }
  .museum-object {
    height: 100%;
    min-height: 170px;
    aspect-ratio: auto;
  }
  .museum-copy {
    padding: 12px;
  }
  .timeline-track {
    grid-template-columns: minmax(0, 1fr);
  }
  .selection-actions {
    grid-template-columns: minmax(0, 1fr);
  }
  .selection-chips {
    max-height: 140px;
  }
  .modal {
    padding: 8px;
    font-size: 18px;
  }
  .modal-card {
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    border-radius: 14px;
  }
  .modal-head {
    padding: 12px 14px;
    gap: 8px;
  }
  .modal-head h2 {
    font-size: 25px;
  }
  .modal-body {
    padding: 14px;
  }
  .modal-foot {
    padding: 10px 14px;
  }
  .repair-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }
  .repair-context > p {
    display: none;
  }
  .repair-phrase {
    padding: 14px;
    font-size: 1em;
  }
  .option {
    padding: 14px;
    font-size: 1em;
  }
  .repair-footer-hint {
    font-size: 13px;
  }
  .repair-footer-hint:has(+ .show) {
    display: none;
  }
  #repairContinue {
    width: 100%;
  }
  .text-expand-card,
  .zoom-card {
    height: calc(100dvh - 16px);
  }
  .text-expand-paper {
    --play-read: 24px;
    padding: 16px;
  }
  .text-expand-foot > span,
  .text-expand-subtitle {
    display: none;
  }
  .zoom-topbar {
    padding: 10px 12px;
  }
  .zoom-topbar h2 {
    font-size: 21px;
  }
  .zoom-actions {
    gap: 5px;
    width: 100%;
    justify-content: space-between;
  }
  .zoom-tip {
    margin: 8px 12px;
  }
  .zoom-footer {
    padding: 10px 12px;
  }
  .zoom-footer .btn {
    width: 100%;
  }
  .board .game-wrap {
    --play-ui: 18px;
    --play-read: 25px;
  }
  .board .modal {
    font-size: 20px;
  }
  .board .modal .option {
    min-height: 56px;
    padding: 14px;
  }
}
@media (max-height: 600px) and (min-width: 761px) {
  .modal {
    padding: 8px;
    font-size: 17px;
  }
  .modal-card {
    max-height: calc(100dvh - 16px);
  }
  .modal-head {
    padding: 10px 16px;
  }
  .modal-head h2 {
    font-size: 24px;
  }
  .modal-head .eyebrow,
  .text-expand-subtitle {
    display: none;
  }
  .modal-body {
    padding: 14px 16px;
  }
  .modal-foot {
    padding: 8px 16px;
  }
  .board .modal {
    font-size: 20px;
  }
  .board .modal-head h2 {
    font-size: 26px;
  }
  .board .modal .btn,
  .board .modal .option {
    min-height: 48px;
    padding: 10px 14px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .loading-dot {
    animation: none;
  }
  .rigor-meter span {
    transition: none;
  }
}
@media print {
  body[data-view="game"] {
    height: auto;
    display: block;
    overflow: visible;
  }
  .app-header,
  .investigation-controls,
  .quick-accuse,
  .modal {
    display: none;
  }
  #gameScreen.active,
  .game-wrap,
  .workspace,
  .document {
    display: block;
    height: auto;
    overflow: visible;
  }
}
