@font-face {
  font-family: DotGothic;
  src: url("assets/DotGothic16.ttf") format("truetype");
  font-display: swap;
}
* {
  box-sizing: border-box;
}
:root {
  color-scheme: dark;
  --paper: #ede5c9;
  --muted: #a7a7ab;
  --navy: #242849;
  --deep: #171a30;
  --gold: #d7b86e;
  --border: #bcbfc8;
  --green: #a9c173;
}
body {
  margin: 0;
  background: #141622;
  color: var(--paper);
  font-family: DotGothic, "MS Gothic", monospace;
  letter-spacing: 0.03em;
  font-size: 16px;
  line-height: 1.7;
  min-height: 100dvh;
}
body:before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, #0000 0 3px, #0000000d 3px 4px);
  z-index: 10;
  opacity: 0.25;
}
button {
  font: inherit;
  color: inherit;
  background: transparent;
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
  line-height: 1.55;
  letter-spacing: inherit;
}
button:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}
button:disabled {
  cursor: default;
  opacity: 0.45;
}
button:hover:not(:disabled) {
  color: #fff6a6;
}
button:active:not(:disabled) {
  transform: translateY(1px);
}
[hidden] {
  display: none !important;
}
h1,
h2,
p {
  margin: 0;
}
canvas {
  display: block;
  image-rendering: pixelated;
  max-width: 100%;
}
.frame {
  background: var(--navy);
  border: 3px solid #e0e0d8;
  outline: 2px solid #4f536d;
  box-shadow:
    inset 0 0 0 3px #414865,
    4px 4px 0 #0b0e1b;
}
#app {
  max-width: 1040px;
  margin: auto;
  padding: 24px 32px 18px;
}
#titleScreen {
  max-width: 960px;
  margin: auto;
}
.edition {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 11px;
  letter-spacing: 0.23em;
  color: var(--gold);
  margin-bottom: 15px;
}
.edition:after {
  content: "";
  height: 1px;
  background: #424250;
  flex: 1;
}
.titleArt {
  position: relative;
  border: 5px solid #62646c;
  outline: 2px solid #c7baa0;
  overflow: hidden;
  height: 360px;
  background: #43543d;
}
.titleArt canvas {
  width: 640px;
  height: 360px;
  margin: auto;
}
.titlePlate {
  position: absolute;
  left: 24px;
  top: 20px;
  padding: 12px 20px;
  background: #1b2135ed;
  border: 2px solid #bcb7a0;
  box-shadow: 4px 4px 0 #25252c;
}
.titlePlate > span {
  font-size: 12px;
  color: var(--green);
  letter-spacing: 0.15em;
}
h1 {
  font-size: 32px;
  line-height: 1.5;
  font-weight: normal;
  margin-top: 6px;
  text-shadow: 3px 3px #11162a;
}
h1 em {
  font-style: normal;
  color: #e6cc83;
}
.episode {
  position: absolute;
  bottom: 12px;
  right: 18px;
  font-size: 15px;
  background: #252a49;
  border: 2px solid #c3bfae;
  padding: 5px 13px;
}
.titleBottom {
  padding: 22px 4px;
  display: grid;
  grid-template-columns: 1fr 270px;
  gap: 16px 30px;
}
.titleBottom p {
  font-size: 15px;
  align-self: center;
  line-height: 2.1;
}
.titleBottom small {
  font-size: 11px;
  color: var(--muted);
  grid-column: 1;
  grid-row: 2;
}
.titleCommands {
  grid-column: 2;
  grid-row: 1/3;
  padding: 10px 16px;
  display: grid;
  align-content: center;
  gap: 2px;
}
.titleCommands button {
  text-align: left;
  padding: 7px 6px 7px 28px;
  position: relative;
}
.titleCommands button:first-of-type:before,
.titleCommands button:hover:before {
  content: "▶";
  position: absolute;
  left: 6px;
  color: var(--paper);
}
.gameHeader {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 0 16px;
  min-height: 65px;
}
.gameHeader > button {
  border: 1px solid #585c71;
  padding: 6px 9px;
  font-size: 12px;
  white-space: nowrap;
}
.gameHeader > button:first-child {
  font-size: 17px;
  padding: 3px 9px;
}
.chapter {
  flex: 1;
  line-height: 1.6;
}
.chapter small {
  display: block;
  font-size: 10px;
  color: var(--gold);
  letter-spacing: 0.16em;
}
.chapter span {
  font-size: 16px;
}
.trust {
  margin-left: auto;
  line-height: 1.7;
  white-space: nowrap;
}
.trust small {
  font-size: 10px;
  display: block;
  color: var(--muted);
}
#hearts {
  font-family: monospace;
  letter-spacing: 3px;
  font-size: 18px;
  color: var(--green);
}
#evidenceCount {
  color: var(--gold);
}
.playfield {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  background: #302d2c;
  border: 4px solid #6a625c;
  outline: 1px solid #b6a387;
  min-height: 360px;
}
.playfield.withGraph {
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
}
.sceneWrap {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 360px;
  background: #5b4637;
}
.sceneWrap canvas {
  flex-shrink: 0;
  max-width: none;
}
.sceneLabel {
  position: absolute;
  left: 12px;
  top: 12px;
  background: #242849;
  border: 2px solid #d0c7ae;
  padding: 3px 12px;
  font-size: 13px;
  box-shadow: 2px 2px #202236;
}
.sceneFloor {
  position: absolute;
  bottom: 8px;
  left: 12px;
  font-size: 9px;
  letter-spacing: 0.16em;
  color: #d9c69c;
}
.exhibit {
  background: #e5ddc2;
  padding: 15px 16px;
  color: #35313d;
  border-left: 4px solid #7a5a41;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.evidenceTag {
  font-size: 10px;
  letter-spacing: 0.15em;
  color: #645c51;
}
h2 {
  font-size: 18px;
  font-weight: normal;
}
.exhibit h2 {
  margin-bottom: 8px;
}
.exhibit canvas {
  width: 100%;
  height: auto;
  border: 2px solid #80776b;
}
.exhibit p {
  font-size: 12px;
  margin-top: 8px;
  line-height: 1.7;
}
.exhibit button {
  align-self: flex-end;
  font-size: 12px;
  color: #48445c;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 5px;
}
.conversationArea {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  margin-top: 18px;
}
.conversationArea.hasCommands {
  grid-template-columns: minmax(0, 1.25fr) minmax(270px, 1fr);
}
.dialogue {
  position: relative;
  min-height: 177px;
  padding: 14px 20px 27px;
  cursor: pointer;
  touch-action: manipulation;
}
.speaker {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 24px;
  margin-bottom: 7px;
}
.speaker strong {
  font-size: 17px;
  font-weight: normal;
  color: #e7d79d;
}
.speaker span {
  font-size: 10px;
  color: #a8b2c8;
}
.dialogue p {
  font-size: 18px;
  line-height: 1.85;
  min-height: 66px;
}
.dialogue small {
  position: absolute;
  bottom: 8px;
  left: 20px;
  color: #8993b3;
  font-size: 9px;
}
#nextMark {
  position: absolute;
  bottom: 8px;
  right: 17px;
  font-size: 13px;
  animation: blink 1.2s steps(2) infinite;
}
.commands {
  padding: 11px 10px;
  display: grid;
  align-content: center;
  gap: 2px;
}
.commands button {
  position: relative;
  text-align: left;
  padding: 8px 8px 8px 28px;
  font-size: 14px;
  min-height: 44px;
}
.commands button.selected:before,
.commands button:hover:not(:disabled):before {
  position: absolute;
  left: 6px;
  content: "▶";
  color: var(--paper);
}
.commands button.selected {
  background: #ffffff08;
}
.commands small {
  display: block;
  color: #a4aec9;
  font-size: 10px;
  padding: 0 10px 6px;
}
.gameFooter {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 10px;
  color: #7d8399;
  padding: 17px 0 0;
}
#mapControls {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-top: 17px;
}
.mapHint {
  font-size: 12px;
  flex: 1;
  color: #c1c0b2;
}
.mapHint span {
  font-size: 10px;
  color: #8b92a4;
}
.modal {
  color: var(--paper);
  padding: 20px;
  max-width: 720px;
  width: calc(100% - 32px);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  font-size: 15px;
}
.modal::backdrop {
  background: #0a0d20d9;
}
.modalHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #626783;
  margin-bottom: 18px;
}
.modalHeader h2 {
  color: var(--gold);
  font-size: 18px;
}
.modalHeader button {
  font-size: 12px;
  white-space: nowrap;
}
.modal p {
  margin-bottom: 13px;
  line-height: 1.95;
}
.modal .subtle {
  font-size: 12px;
  color: #b3b9cb;
}
.modalButtons {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}
.modalButtons button,
.evidenceList button {
  border: 1px solid #8289a3;
  padding: 10px 13px;
  text-align: left;
  background: #ffffff05;
}
.modalButtons button:before {
  content: "▶ ";
  color: var(--gold);
}
.evidenceList {
  display: grid;
  gap: 8px;
}
.evidenceList button {
  display: flex;
  justify-content: space-between;
  gap: 15px;
}
.evidenceList small {
  font-size: 11px;
  color: #aeb8cb;
}
.evidenceSheet {
  background: #e5ddc2;
  color: #33313a;
  padding: 15px;
  border: 3px solid #a89572;
}
.evidenceSheet canvas {
  width: 100%;
  margin: 14px 0 8px;
}
.evidenceSheet h3 {
  font-weight: normal;
  font-size: 20px;
  margin: 0;
}
.evidenceSheet .subtle {
  color: #67625e;
}
.evidenceSheet p {
  font-size: 14px;
}
.evidenceSheet table {
  border-collapse: collapse;
  width: 100%;
  margin: 12px 0;
  font-size: 15px;
}
.evidenceSheet td {
  border-bottom: 1px solid #b9b19b;
  padding: 5px 8px;
}
.evidenceSheet td:last-child {
  text-align: right;
}
.evidenceSheet .note {
  background: #d2cbb5;
  font-size: 12px;
  padding: 10px;
}
.evidenceSheet button {
  color: #3c3654;
  border: 1px solid #6b6681;
  padding: 6px 10px;
  font-size: 12px;
}
.helpRow {
  display: grid;
  grid-template-columns: 75px 1fr;
  gap: 16px;
  align-items: center;
  padding-bottom: 16px;
}
.helpIcon {
  border: 2px solid #c0bdd2;
  padding: 12px;
  text-align: center;
  font-size: 24px;
  color: var(--green);
}
#toast {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #252849;
  border: 2px solid #dfd8ba;
  padding: 12px 20px;
  font-size: 13px;
  max-width: 90%;
  width: max-content;
  box-shadow: 4px 4px #11162a;
}
#objection {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff1ad;
  text-shadow:
    4px 4px #7c3438,
    -2px -2px #7c3438;
  font-size: 42px;
  background: #19213955;
  animation: objection 0.7s steps(3);
  z-index: 5;
  white-space: nowrap;
}
.shake {
  animation: shake 0.3s steps(2);
}
.endingBadge {
  text-align: center;
  color: var(--green);
  font-size: 28px;
  padding: 15px;
  border-bottom: 1px solid #788164;
  margin-bottom: 15px;
}
.endingSummary {
  font-size: 14px;
}
.errorBadge {
  color: #e4a18d;
}
.helpCanvas {
  width: 100%;
  border: 2px solid #77768b;
  margin-bottom: 12px;
}
@keyframes blink {
  50% {
    opacity: 0.25;
  }
}
@keyframes shake {
  0%,
  100% {
    transform: translate(0);
  }
  25% {
    transform: translate(4px, -2px);
  }
  75% {
    transform: translate(-4px, 2px);
  }
}
@keyframes objection {
  0% {
    transform: scaleY(0.3);
  }
  35% {
    transform: scaleY(1.2);
  }
  70% {
    transform: scaleY(1);
  }
}
@media (min-width: 1100px) {
  #app {
    padding-top: 36px;
  }
}
@media (max-width: 760px) {
  #app {
    padding: 15px 14px 18px;
  }
  .edition {
    font-size: 9px;
    margin-bottom: 12px;
    letter-spacing: 0.12em;
  }
  .titleArt {
    height: 360px;
  }
  .titleArt canvas {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: 0;
  }
  .titlePlate {
    left: 14px;
    right: 14px;
    top: 14px;
    padding: 11px 13px;
    background: #1b2135f2;
  }
  .titlePlate > span {
    font-size: 10px;
  }
  h1 {
    font-size: 27px;
  }
  .episode {
    bottom: 9px;
    right: 9px;
    font-size: 13px;
  }
  .titleBottom {
    grid-template-columns: 1fr;
    padding: 18px 0 0;
    gap: 18px;
  }
  .titleBottom p {
    font-size: 13px;
    line-height: 1.9;
  }
  .titleCommands {
    grid-column: 1;
    grid-row: 2;
    padding: 8px 15px;
  }
  .titleCommands button {
    font-size: 16px;
    padding-top: 8px;
    padding-bottom: 8px;
  }
  .titleBottom small {
    grid-row: 3;
    font-size: 10px;
  }
  .gameHeader {
    gap: 8px;
    padding-bottom: 12px;
    min-height: 60px;
    flex-wrap: wrap;
  }
  .chapter small {
    font-size: 9px;
  }
  .chapter span {
    font-size: 13px;
  }
  .trust small {
    font-size: 9px;
  }
  #hearts {
    font-size: 15px;
    letter-spacing: 1px;
  }
  .gameHeader > button {
    font-size: 10px;
    padding: 5px 7px;
  }
  .gameHeader > button:first-child {
    padding: 4px 7px;
    font-size: 13px;
  }
  #audioButton {
    font-size: 9px;
  }
  .playfield,
  .playfield.withGraph {
    grid-template-columns: 1fr;
    min-height: 180px;
  }
  .sceneWrap {
    min-height: 180px;
    height: 180px;
  }
  .sceneWrap canvas {
    width: 320px !important;
    height: 180px !important;
  }
  .sceneLabel {
    font-size: 10px;
    left: 8px;
    top: 8px;
    padding: 2px 8px;
  }
  .sceneFloor {
    font-size: 7px;
  }
  .playfield.withGraph .sceneWrap {
    height: 76px;
    min-height: 76px;
    align-items: flex-start;
  }
  .playfield.withGraph .sceneWrap canvas {
    margin-top: -52px;
    transform: translateX(-70px);
  }
  .playfield.withGraph .sceneLabel {
    left: auto;
    right: 10px;
    top: 14px;
  }
  .playfield.withGraph .sceneFloor {
    display: none;
  }
  .exhibit {
    border-left: 0;
    border-top: 3px solid #8c7351;
    padding: 9px 12px;
  }
  .evidenceTag {
    font-size: 9px;
  }
  .exhibit h2 {
    font-size: 15px;
    margin: 2px 0 6px;
  }
  .exhibit canvas {
    max-width: 420px;
    margin: auto;
    width: 100%;
    max-height: 180px;
    object-fit: contain;
  }
  .exhibit p {
    font-size: 11px;
    margin-top: 5px;
  }
  .exhibit button {
    padding: 1px 4px;
    font-size: 10px;
  }
  .conversationArea,
  .conversationArea.hasCommands {
    grid-template-columns: 1fr;
    gap: 13px;
    margin-top: 14px;
  }
  .dialogue {
    min-height: 158px;
    padding: 11px 14px 25px;
  }
  .dialogue p {
    font-size: 16px;
    line-height: 1.85;
    min-height: 59px;
  }
  .speaker {
    margin-bottom: 5px;
    gap: 8px;
  }
  .speaker strong {
    font-size: 15px;
  }
  .speaker span {
    font-size: 9px;
  }
  .dialogue small {
    left: 14px;
    font-size: 8px;
  }
  .commands {
    padding: 7px 9px;
  }
  .commands button {
    font-size: 14px;
    padding-top: 9px;
    padding-bottom: 9px;
  }
  .gameFooter {
    font-size: 9px;
    display: block;
  }
  .gameFooter > span:first-child {
    display: none;
  }
  #mapControls {
    gap: 14px;
    margin-top: 16px;
  }
  .mapHint {
    font-size: 10px;
  }
  .mapHint span {
    font-size: 9px;
  }
  .modal {
    padding: 14px;
    font-size: 14px;
    width: calc(100% - 24px);
    max-height: calc(100dvh - 24px);
  }
  .modalHeader h2 {
    font-size: 16px;
  }
  .modalHeader button {
    font-size: 10px;
  }
  .evidenceSheet {
    padding: 10px;
  }
  .evidenceSheet p {
    font-size: 13px;
  }
  .evidenceSheet h3 {
    font-size: 17px;
  }
  .evidenceList button {
    display: block;
  }
  .evidenceList small {
    display: block;
  }
  .helpRow {
    grid-template-columns: 50px 1fr;
    gap: 12px;
  }
  .helpIcon {
    font-size: 19px;
    padding: 8px;
  }
  #objection {
    font-size: 31px;
  }
  body.playing #app {
    padding-top: max(8px, env(safe-area-inset-top));
    padding-bottom: max(18px, env(safe-area-inset-bottom));
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    scroll-behavior: auto !important;
  }
}
.titleArt canvas {
  max-width: none;
}
.playfield.withGraph .sceneWrap canvas {
  flex-shrink: 0;
}
body:before {
  background: none;
}
@media (max-width: 760px) {
  .playfield.withGraph .sceneWrap canvas {
    transform: none;
    margin-left: 0;
    align-self: flex-start;
  }
  #toast {
    top: 72px;
    bottom: auto;
    padding: 8px 12px;
    font-size: 11px;
    pointer-events: none;
    max-width: calc(100% - 32px);
  }
  .exhibit p {
    font-size: 12px;
  }
  .conversationArea.hasCommands .dialogue {
    min-height: 135px;
  }
}
@media (max-width: 360px) {
  .gameHeader {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) auto auto;
    gap: 5px 7px;
    min-height: 65px;
  }
  .gameHeader > button:first-child {
    grid-column: 1;
    grid-row: 1/3;
    align-self: center;
    padding: 4px 6px;
  }
  .chapter {
    grid-column: 2/5;
    white-space: nowrap;
  }
  .chapter small {
    display: inline;
    font-size: 8px;
    margin-right: 9px;
  }
  .chapter span {
    font-size: 12px;
  }
  .trust {
    grid-column: 2;
    grid-row: 2;
    display: flex;
    align-items: center;
    gap: 4px;
  }
  .trust small {
    font-size: 8px;
  }
  #hearts {
    font-size: 12px;
    letter-spacing: 0;
  }
  #audioButton {
    grid-column: 3;
    grid-row: 2;
  }
  #evidenceButton {
    grid-column: 4;
    grid-row: 2;
  }
  .exhibit p {
    font-size: 10px;
  }
  .speaker {
    flex-wrap: wrap;
    gap: 1px 8px;
  }
  .dialogue p {
    font-size: 15px;
  }
  .commands button {
    font-size: 13px;
  }
}
@media (max-width: 760px) {
  .mapHint {
    min-width: 0;
  }
}

