/* Touch additions are isolated from narrow mouse-driven windows. */
.ht-touch-camera, .ht-touch-actions, .ht-touch-hud, .ht-touch-news, .ht-guide-toggle { display: none; }
.tk-package-toggle { display: contents; }

@media (pointer: coarse) {
  #v-board { display: none; }   /* the cash button carries the countdown on a phone */
  html, body { overscroll-behavior: none; }
  .ht-app { --ht-bottom: calc(128px + env(safe-area-inset-bottom)); height: 100dvh; }
  .ht-app button, .ht-app a, .ht-app input { touch-action: manipulation; }
  .ht-app button { -webkit-tap-highlight-color: transparent; min-height: 44px; min-width: 44px; }
  .ht-app button:active:not(:disabled) { filter: brightness(0.9); }
  .ht-app .pv-btn, .ht-app .ht-hchip, .ht-app .ht-tab, .ht-app .ht-win-x, .ht-app .ht-guide-x { min-width: 44px; min-height: 44px; height: auto; }
  .ht-app input:not([type=checkbox]):not([type=range]), .ht-app select, .ht-app textarea { font-size: 16px; min-height: 44px; }
  button.ht-hchip:hover, .ht-tool:hover { transform: none; }
  .ht-top { top: calc(8px + env(safe-area-inset-top)); left: calc(60px + env(safe-area-inset-left)); right: calc(8px + env(safe-area-inset-right)); height: 44px; display: block; }
  .ht-top > .ht-top-left { width: 100%; display: block; }
  .ht-bar { height: 44px; padding: 0 8px; margin-right: 166px; flex-wrap: nowrap; backdrop-filter: none; -webkit-backdrop-filter: none; }
  .ht-name { display: flex; align-items: center; height: 44px; width: 100%; }
  .ht-name h1 { font-size: 13px; line-height: 1.2; }
  .ht-name::after { display: none; }
  .ht-name:hover h1, .ht-name:focus-visible h1 { visibility: visible; }
  .ht-touch-hud { position: absolute; z-index: 6; top: calc(8px + env(safe-area-inset-top)); right: calc(8px + env(safe-area-inset-right)); display: flex; gap: 4px; }
  .ht-touch-hud .ht-hchip { font-size: 11px; padding: 0 7px; justify-content: center; }
  #touch-vitals { min-width: 84px; }
  #touch-clock { min-width: 74px; }
  .ht-vitals, .ht-clock { display: none; position: fixed; top: calc(60px + env(safe-area-inset-top)); left: calc(8px + env(safe-area-inset-left)); right: calc(8px + env(safe-area-inset-right)); padding: 8px; border-radius: 10px; background: var(--app-cream); z-index: 3; }
  .ht-vitals-open .ht-vitals { display: flex; flex-wrap: wrap; }
  .ht-vitals .ht-hchip { flex: 1 1 auto; justify-content: center; }
  .ht-clock-open .ht-clock { display: flex; }
  .ht-date { flex: 1; font-size: 11px; }
  .ht-speeds { width: 100%; height: 44px; flex: 1 1 240px; }
  .ht-speed { min-width: 44px; }
  .ht-clock .ht-sound { justify-content: center; }
  .ht-guide { position: fixed; top: calc(60px + env(safe-area-inset-top)); left: calc(8px + env(safe-area-inset-left)); width: calc(100% - 88px - env(safe-area-inset-left) - env(safe-area-inset-right)); padding: 0 8px; max-height: calc(100dvh - 200px); overflow-y: auto; }
  .ht-guide-toggle { display: block; width: 100%; min-height: 44px; padding: 6px 0; background: transparent; border: 0; color: inherit; font: 600 11px/1.4 var(--app-hud-font); text-align: left; }
  .ht-guide:not(.ht-guide-expanded) .hd, .ht-guide:not(.ht-guide-expanded) ol { display: none; }
  .ht-guide.ht-guide-expanded { width: calc(100% - 16px - env(safe-area-inset-left) - env(safe-area-inset-right)); padding-bottom: 10px; z-index: 2; }
  .ht-guide.ht-guide-expanded li { display: grid; }
  .ht-guide .hd { align-items: center; margin: 0; }
  .ht-touch-news { display: flex; position: absolute; z-index: 6; top: calc(60px + env(safe-area-inset-top)); right: calc(8px + env(safe-area-inset-right)); width: 64px; font-size: 11px; justify-content: center; padding: 0 4px; }
  .ht-notices { display: none; position: fixed; top: calc(108px + env(safe-area-inset-top)); left: calc(8px + env(safe-area-inset-left)); right: calc(8px + env(safe-area-inset-right)); width: auto; max-width: none; max-height: calc(100dvh - 260px); overflow-y: auto; overscroll-behavior: contain; background: var(--app-cream); padding: 6px; border-radius: 10px; }
  .ht-news-open .ht-notices { display: flex; }
  .ht-tickers, .ht-ticker { width: 100%; }
  .ht-ticker-open { min-height: 44px; }
  .ht-ticker-close { width: 44px; height: 44px; }
  .ht-toolbar { left: calc(8px + env(safe-area-inset-left)); right: calc(8px + env(safe-area-inset-right)); bottom: calc(8px + env(safe-area-inset-bottom)); max-width: none; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; padding: 6px; overflow: visible; }
  .ht-toolbar .ht-pair { display: contents; }
  .ht-toolbar .ht-sep { display: none; }
  .ht-toolbar .ht-tool { min-width: 0; height: 48px; padding: 4px 2px; font-size: 10px; border: 1px solid var(--app-chip-line); border-radius: 7px; background: var(--app-chip); }
  .ht-hint, .ht-pointer { display: none; }
  .pv-tip.text { max-width: min(360px, calc(100vw - 16px)); max-height: calc(100dvh - 80px); overflow-y: auto; pointer-events: auto; font-size: 14px; line-height: 1.5; }
  .ht-touch-camera { position: absolute; z-index: 5; right: calc(8px + env(safe-area-inset-right)); top: calc(110px + env(safe-area-inset-top)); display: flex; flex-direction: column; gap: 4px; padding: 4px; }
  .ht-touch-camera .ht-zbtn { width: 44px; height: 44px; font-size: 12px; }
  .ht-touch-camera #touch-floor-down { font-size: 10px; line-height: 1.15; white-space: normal; padding: 0; }
  .ht-mini { display: none; right: calc(64px + env(safe-area-inset-right)); top: calc(110px + env(safe-area-inset-top)); bottom: auto; }
  .ht-mini.ht-map-open { display: block; }
  .ht-mini .ht-zoom { display: none; }
  #minimap { touch-action: none; }
  .ht-touch-actions { display: block; position: absolute; z-index: 6; left: calc(8px + env(safe-area-inset-left)); bottom: var(--ht-bottom); width: min(370px, calc(100% - 16px - env(safe-area-inset-left) - env(safe-area-inset-right))); padding: 10px; background: var(--app-toast); font: 500 12px/1.4 var(--app-hud-font); }
  #touch-room-actions .ht-touch-actions { position: static; width: auto; padding: 8px 0 0; background: transparent; backdrop-filter: none; }
  .ht-touch-buttons { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
  .ht-touch-buttons .pv-btn { min-height: 44px; min-width: 44px; font-size: 12px; padding: 6px 10px; }
  .ht-place { left: calc(8px + env(safe-area-inset-left)); bottom: var(--ht-bottom); width: min(370px, calc(100% - 16px - env(safe-area-inset-left) - env(safe-area-inset-right))); min-width: 0; max-width: none; }
  .ht-place .how { display: none; }
  .ht-place .menu { display: none; }
  .ht-step button { width: 44px; height: 44px; }
  .ht-place .door { min-height: 44px; }
  .ht-app[data-screen="title"] .ht-touch-camera, .ht-app[data-screen="title"] .ht-touch-hud, .ht-app[data-screen="title"] .ht-touch-news { display: none; }
  .ht-win, .ht-win.ht-wide { left: calc(8px + env(safe-area-inset-left)) !important; right: calc(8px + env(safe-area-inset-right)); top: calc(60px + env(safe-area-inset-top)) !important; bottom: var(--ht-bottom); width: auto; max-width: none; max-height: none !important; }
  .ht-win-head { flex: none; padding: 4px 8px 4px 12px; cursor: default; }
  .ht-win-body { min-height: 0; flex: 1; overscroll-behavior: contain; }
  .ht-win-x { flex: none; }
  .ht-app:has(.ht-win:not(.ht-tucked)) .ht-guide, .ht-app:has(.ht-win:not(.ht-tucked)) .ht-place, .ht-app:has(.ht-win:not(.ht-tucked)) > .ht-touch-actions { visibility: hidden; }
  .ht-modal { padding: calc(60px + env(safe-area-inset-top)) calc(8px + env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-left)); }
  .ht-modal-card { max-height: 100%; overflow-y: auto; overscroll-behavior: contain; padding: 16px; }
  .ht-title { padding: calc(60px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left)); }
  .ht-talks { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .tk-stage { width: 100%; height: 100%; max-height: 100%; }
  .tk-main { flex: 1; }
  .tk-card { display: flex; flex-direction: column; width: 100%; height: 100%; overflow: hidden; }
  .tk-touch-scroll { min-height: 0; flex: 1; overflow-y: auto; overscroll-behavior: contain; }
  .tk-touch-scroll > .row { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px; }
  .tk-foot { flex: none; position: static; padding: 8px; background: var(--app-cream); }
  .tk-foot .row.acts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) 44px; gap: 4px; }
  .tk-foot .ht-note { grid-column: 1 / -1; }
  .tk-foot .ht-note:empty { display: none; }
  .tk-foot .pv-btn { font-size: 12px; line-height: 1.2; padding: 6px; white-space: normal; }
  .tk-foot .tk-x { margin: 0; }
  .tk-tactic, .tk-take, .tk-seg button, .tk-sw { min-height: 44px; min-width: 44px; }
  .tk-seg { flex: none; }
  .tk-sw input { width: 24px; height: 24px; }
  .tk-card input[type=range], .tk-packs input[type=range] { min-height: 44px; touch-action: pan-y; }
  .tk-head { grid-template-columns: 44px 1fr; gap: 10px; padding: 12px; }
  .tk-head .tk-face { width: 44px; height: 44px; }
  .tk-head .say { margin-top: 4px; }
  .tk-clock { grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: space-between; }
  .tk-days { font-size: 20px; }
  .tk-deal { margin: 10px; }
  .tk-row { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 6px; }
  .tk-row > .k { grid-column: 1 / -1; }
  .tk-hd > span:first-child { display: none; }
  .tk-row .y { flex-wrap: wrap; gap: 4px; }
  .tk-row .tk-seg button { min-width: 44px; padding: 0 6px; }
  .tk-row .tk-take { white-space: normal; }
  .tk-intel-4 .row { grid-template-columns: minmax(0, 1fr) repeat(3, 60px); font-size: 11px; }
  .tk-reply-wrap { padding: calc(60px + env(safe-area-inset-top)) calc(8px + env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-left)); }
  .tk-reply, .tk-packs { max-height: 100%; overflow-y: auto; overscroll-behavior: contain; }
  .tk-reply .ft, .tk-packs .ft { position: sticky; bottom: -16px; background: var(--app-cream); padding-block: 8px; }
  .tk-pk:not(.all) { grid-template-columns: 44px 1fr 56px; }
  .tk-pk .c { grid-column: 2 / -1; grid-row: 2; flex-wrap: wrap; }
  .tk-package-toggle { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; }
  .tk-pk input[type=checkbox] { width: 24px; height: 24px; }
  .ht-toggle { min-height: 44px; }

}

