/* Visual QA: preserve PC-98 art, repair panel geometry and overlay clearance. */
html { scroll-padding-top: calc(var(--top, 122px) + 8px); scroll-padding-bottom: calc(var(--ui-bottom, 40px) + 76px); }
/* Empty notification space must never steal clicks from the page behind it. */
.toasts { pointer-events: none; }
.toasts > .toast { pointer-events: auto; }
/* Scaling an ancestor of a fixed panel changes its containing block mid-transition. */
body[data-view="phone"] .screens.zoom-in,
html.pc98 body[data-view="phone"] .screens.zoom-in {
  animation: panelFadeIn 180ms steps(3);
}
@keyframes panelFadeIn { from { opacity: 0; } }

/* The breakpoint must follow the panel width, not the browser window width. */
.screen[data-screen="vault"] > .win { container-type: inline-size; }
.vt-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 192px), 1fr)); }
.vt-spot > div { min-width: 0; }
.vt-spot dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.vt-spot dd, .vt-name, .vt-set > span { overflow-wrap: anywhere; }
.vt-spot-pic .px-box { inset: auto; width: 100%; }
@container (max-width: 520px) {
  .vt-spot { grid-template-columns: minmax(0, 1fr); }
  .vt-spot-pic { width: min(100%, 240px); max-width: 240px; justify-self: center; }
  .vt-set { grid-template-columns: minmax(0, 1fr) minmax(40px, 1fr) 40px; }
}

.inbox-pop { max-height: min(46vh, calc(100dvh - var(--top, 132px) - 64px)); overflow-y: auto; }
.fx-hero .fx-stats > div { min-width: 0; }
.fx-map-wrap { min-width: 0; align-self: start; }
.fx-map-wrap .fx-map-caption, html.pc98 .fx-map-wrap .fx-map-caption {
  position: static; margin-top: 6px; font: 12px/1.4 var(--mono); padding: 4px 6px; pointer-events: none;
}
body.mkt-fit .chartwin .chart-wrap { min-height: min(240px, calc(var(--mkt-h, 640px) * 0.5)); }

@media (max-width: 760px) {
  /* A 32px PC-98 override made the four city stats collide on small phones. */
  .fx-hero, html.pc98 .fx-hero { flex-wrap: wrap; gap: 8px; }
  .fx-hero .fx-stats, html.pc98 .fx-hero .fx-stats {
    display: grid !important; width: 100%; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px;
  }
  html.pc98 .fx-hero .fx-stats strong { font: 20px/1.25 var(--mono); }
  html.pc98 .fx-hero .fx-stats .fx-economy { font-size: 16px; overflow-wrap: anywhere; }
  .fx-hero .fx-stats small { white-space: nowrap; font-size: 8px; }
  html.pc98 .fx-map-caption { top: auto; bottom: 6px; left: 6px; font: 12px/1.2 var(--mono); padding: 4px 6px; pointer-events: none; }
  /* Do not cut the date/age with an invisible overflow mask. */
  .hud-clock b, .hud-clock span { white-space: normal; overflow-wrap: anywhere; }
  html.pc98 .hud-clock b, html.pc98 .hud-clock span { white-space: normal; line-height: 1.6; }
  .toasts { top: auto; bottom: calc(var(--ui-bottom, 89px) + 15px); }
  .inbox-pop, .snd-pop { bottom: calc(var(--ui-bottom, 89px) + 15px); }
  .inbox-pop { max-height: min(46dvh, calc(100dvh - var(--top, 132px) - 116px)); }
  .screen[data-screen="vault"] > .win { padding-bottom: 8px; }
}

/* Desktop-width phones in landscape otherwise leave a 96px phone/106px life scroller. */
@media (min-width: 761px) and (max-height: 520px) {
  body[data-view="phone"] .screen[data-screen="phone"] > .win,
  body[data-view="life"] .screen[data-screen="life"] > .win,
  body[data-view="life"] .screen[data-screen="vault"] > .win {
    position: relative; inset: auto; width: min(100%, 640px); margin: 12px auto 80px;
    max-height: none; overflow: visible; animation: none;
  }
  body[data-view="phone"] .screens, body[data-view="life"] .screens { pointer-events: auto; }
  body[data-view="phone"] .thread { max-height: none; }
  body.sheet-off[data-view="life"] .screen[data-screen="life"] > .win { width: min(100%, 640px); }
}
@media (prefers-reduced-motion: reduce) {
  .screens.zoom-in, html.pc98 .screens.zoom-in, .screen, html.pc98 .screen,
  body[data-view="phone"] .screens.zoom-in, html.pc98 body[data-view="phone"] .screens.zoom-in,
  .screen > .win { animation: none !important; }
}
