/* THE QUIET ROOM — deep ink blue, paper ivory, muted copper. */
:root {
  --ink: #0f1b2d; --ink2: #15253c; --ink3: #1d3150; --ink4: #2a4368;
  --paper: #f3ecdc; --paper2: #e3d8c1; --paper-dim: #c9bfa9;
  --copper: #b87333; --copper2: #d6955a; --rust: #a4523a;
  --line: rgba(243, 236, 220, 0.16);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --tap: 44px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--ink); color: var(--paper); font: 17px/1.55 var(--serif); -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--copper2); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: 0.01em; margin: 0.4em 0 0.3em; }
p { margin: 0.35em 0; }
.small { font-size: 16px; color: var(--paper-dim); }
.muted { color: var(--paper-dim); }
.pre { white-space: pre-wrap; }

#app { height: 100dvh; overflow: hidden; }
#offline-tools [hidden], #offline-tools[hidden] { display: none !important; }

/* Buttons */
.btn { min-height: var(--tap); padding: 8px 16px; border-radius: 4px; border: 1px solid var(--ink4); background: var(--ink3); color: var(--paper); cursor: pointer; font-family: var(--sans); font-size: 16px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-align: center; }
.btn:hover:not(:disabled) { border-color: var(--copper); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--copper); border-color: var(--copper2); color: #1a0f06; font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--copper2); }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.big { min-height: 52px; font-size: 18px; padding: 10px 22px; }
.small-btn { padding: 6px 12px; font-size: 15px; }
.btn.file { position: relative; overflow: hidden; }
.btn.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 10px 0; }
.flash { margin: 6px 12px; padding: 10px 14px; border-left: 4px solid var(--copper); background: var(--ink2); font-family: var(--sans); font-size: 16px; }

/* Menu, new game, how to play */
.menu, .newgame, .how { height: 100dvh; overflow-y: auto; padding: 24px 20px 48px; max-width: 760px; margin: 0 auto; }
.menu { text-align: center; }
.menu-cast { display: flex; justify-content: center; gap: 4px; margin-top: 12px; }
.figure.tiny { width: 60px; height: 82px; }
.title { font-size: clamp(34px, 8vw, 56px); letter-spacing: 0.16em; margin: 8px 0 0; color: var(--paper); }
.tagline { font-style: italic; color: var(--copper2); font-size: 19px; }
.menu-actions { display: grid; gap: 12px; max-width: 420px; margin: 24px auto; }
.menu-runs, .menu-history, .menu-saves { max-width: 520px; margin: 18px auto; text-align: left; }
.menu-runs .btn { width: 100%; justify-content: flex-start; margin: 4px 0; }
.menu-history ul { padding-left: 20px; }
.menu-saves summary { cursor: pointer; min-height: var(--tap); display: flex; align-items: center; font-family: var(--sans); }
.check { display: flex; gap: 10px; align-items: flex-start; min-height: var(--tap); padding: 8px 0; cursor: pointer; }
.check input { width: 22px; height: 22px; margin-top: 2px; flex: none; accent-color: var(--copper); }
.check.warn { color: var(--copper2); }
fieldset { border: 1px solid var(--line); border-radius: 6px; margin: 14px 0; padding: 10px 14px; }
legend { font-family: var(--sans); font-size: 15px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--copper2); padding: 0 6px; }
.card-radio { display: flex; gap: 12px; align-items: flex-start; padding: 10px; min-height: var(--tap); border-radius: 4px; cursor: pointer; }
.card-radio:hover { background: var(--ink2); }
.card-radio input { width: 22px; height: 22px; margin-top: 3px; flex: none; accent-color: var(--copper); }
.card-radio > span { display: flex; flex-direction: column; }
.card-radio.inline { display: inline-flex; padding-right: 18px; }
.how li { margin: 6px 0; }