@media (pointer: coarse) and (orientation: landscape) {
  .ht-app { --ht-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .ht-toolbar { grid-template-columns: repeat(10, minmax(0, 1fr)); }
  .ht-bar { max-width: 380px; }
  .ht-guide { max-width: 370px; }
  .ht-guide.ht-guide-expanded { max-width: 440px; }
  .ht-clock, .ht-vitals { left: auto; width: 390px; }
  .ht-notices { left: auto; width: 360px; max-height: calc(100dvh - 188px); }
  .ht-place { padding: 8px; max-height: calc(100dvh - 138px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); overflow-y: auto; }
  .ht-touch-actions { max-height: calc(100dvh - 138px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); overflow-y: auto; }
  #touch-room-actions .ht-touch-actions { max-height: none; overflow: visible; }
  /* A short screen has no room for both: the placement card or the tool actions take the guide's place. */
  .ht-app:has(.ht-place:not([hidden])) .ht-guide, .ht-app:has(> .ht-touch-actions:not([hidden])) .ht-guide { visibility: hidden; }
  .ht-win, .ht-win.ht-wide { left: calc(60px + env(safe-area-inset-left)) !important; right: auto; top: calc(8px + env(safe-area-inset-top)) !important; bottom: calc(8px + env(safe-area-inset-bottom)); width: min(420px, calc(100% - 76px - env(safe-area-inset-left) - env(safe-area-inset-right))); }
  .ht-talks { padding-top: calc(8px + env(safe-area-inset-top)); padding-left: calc(60px + env(safe-area-inset-left)); }
  .tk-head { grid-template-columns: 44px minmax(0, 1fr) 160px; }
  .tk-clock { grid-column: auto; flex-direction: column; align-items: flex-end; }
  .tk-row { grid-template-columns: 100px minmax(0, 1fr) 150px; }
  .tk-row > .k { grid-column: auto; }
  .tk-hd > span:first-child { display: block; }
  .tk-foot .row.acts { grid-template-columns: minmax(0, 1fr) repeat(3, auto) 44px; }
  .tk-foot .ht-note { grid-column: auto; }
  .tk-foot .ht-note:empty { display: block; }
}