@media (max-width: 760px) {
  .mapReady .dialogue {
    display: none;
  }
  .mapReady .gameFooter {
    display: none;
  }
  .mapReady #mapControls {
    margin-top: 10px;
  }
}

/* Touch controls: no text selection or iOS long-press callout. */
#mapControls,
#mapControls * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.mapHint #mapHintText {
  font-size: 12px;
  color: #c1c0b2;
}
.mapHint small {
  font-size: 10px;
  color: #8b92a4;
}
@media (max-width: 760px) {
  .mapHint #mapHintText {
    font-size: 10px;
  }
  .mapHint small {
    font-size: 9px;
  }
}

.dialogueLayout {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.dialogueSpeech {
  flex: 1;
  min-width: 0;
}
#speakerPortrait {
  width: 64px;
  height: 80px;
  flex-shrink: 0;
  image-rendering: pixelated;
  background: #1b2038;
  border: 1px solid #67708e;
}
.speaker {
  flex-wrap: wrap;
}
@media (max-width: 760px) {
  .dialogueLayout {
    gap: 10px;
  }
  #speakerPortrait {
    width: 48px;
    height: 60px;
  }
}

#scene {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  cursor: pointer;
}
.sceneLabel,
.sceneFloor {
  pointer-events: none;
}

.mapReady .conversationArea {
  display: none;
}

