/* =====================================================================================================
   Space Game client stylesheet
   -----------------------------------------------------------------------------------------------------
   Layout containers (index.html, fixed positions, all overlays over the full-screen #galaxy svg):
     #galaxy          full screen svg                     #top-left       turn + Score / New game buttons
     #command-list    top center, single scrollable line  #resources      top right, 2 rows
     #under-commands  below command list (centered)       #step-text      top center progression text
     #action-left     above selection, left               #action-right   above selection, right
     #selection       bottom 25% of the screen            #progress-panel right side log (progression)
     #center-msg      toast in the middle                 #popup-layer    modal container
   Visibility helpers:
     .hidden          display:none (use on any element)
     .overlay         generic translucent panel look (already applied to layout containers)
     body.mode-<mode> set by main.js on every render: mode-default, mode-finished, mode-activation,
                      mode-progression, mode-deployment, mode-bombardment, mode-annihilation, mode-gameover
   Buttons:
     .btn             generic button (<button class="btn">)     .btn.primary   highlighted main action
     .btn.danger      red action                                .btn.small     compact button
     .btn:disabled    greyed out, not clickable                 .btn.active    toggled on state
     .icon-btn        small square text button, e.g. "+" / "-"  .remove-x      red "x" for removing entries
   Popups (inside #popup-layer):
     .popup-backdrop  full screen dim layer (click-catcher)     .popup         centered dialog box
     .popup h2/.popup-title   title          .popup-body   scrollable content   .popup-buttons  bottom bar
     .popup.wide      wider dialog (score table, battle report)
   Tabs:
     .tabs > .tab (.tab.active)               tab strip; content below is up to the module
   Lists / rows:
     .list            vertical scrollable box              .list-item     row inside (flex, space-between)
     .list-item.selected  highlighted choice               .list-item.clickable  hover/cursor
     .disabled        greyed entry (opacity + no pointer)  .queued        italic "queued" entries
     .indent          indented sub row (cargo lines)       .muted         secondary grey text
     .row             horizontal flex row with gap         .col           vertical flex column
     .spacer          flex:1 filler                        .right         text-align right / margin-left auto
     .error / .warn / .ok   red / orange / green text      .bad           red number (over budget)
   Player colors:
     .pc              inline player colored text: set style="color: <player color>" (adds text shadow)
     .swatch          small colored square: set style="background: <color>"
   Inputs:
     .num-input       small number box, with .icon-btn +/- around it
     .qty             wrapper row for "- [n] +"
   Tables:
     table.grid       compact table (score table, battle report); th/td; .num right aligned
   Command list:
     .cmd-entry       one command entry in #command-list    .cmd-entry.error  invalid command (red border)
     .cmd-entry .remove-x
   Selection view helpers:
     .sel-grid        two column grid for selection views   .sel-box   bordered scrollable sub box
     .sel-header      header line                           .pbox      html planet view box container
   Log (progress panel):
     .log-entry (.log-entry.battle/.capture/.build/.research/.score/.event/.move) .log-step  step heading
     .log-entry.current  currently replayed entry
   Tooltip (long press / hover):
     .tooltip         absolutely positioned tooltip box (module positions it)
   Galaxy svg classes (galaxy.js): .hex, .hex.activated, .hex.current, .hex.path, .hex.selected, .hex.home,
     .storm, .sys-name, .ship-row, .planet-grp, .sb-text, .move-arrow, .anim-arrow
   ===================================================================================================== */

:root {
  --bg: #05070f;
  --panel: rgba(12, 18, 34, 0.86);
  --panel-solid: #0e1528;
  --panel-border: rgba(110, 150, 220, 0.35);
  --text: #dfe7f5;
  --muted: #8592ab;
  --accent: #4fa3ff;
  --accent-2: #7cc4ff;
  --danger: #ff5a5f;
  --danger-muted: #d96b6b;
  --warn: #ffb347;
  --ok: #5fd35f;
  --sel-h: 25vh;
  --gap: 6px;
  --radius: 6px;
  --font: 14px;
}

