:root {
  --ink: #0a0f0e;
  --panel: #121b19;
  --panel-2: #1a2421;
  --line: #34423d;
  --paper: #e8dcc0;
  --muted: #9ca99f;
  --brass: #e0b85b;
  --brass-dark: #8f6d2f;
  --signal: #e65d48;
  --safe: #73ce91;
  --amber-hot: #ffd977;
  --steel-hi: #718179;
  --steel-low: #202a27;
  --glass: rgba(11, 18, 16, .84);
  --font-title-xl: 24px;
  --font-title: 18px;
  --font-copy: 12px;
  --font-action: 20px;
  --touch-target: 48px;
  --z-hud: 10;
  --z-modal: 50;
  --button-art: url("assets/ui/tex-command-button-v1.webp");
}

* { box-sizing: border-box; }

html, body { width: 100%; height: 100%; margin: 0; min-width: 320px; background: var(--ink); color: var(--paper); overflow: hidden; overscroll-behavior: none; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  font-family: "DIN Condensed", "Bahnschrift Condensed", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  background:
    radial-gradient(circle at 73% 12%, rgba(171, 116, 42, .12), transparent 28%),
    linear-gradient(135deg, #18211e 0%, #070b0b 65%);
}

.rotate-notice { display: none; }

button { font: inherit; }
button, [role="button"] { cursor: pointer; }
button:focus-visible { outline: 3px solid #f6d77c; outline-offset: 3px; }
[hidden] { display: none !important; }

.app-shell { width: 100%; height: 100vh; height: 100dvh; min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  position: relative;
  z-index: var(--z-hud);
  min-height: 74px;
  display: grid;
  grid-template-columns: 265px 1fr auto;
  align-items: stretch;
  border-bottom: 1px solid #3b4944;
  background: rgba(12, 19, 17, .94);
  box-shadow: 0 8px 32px rgba(0, 0, 0, .35);
}

.topbar::after {
  content: "";
  position: absolute;
  inset: auto 0 -4px;
  height: 4px;
  background: var(--brass);
  opacity: .4;
}

.brand-block { display: flex; align-items: center; gap: 13px; padding: 11px 20px; border-right: 1px solid #35413d; }
.brand-block strong { display: block; font-family: Impact, "PingFang SC", sans-serif; font-size: 24px; letter-spacing: .16em; font-weight: 500; line-height: 1; }
.brand-block small { display: block; margin-top: 5px; color: #9fa99e; font-size: 8px; letter-spacing: .16em; }

.brand-mark { width: 42px; height: 42px; display: flex; align-items: flex-end; justify-content: center; gap: 4px; padding: 8px; border: 2px solid var(--brass); transform: skewX(-8deg); }
.brand-mark i { display: block; width: 6px; background: var(--brass); }
.brand-mark i:nth-child(1) { height: 12px; }
.brand-mark i:nth-child(2) { height: 23px; }
.brand-mark i:nth-child(3) { height: 17px; }

.telemetry { display: grid; grid-template-columns: minmax(155px, 1.15fr) 1.25fr 1.15fr minmax(115px, .8fr); }
.telemetry-cell { min-width: 0; padding: 11px 18px; border-right: 1px solid #2f3c37; display: flex; flex-direction: column; justify-content: center; }
.telemetry-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .12em; }
.telemetry-cell strong { margin-top: 3px; font-size: 18px; letter-spacing: .04em; white-space: nowrap; }
.money-cell strong { color: #ffd56d; font-family: Impact, "PingFang SC", sans-serif; font-weight: 500; font-size: 25px; }
.mode-wave-status { min-width: 0; margin-top: 3px; display: flex; align-items: baseline; gap: 10px; }
.telemetry-cell .mode-wave-status strong { min-width: 0; margin: 0; }
#modeValue { flex: 0 0 auto; color: var(--brass); font-size: 14px; }
#waveValue { overflow: hidden; text-overflow: ellipsis; }

.mini-track { width: 100%; height: 3px; margin-top: 5px; background: #303b37; overflow: hidden; }
.mini-track i { display: block; width: 0; height: 100%; background: var(--brass); transition: width .25s ease; }
.mini-track.danger i { width: 100%; background: var(--safe); }

.command-buttons { display: flex; align-items: center; gap: 6px; padding: 0 14px; }
.icon-button {
  width: 46px; height: 46px; display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  color: #d9d4c5; border: 1px solid #46534e; background: #1a2421; transition: background .2s, border-color .2s, color .2s;
}
.icon-button:hover { color: #fff0bd; border-color: var(--brass); background: #26332e; }
.icon-button.active { color: #101613; background: var(--brass); }
.icon-button.wide { width: 63px; }
.icon-button svg { width: 20px; height: 20px; fill: currentColor; stroke: currentColor; stroke-width: 1.5; }
.icon-button span { font-weight: 800; font-size: 18px; }
.session-button { width: 78px; padding: 0 9px; background-image: linear-gradient(rgba(21,31,28,.38), rgba(8,13,12,.74)), var(--button-art); background-size: 100% 100%; }
.session-button svg { flex: 0 0 auto; fill: none; stroke-width: 2; }
.session-label { font-size: 16px !important; letter-spacing: .04em; }
.restart-button { color: #dce8df; border-color: #587469; }
.restart-button:hover { color: #e7ffef; border-color: #7bc697; }
.exit-button { color: #f0c6bd; border-color: #7b5149; }
.exit-button:hover { color: #ffe0d8; border-color: #e36b57; background-color: #4a2722; }

.battle-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 292px minmax(0, 1fr); gap: 12px; padding: 14px max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); }

.loadout-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #17211e, #0f1715);
  border: 1px solid #3c4944;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .3);
}

.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px; border-bottom: 1px solid #34413c; }
.panel-heading > div > span { display: block; font-family: Impact, "PingFang SC", sans-serif; font-size: var(--font-title); letter-spacing: .13em; }
.panel-heading small { display: block; margin-top: 4px; color: var(--brass); font-size: 9px; letter-spacing: .18em; }

.scrap-button { min-width: 84px; min-height: var(--touch-target); display: flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid #56635d; color: #c5cdc8; background: #222c29; font-size: 18px; transition: .2s; }
.scrap-button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.scrap-button:hover, .scrap-button[aria-pressed="true"] { color: #fff1cb; border-color: var(--signal); background: #63342c; }

.zone-rule { margin: 0; padding: 10px 14px; color: #b8c1bb; background: #111917; border-bottom: 1px solid #303d38; font-size: 12px; line-height: 1.55; }
.zone-rule b:first-child { color: #f0c45f; }
.zone-rule b:last-child { color: #ef7864; }

.build-cards { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; padding: 10px; overscroll-behavior: contain; scrollbar-width: none; }

.build-card {
  position: relative;
  width: 100%; min-height: 108px;
  display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: 10px;
  align-items: start; padding: 9px 9px 9px 10px; overflow: hidden;
  color: #e5ddc8; text-align: left;
  border: 1px solid #3d4a45; border-left: 4px solid var(--category, #71877d);
  background: #1a2421;
  transition: border-color .2s, background .2s, opacity .2s;
}
.build-card::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(105deg, transparent 55%, rgba(255,255,255,.04)); }
.build-card:hover { border-color: var(--brass); background: #23302b; }
.build-card.selected { border-color: #f2cb6e; box-shadow: inset 0 0 0 1px #f2cb6e; background: #2b3429; }
.build-card.unaffordable, .build-card.limit-reached { opacity: .55; }
.build-card[data-category="factory"] { --category: #d6aa4e; }
.build-card[data-category="weapon"] { --category: #d45f4d; }
.build-card[data-category="defense"] { --category: #769b87; }

.blueprint-icon { position: relative; width: 46px; height: 58px; display: flex; align-items: flex-end; justify-content: center; overflow: hidden; border: 1px solid #53615b; background-color: #0d1513; background-repeat: no-repeat; background-size: 300% 200%; color: var(--category); }
.blueprint-icon::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle, transparent 45%, rgba(5,9,8,.65)); pointer-events: none; }
.blueprint-icon i { display: none; }
.blueprint-icon small { position: relative; z-index: 1; width: 100%; padding: 3px 1px; color: #d8ddd8; background: rgba(7,12,11,.78); font-size: 7px; letter-spacing: .06em; text-align: center; }
[data-item="daily"] .blueprint-icon, [data-item="food"] .blueprint-icon, [data-item="auto"] .blueprint-icon, [data-item="armor"] .blueprint-icon, [data-item="wall"] .blueprint-icon { background-image: url("assets/sprites/atlas-factories-v2.webp"); }
[data-item="daily"] .blueprint-icon { background-position: 0 0; }
[data-item="food"] .blueprint-icon { background-position: 50% 0; }
[data-item="auto"] .blueprint-icon { background-position: 100% 0; }
[data-item="armor"] .blueprint-icon { background-position: 0 100%; }
[data-item="wall"] .blueprint-icon { background-position: 50% 100%; }
[data-item="pistol"] .blueprint-icon, [data-item="smg"] .blueprint-icon, [data-item="rocket"] .blueprint-icon, [data-item="howitzer"] .blueprint-icon, [data-item="tank"] .blueprint-icon, [data-item="nuke"] .blueprint-icon { background-image: url("assets/sprites/atlas-weapons-v2.webp"); }
[data-item="pistol"] .blueprint-icon { background-position: 0 0; }
[data-item="smg"] .blueprint-icon { background-position: 50% 0; }
[data-item="rocket"] .blueprint-icon { background-position: 100% 0; }
[data-item="howitzer"] .blueprint-icon { background-position: 0 100%; }
[data-item="tank"] .blueprint-icon { background-position: 50% 100%; }
[data-item="nuke"] .blueprint-icon { background-position: 100% 100%; }

.card-copy { min-width: 0; display: block; }
.card-copy strong { display: block; font-size: 18px; line-height: 1.25; letter-spacing: .04em; white-space: normal; overflow-wrap: anywhere; }
.card-copy > span:not(.card-cost) { display: block; margin-top: 4px; color: #aab5ae; font-size: var(--font-copy); line-height: 1.4; white-space: normal; overflow-wrap: anywhere; }
.card-copy .card-cost { width: fit-content; margin-top: 7px; display: inline-flex; align-items: center; min-height: 25px; padding: 3px 7px; color: #211c10; background: var(--brass); font-family: Impact, "PingFang SC", sans-serif; font-weight: 500; font-size: 14px; }
.card-hotkey { grid-column: 3; align-self: start; justify-self: end; color: #7e8a83; font-size: 9px; }

.keyboard-legend { padding: 9px 10px; border-top: 1px solid #34413c; color: #84918a; font-size: 9px; text-align: center; letter-spacing: .04em; }
kbd { padding: 2px 5px; color: #d4d9d6; border: 1px solid #51605a; background: #202b27; box-shadow: 0 2px 0 #0c1210; font: inherit; }

.battle-stage { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.mission-ribbon { min-height: 61px; display: grid; grid-template-columns: 220px 1fr 120px; align-items: center; gap: 18px; padding: 8px 15px; border: 1px solid #3c4944; border-bottom: 0; background: #151f1c; }
.mission-ribbon > div:first-child span, .next-wave span { display: block; color: var(--brass); font-size: 11px; letter-spacing: .12em; }
.mission-ribbon > div:first-child strong { display: block; margin-top: 3px; font-size: 17px; letter-spacing: .08em; }
.mission-ribbon p { margin: 0; color: #aab4ae; font-size: 12px; line-height: 1.5; }
.next-wave { padding-left: 15px; border-left: 1px solid #3a4742; text-align: right; }
.next-wave strong { display: block; margin-top: 3px; color: #f3d485; font: 500 20px Impact, sans-serif; letter-spacing: .08em; }

.canvas-frame { position: relative; min-height: 0; flex: 1; overflow: auto; border: 1px solid #46534d; background: #0c1311; box-shadow: inset 0 0 50px rgba(0, 0, 0, .4); cursor: grab; touch-action: none; overscroll-behavior: contain; scrollbar-width: none; }
.canvas-frame::-webkit-scrollbar, .build-cards::-webkit-scrollbar, .level-cards::-webkit-scrollbar, .zone-preview::-webkit-scrollbar { display: none; }
.canvas-frame.dragging { cursor: grabbing; user-select: none; }
#gameCanvas { display: block; width: auto; height: auto; max-width: none; max-height: none; cursor: crosshair; touch-action: none; }

.announcement { position: absolute; left: 50%; top: 18%; min-width: 320px; padding: 11px 32px; opacity: 0; transform: translate(-50%, -14px) skewX(-5deg); pointer-events: none; color: #17140d; background: var(--brass); box-shadow: 0 8px 28px rgba(0, 0, 0, .45); font-family: Impact, "PingFang SC", sans-serif; font-size: 24px; letter-spacing: .13em; text-align: center; }
.announcement.show { animation: announce 2.4s ease both; }

.asset-progress { position: absolute; right: 12px; bottom: 12px; padding: 5px 12px; pointer-events: none; color: #d9cead; border: 1px solid rgba(224, 184, 91, .34); background: rgba(8, 13, 12, .82); clip-path: polygon(7px 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%, 0 7px); font-size: 11px; letter-spacing: .12em; }

.pause-plate { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(7, 12, 11, .78); backdrop-filter: blur(4px); }
.pause-plate span { color: var(--brass); font-size: 11px; letter-spacing: .35em; }
.pause-plate strong { margin-top: 5px; font: 500 24px Impact, "PingFang SC", sans-serif; letter-spacing: .16em; }
.pause-plate small { margin-top: 9px; color: #9daba2; }

.intel-strip { min-height: 46px; display: grid; grid-template-columns: 190px 1fr 155px; align-items: center; border: 1px solid #3c4944; border-top: 0; background: #151f1c; }
.intel-strip > div { min-height: 45px; padding: 8px 13px; display: flex; align-items: center; gap: 8px; border-right: 1px solid #33403b; }
.intel-status { color: #aab4ad; font-size: 12px; }
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--safe); box-shadow: 0 0 0 0 rgba(115, 206, 145, .7); animation: pulse 1.6s infinite; }
.selected-info { min-width: 0; color: #c4cbc6; font-size: 12px; }
.selected-info strong { color: #f1cf75; }
.selected-info span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.factory-meter { justify-content: space-between; border-right: 0 !important; color: #9ca9a1; font-size: 12px; }
.factory-meter strong { color: #edc86c; font-size: 14px; }

.toast { position: fixed; z-index: 30; left: 50%; bottom: 24px; max-width: min(460px, calc(100vw - 30px)); padding: 11px 18px; opacity: 0; transform: translate(-50%, 15px); color: #f5e7c7; border: 1px solid #d66b58; background: #402820; box-shadow: 0 9px 25px rgba(0,0,0,.4); pointer-events: none; font-size: 13px; }
.toast.show { animation: toast 2.15s ease both; }

.full-overlay, .dialog-overlay { position: fixed; z-index: var(--z-modal); inset: 0; width: 100%; height: 100vh; height: 100dvh; overflow: hidden; }
.menu-overlay { overflow: hidden; background-image: linear-gradient(90deg, rgba(6,10,9,.96) 0%, rgba(7,12,11,.86) 46%, rgba(7,11,10,.3) 100%), linear-gradient(0deg, rgba(6,9,8,.8), transparent 52%), url("assets/ui/bg-command-center-v2.webp"); background-size: cover; background-position: center; }
.menu-content { position: relative; width: min(1180px, calc(100% - 40px)); height: 100%; min-height: 0; margin: 0 auto; padding: clamp(16px, 3vh, 32px) 0 max(16px, env(safe-area-inset-bottom)); display: grid; grid-template-rows: auto auto minmax(0, 1fr) 48px; gap: clamp(10px, 1.5vh, 18px); overflow: hidden; }

.title-lockup { max-width: 700px; animation: reveal .7s ease both; }
.eyebrow { color: var(--brass); font-size: 10px; font-weight: 800; letter-spacing: .28em; }
.title-lockup h1 { margin: 5px 0 7px; font: 500 var(--font-title-xl)/1 Impact, "PingFang SC", sans-serif; letter-spacing: .12em; text-transform: uppercase; }
.title-lockup h1 span { color: var(--signal); }
.title-lockup p { max-width: 610px; margin: 0; color: #b9c1bc; font-size: var(--font-copy); line-height: 1.6; letter-spacing: .03em; }

.doctrine-grid { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid #3d4b45; background: rgba(18,27,24,.78); animation: reveal .7s .1s ease both; }
.doctrine-grid article { position: relative; min-height: 76px; padding: 13px 18px 12px 58px; border-right: 1px solid #3d4b45; }
.doctrine-grid article:last-child { border: 0; }
.doctrine-grid b { position: absolute; left: 17px; top: 13px; color: #6a756f; font: 500 24px Impact, sans-serif; }
.doctrine-grid strong, .doctrine-grid span { display: block; }
.doctrine-grid strong { font-size: 14px; letter-spacing: .08em; }
.doctrine-grid span { margin-top: 5px; color: #9eaaa3; font-size: var(--font-copy); line-height: 1.45; }

.level-cards { min-width: 0; min-height: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(88px, 1fr)); gap: 8px; overflow: hidden; animation: reveal .7s .2s ease both; }
.level-card { position: relative; min-width: 0; min-height: 0; height: 100%; padding: 13px; overflow: hidden; text-align: left; color: var(--paper); border: 1px solid #46534e; background: linear-gradient(135deg, #1b2622, #111816); transition: border-color .2s, background .2s; }
.level-card::after { content: attr(data-index); position: absolute; right: -2px; bottom: -15px; color: rgba(255,255,255,.035); font: 500 86px Impact, sans-serif; }
.level-card:hover:not(:disabled) { border-color: var(--brass); background: linear-gradient(135deg, #26322b, #171f1d); }
.level-card:disabled { cursor: not-allowed; filter: grayscale(.8); opacity: .48; }
.level-card .mission-number { color: var(--brass); font-size: 9px; letter-spacing: .2em; }
.level-card strong { position: relative; z-index: 1; display: block; margin-top: 11px; font-size: 20px; letter-spacing: .08em; }
.level-card p { position: relative; z-index: 1; margin: 6px 0 9px; color: #9ea9a2; font-size: var(--font-copy); line-height: 1.4; }
.level-card small { font-size: 12px; }
.level-card small { position: relative; z-index: 1; color: #d7ba73; }
.level-card.completed { border-color: #557d64; }
.level-card.completed .mission-number { color: #80d49a; }

.menu-footer { min-height: 0; height: 100%; display: flex; justify-content: space-between; align-items: center; overflow: hidden; color: #8e9a93; font-size: 12px; animation: reveal .7s .3s ease both; }
.menu-footer button { height: 100%; min-height: 0; padding: 0 16px; color: #b9c2bc; border: 1px solid #3c4944; background: rgba(10,16,14,.62); font-size: 16px; }
.menu-footer button:hover { color: #e6d8b9; border-color: #8e5a50; }

.dialog-overlay { display: flex; align-items: center; justify-content: center; padding: 20px; overflow: hidden; background: rgba(6,10,9,.82); backdrop-filter: blur(7px); }
.result-card, .manual-card, .deployment-card { width: min(680px, 100%); border: 1px solid #54625c; background: linear-gradient(145deg, rgba(28,39,35,.98), rgba(16,23,21,.98)); box-shadow: 0 30px 80px rgba(0,0,0,.55); animation: dialogIn .3s ease both; }
.result-card { padding: 36px; text-align: center; }
.result-card h2 { margin: 8px 0; font: 500 24px Impact, "PingFang SC", sans-serif; letter-spacing: .12em; }
.result-card > p { margin: 0; color: #aeb8b2; font-size: var(--font-copy); }
.result-card.defeat { border-color: #8e493e; }
.result-card.defeat h2 { color: #ef725f; }

.result-stats { margin: 25px 0; display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid #3b4843; }
.result-stats div { padding: 15px 8px; border-right: 1px solid #3b4843; }
.result-stats div:last-child { border: 0; }
.result-stats span, .result-stats strong { display: block; }
.result-stats span { color: #89968f; font-size: 9px; letter-spacing: .08em; }
.result-stats strong { margin-top: 7px; color: #f0ce75; font-size: 20px; }

.dialog-actions { display: flex; justify-content: center; gap: 10px; }
.dialog-actions button { min-width: 160px; min-height: 52px; padding: 0 20px; border: 1px solid; background-image: linear-gradient(rgba(26,36,32,.3), rgba(8,13,12,.58)), var(--button-art); background-size: 100% 100%; font-size: var(--font-action); font-weight: 800; letter-spacing: .04em; }
.dialog-actions .primary-action { color: #17140c; border-color: #f0c863 !important; background: var(--brass); background-image: none; }
.dialog-actions .primary-action:hover { background: #f3d27d; }
.dialog-actions .primary-action:disabled { color: #6f746f; border-color: #4a514d !important; background: #2a312e; background-image: none; cursor: not-allowed; }
.secondary-action { color: #d5d9d6; border-color: #53615b !important; background: #202b27; }
.secondary-action:hover { border-color: #92a199 !important; }

.deployment-card { width: min(980px, 100%); height: calc(100vh - 40px); height: calc(100dvh - 40px); max-height: none; min-height: 0; padding: 26px; display: grid; grid-template-rows: auto auto auto minmax(0, 1fr) auto auto; gap: 10px; overflow: hidden; background-image: linear-gradient(135deg, rgba(16,24,21,.93), rgba(9,15,13,.96)), url("assets/ui/tex-battlefield-v2.webp"), var(--mission-art, url("assets/backgrounds/bg-level-01-suburban.webp")); background-size: auto, 560px, cover; background-position: center; }
.deployment-card > * { min-width: 0; min-height: 0; }
.deployment-copy h2 { margin: 5px 0 8px; font: 500 24px Impact, "PingFang SC", sans-serif; letter-spacing: .1em; }
.deployment-copy > strong { color: #edc86c; font-size: 13px; letter-spacing: .1em; }
.deployment-copy p { margin: 9px 0 0; color: #aeb9b2; font-size: 12px; line-height: 1.6; }
.mode-options { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mode-options button { min-height: 78px; padding: 11px 14px; text-align: left; color: #b8c2bc; border: 1px solid #485650; background: rgba(20,30,27,.9); transition: .2s; }
.mode-options button:hover { border-color: #d3aa50; }
.mode-options button.selected { color: #f4deaa; border-color: #e0b85b; background: linear-gradient(120deg, rgba(111,83,33,.48), rgba(25,35,31,.95)); box-shadow: inset 4px 0 #e0b85b, 0 0 25px rgba(210,166,73,.1); }
.mode-options span, .mode-options strong, .mode-options small { display: block; }
.mode-options span { color: #d8b65f; font-size: 8px; letter-spacing: .18em; }
.mode-options strong { margin-top: 3px; font-size: var(--font-action); letter-spacing: .06em; }
.mode-options small { margin-top: 4px; color: #aeb8b2; font-size: var(--font-copy); }
.scenario-config { margin: 0; display: grid; grid-template-columns: 1fr auto; align-items: stretch; gap: 8px; }
.map-size-controls { display: flex; align-items: center; gap: 9px; padding: 8px 12px; border: 1px solid #42504a; background: rgba(11,18,16,.76); }
.map-size-controls label { flex: 1; display: grid; grid-template-columns: 1fr 72px; align-items: center; gap: 8px; }
.map-size-controls label span, .random-map-summary span { color: #aab4ae; font-size: 12px; letter-spacing: .06em; }
.map-size-controls input { width: 100%; height: var(--touch-target); padding: 0 7px; color: #f0cf77; border: 1px solid #5a674f; background: #111a17; font: 500 20px Impact, sans-serif; text-align: center; }
.map-size-controls input[aria-invalid="true"] { color: #ffb0a0; border-color: #d66b58; }
.map-size-controls b { color: #d6b35b; font-size: 18px; }
.random-map-summary { display: flex; flex-direction: column; justify-content: center; padding: 8px 12px; border: 1px solid #725f36; background: rgba(79,62,28,.24); }
.random-map-summary strong { margin-top: 3px; color: #f0cf77; font-size: 15px; }
.reroll-scenario { min-width: 170px; min-height: var(--touch-target); padding: 0 14px; color: #d9d5c8; border: 1px solid #56645d; background: #1a2521; font-size: 18px; letter-spacing: .04em; }
.reroll-scenario:hover { color: #f2d583; border-color: #caa650; }
.zoning-console { margin: 0; min-height: 0; display: grid; grid-template-columns: 1.5fr .75fr; gap: 16px; align-items: stretch; overflow: hidden; }
.zone-preview { display: grid; grid-template-columns: repeat(var(--map-cols, 10), var(--touch-target)); grid-template-rows: repeat(var(--map-rows, 5), var(--touch-target)); align-content: start; justify-content: start; gap: 4px; width: 100%; height: 100%; min-height: 0; padding: 10px; overflow: auto; border: 1px solid #46534e; background: rgba(5,10,8,.8); touch-action: none; overscroll-behavior: contain; scrollbar-width: none; }
.zone-preview.dragging { cursor: grabbing; user-select: none; }
.zone-preview button { position: relative; width: var(--touch-target); height: var(--touch-target); min-width: var(--touch-target); padding: 0; overflow: hidden; color: #a9b1ac; border: 1px solid; transition: transform .15s, color .2s, background .2s, border-color .2s, box-shadow .2s; }
.zone-preview button:hover { z-index: 1; transform: translateY(-2px); color: #fff4d1; border-color: #f0c96c; }
.zone-preview button:focus-visible { z-index: 2; outline-offset: 1px; }
.zone-preview button span { position: absolute; left: 4px; top: 3px; opacity: .7; font-size: 7px; letter-spacing: .04em; }
.zone-preview button b { display: block; font: 500 16px Impact, "PingFang SC", sans-serif; letter-spacing: .08em; }
.zone-preview button.industry { color: #f5d984; border-color: #b69242; background: #4d482b; box-shadow: inset 0 0 13px rgba(240,190,70,.16); }
.zone-preview button.defense { border-color: #75463d; background: #382d2a; }
.zone-preview button.converted { color: #9ec8c5; border-color: #5d8c87; background: #29413d; }
.zone-preview.random-locked button { cursor: not-allowed; opacity: 1; }
.zone-preview.random-locked button:hover { transform: none; }
.zone-preview.convert-active button[data-random-factory="true"]:not(.converted) { cursor: pointer; box-shadow: inset 0 0 0 1px rgba(146,211,202,.65); }
.zone-preview.pan-active { cursor: grab; }
.zone-preview.pan-active button { pointer-events: none; }
.zoning-control > span { color: #b6c0ba; font-size: 12px; letter-spacing: .08em; }
.selection-counter { margin-top: 10px; padding: 12px; border: 1px solid #78633a; background: rgba(86,68,31,.25); }
.selection-counter small, .selection-counter strong { display: block; }
.selection-counter small { color: #a8b1ab; font-size: 9px; letter-spacing: .12em; }
.selection-counter strong { margin-top: 4px; color: #f0cd73; font: 500 28px Impact, sans-serif; letter-spacing: .08em; }
.zoning-legend { margin-top: 8px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.zoning-legend span { padding: 8px; border: 1px solid; font-size: 12px; text-align: center; }
.zoning-legend .industry { color: #efd075; border-color: #8f7338; background: rgba(109,87,39,.25); }
.zoning-legend .defense { color: #d78b7d; border-color: #74463e; background: rgba(96,49,42,.22); }
.zoning-tools { margin-top: 8px; display: grid; grid-template-columns: 1fr; gap: 5px; }
.tool-zoning { width: 100%; min-height: var(--touch-target); color: #c7ceca; border: 1px solid #4b5953; background: #1b2522; font-size: 16px; }
.tool-zoning:hover:not(:disabled), .tool-zoning[aria-pressed="true"] { border-color: #d4b05b; color: #f1d787; background: #2d2a1c; }
.tool-zoning:disabled { opacity: .4; cursor: not-allowed; }
.convert-zoning { color: #a9d5d0; border-color: #557e79; }
.zoning-control p { min-height: 57px; margin: 12px 0 0; padding: 10px; color: #b3bcb6; border-left: 3px solid #d3aa4e; background: rgba(12,19,17,.75); font-size: var(--font-copy); line-height: 1.55; }
.zoning-stats { margin: 0; display: grid; grid-template-columns: repeat(5, 1fr); border: 1px solid #3e4b46; }
.zoning-stats div { padding: 11px; border-right: 1px solid #3e4b46; text-align: center; }
.zoning-stats div:last-child { border: 0; }
.zoning-stats span, .zoning-stats strong { display: block; }
.zoning-stats span { color: #84918a; font-size: 9px; }
.zoning-stats strong { margin-top: 5px; color: #ebc86d; font-size: 18px; }

.manual-card { width: min(900px, 100%); max-height: calc(100vh - 40px); padding: 28px; overflow-y: auto; }
.manual-heading { display: flex; justify-content: space-between; align-items: flex-start; }
.manual-heading h2 { margin: 5px 0 0; font: 500 24px Impact, "PingFang SC", sans-serif; letter-spacing: .12em; }
.close-button { width: 44px; height: 44px; color: #d7d2c5; border: 1px solid #4f5c56; background: #1b2522; font-size: 25px; }
.close-button:hover { color: #fff; border-color: var(--signal); }
.manual-grid { margin-top: 24px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: #3d4a45; border: 1px solid #3d4a45; }
.manual-grid article { padding: 17px; background: #17211e; }
.manual-grid b { color: #e6c56f; font-size: 14px; }
.manual-grid p { margin: 8px 0 0; color: #a8b2ac; font-size: 12px; line-height: 1.6; }
.balance-table { margin-top: 18px; border: 1px solid #3c4944; font-size: 12px; }
.balance-table [role="row"] { display: grid; grid-template-columns: 1.1fr .8fr .8fr 1.3fr; }
.balance-table [role="row"] > * { padding: 9px 11px; border-right: 1px solid #34413c; }
.balance-table [role="row"] > *:last-child { border: 0; }
.balance-table [role="row"]:first-child { color: #17140c; background: #c9a956; }
.balance-table [role="row"]:not(:first-child) { border-top: 1px solid #34413c; color: #adb7b1; }

/* Forge Command visual system: industrial armor, amber optics and tactical scan layers. */
.app-shell { background: radial-gradient(circle at 56% 0, rgba(231, 176, 63, .08), transparent 29%), linear-gradient(135deg, #111a18, #070b0a 72%); }
.topbar { border-bottom-color: #7e6638; background: linear-gradient(180deg, rgba(28, 37, 34, .98), rgba(9, 15, 13, .97)); box-shadow: 0 10px 38px rgba(0,0,0,.52), inset 0 1px rgba(255,255,255,.05); }
.topbar::before { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .32; background: linear-gradient(110deg, transparent 0 18%, rgba(238,199,105,.08) 18.2% 18.35%, transparent 18.5% 72%, rgba(238,199,105,.06) 72.2% 72.35%, transparent 72.5%); }
.topbar::after { opacity: .9; background: linear-gradient(90deg, transparent, var(--brass) 12% 76%, var(--signal) 94%, transparent); box-shadow: 0 0 14px rgba(224,184,91,.5); }
.brand-block { position: relative; background: linear-gradient(100deg, rgba(224,184,91,.08), transparent 65%); }
.brand-block::after { content: "CMD // 09"; position: absolute; right: 10px; bottom: 5px; color: rgba(224,184,91,.35); font: 8px "DIN Condensed", sans-serif; letter-spacing: .15em; }
.brand-block strong { color: #f4ead3; text-shadow: 0 0 18px rgba(239,190,75,.25); }
.brand-mark { position: relative; border-color: var(--amber-hot); box-shadow: inset 0 0 18px rgba(224,184,91,.12), 0 0 18px rgba(224,184,91,.12); }
.brand-mark::after { content: ""; position: absolute; width: 5px; height: 5px; right: -4px; top: -4px; border-radius: 50%; background: var(--signal); box-shadow: 0 0 9px var(--signal); animation: statusBlink 2.4s steps(1) infinite; }
.telemetry-cell { position: relative; background: linear-gradient(180deg, rgba(255,255,255,.025), transparent); }
.telemetry-cell::after { content: ""; position: absolute; left: 18px; right: 18px; bottom: 5px; height: 1px; opacity: .55; background: linear-gradient(90deg, var(--brass), transparent); }
.money-cell strong { color: var(--amber-hot); text-shadow: 0 0 18px rgba(255,190,65,.28); }
.mini-track { height: 4px; border: 1px solid rgba(255,255,255,.05); background: #090e0d; box-shadow: inset 0 1px 4px rgba(0,0,0,.9); }
.mini-track i { box-shadow: 0 0 9px currentColor; }

.icon-button, .scrap-button, .reroll-scenario, .tool-zoning, .close-button, .menu-footer button {
  position: relative;
  overflow: hidden;
  border-color: #5b6862;
  background-color: #18211f;
  background-image: linear-gradient(rgba(21,30,27,.5), rgba(7,11,10,.76)), var(--button-art);
  background-size: 100% 100%;
  box-shadow: inset 0 1px rgba(255,255,255,.06), 0 4px 12px rgba(0,0,0,.22);
  transition: color .2s, border-color .2s, box-shadow .2s, filter .2s, transform .2s;
}
.icon-button:hover, .reroll-scenario:hover, .tool-zoning:hover:not(:disabled), .close-button:hover, .menu-footer button:hover { transform: translateY(-1px); filter: brightness(1.15); box-shadow: inset 0 1px rgba(255,255,255,.09), 0 0 18px rgba(224,184,91,.14); }
.icon-button:active, .scrap-button:active, .reroll-scenario:active, .tool-zoning:active, .dialog-actions button:active { transform: translateY(1px); }

.loadout-panel, .mission-ribbon, .intel-strip { border-color: #52605a; background-image: linear-gradient(145deg, rgba(31,43,39,.97), rgba(11,17,15,.98)), url("assets/ui/tex-battlefield-v2.webp"); background-size: auto, 460px; box-shadow: 0 16px 42px rgba(0,0,0,.38), inset 0 1px rgba(255,255,255,.04); }
.loadout-panel { position: relative; clip-path: polygon(0 0, calc(100% - 13px) 0, 100% 13px, 100% 100%, 0 100%); }
.loadout-panel::after { content: ""; position: absolute; z-index: 3; right: 0; top: 0; width: 14px; height: 14px; background: var(--brass); clip-path: polygon(0 0, 100% 100%, 100% 0); }
.panel-heading { background: linear-gradient(90deg, rgba(224,184,91,.1), transparent); }
.panel-heading > div > span { color: #f4ead1; text-shadow: 0 0 16px rgba(224,184,91,.2); }
.zone-rule { background: rgba(7,12,10,.9); box-shadow: inset 4px 0 #6b5a31; }

.build-card { min-height: 116px; gap: 11px; border-color: #48564f; border-left-width: 4px; background: linear-gradient(105deg, rgba(32,44,40,.97), rgba(13,20,18,.98) 74%); clip-path: polygon(0 0, calc(100% - 11px) 0, 100% 11px, 100% 100%, 0 100%); box-shadow: inset 0 1px rgba(255,255,255,.035), 0 6px 16px rgba(0,0,0,.17); transition: border-color .2s, background .2s, opacity .2s, transform .2s, box-shadow .2s; }
.build-card::before { content: ""; position: absolute; z-index: 2; right: 0; top: 0; width: 11px; height: 11px; background: var(--category); clip-path: polygon(0 0, 100% 100%, 100% 0); }
.build-card::after { background: linear-gradient(110deg, transparent 0 58%, rgba(255,255,255,.055) 68%, transparent 80%); }
.build-card:hover { transform: translateX(3px); border-color: var(--category); background: linear-gradient(105deg, rgba(42,56,50,.98), rgba(17,25,22,.98)); box-shadow: inset 0 1px rgba(255,255,255,.05), 0 8px 22px rgba(0,0,0,.26); }
.build-card.selected { transform: translateX(4px); border-color: var(--amber-hot); background: linear-gradient(105deg, rgba(66,60,35,.95), rgba(20,29,25,.98)); box-shadow: inset 0 0 0 1px rgba(255,220,126,.7), 0 0 22px rgba(224,184,91,.18); animation: selectedCard 1.8s ease-in-out infinite; }
.build-card.unaffordable, .build-card.limit-reached { opacity: .48; filter: saturate(.55); }
.blueprint-icon { width: 50px; height: 64px; border-color: #66756d; clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 0 100%); box-shadow: inset 0 0 22px rgba(0,0,0,.65), 0 0 0 1px rgba(0,0,0,.45); }
.blueprint-icon::before { content: ""; position: absolute; z-index: 1; inset: 0; pointer-events: none; background: linear-gradient(90deg, transparent 49%, rgba(224,184,91,.18) 50%, transparent 51%), linear-gradient(0deg, transparent 49%, rgba(224,184,91,.12) 50%, transparent 51%); }
.blueprint-icon small { border-top: 1px solid rgba(224,184,91,.35); color: #f5e3b4; }
.card-role { display: block !important; margin: 0 0 3px !important; color: var(--category) !important; font-size: 8px !important; line-height: 1 !important; letter-spacing: .15em; }
.card-copy strong { color: #f0eadb; font-size: 19px; text-shadow: 0 1px #000; }
.card-copy .card-cost { color: #17130a; background: linear-gradient(180deg, #f3d782, #c89a3e); box-shadow: inset 0 1px rgba(255,255,255,.35), 0 2px 8px rgba(0,0,0,.25); clip-path: polygon(0 0, calc(100% - 6px) 0, 100% 6px, 100% 100%, 0 100%); }
.card-hotkey { padding: 3px 5px; color: #c3ccc6; border: 1px solid #4f5c56; background: rgba(5,9,8,.6); }

.canvas-frame { border-color: #65736c; background-image: radial-gradient(circle at 50% 45%, rgba(224,184,91,.045), transparent 40%), url("assets/ui/tex-battlefield-v2.webp"); background-size: auto, 620px; box-shadow: inset 0 0 70px rgba(0,0,0,.56), 0 18px 45px rgba(0,0,0,.28); }
.canvas-frame::before { content: ""; position: absolute; z-index: 2; display: block; left: 0; top: 0; width: 100%; height: 3px; pointer-events: none; background: linear-gradient(90deg, transparent, rgba(255,215,112,.7), transparent); box-shadow: 0 0 12px rgba(255,204,90,.32); animation: radarSweep 5.8s ease-in-out infinite; }
.mission-ribbon { position: relative; overflow: hidden; }
.mission-ribbon::after { content: "ACTIVE THEATER"; position: absolute; right: 132px; top: 3px; color: rgba(224,184,91,.25); font-size: 7px; letter-spacing: .2em; }
.intel-strip { box-shadow: 0 12px 30px rgba(0,0,0,.25); }
.pulse-dot { background: #8bf0a9; box-shadow: 0 0 12px rgba(115,206,145,.7); }

.menu-overlay { background-image: linear-gradient(90deg, rgba(4,8,7,.97) 0%, rgba(6,11,10,.88) 44%, rgba(7,11,10,.2) 100%), radial-gradient(circle at 72% 34%, rgba(225,151,48,.1), transparent 26%), linear-gradient(0deg, rgba(4,7,6,.86), transparent 58%), url("assets/ui/bg-command-center-v2.webp"); }
.menu-content { z-index: 1; }
.title-lockup { max-width: 780px; }
.eyebrow { display: inline-flex; align-items: center; gap: 9px; color: var(--amber-hot); text-shadow: 0 0 15px rgba(224,184,91,.26); }
.eyebrow::before { content: ""; width: 28px; height: 2px; background: var(--signal); box-shadow: 0 0 8px rgba(230,93,72,.55); }
.title-lockup h1 { margin: 7px 0 8px; font-size: clamp(44px, 6.5vw, 82px); letter-spacing: .08em; text-shadow: 0 4px 0 #080b0a, 0 0 34px rgba(224,184,91,.13); }
.title-lockup h1 span { position: relative; color: #f0725d; text-shadow: 0 0 28px rgba(230,93,72,.22); }
.title-lockup p { max-width: 650px; color: #d0d7d1; font-size: 14px; }
.command-status { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 7px; color: #9ca9a1; font-size: 9px; letter-spacing: .1em; }
.command-status span { min-height: 24px; display: inline-flex; align-items: center; gap: 7px; padding: 4px 9px; border: 1px solid rgba(103,119,111,.65); background: rgba(7,12,10,.66); }
.command-status i { width: 6px; height: 6px; border-radius: 50%; background: var(--safe); box-shadow: 0 0 8px var(--safe); }
.doctrine-grid { border-color: #59665f; background: linear-gradient(90deg, rgba(19,29,25,.93), rgba(9,15,13,.78)); box-shadow: 0 12px 32px rgba(0,0,0,.24), inset 0 1px rgba(255,255,255,.04); clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 0 100%); }
.doctrine-grid article { border-right-color: #47544e; }
.doctrine-grid b { color: rgba(224,184,91,.28); }
.doctrine-grid strong { color: #efe7d4; }
.level-card { border-color: #53615a; background: linear-gradient(145deg, rgba(31,43,38,.94), rgba(9,15,13,.98)); clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 0 100%); box-shadow: inset 0 1px rgba(255,255,255,.035), 0 8px 20px rgba(0,0,0,.16); transition: border-color .2s, background .2s, transform .2s, box-shadow .2s; }
.level-card::before { content: ""; position: absolute; left: 0; top: 0; width: 34%; height: 3px; background: var(--brass); box-shadow: 0 0 10px rgba(224,184,91,.35); }
.level-card:hover:not(:disabled) { transform: translateY(-3px); border-color: var(--amber-hot); background: linear-gradient(145deg, rgba(49,56,39,.97), rgba(14,22,19,.99)); box-shadow: 0 13px 30px rgba(0,0,0,.32), inset 0 0 24px rgba(224,184,91,.045); }
.level-card.completed::before { background: var(--safe); box-shadow: 0 0 10px rgba(115,206,145,.45); }
.level-card:disabled::before { background: #68716c; box-shadow: none; }
.level-card small { display: inline-block; padding: 3px 6px; border: 1px solid rgba(224,184,91,.28); background: rgba(95,74,30,.16); }

.dialog-overlay { background: radial-gradient(circle at 50% 45%, rgba(224,184,91,.08), transparent 34%), rgba(3,7,6,.87); }
.result-card, .manual-card, .deployment-card { border-color: #68766f; box-shadow: 0 34px 100px rgba(0,0,0,.68), inset 0 1px rgba(255,255,255,.04); }
.result-card, .manual-card { background-image: linear-gradient(145deg, rgba(30,42,37,.98), rgba(10,16,14,.99)), url("assets/ui/tex-battlefield-v2.webp"); background-size: auto, 560px; }
.deployment-card { border-top: 3px solid var(--brass); }
.mode-options button { position: relative; overflow: hidden; border-color: #59665f; background: linear-gradient(135deg, rgba(26,38,33,.95), rgba(11,17,15,.96)); clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 9px, 100% 100%, 0 100%); }
.mode-options button::after { content: ""; position: absolute; right: 0; top: 0; width: 9px; height: 9px; background: #66746d; clip-path: polygon(0 0, 100% 100%, 100% 0); }
.mode-options button.selected::after { background: var(--amber-hot); }
.mode-options button.selected { box-shadow: inset 4px 0 var(--amber-hot), 0 0 28px rgba(224,184,91,.12); }
.map-size-controls, .random-map-summary, .selection-counter, .zoning-stats { box-shadow: inset 0 1px rgba(255,255,255,.035), 0 6px 18px rgba(0,0,0,.16); }
.zone-preview { border-color: #5c6a63; background-image: linear-gradient(rgba(3,7,6,.82), rgba(3,7,6,.82)), url("assets/ui/tex-battlefield-v2.webp"); background-size: auto, 430px; box-shadow: inset 0 0 36px rgba(0,0,0,.5); }
.zone-preview button.industry { background: linear-gradient(145deg, #5b512b, #332f1f); }
.zone-preview button.defense { background: linear-gradient(145deg, #482e29, #2b2220); }
.zone-preview button.converted { background: linear-gradient(145deg, #31504a, #213733); }
.zoning-stats strong, .result-stats strong { text-shadow: 0 0 14px rgba(224,184,91,.2); }

@keyframes statusBlink { 0%, 46%, 50%, 100% { opacity: 1; } 47%, 49% { opacity: .2; } }
@keyframes selectedCard { 0%, 100% { box-shadow: inset 0 0 0 1px rgba(255,220,126,.68), 0 0 18px rgba(224,184,91,.12); } 50% { box-shadow: inset 0 0 0 1px rgba(255,220,126,.9), 0 0 27px rgba(224,184,91,.25); } }
@keyframes radarSweep { 0%, 12% { transform: translateY(-3px); opacity: 0; } 45%, 55% { opacity: .7; } 88%, 100% { transform: translateY(calc(100vh - 140px)); opacity: 0; } }

@keyframes reveal { from { opacity: 0; transform: translateY(17px); } to { opacity: 1; transform: translateY(0); } }
@keyframes announce { 0% { opacity: 0; transform: translate(-50%, -14px) skewX(-5deg); } 12%, 75% { opacity: 1; transform: translate(-50%, 0) skewX(-5deg); } 100% { opacity: 0; transform: translate(-50%, 10px) skewX(-5deg); } }
@keyframes toast { 0%, 100% { opacity: 0; transform: translate(-50%, 15px); } 12%, 78% { opacity: 1; transform: translate(-50%, 0); } }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(115,206,145,0); } 100% { box-shadow: 0 0 0 0 rgba(115,206,145,0); } }
@keyframes dialogIn { from { opacity: 0; transform: translateY(20px) scale(.98); } to { opacity: 1; transform: none; } }

@media (max-width: 1120px) {
  .topbar { grid-template-columns: 205px 1fr auto; }
  .brand-block { padding-left: 13px; }
  .brand-block strong { font-size: 20px; }
  .brand-mark { width: 36px; height: 36px; }
  .telemetry { grid-template-columns: 1.1fr 1fr 1fr; }
  .time-cell { display: none; }
  .telemetry-cell { padding-inline: 10px; }
  .session-button { width: 46px; padding: 0; }
  .session-label { display: none; }
  .battle-layout { grid-template-columns: 240px minmax(0,1fr); padding: 8px; gap: 8px; }
  .loadout-panel { font-size: 14px; }
  .build-card { grid-template-columns: 42px minmax(0, 1fr) auto; padding-left: 7px; }
  .blueprint-icon { width: 40px; }
  .mission-ribbon { grid-template-columns: 190px 1fr 100px; }
  #gameCanvas { max-height: none; }
}

@media (max-width: 980px) and (orientation: landscape), (max-height: 560px) and (orientation: landscape) {
  body { font-size: 13px; }
  .topbar { min-height: 60px; grid-template-columns: 116px minmax(180px, 1fr) auto; padding: env(safe-area-inset-top) max(3px, env(safe-area-inset-right)) 0 max(3px, env(safe-area-inset-left)); }
  .brand-mark { display: none; }
  .brand-block { gap: 0; padding: 6px 7px; }
  .brand-block strong { font-size: 16px; letter-spacing: .08em; }
  .brand-block small, .telemetry-label { display: none; }
  .telemetry-cell { padding: 5px 6px; }
  .telemetry-cell strong { font-size: 14px; }
  .money-cell strong { font-size: 18px; }
  .mode-wave-status { margin-top: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; }
  #modeValue { font-size: 10px; line-height: 1.1; }
  #waveValue { font-size: 13px; line-height: 1.15; }
  .command-buttons { padding-inline: 4px; gap: 3px; }
  .icon-button { width: 44px; height: 44px; }
  .icon-button.wide { width: 50px; }
  .session-button { width: 44px; }
  .help-button { display: none; }
  .battle-layout { grid-template-columns: 184px minmax(0,1fr); padding: 4px max(4px, env(safe-area-inset-right)) max(4px, env(safe-area-inset-bottom)) max(4px, env(safe-area-inset-left)); gap: 4px; }
  .panel-heading { min-height: 48px; padding: 4px 6px; }
  .panel-heading > div > span { font-size: 16px; }
  .panel-heading small { font-size: 10px; }
  .scrap-button { min-width: 70px; min-height: 44px; padding: 0 6px; font-size: 16px; }
  .zone-rule, .keyboard-legend { display: none; }
  .build-cards { padding: 5px; gap: 4px; }
  .build-card { min-height: 96px; grid-template-columns: 38px minmax(0, 1fr) auto; padding: 6px; }
  .blueprint-icon { width: 36px; height: 48px; }
  .card-copy strong { font-size: 14px; }
  .card-copy > span:not(.card-cost) { margin-top: 3px; font-size: 11px; line-height: 1.3; }
  .card-copy .card-role { display: none !important; }
  .card-copy .card-cost { min-height: 22px; margin-top: 5px; padding: 2px 6px; font-size: 13px; }
  .blueprint-icon small, .card-hotkey { display: none; }
  .mission-ribbon { min-height: 48px; grid-template-columns: 160px 1fr 92px; padding: 4px 10px; }
  .mission-ribbon p { display: none; }
  .intel-strip { min-height: 44px; grid-template-columns: 130px 1fr 112px; }
  .intel-strip > div { min-height: 43px; padding: 4px 8px; }
  #gameCanvas { max-height: none; }
  .dialog-overlay { padding: 5px; }
  .menu-content { width: calc(100% - 20px); padding: 8px 0 max(8px, env(safe-area-inset-bottom)); gap: 6px; }
  .title-lockup h1 { margin-block: 2px; font-size: 22px; }
  .title-lockup p { font-size: 12px; line-height: 1.35; }
  .command-status { display: none; }
  .doctrine-grid article { min-height: 58px; padding: 8px 8px 7px 39px; }
  .doctrine-grid b { left: 9px; top: 8px; font-size: 20px; }
  .doctrine-grid span { margin-top: 2px; font-size: 12px; line-height: 1.25; }
  .level-cards { gap: 5px; grid-template-rows: repeat(2, minmax(76px, 1fr)); }
  .level-card { padding: 8px; }
  .level-card strong { margin-top: 3px; font-size: 16px; }
  .level-card p { margin: 3px 0 4px; font-size: 12px; line-height: 1.2; }
  .level-card small { display: none; }
  .menu-footer span { font-size: 12px; }
  .menu-footer button { min-height: 44px; padding-inline: 12px; font-size: 14px; }
  .deployment-card { height: calc(100vh - 10px); height: calc(100dvh - 10px); max-height: none; padding: 9px 14px; overflow: hidden; }
  .deployment-copy .eyebrow { display: none; }
  .deployment-copy h2 { margin: 0 0 2px; font-size: 20px; }
  .deployment-copy > strong { font-size: 12px; }
  .deployment-copy p { display: none; }
  .mode-options { margin: 0; gap: 4px; }
  .mode-options button { min-height: 54px; padding: 4px 8px; }
  .mode-options span { font-size: 9px; }
  .mode-options strong { margin-top: 1px; font-size: 17px; }
  .mode-options small { display: none; }
  .scenario-config { margin: 0; gap: 4px; }
  .map-size-controls { gap: 4px; padding: 3px 7px; }
  .map-size-controls label { grid-template-columns: 1fr 52px; gap: 4px; }
  .map-size-controls input { height: 44px; font-size: 18px; }
  .random-map-summary { padding: 3px 7px; }
  .random-map-summary strong { margin-top: 1px; font-size: 14px; }
  .reroll-scenario { min-width: 150px; min-height: 44px; padding-inline: 7px; font-size: 16px; }
  .zoning-console { height: 100%; margin: 0; grid-template-columns: 1fr 1.15fr; gap: 7px; }
  .zone-preview { height: 100%; min-height: 0; padding: 4px; gap: 3px; }
  .zone-preview button span { display: none; }
  .zone-preview button b { font-size: 14px; }
  .zoning-control > span, .zoning-legend { display: none; }
  .selection-counter { margin-top: 0; padding: 4px 7px; }
  .selection-counter strong { margin: 0; font-size: 20px; }
  .zoning-tools { margin-top: 4px; grid-template-columns: repeat(2, 1fr); gap: 3px; }
  .tool-zoning { min-height: 44px; font-size: 14px; }
  .zoning-tools .convert-zoning { grid-column: 1 / -1; }
  .zoning-control p { min-height: 0; margin-top: 4px; padding: 5px; font-size: 12px; line-height: 1.3; }
  .zoning-stats { margin: 0; }
  .zoning-stats div { padding: 4px 3px; }
  .zoning-stats span { font-size: 10px; }
  .zoning-stats strong { margin-top: 2px; font-size: 14px; }
  .dialog-actions button { min-width: 140px; min-height: 46px; font-size: 18px; }
  .result-card { padding: 20px; }
  .manual-card { max-height: calc(100dvh - 10px); padding: 14px; }
  .manual-grid { margin-top: 12px; }
  .manual-grid article { padding: 10px; }
}

/* Short landscape screens share a fixed, non-scrolling planning grid. */
@media (max-height: 700px) and (orientation: landscape) {
  .dialog-overlay { padding: 10px; }
  .deployment-card {
    height: calc(100vh - 20px);
    height: calc(100dvh - 20px);
    padding: 10px 14px;
    grid-template-rows: 40px 56px 48px minmax(0, 1fr) 44px 48px;
    gap: 6px;
  }
  .deployment-copy { min-width: 0; overflow: hidden; }
  .deployment-copy .eyebrow, .deployment-copy p { display: none; }
  .deployment-copy h2 { margin: 0 0 2px; font-size: 20px; line-height: 1; }
  .deployment-copy > strong { display: block; overflow: hidden; font-size: 12px; white-space: nowrap; text-overflow: ellipsis; }
  .mode-options { height: 56px; gap: 6px; }
  .mode-options button { min-height: 0; height: 56px; padding: 5px 10px; overflow: hidden; }
  .mode-options span { font-size: 8px; line-height: 1; }
  .mode-options strong { margin-top: 3px; font-size: 18px; line-height: 1; }
  .mode-options small { display: none; }
  .scenario-config { height: 48px; gap: 6px; }
  .map-size-controls { height: 48px; padding: 3px 8px; }
  .map-size-controls input { height: 40px; }
  .random-map-summary { height: 48px; padding-block: 4px; }
  .reroll-scenario { min-height: 48px; height: 48px; }
  .zoning-console { height: 100%; min-height: 0; overflow: hidden; }
  .zone-preview { height: 100%; min-height: 0; }
  .zoning-control { min-height: 0; display: grid; grid-template-rows: 40px 44px minmax(0, 1fr); gap: 5px; overflow: hidden; }
  .zoning-control > span, .zoning-legend { display: none; }
  .selection-counter { height: 40px; margin: 0; padding: 5px 9px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .selection-counter small { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .selection-counter strong { flex: 0 0 auto; margin: 0; font-size: 20px; }
  .zoning-tools { height: 44px; margin: 0; display: flex; gap: 5px; }
  .tool-zoning { min-width: 0; min-height: 44px; height: 44px; padding-inline: 6px; font-size: 14px; }
  .zoning-control p { min-height: 0; height: 100%; margin: 0; padding: 6px 8px; overflow: hidden; font-size: 12px; line-height: 1.3; }
  .zoning-stats { height: 44px; }
  .zoning-stats div { padding: 4px 3px; }
  .zoning-stats span { font-size: 9px; }
  .zoning-stats strong { margin-top: 2px; font-size: 14px; }
  .dialog-actions { height: 48px; }
  .dialog-actions button { min-height: 48px; height: 48px; font-size: 18px; }
}

/* Compact phone landscape, including the 667×375 minimum viewport. */
@media (max-height: 430px) and (orientation: landscape) {
  :root { --compact-gap: 4px; }

  .menu-content {
    width: calc(100% - 12px);
    padding: 6px 0;
    grid-template-rows: 32px 52px minmax(0, 1fr) 44px;
    gap: var(--compact-gap);
  }
  .title-lockup { max-width: none; display: flex; align-items: center; gap: 12px; min-width: 0; }
  .title-lockup .eyebrow { display: none; }
  .title-lockup h1 { flex: 0 0 auto; margin: 0; font-size: 22px; line-height: 1; }
  .title-lockup p { min-width: 0; max-width: none; overflow: hidden; font-size: 12px; line-height: 1.25; white-space: nowrap; text-overflow: ellipsis; }
  .doctrine-grid { min-height: 0; height: 52px; overflow: hidden; }
  .doctrine-grid article { min-height: 0; height: 100%; padding: 6px 7px 5px 36px; overflow: hidden; }
  .doctrine-grid b { left: 8px; top: 7px; font-size: 18px; }
  .doctrine-grid strong { font-size: 14px; line-height: 1.2; }
  .doctrine-grid span { margin-top: 2px; display: -webkit-box; overflow: hidden; font-size: 12px; line-height: 1.2; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
  .level-cards { grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 4px; }
  .level-card { padding: 6px 7px; }
  .level-card::after { display: none; }
  .level-card .mission-number { font-size: 8px; }
  .level-card strong { margin-top: 3px; display: -webkit-box; overflow: hidden; font-size: 14px; line-height: 1.25; white-space: normal; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
  .level-card p { margin: 3px 0 0; display: -webkit-box; overflow: hidden; font-size: 12px; line-height: 1.15; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
  .level-card small { display: none; }
  .menu-footer { min-width: 0; gap: 8px; }
  .menu-footer span { min-width: 0; overflow: hidden; font-size: 12px; white-space: nowrap; text-overflow: ellipsis; }
  .menu-footer button { flex: 0 0 auto; min-height: 44px; padding-inline: 13px; font-size: 14px; }

  .dialog-overlay { padding: 4px; }
  .deployment-card {
    width: 100%;
    height: calc(100dvh - 8px);
    max-height: none;
    padding: 6px 8px;
    display: grid;
    grid-template-rows: 22px 48px 44px minmax(0, 1fr) 34px 44px;
    gap: var(--compact-gap);
    overflow: hidden;
  }
  .deployment-card > * { min-width: 0; min-height: 0; }
  .deployment-copy { display: flex; align-items: center; }
  .deployment-copy .eyebrow, .deployment-copy h2, .deployment-copy p { display: none; }
  .deployment-copy > strong { overflow: hidden; font-size: 14px; line-height: 1; white-space: nowrap; text-overflow: ellipsis; }
  .mode-options { height: 48px; margin: 0; gap: 4px; }
  .mode-options button { min-height: 0; height: 48px; padding: 4px 8px; }
  .mode-options span { font-size: 8px; line-height: 1; }
  .mode-options strong { margin-top: 3px; font-size: 17px; line-height: 1; }
  .scenario-config { height: 44px; margin: 0; gap: 4px; }
  .map-size-controls { height: 44px; padding: 3px 7px; }
  .map-size-controls label { grid-template-columns: minmax(0, 1fr) 46px; }
  .map-size-controls label span, .random-map-summary span { font-size: 10px; }
  .map-size-controls input { height: 36px; font-size: 18px; }
  .random-map-summary { height: 44px; padding: 4px 8px; }
  .random-map-summary strong { font-size: 13px; line-height: 1.1; }
  .reroll-scenario { min-width: 140px; min-height: 44px; height: 44px; font-size: 14px; }
  .zoning-console { height: 100%; margin: 0; grid-template-columns: 1.05fr 1.15fr; gap: 6px; overflow: hidden; }
  .zone-preview { width: 100%; height: 100%; min-height: 0; padding: 4px; gap: 3px; }
  .zone-preview button { width: 44px; height: 44px; min-width: 44px; }
  .zone-preview button b { font-size: 14px; }
  .zoning-control { min-height: 0; display: grid; grid-template-rows: 40px 44px minmax(0, 1fr); gap: 4px; overflow: hidden; }
  .zoning-control > span, .zoning-legend { display: none; }
  .selection-counter { height: 40px; margin: 0; padding: 4px 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .selection-counter small { display: block; overflow: hidden; font-size: 10px; white-space: nowrap; text-overflow: ellipsis; }
  .selection-counter strong { flex: 0 0 auto; margin: 0; font-size: 18px; line-height: 1; }
  .zoning-tools { height: 44px; margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
  .zoning-tools .convert-zoning { grid-column: auto; }
  .tool-zoning { min-height: 44px; height: 44px; padding-inline: 4px; overflow: hidden; font-size: 13px; white-space: nowrap; text-overflow: ellipsis; }
  .zoning-control p { min-height: 0; height: 100%; margin: 0; padding: 4px 7px; overflow: hidden; font-size: 11px; line-height: 1.25; }
  .zoning-stats { height: 34px; margin: 0; }
  .zoning-stats div { padding: 3px 2px; }
  .zoning-stats span { font-size: 8px; line-height: 1; }
  .zoning-stats strong { margin-top: 2px; font-size: 12px; line-height: 1; }
  .dialog-actions { position: static; height: 44px; padding: 0; gap: 4px; background: none; }
  .dialog-actions button { flex: 1; min-width: 0; min-height: 44px; height: 44px; padding-inline: 8px; font-size: 16px; }

  .topbar { min-height: 52px; height: 52px; grid-template-columns: 104px minmax(150px, 1fr) auto; }
  .brand-block { padding: 4px 7px; }
  .brand-block strong { font-size: 15px; }
  .telemetry-cell { padding: 3px 5px; }
  .telemetry-cell strong { font-size: 13px; }
  .money-cell strong { font-size: 17px; }
  .command-buttons { gap: 3px; padding-inline: 4px; }
  .icon-button { width: 44px; height: 44px; }
  .icon-button.wide { width: 48px; }
  .battle-layout { grid-template-columns: 160px minmax(0, 1fr); gap: 3px; padding: 3px max(3px, env(safe-area-inset-right)) max(3px, env(safe-area-inset-bottom)) max(3px, env(safe-area-inset-left)); }
  .panel-heading { min-height: 48px; height: 48px; padding: 2px 5px; }
  .panel-heading > div > span { font-size: 15px; }
  .panel-heading small { display: none; }
  .scrap-button { min-width: 64px; min-height: 44px; height: 44px; padding: 0 5px; font-size: 14px; }
  .build-cards { gap: 3px; padding: 4px; }
  .build-card { min-height: 104px; height: auto; grid-template-columns: 34px minmax(0, 1fr); padding: 5px; gap: 5px; }
  .blueprint-icon { width: 32px; height: 44px; }
  .card-copy strong { font-size: 13px; line-height: 1.25; }
  .card-copy > span:not(.card-cost) { font-size: 10px; line-height: 1.25; }
  .card-copy .card-cost { min-height: 22px; padding: 2px 5px; font-size: 13px; }
  .mission-ribbon { min-height: 44px; height: 44px; grid-template-columns: minmax(0, 1fr) 76px; gap: 6px; padding: 3px 7px; }
  .mission-ribbon > div:first-child span, .mission-ribbon p { display: none; }
  .mission-ribbon > div:first-child strong { margin: 0; overflow: hidden; font-size: 15px; white-space: nowrap; text-overflow: ellipsis; }
  .next-wave { padding-left: 6px; }
  .next-wave span { font-size: 9px; }
  .next-wave strong { margin-top: 1px; font-size: 17px; }
  .intel-strip { min-height: 38px; height: 38px; grid-template-columns: 110px minmax(0, 1fr) 88px; }
  .intel-strip > div { min-height: 37px; height: 37px; padding: 3px 6px; }
  .intel-status, .selected-info, .factory-meter { font-size: 11px; }
  .factory-meter strong { font-size: 12px; }
}

@media (orientation: portrait) {
  .app-shell, .full-overlay, .dialog-overlay { display: none !important; }
  .rotate-notice {
    position: fixed;
    z-index: calc(var(--z-modal) + 10);
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
    overflow: hidden;
    text-align: center;
    background: radial-gradient(circle at 50% 42%, rgba(224,184,91,.13), transparent 32%), #0a0f0e;
  }
  .rotate-notice svg { width: 64px; height: 64px; fill: none; stroke: var(--brass); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
  .rotate-notice strong { font: 500 24px/1 Impact, "PingFang SC", sans-serif; letter-spacing: .12em; }
  .rotate-notice span { color: #aeb8b2; font-size: 12px; line-height: 1.5; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