@media (max-width: 760px) {
  .playfield.withGraph .sceneWrap {
    height: 112px;
    min-height: 112px;
  }
  .playfield.withGraph .sceneWrap canvas {
    margin-top: -40px;
  }
}

/* The play session stays inside Safari's visible viewport; long text scrolls only inside its panel. */
body.playing {
  height: 100dvh;
  overflow: hidden;
}
body.playing #app {
  height: 100dvh;
  padding: max(8px, env(safe-area-inset-top)) 20px
    max(8px, env(safe-area-inset-bottom));
}
#gameScreen:not([hidden]) {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
body.playing .gameHeader {
  flex: 0 0 auto;
  min-height: 46px;
  padding: 0;
  flex-wrap: nowrap;
}
.gameScroll {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
body.playing .playfield {
  flex: 1;
  min-height: 0;
}
body.playing .sceneWrap {
  min-height: 0;
  height: auto;
}
body.playing .exhibit {
  min-height: 0;
  overflow: hidden;
  padding: 8px 12px;
}
body.playing .exhibit canvas {
  flex: 1;
  min-height: 0;
  height: 0;
  width: 100%;
  object-fit: contain;
}
body.playing .exhibit h2 {
  margin: 0;
  flex-shrink: 0;
}
body.playing .exhibit p {
  flex-shrink: 0;
  margin: 4px 0;
}
body.playing .exhibit button {
  flex-shrink: 0;
}
body.playing .conversationArea {
  flex: 0 0 auto;
  min-height: 0;
  max-height: 46%;
  margin: 0;
  gap: 10px;
}
body.playing .dialogue {
  min-height: 130px;
  max-height: 190px;
  overflow-y: auto;
  padding: 10px 14px 25px;
}
body.playing .dialogue p {
  font-size: 16px;
  line-height: 1.65;
  min-height: 0;
}
body.playing .commands {
  min-height: 0;
  max-height: 230px;
  overflow-y: auto;
  padding: 5px;
}
body.playing .commands button {
  padding: 5px 7px 5px 23px;
}
body.playing .gameFooter {
  display: none;
}
body.playing #mapControls {
  flex: 0 0 auto;
  margin: 0;
}
body.playing .mapReady .conversationArea {
  display: none;
}
@media (max-width: 760px) {
  body.playing #app {
    padding-left: 8px;
    padding-right: 8px;
  }
  body.playing .gameHeader {
    gap: 5px;
  }
  body.playing .gameHeader > button {
    padding: 4px 5px;
  }
  body.playing .playfield,
  body.playing .playfield.withGraph {
    grid-template-columns: 1fr;
  }
  body.playing .playfield.withGraph {
    grid-template-rows: clamp(34px, 8dvh, 64px) minmax(0, 1fr);
  }
  body.playing .playfield.withGraph .sceneWrap {
    height: auto;
    min-height: 0;
  }
  body.playing .playfield.withGraph .sceneWrap canvas {
    margin-top: -52px;
  }
  body.playing .sceneLabel {
    font-size: 8px;
    top: 4px;
    right: 4px;
    padding: 1px 4px;
  }
  body.playing .exhibit {
    padding: 4px 8px;
  }
  body.playing .evidenceTag {
    display: none;
  }
  body.playing .exhibit h2 {
    font-size: 13px;
  }
  body.playing .exhibit canvas {
    max-height: none;
    max-width: none;
  }
  body.playing .exhibit p {
    font-size: 10px;
    line-height: 1.4;
    margin: 2px 0;
  }
  body.playing .exhibit button {
    font-size: 10px;
    padding: 0 3px;
  }
  body.playing .conversationArea,
  body.playing .conversationArea.hasCommands {
    display: flex;
    flex-direction: column;
    max-height: 55%;
    gap: 7px;
  }
  body.playing .dialogue,
  body.playing .conversationArea.hasCommands .dialogue {
    min-height: 94px;
    max-height: 165px;
    flex: 1 1 auto;
  }
  body.playing .dialogue p {
    font-size: 14px;
    line-height: 1.65;
  }
  body.playing .speaker strong {
    font-size: 13px;
  }
  body.playing .speaker span {
    font-size: 8px;
  }
  body.playing #speakerPortrait {
    width: 32px;
    height: 40px;
  }
  body.playing .dialogueLayout {
    gap: 8px;
  }
  body.playing .commands {
    flex: 0 1 auto;
    max-height: 29dvh;
  }
  body.playing .commands button {
    font-size: 13px;
    min-height: 40px;
  }
  body.playing .commands small {
    font-size: 9px;
    padding-bottom: 2px;
  }
  body.playing .gameScroll {
    gap: 8px;
  }
}
@media (max-height: 560px) and (min-width: 761px) {
  body.playing .dialogue {
    min-height: 100px;
    max-height: 130px;
  }
  body.playing .commands {
    max-height: 150px;
  }
}
@media (max-width: 760px) {
  body.playing .playfield.withGraph {
    grid-template-rows: 64px minmax(0, 1fr);
  }
  body.playing .playfield.withGraph .sceneWrap canvas {
    margin-top: -78px;
  }
}
@media (max-width: 760px) and (max-height: 650px) {
  /* On the smallest screens, the speaking portrait represents the courtroom. */
  body.playing .playfield.withGraph {
    grid-template-rows: minmax(0, 1fr);
  }
  body.playing .playfield.withGraph .sceneWrap {
    display: none;
  }
  body.playing .commands {
    max-height: 32dvh;
  }
}
@media (max-width: 760px) {
  body.playing .commands {
    flex: 0 0 auto;
  }
}
@media (max-width: 760px) and (max-height: 650px) {
  body.playing .conversationArea,
  body.playing .conversationArea.hasCommands {
    max-height: 60%;
  }
}