* { box-sizing: border-box; }

.tier-sup { font-size: 0.7em; vertical-align: super; line-height: 0; }

html, body {
  margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; font-size: var(--font);
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  overscroll-behavior: none;
}

.hidden { display: none !important; }

button, input, select { font: inherit; color: inherit; }

/* --------------------------------------------------------------------------------- galaxy svg */
#galaxy {
  position: fixed; inset: 0; width: 100vw; height: 100vh; display: block;
  background: radial-gradient(ellipse at 50% 45%, #111a36 0%, #070a17 55%, #03040a 100%);
  cursor: grab; user-select: none; -webkit-user-select: none; touch-action: none;
}
#galaxy.dragging { cursor: grabbing; }
#galaxy text { font-family: "Segoe UI", Roboto, Arial, sans-serif; pointer-events: none; }
#galaxy .hit { cursor: pointer; }

#galaxy .hex { fill: rgba(20, 32, 64, 0.35); stroke: rgba(120, 160, 230, 0.35); stroke-width: 1.5; }
#galaxy .hex.home { fill: rgba(40, 40, 70, 0.45); }
#galaxy .hex.center-sys { fill: rgba(60, 40, 80, 0.40); }
/* activated/current: stroke + tint are set inline to the accented player color (galaxy.js);
   these values are fallbacks for spectators / missing colors. */
#galaxy .hex.activated { stroke: #ffd24a; stroke-width: 3.5; }
#galaxy .hex.path { stroke: #4fe0ff; stroke-width: 4; fill: rgba(40, 150, 200, 0.18); }
#galaxy .hex.selected { stroke: #ffffff; stroke-width: 3; }
#galaxy .hex.current { stroke: #ffe066; stroke-width: 6; fill: rgba(255, 210, 60, 0.12); }
#galaxy .hex.hl-deploy { stroke: #6cff9a; stroke-width: 6; fill: rgba(80, 255, 140, 0.10); }
#galaxy .hex.hl-bomb { stroke: #ff9a4d; stroke-width: 6; fill: rgba(255, 150, 70, 0.12); }
#galaxy .hex.hl-ann { stroke: #ff5a5a; stroke-width: 6; fill: rgba(255, 80, 80, 0.14); }
#galaxy .hex.hl-retreat { stroke: #ff7ad9; stroke-width: 6; fill: rgba(255, 110, 200, 0.14);
  animation: retreat-pulse 1.1s ease-in-out infinite; }
#galaxy .retreat-edge { stroke: #ff7ad9; stroke-width: 5; stroke-dasharray: 10 8; opacity: 0.85;
  animation: retreat-pulse 1.1s ease-in-out infinite; }
@keyframes retreat-pulse { from { opacity: 0.45; } 50% { opacity: 1; } to { opacity: 0.45; } }
.popup-backdrop.bp-fade { animation: bp-fade-in 0.18s ease-out; }
.popup-backdrop.bp-fade.bp-hiding { animation: bp-fade-out 0.18s ease-in forwards; }
#galaxy .storm { fill: url(#storm-pattern); pointer-events: none; }
#galaxy .sys-name { fill: #8a93a6; font-weight: 600; }
#galaxy .sys-name.storm-name { fill: #6f88a8; }
#galaxy .sel-outline { fill: none; stroke: #fff; stroke-width: 1.5; stroke-dasharray: 3 2; pointer-events: none; }
#galaxy .move-arrow { font-weight: 700; }
#galaxy .anim-arrow { stroke-width: 4; fill: none; opacity: 0.9; }

/* ------------------------------------------------------------------------------ overlay panels */
.overlay {
  position: fixed; z-index: 10;
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius);
  padding: 4px 8px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  touch-action: pan-x pan-y;
}
.overlay:empty { display: none; }

#top-left {
  top: 8px; left: 8px; display: flex; flex-direction: column; gap: 4px; align-items: flex-start;
  max-width: 30vw;
}
#top-left .turn { font-weight: 700; font-size: 1.1em; white-space: nowrap; }

