/* GRAYLINE v0.4.0 Command Experience
   The field remains black. The command surface becomes obvious. */
:root {
  --ui-scale: 1;
  --deck-height: 246px;
  --deck-map-width: 330px;
  --deck-command-width: 430px;
  --ui-gap: 6px;
  --ui-pad: 10px;
  --line-faint: rgba(255,255,255,.09);
  --line-soft: rgba(255,255,255,.18);
  --line-clear: rgba(255,255,255,.34);
  --panel-deep: rgba(0,0,0,.94);
  --panel-quiet: rgba(3,3,3,.90);
  --panel-raised: rgba(10,10,10,.96);
  --text-primary: #f2f2f2;
  --text-secondary: #a0a0a0;
  --text-tertiary: #676767;
  --command-row: 82px;
  --focus-ring: 0 0 0 1px #fff, 0 0 0 3px #000;
}

html.interface-compact { --ui-scale: .90; --deck-height: 218px; --deck-map-width: 280px; --deck-command-width: 374px; --command-row: 68px; }
html.interface-large { --ui-scale: 1.10; --deck-height: 278px; --deck-map-width: 390px; --deck-command-width: 500px; --command-row: 92px; }

body { min-width: 960px; }

button:focus-visible,
select:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Application-root fullscreen. */
#graylineApp:fullscreen,
#graylineApp:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  background: #000;
}

/* One coherent command deck. */
.bottom-hud {
  left: 10px;
  right: 10px;
  bottom: calc(10px + var(--safe-bottom));
  height: var(--deck-height);
  grid-template-columns: var(--deck-map-width) minmax(560px,1fr) var(--deck-command-width);
  gap: var(--ui-gap);
  padding: 5px;
  border: 1px solid var(--line-soft);
  background: rgba(0,0,0,.74);
  box-shadow: 0 22px 70px rgba(0,0,0,.90), inset 0 1px 0 rgba(255,255,255,.035);
  backdrop-filter: blur(10px);
}

.bottom-hud::before {
  content: "COMMAND DECK";
  position: absolute;
  left: 10px;
  top: -17px;
  color: #595959;
  font: 650 8px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .18em;
}

.bottom-hud > .hud-panel {
  border-color: var(--line-faint);
  background: var(--panel-deep);
  overflow: hidden;
}

.minimap-panel {
  padding: 8px;
  grid-template-rows: minmax(0,1fr) auto;
  background: linear-gradient(145deg, rgba(255,255,255,.025), transparent 55%), #000 !important;
}

#minimap {
  height: calc(var(--deck-height) - 50px);
  min-height: 150px;
  border-color: var(--line-soft);
}

.minimap-meta {
  min-height: 28px;
  align-items: center;
  padding: 7px 4px 0;
  font-size: 8px;
}

.minimap-tools {
  right: 11px;
  top: 11px;
  gap: 4px;
}

.minimap-tools button {
  width: 34px;
  min-height: 34px;
  background: rgba(0,0,0,.88);
  border-color: rgba(255,255,255,.20);
}

#strategicMapButton { font-size: 13px; }

.selection-panel {
  grid-template-columns: clamp(154px, 15vw, 205px) minmax(300px,1fr) minmax(180px,.72fr);
  background: linear-gradient(110deg, rgba(255,255,255,.018), transparent 36%), #000 !important;
}

.selection-portrait-wrap {
  border-color: var(--line-faint);
}

#selectionPortrait {
  width: min(190px, 100%);
  height: auto;
  aspect-ratio: 3 / 2;
}

.selection-copy {
  padding: 15px 18px 12px;
  border-color: var(--line-faint);
  scrollbar-width: thin;
  scrollbar-color: #333 #000;
}

.selection-title {
  font-size: 1rem;
  color: #fff;
  letter-spacing: .15em;
}

.selection-subtitle {
  margin-top: 5px;
  max-width: 760px;
  line-height: 1.35;
  color: #797979;
}

