#modal > #closeModal {
  position: sticky;
  top: 0;
  float: right;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: 0 0 8px 12px;
  padding: 0;
  z-index: 2;
}
#modal > #modalContent > h2:first-of-type,
#modal > #modalContent > .visit-panel > h2 {
  overflow-wrap: anywhere;
}
#modalContent > .eyebrow { padding-inline-end: 54px; }
.quest-intro-details {
  clear: both;
  margin-top: 1rem;
  padding: .75rem .9rem;
  border: 1px solid #c4d4d9;
  border-radius: 8px;
}
.quest-intro-details summary { color: #16555d; font-weight: 700; cursor: pointer; }
#questStartStatus:empty { display: none; }
.quest-floor-progress { font-size: .87rem; }
.visit-panel { --visit-ink:#122633; --visit-teal:#006773; --visit-paper:#eaf3f3; color:var(--visit-ink); }
.visit-panel h2 { line-height:1.1; }
.visit-step { color:var(--visit-teal); font-size:.88rem; font-weight:700; }
.visit-stops { padding:0; margin:1rem 0 0; list-style:none; counter-reset:stops; }
.visit-stops li { counter-increment:stops; }
.visit-stops button {
 display:grid; grid-template-columns:2rem minmax(0,1fr) auto; gap:.6rem; align-items:center;
 width:100%; min-height:48px; padding:.5rem .65rem; text-align:left; color:var(--visit-ink);
 background:transparent; border:0; border-top:1px solid #c6d7d9; border-radius:0;
}
.visit-stops button::before { content:counter(stops,decimal-leading-zero); color:var(--visit-teal); font-weight:700; }
.visit-stops button:hover { background:var(--visit-paper); }
.visit-stops span { color:#435764; font-size:.8rem; }
.visit-fields { display:grid; gap:.45rem; margin:1rem 0; clear:both; }
.visit-fields label { font-weight:700; }
.visit-fields select { width:100%; min-height:44px; padding:.55rem; border:1px solid #839ba3; border-radius:6px; font:inherit; background:#fff; color:var(--visit-ink); }
.visit-result { padding:.85rem 1rem; background:var(--visit-paper); border-inline-start:3px solid var(--visit-teal); }
.visit-result h3 { margin:0; font-size:1.1rem; }
.visit-result p { margin:.4rem 0; }
.visit-actions { display:flex; flex-wrap:wrap; gap:.6rem; margin-top:1rem; }
.visit-actions button:not(.primary) { min-height:44px; padding:.6rem .8rem; color:var(--visit-ink); background:#fff; border:1px solid #829aa3; }
@media(max-width:760px){
 body:not(.walking) .floor-rail { display:none!important; }
 #modal > #closeModal { top:0; }
 #modal > #modalContent > h2:first-of-type,
 #modal > #modalContent > .visit-panel > h2 { font-size:clamp(1.4rem,5.5vw,2rem); }
 .quest-intro-actions { clear:both; }
 .visit-stops button { grid-template-columns:1.65rem minmax(0,1fr); }
 .visit-stops span { grid-column:2; }
}

/* Exhibit dialogs use a separate toolbar so the close control never covers text. */
#modal:has(.visit-panel) {
  --visit-dialog-height: calc(100svh - 24px);
  width: min(670px, calc(100vw - 24px));
  max-height: var(--visit-dialog-height);
  padding: 52px 0 0;
  overflow: hidden;
}
#modal:has(.visit-panel) > #closeModal {
  position: absolute;
  top: 6px;
  inset-inline-end: 8px;
  margin: 0;
}
#modal:has(.visit-panel) > #modalContent {
  max-height: calc(var(--visit-dialog-height) - 54px);
  overflow: auto;
  overscroll-behavior: contain;
  padding: 0 clamp(16px,4vw,34px) 20px;
}
.visit-panel h2 { margin: .35rem 0 .65rem; }
.visit-panel .visit-step { margin: 0; }
.visit-case {
  display:flex; justify-content:space-between; gap:.45rem 1rem; flex-wrap:wrap;
  padding:.65rem .8rem; border-block:1px solid #c6d7d9; font-size:.9rem;
}
.visit-case strong { color:var(--visit-teal); }
.visit-case-stages {
  display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:.35rem;
  padding:0; margin:.8rem 0; list-style:none; font-size:.77rem;
}
.visit-case-stages li { border-top:3px solid #bfd1d6; padding:.4rem .2rem 0; overflow-wrap:anywhere; }
.visit-case-stages li[aria-current] { border-color:var(--visit-teal); color:var(--visit-teal); font-weight:700; }
.visit-fields { grid-template-columns:repeat(auto-fit,minmax(min(100%,210px),1fr)); gap:.7rem; }
.visit-fields > div { display:grid; align-content:start; gap:.25rem; min-width:0; }
.visit-floor-list { display:grid; gap:.35rem; margin-top:1rem; }
.visit-floor-list button {
  display:grid; grid-template-columns:2.4rem minmax(0,1fr); gap:.2rem .55rem; align-items:center;
  text-align:left; min-height:48px; color:var(--visit-ink); background:#fff; border:1px solid #b9cbd0;
  border-radius:7px; padding:.5rem .75rem;
}
.visit-floor-list button[aria-current] { background:var(--visit-paper); border-color:var(--visit-teal); }
.visit-floor-list strong { grid-row:1 / span 2; color:var(--visit-teal); }
.visit-floor-list small { grid-column:2; color:#435764; }
#floorSwitch { display:none; }
@media (max-width:760px) {
  body.walking .floor-rail { padding:0; border:0; background:transparent; box-shadow:none; right:8px; }
  body.walking .floor-rail [data-floor] { display:none; }
  body.walking #floorSwitch { display:block; padding:.45rem; width:63px; height:auto; min-height:44px; color:#fff; background:#132139; border:1px solid #8195b3; font-size:.75rem; }
  #modal:has(.visit-panel) { --visit-dialog-height: calc(100svh - max(24px,env(safe-area-inset-top) + env(safe-area-inset-bottom) + 8px)); }
  .visit-actions button { flex:1 1 9rem; min-height:44px; }
}

.city-journal h3 { margin:1rem 0 .6rem; line-height:1.25; }
.city-journal .city-stops button {
  width:100%; min-height:44px; text-align:left; white-space:normal;
  background:#fff; border:1px solid #b9cbd0; color:var(--visit-ink); border-radius:7px;
}
.city-journal .city-stops button:disabled { opacity:.65; }
.city-journal .city-stops small { color:var(--visit-teal); }
.city-journal #cityFeedback:empty { display:none; }
.city-journal #cityFeedback { color:#16555d; }
.light-era { display:flex; align-items:center; gap:.5rem; color:#182b3c; }
.light-era select { min-height:44px; padding:.4rem; font:inherit; }

.boot-actions { display:grid; gap:.6rem; width:min(300px,calc(100% - 48px)); margin:1rem auto 0; text-align:center; }
.boot-actions a { display:grid; place-items:center; min-height:44px; border-radius:8px; color:#e6faf8; text-decoration:none; border:1px solid #64828d; }
.boot-actions a.primary { background:#086c73; color:#fff; }
#mobileWalkBar { display:none; }
#scene,.mobile-move,.mobile-move button { touch-action:none; -webkit-user-select:none; user-select:none; }
.light-mode .light-route .quest-hud:not([hidden]) {position:static!important; width:auto!important; margin:1rem 0;}
.light-mode .light-era {color:#e9f5f5;}
.light-mode .light-era select {background:#25364d;color:#edf7f6;border:1px solid #7390a6;border-radius:6px;}
.light-mode .light-actions > :is(a,button) {min-height:44px;display:inline-flex;align-items:center;text-decoration:none;}
.light-mode .light-location {scroll-margin-top:.75rem;}
.light-mode #lightRoomActions .quest-collect {color:#192333;}

@media (max-width:760px) {
 body:not(.light-mode) { --touch-gutter:12px; --touch-top:max(12px,env(safe-area-inset-top)); --touch-bottom:max(12px,env(safe-area-inset-bottom)); }
 body.walking #navigationDock, body.walking.quest-active #navigationDock {
  left:max(var(--touch-gutter),env(safe-area-inset-left));right:max(var(--touch-gutter),env(safe-area-inset-right));
  top:calc(68px + var(--touch-top));max-width:none;gap:6px;
 }
 body.walking #mobileWalkBar {
  width:100%; display:grid; grid-template-columns:minmax(0,1fr) auto auto; align-items:center; gap:4px;
  padding:4px 4px 4px 10px; min-height:50px; border:1px solid #526982; border-radius:12px; background:#142439ed;
 }
 #mobileLocation { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-weight:700;font-size:.79rem; }
 body.walking #mobileWalkBar button { display:block; min-height:44px; width:auto; padding:0 8px; color:#edf7f6; background:#22394d; border:1px solid #5c7487; border-radius:8px; font-size:.68rem; }
 body.walking #navigationDock #location {width:100%!important;max-width:100%!important;}
 body.walking #navigationDock #location:not(.location-expanded) .location-actions {display:none!important;}
 body.walking #navigationDock .perspective-toggle {width:100%; grid-template-columns:repeat(3,minmax(0,1fr));}
 body.walking #navigationDock .perspective-toggle button {height:auto;min-height:44px;white-space:normal;}
 body.walking:not(.mobile-tools-open) #navigationDock :is(.top-nav,.perspective-toggle,#location),
 body.walking:not(.mobile-tools-open) :is(footer,.quest-hud,.observer-controls,.guide,.minimap,.staff-talk) {display:none!important;}
 body.walking.mobile-tools-open #navigationDock {
  max-height:min(52svh,350px);overflow:auto;overscroll-behavior:contain;
 }
 body.walking.mobile-tools-open #navigationDock #mobileWalkBar {position:sticky;top:0;z-index:1;}
 body.walking.mobile-tools-open .quest-hud {bottom:calc(65px + var(--touch-bottom))!important;}
 body.walking.mobile-tools-open .observer-controls {display:none!important;}
 body.walking.mobile-tools-open .mobile-move,
 body.walking.mobile-tools-open .interact,
 body.walking.mobile-tools-open .quest-collect {display:none!important;}
 body.walking .floor-rail {display:none!important;}
 body.walking .mobile-move {
  display:grid; grid-template-columns:repeat(3,44px); grid-template-rows:repeat(2,44px);gap:5px;
  width:auto;left:max(var(--touch-gutter),env(safe-area-inset-left));bottom:var(--touch-bottom)!important;
 }
 body.walking .mobile-move[hidden] {display:none!important;}
 .mobile-move > button {grid-column:2;}
 .mobile-move > div {grid-column:1/-1;display:contents;}
 body.walking .mobile-move button {display:grid;place-items:center;width:44px;height:44px;min-height:44px;margin:0;padding:0;border-radius:8px;line-height:1;}
 body.walking :is(.interact,.quest-collect) {
  left:auto!important;right:max(var(--touch-gutter),env(safe-area-inset-right))!important;bottom:var(--touch-bottom)!important;
  transform:none!important;max-width:calc(100vw - 175px);min-height:44px;
  padding:7px 10px;border-radius:8px;line-height:1.2;text-align:left;white-space:normal;
 }
 body.walking .quest-collect {bottom:calc(var(--touch-bottom) + 53px)!important;}
 body.walking .interact kbd {display:none;}
 body.walking #toggleInterface,body.cinema-mode #toggleInterface {
  top:var(--touch-top);min-height:44px;border-radius:9px;
 }
 body.cinema-mode #toggleInterface {right:max(var(--touch-gutter),env(safe-area-inset-right));}
 body.walking:not(.mobile-tools-open) .context-credit {bottom:calc(var(--touch-bottom) + 100px);font-size:8px;}
 body.walking:not(.mobile-tools-open) .context-credit:not(.show-credit) {opacity:.8;}
 body.light-mode .quest-hud:not([hidden]) {display:block!important;}
}
@media(max-width:760px){
 body.walking.mobile-tools-open #navigationDock .quest-hud:not([hidden]),
 body.walking.mobile-tools-open.observer-view #navigationDock .observer-controls {
  position:static!important;transform:none!important;width:100%!important;
  inset:auto!important;margin:0;max-width:none!important;
 }
 body.walking.mobile-tools-open.observer-view #navigationDock .observer-controls {display:block!important;}
}
@media(max-width:760px){
 body.walking #movePad:not([hidden]) {display:grid;justify-items:stretch;align-items:stretch;bottom:var(--touch-bottom)!important;}
 body.walking.mobile-tools-open #movePad:not([hidden]),
 body.cinema-mode #movePad:not([hidden]) {display:none!important;}
 #movePad [data-move="forward"] {grid-area:1/2;}
 #movePad [data-move="left"] {grid-area:2/1;}
 #movePad [data-move="back"] {grid-area:2/2;}
 #movePad [data-move="right"] {grid-area:2/3;}
 body.walking:not(.mobile-tools-open) #toast {
  top:auto;bottom:calc(var(--touch-bottom) + 113px);
  width:max-content;max-width:calc(100vw - 2 * var(--touch-gutter));
  font-size:12px;padding:.6rem .8rem;
 }
 body.walking.mobile-tools-open #toast {top:auto;bottom:calc(var(--touch-bottom) + 62px);}
}
@media(max-width:760px){
 .mobile-location-stack {display:grid;gap:2px;min-width:0;}
 #mobileQuestBadge {display:none;color:#f2d491;font-size:.64rem;line-height:1;}
 .quest-active #mobileQuestBadge {display:block;}
}

/* One high-contrast action at the coin; the equipment action reappears after collection. */
body.walking .quest-collect:not([hidden]) {
 color:#171e29!important;background:#f8de9d!important;border-color:#ffe9ba!important;
}
body.walking .quest-collect:disabled {opacity:.88;}
@media (max-width:699px) {
 body.walking .quest-collect:not([hidden]) {bottom:var(--touch-bottom)!important;}
}

#cityInspectTouch { display:none; }
@media (max-width:760px) {
 body.walking.city-on-foot:not(.mobile-tools-open):not(.cinema-mode) #cityInspectTouch {
  display:block;
  position:fixed;
  z-index:20;
  top:calc(124px + var(--touch-top));
  left:max(var(--touch-gutter),env(safe-area-inset-left));
  min-height:44px;
  padding:7px 12px;
  color:#eaf6fa;
  background:#182a41;
  border:1px solid #7390a6;
  border-radius:9px;
 }
}