#command-list {
  top: 8px; left: 50%; transform: translateX(-50%);
  width: min(56vw, 900px);
  display: flex; flex-wrap: nowrap; gap: 6px; align-items: center;
  overflow-x: auto; overflow-y: hidden; white-space: nowrap;
  scrollbar-width: thin;
  min-height: 34px;
}
#command-list:empty { display: flex; }
#command-list:empty::before { content: "No commands"; color: var(--muted); font-style: italic; }
body.mode-progression #command-list, body.mode-deployment #command-list, body.mode-bombardment #command-list, body.mode-annihilation #command-list, body.mode-gameover #command-list { display: none; }

#resources {
  top: 8px; right: 8px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap;
  display: flex; flex-direction: column; gap: 2px;
}
#resources .res-row { display: flex; gap: 6px; justify-content: flex-end; }
#resources .res-label { color: var(--muted); }

#under-commands {
  top: 50px; left: 50%; transform: translateX(-50%);
  max-width: min(70vw, 700px);
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
}

#step-text {
  top: 50px; left: 50%; transform: translateX(-50%);
  max-width: min(80vw, 800px); text-align: center; font-weight: 600; font-size: 1.1em;
}
body.mode-progression #step-text, body.mode-deployment #step-text, body.mode-bombardment #step-text, body.mode-annihilation #step-text { top: 8px; }

#action-left, #action-right {
  bottom: calc(var(--sel-h) + 6px);
  display: flex; gap: 6px; background: transparent; border: none; box-shadow: none; padding: 0;
}
#action-left { left: 8px; }
#action-right { right: 8px; }

/* activation queue: always visible on the left (see System activation queue view) */
#action-left.sv-queue-panel {
  top: 92px; bottom: calc(var(--sel-h) + 6px);
  flex-direction: column; align-items: stretch; gap: 4px;
  width: min(300px, 34vw);
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5); padding: 6px 8px;
  overflow-y: auto;
}
#action-left.sv-queue-panel .sv-queue-head { font-weight: 700; color: var(--accent-2); }
#action-left.sv-queue-panel .sv-queue-box { flex: 1 1 auto; min-height: 0; overflow-y: auto; font-size: 0.85em; }
#action-left.sv-queue-panel .sv-queue-box .pp-group { margin: 5px 0 1px; font-size: 0.95em; }
#action-left.sv-queue-panel .sv-queue-box .list-item { min-height: 0; padding: 1px 4px; gap: 4px; }
#action-left.sv-queue-panel .sv-queue-box .pp-qrow .remove-x { width: 20px; height: 20px; font-size: 0.9em; }
#action-left.sv-queue-panel .sv-queue-box .indent { padding-left: 8px; }
#action-left.sv-queue-panel .sv-queue-total {
  border-top: 1px solid var(--panel-border); padding-top: 4px;
  font-variant-numeric: tabular-nums; color: var(--muted); text-align: right;
}

#selection {
  left: 0; right: 0; bottom: 0; height: var(--sel-h); max-height: var(--sel-h);
  border-radius: 10px 10px 0 0; border-bottom: none;
  padding: 8px 10px; overflow: auto;
  background: rgba(10, 15, 30, 0.93);
}
#selection:empty { display: block; }
#selection:empty::before { content: "Nothing selected"; color: var(--muted); font-style: italic; }

#progress-panel {
  top: 90px; right: 8px; bottom: calc(var(--sel-h) + 50px);
  width: min(320px, 40vw);
  overflow: hidden; padding: 6px 8px; font-size: 0.92em;
  display: flex; flex-direction: column;
}
#progress-panel.collapsed { bottom: auto; }
#progress-panel .log-head { cursor: pointer; user-select: none; }
#progress-panel .log-head::before { content: "\25B8 "; display: inline-block; transition: transform 0.15s ease; }
#progress-panel:not(.collapsed) .log-head::before { transform: rotate(90deg); }
#progress-panel .log-body { overflow-y: auto; flex: 1 1 auto; }
#progress-panel.collapsed .log-body { display: none; }