/* A single fixed RPG frame. Dialogue never participates in sizing the map. */
body.playing #app {
  max-width: 1280px;
  padding: max(2px, env(safe-area-inset-top)) 2px
    max(2px, env(safe-area-inset-bottom));
}
#gameScreen:not([hidden]) {
  gap: 3px;
}
body.playing .gameHeader {
  padding: 0 5px;
}
body.playing .gameScroll {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) clamp(205px, 33dvh, 300px);
  gap: 0;
  overflow: hidden;
  border: 3px solid #b6a387;
  background: #242849;
  box-shadow: inset 0 0 0 2px #4f536d;
}
body.playing .playfield {
  min-height: 0;
  border: 0;
  outline: 0;
}
body.playing .sceneWrap {
  min-height: 0;
  height: 100%;
  padding: 0;
  align-items: center;
  justify-content: center;
  background: #242849;
}
body.playing .sceneWrap canvas {
  width: auto !important;
  height: auto !important;
  max-width: 100%;
  max-height: 100%;
  margin: 0;
  transform: none;
}
body.playing .conversationArea,
body.playing .conversationArea.hasCommands,
body.playing .mapReady .conversationArea {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 0.8fr);
  grid-template-rows: minmax(0, 1fr);
  height: 100%;
  max-height: none;
  margin: 0;
  gap: 5px;
  padding: 5px;
  background: #171a30;
  border-top: 2px solid #b6a387;
}
body.playing .conversationArea:not(.hasCommands) {
  grid-template-columns: minmax(0, 1fr);
}
body.playing .dialogue,
body.playing .conversationArea.hasCommands .dialogue,
body.playing .mapReady .dialogue {
  display: block;
  min-height: 0;
  max-height: none;
  height: 100%;
  box-shadow: inset 0 0 0 2px #414865;
  outline: 0;
}
body.playing .commands {
  min-height: 0;
  max-height: none;
  height: 100%;
  align-content: center;
  box-shadow: inset 0 0 0 2px #414865;
  outline: 0;
}
body.playing #mapControls {
  display: none;
}
/* Exploration maps use their native aspect ratio. The rest of the frame is the message window. */
body.playing .exploration .gameScroll {
  grid-template-rows: min(56.25vw, 55%) minmax(0, 1fr);
}
body.playing .exploration .sceneWrap {
  background: #5b4637;
}
body.playing .sceneFloor {
  display: none;
}
@media (max-width: 760px) {
  body.playing #app {
    padding-left: 2px;
    padding-right: 2px;
  }
  body.playing .gameScroll {
    grid-template-rows: minmax(0, 1fr) clamp(245px, 43dvh, 345px);
  }
  body.playing .exploration .gameScroll {
    grid-template-rows: min(56.25vw, 46%) minmax(0, 1fr);
  }
  body.playing .playfield.withGraph {
    grid-template-rows: 54px minmax(0, 1fr);
  }
  body.playing .playfield.withGraph .sceneWrap {
    display: flex;
    height: 54px;
  }
  body.playing .playfield.withGraph .sceneWrap canvas {
    width: 320px !important;
    height: 180px !important;
    max-width: none;
    max-height: none;
    margin-top: -78px;
  }
  body.playing .conversationArea,
  body.playing .conversationArea.hasCommands,
  body.playing .mapReady .conversationArea {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) 148px;
    gap: 4px;
    padding: 4px;
  }
  body.playing .conversationArea:not(.hasCommands) {
    grid-template-rows: minmax(0, 1fr);
  }
  body.playing .commands button {
    min-height: 40px;
    padding-top: 3px;
    padding-bottom: 3px;
  }
  body.playing .commands small {
    display: none;
  }
  body.playing .sceneLabel {
    left: 4px;
    right: auto;
    width: auto;
    max-width: calc(100% - 8px);
  }
  body.playing .playfield.withGraph .sceneLabel {
    left: auto;
    right: 4px;
  }
}
@media (max-width: 760px) and (max-height: 650px) {
  body.playing .playfield.withGraph {
    grid-template-rows: minmax(0, 1fr);
  }
  body.playing .playfield.withGraph .sceneWrap {
    display: none;
  }
}
body.playing .sceneWrap canvas {
  width: var(--scene-width, 320px) !important;
  height: var(--scene-height, 180px) !important;
}
@media (max-width: 760px) {
  body.playing .playfield.withGraph .sceneWrap canvas {
    width: 320px !important;
    height: 180px !important;
  }
}
/* Message windows are anchored over the scene, inside the same outer border. */
body.playing .gameScroll {
  --message-height: clamp(205px, 33dvh, 300px);
  display: block;
}
body.playing .playfield {
  position: absolute;
  inset: 0;
}
body.playing .playfield.withGraph {
  bottom: calc(var(--message-height) + 8px);
}
body.playing .conversationArea,
body.playing .conversationArea.hasCommands,
body.playing .mapReady .conversationArea {
  position: absolute;
  inset: auto 4px 4px;
  height: var(--message-height);
  border-top: 0;
  padding: 0;
  background: transparent;
}
body.playing .sceneWrap {
  align-items: flex-start;
}
body.playing .exploration .sceneWrap {
  background: #765039;
}
@media (max-width: 760px) {
  body.playing .gameScroll {
    --message-height: clamp(245px, 43dvh, 345px);
  }
}

