/* Local, responsive command deck. The simulation remains a progressive enhancement. */
:root {
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px; --space-7: 48px;
  --type-xs: 11px; --type-sm: 12px; --type-md: 14px; --type-lg: 18px; --type-xl: 26px;
  --radius-sm: 8px; --radius-md: 12px; --radius-lg: 18px;
  --g-bg: #08111e; --g-paper: #101e2eee; --g-raised: #182b3e;
  --g-ink: #edf5ff; --g-muted: #a9bed2; --g-line: #355069;
  --g-accent: #72ead5; --g-accent-ink: #062b2a; --g-accent-soft: #173d40;
  --g-blue: #91c8ff; --g-warning: #ffd28a; --g-danger: #ffb0af;
  --elevation-1: 0 4px 16px #02081233; --elevation-2: 0 14px 40px #02081280;
  --elevation-3: 0 24px 80px #020812b3;
  --deck-gap: 20px; --deck-top: max(16px, env(safe-area-inset-top));
  --deck-bottom: max(14px, env(safe-area-inset-bottom));
}
[hidden] { display: none !important; }
.spatial-active { overflow: hidden; background: var(--g-bg); }
.spatial-active .sidebar, .spatial-active > .app-shell, .spatial-active > .skip-link,
.spatial-active #spatial-fallback { display: none; }
.spatial-fallback { position: relative; z-index: 5; padding: var(--space-3) var(--space-5); background: #173a40; color: var(--g-ink); text-align: center; font-size: var(--type-sm); }
.spatial-fallback button { min-height: 44px; margin-left: var(--space-3); background: transparent; color: var(--g-accent); text-decoration: underline; }
.drawer-close { display: none; }
#game3d { position: fixed; inset: 0; color: var(--g-ink); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; line-height: 1.45; isolation: isolate; }
#game3d button, .game-dialog button { min-width: 44px; min-height: 44px; color: inherit; border: 1px solid transparent; font-family: inherit; cursor: pointer; }
#game3d button:disabled, .game-dialog button:disabled { opacity: .45; cursor: not-allowed; }
#game3d button:focus-visible, #scene-container:focus-visible, .game-dialog button:focus-visible { outline: 3px solid var(--g-blue); outline-offset: 3px; }
#game3d svg, .game-dialog svg { width: 20px; height: 20px; flex-shrink: 0; }
#scene-container { position: absolute; inset: 0; outline: none; }
#scene-container canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.game-top { position: absolute; top: var(--deck-top); left: max(var(--deck-gap), env(safe-area-inset-left)); right: max(var(--deck-gap), env(safe-area-inset-right)); display: flex; align-items: center; gap: var(--space-2); pointer-events: none; }
.game-top > * { pointer-events: auto; }
.game-brand { display: flex; align-items: center; gap: var(--space-3); flex: 0 0 auto; padding-right: var(--space-2); color: var(--g-ink); }
.game-brand:hover { color: white; }
.game-brand-mark { display: grid; place-items: center; width: 40px; height: 44px; border: 1px solid #477a84; border-radius: var(--radius-sm); background: #14313b; color: var(--g-accent); }
#game3d .game-brand-mark svg { width: 25px; height: 28px; }
.game-brand strong { font-size: var(--type-lg); letter-spacing: -.4px; line-height: 1.2; }
.game-brand small { display: block; margin-top: 6px; color: #b6c9da; font: 9px var(--mono); letter-spacing: 1.25px; }
.game-hud { display: flex; flex: 1; min-width: 0; min-height: 88px; border: 1px solid var(--g-line); border-radius: var(--radius-md); background: var(--g-paper); box-shadow: var(--elevation-1); }
.hud-stat { position: relative; display: grid; grid-template-columns: 14px minmax(0, 1fr); column-gap: 5px; flex: 1; min-width: 0; padding: var(--space-3); border-right: 1px solid #2b4055; }
.hud-stat:last-child { border-right: 0; }
.hud-stat small { grid-column: 2; grid-row: 1; display: flex; align-items: center; gap: 5px; color: var(--g-muted); font-size: var(--type-xs); line-height: 1.25; }
.hud-icon { grid-column: 1; grid-row: 1; align-self: center; display: inline-flex; color: var(--g-accent); }
#game3d .hud-icon svg { width: 14px; height: 14px; }
.hud-stat strong { grid-column: 1 / -1; grid-row: 2; display: block; margin-top: 6px; color: var(--g-ink); font-size: var(--type-lg); line-height: 1.15; font-weight: 650; letter-spacing: -.4px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.hud-detail { grid-column: 1 / -1; grid-row: 3; display: block; overflow: hidden; text-overflow: ellipsis; margin-top: 4px; color: var(--g-muted); font-size: 10px; white-space: nowrap; }
.hud-gauge { grid-column: 1 / -1; grid-row: 4; height: 3px; margin-top: 7px; overflow: hidden; border-radius: 4px; background: #304357; }
.hud-gauge > span { display: block; height: 100%; max-width: 100%; border-radius: inherit; background: var(--g-accent); transition: width .3s ease; }
.hud-stat.negative strong, .hud-stat.warning strong { color: var(--g-danger); }
.hud-stat.negative .hud-gauge > span, .hud-stat.warning .hud-gauge > span { background: var(--g-danger); }
.game-button { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); padding: 10px 14px; border: 1px solid var(--g-line) !important; border-radius: var(--radius-sm); background: var(--g-paper); box-shadow: var(--elevation-1); font-size: var(--type-sm); white-space: nowrap; }
.game-button:hover { background: var(--g-raised); border-color: #6487a5 !important; }
.game-icon-button { display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0; flex-shrink: 0; font-size: var(--type-lg); background: var(--g-raised); border-radius: var(--radius-sm); }
.language-toggle { display: inline-flex; align-items: center; align-self: center; gap: 0; flex-shrink: 0; padding: 2px; border: 1px solid var(--g-line); border-radius: var(--radius-sm); background: var(--g-paper); color: var(--g-ink); font-size: var(--type-sm); line-height: 1; white-space: nowrap; }
.language-toggle button { min-width: 44px; min-height: 44px; padding: 7px; border: 0; border-radius: 6px; background: transparent; color: inherit; font: inherit; cursor: pointer; }
.language-toggle button[aria-pressed="true"] { background: var(--g-accent-soft); color: var(--g-accent); font-weight: 700; }
.language-toggle > span { display: none; }
.language-toggle button:focus-visible { outline: 3px solid var(--g-blue); outline-offset: 2px; }
.game-left { position: absolute; top: 132px; left: var(--deck-gap); width: 264px; max-height: calc(100dvh - 420px); overflow: auto; background: var(--g-paper); border: 1px solid var(--g-line); border-radius: var(--radius-md); box-shadow: var(--elevation-1); scrollbar-width: thin; }
.mission-toggle { display: flex; align-items: center; gap: var(--space-3); width: 100%; padding: var(--space-3) var(--space-4); background: transparent; color: var(--g-ink); text-align: left; font-size: var(--type-sm); font-weight: 600; }
.mission-toggle svg { margin-left: auto; transition: transform .2s ease; }
.game-left.is-collapsed .mission-toggle svg { transform: rotate(-90deg); }
.game-left.is-collapsed #mission-panel { display: none; }
.game-chapter { padding: 4px var(--space-4) var(--space-4); }
.game-eyebrow { color: var(--g-accent); font-size: 10px; letter-spacing: 1.5px; line-height: 1.4; }
.game-chapter h1 { margin: var(--space-2) 0; font-size: var(--type-xl); line-height: 1.2; font-weight: 650; letter-spacing: -.7px; }
.game-chapter p { margin: 0; color: var(--g-muted); font-size: var(--type-sm); line-height: 1.65; }
.game-chapter nav { display: flex; justify-content: space-between; gap: 2px; margin-top: var(--space-4); }
.game-chapter nav button { width: 44px; height: 44px; background: #172b3f; border: 1px solid #3b5269 !important; border-radius: var(--radius-sm); font: var(--type-xs) var(--mono); }
.game-chapter nav button.active { border-color: var(--g-accent) !important; background: var(--g-accent-soft); color: var(--g-accent) !important; }
.game-tutorial { margin: 0 var(--space-4) var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--g-line); }
.game-tutorial small { color: var(--g-accent); font-size: var(--type-xs); }
.game-tutorial h2 { margin: var(--space-2) 0; font-size: var(--type-md); }
.game-tutorial p { margin: 0 0 var(--space-3); color: var(--g-muted); font-size: var(--type-sm); line-height: 1.65; }
.tutorial-actions { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.tutorial-actions button { padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); background: var(--g-raised); font-size: var(--type-sm); }
.tutorial-actions button:last-child { background: var(--g-accent); color: var(--g-accent-ink) !important; font-weight: 650; }
.game-library { position: absolute; z-index: 12; top: 112px; right: var(--deck-gap); width: 260px; padding: var(--space-2); border: 1px solid var(--g-line); border-radius: var(--radius-md); background: #101e2e; box-shadow: var(--elevation-2); }
.game-library button { display: block; width: 100%; padding: 10px var(--space-3); border-radius: var(--radius-sm); background: transparent; text-align: left; font-size: var(--type-sm); }
.game-library button:hover, .game-library button:focus-visible { background: var(--g-raised); }
.game-cameras { position: absolute; right: var(--deck-gap); top: 132px; display: flex; gap: var(--space-1); padding: var(--space-1); background: var(--g-paper); border: 1px solid var(--g-line); border-radius: var(--radius-md); box-shadow: var(--elevation-1); }
.game-cameras button { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 60px; min-height: 58px !important; border-radius: var(--radius-sm); background: transparent; font-size: 20px; line-height: 1.15; }
.game-cameras button span { margin-top: 5px; font-size: 10px; }
.game-cameras button.active { background: var(--g-accent-soft); color: var(--g-accent) !important; border-color: #426f72 !important; }
.device-card { position: absolute; z-index: 4; right: var(--deck-gap); top: 214px; width: 290px; max-height: calc(100dvh - 506px); overflow: auto; padding: var(--space-4); border: 1px solid var(--g-line); border-radius: var(--radius-md); background: #101e2ef5; box-shadow: var(--elevation-2); overscroll-behavior: contain; }
.device-card header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.device-card h2 { margin: 0; font-size: var(--type-md); }
.device-card header button { background: transparent; border-radius: var(--radius-sm); font-size: 24px; }
.device-card small { color: var(--g-muted); font: 10px var(--mono); overflow-wrap: anywhere; }
.device-card dl { margin: var(--space-3) 0; }
.device-card dl > div { display: flex; justify-content: space-between; gap: var(--space-3); padding: var(--space-2) 0; border-bottom: 1px solid #2d4258; font-size: var(--type-sm); }
.device-card dt { color: var(--g-muted); }
.device-card dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.device-card h3 { margin: var(--space-4) 0 6px; font-size: var(--type-sm); }
.device-card p { margin: 0 0 var(--space-3); color: var(--g-muted); font-size: var(--type-sm); line-height: 1.65; }
.device-card footer { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.device-card footer button { padding: 7px 10px; border-radius: var(--radius-sm); background: var(--g-raised); font-size: var(--type-xs); }
.device-card footer button[data-device-action="remove"] { color: var(--g-danger) !important; }
.game-bottom { position: absolute; left: max(var(--deck-gap), env(safe-area-inset-left)); right: max(var(--deck-gap), env(safe-area-inset-right)); bottom: var(--deck-bottom); pointer-events: none; }
.game-bottom > * { pointer-events: auto; }
.game-event { display: none; }
.game-control-row { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-3); }
.game-finance { display: flex; flex: 1; gap: var(--space-5); min-width: 0; padding: 8px 14px; background: #08111ecc; border-radius: var(--radius-sm); font-size: var(--type-sm); }
.game-finance small { display: block; margin-bottom: 3px; color: #b4c7d8; font-size: 10px; }
.game-finance b { white-space: nowrap; font-weight: 600; font-variant-numeric: tabular-nums; }
.game-time { display: flex; align-items: center; gap: var(--space-1); padding: var(--space-1); border: 1px solid var(--g-line); border-radius: var(--radius-md); background: var(--g-paper); font-size: var(--type-sm); white-space: nowrap; }
.game-time > span { padding: 0 var(--space-2); color: var(--g-muted); }
.game-time button { padding: 8px 10px; border-radius: var(--radius-sm); background: transparent; }
.game-time button.active { background: var(--g-accent-soft); color: var(--g-accent) !important; border-color: #426f72 !important; }
.game-time button.game-start { padding: 9px 16px; background: var(--g-accent); color: var(--g-accent-ink) !important; font-weight: 700; }
.build-tray { padding: var(--space-2) var(--space-3) 0; border: 1px solid var(--g-line); border-radius: var(--radius-md); background: var(--g-paper); box-shadow: var(--elevation-2); }
.build-topline { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding-bottom: var(--space-2); border-bottom: 1px solid #2c4257; }
.build-categories, .build-mode { display: flex; gap: var(--space-1); }
.build-topline button { padding: 8px 12px; border-radius: var(--radius-sm); background: transparent; font-size: var(--type-sm); white-space: nowrap; }
.build-topline button:hover { background: var(--g-raised); }
.build-topline button.active { background: var(--g-accent-soft); color: var(--g-accent) !important; border-color: #426f72 !important; }
.build-mode { padding-left: var(--space-3); border-left: 1px solid var(--g-line); }
.build-palette { display: flex; gap: var(--space-2); overflow-x: auto; padding: var(--space-2) 0; scrollbar-width: thin; scrollbar-color: #57738e transparent; overscroll-behavior-inline: contain; }
.build-item { position: relative; display: flex; align-items: center; gap: var(--space-3); flex: 0 0 auto; min-width: 195px; padding: 10px 36px 10px 12px; border: 1px solid #355069 !important; border-radius: var(--radius-sm); background: #15263a; text-align: left; }
.build-item:hover { background: #20394f; border-color: #7698b5 !important; }
.build-item.active { background: #173d40; border-color: var(--g-accent) !important; box-shadow: inset 0 0 0 1px var(--g-accent); }
.build-icon { display: grid; place-items: center; width: 32px; color: var(--g-blue); flex-shrink: 0; }
#game3d .build-icon svg { width: 28px; height: 28px; }
.build-item.active .build-icon { color: var(--g-accent); }
.build-copy strong { display: block; font-size: var(--type-sm); font-weight: 650; }
.build-copy small { display: block; margin-top: 4px; color: var(--g-accent); font-size: var(--type-xs); }
.build-unit { margin-top: 3px; color: var(--g-muted); font-size: 10px; }
.build-shortcut { position: absolute; right: 8px; top: 8px; display: grid; place-items: center; width: 20px; height: 20px; border: 1px solid #49637a; border-radius: 4px; color: var(--g-muted); font: 10px var(--mono); }
.placement-status { min-height: 32px; padding: 7px 0; border-top: 1px solid #2c4257; color: var(--g-muted); font-size: var(--type-xs); line-height: 1.5; }
.placement-status.invalid { color: var(--g-danger); }
.placement-status.valid { color: var(--g-accent); }
.placement-cursor { position: fixed; left: var(--cursor-x, 0px); top: var(--cursor-y, 0px); z-index: 5; pointer-events: none; max-width: 235px; padding: 9px 12px; border: 1px solid var(--g-accent); border-radius: var(--radius-sm); background: #0a1c2bf5; box-shadow: var(--elevation-2); color: var(--g-accent); font-size: var(--type-sm); }
.placement-cursor strong, .placement-cursor span { display: block; }
.placement-cursor span { margin-top: 3px; font-size: var(--type-xs); }
.placement-cursor.invalid { border-color: var(--g-danger); color: var(--g-danger); }
.game-footnote { display: flex; justify-content: space-between; gap: var(--space-3); padding: var(--space-2) 2px 0; color: #c2d2df; font-size: 10px; text-shadow: 0 1px 3px #000; }
/* Native dialogs provide a focus trap and a genuine modal reading surface. */
.game-dialog { width: min(460px, calc(100vw - 32px)); max-height: calc(100dvh - 40px); padding: var(--space-5); overflow: auto; border: 1px solid #4d738f; border-radius: var(--radius-lg); background: #102034; color: var(--g-ink); box-shadow: var(--elevation-3); }
.game-dialog::backdrop { background: #02091599; }
.onboarding-dialog::backdrop { background: #02091566; backdrop-filter: none; }
.onboarding-top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.step-badge { padding: 5px 9px; border: 1px solid #41657c; border-radius: 50px; color: var(--g-blue); font: var(--type-xs) var(--mono); }
.game-dialog h2 { margin: var(--space-4) 0 var(--space-3); font-size: 24px; line-height: 1.25; letter-spacing: -.4px; }
.game-dialog p { color: var(--g-muted); font-size: var(--type-md); line-height: 1.75; }
.onboarding-actions { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); margin-top: var(--space-5); }
.onboarding-actions > div { display: flex; gap: var(--space-2); }
.game-dialog button { padding: 8px 14px; border-radius: var(--radius-sm); font-size: var(--type-sm); }
.dialog-quiet { background: transparent; color: var(--g-muted) !important; }
.dialog-secondary { background: var(--g-raised); }
.dialog-primary { background: var(--g-accent); color: var(--g-accent-ink) !important; font-weight: 700; }
.onboarding-target { outline: 3px solid var(--g-accent); outline-offset: 5px; box-shadow: 0 0 0 9px #72ead526, 0 0 40px #72ead544; }
body[data-onboarding-step="2"] .onboarding-dialog { margin-top: 180px; }
.shortcut-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }
.shortcut-header h2 { font-size: 21px; margin-bottom: 0; }
.shortcut-header .game-icon-button { padding: 0; font-size: 24px; }
.shortcut-list { margin: var(--space-5) 0 var(--space-4); }
.shortcut-list > div { display: flex; justify-content: space-between; align-items: center; gap: var(--space-4); padding: 9px 0; border-bottom: 1px solid #2d4258; }
.shortcut-list dt { max-width: 58%; color: var(--g-muted); font-size: var(--type-sm); }
.shortcut-list dd { margin: 0; flex-shrink: 0; color: var(--g-muted); font-size: var(--type-xs); }
kbd { display: inline-block; padding: 3px 6px; border: 1px solid #58728b; border-bottom-width: 2px; border-radius: 5px; background: #1c3148; color: var(--g-ink); font: var(--type-xs) var(--mono); }
.game-dialog p.shortcut-note { margin: 0; font-size: var(--type-sm); }
/* Loading is local and reports actual module / renderer initialization stages. */
.game-loading { position: fixed; inset: 0; z-index: 150; display: grid; place-items: center; padding: var(--space-5); background: radial-gradient(ellipse at 50% 35%, #16384a, #08111e 65%); color: var(--g-ink); }
.loading-card { width: min(340px, 100%); text-align: center; }
.loading-mark { display: grid; place-items: center; width: 76px; height: 76px; margin: 0 auto var(--space-5); border: 1px solid #4b8791; border-radius: var(--radius-lg); color: var(--g-accent); background: #173d404d; box-shadow: 0 0 60px #72ead519; }
.loading-mark svg { width: 36px; height: 42px; }
.loading-card > strong { font-size: 30px; font-weight: 650; letter-spacing: -.7px; }
.loading-card p { margin: var(--space-3) 0 var(--space-5); color: var(--g-muted); font-size: var(--type-md); }
.loading-card progress { display: block; width: 100%; height: 5px; margin-bottom: var(--space-3); border: 0; border-radius: 6px; overflow: hidden; accent-color: var(--g-accent); background: #294259; }
.loading-card progress::-webkit-progress-bar { background: #294259; }
.loading-card progress::-webkit-progress-value { background: var(--g-accent); transition: width .2s; }
.loading-card progress::-moz-progress-bar { background: var(--g-accent); }
#loading-value { color: var(--g-accent); font: var(--type-sm) var(--mono); }
.loading-card small { display: block; margin-top: var(--space-5); color: var(--g-muted); font-size: var(--type-xs); }
/* Toast content is shared by 2D and 3D. */
#toast { display: flex; align-items: center; gap: var(--space-3); width: max-content; max-width: min(520px, calc(100vw - 32px)); padding: 10px 10px 10px 16px; border: 1px solid #4d738f; border-radius: var(--radius-md); background: #152a40; color: var(--g-ink); box-shadow: var(--elevation-2); line-height: 1.5; }
.toast-icon { display: grid; place-items: center; width: 24px; flex-shrink: 0; color: var(--g-blue); }
.toast-icon svg { width: 22px; height: 22px; }
.toast-copy small { display: block; color: var(--g-muted); }
.toast-copy { font-size: var(--type-sm); }
.toast-close { min-width: 44px; min-height: 44px; margin-left: auto; padding: 0; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--g-muted); font-size: 22px; }
.toast-close:hover { background: #284059; }
#toast[data-tone="success"] { border-color: #518b7f; }
#toast[data-tone="success"] .toast-icon { color: var(--g-accent); }
#toast[data-tone="danger"] { border-color: #aa646b; }
#toast[data-tone="danger"] .toast-icon { color: var(--g-danger); }
#toast[data-tone="warning"] { border-color: #9b8056; }
#toast[data-tone="warning"] .toast-icon { color: var(--g-warning); }
.spatial-active #toast { z-index: 100; left: 50%; bottom: 294px; transform: translate(-50%, 12px); }
.spatial-active #toast.visible { transform: translate(-50%, 0); }
.spatial-active #modal { z-index: 110; }
.spatial-active.panel-open > .app-shell { display: block; position: fixed; inset: 16px 16px 16px auto; z-index: 20; width: min(1050px, calc(100% - 32px)); margin: 0; overflow: auto; border: 1px solid var(--g-line); border-radius: var(--radius-lg); background: var(--bg); box-shadow: 0 0 0 100vmax #020915aa, var(--elevation-3); overscroll-behavior: contain; }
.spatial-active.panel-open .drawer-close { display: block; position: fixed; top: 29px; right: 32px; z-index: 21; min-height: 44px; padding: 8px 14px; border: 1px solid #5b7a91; border-radius: var(--radius-sm); background: var(--g-raised); color: var(--g-ink); font-size: var(--type-sm); cursor: pointer; }
.spatial-active.panel-open .topbar-actions { margin-right: 120px; }
.spatial-active.panel-open .topbar { position: relative; }
.spatial-active.panel-open main { padding-top: var(--space-5); }
@media (min-width: 1600px) {
  :root { --deck-gap: 32px; --deck-top: max(24px, env(safe-area-inset-top)); --deck-bottom: max(20px, env(safe-area-inset-bottom)); }
  .game-top { gap: var(--space-3); }
  .hud-stat { padding: 14px 20px; }
  .hud-stat strong { font-size: 22px; }
  .hud-stat small { font-size: var(--type-sm); }
  .game-left, .game-cameras { top: 150px; }
  .game-left { width: 284px; }
  .device-card { top: 232px; width: 310px; }
  .build-item { min-width: 215px; padding-top: 14px; padding-bottom: 14px; }
  .build-copy strong { font-size: var(--type-md); }
}
@media (max-width: 1200px) and (min-width: 761px) {
  .game-brand-mark { display: none; }
  .game-brand strong { font-size: 16px; }
  .game-brand small { font-size: 8px; }
  #game-menu span { display: none; }
  #game-menu { padding: 10px; width: 44px; }
  .hud-stat { padding: 12px 8px; grid-template-columns: 1fr; }
  .hud-stat small { grid-column: 1; }
  .hud-stat strong { font-size: 16px; }
  .hud-icon { display: none; }
  .game-finance { gap: var(--space-3); padding: 8px; }
  .game-finance > div:last-child { display: none; }
  .game-time { font-size: var(--type-xs); }
  .game-time button.game-start { padding: 9px 12px; }
  .build-topline button { padding: 8px; }
}
@media (max-width: 760px) {
  :root { --deck-gap: 10px; --deck-top: max(10px, env(safe-area-inset-top)); --deck-bottom: max(8px, env(safe-area-inset-bottom)); }
  .game-top { gap: 5px; flex-wrap: wrap; }
  .game-brand { flex: 1; min-width: 70px; padding: 0 2px; }
  .game-brand strong { font-size: 16px; letter-spacing: -.6px; }
  .game-brand-mark, .game-brand small { display: none; }
  .game-top .language-toggle { padding: 0; }
  #game-menu { width: 44px; padding: 0; }
  #game-menu span { display: none; }
  .game-hud { order: 10; flex-basis: 100%; min-height: 83px; margin-top: 3px; border-radius: var(--radius-sm); }
  .hud-stat { padding: 9px 6px; grid-template-columns: 1fr; }
  .hud-stat small { grid-column: 1; font-size: 10px; min-height: 25px; align-items: flex-start; overflow-wrap: anywhere; }
  .hud-stat strong { min-height: 27px; margin-top: 2px; font-size: 12px; letter-spacing: -.45px; white-space: normal; overflow-wrap: normal; }
  .hud-detail, .hud-icon { display: none; }
  .hud-gauge { margin-top: 8px; }
  .game-left { top: calc(var(--deck-top) + 150px); width: 256px; max-height: calc(100dvh - 560px); z-index: 5; }
  .game-left.is-collapsed { width: 165px; }
  .mission-toggle { padding: 10px 12px; font-size: var(--type-xs); gap: var(--space-2); }
  .game-chapter h1 { font-size: 22px; }
  .game-chapter p { font-size: var(--type-xs); }
  .game-chapter nav button { min-width: 44px !important; width: 44px; }
  .game-chapter { padding: 4px 12px 12px; }
  .game-tutorial { margin: 0 12px 12px; }
  .game-cameras { top: calc(var(--deck-top) + 150px); flex-direction: column; gap: 2px; padding: 3px; }
  .game-cameras button { width: 46px; min-height: 46px !important; font-size: 17px; }
  .game-cameras button span { font-size: 9px; margin-top: 2px; }
  .game-library { top: calc(var(--deck-top) + 50px); max-height: calc(100dvh - 90px); overflow: auto; width: min(280px, calc(100vw - 20px)); }
  .game-control-row { display: grid; grid-template-columns: repeat(3, 44px) minmax(0, 1fr); gap: 5px; padding: 5px; border: 1px solid var(--g-line); border-radius: var(--radius-md); background: var(--g-paper); margin-bottom: 6px; }
  #game-planning { grid-column: 1 / 4; grid-row: 1; padding: 5px; min-width: 0; white-space: normal; line-height: 1.2; font-size: 10px; box-shadow: none; background: #1b3044; }
  .game-finance { display: none; }
  .game-time { display: contents; }
  .game-control-row:has(.game-time.onboarding-target) { outline: 3px solid var(--g-accent); outline-offset: 5px; box-shadow: 0 0 0 9px #72ead526, 0 0 40px #72ead544; }
  .game-time > span { grid-column: 4; grid-row: 1; padding: 0 4px; font-size: 10px; white-space: normal; text-align: right; }
  .game-time > button[data-speed="0"] { grid-column: 1; grid-row: 2; }
  .game-time > button[data-speed="1"] { grid-column: 2; grid-row: 2; }
  .game-time > button[data-speed="4"] { grid-column: 3; grid-row: 2; }
  .game-time > #game-step { grid-column: 4; grid-row: 2; justify-self: end; padding: 8px; font-size: 11px; }
  .game-time > button.game-start { grid-column: 1 / -1; grid-row: 3; min-height: 44px; padding: 8px 12px; }
  .build-tray { padding: 4px 7px 0; border-radius: var(--radius-md); }
  .build-topline { display: block; padding-bottom: 4px; }
  .build-categories { justify-content: space-between; gap: 0; }
  .build-mode { justify-content: space-between; gap: 0; border: 0; padding: 0; }
  .build-topline button { min-width: 44px; padding: 6px 8px; font-size: 10px; }
  .build-mode button { padding: 6px 10px; }
  .build-palette { gap: 6px; padding: 6px 0; }
  .build-item { min-width: 178px; padding: 8px 29px 8px 9px; gap: 8px; }
  .build-copy strong { font-size: 11px; }
  .build-copy small { margin-top: 3px; font-size: 10px; }
  .build-unit { font-size: 9px; }
  .build-icon { width: 25px; }
  #game3d .build-icon svg { width: 24px; height: 24px; }
  .placement-status { padding: 5px 0; min-height: 28px; max-height: 42px; overflow: auto; font-size: 10px; }
  .game-footnote { display: none; }
  .device-card { top: auto; right: 0; left: 0; bottom: 0; z-index: 15; width: auto; max-height: min(65dvh, 520px); padding: 14px 18px max(18px, env(safe-area-inset-bottom)); border-radius: 20px 20px 0 0; background: #102034; box-shadow: 0 -20px 70px #020915aa; }
  .device-card::before { content: ''; display: block; width: 36px; height: 4px; margin: -5px auto 9px; border-radius: 5px; background: #63809a; }
  .device-card dl { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
  .device-card dl > div { font-size: 11px; }
  .game-dialog { width: calc(100vw - 24px); max-height: calc(100dvh - 32px); padding: 20px; border-radius: 16px; }
  .game-dialog h2 { font-size: 23px; }
  .game-dialog p { font-size: 13px; }
  .onboarding-actions { margin-top: 16px; gap: 4px; }
  .game-dialog button { padding: 8px 11px; }
  body[data-onboarding-step="0"] .onboarding-dialog,
  body[data-onboarding-step="3"] .onboarding-dialog { margin-top: calc(var(--deck-top) + 150px); margin-bottom: auto; }
  body[data-onboarding-step="1"] .onboarding-dialog { margin-top: calc(var(--deck-top) + 360px); margin-bottom: auto; }
  body[data-onboarding-step="2"] .onboarding-dialog { margin-top: 180px; margin-bottom: auto; }
  .shortcut-list dt { max-width: 53%; font-size: 11px; }
  .shortcut-list dd { font-size: 10px; }
  kbd { font-size: 10px; padding: 3px 4px; }
  .spatial-active #toast { bottom: auto; top: calc(var(--deck-top) + 145px); max-width: calc(100vw - 24px); }
  #toast { gap: 8px; padding-left: 12px; }
  .toast-copy { font-size: 11px; }
  .spatial-active.panel-open > .app-shell { inset: max(56px, env(safe-area-inset-top)) 0 0; width: 100%; border-radius: 20px 20px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .spatial-active.panel-open .drawer-close { top: max(68px, calc(env(safe-area-inset-top) + 12px)); right: 12px; min-height: 44px; }
  .spatial-active.panel-open .topbar { min-height: 72px; padding: 12px; }
  .spatial-active.panel-open .topbar-actions { margin-right: 120px; }
  .spatial-active.panel-open .breadcrumb, .spatial-active.panel-open .save-status { display: none; }
  .spatial-active.panel-open #main { padding: 16px 12px; }
  .topbar-actions { gap: 8px; }
  .topbar-actions .save-status, .sidebar-bottom .nav-item { display: none; }
}
@media (max-height: 680px) and (min-width: 761px) {
  .game-left { max-height: calc(100dvh - 400px); }
  .game-tutorial { padding-top: 8px; }
  .game-tutorial p { display: none; }
  .game-footnote { display: none; }
  .device-card { max-height: calc(100dvh - 470px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}

#loading-fallback { min-width: 44px; min-height: 44px; margin-top: 24px; padding: 8px 16px; border: 1px solid #4d738f; border-radius: var(--radius-sm); background: #173044; color: var(--g-ink); font-size: var(--type-sm); }
#toast { visibility: hidden; pointer-events: none; }
#toast.visible { visibility: visible; pointer-events: auto; }

.palette-empty { margin: 0; padding: 18px 12px; color: var(--g-muted); font-size: var(--type-sm); }
