/* Tidemark — touch layouts (phones, foldables, tablets). Everything here is scoped to body.touch; the desktop design in
   style.css is untouched. The interface is laid out in real screen pixels around the scene port (see
   runtime/layout.js), sized from one unit that grows with the screen: about 15px on a phone, 22px on a Fold unfolded
   or a tablet. The port and panel rectangles arrive as --px/--py/--pw/--ph and --dx/--dy/--dw/--dh.
     l-stack: scene on top, panel below      l-wide: panel over the scene's foot      l-side: panel on the right */

html { touch-action: manipulation; }
body.touch {
  --u: clamp(15px, calc(9px + 1.5vmin), 22px);
  --fs: min(var(--u) * 1.6675, 29.9px);   /* what is said: about 25.5px on a phone, 30px unfolded (times its Fonts setting) */
  --tap: max(44px, calc(var(--u) * 2.35));
  --gut: max(10px, calc(var(--u) * .66));
  --chamfer: calc(var(--u) * .8);
  --sl: env(safe-area-inset-left, 0px); --sr: env(safe-area-inset-right, 0px);
  --st: env(safe-area-inset-top, 0px); --sb: env(safe-area-inset-bottom, 0px);
  overscroll-behavior: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
body.touch img { -webkit-user-drag: none; }
body.touch .kh, body.touch .keyhelp, body.touch .desk-only, body.touch .cursorlabel, body.touch #examine .hint { display: none !important; }
body.touch .touch-only { display: block; }
body.touch #stage::after { display: none; }   /* print grain: invisible at phone pixel densities, not worth compositing */

/* ---------- scene port and hud ---------- */
body.touch #frame { inset: auto; display: block; overflow: hidden; touch-action: none; background: #000; }
body.touch #stage { position: absolute; will-change: transform; }
body.touch #hud { position: fixed; inset: 0; z-index: 2; pointer-events: none; }
body.touch #portui { display: block; position: absolute; left: var(--px); top: var(--py); width: var(--pw); height: var(--ph); pointer-events: none; }
body.touch #dock { display: flex; flex-direction: column; position: absolute; left: var(--dx); top: var(--dy); width: var(--dw); height: var(--dh);
  padding: var(--gut) calc(var(--gut) + var(--sr)) calc(var(--gut) + var(--sb)) calc(var(--gut) + var(--sl)); gap: var(--gut); container: dock / size; }
body.touch.l-stack #dock { background: linear-gradient(180deg, #0d1011, #07090a 60%); border-top: 1px solid rgba(200,160,74,.4); }
body.touch.l-side #dock { background: linear-gradient(90deg, #0d1011, #07090a); border-left: 1px solid rgba(200,160,74,.4); padding-left: var(--gut); padding-top: calc(var(--gut) + var(--st)); }
body.touch.l-stack #dock { padding-left: calc(var(--gut) + var(--sl)); }
body.touch.l-wide #dock { pointer-events: none; padding-top: 0; }
body.touch.l-wide #dock > * { pointer-events: auto; }
body.touch.cine #dock { display: none; }
body.touch:not(.insession) #dock { visibility: hidden; }
body.touch .panel { clip-path: polygon(var(--chamfer) 0, 100% 0, 100% calc(100% - var(--chamfer)), calc(100% - var(--chamfer)) 100%, 0 100%, 0 var(--chamfer)); }
body.touch .panel::before { clip-path: polygon(var(--chamfer) 0, 100% 0, 100% calc(100% - var(--chamfer)), calc(100% - var(--chamfer)) 100%, 0 100%, 0 var(--chamfer)); }
body.touch .btn { font-size: calc(var(--u) * 1.345 * var(--ts-buttons)); padding: 0 calc(var(--u) * 1.1); min-height: var(--tap); gap: 10px; justify-content: center; }
body.touch .btn svg { width: calc(var(--u) * 1.3); height: calc(var(--u) * 1.3); }
body.touch .btn:active, body.touch .verb:active, body.touch .item:active, body.touch .tb:active, body.touch .cell:active, body.touch .slot:active { filter: brightness(1.35); }
@media (hover: none) { body.touch .btn:hover { border-color: rgba(230,219,195,.45); } body.touch .btn.gold:hover { border-color: #f0d38c; } }

/* ---------- top bar: Auto, Skip, History, Court Record, Menu ---------- */
body.touch #tbar { display: none; position: absolute; top: calc(var(--st) + var(--u) * .45); right: calc(var(--sr) + var(--u) * .45); gap: calc(var(--u) * .35); align-items: center; pointer-events: auto; z-index: 3; }
body.touch.insession #tbar { display: flex; }
body.touch #tbar.docked { position: relative; top: auto; right: auto; order: -1; justify-content: flex-end; flex: none; }
body.touch.cine #tbar .tb:not([data-a=skip]):not([data-a=menu]) { display: none; }
body.touch #tbar [data-a=skip] { touch-action: none; }   /* held down to fast-forward: a drifting finger mustn't cancel it */
body.touch.cine #tbar { position: fixed; top: calc(var(--st) + var(--u) * .5); right: calc(var(--sr) + var(--u) * .5); opacity: .8; }
body.touch #rotatehint { display: none; }
@media (max-aspect-ratio: 5/7) { body.touch.l-stack.cine #rotatehint { display: flex; }
}
body.touch #rotatehint { position: absolute; left: 0; right: 0; bottom: calc(var(--sb) + var(--u) * 1.5); justify-content: center; gap: 8px; align-items: center;
  font-size: calc(var(--u) * 1.076 * var(--ts-buttons)); color: var(--bone-dim); opacity: 0; animation: rotatehint 7s ease 1.5s 1; pointer-events: none; }
body.touch #rotatehint svg { width: 1.6em; height: 1.6em; stroke: currentColor; fill: none; stroke-width: 1.5; }
@keyframes rotatehint { 0%, 100% { opacity: 0; } 12%, 80% { opacity: .85; } }
body.touch .modal:has(~ .modal) { visibility: hidden; }
body.touch #tbar .tb { width: var(--tap); height: var(--tap); display: flex; align-items: center; justify-content: center; border-radius: 50%; cursor: pointer;
  background: rgba(8,10,11,.62); border: 1px solid rgba(230,219,195,.28); color: var(--bone); }