#center-msg {
  position: fixed; z-index: 200; top: 42%; left: 50%; transform: translate(-50%, -50%);
  background: rgba(20, 24, 40, 0.95); border: 1px solid var(--accent); color: #fff;
  padding: 10px 18px; border-radius: 8px; font-size: 1.1em; font-weight: 600;
  pointer-events: none; text-align: center; max-width: 80vw;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.7);
  animation: toast-in 0.15s ease-out;
}
#center-msg.persistent { pointer-events: auto; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -40%); } to { opacity: 1; transform: translate(-50%, -50%); } }
@keyframes bp-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes bp-fade-out { from { opacity: 1; } to { opacity: 0; } }

/* ------------------------------------------------------------------------- lobby (start screen) */
#lobby {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 12px;
  background: radial-gradient(ellipse at 50% 45%, #111a36 0%, #070a17 55%, #03040a 100%);
  touch-action: pan-y;
}
#lobby .lobby-box {
  width: min(380px, 94vw); display: flex; flex-direction: column; gap: 10px; align-items: stretch;
  background: var(--panel-solid); border: 1px solid #3a5388; border-radius: 10px;
  padding: 18px 20px; box-shadow: 0 8px 40px rgba(0, 0, 0, 0.8); text-align: center;
}
#lobby h1 { margin: 0; font-size: 1.6em; letter-spacing: 0.05em; }
#lobby .lobby-list { text-align: left; }
#lobby .lobby-list .list-item { gap: 8px; }
#lobby .lobby-status { margin-left: auto; }
#lobby .lobby-kick {
  padding: 0 8px; min-height: 24px; min-width: 24px; font-size: 0.9em;
  color: #ff6b6b; border-color: #a33; background: #2a1414; line-height: 1;
}
#lobby .lobby-kick:hover { color: #fff; background: #a33; border-color: #c55; }
#lobby .lobby-ready { font-size: 1.2em; min-height: 48px; }
body.mode-lobby .overlay { display: none !important; }

#popup-layer { position: fixed; inset: 0; z-index: 100; pointer-events: none; }
#popup-layer > * { pointer-events: auto; }

/* ----------------------------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  padding: 6px 14px; min-height: 32px;
  background: #1b2744; color: var(--text);
  border: 1px solid #3a5388; border-radius: var(--radius);
  cursor: pointer; white-space: nowrap; user-select: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}
.btn:hover { background: #24345a; border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: #1d5fb8; border-color: #4fa3ff; color: #fff; font-weight: 600; }
.btn.primary:hover { background: #2470d6; }
.btn.danger { background: #6a1f25; border-color: #ff5a5f; }
.btn.danger:hover { background: #862a31; }
.btn.active { background: #2b4d86; border-color: var(--accent-2); color: #fff; }
.btn.small { padding: 2px 8px; min-height: 24px; font-size: 0.9em; }
.btn:disabled, .btn.disabled {
  opacity: 0.4; cursor: not-allowed; pointer-events: none; box-shadow: none; transform: none;
}
.btn.link { background: none; border: none; box-shadow: none; color: var(--accent-2); text-decoration: underline; padding: 2px 4px; min-height: 0; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; padding: 0; line-height: 1;
  background: #1b2744; border: 1px solid #3a5388; border-radius: 4px; cursor: pointer; font-weight: 700;
  flex: none;
}
.icon-btn:hover { border-color: var(--accent); }
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.remove-x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; padding: 0; margin-left: 4px;
  background: none; border: none; color: var(--danger); font-weight: 700; cursor: pointer; line-height: 1;
}
.remove-x:hover { color: #ff9095; }

/* ------------------------------------------------------------------------------------ popups */
.popup-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55);
  display: flex; align-items: center; justify-content: center; padding: 12px;
  z-index: 100;
}
.popup {
  background: var(--panel-solid); border: 1px solid #3a5388; border-radius: 10px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.8);
  width: min(460px, 94vw); max-height: 88vh;
  display: flex; flex-direction: column; overflow: hidden;
  touch-action: pan-y;
}
.popup.wide { width: min(760px, 96vw); }
.popup h2, .popup .popup-title {
  margin: 0; padding: 10px 14px; font-size: 1.1em; border-bottom: 1px solid var(--panel-border);
}
.popup .popup-body { padding: 10px 14px; overflow-y: auto; flex: 1 1 auto; }
.popup > p { margin: 8px 14px; }
.popup-buttons {
  display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap;
  padding: 10px 14px; border-top: 1px solid var(--panel-border); background: rgba(0, 0, 0, 0.2);
}
.popup-buttons .summary { margin-right: auto; align-self: center; color: var(--muted); }

