:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  color: #f8f5ff;
  background: #1a1622;
  font-synthesis: none;
  --panel: #282235;
  --panel-deep: #1d1a28;
  --line: #665a76;
  --muted: #d1c8da;
  --purple: #c4a4ff;
  --orange: #ffaf78;
  --gold: #ffe09a;
}
* { box-sizing: border-box; }
html, body { width: 100%; min-width: 0; height: 100%; margin: 0; }
button, select { font: inherit; cursor: pointer; }
button:focus-visible, select:focus-visible, canvas:focus-visible { outline: 3px solid #ffe39f; outline-offset: 2px; }
button:disabled { cursor: not-allowed; opacity: .58; }
button:not(:disabled):active { transform: translateY(1px); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.game-shell { display: grid; grid-template-rows: auto minmax(120px, 1fr) minmax(0, 282px); width: 100%; height: 100dvh; overflow: hidden; }
.status-bar { position: relative; z-index: 2; display: grid; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); align-items: center; gap: clamp(8px, 1.3vw, 22px); min-height: 74px; padding: 8px clamp(10px, 1.5vw, 24px); background: #241e2d; border-bottom: 3px solid #5b4d67; box-shadow: 0 5px 12px #15111a66; }
.commander { display: flex; min-width: 0; align-items: center; gap: 10px; }
.commander-enemy { justify-content: flex-end; text-align: right; }
.portrait { flex: 0 0 50px; width: 50px; height: 50px; border: 2px solid #cfb9f4; border-radius: 12px; background-image: url('/public/assets/commanders.webp'); background-repeat: no-repeat; background-size: 850% auto; background-color: #47395f; }
.portrait.eko { background-position: left top; }
.portrait.kwon { background-image: url('/public/assets/eko-kwon-reference.webp'); background-size: 322% auto; background-position: 87% top; background-color: #e6c1a2; border-color: #ffc197; }
.commander-copy { display: flex; flex-direction: column; min-width: 48px; gap: 2px; }
.commander-copy strong { font-size: 16px; line-height: 1; }
.commander-copy span, .base-label { color: var(--muted); font-size: 11px; }
.mobile-hp { display: none; }
.base-status { display: grid; grid-template-columns: auto minmax(45px, 1fr); gap: 3px 7px; flex: 1 1 180px; max-width: 220px; min-width: 55px; align-items: center; }
.base-status > span:last-child { grid-column: 2; font-size: 11px; color: #ece7ef; font-variant-numeric: tabular-nums; }
.health-track { height: 11px; background: #100e16; border: 1px solid #83788a; border-radius: 7px; overflow: hidden; }
.health-track i { display: block; width: 100%; height: 100%; background: #b991ff; }
.commander-enemy .health-track i { background: #ff9569; }
.match-status { display: flex; align-items: center; gap: clamp(8px, 1.5vw, 24px); text-align: center; }
.money, .wave { display: grid; grid-template-columns: auto auto; align-items: baseline; gap: 2px 7px; }
.money span, .wave span { grid-column: 1 / -1; color: #ddd2df; font-size: 11px; white-space: nowrap; }
.money strong { color: var(--gold); font-size: 22px; font-variant-numeric: tabular-nums; }
.money small { color: #ebd6a8; font-size: 11px; white-space: nowrap; }
.money #income { color: #ebd6a8; font-variant-numeric: tabular-nums; }
.wave strong { grid-column: 1 / -1; color: #fff; font-size: 22px; font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.arena { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #506b58; }
#battlefield { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
#battlefield.is-dragging { cursor: grabbing; }
.unit-tooltip { position: absolute; z-index: 3; max-width: 230px; padding: 8px 9px; border: 1px solid #b5a6c4; border-radius: 7px; color: #fff; background: #211d2df2; font-size: 12px; line-height: 1.4; pointer-events: none; }
.team-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #b59aff; }
.team-dot.orange { background: #ff9f6a; }
.placement-bar { position: absolute; z-index: 4; top: 8px; left: 8px; right: 8px; display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid #a99bbb; border-radius: 8px; color: #fff; background: #26212ef2; font-size: 12px; }
.placement-bar span { flex: 1; min-width: 0; }
.placement-bar button { flex: 0 0 auto; min-width: 44px; min-height: 36px; padding: 0 10px; border: 1px solid #b4a6bf; border-radius: 6px; color: #fff; background: #59466b; font-weight: 700; }
.arena.is-placing .notice { display: none; }
.map-frame { position: absolute; right: 12px; bottom: 12px; width: clamp(150px, 15vw, 220px); padding: 5px; background: #24202cd9; border: 1px solid #988d9c; border-radius: 8px; }
.map-heading { display: flex; justify-content: space-between; padding: 1px 3px 5px; font-size: 11px; }
.map-heading small { color: #ded5e4; font-size: 11px; }
#minimap { display: block; width: 100%; aspect-ratio: 7200 / 5050; border-radius: 3px; cursor: crosshair; touch-action: manipulation; }
.notice { position: absolute; left: 50%; top: 14px; max-width: min(70%, 550px); padding: 9px 15px; border-radius: 8px; color: #fff; background: #211d2de8; font-size: 13px; text-align: center; transform: translateX(-50%); pointer-events: none; }
.notice:empty { display: none; }
.command-deck { position: relative; z-index: 2; display: grid; grid-template-rows: auto minmax(0,1fr); min-height: 0; border-top: 3px solid #816ca0; background: #262033; box-shadow: 0 -6px 18px #17132055; }
.deck-top { display: flex; align-items: stretch; gap: 14px; min-width: 0; min-height: 55px; padding: 8px clamp(10px, 1.3vw, 22px); }
.deck-heading { display: flex; flex-direction: column; justify-content: center; min-width: 84px; gap: 2px; }
.deck-kicker { color: #c5b4d8; font-size: 11px; letter-spacing: .08em; }
.deck-heading strong { font-size: 16px; }
.deck-tabs { display: flex; gap: 3px; min-width: 0; overflow-x: auto; scrollbar-width: thin; }
.deck-tabs button { flex: 0 0 auto; min-height: 50px; padding: 0 15px; border: 0; border-bottom: 3px solid transparent; color: #d8d0de; background: transparent; font-weight: 700; font-size: 13px; }
.deck-tabs button:hover { color: #fff; background: #ffffff0b; }
.deck-tabs button[aria-selected="true"], .deck-tabs button[aria-pressed="true"] { color: #fff; border-bottom-color: #c9a8ff; }
.capacity { display: flex; align-items: center; gap: 8px; margin-left: auto; color: #ddd2e7; font-size: 12px; white-space: nowrap; }
.capacity strong { color: #fff; font-size: 15px; font-variant-numeric: tabular-nums; }
.capacity small { color: #ddd2e7; font-size: 11px; }
.deck-panel { min-height: 0; overflow: auto; padding: 12px clamp(10px, 1.3vw, 22px) 16px; scrollbar-color: #8d7da0 #2b2435; }
.building-layout { display: grid; grid-template-columns: minmax(230px, 35%) minmax(0, 1fr); gap: 14px; min-height: 100%; }
.building-list { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 7px; align-content: start; }
.building-card { display: flex; align-items: center; gap: 9px; min-width: 0; min-height: 55px; padding: 8px; border: 1px solid #736784; border-radius: 8px; text-align: left; color: #fff; background: #342c40; }
.building-card:hover { background: #493c58; }
.building-card.selected { border-color: #e7d1ff; background: #554465; }
.building-card .building-glyph { display: grid; flex: 0 0 36px; height: 36px; place-items: center; border-radius: 7px; color: #fff; background: #70558e; font-size: 16px; font-weight: 800; }
.building-card .building-name { display: flex; min-width: 0; flex-direction: column; gap: 3px; }
.building-name strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.building-name small { color: #ead8ab; font-size: 11px; }
.building-detail { min-width: 0; border: 1px solid #766981; border-radius: 10px; background: #f2e8dc; color: #292130; overflow: hidden; }
.detail-head { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-bottom: 1px solid #d4c8be; background: #e8d9cb; }
.detail-title { min-width: 0; flex: 1; }
.detail-title strong { display: block; font-size: 15px; }
.detail-title p { margin: 3px 0 0; color: #564b58; font-size: 12px; }
.unit-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(195px, 1fr)); gap: 7px; padding: 8px; }
.unit-card { display: flex; min-width: 0; flex-direction: column; gap: 5px; padding: 9px; border: 1px solid #c9bbc3; border-radius: 8px; background: #fffaf4; }
.unit-card h3 { margin: 0; color: #2f2636; font-size: 13px; }
.unit-role { margin-left: 4px; color: #735381; font-size: 11px; }
.built-label { color: #396848; font-size: 12px; font-weight: 800; white-space: nowrap; }
.unit-card p { margin: 0; color: #514753; font-size: 12px; line-height: 1.35; }
.unit-meta { color: #65546c !important; font-weight: 700; }
.unit-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; margin-top: auto; }
.unit-actions strong { min-width: 62px; color: #352d3a; font-size: 11px; text-align: center; }
.small-button, .primary-button, .secondary-button { min-height: 36px; padding: 0 11px; border: 1px solid #654c83; border-radius: 7px; color: #fff; background: #6f4a9f; font-weight: 700; }
.small-button:hover:not(:disabled), .primary-button:hover:not(:disabled) { background: #8058b1; }
.small-button.quiet { border-color: #a99ba9; color: #3c3042; background: #f6edf3; }
.small-button.quiet:hover:not(:disabled) { background: #e6d8eb; }
.small-button.step { min-width: 36px; padding: 0 8px; font-size: 18px; }
.small-button:disabled { opacity: .55; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 8px; }
.info-card { display: flex; flex-direction: column; gap: 5px; min-width: 0; padding: 10px; border: 1px solid #6f627c; border-radius: 8px; background: #352d40; }
.info-card h3 { margin: 0; font-size: 14px; }
.info-card p { margin: 0; color: #e1d9e4; font-size: 12px; line-height: 1.4; }
.info-card .small-button { align-self: flex-start; margin-top: auto; }
.info-card .meta { color: #f1d3a5; font-size: 11px; }
.empty-note { margin: 0; color: #eadfee; font-size: 13px; line-height: 1.5; }
.hero-status { margin-bottom: 10px; }
.enemy-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.enemy-heading h2 { margin: 4px 0; font-size: 17px; }
.enemy-heading h2 small, .enemy-heading > span { color: #e3d9e5; font-size: 12px; font-weight: 400; }
.section-label { margin: 8px 0 3px; font-size: 13px; }
.available-list { margin-top: 10px; color: #eee6ef; font-size: 12px; }
.available-list summary { cursor: pointer; }
.available-list p { line-height: 1.6; }
.enemy-unit-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.enemy-chip { padding: 8px 9px; border: 1px solid #af8878; border-radius: 6px; color: #fff; background: #5a403c; font-size: 12px; }
.guide-copy { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px 20px; color: #f1eaf3; font-size: 13px; line-height: 1.55; }
.guide-copy p { margin: 0; }
.overlay { position: fixed; z-index: 10; inset: 0; display: grid; place-items: center; overflow: auto; padding: 20px; background: #15121edb; }
.setup-card, .end-card { width: min(890px, 100%); max-height: min(900px, calc(100dvh - 40px)); overflow: auto; padding: clamp(20px, 3vw, 36px); border: 1px solid #9c88ad; border-radius: 16px; background: #2d2538; box-shadow: 0 18px 60px #0009; }
.eyebrow { margin: 0 0 8px; color: #d0b6f2; font-size: 12px; font-weight: 800; }
.setup-card h2, .end-card h2 { margin: 0; color: #fff; font-size: clamp(27px, 4vw, 42px); letter-spacing: -.02em; }
.setup-card h2 span { color: #e6c486; font-size: .65em; }
.setup-description, .end-card p { color: #e4dae8; font-size: 14px; line-height: 1.55; }
.setup-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 22px; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend { margin-bottom: 9px; color: #fff; font-weight: 800; font-size: 14px; }
.faction-options { display: grid; gap: 6px; }
.faction-choice { display: flex; align-items: center; min-height: 57px; gap: 10px; padding: 8px 11px; border: 1px solid #75677f; border-radius: 8px; color: #f9f5ff; background: #3a3046; text-align: left; }
.faction-choice:hover { background: #4b3d59; }
.faction-choice[aria-pressed="true"] { border: 2px solid #d5b6ff; background: #59466a; }
.enemy-options .faction-choice[aria-pressed="true"] { border-color: #ffb185; background: #64453f; }
.faction-choice span { display: grid; gap: 3px; }
.faction-choice strong { font-size: 13px; }
.faction-choice small { color: #e1d9e4; font-size: 11px; line-height: 1.25; }
.setup-footer { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-top: 22px; }
.setup-footer p { margin: 0; color: #e5dce6; font-size: 12px; }
.setup-footer .primary-button { flex-shrink: 0; white-space: nowrap; }
.primary-button, .secondary-button { min-height: 44px; padding: 0 20px; font-size: 14px; }
.secondary-button { background: #41364a; border-color: #9e8ba7; }
.secondary-button:hover { background: #58465e; }
.end-card { max-width: 460px; padding: 24px; }
.end-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
@media (max-width: 950px) {
  .portrait { flex-basis: 42px; width: 42px; height: 42px; }
  .status-bar { min-height: 64px; gap: 8px; }
  .base-status { max-width: 150px; }
  .deck-heading { min-width: 62px; }
  .deck-tabs button { padding: 0 10px; }
  .building-layout { grid-template-columns: minmax(180px, 31%) minmax(0, 1fr); }
  .building-list { grid-template-columns: 1fr; }
}
@media (max-width: 650px) {
  .game-shell { grid-template-rows: auto minmax(100px, 1fr) minmax(0, 38dvh); }
  .status-bar { min-height: 58px; padding: 5px 8px; }
  .portrait { flex-basis: 32px; width: 32px; height: 32px; border-radius: 8px; }
  .commander { gap: 5px; }
  .commander-copy strong { font-size: 13px; }
  .commander-copy span, .base-label { font-size: 11px; }
  .mobile-hp { display: block; color: #f6ead0; font-size: 11px; white-space: nowrap; }
  .base-status { display: none; }
  .money strong, .wave strong { font-size: 17px; }
  .money small { display: none; }
  .match-status { gap: 10px; }
  .map-frame { width: 122px; bottom: 7px; right: 7px; }
  .map-heading small { display: none; }
  .placement-bar { gap: 5px; padding: 6px; font-size: 11px; }
  .placement-bar button { min-height: 44px; padding: 0 7px; }
  .small-button { min-height: 44px; }
  .small-button.step { min-width: 44px; }
  .deck-top { min-height: 45px; gap: 5px; padding: 8px 7px; }
  .deck-heading { display: none; }
  .deck-tabs button { min-height: 44px; padding: 0 9px; font-size: 12px; }
  .capacity { font-size: 11px; gap: 4px; }
  .capacity strong { font-size: 12px; }
  .deck-panel { padding: 7px; }
  .building-layout { grid-template-columns: minmax(115px, 32%) minmax(0,1fr); gap: 7px; }
  .building-card { min-height: 44px; padding: 8px; gap: 5px; }
  .building-card .building-glyph { flex-basis: 28px; height: 28px; font-size: 13px; }
  .building-name strong { font-size: 11px; }
  .building-name small { font-size: 11px; }
  .detail-head { padding: 8px; }
  .detail-title p { font-size: 11px; }
  .unit-list { grid-template-columns: 1fr; padding: 6px; }
  .setup-grid { grid-template-columns: 1fr; gap: 12px; margin-top: 12px; }
  .setup-card { padding: 18px; }
  .setup-description { font-size: 12px; }
  .faction-choice { min-height: 45px; }
  .setup-footer { margin-top: 12px; }
}
@media (max-width: 360px) {
  .detail-head { align-items: stretch; flex-direction: column; }
  .detail-head .small-button { align-self: flex-start; }
}
@media (max-height: 600px) and (min-width: 651px) {
  .game-shell { grid-template-rows: auto minmax(90px,1fr) minmax(0, 43dvh); }
  .status-bar { min-height: 54px; padding-block: 4px; }
  .portrait { flex-basis: 36px; width: 36px; height: 36px; }
  .deck-top { min-height: 42px; }
  .deck-tabs button { min-height: 42px; }
  .setup-card { max-height: calc(100dvh - 16px); padding: 16px 22px; }
  .setup-card h2 { font-size: 26px; }
  .setup-description { margin: 5px 0; }
  .setup-grid { margin-top: 8px; }
  .faction-choice { min-height: 42px; }
  .small-button { min-height: 44px; }
  .small-button.step { min-width: 44px; }
  .setup-footer { margin-top: 10px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; } }

/* Fixed command deck: selection and paging keep every command reachable. */
.game-shell { grid-template-rows: auto minmax(120px, 1fr) 242px; }
.command-deck { grid-template-columns: 218px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
.deck-map { display: flex; align-items: center; padding: 10px; border-right: 1px solid #5c4f6c; }
.map-frame { position: static; width: 100%; padding: 7px; }
.deck-content { display: grid; grid-template-rows: auto minmax(0, 1fr); min-width: 0; min-height: 0; }
.deck-top { min-height: 43px; gap: 8px; padding: 0 12px; border-bottom: 0; }
.deck-tabs { flex: 1; overflow: hidden; }
.context-tablist { display: flex; flex: 1; min-width: 0; }
.deck-tabs button { flex: 0 1 auto; min-width: 0; min-height: 42px; padding: 0 13px; white-space: nowrap; }
.tab-short { display: none; }
.deck-panel { overflow: hidden; padding: 8px 10px; }
.building-layout { height: 100%; min-height: 0; grid-template-columns: minmax(310px, 39%) minmax(0, 1fr); gap: 8px; }
.building-menu { display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 4px; min-height: 0; }
.building-menu .page-controls { justify-content: center; margin-left: 0; }
.building-list { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 5px; min-height: 0; }
.building-card { flex-direction: column; justify-content: center; gap: 3px; min-height: 0; padding: 5px; text-align: center; }
.building-card .building-glyph { flex: 0 0 28px; width: 28px; height: 28px; }
.building-sprite { display: block; flex: 0 0 34px; width: 56px; height: 34px; object-fit: contain; }
.building-card .building-name { align-items: center; width: 100%; gap: 1px; }
.building-name strong { max-width: 100%; font-size: 11px; }
.building-name small { font-size: 11px; }
.building-detail { display: grid; grid-template-rows: auto auto minmax(0, 1fr); min-height: 0; }
.detail-head { min-height: 34px; padding: 4px 8px; }
.detail-title strong { font-size: 13px; }
.detail-title p { margin-top: 1px; font-size: 11px; }
.detail-head .small-button { min-height: 32px; }
.back-buildings { display: none; }
.unit-picker { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 4px 7px 0; }
.unit-choice { display: flex; flex-direction: row; align-items: center; justify-content: flex-start; gap: 5px; min-width: 0; min-height: 35px; padding: 3px 7px; border: 1px solid #a99aab; border-radius: 5px; color: #332b39; background: #fcf7f0; text-align: left; }
.unit-choice img { flex: 0 0 32px; width: 32px; height: 32px; object-fit: contain; }
.unit-choice span { display: flex; flex-direction: column; min-width: 0; }
.unit-choice[aria-pressed="true"] { border-color: #74509c; background: #e7d9ef; box-shadow: inset 0 0 0 1px #74509c; }
.unit-choice strong { max-width: 100%; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.unit-choice small { font-size: 11px; }
.unit-focus { display: flex; align-items: center; gap: 9px; min-height: 0; padding: 5px 8px 7px; }
.unit-copy { flex: 1; min-width: 0; }
.unit-copy h3, .hero-detail h3 { margin: 0; color: #302638; font-size: 13px; }
.unit-copy p, .hero-detail p { margin: 2px 0 0; color: #514753; font-size: 11px; line-height: 1.2; }
.unit-stats { color: #3e3149 !important; font-weight: 700; font-variant-numeric: tabular-nums; }
.unit-inspector { display: grid; grid-template-columns: minmax(90px, 130px) minmax(0, 1fr); height: 100%; min-height: 0; overflow: hidden; border: 1px solid #b8a5b5; border-radius: 8px; color: #302638; background: #f2e8dc; }
.inspection-portrait { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 0; min-height: 0; padding: 7px; background: #e2d5e9; }
.inspection-portrait img { display: block; width: 100%; max-width: 112px; min-height: 0; max-height: 100%; object-fit: contain; }
.portrait-focus { display: grid; place-items: center; min-width: 0; min-height: 0; padding: 0; border: 2px solid transparent; border-radius: 8px; background: transparent; cursor: pointer; }
.portrait-focus:hover { border-color: #7d9ed0; background: #d4e1f4; }
.portrait-focus:focus-visible { outline: 3px solid #2359b6; outline-offset: 2px; }
.inspection-portrait .portrait-focus { flex: 0 1 112px; width: 100%; }
.inspection-portrait span { color: #493b52; font-size: 11px; font-weight: 700; text-align: center; }
.inspection-main { display: grid; grid-template-rows: auto auto auto auto; align-content: center; gap: 6px; min-width: 0; min-height: 0; padding: 8px 12px; }
.inspection-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.inspection-header h2 { margin: 0; color: #2c2034; font-size: 16px; line-height: 1.1; }
.inspection-header p { margin: 2px 0 0; color: #5b4a5d; font-size: 11px; }
.inspection-close { flex: 0 0 auto; min-height: 32px; padding: 0 10px; border: 1px solid #8c798e; border-radius: 5px; color: #3e2e43; background: #fbf4ed; font-size: 12px; font-weight: 700; }
.inspection-close:hover { background: #e9d9ee; }
.inspection-vitals { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.inspection-vital { display: grid; grid-template-columns: auto auto; gap: 2px 8px; flex: 1 1 130px; min-width: 0; font-size: 12px; }
.inspection-vital span { font-weight: 700; }
.inspection-vital strong { text-align: right; font-variant-numeric: tabular-nums; }
.inspection-vital small { color: #356678; font-size: 11px; }
.inspection-track { grid-column: 1 / -1; height: 7px; overflow: hidden; border-radius: 4px; background: #c9baba; }
.inspection-track i { display: block; height: 100%; background: #6a994c; }
.inspection-track i.shield { background: #328fac; }
.inspection-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 0; }
.inspection-stats div { min-width: 0; }
.inspection-stats dt { color: #5b4a5d; font-size: 11px; font-weight: 700; }
.inspection-stats dd { margin: 2px 0 0; color: #2f2634; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.inspection-note { margin: 0; color: #5b4a5d; font-size: 11px; line-height: 1.2; }
.building-layout.site-detail-only { grid-template-columns: minmax(0, 1fr); }
.site-detail-only .building-menu, .site-detail-only .back-buildings { display: none; }
.unit-actions { justify-content: flex-end; flex: 0 1 300px; margin: 0; }
.unit-actions .small-button { min-height: 32px; }
.paged-panel { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 5px; height: 100%; min-height: 0; }
.page-heading { display: flex; align-items: center; gap: 10px; min-height: 32px; font-size: 13px; }
.page-heading > span { color: #e1d9e4; font-size: 11px; }
.page-controls { display: flex; align-items: center; gap: 7px; margin-left: auto; white-space: nowrap; font-size: 12px; }
.page-controls button, .enemy-filter button, .back-buildings { min-width: 34px; min-height: 32px; padding: 0 9px; border: 1px solid #897a99; border-radius: 5px; color: #fff; background: #45374f; }
.info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); min-height: 0; }
.info-grid.one-card { grid-template-columns: minmax(0, 1fr); }
.info-card { min-height: 0; padding: 8px; }
.info-card .small-button { min-height: 32px; }
.hero-layout { display: grid; grid-template-columns: minmax(165px, 28%) minmax(0, 1fr); gap: 8px; height: 100%; }
.hero-picker { display: grid; grid-template-rows: repeat(var(--hero-count, 2), minmax(0, 1fr)); gap: 5px; min-height: 0; }
.hero-choice { min-height: 0; }
.hero-detail { min-height: 0; padding: 8px 10px; border-radius: 8px; color: #302638; background: #f2e8dc; }
.hero-detail .hero-status { margin: 0 0 4px; color: #674b76; font-weight: 700; }
.hero-detail .small-button { margin-top: 6px; min-height: 32px; }
.enemy-filter { display: flex; gap: 5px; }
.enemy-filter button[aria-pressed="true"] { background: #745499; border-color: #d1b0ec; }
.enemy-unit-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); gap: 5px; margin: 0; }
.enemy-chip { padding: 7px; font-size: 11px; }
.guide-copy { display: block; padding: 8px 10px; border-radius: 8px; background: #352d40; }
.guide-copy h3 { margin: 0 0 5px; font-size: 14px; }
.guide-copy p { margin: 0; font-size: 12px; }
@media (max-width: 950px) {
  .command-deck { grid-template-columns: 150px minmax(0, 1fr); }
  .deck-map { padding: 6px; }
  .building-layout { grid-template-columns: minmax(235px, 38%) minmax(0, 1fr); }
  .building-list { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .building-card .building-glyph { flex-basis: 22px; width: 22px; height: 22px; font-size: 12px; }
  .building-sprite { flex-basis: 27px; width: 42px; height: 27px; }
  .building-name strong { font-size: 11px; }
  .building-name small { display: none; }
  .detail-title p { display: none; }
}
@media (max-width: 800px) {
  .capacity small { display: none; }
  .building-layout { grid-template-columns: minmax(0, 1fr); }
  .building-layout.show-detail .building-menu { display: none; }
  .building-layout:not(.show-detail) .building-detail, .building-layout.show-detail .building-list { display: none; }
  .back-buildings { display: block; min-height: 32px; color: #372b40; background: #eee5ef; }
}
.setup-opponent { padding: 12px 14px; border: 1px solid #75677f; border-radius: 8px; background: #342c40; }
.setup-opponent strong { font-size: 14px; }
.setup-opponent p { margin: 10px 0 6px; font-weight: 700; }
.setup-opponent small { color: #e1d9e4; font-size: 12px; }
.difficulty-control { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: 13px; font-weight: 700; }
.difficulty-control select { min-height: 38px; padding: 5px 28px 5px 10px; border: 1px solid #a99bbb; border-radius: 6px; color: #fff; background: #45374f; }
.difficulty-description { display: block; margin-top: 7px; line-height: 1.35; }
@media (max-width: 650px) {
  .game-shell { grid-template-rows: auto minmax(100px, 1fr) minmax(0, 38dvh); }
  .command-deck { grid-template-columns: minmax(0, 1fr); }
  .deck-map { display: contents; }
  .map-frame { position: fixed; right: 7px; bottom: calc(38dvh + 7px); z-index: 3; width: 122px; }
  .deck-top { min-height: 41px; padding: 0 5px; }
  .deck-tabs button { flex: 1 1 0; min-height: 41px; padding: 0 3px; }
  .tab-full { display: none; }
  .tab-short { display: inline; }
  .capacity { gap: 3px; }
  .deck-panel { padding: 5px; }
  .building-layout { grid-template-columns: minmax(0, 1fr); }
  .building-layout:not(.show-detail) .building-detail, .building-layout.show-detail .building-list { display: none; }
  .back-buildings { display: block; min-height: 32px; color: #372b40; background: #eee5ef; }
  .building-card { padding: 5px; }
  .building-card .building-glyph { flex-basis: 25px; width: 25px; height: 25px; }
  .building-name small { display: block; }
  .detail-head { flex-direction: row; align-items: center; padding: 4px 6px; }
  .unit-picker { padding: 3px 5px 0; }
  .unit-focus { padding: 4px 6px; }
  .unit-actions { flex-basis: auto; }
  .unit-actions .small-button { min-height: 38px; }
  .hero-layout { grid-template-columns: 34% minmax(0, 1fr); }
  .unit-inspector { grid-template-columns: 76px minmax(0, 1fr); }
  .inspection-portrait { padding: 6px; }
  .inspection-main { gap: 6px; padding: 7px 9px; }
  .inspection-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px 10px; }
}
@media (max-width: 400px) {
  .hero-detail .unit-meta { display: none; }
  .inspection-main { gap: 2px; padding: 4px 7px; }
  .enemy-unit-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 650px) and (max-height: 600px) and (orientation: landscape) {
  .game-shell { grid-template-rows: auto minmax(70px, 1fr) minmax(0, 52dvh); }
  .map-frame { bottom: calc(52dvh + 7px); }
  .unit-copy .unit-meta, .unit-copy h3 { display: none; }
  .enemy-chip { padding: 5px 7px; }
}
@media (max-height: 600px) {
  .info-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto; column-gap: 8px; row-gap: 2px; align-content: center; }
  .info-card h3, .info-card p { grid-column: 1; }
  .info-card .small-button { grid-column: 2; grid-row: 1 / 3; align-self: center; margin: 0; }
}
@media (max-height: 600px) and (min-width: 651px) {
  .game-shell { grid-template-rows: auto minmax(90px, 1fr) minmax(0, 47dvh); }
  .deck-top { min-height: 38px; }
  .deck-tabs button { min-height: 38px; }
  .deck-panel { padding: 5px 8px; }
  .detail-title p, .unit-copy .unit-meta, .unit-copy h3 { display: none; }
  .unit-focus { padding: 3px 7px; }
  .unit-inspector { grid-template-columns: 90px minmax(0, 1fr); }
  .inspection-main { gap: 3px; padding: 5px 9px; }
  .inspection-portrait span { display: none; }
}
@media (max-height: 600px) and (orientation: landscape) {
  .game-shell.is-placing { grid-template-rows: auto minmax(0, 1fr) 0; }
  .game-shell.is-placing .command-deck { visibility: hidden; }
  .placement-bar button { min-height: 44px; }
}
@media (max-height: 420px) and (orientation: landscape) {
  .hero-detail .unit-meta { display: none; }
  .inspection-main { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto auto auto; gap: 3px 10px; padding: 5px 8px; }
  .inspection-header { grid-column: 1; }
  .inspection-vitals { grid-column: 2; align-self: center; }
  .inspection-stats, .inspection-note { grid-column: 1 / -1; }
  .inspection-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
}

.worker-layout { display: grid; grid-template-columns: minmax(150px, 22%) minmax(0, 1fr); gap: 8px; height: 100%; min-height: 0; }
.worker-identity { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 8px; border: 1px solid #b8a5b5; border-radius: 8px; color: #302638; background: #e2d5e9; }
.worker-identity .portrait-focus { flex: 0 1 96px; width: min(46%, 96px); max-height: 100%; }
.worker-identity img { width: 100%; max-height: 100%; object-fit: contain; }
.worker-identity div { min-width: 0; }
.worker-identity h2 { margin: 0; font-size: 15px; }
.worker-identity p { margin: 4px 0 0; color: #5b4a5d; font-size: 12px; line-height: 1.3; }
.worker-identity p span { display: block; }
.empty-selection { display: flex; align-items: center; justify-content: center; gap: 14px; height: 100%; min-height: 0; padding: 10px; }
.empty-selection p { margin: 0; color: #e5dbe8; font-size: 13px; }
.empty-selection .small-button { flex: 0 0 auto; }
.worker-orders { display: flex; flex-direction: column; justify-content: center; gap: 10px; min-width: 0; padding: 12px 16px; border: 1px solid #766981; border-radius: 8px; color: #302638; background: #f2e8dc; }
.worker-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.worker-buttons button { min-width: 100px; min-height: 44px; }
.worker-buttons span { margin-left: 8px; color: #e3d6ee; font-size: 11px; }
.worker-orders p { margin: 0; color: #514753; font-size: 12px; line-height: 1.35; }
.worker-build-menu { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 5px; min-width: 0; min-height: 0; }
.worker-build-heading { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 13px; }
.worker-back { display: block; flex: 0 0 auto; min-height: 32px; }
.worker-building-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 5px; min-height: 0; }
.worker-building { position: relative; min-width: 0; }
.worker-building kbd { position: absolute; top: 5px; right: 6px; display: grid; place-items: center; min-width: 22px; height: 22px; border-radius: 4px; font-family: inherit; font-size: 12px; font-weight: 700; line-height: 1; }
.worker-page-shortcuts { color: #52617a; font-size: 11px; white-space: nowrap; }
.worker-building.unavailable { color: #c6bdc9; background: #2b2533; }
.worker-building.unavailable .building-sprite { opacity: .6; }
.worker-building .building-name small { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 650px) {
  .worker-layout { grid-template-columns: 85px minmax(0, 1fr); gap: 5px; }
  .worker-identity { flex-direction: column; justify-content: center; gap: 2px; padding: 5px; text-align: center; }
  .worker-identity .portrait-focus { flex: 0 1 60px; width: 70%; }
  .worker-identity h2 { font-size: 12px; }
  .worker-identity p { margin-top: 1px; font-size: 11px; }
  .worker-orders { gap: 5px; padding: 8px; }
  .worker-buttons button { min-width: 76px; }
  .worker-orders p { font-size: 11px; }
  .worker-building-grid { gap: 3px; }
  .worker-page-shortcuts { display: none; }
}
@media (max-height: 600px) {
  .worker-building .building-sprite { display: none; }
  .worker-building { gap: 0; padding-right: 26px; }
  .worker-building kbd { top: 3px; right: 3px; }
  .worker-build-menu { gap: 3px; }
}
@media (max-width: 400px) {
  .worker-building-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* The selected unit stays next to its context; orders occupy a consistent right-hand bay. */
.worker-orders { flex-direction: row; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 18px; border-color: #675872; color: #f5edf6; background: #352c40; }
.worker-orders p { max-width: 280px; color: #e4d8e7; font-size: 13px; line-height: 1.6; }
.worker-orders p strong { color: #f0d7ff; }
.worker-buttons { display: grid; flex: 0 0 auto; grid-template-columns: repeat(2, 88px); gap: 8px; }
.worker-buttons .worker-command { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-width: 0; min-height: 92px; padding: 8px 4px; border: 1px solid #8b70a3; border-radius: 7px; color: #fff; background: #67468d; font-size: 12px; font-weight: 700; }
.worker-command:hover { background: #7b58a0; }
.worker-command svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; }
.worker-buttons .worker-command span { margin: 0; color: inherit; font-size: 12px; }
.worker-command kbd { position: absolute; top: 5px; right: 6px; color: #ecdcf6; font-family: inherit; font-size: 11px; font-weight: 700; }

.enemy-layout { display: grid; grid-template-columns: minmax(230px, 27%) minmax(0, 1fr); gap: 8px; height: 100%; min-height: 0; }
.enemy-profile { display: grid; grid-template-columns: minmax(86px, 40%) minmax(0, 1fr); align-items: center; min-width: 0; min-height: 0; overflow: hidden; border: 1px solid #a98a87; border-radius: 8px; color: #302638; background: #eee0d9; }
.enemy-profile-art { display: flex; align-items: center; justify-content: center; align-self: stretch; min-width: 0; min-height: 0; padding: 6px; background: #ddc3b7; }
.enemy-profile-art img { display: block; width: 100%; max-width: 128px; max-height: 100%; object-fit: contain; }
.enemy-profile-copy { display: flex; flex-direction: column; justify-content: center; gap: 3px; min-width: 0; min-height: 0; padding: 8px 10px; }
.enemy-profile-copy > span, .enemy-profile-copy > small { color: #654d4c; font-size: 11px; font-weight: 700; }
.enemy-profile-copy h2 { margin: 0; color: #302638; font-size: 17px; line-height: 1.15; }
.enemy-profile-copy p { margin: 0; color: #5d4950; font-size: 12px; }
.enemy-profile-copy dl { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 5px 0; font-size: 11px; }
.enemy-profile-copy dl div { display: flex; gap: 4px; }
.enemy-profile-copy dt { color: #654d4c; }
.enemy-profile-copy dd { margin: 0; color: #302638; font-weight: 800; }
.enemy-profile-empty { display: grid; gap: 5px; grid-column: 1 / -1; padding: 14px; }
.enemy-profile-empty span, .enemy-profile-empty p { margin: 0; color: #654d4c; font-size: 12px; }
.enemy-roster { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 6px; min-width: 0; min-height: 0; }
.enemy-toolbar { display: flex; align-items: center; gap: 10px; min-width: 0; min-height: 32px; }
.enemy-filter { flex: 0 0 auto; }
.enemy-filter button { min-height: 32px; padding: 0 10px; font-size: 12px; font-weight: 700; }
.enemy-count-legend { color: #d9ccd7; font-size: 11px; white-space: nowrap; }
.enemy-unit-list { display: grid; grid-template-columns: repeat(var(--enemy-count, 6), minmax(0, 138px)); grid-template-rows: minmax(0, 1fr); justify-content: center; gap: 6px; align-content: stretch; min-height: 0; margin: 0; }
.enemy-unit { display: grid; grid-template-rows: minmax(0, 1fr) auto auto; align-items: center; justify-items: center; gap: 2px; min-width: 0; min-height: 0; padding: 5px 4px; border: 1px solid #806a78; border-radius: 6px; color: #f8f1f4; background: #493b45; font-size: 11px; }
.enemy-unit:hover { background: #5c474d; }
.enemy-unit[aria-pressed="true"] { border-color: #f3c09d; background: #6a4c47; box-shadow: inset 0 0 0 1px #f3c09d; }
.enemy-unit img { display: block; width: 100%; height: 100%; min-height: 0; max-width: 88px; object-fit: contain; }
.enemy-unit span { max-width: 100%; overflow: hidden; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.enemy-unit strong { color: #ffdebb; font-size: 11px; font-variant-numeric: tabular-nums; }
.enemy-empty { align-self: center; margin: 0; padding: 8px 12px; color: #e7dce8; font-size: 12px; }

@media (max-width: 950px) {
  .enemy-layout { grid-template-columns: minmax(155px, 25%) minmax(0, 1fr); }
  .enemy-profile { grid-template-columns: minmax(55px, 42%) minmax(0, 1fr); }
  .enemy-profile-copy { padding: 6px; }
  .enemy-profile-copy dl { gap: 3px 6px; }
}
@media (max-height: 600px) and (min-width: 651px) {
  .enemy-profile-copy { gap: 1px; padding: 4px 6px; }
  .enemy-profile-copy > span, .enemy-profile-copy > small, .enemy-profile-copy p { line-height: 1.1; }
  .enemy-profile-copy dl { flex-direction: column; gap: 1px; margin: 2px 0; line-height: 1.1; }
}
@media (max-width: 650px) {
  .worker-orders { gap: 6px; padding: 7px; }
  .worker-orders p { font-size: 11px; line-height: 1.3; }
  .worker-buttons { grid-template-columns: repeat(2, 60px); gap: 4px; }
  .worker-buttons .worker-command { min-height: 68px; padding: 5px 2px; }
  .worker-command svg { width: 22px; height: 22px; }
  .worker-buttons .worker-command span { font-size: 11px; }
  .enemy-layout { grid-template-columns: minmax(90px, 28%) minmax(0, 1fr); gap: 5px; }
  .enemy-profile { display: flex; flex-direction: column; justify-content: center; }
  .enemy-profile-art { flex: 1 1 42px; width: 100%; padding: 3px; }
  .enemy-profile-art img { max-width: 70px; }
  .enemy-profile-copy { flex: 0 0 auto; width: 100%; gap: 1px; padding: 4px 6px; }
  .enemy-profile-copy h2 { font-size: 13px; }
  .enemy-profile-copy > span, .enemy-profile-copy > small, .enemy-profile-copy p { font-size: 11px; }
  .enemy-profile-copy dl { display: none; }
  .enemy-profile-empty { padding: 7px; }
  .enemy-toolbar { gap: 4px; }
  .enemy-filter { gap: 3px; }
  .enemy-filter button { min-width: 0; padding: 0 6px; font-size: 11px; }
  .enemy-count-legend { display: none; }
  .enemy-unit-list { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(var(--enemy-rows, 2), minmax(0, 1fr)); gap: 3px; }
  .enemy-unit { padding: 3px; }
  .enemy-unit img { max-width: 60px; }
}
@media (max-width: 400px) {
  .worker-orders p { display: none; }
  .worker-orders { justify-content: center; }
  .enemy-toolbar .page-controls { gap: 3px; }
  .site-detail-only .unit-copy h3 { display: none; }
  .site-detail-only .unit-choice img { flex-basis: 26px; width: 26px; height: 26px; }
  .site-detail-only .unit-focus { gap: 5px; padding-block: 2px; }
  .site-detail-only .unit-actions { gap: 3px; }
  .site-detail-only .unit-actions strong { min-width: 48px; white-space: nowrap; }
}
@media (max-width: 650px) and (max-height: 420px) {
  .enemy-unit-list { grid-template-rows: minmax(0, 1fr); }
  .enemy-profile-copy > small, .enemy-profile-copy p { display: none; }
  .enemy-profile-art { flex-basis: 28px; }
  .enemy-unit img { max-width: 56px; }
}

/* Commander selection uses the same character art as the game. */
.setup-card { width: min(900px, 100%); padding: 26px; }
.setup-card h2 { font-size: 32px; }
.setup-grid { display: block; margin-top: 18px; }
.setup-grid legend { margin-bottom: 9px; color: #e3d7eb; font-size: 13px; }
.faction-options { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.faction-choice { position: relative; display: grid; grid-template-rows: minmax(0, 1fr) auto; min-width: 0; height: 244px; gap: 0; padding: 10px 14px 12px; overflow: hidden; border-radius: 10px; }
.faction-choice.faction-cat { background: #3e324e; }
.faction-choice.faction-dog { background: #49362f; }
.faction-choice.faction-cat:hover { background: #51405e; }
.faction-choice.faction-dog:hover { background: #5d4438; }
.faction-choice.faction-cat[aria-pressed="true"] { border-color: #d5b6ff; background: #59466a; }
.faction-choice.faction-dog[aria-pressed="true"] { border-color: #ffc197; background: #68493d; }
.faction-choice .faction-art { display: flex; align-items: flex-end; justify-content: center; gap: 0; min-width: 0; min-height: 0; height: 100%; }
.setup-commander-art { display: block; flex: 0 1 180px; width: 180px; height: auto; max-width: 58%; aspect-ratio: 1; background-image: url('/public/assets/eko-kwon-reference.webp'); background-repeat: no-repeat; background-size: 200% 100%; }
.setup-commander-art.cat { background-position: left center; }
.setup-commander-art.dog { background-position: right center; }
.faction-art img { display: block; flex: 0 1 138px; width: 138px; height: 138px; max-width: 47%; margin-left: -22px; object-fit: contain; }
.faction-choice .faction-choice-info { display: flex; flex-direction: row; align-items: baseline; gap: 8px; min-width: 0; }
.faction-choice-info strong { font-size: 18px; }
.faction-choice-info small { color: #eee3ed; font-size: 12px; }
.faction-choice .faction-side { position: absolute; top: 10px; left: 12px; display: block; padding: 5px 8px; border-radius: 5px; color: #eadfe9; background: #27202cd9; font-size: 11px; font-weight: 800; }
.faction-choice[aria-pressed="true"] .faction-side { color: #2b2031; background: #e8d5ff; }
.faction-choice.faction-dog[aria-pressed="true"] .faction-side { background: #ffd2b0; }
.setup-footer { gap: 12px; margin-top: 16px; }
.setup-footer .difficulty-control { margin: 0; color: #f5eef6; }
.setup-footer .difficulty-control select { min-width: 100px; }
.setup-footer .primary-button { min-width: 138px; }
@media (max-width: 650px) {
  .setup-card { padding: 16px; }
  .setup-card h2 { font-size: 26px; }
  .setup-grid { margin-top: 12px; }
  .faction-options { gap: 7px; }
  .faction-choice { height: 188px; padding: 8px 9px; }
  .setup-commander-art { flex-basis: 120px; width: 120px; }
  .faction-art img { flex-basis: 95px; width: 95px; height: 95px; margin-left: -16px; }
  .faction-choice-info strong { font-size: 15px; }
  .faction-choice-info small { font-size: 11px; }
  .faction-choice .faction-choice-info { flex-wrap: wrap; gap: 2px 5px; }
  .faction-choice .faction-side { top: 7px; left: 7px; padding: 4px 6px; }
  .setup-footer { margin-top: 12px; }
  .setup-footer .difficulty-control { gap: 6px; font-size: 12px; }
  .setup-footer .difficulty-control select { min-width: 82px; }
  .setup-footer .primary-button { min-width: 104px; padding-inline: 12px; }
  .money { grid-template-columns: 1fr; gap: 0; }
  .money small { display: block; grid-column: 1; font-size: 11px; line-height: 1; }
}
@media (max-width: 400px) {
  .setup-card { padding: 14px; }
  .faction-choice { height: 166px; }
  .faction-choice .faction-art { align-items: center; }
  .setup-commander-art { flex-basis: 100px; width: 100px; }
  .faction-art img { flex-basis: 80px; width: 80px; height: 80px; margin-left: -32px; }
  .setup-footer { flex-wrap: wrap; }
  .setup-footer .primary-button { flex: 1; }
}
@media (max-height: 420px) {
  .overlay { padding: 8px; }
  .setup-card { max-height: calc(100dvh - 16px); padding: 12px 16px; }
  .setup-card h2 { font-size: 23px; }
  .setup-grid { margin-top: 6px; }
  .setup-grid legend { margin-bottom: 4px; font-size: 12px; }
  .faction-choice { height: 118px; padding: 5px 9px; }
  .setup-commander-art { flex-basis: 76px; width: 76px; }
  .faction-art img { flex-basis: 68px; width: 68px; height: 68px; margin-left: -12px; }
  .faction-choice-info strong { font-size: 14px; }
  .faction-choice .faction-side { top: 5px; left: 6px; padding: 3px 5px; }
  .setup-footer { margin-top: 8px; }
}
@media (max-width: 650px) and (max-height: 420px) {
  .worker-identity { gap: 0; padding: 3px; }
  .worker-identity .portrait-focus { flex-basis: 38px; width: 55%; max-height: 42px; }
  .worker-identity p { line-height: 1.1; }
  .site-detail-only .building-detail { grid-template-columns: minmax(95px, 25%) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .site-detail-only .detail-head { grid-column: 1 / -1; }
  .site-detail-only .unit-picker { grid-column: 1; grid-row: 2; grid-template-columns: minmax(0, 1fr); padding: 3px; }
  .site-detail-only .unit-choice { min-height: 0; }
  .site-detail-only .unit-focus { grid-column: 2; grid-row: 2; min-width: 0; }
}