/* Exploration uses the complete frame. Windows appear only during an actual event. */
body.playing .mapReady .conversationArea,
body.playing .mapReady #mapControls {
  display: none;
}

/* Overlay geometry stays independent of the map. Each window fits its current line. */
body.playing .conversationArea,
body.playing .conversationArea.hasCommands {
  height: auto;
  max-height: calc(100% - 8px);
  grid-template-rows: auto;
  align-items: end;
}
body.playing .dialogue,
body.playing .conversationArea.hasCommands .dialogue {
  height: auto;
  min-height: 0;
  max-height: 50dvh;
  align-self: end;
}
body.playing .conversationArea:not(.hasCommands) .dialogue {
  max-height: 65dvh;
}
body.playing .commands {
  height: auto;
  max-height: 32dvh;
  align-self: end;
}
@media (max-width: 760px) {
  body.playing .conversationArea,
  body.playing .conversationArea.hasCommands {
    grid-template-rows: auto auto;
  }
  body.playing .conversationArea:not(.hasCommands) {
    grid-template-rows: auto;
  }
  body.playing .conversationArea.hasCommands .dialogue {
    max-height: 38dvh;
  }
}

/* Keep names and dialogue; secondary role labels and operation captions belong in Help. */
#speakerRole,
#dialogueHint,
#nextMark,
body.playing .gameHeader small,
.commands small,
.gameFooter,
.sceneFloor,
#titleScreen .titleBottom small {
  display: none !important;
}
body.playing .dialogue {
  padding-bottom: 10px;
}
.modal .subtle,
.modal .note {
  font-size: 14px;
  line-height: 1.7;
}
body.playing .evidenceTag {
  display: none;
}