/* -------------------------------------------------------------------------------------- tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--panel-border); margin-bottom: 8px; }
.tab {
  padding: 6px 12px; cursor: pointer; border: 1px solid transparent; border-bottom: none;
  border-radius: 6px 6px 0 0; color: var(--muted); background: none;
}
.tab:hover { color: var(--text); }
.tab.active { color: #fff; background: #1b2744; border-color: var(--panel-border); }

/* ------------------------------------------------------------------------------------- lists */
.list {
  display: flex; flex-direction: column; gap: 2px;
  border: 1px solid var(--panel-border); border-radius: var(--radius);
  padding: 4px; overflow-y: auto; background: rgba(0, 0, 0, 0.2);
}
.list-item {
  display: flex; align-items: center; gap: 6px; justify-content: space-between;
  padding: 4px 6px; border-radius: 4px; border: 1px solid transparent;
}
.list-item.clickable, .list-item[data-click] { cursor: pointer; }
.list-item.clickable:hover { background: rgba(80, 120, 200, 0.15); }
.list-item.selected { background: rgba(79, 163, 255, 0.22); border-color: var(--accent); }
.disabled { opacity: 0.4; cursor: not-allowed !important; }
.list-item.disabled:hover { background: none; }
.queued { font-style: italic; opacity: 0.85; }
.indent { padding-left: 18px; font-size: 0.92em; color: var(--muted); }

.row { display: flex; flex-direction: row; gap: var(--gap); align-items: center; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: var(--gap); }
.spacer { flex: 1 1 auto; }
.right { text-align: right; margin-left: auto; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 0.88em; }
.bold { font-weight: 700; }
.error, .bad { color: var(--danger); }
.warn { color: var(--warn); }
.ok { color: var(--ok); }

.pc { font-weight: 600; text-shadow: 0 0 2px rgba(0, 0, 0, 0.9); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: middle; margin-right: 4px; }

/* ------------------------------------------------------------------------------------ inputs */
.num-input {
  width: 48px; text-align: center; padding: 3px 4px;
  background: #0a1122; border: 1px solid #3a5388; border-radius: 4px;
  -moz-appearance: textfield; appearance: textfield;
}
.num-input::-webkit-outer-spin-button, .num-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.num-input.invalid { border-color: var(--danger); }
.qty { display: inline-flex; align-items: center; gap: 4px; }
select, input[type="text"] {
  background: #0a1122; border: 1px solid #3a5388; border-radius: 4px; padding: 3px 6px;
}
input[type="range"] { accent-color: var(--accent); }
input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }

/* ------------------------------------------------------------------------------------ tables */
table.grid { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
table.grid th, table.grid td { padding: 3px 6px; border-bottom: 1px solid rgba(110, 150, 220, 0.18); text-align: left; }
table.grid th { color: var(--muted); font-weight: 600; }
table.grid .num, table.grid td.num, table.grid th.num { text-align: right; }
table.grid tr.total td { font-weight: 700; border-top: 1px solid var(--panel-border); }

/* ------------------------------------------------------------------------------ command list */
.cmd-entry {
  display: inline-flex; align-items: center; gap: 2px; flex: none;
  padding: 3px 6px 3px 8px; border-radius: 4px; background: #16213d; border: 1px solid #2d426e;
  cursor: pointer; font-size: 0.92em;
}
.cmd-entry:hover { border-color: var(--accent); }
.cmd-entry.error { border-color: var(--danger); color: #ffc3c5; }
.cmd-entry.editing { border-color: #ffd24a; background: #2d2a14; }
body.mode-finished .cmd-entry { cursor: default; }

/* --------------------------------------------------------------------------- selection views */
.sel-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; height: 100%; }
.sel-box {
  border: 1px solid var(--panel-border); border-radius: var(--radius);
  padding: 4px 6px; overflow-y: auto; min-height: 0; background: rgba(0, 0, 0, 0.2);
}
.sel-header { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-weight: 600; margin-bottom: 4px; }
.sel-header .title { font-size: 1.05em; }

/* HTML planet view box (views.js planetBox) */
.pbox { display: inline-flex; align-items: flex-start; gap: 4px; padding: 4px; border-radius: 6px; cursor: pointer; }
.pbox:hover { background: rgba(80, 120, 200, 0.15); }
.pbox .tower { display: flex; flex-direction: column-reverse; gap: 2px; align-self: center; }
.pbox .tower span { width: 8px; height: 8px; border: 1px solid #778; display: block; }
.pbox .circle {
  width: 46px; height: 46px; border-radius: 50%; border: 2px solid currentColor;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.9em;
  background: rgba(0, 0, 0, 0.35);
}
.pbox .land { display: flex; flex-direction: column; font-size: 0.85em; font-weight: 700; }
.pbox .bld { font-size: 0.8em; text-align: center; }

/* ---------------------------------------------------------------------------- progress log */
.log-step { margin-top: 6px; font-weight: 700; color: var(--accent-2); border-bottom: 1px solid var(--panel-border); }
.log-entry { padding: 2px 0 2px 6px; border-left: 3px solid transparent; }
.log-entry.battle { border-left-color: var(--danger); cursor: pointer; }
.log-entry.capture { border-left-color: var(--warn); }
.log-entry.build { border-left-color: var(--ok); }
.log-entry.research { border-left-color: #c070f0; }
.log-entry.score { border-left-color: #ffd24a; }
.log-entry.event { border-left-color: #4fe0ff; }
.log-entry.move { border-left-color: #4fa3ff; }
.log-entry.current { background: rgba(79, 163, 255, 0.18); }

/* ---------------------------------------------------------------------------------- tooltip */
.tooltip {
  position: fixed; z-index: 300; max-width: 260px; pointer-events: none;
  background: #1a2238; border: 1px solid var(--accent); border-radius: 4px; padding: 4px 8px; font-size: 0.9em;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}

/* scrollbars */
::-webkit-scrollbar { width: 8px; height: 6px; }
::-webkit-scrollbar-thumb { background: #2d426e; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ------------------------------------------------------------------------------- responsive */
@media (max-width: 700px) {
  :root { --font: 13px; --sel-h: 25vh; }
  #top-left { max-width: 62vw; padding: 3px 5px; flex-direction: row; flex-wrap: wrap; align-items: center; }
  #top-left .btn { padding: 4px 8px; }
  #command-list { top: auto; bottom: auto; left: 8px; right: 8px; transform: none; width: auto; top: 64px; }
  #under-commands { top: 104px; max-width: 94vw; }
  #step-text { top: 64px; max-width: 94vw; font-size: 1em; }
  body.mode-progression #step-text, body.mode-deployment #step-text, body.mode-bombardment #step-text, body.mode-annihilation #step-text { top: 64px; }
  #resources { padding: 3px 6px; font-size: 0.92em; }
  #progress-panel { top: auto; left: 8px; right: 8px; width: auto; bottom: calc(var(--sel-h) + 46px); max-height: 22vh; }
  #progress-panel.collapsed { max-height: none; }
  .sel-grid { grid-template-columns: minmax(0, 1fr); height: auto; max-height: 100%; overflow-y: auto; }
  .btn { padding: 6px 10px; }
  .popup { width: 96vw; max-height: 92vh; }
}
@media (max-height: 500px) and (orientation: landscape) {
  :root { --sel-h: 32vh; --font: 12px; }
}