.selection-stats {
  grid-template-columns: repeat(auto-fit, minmax(150px,1fr));
  margin-top: 13px;
  gap: 6px 16px;
}

.stat-row {
  min-height: 22px;
  align-items: center;
  color: #777;
}

.stat-row strong { color: #ddd; }

.selection-panel.tactical-overview .selection-portrait-wrap {
  background:
    linear-gradient(135deg, transparent 0 47%, rgba(255,255,255,.045) 48% 49%, transparent 50%),
    radial-gradient(circle at center, #101010 0, #030303 56%, #000 100%);
}

.selection-panel.tactical-overview .selection-copy {
  background: linear-gradient(90deg, rgba(255,255,255,.025), transparent 70%);
}

.selection-panel.tactical-overview .selection-stats {
  grid-template-columns: repeat(3, minmax(125px,1fr));
}

.selection-cards {
  grid-template-columns: repeat(auto-fit, minmax(72px,1fr));
  grid-auto-rows: minmax(74px,1fr);
  padding: 9px;
  scrollbar-width: thin;
}

.unit-card {
  min-width: 0;
  border-color: #252525;
  background: linear-gradient(145deg,#080808,#020202);
  overflow: hidden;
}

.unit-card strong {
  max-width: 100%;
  overflow: hidden;
  color: #aaa;
  font-size: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.unit-card:hover strong,
.unit-card.active strong { color: #fff; }

/* Command categories, context, and pages. */
.command-panel {
  grid-template-rows: 43px 44px minmax(0,1fr);
  background: #000 !important;
}

.command-tabs {
  border-color: var(--line-faint);
}

.command-tabs button {
  color: #646464;
  letter-spacing: .11em;
  font-size: 9px;
}

.command-tabs button[aria-selected="true"] {
  color: #fff;
  background: linear-gradient(to bottom,#141414,#040404);
}

.command-tabs button[aria-selected="true"]::after {
  left: 18px;
  right: 18px;
}

.command-context-bar {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 11px;
  border-bottom: 1px solid var(--line-faint);
  background: #030303;
}

.command-context-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.command-context-copy > span {
  overflow: hidden;
  color: #cfcfcf;
  font: 700 8px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .13em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.command-context-copy small {
  overflow: hidden;
  color: #5f5f5f;
  font-size: 7px;
  letter-spacing: .04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.command-context-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.command-context-actions button {
  min-width: 29px;
  min-height: 28px;
  padding: 0 7px;
  border-color: #2d2d2d;
  background: #070707;
  color: #929292;
  font-size: 8px;
}

#commandIndexButton { min-width: 48px; }

#commandPageIndicator {
  min-width: 35px;
  color: #777;
  font: 8px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-align: center;
}

.command-grid {
  grid-template-columns: repeat(3,minmax(0,1fr));
  grid-template-rows: repeat(2,minmax(0,1fr));
  grid-auto-rows: minmax(0,1fr);
  gap: 6px;
  padding: 7px;
  overflow: hidden;
}

.command-grid.is-empty {
  display: grid;
  place-items: center;
}

.command-empty-state {
  grid-column: 1 / -1;
  align-self: stretch;
  display: grid;
  place-content: center;
  gap: 7px;
  padding: 14px;
  border: 1px dashed #242424;
  color: #666;
  text-align: center;
}

.command-empty-state strong {
  color: #aaa;
  font-size: 10px;
  letter-spacing: .12em;
}

.command-empty-state button { justify-self: center; }

.command-button {
  grid-template-rows: 1fr auto auto;
  min-height: 0;
  padding: 7px 6px 6px;
  border-color: #292929;
  background: linear-gradient(145deg,#090909 0,#020202 72%);
  overflow: hidden;
}

.command-button:hover:not(:disabled),
.command-button:focus-visible:not(:disabled) {
  border-color: #aaa;
  background: linear-gradient(145deg,#141414,#050505);
}

.command-button .command-icon {
  align-self: center;
  font-size: clamp(1.05rem,1.4vw,1.6rem);
  color: #d0d0d0;
}

.command-button > span:not(.command-icon):not(.command-cost) {
  max-width: 100%;
  color: #aaa;
  font-size: 8px;
  font-weight: 650;
  letter-spacing: .05em;
  overflow: hidden;
  text-overflow: ellipsis;
}

.command-button .command-cost {
  top: 5px;
  right: 6px;
  color: #777;
  font-size: 7px;
}

.command-button .command-reason {
  min-height: 17px;
  max-height: 18px;
  overflow: hidden;
  color: #666;
  font-size: 7px;
  line-height: 1.15;
}

.command-button:disabled {
  opacity: .78;
  background: #020202;
}

.command-button:disabled .command-icon { color: #4c4c4c; }
.command-button:disabled > span:not(.command-cost) { color: #565656; }
.command-button.command-locked { border-style: dashed; }
.command-button.command-ready { border-color: #555; }
.command-button.command-active { box-shadow: inset 0 0 0 1px #fff; }

.command-page-flash { animation: command-page-flash 180ms ease-out; }
@keyframes command-page-flash { from { opacity: .45; transform: translateX(4px); } to { opacity: 1; transform: none; } }

/* Top HUD hierarchy. */
.top-hud {
  inset: 10px 10px auto 10px;
  grid-template-columns: minmax(310px,460px) 1fr;
  gap: 10px;
}

.objective-panel,
.resource-panel { min-height: 78px; }

.objective-panel {
  padding: 11px 14px;
  background: linear-gradient(120deg,rgba(255,255,255,.025),transparent 55%),rgba(0,0,0,.93);
}

.objective-row { font-size: 11px; }

.resource-panel {
  background: #000;
  border-color: var(--line-soft);
}

.resource-item,
.resource-time {
  min-width: 115px;
  border-color: var(--line-faint);
}

.resource-panel .resource-item:first-child {
  min-width: 145px;
  background: linear-gradient(135deg,rgba(255,255,255,.06),transparent 70%);
}

.resource-panel .resource-item:first-child strong { font-size: 1.12rem; }
.resource-item small,.resource-time small { font-size: 8px; }
.resource-item em { max-width: 145px; }

.logistics-strip {
  top: 98px;
  right: 10px;
  padding: 6px;
  border-color: var(--line-faint);
  background: rgba(0,0,0,.91);
}

/* Reserved event rail never covers the economy bar. */
.toast-stack {
  top: 156px;
  right: 10px;
  width: min(390px,31vw);
  gap: 5px;
}

.toast {
  pointer-events: auto;
  background: rgba(0,0,0,.96);
  border-color: #333;
  padding: 10px 12px;
}

.toast[data-viewable="true"]::after { content: "CLICK TO LOCATE"; }
.toast-action {
  grid-column: 2 / -1;
  justify-self: start;
  min-height: 24px;
  margin-top: 3px;
  padding: 4px 7px;
  font-size: 7px;
}

/* Queue management remains explicit. */
.queue-list { max-height: 104px; }
.queue-item { min-height: 36px; }
.queue-copy strong { font-size: 8.5px; }
.queue-cancel { min-width: 58px; }

/* Title and setup hierarchy. */
.title-screen .title-content {
  width: min(1500px,calc(100vw - 28px));
  padding: clamp(22px,3vh,48px) 0 36px;
}

.title-content h1 { font-size: clamp(3.5rem,7vw,6.6rem); }
.title-description { max-width: 880px; color: #858585; }

.skirmish-setup {
  width: min(960px,100%);
  gap: 8px;
  margin-top: 16px;
}

.skirmish-setup label,
.rando-grid label {
  border-color: #2b2b2b;
  background: rgba(0,0,0,.94);
}

.map-select-v030 {
  gap: 8px;
  margin-top: 15px;
}

.map-select-v030 .map-card {
  min-height: 116px;
  background: rgba(0,0,0,.94);
}

.title-actions { justify-content: center; margin-top: 18px; }
.title-actions button { min-width: 150px; }
.title-actions button span { margin-left: 7px; color: #686868; }

/* Systems: category navigation, responsive panels, predictable footer. */
.settings-dialog-v040 {
  width: min(1120px,94vw);
  height: min(790px,92vh);
  max-height: 92vh;
}

.settings-dialog-v040 form {
  height: 100%;
  max-height: none;
  display: grid;
  grid-template-rows: auto minmax(0,1fr) auto;
  padding: 26px;
  overflow: hidden;
}

.settings-dialog-v040 .dialog-head p,
.command-index-dialog .dialog-head p {
  margin: 7px 0 0;
  color: #6b6b6b;
  font-size: 11px;
  line-height: 1.45;
}

.settings-shell {
  min-height: 0;
  display: grid;
  grid-template-columns: 190px minmax(0,1fr);
  margin-top: 20px;
  border: 1px solid var(--line-soft);
  background: #000;
}

.settings-nav {
  display: grid;
  align-content: start;
  border-right: 1px solid var(--line-soft);
  background: #030303;
}

.settings-nav button {
  min-height: 54px;
  display: grid;
  grid-template-columns: 30px 1fr;
  align-items: center;
  padding: 0 14px;
  border: 0;
  border-bottom: 1px solid var(--line-faint);
  color: #747474;
  background: transparent;
  text-align: left;
  font-size: 9px;
}

.settings-nav button span { color: #3e3e3e; font-size: 8px; }
.settings-nav button.active { color: #fff; background: #0c0c0c; box-shadow: inset 2px 0 0 #fff; }
.settings-nav button.active span { color: #aaa; }

.settings-panels {
  min-height: 0;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: #383838 #000;
}

.settings-section {
  min-height: 100%;
  padding: 22px;
}

.settings-section[hidden] { display: none; }

.settings-section > header {
  padding-bottom: 15px;
  border-bottom: 1px solid var(--line-soft);
}

.settings-section > header span {
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .16em;
}

.settings-section > header p { margin: 5px 0 0; color: #676767; font-size: 10px; }

.settings-section-grid {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 1px;
  margin-top: 16px;
  background: var(--line-faint);
  border: 1px solid var(--line-faint);
}

.settings-section .setting-row {
  min-height: 84px;
  grid-template-columns: minmax(0,1fr) minmax(138px,42%);
  gap: 14px;
  padding: 12px 14px;
  border: 0;
  background: #030303;
}

.settings-section .setting-row > span {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.settings-section .setting-row strong { color: #cfcfcf; font-size: 10px; font-weight: 650; }
.settings-section .setting-row small { color: #626262; font-size: 9px; line-height: 1.35; }
.settings-section .setting-row select { width: 100%; min-width: 0; }
.settings-section .setting-row input[type="checkbox"] { justify-self: end; }
.settings-section .setting-row input[type="color"] { justify-self: end; }
.settings-section .setting-row-range { grid-template-columns: 1fr; align-content: center; }
.settings-section .setting-row-range > span { grid-template-columns: 1fr auto; }
.settings-section .setting-row-range > span small { grid-column: 1 / -1; }
.settings-section .setting-row-range input[type="range"] { width: 100%; }

.signal-preview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid #292929;
  background: #020202;
}

.signal-preview > span {
  padding: 12px;
  border: 1px solid currentColor;
  font-size: 10px;
  letter-spacing: .15em;
  text-align: center;
}
.signal-preview-friendly { color: var(--friendly-signal); }
.signal-preview-hostile { color: var(--enemy-signal); }
.signal-preview small { grid-column: 1 / -1; color: #5e5e5e; text-align: center; letter-spacing: .12em; }

.settings-footer {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  align-items: center;
  gap: 16px;
  padding-top: 16px;
}

.settings-note { margin: 0; }
.settings-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: 7px; }
.settings-actions button { min-height: 36px; }

/* Strategic theater view. */
.strategic-map-overlay {
  z-index: 72;
  background: rgba(0,0,0,.94);
  backdrop-filter: blur(8px);
}

.strategic-map-shell {
  width: min(1420px,94vw);
  height: min(880px,92vh);
  display: grid;
  grid-template-rows: auto minmax(0,1fr);
  border: 1px solid var(--line-clear);
  background: #000;
  box-shadow: 0 36px 140px #000;
}

.strategic-map-shell > header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line-soft);
}

.strategic-map-shell h2 { margin: 5px 0 0; color: #fff; font-weight: 300; letter-spacing: .16em; }
.strategic-map-shell p { margin: 5px 0 0; color: #666; font-size: 10px; }
.strategic-map-shell header > button { width: 42px; padding: 0; }
.strategic-map-stage { position: relative; min-height: 0; padding: 16px; }
#strategicMapCanvas { width: 100%; height: 100%; border: 1px solid #282828; background: #000; cursor: crosshair; }
.strategic-map-legend { position: absolute; left: 28px; bottom: 27px; display: flex; flex-wrap: wrap; gap: 12px; padding: 8px 10px; border: 1px solid #2e2e2e; background: rgba(0,0,0,.90); color: #888; font-size: 8px; letter-spacing: .08em; }

/* Command Index. */
.command-index-dialog {
  width: min(1320px,94vw);
  height: min(880px,92vh);
  max-height: 92vh;
}

.command-index-dialog form {
  height: 100%;
  max-height: none;
  display: grid;
  grid-template-rows: auto auto minmax(0,1fr) auto;
  padding: 26px;
  overflow: hidden;
}

.command-index-toolbar {
  display: grid;
  grid-template-columns: minmax(260px,1fr) auto;
  gap: 12px;
  margin-top: 18px;
}

.command-index-toolbar input {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid #3a3a3a;
  background: #030303;
  color: #fff;
  letter-spacing: .06em;
}

.command-index-filters { display: flex; gap: 4px; }
.command-index-filters button { min-height: 42px; padding-inline: 12px; }
.command-index-filters button.active { color: #000; background: #fff; border-color: #fff; }

.command-index-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(4,minmax(0,1fr));
  gap: 8px;
  margin-top: 14px;
  padding-right: 5px;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: #3a3a3a #000;
}

.index-card {
  min-height: 168px;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 7px;
  padding: 13px;
  border: 1px solid #282828;
  background: linear-gradient(145deg,#090909,#020202);
}

.index-card header { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; }
.index-card .index-icon { color: #ddd; font-size: 20px; }
.index-card h3 { margin: 0; color: #e5e5e5; font-size: 10px; letter-spacing: .09em; }
.index-card .index-category { color: #555; font-size: 7px; }
.index-card p { margin: 0; color: #777; font-size: 9px; line-height: 1.45; }
.index-meta { display: grid; gap: 4px; color: #686868; font-size: 8px; }
.index-meta strong { color: #aaa; font-weight: 600; }
.index-status { padding-top: 7px; border-top: 1px solid #202020; color: #858585; font-size: 8px; }
.index-card.available { border-color: #494949; }
.index-card.locked { border-style: dashed; }
.index-card.completed { box-shadow: inset 0 0 0 1px #5e5e5e; }
.index-card button { min-height: 30px; margin-top: 5px; padding: 4px 7px; font-size: 7px; }

.command-index-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 14px; color: #666; font-size: 9px; letter-spacing: .1em; }

/* Responsive behavior uses actual viewport, never silently clips commands. */
@media (max-width: 1420px) {
  :root { --deck-map-width: 292px; --deck-command-width: 390px; --deck-height: 232px; }
  .selection-panel { grid-template-columns: 160px minmax(270px,1fr) minmax(165px,.68fr); }
  .resource-item,.resource-time { min-width: 102px; }
  .command-index-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
}

@media (max-width: 1180px), (max-height: 760px) {
  :root { --deck-height: 210px; --deck-map-width: 245px; --deck-command-width: 350px; }
  .bottom-hud { left: 7px; right: 7px; bottom: calc(7px + var(--safe-bottom)); }
  .selection-panel { grid-template-columns: 145px minmax(250px,1fr); }
  .selection-cards { display: none; }
  .resource-item,.resource-time { min-width: 90px; padding: 8px 9px; }
  .objective-panel { max-width: 350px; }
  .logistics-strip { top: 94px; }
  .toast-stack { top: 148px; width: min(330px,31vw); }
  .settings-section-grid { grid-template-columns: 1fr; }
  .settings-section .setting-row { min-height: 72px; }
  .command-index-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

@media (max-width: 980px) {
  :root { --deck-map-width: 220px; --deck-command-width: 320px; }
  .top-hud { grid-template-columns: 280px 1fr; }
  .resource-item:nth-child(4) { display: none; }
  .command-context-hint { display: none; }
  .settings-shell { grid-template-columns: 150px minmax(0,1fr); }
}

@media (max-width: 760px), (pointer: coarse) {
  body { min-width: 760px; }
  .settings-dialog-v040 { width: 96vw; height: 94vh; }
  .settings-dialog-v040 form { padding: 16px; }
  .settings-shell { grid-template-columns: 1fr; }
  .settings-nav { grid-template-columns: repeat(3,1fr); border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .settings-nav button { grid-template-columns: 1fr; justify-items: center; padding: 5px; }
  .settings-nav button span { display: none; }
  .settings-section { padding: 15px; }
  .settings-section .setting-row { grid-template-columns: minmax(0,1fr) minmax(120px,40%); }
  .settings-footer { grid-template-columns: 1fr; }
  .settings-actions { justify-content: start; }
  .command-index-toolbar { grid-template-columns: 1fr; }
  .command-index-filters { overflow-x: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .command-page-flash { animation: none; }
}

/* v0.4.0 implementation alignment and behavior refinements. */
.command-context-copy > strong {
  overflow: hidden;
  color: #d7d7d7;
  font: 700 8px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .13em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.command-page-tools { display: flex; align-items: center; gap: 4px; }
.command-page-tools button {
  min-width: 30px;
  min-height: 28px;
  padding: 0 7px;
  border-color: #2d2d2d;
  background: #070707;
  color: #929292;
  font-size: 8px;
}
#globalQueueButton, #commandIndexButton { min-width: 50px; }

.command-button { position: relative; cursor: pointer; }
.command-button[aria-disabled="true"] { opacity: .78; background: #020202; }
.command-button[aria-disabled="true"] .command-icon { color: #4d4d4d; }
.command-button[aria-disabled="true"] .command-copy strong { color: #626262; }
.command-button[aria-disabled="true"]:hover { border-color: #555; }
.command-copy { display: grid; gap: 2px; min-width: 0; justify-items: center; }
.command-copy strong {
  max-width: 100%;
  overflow: hidden;
  color: #b9b9b9;
  font-size: 8px;
  line-height: 1.1;
  letter-spacing: .055em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.command-role {
  max-width: 100%;
  overflow: hidden;
  color: #5d5d5d;
  font-size: 6.5px;
  line-height: 1.12;
  letter-spacing: .025em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.command-button:hover .command-copy strong,
.command-button:focus-visible .command-copy strong { color: #fff; }
.command-button:hover .command-role,
.command-button:focus-visible .command-role { color: #929292; }

.command-tooltip {
  position: fixed;
  z-index: 110;
  width: min(282px, calc(100vw - 20px));
  display: grid;
  gap: 5px;
  padding: 9px 11px;
  border: 1px solid #484848;
  background: rgba(0,0,0,.97);
  box-shadow: 0 14px 50px #000;
  pointer-events: none;
}
.command-tooltip[hidden] { display: none; }
.command-tooltip strong { color: #fff; font-size: 9px; letter-spacing: .1em; }
.command-tooltip span { color: #8b8b8b; font-size: 8px; }
.command-tooltip small { color: #656565; font-size: 8px; line-height: 1.35; }

.tactical-overview {
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  gap: 6px;
  margin-top: 12px;
}
.tactical-overview[hidden] { display: none; }
.overview-card {
  min-height: 60px;
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid #252525;
  background: linear-gradient(145deg,#080808,#020202);
  text-align: left;
}
.overview-card small { color: #5f5f5f; font-size: 7px; letter-spacing: .1em; }
.overview-card strong { color: #e0e0e0; font-size: 12px; }
.overview-card span { color: #747474; font-size: 7px; }
.overview-card:hover { border-color: #757575; }

.event-rail {
  position: absolute;
  z-index: 34;
  top: 150px;
  right: 10px;
  width: min(390px,31vw);
  max-height: calc(100vh - var(--deck-height) - 185px);
  padding: 0;
  border-color: var(--line-faint);
  background: rgba(0,0,0,.84);
  pointer-events: none;
}
.event-rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 25px;
  padding: 4px 7px;
  border-bottom: 1px solid #202020;
  color: #565656;
  font-size: 7px;
  letter-spacing: .12em;
  pointer-events: auto;
}
.event-rail-head button { min-height: 20px; padding: 2px 6px; font-size: 6px; }
.event-rail .toast-stack {
  position: static;
  width: auto;
  max-height: calc(100vh - var(--deck-height) - 216px);
  overflow: auto;
  padding: 4px;
}

.resource-speed strong { font-size: .96rem; }
#supplyFlowDetail { display: block; margin-top: 2px; color: #585858; font-size: 6.5px; font-style: normal; white-space: nowrap; }
.objective-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.objective-head button { width: 27px; min-height: 25px; padding: 0; border-color: #272727; font-size: 12px; }

/* Systems dialog uses a real category layout at every viewport. */
.systems-layout { min-height: 0; }
.settings-panel { min-height: 100%; padding: 22px; }
.settings-panel[hidden] { display: none; }
.settings-panel > header { padding-bottom: 15px; border-bottom: 1px solid var(--line-soft); }
.settings-panel > header strong { color: #fff; font-size: 12px; letter-spacing: .16em; }
.settings-panel > header small { display: block; margin-top: 5px; color: #676767; font-size: 10px; }
.settings-fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1px; margin-top: 16px; background: var(--line-faint); border: 1px solid var(--line-faint); }
.settings-panel .setting-row { min-height: 76px; grid-template-columns: minmax(0,1fr) minmax(138px,42%); gap: 14px; padding: 12px 14px; border: 0; background: #030303; }
.settings-panel .setting-row > span { min-width: 0; }
.settings-panel .setting-row select { width: 100%; min-width: 0; }
.settings-panel .setting-row input[type="checkbox"],
.settings-panel .setting-row input[type="color"] { justify-self: end; }
.settings-panel .setting-row-range { grid-template-columns: 1fr; align-content: center; }
.settings-panel .setting-row-range > span { display: grid; grid-template-columns: 1fr auto; }
.settings-panel .setting-row-range input[type="range"] { width: 100%; }
.setting-help { color: #666; font-size: 9px; line-height: 1.5; }
.input-reference { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 16px; }
.input-reference span { padding: 7px 9px; border: 1px solid #282828; color: #747474; font-size: 8px; }
kbd { color: #ddd; background: #080808; border: 1px solid #393939; padding: 2px 4px; }

.signal-preview-unit {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid currentColor;
  color: #aaa;
  font-size: 9px;
  letter-spacing: .12em;
}
.signal-preview-unit span { width: 24px; height: 9px; background: currentColor; opacity: var(--preview-strength,.7); }
.signal-preview-unit.friendly { color: var(--preview-friendly,var(--friendly-signal)); }
.signal-preview-unit.hostile { color: var(--preview-hostile,var(--enemy-signal)); }

/* Strategic map dialog. */
.strategic-map-dialog {
  width: min(1440px,95vw);
  height: min(900px,94vh);
  max-height: 94vh;
}
.strategic-map-dialog form {
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0,1fr) auto;
  padding: 24px;
  overflow: hidden;
}
.strategic-map-layout { min-height: 0; display: grid; grid-template-columns: minmax(0,1fr) 230px; gap: 12px; margin-top: 14px; }
.strategic-canvas-wrap { min-height: 0; position: relative; border: 1px solid #303030; background: #000; }
.strategic-canvas-wrap #strategicMapCanvas { width: 100%; height: 100%; }
.strategic-sidebar { display: grid; align-content: start; gap: 10px; overflow: auto; }
.strategic-sidebar section { padding: 12px; border: 1px solid #292929; background: #030303; }
.strategic-sidebar section > strong { color: #aaa; font-size: 8px; letter-spacing: .12em; }
.strategic-legend { display: grid; gap: 5px; margin: 10px 0 0; }
.strategic-legend div { display: grid; grid-template-columns: 20px 1fr; color: #6e6e6e; font-size: 8px; }
.bookmark-list { display: grid; gap: 4px; margin-top: 9px; }
.bookmark-list button, .strategic-sidebar button { width: 100%; min-height: 30px; margin-top: 4px; font-size: 7px; }

.index-faction { color: #555; font-size: 7px; }
.index-card { grid-template-rows: auto auto 1fr auto auto; }

/* Optional physical ownership markings remain subordinate to the grayscale field. */
html.display-markings .command-button.command-ready { border-color: color-mix(in srgb, var(--friendly-signal) 50%, #333); }
html.display-markings .selection-title { text-shadow: 0 0 18px color-mix(in srgb, var(--friendly-signal) 28%, transparent); }

html.minimap-compact { --deck-map-width: 280px; }
html.minimap-large { --deck-map-width: 410px; }
html.command-density-compact { --command-row: 68px; }
html.command-density-expanded { --deck-command-width: 520px; }
html { font-size: calc(16px * var(--text-scale,1)); }

.camera-grabbing,
.right-camera-grabbing { cursor: grabbing !important; }

@media (max-width: 1180px), (max-height: 760px) {
  .settings-fields { grid-template-columns: 1fr; }
  .settings-panel { padding: 15px; }
  .settings-panel .setting-row { min-height: 64px; }
  .tactical-overview { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .event-rail { width: min(330px,32vw); }
}

/* Tactical overview occupies the center command surface rather than a cramped card rail. */
.selection-panel.tactical-overview { grid-template-columns: clamp(154px,15vw,205px) minmax(0,1fr); }
.selection-panel.tactical-overview .selection-cards { display: none; }
.selection-panel.tactical-overview .selection-stats { grid-template-columns: repeat(2,minmax(145px,1fr)); }
.selection-panel.tactical-overview .tactical-overview { grid-template-columns: repeat(4,minmax(105px,1fr)); }
.selection-panel.tactical-overview .overview-card { min-height: 52px; }
.selection-cards[hidden] { display: none; }

@media (max-width: 1320px) {
  .selection-panel.tactical-overview .tactical-overview { grid-template-columns: repeat(2,minmax(110px,1fr)); }
  .selection-panel.tactical-overview .selection-stats { grid-template-columns: repeat(2,minmax(130px,1fr)); }
}