body.touch #tbar .tb svg { width: 52%; height: 52%; stroke: currentColor; fill: none; stroke-width: 1.7; }
body.touch #tbar .pill { width: auto; padding: 0 calc(var(--u) * .8); border-radius: calc(var(--tap) / 2); font: 600 calc(max(13.8px, calc(var(--u) * 0.897)) * var(--ts-buttons))/1 var(--display-font); letter-spacing: .2em; text-transform: uppercase; }
body.touch #tbar .tb.on { background: linear-gradient(180deg, #d8b25a, #b88f3c); color: #16130c; border-color: #f0d38c; }
body.touch #tbar.docked .tb { background: rgba(255,255,255,.035); }
body.touch #tbar.docked .tb.on { background: linear-gradient(180deg, #d8b25a, #b88f3c); }

/* ---------- dialogue panel ---------- */
body.touch #dlg { position: relative; left: auto; right: auto; bottom: auto; height: auto; flex: 1 1 auto; min-height: 0; order: 1;
  display: none; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; grid-template-areas: "name" "text" "verbs"; }
body.touch #dlg.on { display: grid; }
body.touch.l-wide #dlg { flex: 0 1 auto; margin-top: auto; min-height: min(100%, calc(var(--u) * 8.5)); }
body.touch #dlg .nameplate { grid-area: name; position: relative; left: auto; top: auto; height: calc(var(--u) * 1.95); margin-left: calc(var(--chamfer) + 4px); justify-self: start;
  padding: 0 calc(var(--u) * 2.2) 0 calc(var(--u) * .9); }
body.touch :is(#dlg, #ceplate) .name { font-size: calc(var(--u) * 1.049 * var(--ts-names)); letter-spacing: .26em; }   /* (and the statements') */
body.touch :is(#dlg, #cebox) .text { font-size: calc(var(--fs) * var(--ts-dialogue)); line-height: 1.4; }
body.touch #dlg .text { grid-area: text; position: relative; left: auto; top: auto; right: auto; overflow-y: auto; overscroll-behavior: contain;
  padding: calc(var(--u) * .35) calc(var(--u) * 1.1) calc(var(--u) * 1.5); }
body.touch #dlg.noverbs .text { right: auto; }
body.touch #dlg .adv { right: calc(var(--u) * .9); bottom: calc(var(--u) * .65); border-left-width: 9px; border-right-width: 9px; border-top-width: 11px; }
body.touch #dlg.noverbs .adv { right: calc(var(--u) * .9); }
/* the four investigation verbs: a row of big buttons under the text; a column at its side when the panel is wide */
body.touch #verbs { grid-area: verbs; position: relative; right: auto; top: auto; bottom: auto; width: auto; border-left: 0; border-top: 1px solid rgba(230,219,195,.16);
  padding: calc(var(--u) * .5); display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: calc(var(--u) * .4); }
body.touch #dlg.noverbs #verbs { display: none; }
body.touch .verb { height: auto; min-height: calc(var(--tap) * 1.2); padding: 6px 2px; flex-direction: column; justify-content: center; gap: 4px; font-size: calc(var(--u) * 1.2375 * var(--ts-menus));
  color: var(--bone); border: 1px solid rgba(230,219,195,.2); background: rgba(255,255,255,.035); }
