/* The full camp remains visible at the default zoom on every screen. */
:root {
  --nav-height: 68px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html { min-width: 320px; scroll-padding: 20px 0 calc(var(--nav-height) + var(--safe-bottom) + 20px); }
body { min-width: 320px; min-height: 100svh; overflow-x: clip; }
.app-shell { min-height: 100svh; grid-template-columns: 76px minmax(0, 1fr); grid-template-rows: 72px 1fr; }
.topbar { gap: 20px; padding-inline: 30px; }
.topbar-center { font-size: 10px; margin-right: 24px; white-space: nowrap; }
.topbar-actions { gap: 8px; }
.help-button, .icon-button { min-width: 44px; min-height: 44px; }
.help-button { font-size: 12px; justify-content: center; padding-inline: 8px; }
.icon-button { border-radius: 5px; }
.icon-button svg { width: 20px; height: 20px; }
.icon-button[aria-pressed="true"] { color: var(--accent); background: #c7a37114; }
.topbar-divider { margin-inline: 4px; }
.navrail { padding: 26px 0 22px; }
.nav-main { gap: 14px; }
.rail-button { width: 64px; min-height: 64px; font-size: 10px; }
.rail-button.selected::before { left: -6px; }
.main-content { padding: 24px 28px 0; }
.chapter-header { gap: 20px; margin-bottom: 22px; }
.chapter-header h1 { font-size: clamp(27px, 2.4vw, 37px); margin: 9px 0 6px; }
.chapter-header p { display: block; font-size: 12px; line-height: 1.6; }
.eyebrow { font-size: 10px; letter-spacing: 1.4px; }
.day-clock { gap: 12px; padding-top: 12px; }
.day-clock strong { font-size: 24px; }
.day-clock span { font-size: 9px; }
.day-clock small { font-size: 11px; }
.day-clock small > span { font-size: 11px; }
.game-layout { grid-template-columns: minmax(0, 1fr) 296px; gap: 24px; align-items: start; }
.game-column, .sidebar, .player-identity, .stat { min-width: 0; }
.game-column, .sidebar, .scene-panel { scroll-margin-block: 18px; }
.scene-panel { height: clamp(430px, calc(100svh - 275px), 660px); min-height: 0; max-height: none; }
.scene-art { inset: 0; transform-origin: 50% 54%; }
.scene-art > svg { width: 100%; height: 100%; touch-action: manipulation; }
.scene-top { top: 15px; left: 18px; right: 15px; align-items: center; gap: 12px; }
.location-title { font-size: 10px; letter-spacing: 1px; }
.location-title small { font-size: 9px; margin-top: 4px; line-height: 1.5; }
.perception-toggle { min-width: 44px; min-height: 44px; font-size: 10px; gap: 8px; padding: 8px 10px; }
.perception-toggle > span:nth-child(2) { display: block; }
.regime-strip { top: 67px; left: 18px; gap: 10px; font-size: 8px; letter-spacing: .8px; }
.scene-caption { left: 68px; bottom: 23px; gap: 9px; max-width: calc(100% - 220px); }
.scene-caption p { font-size: 11px; line-height: 1.65; }
.caption-line { width: 14px; }
.compass { bottom: 21px; left: 20px; }
.scene-zoom { bottom: 17px; right: 15px; }
.scene-zoom button { width: 44px; height: 44px; font-size: 21px; }
.scene-zoom span { min-width: 36px; font-size: 10px; }
.interact-prompt { min-height: 44px; max-width: calc(100% - 30px); padding: 10px 14px; font-size: 12px; bottom: 78px; }
.hotspot-hit { stroke: transparent; stroke-width: 12px; vector-effect: non-scaling-stroke; }
.map-hotspot:focus-visible .hotspot-ring { stroke: #f1d29a; stroke-width: 3px; }
.player-bar { display: grid; grid-template-columns: minmax(150px, 1.4fr) repeat(2, minmax(92px, 1fr)) 44px; gap: 18px; padding: 17px 20px; min-height: 91px; }
.player-identity { min-width: 0; gap: 12px; flex-basis: auto; }
.player-identity h2 { font-size: 15px; gap: 8px; }
.player-identity h2 span { font-size: 10px; }
.player-identity p { font-size: 10px; line-height: 1.6; margin-top: 3px; }
.hero-portrait { width: 46px; height: 46px; }
.stat { order: initial; }
.stat > div:first-child { font-size: 11px; gap: 5px; }
.stat strong { font-size: 12px; white-space: nowrap; }
.stat strong span { font-size: 9px; }
.stat-track { height: 4px; margin-top: 10px; }
.inventory-slot { width: 44px; height: 44px; order: initial; margin-left: 0; }
.inventory-slot > span { font-size: 10px; right: 4px; }
.controls-footer { padding-block: 14px; gap: 12px; font-size: 10px; flex-wrap: wrap; }
.controls-footer > div { gap: 7px; flex-wrap: wrap; }
.controls-footer kbd { min-width: 21px; height: 22px; font-size: 10px; }
.saved-status { display: flex; font-size: 10px; }
.sidebar-tabs { height: 52px; gap: 26px; padding-inline: 20px; }
.sidebar-tabs button { min-height: 44px; font-size: 13px; }
.sidebar-tabs button > span { font-size: 10px; }
.mission-heading { padding: 20px; }
.mission-heading .eyebrow { font-size: 9px; letter-spacing: 1.3px; }
.mission-heading h2 { font-size: 26px; margin: 7px 0; }
.mission-heading p { font-size: 12px; line-height: 1.7; }
.mission-progress { height: 3px; margin-top: 16px; }
.mission-progress-label { font-size: 10px; margin-top: 8px; }
.tasks-heading { padding: 0 20px 10px; }
.tasks-heading h3 { font-size: 12px; }
.tasks-heading > span { font-size: 9px; }
.task-list { display: flex; flex-direction: column; gap: 3px; padding-inline: 10px; }
.task-card { min-height: 91px; padding: 12px 10px; gap: 10px; }
.task-card > div { min-width: 0; }
.task-card h4 { font-size: 12px; line-height: 1.5; padding-right: 6px; }
.task-card p { font-size: 11px; line-height: 1.6; margin-top: 4px; }
.task-tag { font-size: 9px; line-height: 1.5; letter-spacing: .15px; margin-top: 7px; }
.task-check { width: 14px; height: 14px; margin-top: 3px; }
.task-card.current .task-check::after { width: 6px; height: 6px; margin: 3px; }
.task-arrow { width: 14px; height: 14px; right: 8px; top: 14px; }
.watch-status { margin: 15px 20px 20px; padding-top: 17px; }
.watch-status > div:first-child { font-size: 12px; }
.watch-status p { font-size: 11px; line-height: 1.6; margin-top: 5px; }
.alert-meter { margin-top: 12px; }
.alert-meter small { font-size: 9px; }
.family-summary { padding: 16px 20px; }
.family-summary strong { font-size: 11px; }
.family-summary p { font-size: 10px; }
.family-summary .pig-portrait { width: 29px; height: 29px; }
.family-card { padding: 18px 20px; }
.family-card h3 { font-size: 14px; }
.family-card h3 small { font-size: 10px; }
.family-card p { font-size: 12px; }
.family-card .family-mood { font-size: 10px; }
.page-footer { display: flex; gap: 18px; font-size: 9px; letter-spacing: .8px; line-height: 1.7; margin-top: 20px; padding-block: 16px; }
.mobile-mission, .touch-controls { display: none; }
.camp-navigation { display: flex; min-width: 0; gap: 10px; margin-bottom: 10px; }
#camp-map-button { display: flex; flex-shrink: 0; min-height: 44px; align-items: center; gap: 8px; padding: 9px 12px; border: 1px solid #c7a37135; border-radius: 4px; font-size: 11px; color: var(--accent); }
#camp-map-button svg { width: 18px; height: 18px; }
.camp-tabs { display: flex; flex: 1; min-width: 0; gap: 4px; overflow-x: auto; overscroll-behavior-inline: contain; scrollbar-width: thin; scrollbar-color: #c7a37140 transparent; }
.camp-tabs button { min-height: 44px; flex: 1 0 auto; padding: 9px 12px; border: 1px solid #b0bba71c; border-radius: 4px; font-size: 11px; white-space: nowrap; }
.camp-tabs button[aria-selected="true"], .camp-tabs button.active { color: var(--accent); background: #c7a37110; border-color: #c7a37150; }
.region-objective { display: flex; gap: 18px; align-items: center; justify-content: space-between; padding: 16px 18px; border: 1px solid var(--line); border-top: 0; background: #1b2625; }
.region-objective > div { display: flex; flex: 1; min-width: 0; flex-direction: column; gap: 4px; }
.region-objective small { font-size: 9px; letter-spacing: 1px; color: var(--accent); }
.region-objective strong { font-size: 13px; font-weight: 500; line-height: 1.5; }
.region-objective span { font-size: 11px; line-height: 1.6; color: #94a299; }
#region-objective-action { display: flex; min-height: 44px; max-width: 45%; align-items: center; gap: 9px; padding: 10px 13px; border: 1px solid #c7a37140; border-radius: 4px; font-size: 12px; color: var(--accent); }
#region-objective-action svg { width: 17px; height: 17px; }

/* Dialog text and actions must remain useful on a small screen. */
dialog { width: min(540px, calc(100vw - 32px)); max-height: calc(100dvh - 40px); padding: 36px 32px 28px; overscroll-behavior: contain; }
.dialog-close { top: 9px; right: 9px; }
.dialog-eyebrow { font-size: 10px; line-height: 1.6; padding-right: 30px; }
.dialog-title { font-size: 29px; padding-right: 10px; }
.dialog-body { font-size: 14px; line-height: 1.85; }
.dialog-body em { font-size: 15px; }
.dialog-actions { gap: 10px; margin-top: 24px; }
.primary-button, .secondary-button { min-height: 46px; font-size: 13px; padding: 12px 16px; justify-content: center; }
.dialog-note { font-size: 11px; line-height: 1.75; }
.help-row, .settings-row { font-size: 13px; line-height: 1.6; gap: 12px; }
.help-row kbd { min-width: 24px; height: 25px; font-size: 11px; }
.settings-row button { min-width: 88px; min-height: 44px; font-size: 12px; padding: 8px 10px; }
.settings-row > span:last-child { text-align: right; }
.journal-entry time { font-size: 10px; }
.journal-entry p { font-size: 14px; }
.item-card strong { font-size: 14px; }
.item-card p { font-size: 12px; }
.toast { max-width: min(600px, calc(100vw - 28px)); font-size: 13px; bottom: max(22px, var(--safe-bottom)); line-height: 1.6; }

@media (min-width: 901px) and (max-width: 1240px) {
  .app-shell { grid-template-columns: 68px minmax(0, 1fr); }
  .topbar { padding-inline: 22px; }
  .topbar-center { margin-right: 12px; }
  .wordmark-caption { display: none; }
  .main-content { padding-inline: 22px; }
  .game-layout { grid-template-columns: minmax(0, 1fr) 272px; gap: 18px; }
  .rail-button { width: 60px; }
  .rail-button.selected::before { left: -4px; }
  .chapter-header h1 { font-size: 29px; }
  .day-clock small, .clock-divider { display: none; }
  .scene-top { left: 14px; right: 12px; }
  .perception-toggle > span:nth-child(2) { display: none; }
  .regime-strip { left: 14px; }
  .player-bar { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 44px; gap: 16px; padding: 16px; }
  .player-identity { grid-column: 1 / 3; }
  .inventory-slot { grid-column: 3; grid-row: 1; }
  .stat { grid-row: 2; }
  .hope-stat { grid-column: 2 / 4; }
  .hero-portrait { width: 42px; height: 42px; }
  .mission-heading { padding-inline: 17px; }
  .mission-heading h2 { font-size: 24px; }
  .task-card { padding-inline: 9px; }
  .task-card h4 { font-size: 12px; }
}

@media (min-width: 901px) and (max-height: 820px) {
  .app-shell { grid-template-rows: 64px 1fr; }
  .main-content { padding-top: 18px; }
  .chapter-header { margin-bottom: 17px; }
  .chapter-header h1 { font-size: 28px; margin-block: 6px; }
  .chapter-header p { font-size: 11px; }
  .day-clock { padding-top: 4px; }
  .scene-panel { height: max(430px, calc(100svh - 274px)); }
  .mission-heading { padding: 16px 18px; }
  .mission-heading h2 { font-size: 24px; }
  .mission-heading p { font-size: 11px; }
  .mission-progress { margin-top: 12px; }
  .task-card { min-height: 84px; padding-block: 10px; }
  .task-card h4 { font-size: 12px; }
  .task-card p { font-size: 10px; }
  .task-tag { font-size: 9px; margin-top: 5px; }
  .watch-status { margin-block: 12px 15px; padding-top: 14px; }
  .family-summary { padding-block: 13px; }
}

/* Tablet and phone: one continuous page with a persistent five-item rail. */
@media (max-width: 900px) {
  .app-shell { display: block; }
  .topbar { height: 64px; padding: 0 max(16px, env(safe-area-inset-left)); gap: 8px; }
  .wordmark { font-size: 18px; letter-spacing: 2.7px; gap: 9px; white-space: nowrap; }
  .brand-fence { transform: scale(.78); transform-origin: left center; width: 23px; }
  .wordmark-caption, .topbar-center, .topbar-divider, .help-button span { display: none; }
  .topbar-actions { gap: 0; }
  .help-button { padding: 0; }
  .navrail { position: fixed; z-index: 25; inset: auto 0 0; width: 100%; height: calc(var(--nav-height) + var(--safe-bottom)); display: flex; flex-direction: row; align-items: flex-start; padding: 0 max(7px, env(safe-area-inset-left)) var(--safe-bottom) max(7px, env(safe-area-inset-right)); background: #142020f5; border-top: 1px solid #c7a37125; border-right: 0; backdrop-filter: blur(16px); }
  .nav-main { flex: 4; display: flex; flex-direction: row; gap: 0; justify-content: space-around; }
  .nav-bottom { flex: 1; display: flex; flex-direction: row; justify-content: center; padding: 0; }
  .nav-main .rail-button { flex: 1; }
  .nav-bottom .rail-button { width: 100%; }
  .rail-button { min-width: 0; width: auto; height: var(--nav-height); min-height: 44px; gap: 5px; font-size: 10px; }
  .rail-button svg { width: 21px; height: 21px; }
  .rail-button.selected::before { left: 25%; right: 25%; top: 0; bottom: auto; height: 2px; width: auto; }
  .rail-button > i { right: calc(50% - 16px); top: 10px; }
  .nav-bottom .rail-decoration, .rail-version { display: none; }
  .main-content { padding: 22px max(18px, env(safe-area-inset-left)) calc(var(--nav-height) + var(--safe-bottom) + 24px) max(18px, env(safe-area-inset-right)); }
  .chapter-header { align-items: flex-start; gap: 14px; margin-bottom: 20px; }
  .chapter-header > div:first-child { min-width: 0; }
  .chapter-header h1 { font-size: clamp(26px, 4vw, 34px); line-height: 1.3; max-width: none; letter-spacing: -.8px; margin: 9px 0; }
  .chapter-header p { display: block; font-size: 12px; max-width: 480px; line-height: 1.7; }
  .eyebrow { font-size: 10px; letter-spacing: .9px; gap: 7px; }
  .day-clock { gap: 8px; padding-top: 29px; }
  .day-clock > svg { width: 21px; height: 21px; }
  .day-clock span { font-size: 9px; }
  .day-clock strong { font-size: 21px; }
  .day-clock small, .clock-divider { display: none; }
  .game-layout { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .scene-panel { height: auto; min-height: 0; max-height: none; aspect-ratio: 1000 / 870; }
  .scene-art { inset: 68px 0 44px; }
  .scene-top { top: 10px; left: 15px; right: 12px; min-height: 44px; }
  .location-title { font-size: 10px; letter-spacing: .8px; }
  .location-title small { font-size: 9px; letter-spacing: 0; }
  .perception-toggle > span:nth-child(2) { display: block; }
  .regime-strip { top: 56px; left: 15px; font-size: 8px; gap: 10px; letter-spacing: .6px; }
  .scene-vignette { background: linear-gradient(180deg, #09141c22, transparent 30%, transparent 83%, #0c181d44); }
  .scene-caption { left: 18px; bottom: 13px; max-width: calc(100% - 173px); }
  .scene-caption p { font-size: 11px; line-height: 1.5; }
  .scene-caption p br { display: none; }
  .caption-line { display: none; }
  .compass { display: none; }
  .scene-zoom { right: 11px; bottom: 9px; background: #142024d9; }
  .scene-zoom button { width: 44px; height: 44px; }
  .scene-zoom span { font-size: 10px; min-width: 35px; }
  .interact-prompt { bottom: 67px; font-size: 12px; white-space: normal; text-align: left; }
  .hotspot-hit { stroke-width: 32px; }
  .player-bar { grid-template-columns: minmax(170px, 1.3fr) repeat(2, minmax(88px, 1fr)) 44px; gap: 17px; min-height: 90px; padding: 16px 18px; }
  .player-identity { grid-column: auto; grid-row: auto; min-width: 0; flex-basis: auto; order: initial; }
  .player-identity h2 { font-size: 15px; }
  .player-identity p { font-size: 10px; }
  .hero-portrait { width: 44px; height: 44px; }
  .inventory-slot { grid-column: auto; grid-row: auto; order: initial; }
  .stat, .hope-stat { grid-column: auto; grid-row: auto; order: initial; }
  .mobile-mission { display: flex; width: 100%; min-height: 61px; padding: 10px 15px; margin-bottom: 10px; gap: 12px; text-align: left; align-items: center; border: 1px solid #c7a37127; border-radius: 4px; background: #c7a37108; }
  .mobile-mission-number { flex-shrink: 0; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; border: 1px solid #c7a37155; color: var(--accent); font-size: 12px; }
  .mobile-mission > span:nth-child(2) { display: flex; min-width: 0; flex-direction: column; gap: 3px; }
  .mobile-mission small { font-size: 9px; color: #9b9c87; letter-spacing: 1px; }
  .mobile-mission strong { font-size: 13px; line-height: 1.5; font-weight: 500; }
  .mobile-mission > svg { margin-left: auto; color: var(--accent); width: 19px; height: 19px; }
  .camp-navigation { gap: 8px; }
  #camp-map-button { font-size: 12px; padding-inline: 11px; }
  .camp-tabs button { flex: 0 0 auto; font-size: 12px; padding-inline: 14px; }
  .region-objective strong { font-size: 14px; }
  .region-objective span { font-size: 12px; }
  .controls-footer { padding-top: 12px; padding-bottom: 0; justify-content: center; }
  .controls-footer > div { display: none; }
  .saved-status { display: flex; font-size: 10px; }
  .sidebar-tabs { height: 56px; gap: 28px; }
  .sidebar-tabs button { font-size: 14px; }
  .mission-heading { padding: 22px; }
  .mission-heading .eyebrow { font-size: 10px; }
  .mission-heading h2 { font-size: 29px; }
  .mission-heading p { font-size: 13px; line-height: 1.75; }
  .mission-heading p br { display: none; }
  .mission-progress-label { font-size: 11px; }
  .tasks-heading { padding-inline: 22px; }
  .tasks-heading h3 { font-size: 13px; }
  .tasks-heading > span { font-size: 10px; }
  .task-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; padding-inline: 12px; }
  .task-card { padding: 15px 12px; min-height: 110px; gap: 12px; }
  .task-card h4 { font-size: 14px; line-height: 1.5; padding-right: 10px; }
  .task-card p { font-size: 12px; }
  .task-tag { font-size: 10px; margin-top: 8px; }
  .task-check { width: 16px; height: 16px; margin-top: 3px; }
  .task-card.current .task-check::after { width: 6px; height: 6px; margin: 4px; }
  .task-card.done .task-check::after { left: 4px; top: 3px; }
  .task-arrow { display: block; }
  .watch-status { margin: 20px 22px; padding-top: 20px; }
  .watch-status > div:first-child { font-size: 13px; }
  .watch-status p { font-size: 12px; }
  .family-summary { padding: 18px 22px; }
  .family-summary strong { font-size: 12px; }
  .family-summary p { font-size: 11px; }
  #family-cards { display: block; }
  .family-card { flex-direction: row; padding: 20px 22px; }
  .family-card h3 { font-size: 15px; }
  .family-card h3 small { display: inline; font-size: 11px; margin-left: 8px; }
  .family-card p { font-size: 13px; }
  .family-card .family-mood { font-size: 11px; }
  .page-footer { margin-top: 20px; font-size: 9px; letter-spacing: .8px; }
  .page-footer > span:last-child { display: none; }
  .toast { width: max-content; bottom: calc(var(--nav-height) + var(--safe-bottom) + 14px); }
}

/* A two-row directional pad is easy to reach and leaves the map unobscured. */
@media (pointer: coarse), (max-width: 900px) {
  .touch-controls { display: flex; gap: 20px; align-items: center; justify-content: space-between; padding: 16px 18px; margin-top: 10px; border: 1px solid #b9c4b21a; border-radius: 5px; background: #182224; }
  .touch-pad { display: grid; grid-template-columns: repeat(3, 48px); grid-template-rows: repeat(2, 46px); gap: 5px; flex-shrink: 0; }
  .touch-pad button { display: grid; place-items: center; min-width: 44px; min-height: 44px; border: 1px solid #a4b2a635; border-radius: 6px; background: #263333; color: #c6cec0; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
  .touch-pad button svg { width: 20px; height: 20px; pointer-events: none; }
  .touch-pad button[data-move="KeyW"] { grid-column: 2; grid-row: 1; }
  .touch-pad button[data-move="KeyA"] { grid-column: 1; grid-row: 2; }
  .touch-pad button[data-move="KeyS"] { grid-column: 2; grid-row: 2; }
  .touch-pad button[data-move="KeyD"] { grid-column: 3; grid-row: 2; }
  .touch-pad button:active, .touch-pad button.pressed, .touch-pad button[aria-pressed="true"] { color: #efe0bf; border-color: #c7a371; background: #5a513b; box-shadow: inset 0 1px 6px #0004; }
  .touch-context { display: flex; min-width: 0; flex: 1; max-width: 300px; flex-direction: column; gap: 10px; align-items: stretch; }
  #touch-hint { font-size: 11px; color: #98a69d; line-height: 1.6; }
  #touch-action { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 10px 12px; background: #c7a371; border: 1px solid #c7a371; border-radius: 5px; color: #202923; font-size: 12px; font-weight: 550; line-height: 1.5; touch-action: manipulation; }
  #touch-action:disabled { color: #9ba99d; background: #25302e; border-color: #a4b2a626; opacity: .65; }
  #touch-action svg { width: 16px; height: 16px; }
  .controls-footer > div { display: none; }
}

@media (max-width: 560px) {
  .topbar { height: 60px; padding-inline: max(10px, env(safe-area-inset-left)); }
  .wordmark { font-size: 16px; letter-spacing: 2px; gap: 5px; }
  .brand-fence { width: 22px; transform: scale(.7); }
  .topbar-actions .icon-button, .topbar-actions .help-button { width: 44px; }
  .topbar-actions svg { width: 19px; height: 19px; }
  .main-content { padding: 19px max(14px, env(safe-area-inset-left)) calc(var(--nav-height) + var(--safe-bottom) + 20px) max(14px, env(safe-area-inset-right)); }
  .chapter-header { position: relative; display: block; margin-bottom: 16px; }
  .chapter-header .eyebrow { font-size: 9px; letter-spacing: .5px; gap: 6px; }
  .chapter-line { width: 13px; }
  .chapter-header h1 { padding-right: 76px; font-size: clamp(24px, 6.4vw, 31px); line-height: 1.25; margin: 10px 0 8px; }
  .chapter-header p { max-width: none; font-size: 11px; line-height: 1.65; }
  .day-clock { position: absolute; top: 35px; right: 0; padding: 0; gap: 6px; }
  .day-clock > svg { width: 17px; height: 17px; }
  .day-clock strong { font-size: 18px; }
  .day-clock span { font-size: 8px; letter-spacing: 1px; }
  .mobile-mission { min-height: 59px; padding: 10px 12px; gap: 10px; }
  .mobile-mission strong { font-size: 12px; }
  .camp-navigation { flex-wrap: wrap; }
  #camp-map-button { min-height: 44px; }
  .camp-tabs { flex-basis: 100%; padding-bottom: 3px; }
  .camp-tabs button { font-size: 11px; padding-inline: 12px; }
  .region-objective { align-items: flex-start; gap: 12px; padding: 14px 13px; }
  .region-objective strong { font-size: 13px; }
  .region-objective span { font-size: 11px; }
  #region-objective-action { max-width: 40%; font-size: 11px; padding: 10px; gap: 5px; }
  .scene-panel { aspect-ratio: auto; height: calc((100vw - 30px) * .74 + 92px); }
  .scene-art { inset: 66px 0 26px; }
  .scene-top { top: 8px; left: 11px; right: 9px; gap: 6px; }
  .location-title { font-size: 9px; letter-spacing: .6px; gap: 6px; }
  .location-title small { max-width: 220px; font-size: 8px; line-height: 1.5; }
  .perception-toggle { min-width: 54px; padding: 8px; gap: 5px; }
  .perception-toggle > span:nth-child(2) { display: none; }
  .perception-toggle > svg { width: 16px; height: 16px; }
  .toggle-track { margin-left: 0; width: 23px; }
  .regime-strip { top: 55px; left: 11px; gap: 8px; font-size: 7px; letter-spacing: .5px; }
  .scene-caption { display: none; }
  .scene-zoom { right: 9px; bottom: 8px; }
  .scene-zoom button { width: 44px; height: 44px; }
  .scene-zoom span { min-width: 31px; font-size: 9px; }
  .interact-prompt { left: 10px; right: 10px; bottom: 61px; transform: none; max-width: none; font-size: 12px; justify-content: center; padding: 9px 10px; }
  .interact-prompt kbd { display: none; }
  .map-hotspot > rect { x: -86px; width: 172px; height: 31px; rx: 12px; }
  .map-hotspot > text:last-child { font-size: 22px; letter-spacing: .4px; transform: translateY(9px); }
  .map-hotspot > text:not(:last-child) { font-size: 20px; transform: translateY(3px); }
  .map-hotspot .hotspot-ring { r: 23px; }
  .player-bar { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 44px; gap: 15px 16px; padding: 15px 16px; min-height: 123px; }
  .player-identity { grid-column: 1 / 3; grid-row: 1; gap: 11px; }
  .player-identity h2 { font-size: 15px; }
  .player-identity h2 span { font-size: 9px; }
  .player-identity p { font-size: 10px; }
  .hero-portrait { width: 40px; height: 40px; }
  .inventory-slot { grid-column: 3; grid-row: 1; }
  .stat { grid-column: 1; grid-row: 2; }
  .hope-stat { grid-column: 2 / 4; grid-row: 2; }
  .stat > div:first-child { font-size: 11px; }
  .stat strong { font-size: 12px; }
  .stat strong span { font-size: 9px; }
  .stat-track { margin-top: 8px; }
  .touch-controls { gap: 14px; padding: 13px 12px; margin-top: 9px; }
  .touch-pad { grid-template-columns: repeat(3, 44px); grid-template-rows: repeat(2, 44px); gap: 4px; }
  .touch-context { gap: 8px; }
  #touch-hint { font-size: 10px; line-height: 1.55; }
  #touch-action { min-height: 46px; font-size: 11px; padding: 9px 8px; gap: 5px; }
  #touch-action svg { width: 14px; height: 14px; }
  .task-list { display: flex; flex-direction: column; gap: 5px; }
  .task-card { min-height: 106px; }
  .task-card h4 { font-size: 14px; }
  .task-card p { font-size: 12px; }
  .task-tag { font-size: 10px; }
  .task-arrow { opacity: .6; }
  .mission-heading { padding: 21px 20px; }
  .mission-heading h2 { font-size: 28px; }
  .mission-heading p { font-size: 12px; }
  dialog { width: calc(100vw - 24px); padding: 32px 22px 24px; max-height: calc(100dvh - 24px - var(--safe-bottom)); }
  .dialog-title { font-size: 27px; }
  .dialog-body { font-size: 14px; line-height: 1.8; }
  .dialog-actions { flex-direction: column; align-items: stretch; }
  .primary-button, .secondary-button { width: 100%; min-height: 48px; font-size: 13px; }
  .help-row { flex-wrap: wrap; font-size: 12px; }
  .settings-row { font-size: 12px; }
  .toast { justify-content: center; font-size: 12px; padding: 12px 15px; }
}

@media (max-width: 374px) {
  .wordmark { font-size: 15px; letter-spacing: 1.4px; gap: 2px; }
  .brand-fence { width: 19px; }
  .topbar { padding-inline: 7px; }
  .topbar-actions { gap: 0; }
  .main-content { padding-inline: 12px; }
  .scene-panel { height: calc((100vw - 26px) * .74 + 92px); }
  .location-title small { max-width: 205px; font-size: 7.5px; }
  .touch-controls { gap: 10px; padding-inline: 10px; }
  .touch-pad { gap: 3px; }
  .player-bar { padding-inline: 13px; gap: 14px; }
}

/* In landscape the whole scene is preserved; controls sit alongside it. */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 540px) {
  :root { --nav-height: 58px; }
  .topbar { height: 56px; }
  .main-content { padding-top: 15px; }
  .chapter-header { display: flex; margin-bottom: 14px; }
  .chapter-header h1 { font-size: 25px; padding-right: 0; margin: 5px 0; }
  .chapter-header p { font-size: 11px; }
  .day-clock { position: static; padding-top: 17px; }
  .game-column { display: grid; grid-template-columns: minmax(0, 1fr) 200px; gap: 10px 14px; align-items: start; }
  .mobile-mission { grid-column: 1 / -1; margin: 0; min-height: 54px; }
  .camp-navigation { grid-column: 1 / -1; grid-row: 2; margin-bottom: 0; flex-wrap: nowrap; }
  .camp-tabs { flex-basis: auto; }
  .region-objective { grid-column: 1 / -1; grid-row: 6; border-top: 1px solid var(--line); }
  .scene-panel { grid-column: 1; grid-row: 3 / 6; height: auto; aspect-ratio: 1000 / 910; }
  .scene-art { inset: 64px 0 36px; }
  .scene-top { left: 11px; right: 9px; top: 8px; }
  .location-title { font-size: 9px; }
  .location-title small { font-size: 8px; }
  .perception-toggle > span:nth-child(2) { display: none; }
  .regime-strip { top: 53px; left: 11px; font-size: 7px; }
  .scene-caption { display: none; }
  .player-bar { grid-column: 2; grid-row: 3; display: grid; grid-template-columns: minmax(0, 1fr) 44px; gap: 14px 9px; padding: 14px 12px; border-top: 1px solid var(--line); border-radius: 4px; }
  .player-identity { grid-column: 1 / -1; gap: 10px; }
  .player-identity h2 { font-size: 14px; gap: 6px; }
  .player-identity h2 span { font-size: 8px; }
  .player-identity p { font-size: 9px; }
  .hero-portrait { width: 34px; height: 34px; }
  .stat { grid-column: 1; grid-row: 2; }
  .hope-stat { grid-column: 1; grid-row: 3; }
  .inventory-slot { grid-column: 2; grid-row: 2 / 4; align-self: center; }
  .stat > div:first-child { font-size: 10px; }
  .stat strong { font-size: 11px; }
  .stat strong span { display: none; }
  .touch-controls { grid-column: 2; grid-row: 4; flex-direction: column; gap: 12px; padding: 12px; margin-top: 0; }
  .touch-pad { grid-template-columns: repeat(3, 44px); grid-template-rows: repeat(2, 44px); gap: 4px; }
  .touch-context { width: 100%; max-width: none; gap: 6px; }
  #touch-hint { font-size: 10px; text-align: center; }
  .controls-footer { grid-column: 2; grid-row: 5; padding-top: 0; }
  .saved-status { font-size: 9px; }
  .rail-button { height: var(--nav-height); font-size: 9px; gap: 3px; }
  .rail-button svg { width: 19px; height: 19px; }
  dialog { max-height: calc(100dvh - 20px); padding-top: 26px; }
}

/* Keep the expanded camp playable without shrinking its interface text. */
@media (min-width: 901px) {
  .scene-panel { height: clamp(330px, calc(100svh - 400px), 550px); }
  .sidebar { max-height: calc(100svh - 190px); overflow-y: auto; overscroll-behavior-y: contain; scrollbar-width: thin; scrollbar-color: #a79b774d transparent; }
  .sidebar-tabs { position: sticky; top: 0; z-index: 4; background: #1b2526; }
}

@media (max-width: 900px) and (orientation: portrait) {
  .camp-navigation { flex-wrap: nowrap; align-items: stretch; gap: 7px; }
  #camp-map-button { position: relative; flex: 0 0 44px; width: 44px; height: 44px; padding: 0; justify-content: center; }
  #camp-map-button span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .camp-tabs { flex: 1 1 auto; min-width: 0; padding-bottom: 0; }
  .camp-tabs button { min-height: 44px; }
  .touch-controls { position: sticky; bottom: calc(var(--nav-height) + var(--safe-bottom) + 8px); z-index: 12; background: #182224f7; backdrop-filter: blur(12px); border-color: #a4b2a63d; box-shadow: 0 5px 24px #0006; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
