:root {
  color-scheme: dark;
  --base: #0b141b;
  --panel: #15222a;
  --panel-raised: #24363e;
  --line: #354b52;
  --text: #edf5ef;
  --muted: #9badb0;
  --green: #a7db7d;
  --green-dark: #283d26;
  --cyan: #80dce1;
  --amber: #efd08a;
  --red: #ef8e7e;
  --mono: Consolas, 'SFMono-Regular', monospace;
  --hud-width: 216px;
  --hud-gap: 7px;
  --hud-inset: max(10px, env(safe-area-inset-left));
  --hud-right: max(10px, env(safe-area-inset-right));
  --hud-top: max(10px, env(safe-area-inset-top));
  --hud-bottom: max(10px, env(safe-area-inset-bottom));
  --surface: #192b30d9;
  --shadow: 0 3px 12px #02090b3d, inset 0 1px #e6ffff12;
}
* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; overscroll-behavior: none; background: var(--base); color: var(--text); }
body { font: 13px/1.45 'Segoe UI', Arial, sans-serif; }
button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; color: var(--text); font: inherit; cursor: pointer; border: 1px solid #53656a; border-radius: 7px; padding: 8px 11px; background: linear-gradient(#2d414a, #1c2e37); box-shadow: inset 0 1px #e6ffff14, 0 2px 3px #020b1240; transition: border-color .15s, background .15s, box-shadow .15s, transform .15s; }
button:hover { background: #2a424b; border-color: var(--cyan); box-shadow: 0 0 0 2px #80dce111, inset 0 1px #e6ffff20; }
button:active { transform: translateY(1px); background: #15252d; box-shadow: inset 0 2px 6px #0005; }
button:disabled { color: #899c9d; cursor: not-allowed; background: #1b2a30; border-color: #3b4d51; box-shadow: none; transform: none; }
button:focus-visible, canvas:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
button[aria-pressed='true'] { color: var(--green); }
[hidden] { display: none !important; }
kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 15px; font: 9px/1.4 var(--mono); padding: 1px 4px; border: 1px solid #53666b; border-radius: 3px; color: #cedfdf; background: #111d238c; white-space: nowrap; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.ui-icon { display: inline-block; width: 19px; height: 19px; flex: 0 0 auto; vertical-align: middle; }
.ui-icon--native { object-fit: contain; image-rendering: pixelated; }
.icon-metric { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.icon-metric .ui-icon { width: 14px; height: 14px; }
.metric-value { font-variant-numeric: tabular-nums; }
#game-shell { position: fixed; inset: 0; width: 100%; height: 100dvh; overflow: hidden; }
.topbar { position: absolute; top: var(--hud-top); left: var(--hud-inset); right: var(--hud-right); display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; z-index: 8; pointer-events: none; }
.resources { display: flex; align-items: center; gap: 4px; min-width: 0; pointer-events: auto; }
.resource { display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 8px; background: #203237c9; border: 1px solid #c4dad34a; border-radius: 6px; white-space: nowrap; box-shadow: 0 2px 6px #06131026; }
.resource .resource-icon { width: 18px; height: 18px; color: #c4d7d6; }
.resource strong { font: 700 14px/1 var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.04em; }
.resource-credits { border-color: #d4b77466; background: #3b3c28cf; }
.resource-credits strong, .resource-credits > .ui-icon { color: var(--amber); }
.income-metric { display: flex; align-items: center; gap: 3px; margin-left: 3px; color: var(--green); }
.income-metric .ui-icon { width: 12px; height: 12px; }
.resource small { font: 9px var(--mono); }
.resource-army strong, .resource-army .ui-icon { color: var(--green); }
.resource-time .ui-icon { color: var(--cyan); }
.resource-wave .ui-icon { color: var(--red); }
.resource-wave strong { color: #f2b291; }
.wave-badge { font: 9px var(--mono); color: var(--red); align-self: flex-start; margin: 3px -5px 0 -5px; }
.session-controls { display: flex; gap: 4px; flex-shrink: 0; pointer-events: auto; }
.session-controls button { width: 34px; height: 34px; padding: 6px; border-color: #c4dad34a; background: #203237d9; }
.session-controls button:hover { border-color: var(--cyan); background: #29414b; }
.session-controls .help-button { color: var(--cyan); }
.play-layout { position: absolute; inset: 0; min-height: 0; }
#viewport { position: absolute; inset: 0; min-width: 0; overflow: hidden; background: #6b7354; }
#battlefield { display: block; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
.idle-hint { position: absolute; bottom: calc(var(--hud-bottom) + 49px); left: var(--hud-inset); display: grid; grid-template-columns: 22px auto; gap: 1px 8px; align-items: center; max-width: min(285px, calc(100% - var(--hud-width) - 38px)); padding: 7px 10px; background: var(--surface); border: 1px solid #c4dad33d; border-radius: 6px; box-shadow: var(--shadow); pointer-events: none; }
.idle-icon { grid-row: 1 / 3; color: var(--cyan); width: 24px; height: 24px; }
.idle-hint strong { font-size: 12px; font-weight: 600; }
.idle-hint > span:not(.ui-icon) { grid-column: 2; font-size: 10px; color: var(--muted); }
.idle-hint button { grid-row: 1 / 3; grid-column: 3; padding: 6px; color: var(--green); margin-left: 8px; }
.pause-banner { position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%); display: grid; justify-items: center; gap: 8px; padding: 17px 28px; border: 1px solid #a7db7d66; border-radius: 10px; background: #14231fea; color: var(--green); font-size: 15px; font-weight: 600; text-align: center; pointer-events: none; box-shadow: var(--shadow); }
.pause-banner > .ui-icon { width: 26px; height: 26px; }
.pause-banner small { color: #a9beb6; font-size: 10px; font-weight: normal; }
.pause-banner kbd { margin-right: 4px; }
.toast { position: absolute; bottom: calc(var(--hud-bottom) + 52px); left: var(--hud-inset); max-width: calc(100% - var(--hud-width) - 38px); border: 1px solid #d8bc6c66; border-left: 3px solid var(--amber); border-radius: 6px; padding: 8px 11px; background: #17262dee; color: var(--text); box-shadow: var(--shadow); pointer-events: none; z-index: 7; font-size: 11px; }
.tactical-hud { position: absolute; top: calc(var(--hud-top) + 44px); right: var(--hud-right); bottom: var(--hud-bottom); width: var(--hud-width); display: flex; flex-direction: column; gap: var(--hud-gap); pointer-events: none; z-index: 6; }
.map-section { flex: 0 0 auto; padding: 6px 7px; background: var(--surface); border: 1px solid #c4dad33d; border-radius: 6px; box-shadow: var(--shadow); pointer-events: auto; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: #a2bdbd; margin-bottom: 8px; }
.section-symbol { display: inline-flex; align-items: center; justify-content: center; color: var(--cyan); }
.section-symbol .ui-icon { width: 19px; height: 19px; }
.text-button { padding: 3px 5px; border-color: transparent; color: #c4d4d5; background: transparent; box-shadow: none; border-radius: 5px; }
.text-button .ui-icon { width: 16px; height: 16px; }
.text-button:hover { background: #3d666c33; }
#minimap { display: block; width: 100%; max-width: 216px; height: auto; margin: 0 auto; aspect-ratio: 1.5; background: #343e2e; border: 2px solid #101b22; outline: 1px solid #58787f80; border-radius: 4px; cursor: crosshair; touch-action: none; image-rendering: pixelated; }
.map-legend { display: flex; justify-content: center; align-items: center; gap: 27px; margin-top: 8px; }
.map-legend > span { display: flex; align-items: center; justify-content: center; }
.map-legend .ui-icon { width: 15px; height: 15px; }
.legend-player { color: var(--green); }.legend-enemy { color: var(--red); }.legend-deposit { color: var(--amber); }
.command-panel { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; overflow: hidden; background: #192b30e6; border: 1px solid #c4dad34a; border-radius: 6px; box-shadow: var(--shadow); opacity: 0; visibility: hidden; transform: translateX(16px); pointer-events: none; transition: opacity .18s, transform .18s, visibility .18s; }
.command-panel.is-open { opacity: 1; visibility: visible; transform: translateX(0); pointer-events: auto; }
.command-heading { display: flex; align-items: center; gap: 8px; padding: 7px 12px; min-height: 34px; flex: 0 0 auto; color: var(--cyan); background: #29424955; border-bottom: 1px solid #73989f26; }
.heading-icon { width: 16px; height: 16px; }
.command-counts { display: flex; align-items: center; gap: 13px; margin-left: auto; }
.count-chip { display: inline-flex; align-items: center; gap: 5px; color: #adc8c9; font: 10px var(--mono); }
.count-chip .ui-icon { width: 13px; height: 13px; }
.queue-count-chip { color: var(--amber); }
.selection-count { font: 10px var(--mono); color: #b7d1cf; text-align: center; }
#close-command-panel { width: 23px; height: 23px; padding: 3px; background: transparent; border-color: transparent; box-shadow: none; }
#close-command-panel .ui-icon { width: 15px; height: 15px; }
#close-command-panel:hover { color: var(--red); background: #69443c44; border-color: #c5766866; }
#selection-content { flex: 0 0 auto; padding: 12px 13px 10px; background: #0b1a2038; }
.selected-header { display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: 11px; margin-bottom: 9px; align-items: center; }
.unit-portrait { width: 54px; height: 54px; border: 1px solid #657d7666; border-radius: 7px; background: linear-gradient(#1d292bad, #0e1b1dcc), url('./content/ui/metal.png') center / 128px 128px; display: block; image-rendering: pixelated; box-shadow: inset 0 1px #ecffd917, 0 2px 5px #0003; }
.selected-name { font-size: 15px; font-weight: 700; line-height: 1.3; color: #f0f7eb; }
.selected-tier { display: inline-block; vertical-align: 1px; margin-left: 6px; padding: 2px 5px; border: 1px solid #97c76666; border-radius: 4px; background: #3d553933; color: #c9ecab; font: 700 9px/1.2 var(--mono); white-space: nowrap; }
.enemy-selection .selected-tier { color: #ffa18e; border-color: #a16c61; background: #49332d; }
.selected-role { color: #94b2b6; font-size: 10px; margin-top: 4px; }
.selected-role .ui-icon { width: 14px; height: 14px; }
.health-row { display: flex; justify-content: space-between; align-items: center; color: var(--green); margin-bottom: 5px; }
.health-row .ui-icon { width: 13px; height: 13px; }
.shield-row { color: var(--cyan); margin-top: 8px; }
.energy-row { color: var(--amber); margin-top: 8px; }
.health-value { font: 10px var(--mono); color: #c5dfb6; }
.health-track { height: 4px; background: #070e13; border-radius: 3px; overflow: hidden; box-shadow: 0 1px #e3ffdf0d; }
.health-track span { display: block; height: 100%; background: var(--green); border-radius: inherit; }
.enemy-selection .health-track span { background: var(--red); }.enemy-selection .health-value { color: var(--red); }
.command-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px 8px; flex: 0 0 auto; background: #0a161d60; border-top: 1px solid #8eb2b618; border-bottom: 1px solid #8eb2b621; }
.command-tabs button { padding: 7px; min-height: 34px; border: 1px solid transparent; border-radius: 5px; box-shadow: none; background: transparent; color: #829da2; }
.command-tabs button .ui-icon { width: 18px; height: 18px; }
.command-tabs button:hover { color: #d1edec; background: #3d657833; }
.command-tabs button[aria-selected='true'] { color: var(--cyan); border-color: #80dce140; background: #35677533; box-shadow: inset 0 -2px #80dce167; }
.command-pages { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #587178 #10202a; }
#command-view, #intel-view { padding: 12px; }
.command-grid, .production-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.command-grid:empty { display: none; }
.subheading { display: flex; align-items: center; gap: 9px; color: #95b5bc; min-height: 18px; margin: 15px 0 9px; font: 10px var(--mono); }
.subheading::after { content: ''; height: 1px; background: linear-gradient(90deg, #64838944, transparent); flex: 1; }
.subheading > span:last-child:not(:first-child) { order: 2; }
.command-tile { --tile-color: var(--green); position: relative; display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; align-content: start; gap: 5px; width: 100%; min-width: 0; min-height: 115px; padding: 23px 5px 7px; text-align: center; border: 1px solid #68828266; border-radius: 7px; background: linear-gradient(#27383cc9, #122029e3), url('./content/ui/metal.png') center / 128px 128px; box-shadow: inset 0 1px #dcecea15, 0 2px 5px #0003; }
.command-tile[data-tone='mech'] { --tile-color: #c9be86; }.command-tile[data-tone='air'] { --tile-color: var(--cyan); }.command-tile[data-tone='build'] { --tile-color: #99c9e7; }.command-tile[data-tone='economy'] { --tile-color: var(--amber); }
.command-tile:hover { border-color: var(--tile-color); background: linear-gradient(#3a5153b8, #1e333ae3), url('./content/ui/metal.png') center / 128px 128px; box-shadow: 0 0 0 1px #c9e8d414, inset 0 1px #d9f5fa26; }
.command-tile.is-armed { border-color: var(--cyan); color: var(--cyan); box-shadow: inset 0 0 0 1px #80dce180, 0 0 10px #80dce118; background: #204450; }
.command-tile.is-armed::after { content: ''; position: absolute; bottom: 0; left: 15px; right: 15px; height: 2px; background: var(--cyan); }
.command-tile:disabled { border-color: #40545666; background: linear-gradient(#233135c9, #152128df), url('./content/ui/metal.png') center / 128px 128px; }
.command-tile .tile-portrait { width: 47px; height: 47px; border: 0; background: transparent; box-shadow: none; filter: none; opacity: 1; }
.command-tile.order-tile { display: flex; align-items: center; justify-content: center; min-height: 50px; height: 50px; padding: 9px 10px; color: #c0d9d5; }
.command-tile.order-tile .command-icon { width: 27px; height: 27px; }
.command-grid > .order-tile:only-child { grid-column: 1 / -1; }
.tile-action { position: absolute; top: 6px; left: 7px; color: var(--tile-color); }
.tile-action .ui-icon { width: 13px; height: 13px; }
.tile-shortcut { position: absolute; top: 5px; right: 6px; font-size: 9px; border-color: #8ba8ad66; }
.tile-label, .production-label { font-size: 11px; font-weight: 650; line-height: 1.2; color: #e7f0ed; overflow-wrap: break-word; }
.tile-detail, .production-detail { font: 10px var(--mono); color: #b0c2c0; line-height: 1.3; }
.icon-detail { display: flex; justify-content: center; align-items: center; gap: 9px; }
.tile-detail .ui-icon { width: 12px; height: 12px; }
.tile-cost, .production-cost { display: inline-flex; align-items: center; gap: 3px; color: var(--amber); font: 700 11px var(--mono); }
.tile-cost { position: absolute; top: 5px; right: 5px; padding: 2px 5px; background: #111d23b8; border: 1px solid #c9ac593d; border-radius: 4px; }
.tile-cost .ui-icon { width: 12px; height: 12px; }
.selection-hint { grid-column: 1 / -1; margin: 0; padding: 8px 10px; color: #b5c9c6; font-size: 10px; line-height: 1.5; border-radius: 5px; background: #2c4a4e33; }
.selection-description { color: #a6bec0; font-size: 11px; line-height: 1.65; margin: 0 0 14px; }
.intel-tier { display: flex; align-items: center; gap: 6px; color: var(--cyan); font: 10px var(--mono); margin: 12px 0 9px; }
.intel-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin: 0 0 13px; }
.intel-stats > div { display: flex; align-items: center; gap: 7px; min-width: 0; padding: 9px 8px; background: #0718206b; border: 1px solid #5679832e; border-radius: 6px; }
.intel-stats dt { margin: 0; color: #85b7ba; }.stat-icon { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 20px; }
.stat-icon .ui-icon { width: 17px; height: 17px; }
.intel-stats dd { margin: 0 0 0 auto; color: #e2eee6; font: 11px/1.5 var(--mono); text-align: right; white-space: nowrap; }
.intel-stats .intel-stat-list { grid-column: 1 / -1; display: flex; align-items: flex-start; }
.intel-stat-list dd { font: 10px/1.6 'Segoe UI', sans-serif; text-align: left; margin-left: 4px; white-space: normal; }
.intel-unit-list { display: flex; flex-wrap: wrap; gap: 6px 10px; }
.intel-unit-item { display: inline-flex; align-items: center; gap: 5px; }
.intel-unit-item .unit-portrait { width: 24px; height: 24px; border: 0; border-radius: 3px; background: transparent; box-shadow: none; }
.intel-group-type { margin-top: 13px; font-size: 11px; }.intel-group-title { display: flex; align-items: center; gap: 7px; color: #d2e4bf; }
.upgrade-section .section-symbol { color: var(--green); } #upgrade-tier { color: var(--green); font-size: 10px; }
.upgrade-card { border: 1px solid #88b66a66; border-radius: 7px; overflow: hidden; background: #25372866; box-shadow: inset 0 1px #daf4b012; }
.upgrade-button { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 9px; width: 100%; padding: 9px; text-align: left; border: 0; border-bottom: 1px solid #88b66a30; border-radius: 0; background: linear-gradient(115deg, #354c32a8, #1a332bbd), url('./content/ui/metal.png') center / 128px 128px; box-shadow: inset 0 1px #d4fcae12; }
.upgrade-button:hover { background: #3a5736; }.upgrade-button:disabled { background: linear-gradient(115deg, #2a3e2e, #1b2b28); border-color: #51694c; color: #c4d4c2; }
.upgrade-button .upgrade-portrait { width: 40px; height: 40px; border: 1px solid #99bd6526; background: #1b2b2460; box-shadow: none; filter: none; opacity: 1; }
.upgrade-label { min-width: 0; }.upgrade-label strong { display: flex; align-items: center; gap: 6px; color: #d9f3bb; font: 700 13px var(--mono); }
.upgrade-label strong .ui-icon { width: 17px; height: 17px; }.upgrade-label small { display: flex; align-items: center; margin-top: 5px; color: #abc3a2; font: 10px var(--mono); }
.upgrade-cost { display: inline-flex; align-items: center; gap: 4px; color: var(--amber); font: 700 12px var(--mono); white-space: nowrap; }.upgrade-cost .ui-icon { width: 15px; height: 15px; }
.upgrade-benefits { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px 8px; margin: 0; padding: 10px 9px; background: #0b211b4d; }
.upgrade-benefits > div { display: flex; align-items: center; gap: 6px; min-width: 0; }
.upgrade-benefits dt { color: #9dc389; }.upgrade-benefits dd { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; margin: 0; font: 11px/1.45 var(--mono); }
.upgrade-benefits .upgrade-arrow { width: 12px; height: 12px; }
.upgrade-before { color: #adc2a9; }.upgrade-arrow { color: #759269; }.upgrade-benefits strong { color: #d9f2b5; font-weight: 700; }
.upgrade-hint { margin: 0; padding: 7px 9px; color: #a8bfa7; font-size: 10px; line-height: 1.4; }.upgrade-hint.is-shortfall { color: var(--amber); }
.upgrade-card.is-unaffordable .upgrade-cost { color: #eaa88c; }.upgrade-card.is-researching { border-color: #a7db7d99; box-shadow: 0 0 12px #a7db7d0b; }
.upgrade-progress { padding: 2px 9px 10px; }.upgrade-progress-label { display: flex; justify-content: space-between; align-items: center; gap: 7px; margin-bottom: 6px; color: #c0e7a1; font: 10px var(--mono); }
.upgrade-progress-label > strong { display: inline-flex; align-items: center; gap: 4px; font-weight: 500; }.upgrade-progress-label .ui-icon { width: 13px; height: 13px; }
.upgrade-progress-track { height: 4px; border-radius: 3px; background: #0a180d; overflow: hidden; }.upgrade-progress-track > span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--green); transition: width .13s linear; }
.upgrade-max { display: flex; align-items: center; gap: 8px; padding: 11px; color: #c2e3a8; font: 11px var(--mono); background: #3045284d; border-radius: 6px; }
.selection-capabilities:empty { display: none; }.movement-label { display: flex; align-items: center; gap: 5px; color: var(--cyan); margin: 10px 0; }
.target-capabilities { display: flex; align-items: center; gap: 7px; margin: 10px 0 13px; }.target-chip { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 23px; color: #c5e1b4; border: 1px solid #65825a77; border-radius: 4px; background: #30452d55; }
.target-chip .ui-icon { width: 15px; height: 15px; }.target-chip.is-unavailable { color: #6d8087; background: #12212a; border-color: #4d5e6577; }.target-chip.is-unavailable .ui-icon--native { opacity: .45; }
.icon-detail .target-capabilities { margin: 0; gap: 3px; }
.icon-detail .target-chip { width: 17px; height: 16px; border: 0; background: transparent; }
.icon-detail .target-chip .ui-icon { width: 12px; height: 12px; }
.production-group-heading { grid-column: 1 / -1; display: flex; align-items: center; gap: 7px; margin: 4px 0 0; padding: 8px 1px 2px; color: #b9ceca; font-size: 10px; font-weight: 650; }
.production-group-heading .ui-icon { width: 15px; height: 15px; }
.production-group-heading:not(:first-child) { margin-top: 8px; border-top: 1px solid #658a9329; }
.production-group-count { margin-left: auto; color: #789b9e; font: 9px var(--mono); }
.group-portraits { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }.group-portraits .unit-portrait { width: 37px; height: 37px; }
.queue-item { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 5px 9px; padding: 7px 8px; margin-bottom: 6px; border: 1px solid #536e792b; border-radius: 6px; background: #0719234d; font-size: 11px; }
.queue-item time { font: 10px var(--mono); color: var(--amber); }.queue-item .ui-icon { width: 13px; height: 13px; }
.queue-progress { height: 3px; background: #0a141a; grid-column: 1 / -1; border-radius: 2px; overflow: hidden; }.queue-progress span { display: block; height: 100%; background: var(--cyan); border-radius: inherit; }
.mission-section { border-left: 2px solid #d2b66b77; border-radius: 0 6px 6px 0; padding: 9px 10px; margin: 16px 0; background: #33413844; }.mission-section h1 { font-size: 12px; line-height: 1.4; margin: 0 0 5px; font-weight: 650; }.mission-section p { font-size: 10px; color: var(--muted); margin: 0; line-height: 1.6; }
.field-log { margin-top: 16px; } #event-log p { color: #9db5b9; font-size: 10px; line-height: 1.6; margin: 0 0 7px; } #event-log p:first-child { color: #c0dcd1; }
.modal-backdrop { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 24px; background: #0a151deb; overflow-y: auto; }
.dialog-panel { width: min(760px, 100%); max-height: calc(100dvh - 48px); overflow-y: auto; border: 1px solid #7996a4; border-top: 3px solid var(--cyan); background: var(--panel); box-shadow: 0 20px 90px #0009, inset 0 1px #d9edff29; padding: 24px 28px; }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; color: var(--cyan); font-size: 10px; letter-spacing: .06em; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.dialog-heading span:last-child { color: var(--muted); }
.dialog-panel h2 { font-size: 30px; font-weight: 700; letter-spacing: -.02em; margin: 20px 0 12px; line-height: 1.15; }
.dialog-intro { color: #c1d0d6; line-height: 1.65; max-width: 62ch; margin: 0 0 21px; font-size: 13px; }
.help-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; }
.help-columns h3 { font-size: 12px; margin: 0 0 11px; color: var(--green); font-weight: 650; }
.controls-list { margin: 0; font-size: 11px; }
.controls-list > div { display: grid; grid-template-columns: 132px 1fr; gap: 8px; margin-bottom: 10px; align-items: baseline; }
.controls-list dt { color: var(--text); }
.controls-list dd { margin: 0; color: var(--muted); }
.help-start { padding: 12px 14px; background: #253c38; border-left: 2px solid var(--green); color: #ccded8; font-size: 12px; line-height: 1.7; margin-top: 18px; }
.help-start strong { color: var(--text); }
.help-upgrade { font-size: 11px; line-height: 1.65; color: #c7d7cc; border-left: 2px solid #9acf6c; background: #26372b; padding: 9px 13px; margin: 11px 0 0; }
.help-upgrade strong { color: #ddf9c8; }
.help-force-guide { margin-top: 17px; }
.help-force-guide h3 { color: var(--cyan); font-size: 12px; font-weight: 600; margin: 0 0 9px; }
.help-force-guide dl { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 26px; margin: 0; font-size: 11px; }
.help-force-guide dl > div { display: grid; grid-template-columns: 102px 1fr; gap: 8px; }
.help-force-guide dt { color: var(--text); }
.help-force-guide dd { color: var(--muted); margin: 0; }
.dialog-footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-top: 18px; margin-top: 20px; border-top: 1px solid var(--line); }
.dialog-footer > span { color: var(--muted); font-size: 11px; }
.primary-button { border: 1px solid #c6ffa6; background: linear-gradient(#a6f46d, #75bf40); color: #102309; font-weight: 750; padding: 10px 17px; min-width: 125px; white-space: nowrap; }
.primary-button:hover { border-color: #d8ffbc; background: #b5ff85; }
.primary-button span { margin-left: 24px; }
.result-dialog { max-width: 500px; }
.result-dialog h2 { color: var(--green); font-size: 40px; margin-top: 30px; }
.result-dialog[data-result="defeat"] h2 { color: var(--red); }
#result-description { color: var(--muted); font-size: 13px; line-height: 1.7; }
.result-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; margin: 27px 0 8px; gap: 16px; }
.result-stats dt { color: var(--muted); font-size: 10px; margin-bottom: 7px; }
.result-stats dd { margin: 0; font: 22px var(--mono); color: var(--amber); }
.loading-backdrop { z-index: 30; }
.loading-panel { width: min(330px, 100%); text-align: center; }
.loading-wordmark { display: block; font-size: 23px; letter-spacing: .15em; font-weight: 800; margin-bottom: 25px; }
.loading-track { height: 4px; background: #334853; overflow: hidden; }
.loading-track span { display: block; height: 100%; width: 35%; background: var(--cyan); animation: loading-slide 1.4s ease-in-out infinite alternate; }
#loading-message { font-size: 13px; color: var(--cyan); margin-top: 18px; }
.loading-hint { font-size: 11px; color: var(--muted); }
.loading-backdrop.error .loading-track { display: none; }
.loading-backdrop.error #loading-message { color: var(--red); line-height: 1.7; }
.noscript-message { position: fixed; inset: 0; background: var(--base); display: grid; place-items: center; z-index: 50; }
@keyframes loading-slide { from { transform: translateX(-100%); } to { transform: translateX(280%); } }

.dialog-panel { border-color: #739aa24d; border-radius: 12px; background: linear-gradient(145deg, #24353efc, #121f27); box-shadow: 0 24px 90px #0009, inset 0 1px #d9edff12; }
.primary-button { border-color: #c6ffa666; border-radius: 7px; background: linear-gradient(#badf90, #8ebd66); }
.primary-button:hover { background: #c8efa2; }
/* Every control floats over the battlefield; no header or footer reserves map space. */
#menu-button[aria-expanded='true'] .menu-open-icon { display: none; }
#menu-button[aria-expanded='false'] .menu-close-icon { display: none; }
.runtime-metrics { position: absolute; z-index: 5; top: calc(var(--hud-top) + 42px); left: var(--hud-inset); display: inline-flex; align-items: center; gap: 8px; padding: 3px 5px; border-radius: 4px; background: #203237b8; color: #e1eee3; font: 9px var(--mono); pointer-events: none; user-select: none; }
.runtime-metrics span { display: inline-flex; align-items: center; gap: 3px; }
.runtime-metrics strong { color: var(--green); }
#ping-value { color: var(--cyan); }
.view-controls { position: absolute; z-index: 7; bottom: var(--hud-bottom); left: var(--hud-inset); display: flex; align-items: center; gap: 8px; }
.view-controls > button, .zoom-controls button { width: 38px; height: 38px; padding: 7px; border-color: #c4dad34a; background: #203237d9; }
.zoom-controls { display: flex; gap: 3px; }
.view-controls .ui-icon { width: 20px; height: 20px; }
.section-heading { margin-bottom: 4px; }
.section-symbol .ui-icon { width: 16px; height: 16px; }
.text-button { min-width: 26px; min-height: 25px; padding: 3px; }
#minimap { max-width: 100%; border-width: 1px; }
.map-legend { gap: 15px; margin-top: 4px; }
.map-legend .ui-icon { width: 12px; height: 12px; }
.command-heading { gap: 5px; padding: 4px 7px; min-height: 29px; }
.heading-icon { width: 14px; height: 14px; }
.command-counts { gap: 8px; }
.count-chip { gap: 3px; font-size: 9px; }
#close-command-panel { width: 24px; height: 24px; }
#selection-content { padding: 7px 8px 6px; }
.selected-header { grid-template-columns: 38px minmax(0, 1fr); gap: 7px; margin-bottom: 6px; }
.unit-portrait { width: 38px; height: 38px; border-radius: 5px; }
.selected-name { font-size: 12px; }
.selected-role { margin-top: 2px; font-size: 9px; }
.health-row { margin-bottom: 3px; }
.shield-row, .energy-row { margin-top: 5px; }
.command-tabs { gap: 3px; padding: 3px 5px; }
.command-tabs button { min-height: 29px; padding: 4px; }
.command-tabs button .ui-icon { width: 15px; height: 15px; }
#command-view, #intel-view { padding: 7px; }
.command-grid, .production-actions { gap: 5px; }
.command-tile { min-height: 68px; padding: 16px 4px 5px; gap: 3px; border-radius: 5px; }
.command-tile .tile-portrait { width: 36px; height: 36px; }
.command-tile.order-tile { min-height: 44px; height: 44px; padding: 6px; }
.command-tile.order-tile .command-icon { width: 23px; height: 23px; }
.tile-action { top: 4px; left: 5px; }
.tile-action .ui-icon { width: 11px; height: 11px; }
.tile-shortcut { top: 3px; right: 4px; font-size: 8px; }
.tile-label, .production-label { font-size: 10px; }
.tile-detail, .production-detail { font-size: 9px; }
.tile-cost { top: 3px; right: 3px; padding: 1px 3px; font-size: 9px; }
.tile-cost .ui-icon { width: 10px; height: 10px; }
.production-button { grid-template-columns: 34px minmax(0, 1fr); grid-template-rows: auto auto; justify-items: start; align-items: center; min-height: 58px; padding: 5px 4px 5px 5px; text-align: left; }
.production-button .tile-portrait { grid-column: 1; grid-row: 1 / span 2; width: 32px; height: 32px; }
.production-button .production-label { grid-column: 2; grid-row: 1; align-self: end; min-width: 0; }
.production-button .production-detail { grid-column: 2; grid-row: 2; align-self: start; min-width: 0; }
.production-button .tile-cost { top: 3px; right: 3px; }
.production-group-heading { gap: 4px; margin-top: 2px; padding: 5px 0 1px; font-size: 9px; }
.production-group-heading .ui-icon { width: 13px; height: 13px; }
.subheading { min-height: 15px; margin: 9px 0 5px; font-size: 9px; }
.queue-item { padding: 5px 6px; margin-bottom: 4px; font-size: 10px; }

.match-chat { position: absolute; z-index: 6; left: var(--hud-inset); bottom: calc(var(--hud-bottom) + 49px); width: min(238px, calc(100% - var(--hud-width) - 30px)); max-height: min(31%, 190px); display: flex; flex-direction: column; overflow: hidden; border: 1px solid #7cabb056; border-radius: 6px; background: #192b30e6; box-shadow: var(--shadow); pointer-events: auto; }
body:not(.is-playing) .match-chat { display: none; }
.match-chat-heading { display: flex; align-items: center; gap: 5px; min-height: 27px; padding: 3px 5px; border-bottom: 1px solid #70969b33; color: var(--cyan); font-size: 10px; }
.match-chat-heading > .ui-icon { width: 13px; height: 13px; }
.match-chat-heading strong { flex: 1; font-weight: 650; }
.match-chat-heading button { width: 23px; height: 23px; padding: 3px; border-color: transparent; background: transparent; box-shadow: none; }
.match-chat-heading button .ui-icon { width: 14px; height: 14px; }
.match-chat-messages { min-height: 26px; overflow-y: auto; padding: 5px 6px; color: #c6d7d3; font-size: 10px; line-height: 1.4; }
.match-chat-messages:empty { display: none; }
.match-chat-form { display: flex; gap: 4px; padding: 4px; border-top: 1px solid #70969b2e; }
.match-chat-form input { min-width: 0; flex: 1; height: 27px; padding: 3px 6px; border: 1px solid #5d7a7e; border-radius: 4px; color: var(--text); background: #081319; font: 10px var(--mono); }
.match-chat-form button { width: 29px; height: 27px; padding: 4px; border-radius: 4px; }
.match-chat-form button .ui-icon { width: 14px; height: 14px; }

@media (max-width: 1050px) {
  :root { --hud-width: 194px; }
  .resource { gap: 4px; padding-inline: 6px; }
  .resource strong { font-size: 13px; }
  .session-controls .restart-button { display: none; }
}
@media (pointer: coarse), (max-width: 760px), (max-height: 520px) {
  :root { --hud-width: 172px; --hud-gap: 5px; --hud-inset: max(6px, env(safe-area-inset-left)); --hud-right: max(6px, env(safe-area-inset-right)); --hud-top: max(6px, env(safe-area-inset-top)); --hud-bottom: max(6px, env(safe-area-inset-bottom)); }
  .topbar { gap: 8px; }
  .resources { gap: 3px; }
  .resource { height: 32px; gap: 4px; padding: 0 5px; }
  .resource .resource-icon { width: 16px; height: 16px; }
  .resource strong { font-size: 12px; }
  .resource small { font-size: 8px; }
  .income-metric { margin-left: 0; gap: 2px; }
  .session-controls { gap: 3px; }
  .session-controls button { width: 40px; height: 40px; padding: 8px; }
  .session-controls .restart-button, .session-controls .help-button { display: none; }
  .runtime-metrics { top: calc(var(--hud-top) + 37px); padding: 2px 4px; font-size: 8px; }
  .tactical-hud { top: calc(var(--hud-top) + 47px); }
  .map-section { padding: 3px; align-self: flex-end; width: 122px; }
  .map-section .section-heading, .map-legend { display: none; }
  .has-selection .map-section { width: 92px; }
  .command-heading { padding: 3px 5px; min-height: 34px; }
  #close-command-panel { width: 30px; height: 30px; }
  #selection-content { padding: 5px 6px; }
  .selected-header { grid-template-columns: 30px minmax(0, 1fr); gap: 5px; margin-bottom: 4px; }
  .unit-portrait { width: 30px; height: 30px; }
  .selected-name { font-size: 10px; }
  .selected-role { font-size: 8px; }
  .health-value { font-size: 9px; }
  .command-tabs button { min-height: 34px; }
  #command-view, #intel-view { padding: 5px; }
  .command-grid, .production-actions { gap: 4px; }
  .command-tile { min-height: 60px; padding: 14px 3px 4px; }
  .command-tile .tile-portrait { width: 30px; height: 30px; }
  .production-button { grid-template-columns: 29px minmax(0, 1fr); min-height: 54px; padding: 4px 3px; }
  .production-button .tile-portrait { width: 27px; height: 27px; }
  .tile-label, .production-label { font-size: 9px; }
  .tile-detail, .production-detail, .tile-cost { font-size: 8px; }
  .tile-shortcut, .text-button kbd { display: none; }
  .view-controls > button, .zoom-controls button { width: 44px; height: 44px; padding: 9px; }
  .idle-hint { padding: 5px 7px; max-width: min(250px, calc(100% - var(--hud-width) - 30px)); }
  .idle-hint strong { font-size: 10px; }
  .idle-hint > span:not(.ui-icon) { font-size: 9px; }
  .idle-icon { width: 20px; height: 20px; }
  .match-chat { width: min(210px, calc(100% - var(--hud-width) - 24px)); }
  .toast { font-size: 10px; padding: 6px 8px; }
  .upgrade-button { grid-template-columns: 28px minmax(0, 1fr); gap: 5px; padding: 6px; }
  .upgrade-button .upgrade-portrait { width: 28px; height: 28px; }
  .upgrade-cost { grid-column: 2; font-size: 10px; }
  .upgrade-label strong { font-size: 11px; }
  .upgrade-benefits { grid-template-columns: 1fr; gap: 5px; padding: 6px; }
  .upgrade-benefits dd { font-size: 9px; }
  .intel-stats { gap: 4px; }
  .intel-stats > div { gap: 3px; padding: 6px 4px; }
  .intel-stats dd { font-size: 9px; }
  .modal-backdrop { padding: 12px; }
  .dialog-panel { padding: 16px; max-height: calc(100dvh - 24px); }
  .dialog-panel h2 { font-size: 25px; margin-top: 14px; }
  .dialog-heading { font-size: 9px; padding-bottom: 10px; }
  .dialog-intro { margin-bottom: 12px; font-size: 12px; }
  .help-columns { gap: 18px; }
  .controls-list > div { grid-template-columns: 120px 1fr; margin-bottom: 8px; }
  .help-force-guide dl { gap: 7px 15px; }
  .dialog-footer { gap: 10px; padding-top: 12px; margin-top: 14px; }
}
@media (max-width: 580px) and (orientation: landscape) {
  .resource-time, .resource-wave { display: none; }
}
@media (max-width: 600px) and (orientation: portrait) {
  .help-columns, .help-force-guide dl { grid-template-columns: 1fr; }
}
/* Browsers without orientation locking still show a real landscape game.
   The display controller applies this only while a touch match is open. */
html.is-portrait-rotated #game-shell,
html.is-portrait-rotated .modal-backdrop {
  position: fixed; inset: auto; top: 0; left: 100vw; width: 100dvh; height: 100dvw;
  transform: rotate(90deg); transform-origin: 0 0;
}
html.is-portrait-rotated .dialog-panel { max-height: calc(100dvw - 24px); }
html.is-portrait-rotated .help-columns, html.is-portrait-rotated .help-force-guide dl { grid-template-columns: 1fr 1fr; }
@media (prefers-reduced-motion: reduce) {
  .loading-track span { animation: none; width: 100%; opacity: .65; }
  button, .command-panel, .upgrade-progress-track > span { transition: none; }
}