/* Play shell */
.play { height: 100dvh; display: grid; grid-template-rows: auto auto auto minmax(0, 1fr) auto; }
.play > .flash { grid-row: 3; }
.play > .view { grid-row: 4; }
.play > .picker { grid-row: 5; }
.bar { display: flex; align-items: center; gap: 12px; padding: 6px 12px; background: var(--ink2); border-bottom: 1px solid var(--line); font-family: var(--sans); }
.bar-title { flex: 1; min-width: 0; margin: 0; font-size: 16px; }
.case-no { color: var(--copper2); text-transform: uppercase; letter-spacing: 0.08em; font-size: 14px; }
.case-name { font-family: var(--serif); font-size: 18px; }
.clock { margin: 0; font-size: 15px; color: var(--paper2); white-space: nowrap; }
.tabs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); background: var(--ink2); border-bottom: 1px solid var(--line); }
.tab { min-height: var(--tap); background: none; border: 0; border-bottom: 3px solid transparent; font-family: var(--sans); font-size: 15px; color: var(--paper2); cursor: pointer; padding: 4px 2px; }
.tab[aria-current="page"] { color: var(--paper); border-bottom-color: var(--copper); font-weight: 600; }
.badge { display: inline-block; min-width: 20px; padding: 0 5px; border-radius: 10px; background: var(--copper); color: #1a0f06; font-size: 13px; }
.view { min-height: 0; overflow: hidden; }

/* Talk */
.talk { height: 100%; display: grid; grid-template-columns: minmax(300px, 40%) minmax(0, 1fr); min-height: 0; }
.stage { position: relative; min-height: 0; overflow: hidden; border-right: 1px solid var(--line); background: var(--ink2); }
.scene { position: absolute; inset: 0; width: 100%; height: 100%; }
.speaker { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); height: 78%; aspect-ratio: 160 / 220; }
.figure.big { width: 100%; height: 100%; display: block; filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.45)); }
.nameplate { position: absolute; left: 12px; top: 12px; display: flex; flex-direction: column; background: rgba(15, 27, 45, 0.88); border: 1px solid var(--line); border-left: 4px solid var(--copper); padding: 6px 12px; border-radius: 3px; font-family: var(--sans); max-width: calc(100% - 24px); }
.nameplate strong { font-size: 18px; font-family: var(--serif); }
.nameplate span { font-size: 15px; color: var(--paper2); }
.nameplate .away { color: var(--copper2); }
.convo { display: grid; grid-template-rows: minmax(0, 1fr) auto; min-height: 0; }
.transcript { overflow-y: auto; padding: 12px 18px; min-height: 0; scroll-behavior: auto; }
.intro { border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 10px; }
.kicker { font-family: var(--sans); font-size: 14px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--copper2); }
.inquiry { background: var(--ink2); padding: 8px 12px; border-left: 4px solid var(--copper); }
.x { margin: 10px 0; }
.x.ev { font-family: var(--sans); font-size: 16px; color: var(--paper2); border-left: 2px solid var(--ink4); padding-left: 10px; }
article.x { border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; background: rgba(21, 37, 60, 0.6); }
article.x.latest { border-color: var(--copper); }
.who { font-family: var(--sans); font-size: 14px; color: var(--copper2); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 6px; }
.q { white-space: pre-wrap; overflow-wrap: anywhere; font-style: italic; }
.a { white-space: pre-wrap; overflow-wrap: anywhere; }
.atm { font-size: 16px; color: var(--paper-dim); font-style: italic; }
.rating { font-family: var(--sans); font-size: 16px; color: var(--paper2); }
.grade { display: inline-block; padding: 1px 8px; border-radius: 3px; font-weight: 700; margin-right: 6px; }
.g-good { background: #5f8f6c; color: #08140c; }
.g-okay { background: #8aa36a; color: #0f1406; }
.g-middling { background: #c9a14a; color: #1a1204; }
.g-bad { background: #c97a4a; color: #1a0c04; }
.g-terrible { background: #a4523a; color: #fff3ea; }
.g-none { background: var(--ink4); color: var(--paper); }
.notice { font-family: var(--sans); font-size: 16px; background: var(--ink3); border-left: 3px solid var(--paper-dim); padding: 6px 10px; }
.askbox { border-top: 1px solid var(--line); padding: 8px 14px 10px; background: var(--ink2); max-height: 52dvh; overflow-y: auto; }
.modebar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-family: var(--sans); font-size: 15px; margin-bottom: 6px; }
.seg { min-height: var(--tap); padding: 4px 12px; border: 1px solid var(--ink4); background: var(--ink); border-radius: 4px; cursor: pointer; font-family: var(--sans); font-size: 15px; }
.seg[aria-pressed="true"] { border-color: var(--copper); background: var(--ink3); font-weight: 600; }
.composer { display: grid; gap: 6px; }
.composer-label { font-family: var(--sans); font-size: 15px; color: var(--paper2); }
.composer textarea { width: 100%; min-height: 64px; resize: vertical; padding: 10px; border-radius: 4px; border: 1px solid var(--ink4); background: var(--paper); color: #14202f; font-size: 17px; line-height: 1.45; }
.composer-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.composer-row .hint { flex: 1 1 220px; }
.hint { font-family: var(--sans); font-size: 15px; color: var(--paper-dim); margin: 0; }
.count { font-family: var(--sans); font-size: 14px; color: var(--paper-dim); }
.choices { display: grid; gap: 8px; }
.choice { min-height: var(--tap); text-align: left; padding: 10px 14px; border-radius: 4px; border: 1px solid var(--ink4); background: var(--ink); cursor: pointer; font-family: var(--serif); font-size: 17px; line-height: 1.4; }
.choice:hover { border-color: var(--copper); }
.closed-note { font-family: var(--sans); color: var(--copper2); }

.picker { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: var(--ink2); border-top: 1px solid var(--line); }
.pick { min-height: 56px; display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto; column-gap: 8px; align-items: center; padding: 4px 8px; border-radius: 4px; border: 1px solid var(--ink4); background: var(--ink); cursor: pointer; text-align: left; font-family: var(--sans); }
.pick[aria-pressed="true"] { border-color: var(--copper); background: var(--ink3); box-shadow: inset 0 -3px 0 var(--copper); }
.figure.mini { width: 34px; height: 46px; grid-row: 1 / span 2; }
.pick-name { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.pick-role { font-size: 13px; color: var(--paper-dim); overflow-wrap: anywhere; }

/* Panes */
.pane { height: 100%; overflow-y: auto; padding: 12px 20px 40px; max-width: 920px; margin: 0 auto; }
.pane-title { font-size: 22px; }
.ev-group { margin: 16px 0; }
.ev-h { font-family: var(--sans); font-size: 15px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--copper2); margin: 12px 0 4px; }
.ev-card { border: 1px solid var(--line); border-left: 4px solid var(--ink4); border-radius: 4px; padding: 8px 12px; margin: 8px 0; background: var(--ink2); }
.ev-card.k-record { border-left-color: var(--copper); background: #f1e9d6; color: #1a2433; }
.ev-card.k-record .src { color: #5a4a30; }
.ev-card.k-observed { border-left-color: #7fae8a; }
.ev-card.k-report { border-left-color: var(--paper-dim); border-style: dashed; }
.ev-card h3 { font-size: 18px; margin: 0; }
.src { font-family: var(--sans); font-size: 14px; color: var(--paper-dim); margin: 2px 0 6px; }
.ev-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.req { border: 1px solid var(--line); border-radius: 6px; padding: 8px 14px 12px; margin: 12px 0; background: var(--ink2); }
.req h3 { font-size: 19px; }
.req label:not(.check) { display: grid; gap: 4px; margin: 8px 0; font-family: var(--sans); font-size: 15px; color: var(--paper2); }
select { min-height: var(--tap); padding: 6px 10px; border-radius: 4px; border: 1px solid var(--ink4); background: var(--ink); color: var(--paper); font-size: 16px; max-width: 100%; }
.receipt { font-family: var(--sans); font-size: 16px; color: var(--copper2); }
.note { display: grid; gap: 4px; margin: 10px 0; font-family: var(--sans); font-size: 15px; color: var(--paper2); }
.note textarea { width: 100%; padding: 8px 10px; border-radius: 4px; border: 1px solid var(--ink4); background: var(--paper); color: #14202f; font: 17px/1.45 var(--serif); resize: vertical; }
.dossier { border-top: 1px solid var(--line); padding: 10px 0; }
.dossier-head { display: flex; gap: 10px; align-items: center; }
.dossier details summary { cursor: pointer; min-height: var(--tap); display: flex; align-items: center; font-family: var(--sans); font-size: 16px; color: var(--copper2); }
.quote { border-left: 3px solid var(--ink4); padding-left: 10px; }
.ev-pick { border-bottom: 1px solid var(--line); }
.ending h2 { font-size: 28px; color: var(--copper2); }
.ending.end-supported h2 { color: #8fc49c; }
.ending.end-mistaken h2, .ending.end-unresolved h2 { color: var(--paper2); }

/* Room overview: people above and below a centered, scrollable briefing. */
.room { height: 100%; position: relative; overflow-y: auto; isolation: isolate; }
.room-scenery { position: absolute; inset: 0; z-index: -1; opacity: .2; pointer-events: none; }
.room-people { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); grid-template-rows: minmax(100px, 1fr) minmax(140px, 1.6fr) minmax(100px, 1fr); gap: 8px 12px; height: 100%; min-height: 380px; max-width: 1000px; margin: auto; padding: 10px max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
.room .room-person { grid-row: 1; grid-column: span 3; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 4px; min-height: 0; min-width: 0; padding: 4px; text-align: center; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--paper); }
.room .room-person:nth-child(n+3) { grid-row: 3; grid-column: span 2; }
.room .room-person:hover, .room .room-person:focus-visible { background: rgba(21,37,60,.85); border-color: var(--copper); }
.room .room-figure { display: block; width: 120px; max-width: 100%; height: 140px; max-height: calc(100% - 30px); min-height: 48px; flex: 0 1 140px; filter: drop-shadow(0 4px 8px #0008); }
.room .pick-name { display: block; font-size: 16px; line-height: 1.25; font-weight: 600; flex: 0 0 auto; }
.room-away { color: var(--copper2); font-size: 13px; }
.room-briefing { grid-row: 2; grid-column: 1 / -1; overflow-y: auto; text-align: center; align-self: stretch; min-height: 0; padding: 10px 16px; margin: 0 auto; width: 100%; max-width: 640px; background: rgba(15,27,45,.92); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); border-radius: 6px; }
.room-briefing .inquiry { text-align: left; margin-top: 12px; }
.room-instruction { font: 14px/1.4 var(--sans); color: var(--copper2); margin-top: 12px; }
.room-updates summary { min-height: 44px; cursor: pointer; padding: 8px; font-family: var(--sans); }

/* Focused conversation: one small person, no cast, scenery, briefing or tabs. */
.play { height: var(--app-height, 100dvh); grid-template-rows: auto auto auto minmax(0, 1fr); }
.play.is-focused { grid-template-rows: auto minmax(0, 1fr); }
.play.is-focused > .bar, .play.is-focused > .tabs { display: none; }
.play.is-focused > .flash { grid-row: 1; }
.play.is-focused > .view { grid-row: 2; }
.conversation-backdrop { height: 100%; min-height: 0; padding: max(6px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left)); background: #080f1bd9; }
.conversation-backdrop .talk { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); max-width: 820px; height: 100%; margin: 0 auto; background: var(--ink); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.talk .stage { height: auto; min-height: 72px; display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 6px 10px; border: 0; border-bottom: 1px solid var(--line); }
.talk .speaker { position: static; transform: none; width: 40px; height: 56px; grid-column: 1; grid-row: 1; }
.talk .nameplate { position: static; grid-column: 2; grid-row: 1; border: 0; background: none; padding: 0; max-width: none; min-width: 0; }
.talk .nameplate strong { font-size: 18px; line-height: 1.3; }
.talk .nameplate span { font-size: 14px; line-height: 1.35; }
.talk .leave-person { grid-column: 3; grid-row: 1; max-width: 120px; padding: 6px 8px; font-size: 14px; line-height: 1.2; }
.conversation-clock { display: none; }
.talk .transcript { padding: 12px 16px; }
.conversation-welcome { color: var(--paper-dim); text-align: center; margin: 24px auto; max-width: 400px; }
.talk .askbox { max-height: none; overflow: visible; }
.talk .choices { max-height: 34dvh; overflow-y: auto; }
@media (max-width: 760px) {
  .talk .stage { padding: 4px 8px; gap: 6px; min-height: 68px; }
  .talk .nameplate strong { font-size: 16px; }
  .talk .nameplate span { font-size: 13px; }
  .talk .transcript { padding: 8px 10px; }
  .talk .askbox { padding: 6px 8px 8px; }
  .room-people { gap: 6px 4px; padding-top: 6px; }
  .room .pick-name { font-size: 15px; }
  .room-briefing { padding: 8px 10px; }
}

/* Ambient motion */
.amb-hand { transform-origin: 200px 70px; animation: spin 60s linear infinite; }
.amb-hand2 { transform-origin: 60px 96px; animation: spin 60s linear infinite; }
.amb-board { animation: shimmer 6s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0%, 100% { opacity: 1; } 50% { opacity: 0.82; } }
@media (prefers-reduced-motion: reduce) {
  .amb-hand, .amb-hand2, .amb-board { animation: none; }
  * { scroll-behavior: auto !important; }
}

/* Phone: compact figure beside the conversation, picker on its own row */
@media (max-width: 760px) {
  body { font-size: 16px; }
  .bar { padding: 4px 8px; gap: 8px; }
  .case-no { display: none; }
  .case-name { font-size: 16px; }
  .clock { font-size: 14px; }
  .tab { font-size: 14px; }
  .talk { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .stage { height: 92px; border-right: 0; border-bottom: 1px solid var(--line); }
  .speaker { left: auto; right: 10px; transform: none; height: 100%; }
  .nameplate { top: 8px; left: 8px; max-width: calc(100% - 96px); padding: 4px 10px; }
  .nameplate strong { font-size: 17px; }
  .transcript { padding: 8px 10px; }
  .askbox { padding: 6px 8px 8px; max-height: 46dvh; }
  .composer textarea { min-height: 52px; }
  .picker { gap: 4px; padding: 4px; }
  .pick { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto; justify-items: center; text-align: center; padding: 2px; min-height: 52px; row-gap: 0; }
  .picker .figure.mini { grid-row: auto; width: 20px; height: 27px; }
  .pick-name { font-size: 14px; }
  .pick-role { display: none; }
  .pick[aria-label$="away"] .pick-name::after { content: " · away"; font-weight: 400; color: var(--copper2); }
  .left { display: none; }
  .askbox { max-height: 38dvh; }
  .choice { font-size: 16px; padding: 8px 10px; }
  .choices { gap: 6px; }
  .pane { padding: 10px 12px 40px; }
}
@media (max-width: 760px) and (max-height: 700px) {
  .stage { height: 76px; }
  .composer textarea { min-height: 46px; }
  .composer-row .hint { font-size: 14px; }
}
@media (max-width: 380px) {
  .tab { font-size: 13px; }
  .modebar > span { display: none; }
}

/* Give the answer room to breathe; explanations stay available on demand. */
.short-hint { display: none; }
.rating-details { margin: 3px 0; font-family: var(--sans); }
.rating-details summary, .ending details summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; gap: 8px; font-size: 15px; }
.rating-why { color: var(--paper-dim); }
@media (max-width: 760px) {
  .stage { height: 64px; }
  .nameplate { top: 3px; padding: 3px 8px; }
  .nameplate strong { font-size: 16px; line-height: 1.25; }
  .nameplate span { font-size: 13px; line-height: 1.3; }
  .picker { gap: 4px; padding: 3px 4px calc(3px + env(safe-area-inset-bottom)); }
  .pick { min-height: 44px; grid-template-rows: 1fr; }
  .picker .figure.mini { display: none; }
  .pick-name { font-size: 14px; }
  .askbox { max-height: none; overflow: visible; padding: 4px 8px 6px; }
  .modebar { gap: 4px; margin: 0 0 4px; flex-wrap: nowrap; }
  .modebar > span { display: none; }
  .modebar .seg { flex: 1; min-width: 0; padding: 4px 6px; font-size: 14px; }
  .composer { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 8px; }
  .composer-label, .composer .count { display: none; }
  .composer textarea { grid-column: 1; grid-row: 1; height: 64px; min-height: 64px; resize: none; padding: 6px 8px; font-size: 16px; }
  .composer-row { display: contents; }
  .composer-row .btn { grid-column: 2; grid-row: 1; min-width: 92px; padding: 6px 8px; font-size: 14px; }
  .composer-row .hint { grid-column: 1 / -1; grid-row: 2; font-size: 12px; line-height: 1.4; }
  .long-hint { display: none; }
  .short-hint { display: inline; }
  .transcript { padding: 6px 8px; }
  article.x { margin: 6px 0; padding: 6px 8px; }
  article.x .who { font-size: 12px; line-height: 1.35; margin: 2px 0; }
  article.x .q, article.x .a { margin: 3px 0; }
  article.x .atm { display: none; }
  .choices { max-height: 33dvh; overflow-y: auto; }
}