/* Speaker colors and effects stay independent of the courtroom canvas. */
#dialogue[data-speaker-kind="audience"] {
  background: #5a3d2b;
}
#dialogue[data-speaker-kind="narration"] {
  background: #050607;
}
#objection {
  position: fixed;
  inset: auto;
  left: 50%;
  top: 50%;
  width: max-content;
  height: auto;
  max-width: 96vw;
  padding: 12px 18px;
  transform: translate(-50%, -50%);
  font-size: clamp(36px, 9vw, 64px);
  background: #192139cc;
  z-index: 100;
  pointer-events: none;
  animation: centeredObjection 0.7s steps(3);
}
#damageFlash {
  position: fixed;
  inset: 0;
  z-index: 99;
  pointer-events: none;
  background: #ef2222;
  animation: damageTint 0.3s ease-out forwards;
}
#gameScreen.damageShake {
  animation: damageShake 0.25s linear;
}
@keyframes centeredObjection {
  0% {
    transform: translate(-50%, -50%) scale(0.7, 0.3);
  }
  35% {
    transform: translate(-50%, -50%) scale(1.08, 1.2);
  }
  70% {
    transform: translate(-50%, -50%) scale(1);
  }
}
@keyframes damageTint {
  from {
    opacity: 0.32;
  }
  to {
    opacity: 0;
  }
}
@keyframes damageShake {
  20%,
  60% {
    transform: translateX(-3px);
  }
  40%,
  80% {
    transform: translateX(3px);
  }
  100% {
    transform: translateX(0);
  }
}
@media (prefers-reduced-motion: reduce) {
  #objection,
  #gameScreen.damageShake {
    animation: none;
  }
  #damageFlash {
    animation: none;
    opacity: 0.16;
  }
}