body.touch .verb svg { width: calc(var(--u) * 1.45); height: calc(var(--u) * 1.45); }
body.touch .verb.sel::before { display: none; }
body.touch[data-input=kbd] .verb.sel, body.touch[data-input=pad] .verb.sel { border-color: var(--brass); color: #f0e2bd; }
body.touch .verb .dot { left: auto; right: 7px; top: 7px; }
@container dock (min-width: 720px) {
  body.touch #dlg { grid-template-columns: minmax(0, 1fr) clamp(190px, 26%, 300px); grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "name verbs" "text verbs"; }
  body.touch #verbs { border-top: 0; border-left: 1px solid rgba(230,219,195,.2); grid-template-columns: 1fr; align-content: center; padding: calc(var(--u) * .6); }
  body.touch .verb { flex-direction: row; justify-content: flex-start; gap: calc(var(--u) * .8); padding: 0 calc(var(--u) * .9); min-height: var(--tap); font-size: calc(var(--u) * 1.345 * var(--ts-menus)); }
}
/* a wide but short panel: the verbs as a 2 x 2 block at the side */
@container dock (min-width: 720px) and (max-height: 340px) {
  body.touch #dlg { grid-template-columns: minmax(0, 1fr) clamp(260px, 36%, 420px); }
  body.touch #verbs { grid-template-columns: 1fr 1fr; }
  body.touch .verb { padding: 0 calc(var(--u) * .6); gap: calc(var(--u) * .5); }
}

/* cinematic subtitles: under the picture when the screen is upright, over its foot otherwise */
body.touch #subs { left: 50%; bottom: calc(var(--sb) + 4%); width: calc(100% - var(--gut) * 4); max-width: 60em; font-size: calc(var(--fs) * var(--ts-subtitles)); }
body.touch #subs .sname { font-size: calc(var(--u) * 0.9415 * var(--ts-names)); margin-bottom: 4px; }
body.touch.l-stack #subs { top: calc(var(--dy) + var(--u) * 1.4); bottom: auto; }

/* ---------- cross-examination ---------- */
body.touch #patience { right: calc(var(--sr) + var(--u) * .8); top: calc(var(--st) + var(--u) * .75); gap: 4px; }
body.touch.insession:not(.cine):has(#portui > #tbar) #patience { top: calc(var(--st) + var(--tap) + var(--u) * 1); }
body.touch #patience svg { width: calc(var(--u) * 1.2); height: calc(var(--u) * 1.2); filter: drop-shadow(0 1px 2px #000); }
body.touch #recordbtn { display: none; }
body.touch #ceplate { position: relative; left: auto; bottom: auto; order: 2; height: calc(var(--u) * 1.95); padding: 0 calc(var(--u) * 2.6) 0 calc(var(--u) * .9);
  align-self: flex-start; margin: 0 0 calc(var(--gut) * -1) calc(var(--chamfer) + 4px); flex: none; }
body.touch #cebox { position: relative; left: auto; bottom: auto; width: auto; height: auto; order: 3; flex: 1 1 auto; min-height: calc(var(--u) * 4); }
body.touch.l-wide #cebox { flex: 0 1 auto; }
body.touch.l-wide #ceplate { margin-top: auto; }
body.touch #cebox .text { position: relative; left: auto; top: auto; right: auto; max-height: 100%; overflow-y: auto; padding: calc(var(--u) * .9) calc(var(--u) * 1.1) calc(var(--u) * 1); }
body.touch #cebox .rule { display: none; }
body.touch #cebtns { position: relative; left: auto; bottom: auto; order: 4; gap: calc(var(--u) * .4); flex: none; }
body.touch #cebtns.on { display: grid; grid-template-columns: var(--tap) minmax(0, 1fr) minmax(0, 1fr) var(--tap); }
body.touch #cebtns .btn { height: var(--tap); width: auto; padding: 0 6px; font-size: calc(var(--u) * 1.345 * var(--ts-buttons)); }
body.touch #cebtns .btn.wide { width: auto; }
body.touch #cebtns .btn.sq { width: auto; font-size: min(calc(var(--u) * 2.152 * var(--ts-buttons)), calc(var(--tap) * .7)); }   /* (an arrow: never bigger than its button) */
body.touch #cebtns [data-a=prev] { order: 0; } body.touch #cebtns [data-a=press] { order: 1; } body.touch #cebtns [data-a=present] { order: 2; } body.touch #cebtns [data-a=next] { order: 3; }
body.touch #cebtns [data-a=history] { display: none; }

/* ---------- examine ---------- */
body.touch #examine { cursor: default; }
body.touch #examine .hs { border-width: calc(2.5px * var(--inv, 1)); }
body.touch #examine .hs.done::after { width: calc(30px * var(--inv, 1)); height: calc(30px * var(--inv, 1)); font-size: calc(19.55px * var(--inv, 1) * var(--ts-examine)); right: calc(4px * var(--inv, 1)); top: calc(4px * var(--inv, 1)); }
body.touch #examine .hs.picked { border-color: var(--brass); background: rgba(230,200,120,.14); box-shadow: 0 0 calc(18px * var(--inv, 1)) rgba(230,200,120,.45); }
body.touch .exdock { display: flex; order: 5; flex: 1 1 auto; flex-direction: column; gap: calc(var(--u) * .5); min-height: 0; overflow-y: auto; padding: calc(var(--u) * .4) calc(var(--u) * .5); }
body.touch.l-wide .exdock { flex: 0 1 auto; margin-top: auto; background: rgba(9,11,12,.9); border-top: 1px solid rgba(200,160,74,.45); padding: var(--gut); }
body.touch .exdock .extitle { color: var(--brass); font-size: calc(var(--u) * 1.049 * var(--ts-examine)); }
body.touch .exdock .exhint { font-size: calc(var(--u) * 1.278 * var(--ts-examine)); color: var(--bone-dim); font-style: italic; }
body.touch .exdock .exname { font-family: var(--display-font); font-weight: 600; font-size: calc(var(--u) * 1.8155 * var(--ts-examine)); color: #f0e2bd; min-height: 1.3em; }
body.touch .exdock { overflow: hidden; }
body.touch .exdock .extext { flex: 0 1 auto; min-height: 0; display: flex; flex-direction: column; }
body.touch .exdock .extext .mitems { flex: 0 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: calc(var(--u) * .5); }
body.touch .exdock .exrow { display: flex; flex: none; gap: calc(var(--u) * .4); margin-top: auto; }
body.touch .exdock .exrow .btn { flex: 1 1 0; padding: 0 6px; }
body.touch .exdock .exglow.on { border-color: var(--brass); color: var(--brass); }
body.touch .panarrow { position: absolute; top: 50%; translate: 0 -50%; width: var(--tap); height: calc(var(--tap) * 1.5); display: none; align-items: center; justify-content: center;
  pointer-events: auto; background: rgba(8,10,11,.55); border: 1px solid rgba(200,160,74,.5); color: var(--brass); cursor: pointer; animation: panhint 1.6s ease-in-out 2; }
body.touch .panarrow svg { width: 60%; height: 60%; stroke: currentColor; fill: none; stroke-width: 2; }
body.touch .panarrow.left { left: calc(var(--sl) + 4px); border-radius: 0 10px 10px 0; } body.touch .panarrow.right { right: 4px; border-radius: 10px 0 0 10px; }
body.touch.examining[data-pan*=l] .panarrow.left, body.touch.examining[data-pan*=r] .panarrow.right { display: flex; }
@keyframes panhint { 0%,100% { opacity: .85; } 50% { opacity: .45; } }

/* ---------- list sheets: talk topics, places, choices ---------- */
body.touch #ui > .menu { position: absolute; left: var(--dx); width: var(--dw); right: auto; top: auto; bottom: 0; translate: none; max-height: max(62%, calc(var(--dh) + 8%));
  padding: calc(var(--u) * .8) 0 0; display: flex; flex-direction: column; overflow: hidden; background: rgba(10,12,13,.975); clip-path: none;
  border-top: 1px solid var(--brass); box-shadow: 0 -12px 40px rgba(0,0,0,.6); animation: sheetin 200ms ease-out; z-index: 4; }
body.touch #ui > .menu::before { display: none; }
body.touch.l-side #ui > .menu { top: 0; max-height: none; border-top: 0; border-left: 1px solid var(--brass); animation-name: sidein; }
body.touch.l-wide #ui > .menu { left: 50%; translate: -50% 0; width: min(94%, 680px); max-height: 82%; }
body.touch #ui > .menu .mscroll { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
body.touch #ui > .menu .mitems { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }   /* (the title and Back stay put) */
@keyframes sheetin { from { transform: translateY(24px); opacity: 0; } }
@keyframes sidein { from { transform: translateX(24px); opacity: 0; } }
body.touch .menu .mtitle { padding: 0 calc(var(--u) * 1.2) calc(var(--u) * .5) calc(var(--u) * 1.2 + var(--sl)); font-size: calc(var(--u) * 1.076 * var(--ts-menus)); }
body.touch .menu .item { display: flex; align-items: center; min-height: var(--tap); padding: calc(var(--u) * .3) calc(var(--u) * 1.2) calc(var(--u) * .3) calc(var(--u) * 3.497 * max(1, var(--ts-menus)) + var(--sl));
  font-size: calc(var(--u) * 1.5065 * var(--ts-menus)); line-height: 1.25; color: var(--bone); border-bottom: 1px solid rgba(230,219,195,.07); }
body.touch .menu .item.seen { color: #9a9181; }
body.touch .menu .item.sel { background: none; }
body.touch[data-input=kbd] .menu .item.sel, body.touch[data-input=pad] .menu .item.sel { background: linear-gradient(90deg, rgba(200,160,74,.22), rgba(200,160,74,0)); color: #f3e6c4; }
body.touch .menu .item .new { left: calc(var(--u) * .5 + var(--sl)); font-size: calc(max(12.65px, calc(var(--u) * .713)) * var(--ts-menus)); letter-spacing: .08em; }
body.touch .menu .item .tick { left: calc(var(--u) * 1.1 + var(--sl)); top: 50%; translate: 0 -50%; }
body.touch #ui > .menu .back { margin: auto 0 0; min-height: calc(var(--tap) + var(--sb)); padding: 0 0 var(--sb); display: flex; align-items: center; justify-content: center;
  background: #0e1112; border-top: 1px solid rgba(230,219,195,.16); font-size: calc(var(--u) * 1.076 * var(--ts-menus)); flex: none; }
/* a list that scrolls: a bobbing ▼ while more is hidden below, a grey ▲ while some is scrolled past above, at the right
   end of the options, where no label reaches (hub.js scrollHints; a tap on one scrolls a page). The list leaves room so
   a selected item is never under an arrow. */
body.touch .mscroll .mitems { scroll-padding: calc(var(--tap) * .7) 0; scrollbar-width: none; }   /* (the arrows say it scrolls: no system scrollbar) */
body.touch .mscroll .mitems::-webkit-scrollbar { display: none; }
body.touch :is(.mscroll, .dmore) .more { display: flex; position: absolute; right: calc(var(--u) * .3); z-index: 2; align-items: center; justify-content: center;
  width: var(--tap); height: var(--tap); opacity: 0; visibility: hidden; transition: opacity 180ms, visibility 180ms; cursor: pointer; color: var(--brass); }
body.touch :is(.mscroll, .dmore) .more.up { top: 0; color: #7f7869; } body.touch :is(.mscroll, .dmore) .more.down { bottom: 0; }
body.touch :is(.mscroll, .dmore).up .more.up, body.touch :is(.mscroll, .dmore).down .more.down { opacity: 1; visibility: visible; }
body.touch :is(.mscroll, .dmore) .more i { display: flex; filter: drop-shadow(0 1px 3px #000); }
body.touch :is(.mscroll, .dmore) .more svg { width: max(22px, calc(var(--u) * 1.3)); height: max(22px, calc(var(--u) * 1.3)); fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
body.touch :is(.mscroll, .dmore).down .more.down i { animation: morebob 1.3s ease-in-out 3 forwards; }   /* (a few bobs when it appears, then still) */
body.touch :is(.mscroll, .dmore) .more:active i { filter: drop-shadow(0 1px 3px #000) brightness(1.4); }
@keyframes morebob { 0%, 100% { transform: translateY(-2px); } 50% { transform: translateY(3px); } }
@media (prefers-reduced-motion: reduce) { body.touch :is(.mscroll, .dmore).down .more.down i { animation: none; } }

/* ---------- modals and the pause menu ---------- */
body.touch .modal { min-width: 0; width: min(calc(100% - var(--gut) * 2), 30em); max-height: calc(100% - var(--gut) * 2); overflow-y: auto; padding: calc(var(--u) * 1.5) calc(var(--u) * 1.3); }
body.touch .modal .mt { font-size: calc(var(--u) * 1.345 * var(--ts-menus)); letter-spacing: .26em; }
body.touch .modal .mb { margin: calc(var(--u) * 1) 0 calc(var(--u) * 1.4); font-size: calc(var(--u) * 1.4525 * var(--ts-menus)); }
body.touch .modal .mb span { font-size: inherit !important; }
body.touch .modal .row { flex-wrap: wrap; gap: calc(var(--u) * .6); }
body.touch .modal .row .btn { flex: 1 1 8em; white-space: normal; }
body.touch .modal .menu { padding: calc(var(--u) * .6) 0 0 !important; }
body.touch .modal .menu .item { padding-left: calc(var(--u) * 1.2); justify-content: center; font-size: calc(var(--u) * 1.5065 * var(--ts-menus)); }
body.touch .modal .menu .item:last-child { border-bottom: 0; }
body.touch .modal:has(.cards) { width: min(calc(100% - var(--gut) * 2), 44em); }
body.touch .modal:has(.cards.one) { width: min(calc(100% - var(--gut) * 2), 30em); }
body.touch .cards { grid-template-columns: repeat(auto-fit, minmax(min(100%, 12em), 1fr)); gap: calc(var(--u) * .6); margin-top: calc(var(--u) * .8); }
body.touch .modal .cards .slot { height: auto; }   /* (as tall as its text: a narrow card wraps more than a save slot) */
body.touch .modal .cards .slot img { height: auto; align-self: stretch; }
body.touch .modal .bar { height: calc(var(--u) * .55); margin: calc(var(--u) * .2) 0 calc(var(--u) * .6); }
body.touch .modal .barv { font-size: calc(var(--u) * 1.15 * var(--ts-menus)); }
body.touch #dlbar { right: auto; left: calc(var(--sl) + var(--u) * .6); top: calc(var(--st) + var(--u) * .5); gap: calc(var(--u) * .4); }   /* (top right is the top bar's) */
body.touch #dlbar .pct { font-size: calc(var(--u) * .8 * var(--ts-notices)); }
body.touch #dlbar .track { width: calc(var(--u) * 5); height: 3px; }
@media (max-height: 520px) {   /* short landscape screens: the pause menu in two columns so it needs no scrolling */
  body.touch .modal { width: min(calc(100% - var(--gut) * 2), 40em); padding: calc(var(--u) * .8) calc(var(--u) * 1); }
  body.touch .modal .menu { display: grid !important; grid-template-columns: 1fr 1fr; column-gap: calc(var(--u) * 1); }
  body.touch .modal .menu .item { min-height: 42px; }
}

/* ---------- full-screen panels: Court Record, settings, saves, history, notebook, pointing ---------- */
body.touch .fullpanel { inset: 0; border: 0; background: rgba(8,10,11,.985); display: flex; flex-direction: column; overflow: hidden;
  padding: var(--st) var(--sr) var(--sb) var(--sl); animation: panelin 180ms ease-out; }
@keyframes panelin { from { opacity: 0; transform: translateY(12px); } }
body.touch .fullpanel .head { position: relative; left: auto; top: auto; flex: none; padding: calc(var(--u) * .95) calc(var(--tap) + 6.5em) calc(var(--u) * .7) calc(var(--u) * 1.1); font-size: calc(var(--u) * 1.278 * var(--ts-buttons)); letter-spacing: .3em; line-height: 1.3; }
body.touch .fullpanel .head.crowded { padding-top: calc(var(--tap) + 8px); padding-right: calc(var(--u) * 1.1); overflow-wrap: anywhere; }
body.touch .fullpanel .close { top: calc(var(--st) + 4px); right: calc(var(--sr) + 4px); min-height: var(--tap); display: flex; align-items: center; padding: 0 calc(var(--u) * 1); font-size: calc(var(--u) * 1.076 * var(--ts-buttons)); z-index: 2; }
body.touch .fullpanel .pprompt { position: relative; left: auto; right: auto; top: auto; flex: none; padding: 0 calc(var(--u) * 1.1) calc(var(--u) * .6); font-size: calc(var(--u) * 1.345 * var(--ts-record)); }
body.touch .tabs { position: relative; left: auto; top: auto; display: flex; flex-wrap: wrap; gap: 0; flex: none; border-bottom: 1px solid rgba(230,219,195,.14); }
body.touch .fullpanel.presenting .tabs, body.touch .fullpanel.presenting .grid, body.touch .fullpanel.presenting .detail { top: auto; }
body.touch .tabs .tab { flex: 1 0 0; min-width: max-content; min-height: var(--tap); display: flex; align-items: center; justify-content: center; padding: 0 calc(var(--u) * .5); font-size: calc(var(--u) * 1.049 * var(--ts-buttons)); letter-spacing: .2em; }

/* Court Record: picture and description on top, the evidence grid in the thumb's reach, Present at the bottom. The grid
   is pages of big squares (record.js lays out as many as fit and sets the tracks), turned with ◀ ▶ or a swipe */
body.touch .fullpanel.record { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto minmax(0, 1fr) auto auto auto;
  grid-template-areas: "head" "prompt" "tabs" "detail" "grid" "pager" "actions"; }
body.touch .fullpanel.record .head { grid-area: head; } body.touch .fullpanel.record .pprompt { grid-area: prompt; } body.touch .fullpanel.record .tabs { grid-area: tabs; }
body.touch .fullpanel.record .detail { grid-area: detail; } body.touch .fullpanel.record .grid { grid-area: grid; } body.touch .fullpanel.record .actions { grid-area: actions; }
body.touch .fullpanel.record .pager { grid-area: pager; }
/* the exhibit and its description scroll as one; the arrows sit in a box laid over the same cell, which lets taps through */
body.touch .fullpanel.record .detail { scrollbar-width: none; } body.touch .fullpanel.record .detail::-webkit-scrollbar { display: none; }
body.touch .fullpanel.record .dmore { grid-area: detail; position: relative; z-index: 2; pointer-events: none; }
body.touch .fullpanel.record .dmore .more { pointer-events: auto; }
body.touch .fullpanel .grid { position: relative; left: auto; top: auto; width: auto; height: min(40vh, calc(var(--tap) * 4.2 + 28px)); max-height: none; display: grid;
  gap: 8px; padding: 10px calc(var(--u) * .8); overflow: hidden; justify-content: center; align-content: center; touch-action: none;
  border-top: 1px solid rgba(230,219,195,.14); }
body.touch .grid .cell { width: auto; height: auto; }
body.touch .grid .cell .cname { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 5px 4px; font-size: calc(max(13.8px, calc(var(--u) * .759)) * var(--ts-record)); line-height: 1.15; color: #efe4c9;
  text-align: center; background: linear-gradient(180deg, rgba(0,0,0,0), rgba(0,0,0,.85) 45%); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; pointer-events: none;
  hyphens: auto; overflow-wrap: anywhere; }   /* (a word wider than the tile, at a large Fonts size, breaks rather than being cut) */
body.touch .grid .gempty { grid-column: 1 / -1; align-self: center; justify-self: center; color: var(--bone-dim); font-style: italic; font-size: calc(var(--u) * 1.345 * var(--ts-record)); }
body.touch .pager { display: flex; align-items: center; justify-content: center; gap: calc(var(--u) * 1); padding: 0 calc(var(--u) * .8) 4px; }
body.touch .pager:empty { display: none; }
body.touch .pager .pg { min-width: min(calc(var(--tap) * 1.8), 24%); font-size: calc(var(--u) * 1.4795 * var(--ts-buttons)); }
body.touch .pager .pg.disabled { opacity: .3; pointer-events: none; }
body.touch .pager .pno { min-width: min(4.5em, 30%); text-align: center; font-size: calc(var(--u) * 1.2105 * var(--ts-buttons)); color: var(--bone-dim); letter-spacing: .12em; }
body.touch .grid .cell .ico { font-size: calc(var(--u) * 0.8875 * var(--ts-record)) !important; padding: 4px !important; }
body.touch .fullpanel .detail { position: relative; left: auto; top: auto; right: auto; bottom: auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; padding: calc(var(--u) * .7) calc(var(--u) * 1.1); }
body.touch .detail .dname { order: -2; }
body.touch .detail .dview { order: -1; width: 100%; height: auto; aspect-ratio: 98 / 47; max-height: 42vh; margin: 0 0 calc(var(--u) * .7); flex: none; }
body.touch .detail .dname { font-size: calc(var(--u) * 1.883 * var(--ts-record)); line-height: 1.2; margin-bottom: calc(var(--u) * .5); }
body.touch .detail .ddesc { margin-top: calc(var(--u) * .4); font-size: calc(var(--u) * 1.372 * var(--ts-record)); max-width: none; }
body.touch .fullpanel > .actions { position: relative; right: auto; bottom: auto; display: flex; padding: calc(var(--u) * .5) calc(var(--u) * .8); gap: 10px; }
body.touch .fullpanel > .actions:empty { display: none; }
body.touch .fullpanel > .actions .btn { flex: 1; min-height: calc(var(--tap) * 1.1); font-size: calc(var(--u) * 1.4795 * var(--ts-buttons)); }
/* documents in the detail view flow as readable text instead of a fixed-size page */
body.touch .dview:has(> .doc) { aspect-ratio: auto; max-height: none; border: 0; background: none; }
body.touch .dview > .doc { position: relative; inset: auto; padding: calc(var(--u) * .9) calc(var(--u) * 1); font-size: calc(var(--u) * 1.278 * var(--ts-documents)); overflow: visible; }
body.touch .doc .dt { font-size: calc(var(--u) * 1.049 * var(--ts-documents)); }
body.touch .doc.print { font-size: calc(var(--u) * 1.076 * var(--ts-documents) * var(--fit, 1)); }
body.touch .doc.ghost .gl { font-size: calc(var(--u) * 1.412 * var(--ts-documents)); }
body.touch .dview .doc table { font-size: calc(var(--u) * 1.049 * var(--ts-documents)) !important; }
body.touch .dview .btn { font-size: calc(var(--u) * 0.9955 * var(--ts-buttons)) !important; padding: 4px 8px !important; min-height: 34px; }
body.touch .dview .tapeplay .btn { height: auto; min-height: var(--tap); padding: 0 calc(var(--u) * 1.2) !important; font-size: calc(var(--u) * 1.412 * var(--ts-buttons)) !important; }   /* (the tape's one control: a full-size target) */
body.touch .mapfoot { padding: 2px 8px 6px; font-size: calc(var(--u) * 1.049 * var(--ts-documents)); }
body.touch .dview.zoomable { cursor: zoom-in; }
body.touch .zoomhint { position: absolute; right: 8px; bottom: 8px; width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; font-size: calc(23px * var(--ts-buttons));
  color: var(--bone); background: rgba(0,0,0,.6); border: 1px solid rgba(230,219,195,.35); border-radius: 50%; pointer-events: none; }
@media (min-width: 760px) and (min-aspect-ratio: 1/1) {
  body.touch .fullpanel.record { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); grid-template-rows: auto auto auto minmax(0, 1fr) auto;
    grid-template-areas: "head head" "prompt prompt" "tabs tabs" "grid detail" "pager actions"; }
  body.touch .fullpanel .grid { height: auto; border-top: 0; border-right: 1px solid rgba(230,219,195,.14); }
}
body.touch .zoomview { position: absolute; inset: 0; background: #000; display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 5; }
body.touch .zoomview .zbox { position: relative; overflow: hidden; background: #0c0e0f; border: 1px solid #444; }
body.touch .zoomview .zinner { position: absolute; inset: 0; }
body.touch .zoomview .zinner img.full { width: 100%; height: 100%; object-fit: contain; }
body.touch .zoomview .zinner > .doc { position: absolute; inset: 0; overflow: hidden; }
body.touch .zoomview .zclose { position: absolute; top: calc(var(--st) + 4px); right: calc(var(--sr) + 4px); min-height: var(--tap); display: flex; align-items: center; padding: 0 calc(var(--u) * 1);
  font: 600 calc(var(--u) * 1.076 * var(--ts-buttons)) var(--display-font); letter-spacing: .3em; text-transform: uppercase; color: var(--bone); cursor: pointer; }
body.touch .zoomview .zhelp { position: absolute; bottom: calc(var(--sb) + 10px); font-size: calc(var(--u) * 1.076 * var(--ts-buttons)); color: var(--bone-dim); }

/* pointing at the proof inside a piece of evidence */
body.touch .fullpanel.pointing .phwrap { flex: 0 1 auto; min-height: 0; display: flex; flex-direction: column; }
body.touch .fullpanel.pointing .pointhint { position: relative; left: auto; right: auto; top: auto; flex: 0 1 auto; min-height: 0; overflow-y: auto; margin: 0 calc(var(--u) * .8) calc(var(--u) * .6); padding: 8px 12px; font-size: calc(var(--u) * 1.278 * var(--ts-record)); text-align: left; }
body.touch .fullpanel.pointing .pointhint .touch-only { display: inline; }
body.touch .fullpanel.pointing .pointhint .rotnote { display: none; }
@media (max-aspect-ratio: 5/7) { body.touch .fullpanel.pointing .pointhint .rotnote { display: inline; } }
body.touch .pwrap { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; container-type: size; padding: 0 calc(var(--u) * .5); }
body.touch .pointview { position: relative; left: auto; right: auto; top: auto; bottom: auto; width: min(100cqw, 200cqh); aspect-ratio: 2 / 1; cursor: default; }
body.touch .pointer-cross { width: 26px; height: 26px; border-width: 2px; box-shadow: 0 0 0 2px rgba(0,0,0,.55); }
body.touch .pointbar.touch-only { display: flex; gap: 10px; padding: calc(var(--u) * .6) calc(var(--u) * .8) calc(var(--u) * .6); flex: none; }
body.touch .pointbar .zin, body.touch .pointbar .zout { width: var(--tap); padding: 0; font-size: min(calc(var(--u) * 1.883 * var(--ts-buttons)), calc(var(--tap) * .7)); }
body.touch .pointbar .pgo { flex: 1; min-height: calc(var(--tap) * 1.1); font-size: calc(var(--u) * 1.4795 * var(--ts-buttons)); }

/* settings */
body.touch .settings .fp-body { position: relative; inset: auto; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 calc(var(--u) * .9) calc(var(--u) * 1.2); }
body.touch .settings .row { height: auto; min-height: var(--tap); flex-wrap: wrap; gap: 4px 12px; padding: 8px 4px; font-size: calc(var(--u) * 1.345 * var(--ts-settings)); border-bottom: 1px solid rgba(230,219,195,.07); }
body.touch .settings .row .lab { width: auto; flex: 1 1 10em; line-height: 1.3; }
/* sliders: the label and value on one line, the slider full width under them (a wide screen fits all three in a row) */
body.touch .settings .row.range { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "lab val" "range range"; gap: 0 12px; }
body.touch .settings .row.range .lab { grid-area: lab; } body.touch .settings .row.range .val { grid-area: val; } body.touch .settings .row.range input { grid-area: range; width: 100%; }
@media (min-width: 640px) { body.touch .settings .row.range { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) 4.5em; grid-template-areas: "lab range val"; } }
body.touch .settings .row .val { width: auto; min-width: 3em; text-align: right; }
body.touch .settings .row .opts { display: flex; gap: 6px; flex-wrap: wrap; }
body.touch .settings .row .opt { min-height: 40px; min-width: 3.4em; display: flex; align-items: center; justify-content: center; padding: 0 12px; font-size: calc(var(--u) * 1.2105 * var(--ts-settings)); }
body.touch .settings .notes { margin-top: calc(var(--u) * 1.2); font-size: calc(var(--u) * 1.1435 * var(--ts-settings)); line-height: 1.5; }
body.touch .settings .row.sel { outline: 0; background: none; }
body.touch[data-input=kbd] .settings .row.sel { outline: 1px solid rgba(200,160,74,.45); }
body.touch input[type=range] { -webkit-appearance: none; appearance: none; height: 40px; background: transparent; }
body.touch input[type=range]::-webkit-slider-runnable-track { height: 4px; background: linear-gradient(90deg, rgba(200,160,74,.7), rgba(230,219,195,.25)); border-radius: 2px; }
body.touch input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; margin-top: -11px; border-radius: 50%; background: #d8b25a; border: 2px solid #f0d38c; box-shadow: 0 1px 4px #000; }
body.touch input[type=range]::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; background: #d8b25a; border: 2px solid #f0d38c; }

/* save / load */
body.touch .slots { position: relative; left: auto; right: auto; top: auto; bottom: auto; flex: 1 1 auto; min-height: 0; grid-template-columns: minmax(0, 1fr); gap: 10px;
  padding: 4px calc(var(--u) * .8) calc(var(--u) * .9); align-content: start; overscroll-behavior: contain; }
/* as many columns as fit slots about 340px wide (one on a phone, two from about 700px, three from about 1100px), wider
   with larger text */
body.touch .slots { grid-template-columns: repeat(auto-fill, minmax(min(100%, calc(391px * max(1, var(--ts-settings)))), 1fr)); }
body.touch .slot { height: calc(var(--u) * 8.07 * max(1, var(--ts-settings))); }
body.touch .slot img { width: 40%; max-width: calc(var(--u) * 11); }
body.touch .slot .info { padding: 8px 12px; font-size: calc(var(--u) * 1.103 * var(--ts-settings)); line-height: 1.4; overflow: hidden; }
body.touch .slot .info b { font-size: calc(var(--u) * 1.076 * var(--ts-settings)); }
body.touch .slot.sel { box-shadow: none; border-color: #3a3a33; }
body.touch[data-input=kbd] .slot.sel { border-color: var(--brass); }

/* history */
body.touch .history { position: relative; left: auto; right: auto; top: auto; bottom: auto; flex: 1 1 auto; min-height: 0; padding: 0 calc(var(--u) * 1) calc(var(--u) * 1); overscroll-behavior: contain; }
body.touch .history .h { padding: 10px 0; font-size: calc(var(--u) * 1.345 * var(--ts-history)); display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
body.touch .history .h .who { flex: 0 0 100%; font-size: calc(max(13.8px, calc(var(--u) * .851)) * var(--ts-names)); margin: 0; }
body.touch .history .h .t { flex: 1 1 0; }
body.touch .history .h .play { margin: 0; width: 40px; height: 40px; flex: none; display: flex; align-items: center; justify-content: center; border: 1px solid rgba(230,219,195,.25); border-radius: 50%; align-self: center; }

/* notebook */
body.touch .notebook .fp-body { position: relative; inset: auto; flex: 1 1 auto; overflow-y: auto; padding: 0 calc(var(--u) * 1.1) calc(var(--u) * 1); }
body.touch .notebook .lead { font-size: calc(var(--u) * 1.412 * var(--ts-history)); padding: 10px 0 10px 1.6em; line-height: 1.4; }

/* ---------- title screen ---------- */
body.touch #title { display: grid; justify-items: center; align-content: center; grid-template-areas: "logo" "sub" "items";
  padding: calc(var(--st) + var(--u)) calc(var(--sr) + var(--u)) calc(var(--sb) + max(var(--u), 9vh)) calc(var(--sl) + var(--u)); background-position: 62% center; }
body.touch.l-side #title, body.touch.l-wide #title { align-content: center; padding-bottom: calc(var(--sb) + var(--u)); }
body.touch #title .shade { background: linear-gradient(180deg, rgba(8,12,12,.72), rgba(8,12,12,.35) 34%, rgba(8,12,12,.8) 66%, rgba(8,12,12,.94)); }
body.touch #title .logo { grid-area: logo; position: relative; left: auto; top: auto; width: min(80vw, 560px, 90vh); }
body.touch #title .sub { grid-area: sub; position: relative; left: auto; top: auto; --box: min(82vw, 520px); width: var(--box); --cap: min(calc(max(13.8px, calc(var(--u) * 0.92)) * var(--ts-title)), calc(var(--box) / 21)); margin: calc(var(--u) * .5) 0 calc(var(--u) * 1.6); }
body.touch #title .items { grid-area: items; position: relative; left: auto; top: auto; align-items: center; gap: 0; }
body.touch #title .it { font-size: calc(var(--u) * 1.8155 * var(--ts-title)); min-height: var(--tap); display: flex; align-items: center; justify-content: center; padding: 0 28px; text-shadow: 0 1px 6px #000; }
body.touch #title .it.sel { color: var(--bone-dim); }
body.touch #title .it.sel::before, body.touch #title .it.sel::after { display: none; }
body.touch[data-input=kbd] #title .it.sel, body.touch[data-input=pad] #title .it.sel { color: #efd79a; }
body.touch #title .fsbtn { display: flex; position: absolute; top: calc(var(--st) + 10px); right: calc(var(--sr) + 10px); width: var(--tap); height: var(--tap); align-items: center; justify-content: center;
  border-radius: 50%; background: rgba(8,10,11,.55); border: 1px solid rgba(230,219,195,.3); color: var(--bone); cursor: pointer; }
body.touch #title .fsbtn svg { width: 52%; height: 52%; stroke: currentColor; fill: none; stroke-width: 1.7; }
body.touch.l-side #title, body.touch.l-wide #title { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); grid-template-areas: "logo items" "sub items"; column-gap: calc(var(--u) * 2); }
body.touch.l-side #title .logo, body.touch.l-wide #title .logo { width: min(44vw, 560px); align-self: end; }
body.touch.l-side #title .sub, body.touch.l-wide #title .sub { --box: min(42vw, 500px); align-self: start; }
body.touch.l-side #title .shade, body.touch.l-wide #title .shade { background: linear-gradient(90deg, rgba(8,12,12,.3), rgba(8,12,12,.55) 50%, rgba(8,12,12,.9)); }
@media (max-height: 460px) { body.touch #title .it { min-height: max(40px, calc(var(--u) * 2.4)); font-size: calc(var(--u) * 1.614 * var(--ts-title)); } }

/* ---------- toasts, cards, shouts, verdicts ---------- */
body.touch #toast { right: auto; left: 50%; translate: -50% 0; top: calc(var(--st) + var(--tap) + var(--u) * 1.2); width: min(calc(100% - var(--gut) * 2), 30em); align-items: center; }
body.touch #toast .t { padding: 8px 16px 8px 10px; font-size: calc(var(--u) * 1.2105 * var(--ts-notices)); gap: 10px; margin-bottom: 6px; }
body.touch #toast .t img, body.touch #toast .t .ico { width: calc(var(--u) * 2.6); height: calc(var(--u) * 2.6); border-width: 2px; }
body.touch #toast .t .lbl { font-size: calc(var(--u) * 0.807 * var(--ts-notices)); }
body.touch #card { padding: var(--gut); text-align: center; }
body.touch #card .c1 { font-size: calc(var(--u) * 2.2865 * var(--ts-notices)); letter-spacing: .3em; }
body.touch #card .c2 { font-size: calc(var(--u) * 1.412 * var(--ts-notices)); margin-top: 10px; }
body.touch #card .rule { width: min(70vw, 420px); margin: calc(var(--u) * 1) 0; }
body.touch #titlecard img { width: min(86vw, 700px); }
body.touch #titlecard .t2 { font-size: calc(var(--u) * 1.2105 * var(--ts-notices)); margin-top: 16px; letter-spacing: .4em; }
body.touch #shout { top: calc(var(--py) + var(--ph) * .45); left: calc(var(--px) + var(--pw) / 2); font-size: clamp(40px, min(13vw, calc(var(--ph) * .22)), 150px); }
body.touch #shout .bar { height: 1.35em; left: -.4em; right: -.4em; }
body.touch .verdict .v { font-size: clamp(38px, 11vmin, 170px); }

/* ---------- one screen laid out as two (body.ds: l-stack and l-side; see runtime/layout.js) ----------
   The scene port is the top screen: what is said (the dialogue box, the testimony and its name tab) sits over the
   scene's foot, as on desktop and on the AYN Thor's top screen; a hub leaves the scene clear. The panel is the lower
   screen, with the same rules as the Thor's (engine/dual.css): the scene faded as its ground, the top bar in the middle
   of its top row, one big ▶ while a line is up, the verbs 2 x 2, in cross-examination Press, Present and a big ◀ ▶. */
/* the box over the scene: about a third of it (the Thor's is 30%), three to four lines of text */
body.ds #hud { --sayh: clamp(calc(var(--u) * 3.2 + var(--fs) * var(--ts-dialogue) * 4.2), calc(var(--ph) * .36), calc(var(--u) * 3.2 + var(--fs) * var(--ts-dialogue) * 5.6)); }
body.ds #dock { background: #07090a; isolation: isolate; }
body.ds.insession:not(.cine) #dock::before { content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: var(--lowbg, none) center / cover no-repeat; filter: saturate(.8) brightness(.3); }
body.ds #dlg, body.ds #cebox { position: absolute; left: calc(var(--gut) + var(--sl)); right: calc(var(--gut) + var(--sr)); top: auto; bottom: var(--gut);
  width: auto; height: var(--sayh); min-height: 0; margin: 0; pointer-events: auto; }
body.l-side.ds #dlg, body.l-side.ds #cebox { right: var(--gut); }
body.ds #dlg { grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "name" "text"; }
body.ds #dlg .text { padding-bottom: calc(var(--u) * .9); }
body.ds #ceplate { position: absolute; left: calc(var(--gut) + var(--sl) + var(--chamfer) + 4px); bottom: calc(var(--gut) + var(--sayh) - 1px); margin: 0; }
/* lists sit on the panel, as on the lower screen, and never cover the scene */
body.ds.l-stack #ui > .menu { max-height: var(--dh); }/* full-screen panels are solid, as on the Thor's lower screen: the panel's big buttons never show through */
body.ds .fullpanel { background: #08090a; }
