/* Compact application shell. Wide desktop keeps the existing office layout. */
.mobile-only { display: none; }
.mobile-menu-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 16px 0; }
.mobile-menu-grid button, .mobile-menu-grid .novel-link { min-height: 48px; font-size: 13px; }
.mobile-menu-status { font-size: 12px; }

@media (max-width: 1099px), (max-height: 719px) {
  html[data-game-started='true'], html[data-game-started='true'] body { height: 100%; overflow: hidden; }
  .mobile-only { display: block; }
  #game-shell {
    height: 100vh;
    height: 100dvh;
    max-width: none;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    gap: 6px;
    padding: max(4px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left));
  }
  .masthead.compact-header { display: flex; min-height: 42px; padding: 0; margin: 0; gap: 8px; border: 0; flex-wrap: nowrap; }
  .masthead .brand-sign { gap: 5px; font-size: 12px; flex: 1; min-width: 0; }
  .brand-sign img { width: 25px; height: 25px; }
  .masthead .brand-sign small { display: none; }
  .masthead .brand-sign > span { white-space: nowrap; }
  .masthead .header-calendar { text-align: right; margin: 0; }
  .header-calendar strong { font-size: 12px; white-space: nowrap; }
  .header-calendar small, .masthead > nav { display: none; }
  .mobile-menu-button { background: #e7ede3; border: 1px solid #cdd9cd; border-radius: 9px; font-size: 17px; min-width: 44px; min-height: 42px; padding: 5px 8px; }
  .mobile-menu-button span { display: block; font-size: 9px; line-height: 1.1; }
  .stats-bar { grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0; padding: 0; border-radius: 9px; }
  .stat { padding: 7px 5px; gap: 3px; min-width: 0; border-bottom: 0; }
  .stat > span { font-size: 9px; line-height: 1.2; white-space: nowrap; }
  .stat strong { font-size: clamp(12px, 3.7vw, 17px); line-height: 1.2; letter-spacing: -.03em; white-space: nowrap; }
  .stat > small { display: none; }
  .game-layout { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto auto; gap: 0; min-height: 0; align-items: stretch; overflow: hidden; }
  .desk-panel { display: contents; }
  .desk-header, .desk-tabs, .page-footer, #day-feedback, #workday-flow, .mobile-desk-link { display: none; }
  .mobile-notice { grid-column: 1; grid-row: 1; display: flex; align-items: center; justify-content: space-between; gap: 5px; min-width: 0; }
  .mobile-notice .text-button { font-size: 11px; min-height: 36px; padding: 5px; line-height: 1.3; }
  #mobile-update { text-align: left; min-width: 0; }
  #mobile-issues { color: #973e26; background: #fff0d6; border-radius: 6px; white-space: nowrap; }
  #mobile-result { color: #fff; background: #286b5d; border-radius: 6px; white-space: nowrap; }
  .desk-body, .office-column, .calendar-card {
    grid-row: 2; grid-column: 1; width: 100%; min-width: 0; min-height: 0;
    max-height: none; margin: 0; padding: 8px;
    overflow: auto; overscroll-behavior: contain; scrollbar-width: thin;
    border: 1px solid var(--line); border-radius: 10px; background: var(--card);
  }
  #game-shell:not([data-mobile-view='office']) .office-column,
  #game-shell:not([data-mobile-view='cash']) .calendar-card,
  #game-shell[data-mobile-view='office'] .desk-body,
  #game-shell[data-mobile-view='cash'] .desk-body { display: none; }
  .desk-body#panel-jobs { display: flex; flex-direction: column; overflow: hidden; }
  .desk-body > .compact-tabs { position: sticky; top: -8px; z-index: 2; flex: none; background: var(--card); padding: 5px 0; margin: -5px 0 3px; }
  .compact-tabs button { min-height: 40px; padding: 7px 3px; font-size: 12px; }
  .compact-tabs button:focus-visible { outline-offset: -3px; }
  .compact-list { display: block; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-width: thin; flex: 1; padding: 2px; }
  .compact-list .compact-job { margin-bottom: 7px; }
  .compact-job, .compact-shop { padding: 8px; border-radius: 8px; }
  .compact-title h3 { font-size: 13px; }
  .compact-title > b, .compact-title > span { font-size: 11px; }
  .compact-bottom { font-size: 10px; gap: 5px; }
  .compact-bottom > div { gap: 4px; flex-shrink: 0; }
  .compact-bottom > button { flex-shrink: 0; min-width: 86px; }
  .compact-bottom .primary-button, .compact-bottom .secondary-button, .compact-job [data-accept], .accepted-seal { min-height: 40px; height: auto; padding: 7px 10px; font-size: 12px; }
  .compact-bottom .text-button { min-height: 40px; padding: 7px; font-size: 11px; }
  .metric-row { gap: 3px; margin-top: 6px; }
  .metric { grid-template-columns: 1fr; padding: 4px 3px; min-width: 0; }
  .metric i { display: none; }
  .metric small { font-size: 9px; }
  .metric b { font-size: 10px; white-space: nowrap; }
  .sales-strip { flex: none; padding: 7px 8px; margin-bottom: 4px; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 3px 7px; align-items: center; }
  .sales-strip .sales-heading, .sales-message small, .sales-strip .sales-message small { display: none; }
  .sales-strip > label { margin: 0; font-size: 11px; }
  .sales-strip .sales-controls { gap: 5px; }
  .sales-strip select { min-height: 40px; font-size: 16px; padding: 5px; }
  .sales-controls > button { min-height: 40px; padding: 5px 6px; font-size: 10px; }
  .sales-message { grid-column: 1 / -1; margin: 2px 0; line-height: 1.35; font-size: 10px; font-weight: 500; }
  .sales-strip .sales-links { grid-column: 1 / -1; gap: 3px; }
  .sales-links .text-button { min-height: 28px; padding: 3px; font-size: 10px; }
  .desktop-workload { display: none; }
  .mobile-workload-link { font-size: 11px; padding: 5px; min-height: 36px; margin-bottom: 4px; }
  .illustrated-shop { gap: 7px; }
  .illustrated-shop > .item-art { width: 45px; height: 50px; }
  .illustrated-shop .fine-print { font-size: 11px; margin: 4px 0; line-height: 1.45; }
  .illustrated-shop .compact-bottom { flex-wrap: wrap; }
  .skill-buttons { gap: 4px; margin-top: 6px; }
  .skill-buttons button { min-height: 56px; padding: 6px 2px; }
  .skill-buttons small { font-size: 9px; line-height: 1.3; }
  .skill-buttons .field-badge { white-space: normal; }
  .day-bar { grid-row: 3; grid-column: 1; position: static; inset: auto; display: flex; flex-direction: row; gap: 6px; margin: 5px 0 0; padding: 6px 2px; min-height: 56px; width: 100%; background: var(--paper); border: 0; box-shadow: none; z-index: auto; }
  .day-bar > div { display: block; flex: 1; min-width: 0; }
  .day-bar strong { font-size: 11px; line-height: 1.3; }
  .day-bar small { display: none; }
  .day-bar .primary-button { width: auto; flex: 0 0 auto; min-height: 46px; padding: 10px 13px; font-size: 13px; border-radius: 9px; }
  .desk-footer { grid-row: 4; grid-column: 1; display: flex; align-items: center; justify-content: space-between; gap: 5px; font-size: 10px; padding: 3px; min-height: 0; }
  #game-shell[data-save-warning='false'] .desk-footer { display: none; }
  #game-shell[data-save-warning='true'] .desk-footer { color: #8d321f; background: #fff0dc; border-radius: 6px; }
  .desk-footer button { flex: none; min-height: 36px; }
  .mobile-nav { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 3px; border-top: 1px solid #ccd5c9; padding: 5px 0 max(5px, env(safe-area-inset-bottom)); background: var(--paper); }
  .mobile-nav button { display: grid; align-content: center; justify-items: center; gap: 2px; min-height: 51px; border: 1px solid transparent; border-radius: 9px; padding: 4px 2px; font-size: 11px; color: #566a60; background: transparent; }
  .mobile-nav button > span { font-size: 20px; line-height: 1.05; font-weight: 700; }
  .mobile-nav button[aria-pressed='true'] { color: #fffef6; background: #285e51; border-color: #285e51; }
  .mobile-nav button:focus-visible { outline-offset: -3px; }
  .calendar-card .section-heading { align-items: center; gap: 5px; }
  .calendar-card h2 { font-size: 14px; }
  .calendar-card h2 small { display: none; }
  .calendar-card .section-heading button { font-size: 11px; min-height: 40px; }
  .calendar-card #forecast-summary { flex: 1; min-height: 180px; }
  .calendar-card #cash-plot { flex: 1 0 170px; height: auto; min-height: 170px; }
  .mobile-finance-links { display: flex; gap: 8px; padding-top: 8px; }
  .mobile-finance-links button { flex: 1; min-height: 42px; padding: 6px; font-size: 12px; }
  .mobile-cash-context { flex: none; font-size: 11px; line-height: 1.5; padding: 5px 0; color: var(--muted); }
  .cash-table { font-size: 10px; }
  .cash-table th, .cash-table td { padding: 9px 3px; overflow-wrap: anywhere; }
  .cash-table small { font-size: 9px; display: block; }
  .list-pager button { min-height: 40px; }
  .office-column { display: flex; flex-direction: column; gap: 5px; }
  .office-column .office-card { flex: 1 0 190px; min-height: 190px; display: flex; flex-direction: column; }
  .card-topline { padding: 7px 9px; flex: none; }
  .card-topline .small-label { display: none; }
  .card-topline h2 { font-size: 13px; margin: 0; }
  .office-stage { height: auto; min-height: 160px; flex: 1; }
  .office-column > #office-readout { flex: none; padding: 5px; }
  .office-people { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
  .actor-button { min-width: 0; min-height: 45px; padding: 6px; }
  .actor-button strong { font-size: 11px; }
  .actor-button span { font-size: 10px; }
  .office-queue { font-size: 10px; padding: 2px 0; margin: 0; }
  .compact-goal { flex: none; padding: 5px; margin: 0; font-size: 10px; }
  .compact-goal #guide-message { font-size: 10px; }
  .scene-caption { font-size: 9px; bottom: 4px; }
  .office-assets { left: 5px; bottom: 18px; gap: 3px; }
  .owned-asset { width: 46px; }
  .owned-asset .item-art { width: 34px; height: 31px; }
  .toast { bottom: calc(128px + env(safe-area-inset-bottom)); max-width: calc(100vw - 24px); font-size: 12px; pointer-events: none; }
  .paper-dialog { max-width: calc(100vw - 16px); width: calc(100vw - 16px); max-height: calc(100dvh - 24px); }
  .paper-dialog[data-kind='menu'] { margin: 8px 8px auto auto; width: min(340px, calc(100vw - 16px)); }
  .dialog-header { padding: 12px 52px 10px 14px; }
  .paper-dialog .dialog-header h2 { font-size: 18px; }
  .dialog-body { padding: 12px 14px; }
  .dialog-footer { padding: 10px 12px max(10px, env(safe-area-inset-bottom)); }
  .setting-row select { font-size: 16px; max-width: 65%; }
  .start-screen { padding: 10px; align-items: start; }
  #start-save-warning { width: 100%; max-width: 1240px; margin: 0 auto 10px; font-size: 13px; }
  .story-welcome-hero, .paper-dialog:has(.story-welcome) .story-welcome-hero { display: block; padding: 16px; border-radius: 13px; }
  .story-welcome .story-illustration, .story-welcome .story-overline { display: none; }
  .story-brand { font-size: 14px; margin-bottom: 12px; }
  .story-brand-sign { width: 30px; height: 30px; font-size: 19px; border-radius: 8px; }
  .story-welcome h1 { font-size: 25px; margin: 10px 0; }
  .story-lead { font-size: 12px; line-height: 1.6; }
  .story-opening-ledger { margin-top: 12px; gap: 5px; }
  .story-opening-ledger > span, .story-opening-ledger > span:last-child { flex: 1 1 0; padding: 6px; border-radius: 7px; }
  .story-opening-ledger small { font-size: 9px; }
  .story-opening-ledger strong { font-size: 11px; }
  .story-pick { margin-top: 16px; }
  .story-section-heading { margin-bottom: 9px; gap: 10px; }
  .story-step { width: 28px; height: 28px; border-radius: 7px; font-size: 11px; }
  .story-section-heading h2 { font-size: 18px; }
  .story-mode-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
  .story-mode-grid .story-mode-card { display: flex; flex-direction: column; align-items: center; text-align: center; justify-content: center; min-height: 78px; padding: 8px 3px; border-radius: 9px; gap: 3px; }
  .story-mode-length strong { font-size: 27px; }
  .story-mode-length small { font-size: 11px; }
  .story-mode-name { font-size: 10px; align-self: auto; }
  .story-mode-lead { display: none; }
  .story-mode-summary { padding: 8px 10px; font-size: 11px; gap: 3px; }
  .story-mode-summary small { font-size: 10px; }
  .story-scenario-intro { font-size: 11px; margin: 0 0 8px; }
  .story-scenario-grid { grid-template-columns: 1fr; gap: 8px; }
  .story-scenario-grid .story-scenario-card, .start-screen .story-scenario-grid .story-scenario-card { padding: 12px; min-height: 0; border-top-width: 3px; }
  .story-scenario-card h3 { font-size: 16px; margin: 4px 0; }
  .story-scenario-card p { font-size: 11px; line-height: 1.5; }
  .story-scenario-growth { display: none; }
  .story-scenario-card .primary-button { margin-top: 8px; font-size: 12px; min-height: 42px; }
}

@media (max-height: 620px) and (max-width: 519px) {
  .sales-strip .sales-links, .sales-strip:not(.sales-unassigned) .sales-message { display: none; }
  .mobile-notice .text-button { min-height: 30px; }
  .mobile-nav button { min-height: 46px; }
}

@media (max-height: 500px) and (min-width: 520px) {
  #game-shell { grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: minmax(180px, 1fr) minmax(0, 1.4fr); gap: 4px 8px; }
  .masthead.compact-header { grid-column: 1; min-height: 38px; }
  .stats-bar { grid-column: 2; grid-row: 1; }
  .stat { padding: 4px; }
  .stat strong { font-size: 13px; }
  .game-layout { grid-column: 1 / -1; grid-row: 2; grid-template-columns: minmax(0, 1fr) 148px; grid-template-rows: auto minmax(0, 1fr) auto; gap: 0 7px; }
  .mobile-notice { grid-column: 2; grid-row: 1 / 3; flex-direction: column; justify-content: start; align-items: stretch; }
  .desk-body, .office-column, .calendar-card { grid-row: 1 / 4; }
  .day-bar { grid-column: 2; grid-row: 2; flex-direction: column; align-self: end; gap: 6px; padding: 4px 0; }
  .day-bar > div { flex: none; }
  .day-bar .primary-button { width: 100%; }
  .desk-footer { grid-column: 2; grid-row: 3; }
  .mobile-nav { grid-column: 1 / -1; grid-row: 3; padding-top: 3px; }
  .mobile-nav button { display: flex; align-items: center; justify-content: center; min-height: 40px; gap: 6px; }
  .sales-strip .sales-links { display: none; }
  .sales-strip .sales-message { margin: 0; }
  .header-calendar strong { font-size: 11px; }
}