/* A compact cast directory in the existing header. */
body.playing .gameHeader {
  display: flex;
}
body.playing .chapter {
  min-width: 0;
  overflow: hidden;
}
body.playing .chapter span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#profilesButton {
  font-size: 10px;
  padding: 4px 5px;
}
.profileList {
  display: grid;
  gap: 12px;
}
.profileCard {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid #78768b;
  background: #202541;
}
.profileCard canvas {
  width: 64px;
  height: 80px;
  image-rendering: pixelated;
}
.profileCard h3 {
  margin: 0 0 5px;
  color: var(--gold);
  font-size: 17px;
}
.profileCard p {
  margin: 4px 0;
  font-size: 13px;
  line-height: 1.6;
}
.profileCard .profileAffiliation {
  color: #bab5c7;
  font-size: 11px;
}
@media (max-width: 360px) {
  body.playing .gameHeader {
    gap: 4px;
  }
  body.playing .gameHeader > button {
    padding: 4px;
    font-size: 9px;
  }
  body.playing .chapter span {
    font-size: 11px;
  }
  body.playing #hearts {
    font-size: 11px;
  }
}

#modal[data-kind="reconsider"] {
  background: #050607;
  color: #eee9dc;
}

#doorTransition {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 1000;
  cursor: wait;
  touch-action: none;
}

#creditsButton {
  font-size: 9px;
  padding: 4px 5px;
}
.creditSection {
  margin: 20px 0;
  padding-top: 14px;
  border-top: 1px solid #77758a;
}
.creditSection h3 {
  color: var(--gold);
  font-size: 16px;
  margin: 0 0 8px;
}
.creditSection a {
  color: #e5d797;
  text-decoration: underline;
  overflow-wrap: anywhere;
}
.creditSection ul {
  padding-left: 20px;
  margin: 10px 0;
  font-size: 13px;
  line-height: 1.8;
}
.creditsTitle {
  color: var(--gold);
}
@media (max-width: 360px) {
  #creditsButton span {
    display: none;
  }
  #creditsButton::before {
    content: "©";
    font-size: 13px;
  }
}

/* Notifications occupy their own row, so evidence messages never cover dialogue. */
#gameScreen > #toast {
  position: static;
  flex: 0 0 auto;
  align-self: center;
  transform: none;
  width: max-content;
  max-width: calc(100% - 8px);
  margin: 0;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.6;
  overflow-wrap: anywhere;
  pointer-events: none;
}
