:root {
  --panel-solid: rgba(7, 18, 24, 0.94);
  --panel-raised: rgba(10, 24, 31, 0.97);
  --focus-ring: #f4bb72;
}

/* Mars47 v61: binder directive, compact chapter status and unified HUD stack. */
.program-logo {
  overflow: hidden;
  padding: 0;
  border: 1px solid rgba(225, 174, 96, .45);
  background: #f7f3e9;
}

.program-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.16);
}

.mission-cover {
  padding: 20px 20px 18px 38px;
  color: #14252b;
  background:
    linear-gradient(92deg, rgba(0,0,0,.07), transparent 9%),
    repeating-linear-gradient(0deg, rgba(65,54,41,.025) 0 1px, transparent 1px 5px),
    #f5f1e7;
  box-shadow: inset 10px 0 24px rgba(47, 38, 28, .08);
}

.mission-cover::before {
  inset: 10px 10px 10px 29px;
  border-color: rgba(68, 55, 38, .17);
}

.mission-cover::after {
  right: -48px;
  bottom: -64px;
  border-color: rgba(26, 76, 85, .08);
  box-shadow: 0 0 0 18px rgba(26,76,85,.025), 0 0 0 40px rgba(26,76,85,.018);
}

.mission-binder-spine {
  position: absolute;
  z-index: 3;
  inset: 0 auto 0 0;
  width: 26px;
  border-right: 1px solid rgba(55, 46, 34, .18);
  background: linear-gradient(90deg, #c9c2b5, #ebe6dc 58%, #bab2a4);
  box-shadow: 4px 0 10px rgba(36, 30, 24, .11);
}

.mission-binder-spine i {
  position: absolute;
  left: 7px;
  width: 11px;
  height: 11px;
  border: 2px solid #887f72;
  border-radius: 50%;
  background: #faf7ef;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.2);
}
.mission-binder-spine i:nth-child(1) { top: 52px; }
.mission-binder-spine i:nth-child(2) { top: 140px; }
.mission-binder-spine i:nth-child(3) { top: 228px; }
.mission-binder-spine i:nth-child(4) { top: 316px; }

.mission-cover-kicker { color: #5b696b; }
.mission-cover-copy small,
.mission-cover-copy span { color: #9b642c; }
.mission-cover-copy strong { color: #182b31; }
.mission-open {
  border-color: rgba(141, 92, 45, .32);
  background: rgba(147, 97, 46, .08);
  color: #74461f;
}
.mission-open:hover { background: rgba(147,97,46,.14); border-color: rgba(141,92,45,.54); }

.mission-patch {
  width: 156px;
  height: 156px;
  margin-top: 12px;
  overflow: hidden;
  border: 1px solid rgba(118, 86, 48, .16);
  border-radius: 24px;
  background: #f7f3ea;
  filter: drop-shadow(0 12px 20px rgba(48,39,28,.18));
}
.mission-patch img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.04); }

.mission-page-art {
  width: 100%;
  height: 52px;
  margin: 0 0 10px;
  border: 1px solid rgba(213, 169, 101, .18);
  border-radius: 9px;
  background-position: center;
  background-size: cover;
  opacity: .68;
  box-shadow: inset 0 0 30px rgba(4, 13, 18, .68);
}
.mission-page-art-coast { background-image: linear-gradient(90deg, rgba(5,17,23,.25), rgba(5,17,23,.72)), url('./branding/mars47-mark-coast-v61.png'); }
.mission-page-art-forge { background-image: linear-gradient(90deg, rgba(5,17,23,.25), rgba(5,17,23,.72)), url('./branding/mars47-mark-shield-v61.png'); }
.mission-page-art-haven { background-image: linear-gradient(90deg, rgba(5,17,23,.18), rgba(5,17,23,.78)), url('./research-energy-v3.jpg'); }

.mission-collapsed-summary { display: none; }
.mission.collapsed {
  width: 284px;
  min-height: 0;
  padding: 13px 42px 13px 14px;
}
.mission.collapsed .mission-book { display: block !important; padding: 0; }
.mission.collapsed .mission-collapsed-summary {
  display: grid;
  gap: 5px;
}
.mission.collapsed .mission-collapsed-summary small {
  color: #e2a65e;
  font: 700 8px/1.15 Barlow Condensed, sans-serif;
  letter-spacing: 1.25px;
}
.mission.collapsed .mission-collapsed-summary strong {
  overflow: hidden;
  color: #e8f2ef;
  font: 700 14px/1.1 Barlow Condensed, sans-serif;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mission.collapsed .mission-collapsed-summary > div {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 9px;
}
.mission.collapsed .mission-collapsed-summary > div > span {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255,255,255,.1);
}
.mission.collapsed .mission-collapsed-summary i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #e9a85e, #69ddd5);
  box-shadow: 0 0 9px rgba(94,216,211,.26);
  transition: width .25s ease;
}
.mission.collapsed .mission-collapsed-summary b {
  color: #84ded8;
  font: 700 9px/1 Barlow Condensed, sans-serif;
}
.mission.collapsed .mission-chapter-tabs,
.mission.collapsed .mission-book > section { display: none !important; }

/* Inspector stays readable even when upgrade actions and construction state coexist. */
.inspector {
  width: min(360px, calc(100vw - 36px));
  max-height: calc(100vh - 205px);
  overflow: auto;
  padding: 17px;
}
.inspector h2 {
  margin: 7px 58px 8px 0;
  font-size: clamp(20px, 2.1vw, 27px);
  line-height: 1.05;
  overflow-wrap: anywhere;
}
.inspector p {
  font-size: 12px;
  line-height: 1.52;
}
.inspector > #closeInspector { position: absolute; top: 8px; right: 10px; }
.inspector .inspector-actions button,
.inspector .lab-upgrade {
  position: static;
  inset: auto;
  font-size: 9px;
}

/* Finance is now formatted and positioned like the operational side panels. */
.cash-breakdown {
  top: 104px;
  left: 18px;
  width: min(390px, calc(100vw - 36px));
  max-height: calc(100vh - 205px);
  padding: 16px;
  overflow: auto;
  transform: none;
}
.cash-breakdown-head strong { font-size: 19px; }
.cash-balance-current b { font-size: 18px; }
.cash-ledger-row { min-height: 52px; }
.cash-ledger-row b { font-size: 13px; }
.cash-ledger-row small { font-size: 10px; }
.cash-ledger-row > strong { font-size: 15px; }
.cash-ledger-total b { font-size: 20px; }

/* One notification rail shared by research, build, finance and completion events. */
.message-preview {
  z-index: 78;
  top: 104px;
  width: min(390px, calc(100vw - 36px));
  min-height: 58px;
  padding: 11px 14px 11px 48px;
}
html[data-active-panel-side="left"] .message-preview { left: 18px; right: auto; }
html[data-active-panel-side="right"] .message-preview { left: auto; right: 18px; }
html[data-notice-visible="true"] .side-panel:not(.hidden),
html[data-notice-visible="true"] .message-panel:not(.hidden),
html[data-notice-visible="true"] .progress-queue-panel:not(.hidden),
html[data-notice-visible="true"] .cash-breakdown:not(.hidden) { top: 174px; }
.research-success { display: none !important; }

@media (max-width: 720px) {
  .cash-breakdown,
  .message-preview,
  html[data-active-panel-side="left"] .message-preview,
  html[data-active-panel-side="right"] .message-preview {
    left: 8px;
    right: 8px;
    width: auto;
  }
  .cash-breakdown,
  .message-preview { top: calc(max(8px, env(safe-area-inset-top)) + 134px); }
  html[data-notice-visible="true"] .side-panel:not(.hidden),
  html[data-notice-visible="true"] .message-panel:not(.hidden),
  html[data-notice-visible="true"] .progress-queue-panel:not(.hidden),
  html[data-notice-visible="true"] .cash-breakdown:not(.hidden) {
    top: calc(max(8px, env(safe-area-inset-top)) + 204px);
  }
  .mission.collapsed { width: 252px; }
}

/* WebGL canvases and backdrop-filter can produce black compositor tiles on
   some browsers/GPUs. A denser translucent surface keeps the visual language
   while rendering predictably across desktop and mobile. */
.glass {
  background: linear-gradient(145deg, var(--panel-raised), var(--panel-solid));
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.modal {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

button:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.resource-card {
  --resource-color: #c6d5d6;
  display: grid;
  grid-template-columns: 25px minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 8px;
  align-items: center;
}

.resource-button {
  appearance: none;
  margin: 0;
  padding: 5px 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.resource-button:hover,
.resource-button[aria-expanded="true"] {
  border-color: color-mix(in srgb, var(--resource-color) 38%, transparent);
  background: color-mix(in srgb, var(--resource-color) 10%, transparent);
  box-shadow: inset 0 0 18px color-mix(in srgb, var(--resource-color) 7%, transparent);
}

.cash-breakdown {
  position: fixed;
  z-index: 72;
  top: 88px;
  left: 50%;
  width: min(310px, calc(100vw - 36px));
  padding: 17px;
  border: 1px solid rgba(240, 180, 95, 0.28);
  border-radius: 18px;
  transform: translateX(-52%);
  color: #e8f1ee;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.34), inset 0 1px rgba(255, 255, 255, 0.035);
}

.cash-breakdown-head,
.cash-balance-current,
.cash-ledger-row,
.cash-ledger-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.cash-breakdown-head {
  margin-bottom: 13px;
}

.cash-breakdown-head > div {
  display: grid;
  gap: 2px;
}

.cash-breakdown-head small,
.cash-balance-current span,
.cash-ledger-total span {
  color: #d3a563;
  font: 700 10px/1.2 var(--font-condensed, sans-serif);
  letter-spacing: 0.15em;
}

.cash-breakdown-head strong {
  font-size: 19px;
}

.cash-breakdown-head button {
  width: 30px;
  height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.025);
  color: #aebfbd;
  font-size: 21px;
  cursor: pointer;
}

.cash-balance-current {
  margin: 0 -4px 10px;
  padding: 12px 13px;
  border: 1px solid rgba(240, 180, 95, 0.13);
  border-radius: 12px;
  background: rgba(240, 180, 95, 0.055);
}

.cash-balance-current b {
  color: #f5c982;
  font-size: 18px;
}

.cash-ledger-row {
  min-height: 54px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.065);
}

.cash-ledger-row > span {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cash-ledger-row > span > span {
  display: grid;
  gap: 2px;
}

.cash-ledger-row small {
  color: #829593;
  font-size: 11px;
}

.cash-ledger-row > strong,
.cash-ledger-total b {
  color: #7ee0c9;
  white-space: nowrap;
}

.cash-ledger-icon {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border: 1px solid currentColor;
  border-radius: 8px;
  font: 800 14px/1 sans-serif;
}

.energy-ledger-icon { color: #72dfd7; }
.patent-ledger-icon { color: #d8a9ff; }

.cash-ledger-total {
  padding: 15px 2px 8px;
}

.cash-ledger-total b {
  font-size: 21px;
}

.cash-breakdown > p {
  margin: 8px 0 0;
  color: #718582;
  font-size: 11px;
  line-height: 1.45;
}

@media (max-width: 980px) {
  .cash-breakdown {
    top: 78px;
    left: 18px;
    width: min(270px, calc(100vw - 36px));
    transform: none;
  }

  .mission.mission-covered { width: 270px; }
}

@media (max-width: 720px) {
  .cash-breakdown {
    top: 72px;
    left: 8px;
    width: min(240px, calc(100vw - 16px));
  }

  .mission.mission-covered { width: 240px; }
  .mission-cover { min-height: 370px; padding: 18px; }
  .mission-patch { width: 138px; height: 138px; margin-top: 12px; }
  .mission-cover-copy strong { font-size: 21px; }
  .mission-book { padding: 13px 40px 13px 13px; }
}

.resource-icon {
  grid-row: 1 / 3;
  width: 23px;
  height: 23px;
  padding: 3px;
  overflow: visible;
  color: var(--resource-color);
  fill: color-mix(in srgb, var(--resource-color) 17%, transparent);
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--resource-color) 32%, transparent));
}

.resource-card > span,
.resource-card > b {
  grid-column: 2;
}

.resource-cash { --resource-color: #f0b45f; }
.resource-energy { --resource-color: #72dfd7; }
.resource-ai { --resource-color: #a7a2ff; }
.resource-staff { --resource-color: #d7e4df; }

/* Keep every strategic resource visible on laptop-width screens. The campaign
   date yields first, while the cards become denser without losing their icon. */
@media (min-width: 981px) and (max-width: 1250px) {
  .campaign-clock {
    display: none;
  }

  .resources {
    justify-content: stretch;
    min-width: 0;
  }

  .resources .resource-card:nth-child(n) {
    display: grid;
    min-width: 0;
    flex: 1 1 0;
    padding: 0 8px;
    grid-template-columns: 22px minmax(0, 1fr);
    column-gap: 5px;
  }

  .resource-icon {
    width: 20px;
    height: 20px;
  }

  .resources b {
    font-size: 13px;
  }
}

.topbar,
.mission,
.side-panel,
.message-panel,
.progress-queue-panel,
.buildbar,
.camera-controls,
.placement-hint,
.minimap {
  isolation: isolate;
}

.minimap,
#minimap {
  display: none !important;
}

@media (min-width: 981px) {
  .camera-controls {
    bottom: 24px;
  }
}

.mission {
  right: 18px;
  left: auto;
  padding-right: 42px;
  transform-origin: top right;
  min-height: 396px;
  overflow: hidden;
  transition: width 180ms ease, min-height 220ms ease, padding 180ms ease, opacity 180ms ease;
}

.mission.mission-covered {
  width: 310px;
  min-height: 396px;
  padding: 0;
  border-color: rgba(240, 160, 75, .28);
}

.mission.mission-covered .mission-toggle {
  opacity: 0;
  pointer-events: none;
}

.mission.directive-open {
  min-height: 0;
}

.mission.directive-open .mission-toggle {
  opacity: 1;
  pointer-events: auto;
}

.mission-cover {
  position: relative;
  display: flex;
  min-height: 394px;
  flex-direction: column;
  align-items: center;
  padding: 22px 22px 19px;
  overflow: hidden;
  cursor: pointer;
  background:
    linear-gradient(145deg, rgba(15, 38, 46, .98), rgba(7, 18, 24, .99)),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, .018) 0 1px, transparent 1px 4px);
  transform-origin: left center;
  transition: opacity 260ms ease, transform 320ms cubic-bezier(.22,.8,.25,1);
}

.mission-cover::before,
.mission-cover::after {
  position: absolute;
  content: "";
  pointer-events: none;
}

.mission-cover::before {
  inset: 10px;
  border: 1px solid rgba(232, 185, 116, .2);
  border-radius: 11px;
}

.mission-cover::after {
  right: -35px;
  bottom: -54px;
  width: 180px;
  height: 180px;
  border: 1px solid rgba(94, 216, 211, .09);
  border-radius: 50%;
  box-shadow: 0 0 0 18px rgba(94,216,211,.018), 0 0 0 40px rgba(94,216,211,.012);
}

.mission-cover.opening {
  opacity: 0;
  transform: perspective(700px) rotateY(-16deg) translateX(-12px);
}

.mission-cover-kicker {
  position: relative;
  z-index: 1;
  width: 100%;
  color: #91aaa9;
  font: 700 9px/1.2 Barlow Condensed, sans-serif;
  letter-spacing: .2em;
  text-align: center;
}

.mission-patch {
  position: relative;
  z-index: 1;
  width: 154px;
  height: 154px;
  margin: 15px 0 8px;
  filter: drop-shadow(0 12px 23px rgba(0,0,0,.36));
}

.mission-patch svg { width: 100%; height: 100%; overflow: visible; }
.patch-field { fill: #0a1b23; stroke: #dda15b; stroke-width: 3; }
.patch-orbit { fill: none; stroke: url(#directiveOrbit); stroke-width: 3; stroke-linecap: round; }
.patch-orbit-secondary { stroke-width: 1.4; opacity: .65; }
.patch-ridge { fill: none; stroke: rgba(92,39,30,.62); stroke-width: 2; stroke-linecap: round; }
.patch-earth { fill: #378ba7; stroke: #b7ecdc; stroke-width: 1.5; }
.patch-earth-land { fill: #8caf6d; }
.patch-star { fill: #f1bc70; }

.mission-cover-copy {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 6px;
  width: 100%;
  text-align: center;
}

.mission-cover-copy small,
.mission-cover-copy span {
  color: #b58c56;
  font: 700 8px/1.3 Barlow Condensed, sans-serif;
  letter-spacing: .19em;
}

.mission-cover-copy strong {
  color: #edf5f1;
  font: 700 24px/.92 Barlow Condensed, sans-serif;
  letter-spacing: .055em;
}

.mission-open {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 172px;
  min-height: 37px;
  margin-top: auto;
  padding: 0 13px;
  border: 1px solid rgba(240, 180, 95, .32);
  border-radius: 9px;
  background: rgba(240, 160, 75, .09);
  color: #f0c283;
  cursor: pointer;
  font: 700 9px/1 Barlow Condensed, sans-serif;
  letter-spacing: .14em;
}

.mission-open:hover { background: rgba(240,160,75,.16); border-color: rgba(240,180,95,.58); }
.mission-open span { color: #5ed8d3; font-size: 16px; }

.mission-book {
  padding: 18px;
  padding-right: 42px;
  animation: missionBookIn 280ms ease both;
}

@keyframes missionBookIn {
  from { opacity: 0; transform: translateX(10px); }
  to { opacity: 1; transform: none; }
}

.mission-book > section > p {
  color: #a6b7b9;
  font-size: 11px;
  line-height: 1.5;
  margin: 0 0 13px;
}

.mission-chapter-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  margin: 0 0 15px;
}

.mission-chapter-tabs button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 30px;
  border: 1px solid rgba(183,222,221,.11);
  border-radius: 7px;
  background: rgba(255,255,255,.025);
  color: #728989;
  cursor: pointer;
  font: 700 8px/1 Barlow Condensed, sans-serif;
  letter-spacing: .1em;
  padding: 0 7px;
}

.mission-chapter-tabs button span { color: #d59651; font-size: 11px; }
.mission-chapter-tabs button b {
  margin-left: auto;
  color: #789090;
  font: 700 8px/1 Barlow Condensed, sans-serif;
  letter-spacing: 0;
}
.mission-chapter-tabs button.active { border-color: rgba(94,216,211,.3); background: rgba(94,216,211,.08); color: #d8eeee; }
.mission-chapter-tabs button.active b { color: #7de2db; }
.mission-chapter-tabs button.locked,
.mission-chapter-tabs button:disabled {
  border-color: rgba(255,255,255,.055);
  background: rgba(255,255,255,.012);
  color: #4c5d5d;
  cursor: not-allowed;
  opacity: .62;
}

.mission-chapter-progress {
  display: grid;
  gap: 6px;
  margin: 0 0 11px;
  padding: 8px 9px;
  border: 1px solid rgba(94,216,211,.11);
  border-radius: 8px;
  background: rgba(94,216,211,.035);
}

.mission-chapter-progress > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.mission-chapter-progress > div span,
.mission-chapter-progress > div b {
  font: 700 8px/1 Barlow Condensed, sans-serif;
  letter-spacing: .11em;
}

.mission-chapter-progress > div span { color: #809897; }
.mission-chapter-progress > div b { color: #8fe2dc; letter-spacing: .04em; }
.mission-chapter-progress > span {
  display: block;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255,255,255,.07);
}

.mission-chapter-progress > span i {
  display: block;
  width: var(--chapter-progress, 0%);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #d88942, #5ed8d3);
  box-shadow: 0 0 10px rgba(94,216,211,.32);
  transition: width 300ms ease;
}
.mission-book section.hidden { display: none; }

.mission.collapsed {
  min-height: 48px;
}

.mission-toggle {
  position: absolute;
  top: 9px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border: 1px solid rgba(94, 216, 211, 0.22);
  border-radius: 7px;
  background: rgba(94, 216, 211, 0.08);
  color: #bce9e5;
  cursor: pointer;
  font: 700 15px/1 Barlow Condensed, sans-serif;
}

.mission-toggle:hover {
  border-color: rgba(94, 216, 211, 0.48);
  background: rgba(94, 216, 211, 0.15);
  color: #fff;
}

.mission.collapsed {
  width: 225px;
  min-height: 48px;
  padding: 15px 42px 14px 16px;
}

.mission.collapsed h1,
.mission.collapsed > p,
.mission.collapsed .mission-progress,
.mission.collapsed .mission-chapter-progress,
.mission.collapsed .mission-chapter-tabs,
.mission.collapsed .mission-book > section {
  display: none;
}

.mission.collapsed .mission-book { padding-top: 15px; padding-bottom: 14px; }

.inspector {
  right: auto;
  left: 18px;
}

.build-category h3 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.category-icon {
  display: inline-grid;
  place-items: center;
  width: 21px;
  height: 21px;
  border: 1px solid color-mix(in srgb, currentColor 32%, transparent);
  border-radius: 6px;
  background: color-mix(in srgb, currentColor 10%, transparent);
  font: 700 14px/1 Barlow Condensed, sans-serif;
  letter-spacing: 0;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.06);
}

.infrastructure-category { color: #d7ae7d; }
.energy-category { color: #72dfd7; }
.research-category { color: #a7a2ff; }
.manufacturing-category { color: #aebfc0; }
.community-category { color: #dc9474; }

.side-panel .build-item .unlock-requirement {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px;
  align-items: center;
  margin-top: 7px;
  color: #c6d1cf;
  font-size: 8.5px;
  line-height: 1.25;
}

.side-panel .build-item .unlock-requirement strong {
  padding: 2px 5px;
  border: 1px solid rgba(240, 160, 75, 0.38);
  border-radius: 4px;
  color: #f0b06c;
  font: 700 7px/1.15 Barlow Condensed, sans-serif;
  letter-spacing: 0.7px;
}

.side-panel .build-item:not(.locked) .unlock-requirement {
  display: none;
}

.side-panel .build-item.locked {
  opacity: 0.72;
}

.side-panel .build-item.locked > .build-icon,
.side-panel .build-item.locked > i,
.side-panel .build-item.locked > kbd {
  opacity: 0.55;
}

.side-panel .building-thumb {
  flex: 0 0 58px;
  width: 58px;
  height: 50px;
  border-color: rgba(140, 183, 190, 0.22);
  border-radius: 8px;
  background-color: #101923;
  background-image: url('./building-atlas-v3.jpg');
  background-repeat: no-repeat;
  background-size: 300% 300%;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.08), 0 5px 14px rgba(0, 0, 0, 0.25);
}

.thumb-road { background-position: 0 0; }
.thumb-solar { background-position: 50% 0; }
.thumb-wind { background-position: 100% 0; }
.thumb-battery { background-position: 0 50%; }
.thumb-fuel { background-position: 50% 50%; }
.thumb-lab { background-position: 100% 50%; }
.thumb-component { background-position: 0 100%; }
.thumb-engine { background-position: 50% 100%; }
.thumb-residential { background-position: 100% 100%; }

.side-panel .build-item:has(.building-thumb) {
  min-height: 68px;
}

.research-node .research-progress {
  position: relative;
  height: 5px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.research-node .research-progress i {
  display: block;
  width: var(--research-progress, 0%);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #54c8c4, #8cf2e9);
  box-shadow: 0 0 9px rgba(94, 216, 211, 0.42);
  transition: width 400ms linear;
}

.research-node .research-timer {
  display: block;
  margin-top: 6px;
  color: #738b8f;
  font: 600 8px/1 Barlow Condensed, sans-serif;
  font-style: normal;
  letter-spacing: 0.8px;
}

.research-node.in-progress {
  border-color: rgba(94, 216, 211, 0.48);
  background: linear-gradient(145deg, rgba(94, 216, 211, 0.12), rgba(94, 216, 211, 0.035));
  cursor: progress;
  opacity: 1;
}

.research-node.in-progress .research-cost,
.research-node.in-progress .research-timer {
  color: #85e7e1;
}

.research-menu-hero {
  position: relative;
  min-height: 118px;
  margin: 2px 0 12px;
  overflow: hidden;
  border: 1px solid rgba(94, 216, 211, 0.22);
  border-radius: 12px;
  background: #071119;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.08), 0 12px 28px rgba(0, 0, 0, 0.26);
}

.research-menu-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(4, 13, 19, 0.92) 0%, rgba(4, 13, 19, 0.44) 54%, rgba(4, 13, 19, 0.06) 100%);
  pointer-events: none;
}

.research-menu-hero img {
  width: 100%;
  height: 132px;
  display: block;
  object-fit: cover;
  object-position: center 48%;
  opacity: 0.86;
}

.research-menu-hero > div {
  position: absolute;
  z-index: 1;
  left: 14px;
  right: 44%;
  bottom: 13px;
}

.research-menu-hero small,
.research-menu-hero strong {
  display: block;
}

.research-menu-hero small {
  color: #6fe0da;
  font: 700 8px/1 Barlow Condensed, sans-serif;
  letter-spacing: 1.3px;
}

.research-menu-hero strong {
  margin-top: 6px;
  color: #f2f9f8;
  font: 700 16px/1.1 Barlow Condensed, sans-serif;
  text-shadow: 0 2px 12px #000;
}

.research-panel .research-node-art {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 11px;
  min-height: 104px;
  padding: 8px 58px 8px 8px;
  overflow: hidden;
}

.research-art {
  width: 104px;
  height: 86px;
  align-self: center;
  object-fit: cover;
  object-position: center;
  border: 1px solid rgba(164, 213, 214, 0.18);
  border-radius: 8px;
  background: #091319;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.08), 0 7px 18px rgba(0, 0, 0, 0.32);
  transition: filter 160ms ease, transform 160ms ease;
}

.research-node-art:hover:not(:disabled) .research-art {
  transform: scale(1.025);
  filter: saturate(1.08) brightness(1.05);
}

.research-copy {
  min-width: 0;
  align-self: center;
}

.research-node-art .research-cost {
  top: 11px;
  right: 10px;
  padding: 4px 6px;
  border: 1px solid rgba(240, 160, 75, 0.25);
  border-radius: 5px;
  background: rgba(4, 12, 18, 0.74);
}

.research-node-art.completed .research-art,
.research-node-art.locked .research-art {
  filter: saturate(0.55) brightness(0.7);
}

.launch-menu-button > span {
  color: #d0a26a;
  font-size: 27px;
}

.launch-empty-state {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 30px 22px;
  border: 1px dashed rgba(167, 188, 190, 0.2);
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.015));
  text-align: center;
}

.launch-empty-state > span {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(240, 160, 75, 0.3);
  border-radius: 50%;
  background: rgba(240, 160, 75, 0.08);
  color: #d8aa72;
  font-size: 26px;
}

.launch-empty-state b {
  color: #dbe8e7;
  font: 700 15px/1.1 Barlow Condensed, sans-serif;
}

.launch-empty-state small {
  max-width: 270px;
  color: #82979a;
  font-size: 9px;
  line-height: 1.55;
}

.research-success {
  position: fixed;
  z-index: 45;
  top: 96px;
  left: 50%;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 26px;
  gap: 12px;
  align-items: center;
  width: min(420px, calc(100vw - 36px));
  padding: 12px 12px 12px 14px;
  border-color: rgba(94, 216, 211, 0.5);
  border-radius: 13px;
  transform: translateX(-50%);
  transition: opacity 180ms ease, transform 180ms ease;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.36), 0 0 32px rgba(94, 216, 211, 0.1);
}

.research-success.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -15px);
}

.research-success-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(94, 216, 211, 0.17);
  color: #8cf2e9;
  font-size: 20px;
  box-shadow: inset 0 0 0 1px rgba(94, 216, 211, 0.38);
}

.research-success small,
.research-success strong {
  display: block;
}

.research-success small {
  color: #72d8d2;
  font: 700 8px/1 Barlow Condensed, sans-serif;
  letter-spacing: 1.4px;
}

.research-success strong {
  margin-top: 5px;
  color: #edfafa;
  font: 700 15px/1.15 Barlow Condensed, sans-serif;
}

.research-success button {
  border: 0;
  background: transparent;
  color: #91a7a9;
  font-size: 22px;
  cursor: pointer;
}

.buildbar,
.side-panel,
.message-panel {
  scrollbar-color: rgba(94, 216, 211, 0.45) transparent;
  scrollbar-width: thin;
}

.progress-queue-button {
  position: relative;
}

.queue-glyph {
  display: grid;
  width: 20px;
  gap: 3px;
}

.queue-glyph i {
  position: relative;
  display: block;
  height: 2px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(184, 208, 207, .32);
}

.queue-glyph i::after {
  content: "";
  position: absolute;
  inset: 0;
  width: var(--queue-glyph-progress, 68%);
  border-radius: inherit;
  background: #71ddd7;
  box-shadow: 0 0 7px rgba(94, 216, 211, .46);
}

.queue-glyph i:nth-child(2)::after { --queue-glyph-progress: 43%; }
.queue-glyph i:nth-child(3)::after { --queue-glyph-progress: 82%; }

.progress-queue-button > b {
  position: absolute;
  top: -5px;
  right: -4px;
  display: grid;
  place-items: center;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: #5ed8d3;
  color: #102026;
  font: 700 9px/1 Inter, sans-serif;
  box-shadow: 0 0 0 2px #0b171d, 0 0 12px rgba(94, 216, 211, .34);
}

.progress-queue-button > b.hidden {
  display: none;
}

.mission-control-button > span {
  display: block;
  color: currentColor;
  font: 700 23px/1 Barlow Condensed, sans-serif;
  transform: translateY(-1px);
}

.mission-control-button.active > span {
  text-shadow: 0 0 12px rgba(94, 216, 211, .45);
}

.progress-queue-panel {
  position: fixed;
  z-index: 24;
  top: 104px;
  right: 18px;
  width: min(430px, calc(100vw - 36px));
  max-height: calc(100vh - 132px);
  padding: 17px;
  overflow: auto;
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(8, 20, 26, .97), rgba(5, 15, 21, .94));
  transition: opacity 180ms ease, transform 180ms ease;
  scrollbar-color: rgba(94, 216, 211, .45) transparent;
  scrollbar-width: thin;
}

.message-preview:not(.hidden) ~ .progress-queue-panel {
  top: 164px;
  max-height: calc(100vh - 192px);
}

.progress-queue-panel.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(24px);
}

.progress-queue-panel .panel-head {
  position: sticky;
  z-index: 2;
  top: -17px;
  margin: -17px -17px 12px;
  padding: 17px 17px 12px;
  background: linear-gradient(180deg, rgba(8, 20, 26, .98) 74%, rgba(8, 20, 26, 0));
}

.progress-queue-overview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.progress-queue-overview > div {
  padding: 10px 11px;
  border: 1px solid rgba(164, 211, 211, .1);
  border-radius: 9px;
  background: rgba(255, 255, 255, .035);
}

.progress-queue-overview span,
.progress-queue-overview b {
  display: block;
}

.progress-queue-overview span {
  color: #708a8e;
  font: 700 7px/1 Barlow Condensed, sans-serif;
  letter-spacing: 1.2px;
}

.progress-queue-overview b {
  margin-top: 5px;
  color: #d8e8e7;
  font: 700 12px/1 Barlow Condensed, sans-serif;
  letter-spacing: .5px;
}

.progress-queue-list {
  display: grid;
  gap: 10px;
}

.progress-queue-summary {
  margin: 0 0 13px;
  padding: 8px 10px;
  border-left: 2px solid rgba(94, 216, 211, .62);
  border-radius: 0 7px 7px 0;
  background: rgba(94, 216, 211, .055);
  color: #89a2a4;
  font-size: 8px;
  line-height: 1.45;
}

.progress-queue-section {
  display: grid;
  gap: 7px;
}

.progress-queue-section + .progress-queue-section {
  margin-top: 4px;
}

.progress-queue-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2px;
  color: #7f9698;
  font: 700 8px/1 Barlow Condensed, sans-serif;
  letter-spacing: 1.25px;
}

.progress-queue-section-head b {
  color: #b7c9c8;
  font: inherit;
}

.progress-queue-empty {
  display: grid;
  place-items: center;
  min-height: 180px;
  padding: 30px 24px;
  border: 1px dashed rgba(155, 199, 199, .15);
  border-radius: 11px;
  background: rgba(255, 255, 255, .022);
  text-align: center;
}

.progress-queue-empty > span {
  color: #5ed8d3;
  font-size: 31px;
  line-height: 1;
  text-shadow: 0 0 17px rgba(94, 216, 211, .33);
}

.progress-queue-empty b {
  margin-top: 11px;
  color: #c7d7d6;
  font: 700 15px/1 Barlow Condensed, sans-serif;
}

.progress-queue-empty small {
  max-width: 245px;
  margin-top: 7px;
  color: #758c8f;
  font-size: 9px;
  line-height: 1.5;
}

.progress-queue-item {
  --queue-color: #f0a04b;
  position: relative;
  min-height: 91px;
  padding: 12px 12px 11px 64px;
  overflow: hidden;
  border: 1px solid rgba(240, 160, 75, .18);
  border-radius: 11px;
  background: linear-gradient(145deg, rgba(240, 160, 75, .08), rgba(255, 255, 255, .025));
}

.progress-queue-item[data-queue-state="queued"] {
  --queue-color: #809295;
  border-color: rgba(151, 178, 180, .14);
  background: linear-gradient(145deg, rgba(151, 178, 180, .045), rgba(255, 255, 255, .018));
}

.progress-queue-item[data-wait-reason="road"] {
  --queue-color: #df876b;
  border-color: rgba(223, 135, 107, .25);
}

.progress-queue-thumb {
  position: absolute;
  top: 12px;
  left: 11px;
  width: 42px !important;
  height: 42px !important;
  border-color: color-mix(in srgb, var(--queue-color) 35%, transparent) !important;
  background-color: #101923;
  background-image: url('./building-atlas-v3.jpg');
  background-repeat: no-repeat;
  background-size: 300% 300%;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--queue-color) 18%, transparent), 0 5px 14px rgba(0, 0, 0, .25) !important;
}

.progress-queue-item[data-queue-kind="research"] {
  --queue-color: #8d9cff;
  border-color: rgba(141, 156, 255, .22);
  background: linear-gradient(145deg, rgba(113, 126, 225, .1), rgba(255, 255, 255, .025));
}

.progress-queue-item.is-paused {
  --queue-color: #ff8065;
  border-color: rgba(255, 112, 86, .34);
}

.progress-queue-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.progress-queue-icon {
  display: grid;
  place-items: center;
  width: 35px;
  height: 35px;
  border: 1px solid color-mix(in srgb, var(--queue-color) 35%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--queue-color) 11%, transparent);
  color: var(--queue-color);
  font: 700 18px/1 Barlow Condensed, sans-serif;
  box-shadow: inset 0 1px rgba(255, 255, 255, .05);
}

.progress-queue-copy {
  min-width: 0;
}

.progress-queue-copy small,
.progress-queue-copy b {
  display: block;
}

.progress-queue-copy small {
  color: color-mix(in srgb, var(--queue-color) 72%, #91a5a7);
  font: 700 7px/1 Barlow Condensed, sans-serif;
  letter-spacing: 1.2px;
}

.progress-queue-copy b {
  margin-top: 5px;
  overflow: hidden;
  color: #e1eceb;
  font: 700 13px/1.1 Barlow Condensed, sans-serif;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-queue-percent {
  color: var(--queue-color);
  font: 700 16px/1 Barlow Condensed, sans-serif;
}

.progress-queue-track {
  display: block;
  height: 5px;
  margin-top: 11px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, .075);
}

.progress-queue-track i {
  display: block;
  width: var(--queue-progress, 0%);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, color-mix(in srgb, var(--queue-color) 70%, #fff), var(--queue-color));
  box-shadow: 0 0 10px color-mix(in srgb, var(--queue-color) 40%, transparent);
  transition: width 350ms linear;
}

.progress-queue-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  color: #748b8f;
  font: 600 8px/1 Barlow Condensed, sans-serif;
  letter-spacing: .65px;
}

.progress-queue-meta time {
  flex: 0 0 auto;
  color: #b4c8c7;
  font-style: normal;
}

.progress-queue-reason {
  margin: 7px 0 0;
  color: color-mix(in srgb, var(--queue-color) 76%, #91a5a7);
  font: 600 8px/1.3 Barlow Condensed, sans-serif;
  letter-spacing: .45px;
}

.progress-queue-position {
  display: grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  border: 1px solid rgba(155, 180, 181, .18);
  border-radius: 7px;
  color: #94a8aa;
  background: rgba(255, 255, 255, .025);
  font: 700 11px/1 Barlow Condensed, sans-serif;
}

.build-item.is-building:not(.has-built) {
  border-color: rgba(240, 160, 75, .34);
}

.build-item.is-queued:not(.has-built) {
  border-color: rgba(145, 169, 171, .25);
}

.construction-world-progress.queued {
  border-color: rgba(145, 169, 171, .42);
}

.construction-world-progress.queued i {
  background: #7f9395;
  box-shadow: none;
}

@media (max-width: 720px) {
  .progress-queue-panel {
    top: calc(max(8px, env(safe-area-inset-top)) + 106px);
    right: 8px;
    left: 8px;
    width: auto;
    max-height: calc(100vh - 200px - env(safe-area-inset-bottom));
  }

  .message-preview:not(.hidden) ~ .progress-queue-panel {
    top: calc(max(8px, env(safe-area-inset-top)) + 178px);
    max-height: calc(100vh - 272px - env(safe-area-inset-bottom));
  }
}

/* Campaign time is strategic information and must remain visible at every
   viewport. The calendar uses twelve 30-day months, with one real day
   advancing one in-game quarter. */
.campaign-clock {
  display: block !important;
  flex: 0 0 auto;
  min-width: 126px;
  padding: 0 12px;
}

.campaign-clock b,
.campaign-clock small {
  white-space: nowrap;
}

@media (min-width: 721px) and (max-width: 1250px) {
  .topbar {
    height: 72px;
  }

  .campaign-clock {
    display: block !important;
    min-width: 118px;
    padding: 0 9px;
  }

  .campaign-clock span,
  .campaign-clock small {
    font-size: 7px;
    letter-spacing: .8px;
  }

  .campaign-clock b {
    font-size: 14px;
  }

  .mission,
  .inspector,
  .side-panel,
  .message-panel,
  .progress-queue-panel {
    top: 104px;
  }
}

@media (max-width: 720px) {
  .topbar {
    height: 126px;
    align-content: center;
  }

  .brand {
    flex: 1 1 calc(100% - 118px);
  }

  .brand span:last-child {
    display: none;
  }

  .campaign-clock {
    order: 3;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr);
    align-content: center;
    flex: 0 0 112px;
    min-width: 112px;
    height: 36px;
    padding: 4px 8px 3px;
    border-left: 0;
    border-right: 1px solid rgba(180, 220, 220, .12);
    border-top: 1px solid rgba(180, 220, 220, .1);
  }

  .campaign-clock span {
    font-size: 6px;
    letter-spacing: .7px;
  }

  .campaign-clock b {
    margin: 2px 0 1px;
    overflow: hidden;
    font-size: 12px;
    text-overflow: ellipsis;
  }

  .campaign-clock small {
    font-size: 6px;
    letter-spacing: .55px;
  }

  .resources {
    order: 4;
    flex: 1 1 calc(100% - 117px);
    width: auto;
  }

  .message-preview,
  .mission,
  .side-panel,
  .message-panel,
  .inspector,
  .progress-queue-panel {
    top: calc(max(8px, env(safe-area-inset-top)) + 134px);
  }

  .message-preview:not(.hidden) + .mission,
  .message-preview:not(.hidden) ~ .progress-queue-panel {
    top: calc(max(8px, env(safe-area-inset-top)) + 206px);
  }

  .rename-base-dialog {
    top: calc(max(8px, env(safe-area-inset-top)) + 133px);
  }
}

/* v61 final cascade lock: these rules intentionally follow all legacy HUD CSS. */
.program-logo { overflow: hidden; padding: 0; border: 1px solid rgba(225,174,96,.45); background: #f7f3e9; }
.program-logo img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.16); }
.mission-cover {
  padding: 20px 20px 18px 38px;
  color: #14252b;
  background: linear-gradient(92deg, rgba(0,0,0,.07), transparent 9%), repeating-linear-gradient(0deg, rgba(65,54,41,.025) 0 1px, transparent 1px 5px), #f5f1e7;
  box-shadow: inset 10px 0 24px rgba(47,38,28,.08);
}
.mission-cover::before { inset: 10px 10px 10px 29px; border-color: rgba(68,55,38,.17); }
.mission-cover::after { right: -48px; bottom: -64px; border-color: rgba(26,76,85,.08); box-shadow: 0 0 0 18px rgba(26,76,85,.025), 0 0 0 40px rgba(26,76,85,.018); }
.mission-cover-kicker { color: #5b696b; }
.mission-cover-copy small, .mission-cover-copy span { color: #9b642c; }
.mission-cover-copy strong { color: #182b31; }
.mission-open { border-color: rgba(141,92,45,.32); background: rgba(147,97,46,.08); color: #74461f; }
.mission-open:hover { background: rgba(147,97,46,.14); border-color: rgba(141,92,45,.54); }
.mission-patch { width: 156px; height: 156px; margin-top: 12px; overflow: hidden; border: 1px solid rgba(118,86,48,.16); border-radius: 24px; background: #f7f3ea; filter: drop-shadow(0 12px 20px rgba(48,39,28,.18)); }
.mission-patch img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.04); }
.mission-collapsed-summary { display: none; }
.mission.collapsed { width: 284px; min-height: 0; padding: 13px 42px 13px 14px; }
.mission.collapsed .mission-book { display: block !important; padding: 0; }
.mission.collapsed .mission-collapsed-summary { display: grid; gap: 5px; }
.mission.collapsed .mission-chapter-tabs, .mission.collapsed .mission-book > section { display: none !important; }
.inspector { width: min(360px, calc(100vw - 36px)); max-height: calc(100vh - 205px); overflow: auto; padding: 17px; }
.inspector h2 { margin: 7px 58px 8px 0; font-size: clamp(20px, 2.1vw, 27px); line-height: 1.05; overflow-wrap: anywhere; }
.inspector p { font-size: 12px; line-height: 1.52; }
.inspector > #closeInspector { position: absolute; top: 8px; right: 10px; }
.inspector .inspector-actions button, .inspector .lab-upgrade { position: static; inset: auto; font-size: 9px; }
.cash-breakdown { top: 104px; left: 18px; width: min(390px, calc(100vw - 36px)); max-height: calc(100vh - 205px); padding: 16px; overflow: auto; transform: none; }
.cash-breakdown-head strong { font-size: 19px; }
.cash-balance-current b { font-size: 18px; }
.cash-ledger-row { min-height: 52px; }
.cash-ledger-row b { font-size: 13px; }
.cash-ledger-row small { font-size: 10px; }
.cash-ledger-row > strong { font-size: 15px; }
.cash-ledger-total b { font-size: 20px; }
.message-preview { z-index: 78; top: 104px; width: min(390px, calc(100vw - 36px)); min-height: 58px; padding: 11px 14px 11px 48px; }
html[data-active-panel-side="left"] .message-preview { left: 18px; right: auto; }
html[data-active-panel-side="right"] .message-preview { left: auto; right: 18px; }
html[data-notice-visible="true"] .side-panel:not(.hidden), html[data-notice-visible="true"] .message-panel:not(.hidden), html[data-notice-visible="true"] .progress-queue-panel:not(.hidden), html[data-notice-visible="true"] .cash-breakdown:not(.hidden) { top: 174px; }
.research-success { display: none !important; }

@media (max-width: 720px) {
  .cash-breakdown, .message-preview, html[data-active-panel-side="left"] .message-preview, html[data-active-panel-side="right"] .message-preview { left: 8px; right: 8px; width: auto; }
  .cash-breakdown, .message-preview { top: calc(max(8px, env(safe-area-inset-top)) + 134px); }
  html[data-notice-visible="true"] .side-panel:not(.hidden), html[data-notice-visible="true"] .message-panel:not(.hidden), html[data-notice-visible="true"] .progress-queue-panel:not(.hidden), html[data-notice-visible="true"] .cash-breakdown:not(.hidden) { top: calc(max(8px, env(safe-area-inset-top)) + 204px); }
  .mission.collapsed { width: 252px; }
}

.buildbar::-webkit-scrollbar,
.side-panel::-webkit-scrollbar,
.message-panel::-webkit-scrollbar,
.progress-queue-panel::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.buildbar::-webkit-scrollbar-thumb,
.side-panel::-webkit-scrollbar-thumb,
.message-panel::-webkit-scrollbar-thumb,
.progress-queue-panel::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(94, 216, 211, 0.38);
}

@media (min-width: 721px) and (max-width: 980px) {
  .buildbar {
    right: 18px;
    left: 18px;
    width: auto;
    max-width: none;
    transform: none;
    justify-content: center;
  }

  .menu-launch {
    flex: 1 1 0;
    min-width: 0;
    max-width: 180px;
  }

  .placement-hint,
  .camera-controls {
    bottom: 106px;
  }

  .minimap {
    display: none;
  }
}

@media (max-width: 720px) {
  .topbar {
    top: max(8px, env(safe-area-inset-top));
    left: 8px;
    right: 8px;
    height: 98px;
    padding: 7px 8px;
    gap: 5px;
    flex-wrap: wrap;
    overflow: hidden;
  }

  .brand {
    min-width: 0;
    flex: 1 1 auto;
    gap: 8px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
  }

  .brand strong {
    font-size: 15px;
  }

  .brand span:last-child {
    max-width: 155px;
    font-size: 7px;
    line-height: 1.25;
  }

  .campaign-clock {
    display: none;
  }

  .top-actions {
    flex: 0 0 auto;
    gap: 4px;
  }

  .icon-button {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    font-size: 12px;
  }

  .resources {
    order: 3;
    flex: 1 0 100%;
    width: 100%;
    height: 36px;
    justify-content: stretch;
    border-top: 1px solid rgba(180, 220, 220, 0.1);
  }

  .resources div {
    display: block !important;
    flex: 1;
    min-width: 0;
    padding: 5px 7px 0;
  }

  .resource-card {
    grid-template-columns: 18px minmax(0, 1fr);
    column-gap: 4px;
  }

  .resource-icon {
    width: 17px;
    height: 17px;
    padding: 1px;
  }

  .resources div:nth-child(4) {
    display: none !important;
  }

  .resources span {
    overflow: hidden;
    font-size: 7px;
    letter-spacing: 0.75px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .resources b {
    margin-top: 2px;
    font-size: 12px;
  }

  .mission {
    top: calc(max(8px, env(safe-area-inset-top)) + 106px);
    right: 8px;
    left: auto;
    width: 232px;
    padding: 12px;
    padding-right: 40px;
  }

  .mission.collapsed {
    width: 205px;
    padding: 13px 40px 12px 13px;
  }

  .inspector {
    right: 8px;
    left: 8px;
  }

  .mission h1 {
    font-size: 19px;
  }

  .step {
    padding: 7px 8px;
  }

  .side-panel,
  .message-panel,
  .inspector {
    top: calc(max(8px, env(safe-area-inset-top)) + 106px);
  }

  .side-panel {
    right: 8px;
    bottom: calc(78px + env(safe-area-inset-bottom));
    max-height: none;
  }

  .buildbar {
    left: 8px;
    right: 8px;
    bottom: max(8px, env(safe-area-inset-bottom));
    width: auto;
    max-width: none;
    height: 64px;
    transform: none;
    overflow: hidden;
  }

  .menu-launch {
    flex: 1 1 0;
    min-width: 0;
    height: 50px;
    grid-template-columns: 26px minmax(0, 1fr);
    padding: 5px 6px;
  }

  .menu-launch > span {
    font-size: 20px;
  }

  .menu-launch b {
    overflow: hidden;
    font-size: 11px;
    letter-spacing: 1px;
    text-overflow: ellipsis;
  }

  .menu-launch small {
    overflow: hidden;
    font-size: 7px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .camera-controls {
    right: 8px;
    bottom: calc(80px + env(safe-area-inset-bottom));
  }

  .camera-controls button {
    width: 38px;
    height: 34px;
  }

  .placement-hint {
    right: 132px;
    left: 8px;
    bottom: calc(80px + env(safe-area-inset-bottom));
    width: auto;
    min-height: 46px;
    padding: 9px 10px;
  }

  .placement-hint span:first-child {
    font-size: 9px;
  }

  #toast {
    top: auto;
    bottom: calc(146px + env(safe-area-inset-bottom));
    width: calc(100% - 32px);
    text-align: center;
    transform: translate(-50%, 12px);
  }

  #toast.show {
    transform: translate(-50%, 0);
  }
}

@media (max-width: 430px) {
  .brand span:last-child {
    display: none;
  }

  .mission {
    width: min(232px, calc(100% - 16px));
  }
}

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

/* Mars47 v65: directive clarity, unified top-right guidance and consistent command surfaces. */
.mission.mission-covered { width: 336px; }
.mission-open {
  width: 224px;
  min-height: 49px;
  padding: 0 16px;
  border: 1px solid #f4ad5d !important;
  color: #142128 !important;
  background: linear-gradient(135deg, #ffc073, #e99443) !important;
  box-shadow: 0 10px 28px rgba(217,123,43,.32), inset 0 1px rgba(255,255,255,.45);
  font-size: 11px;
  letter-spacing: .16em;
  animation: directive-cta 2.2s ease-in-out infinite;
}
.mission-open:hover { border-color: #ffd59b !important; background: linear-gradient(135deg, #ffd091, #f0a050) !important; transform: translateY(-1px); }
.mission-open > span:last-child { color: #17313a; font-size: 20px; }
.mission-open-pulse { width: 8px; height: 8px; border-radius: 50%; background: #0c6b6c; box-shadow: 0 0 0 5px rgba(12,107,108,.13); }
@keyframes directive-cta { 50% { box-shadow: 0 12px 34px rgba(217,123,43,.46), inset 0 1px rgba(255,255,255,.5); } }

.mission.directive-open { width: 430px; }
.mission-book { padding-right: 26px; }
.mission-progress .step { grid-template-columns: 22px minmax(0,1fr) auto; }
.mission-progress .step > span { white-space: nowrap; }

.placement-hint,
.welcome-notice {
  right: 18px;
  left: auto;
  bottom: auto;
  width: min(430px, calc(100vw - 36px));
}
.welcome-notice { position: fixed; z-index: 18; top: 104px; display: grid; grid-template-columns: 46px 1fr; gap: 13px; padding: 14px; border: 1px solid rgba(94,216,211,.32); background: rgba(7,20,27,.96); box-shadow: 0 18px 45px rgba(0,0,0,.3); animation: welcome-in 420ms ease both; }
.welcome-notice.hidden { display: none; }
.welcome-mark { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 12px; color: #071219; background: linear-gradient(145deg,#6fe2dc,#efaa59); font: 900 12px Barlow Condensed; letter-spacing: .06em; }
.welcome-notice div { display: grid; gap: 3px; }
.welcome-notice small { color: #efa65a; font: 700 8px Barlow Condensed; letter-spacing: .16em; }
.welcome-notice strong { color: #edf6f4; font: 700 16px Barlow Condensed; letter-spacing: .03em; }
.welcome-notice p { margin: 0; color: #9fb1b2; font-size: 10px; }
.placement-hint { top: 104px; display: grid; grid-template-columns: 38px 1fr; gap: 11px; min-height: 68px; padding: 12px 14px; border-color: rgba(94,216,211,.26); background: rgba(7,20,27,.95); }
.welcome-notice:not(.hidden) + .placement-hint { display: none; }
#app:has(.welcome-notice:not(.hidden)) .mission { top: 196px; }
#app:has(.placement-hint:not(.intro-dismissed)) .mission { top: 184px; }
#app:has(.welcome-notice:not(.hidden)) .mission { top: 196px; }
.placement-help-icon { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid rgba(242,171,91,.32); border-radius: 10px; color: #f2ab5b; background: rgba(242,171,91,.09); }
.placement-help-icon svg { width: 23px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.placement-hint > span:last-child { display: grid; gap: 6px; }
.placement-hint #placementHint { color: #e8f2f0; font: 700 11px/1.25 Barlow Condensed; letter-spacing: .04em; }
.placement-hint .controls-hint { color: #71888a; font-size: 7px; line-height: 1.3; }
@keyframes welcome-in { from { opacity: 0; transform: translateY(-10px); } }

#toast { top: 104px; right: 18px; left: auto; bottom: auto; width: min(430px, calc(100vw - 36px)); transform: translateY(-10px); }
#toast.show { transform: none; }
#app:has(#toast.show) .mission { top: 154px; }

.menu-launch > svg { grid-row: 1/3; width: 34px; height: 34px; fill: none; stroke: #65ddd6; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 8px rgba(94,216,211,.18)); }
.launch-menu-button > svg { stroke: #e0a459; }
.panel-title-lockup { display: flex; align-items: center; gap: 11px; }
.panel-title-lockup > svg { width: 36px; height: 36px; padding: 7px; border: 1px solid rgba(94,216,211,.25); border-radius: 9px; fill: none; stroke: #66ddd7; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; background: rgba(94,216,211,.06); }
.research-panel { left: 18px !important; right: auto !important; }
.research-menu-hero, .research-resource-strip, .research-roadmap-lock { display: none !important; }
.research-panel .research-node-art { grid-template-columns: 58px minmax(0,1fr); min-height: 68px; padding: 8px 42px 8px 8px; }
.research-panel .research-art { width: 58px; height: 50px; border-radius: 8px; }
.research-node-art .research-cost { display: none !important; }
.research-node.completed .research-progress,
.research-node.completed .research-timer { display: none; }
.research-node.completed::after { position: absolute; top: 50%; right: 13px; display: grid; place-items: center; width: 25px; height: 25px; content: "✓"; border: 1px solid rgba(91,224,158,.58); border-radius: 50%; color: #78e5aa; background: rgba(34,131,85,.18); transform: translateY(-50%); }

.facility-instance-section { margin-top: 16px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.08); }
.facility-instance-section.hidden { display: none; }
.facility-instance-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; margin-top: 9px; }
.facility-instance-card { display: grid; grid-template-columns: 42px 1fr; gap: 8px; padding: 7px; border: 1px solid rgba(135,182,187,.18); border-radius: 9px; color: #dce7e5; background: rgba(255,255,255,.025); text-align: left; }
.facility-instance-card .building-thumb { width: 42px; height: 38px; }
.facility-instance-card b, .facility-instance-card small { display: block; }
.facility-instance-card b { font: 700 10px Barlow Condensed; }
.facility-instance-card small { margin-top: 3px; color: #819698; font-size: 7px; }
.facility-instance-card.ready { border-color: rgba(240,160,75,.4); }

@media (max-width: 720px) {
  .mission.directive-open { width: min(390px, calc(100vw - 16px)); }
  .mission-progress .step > span { white-space: normal; }
  .placement-hint, .welcome-notice { top: 84px; right: 8px; width: calc(100vw - 16px); }
  #app:has(.welcome-notice:not(.hidden)) .mission,
  #app:has(.placement-hint:not(.intro-dismissed)) .mission { top: 176px; }
  .menu-launch > svg { width: 25px; height: 25px; }
}

/* Mars47 v5.2 gameplay feedback and menu hierarchy */
.resource-energy.over-capacity {
  --resource-color: #ff705f;
  border-color: rgba(255, 112, 95, 0.55);
  background: linear-gradient(145deg, rgba(91, 24, 22, 0.88), rgba(34, 12, 14, 0.94));
  box-shadow: inset 0 0 0 1px rgba(255, 112, 95, 0.12), 0 0 22px rgba(255, 70, 50, 0.12);
}

.resource-energy.over-capacity b {
  color: #ff9b8e;
}

.resource-card.resource-pulse {
  animation: resource-pulse-v52 2.3s ease both;
}

@keyframes resource-pulse-v52 {
  0%, 100% { transform: scale(1); }
  15%, 48% { transform: scale(1.055); box-shadow: 0 0 24px color-mix(in srgb, var(--resource-color) 38%, transparent); }
}

.step.complete i {
  display: grid;
  place-items: center;
  border-color: #5bd394;
  background: #173e30;
  box-shadow: 0 0 11px rgba(91, 211, 148, 0.3);
}

.step.complete i::before {
  content: "✓";
  color: #8ff0b8;
  font: 800 11px/1 Arial, sans-serif;
}

.soundtrack-button {
  color: #c8d8d4;
  font-size: 19px;
}

.soundtrack-button.active {
  color: #8cf2e9;
  border-color: rgba(94, 216, 211, 0.46);
  background: rgba(94, 216, 211, 0.12);
  box-shadow: 0 0 18px rgba(94, 216, 211, 0.13);
}

.message-preview {
  position: fixed;
  z-index: 42;
  top: 76px;
  right: 18px;
  width: min(330px, calc(100vw - 36px));
  padding: 10px 12px 11px 48px;
  border-color: rgba(94, 216, 211, 0.3);
  border-radius: 11px;
  color: #d9e9e7;
  transition: opacity 180ms ease, transform 180ms ease;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.32);
}

.message-preview::before {
  content: "✉";
  position: absolute;
  left: 13px;
  top: 50%;
  color: #77ddd7;
  font-size: 21px;
  transform: translateY(-50%);
}

.message-preview strong,
.message-preview small {
  display: block;
}

.message-preview strong {
  font: 700 13px/1.1 Barlow Condensed, sans-serif;
}

.message-preview small {
  margin-top: 4px;
  overflow: hidden;
  color: #879b9d;
  font-size: 8px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-preview.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
}

.message-filters {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  margin: 1px 0 10px;
}

.message-filters button {
  min-height: 27px;
  padding: 4px;
  border: 1px solid rgba(154, 187, 188, 0.14);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.025);
  color: #758b8e;
  cursor: pointer;
  font: 700 8px/1 Barlow Condensed, sans-serif;
  letter-spacing: 0.7px;
}

.message-filters button.active {
  border-color: rgba(94, 216, 211, 0.4);
  background: rgba(94, 216, 211, 0.1);
  color: #93eee8;
}

.message-entry {
  position: relative;
  min-height: 68px;
  padding-left: 62px !important;
}

.message-thumb {
  position: absolute;
  left: 10px;
  top: 12px;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(164, 207, 207, 0.18);
  border-radius: 9px;
  background: linear-gradient(145deg, #263c43, #0d1a20);
  color: #9cded9;
  font: 800 16px/1 Barlow Condensed, sans-serif;
  box-shadow: inset 0 1px rgba(255,255,255,.08);
}

.message-entry[data-category="research"] .message-thumb { color: #aaa5ff; background: linear-gradient(145deg, #29264c, #11152a); }
.message-entry[data-category="buildings"] .message-thumb { color: #efb66e; background: linear-gradient(145deg, #4a3523, #1e1712); }
.message-entry[data-category="funding"] .message-thumb { color: #8ee4ac; background: linear-gradient(145deg, #234533, #101e18); }

.thumb-construction {
  background-position: 0 100%;
  box-shadow: inset 0 0 0 2px rgba(239, 171, 82, 0.28), 0 5px 14px rgba(0, 0, 0, 0.25) !important;
}

.locked-build-section {
  margin-top: 16px;
  padding-top: 13px;
  border-top: 1px solid rgba(148, 184, 185, 0.14);
}

.locked-build-section.hidden,
.build-category.empty {
  display: none;
}

.locked-build-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 9px;
}

.locked-build-grid .build-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  min-height: 70px !important;
  padding: 7px !important;
  gap: 7px;
  text-align: left;
}

.locked-build-grid .building-thumb {
  width: 42px;
  height: 42px;
  flex-basis: 42px;
}

.locked-build-grid .build-item > span:nth-child(2) > b {
  font-size: 10px;
  line-height: 1.1;
}

.locked-build-grid .build-item small {
  display: none;
}

.locked-build-grid .unlock-requirement {
  display: block !important;
  margin-top: 4px !important;
  font-size: 7px !important;
}

.locked-build-grid .unlock-requirement strong,
.locked-build-grid .build-item > i,
.locked-build-grid .build-item > kbd {
  display: none;
}

.build-item.newly-unlocked {
  border-color: rgba(91, 211, 148, 0.55) !important;
  box-shadow: inset 0 0 0 1px rgba(91, 211, 148, 0.11), 0 0 18px rgba(91, 211, 148, 0.08);
}

.build-item.newly-unlocked > i {
  display: inline-grid;
  place-items: center;
  min-width: 54px;
  padding: 3px 5px;
  border: 1px solid rgba(91, 211, 148, 0.42);
  border-radius: 5px;
  color: #8fe8b5;
  font-size: 7px;
}

.research-resource-strip,
.research-roadmap-lock {
  display: grid;
  align-items: center;
  border: 1px solid rgba(166, 161, 255, 0.22);
  border-radius: 10px;
  background: linear-gradient(145deg, rgba(166, 161, 255, 0.09), rgba(50, 53, 82, 0.16));
}

.research-resource-strip {
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  margin-bottom: 12px;
  padding: 10px 12px;
}

.research-resource-strip span {
  color: #aaa5ff;
  font: 700 8px/1 Barlow Condensed, sans-serif;
  letter-spacing: 1px;
}

.research-resource-strip b {
  color: #e3e1ff;
  font: 700 15px/1 Barlow Condensed, sans-serif;
}

.research-resource-strip small {
  grid-column: 1 / 3;
  color: #737690;
  font-size: 8px;
}

.research-roadmap-lock {
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 10px;
  padding: 10px;
  opacity: 0.72;
}

.research-roadmap-lock > span {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(166, 161, 255, 0.28);
  border-radius: 8px;
  color: #aaa5ff;
  font: 800 13px/1 Barlow Condensed, sans-serif;
}

.research-roadmap-lock b,
.research-roadmap-lock small { display: block; }
.research-roadmap-lock b { color: #cfd0df; font-size: 11px; }
.research-roadmap-lock small { margin-top: 4px; color: #777d8e; font-size: 8px; line-height: 1.35; }
.research-roadmap-lock i { color: #777499; font: 700 7px/1 Barlow Condensed, sans-serif; font-style: normal; letter-spacing: 1px; }

.world-overlay {
  position: fixed;
  z-index: 18;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.construction-world-progress,
.building-name-overlay {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, -100%);
}

.construction-world-progress {
  width: 128px;
  padding: 6px 7px 7px;
  border: 1px solid rgba(164, 216, 215, 0.34);
  border-radius: 8px;
  background: rgba(5, 15, 20, 0.9);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.construction-world-progress b {
  display: block;
  margin-bottom: 5px;
  overflow: hidden;
  color: #dcebea;
  font: 700 8px/1 Barlow Condensed, sans-serif;
  letter-spacing: 0.35px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.construction-world-progress span {
  display: block;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
}

.construction-world-progress i {
  display: block;
  width: var(--building-progress, 0%);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #e79b43, #79e6dc);
  box-shadow: 0 0 9px rgba(94, 216, 211, 0.35);
}

.construction-world-progress.paused {
  border-color: rgba(255, 122, 92, 0.48);
}

.construction-world-progress.paused i {
  background: #e77b56;
}

.building-name-overlay {
  max-width: 250px;
  padding: 7px 11px;
  border: 1px solid rgba(94, 216, 211, 0.42);
  border-radius: 7px;
  background: rgba(4, 14, 19, 0.9);
  color: #e8f5f3;
  font: 700 11px/1 Barlow Condensed, sans-serif;
  letter-spacing: 0.45px;
  white-space: nowrap;
  box-shadow: 0 8px 22px rgba(0,0,0,.28);
}

.research-world-check {
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 2px solid #78e8b0;
  border-radius: 50%;
  background: rgba(13, 69, 48, 0.88);
  color: #a5f5c8;
  font: 800 30px/1 Arial, sans-serif;
  transform: translate(-50%, -100%);
  animation: research-world-check 2.8s ease both;
  box-shadow: 0 0 0 8px rgba(91, 211, 148, 0.1), 0 0 30px rgba(91, 211, 148, 0.38);
}

.hidden { display: none !important; }

@keyframes research-world-check {
  0% { opacity: 0; transform: translate(-50%, -70%) scale(.45) rotate(-18deg); }
  18%, 72% { opacity: 1; transform: translate(-50%, -115%) scale(1) rotate(0); }
  100% { opacity: 0; transform: translate(-50%, -145%) scale(.88); }
}

/* Mars47 v5.3 routing, progression, and world-interface polish */
.brand-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: default;
  text-align: left;
}

.brand-button:focus-visible {
  border-radius: 10px;
  outline-offset: 5px;
}

.program-logo {
  overflow: visible;
  border: 0;
  background: radial-gradient(circle at 50% 48%, rgba(216, 108, 62, .16), rgba(4, 13, 18, .7));
  box-shadow: inset 0 0 0 1px rgba(239, 173, 104, .19), 0 0 22px rgba(213, 93, 46, .1);
}

.program-logo svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.mars-orbit {
  fill: none;
  stroke: rgba(243, 172, 100, .28);
  stroke-width: 1.2;
  stroke-dasharray: 3 3;
}

.mars-disc {
  filter: drop-shadow(0 0 5px rgba(238, 116, 63, .32));
}

.mars-ridge {
  fill: none;
  stroke: rgba(92, 39, 30, .6);
  stroke-width: 1.5;
  stroke-linecap: round;
}

.earth-disc {
  fill: #2e8caf;
  stroke: #b7ecdc;
  stroke-width: 1.1;
  filter: drop-shadow(0 0 4px rgba(97, 219, 209, .38));
}

.earth-land {
  fill: #83ad6c;
}

.mission {
  transition: top 220ms ease, width 180ms ease, padding 180ms ease, opacity 180ms ease;
}

.message-preview:not(.hidden) + .mission {
  top: 164px;
}

.inspector-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 13px;
  padding-top: 12px;
  border-top: 1px solid rgba(152, 190, 190, .14);
}

.inspector-actions button,
.lab-upgrade {
  min-height: 37px;
  border: 1px solid rgba(152, 190, 190, .2);
  border-radius: 8px;
  background: rgba(255, 255, 255, .035);
  color: #a9babc;
  cursor: pointer;
  font: 700 8px/1 Barlow Condensed, sans-serif;
  letter-spacing: .6px;
}

.inspector-actions button span {
  display: block;
  margin-bottom: 4px;
  color: #76dcd6;
  font-size: 15px;
}

.inspector-actions button:hover {
  border-color: rgba(94, 216, 211, .42);
  background: rgba(94, 216, 211, .09);
  color: #e4f3f2;
}

.inspector-actions button[data-inspector-action="demolish"]:hover {
  border-color: rgba(255, 116, 91, .44);
  background: rgba(255, 94, 70, .08);
}

.lab-upgrade {
  width: 100%;
  margin-top: 8px;
  border-color: rgba(240, 160, 75, .38);
  background: linear-gradient(145deg, rgba(240, 160, 75, .13), rgba(240, 160, 75, .035));
  color: #f2bc7d;
}

.lab-upgrade.ready {
  border-color: rgba(91, 211, 148, .48);
  color: #90e9b7;
  box-shadow: 0 0 18px rgba(91, 211, 148, .08);
}

.menu-launch b {
  position: relative;
}

.menu-notification {
  display: inline-grid;
  place-items: center;
  min-width: 17px;
  height: 17px;
  margin-left: 5px;
  padding: 0 4px;
  border: 1px solid rgba(91, 211, 148, .7);
  border-radius: 999px;
  background: #17452f;
  color: #9bf2bf;
  font: 800 9px/1 Arial, sans-serif;
  box-shadow: 0 0 12px rgba(91, 211, 148, .26);
  vertical-align: 2px;
}

.build-item.has-built {
  border-color: rgba(91, 211, 148, .34);
}

.build-item .built-check {
  display: grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  margin-left: auto;
  border: 1px solid #5bd394;
  border-radius: 50%;
  background: #173e30;
  color: #8ff0b8;
  font: 800 12px/1 Arial, sans-serif;
  box-shadow: 0 0 11px rgba(91, 211, 148, .3);
}

/* A completed facility has one unambiguous state marker: BUILT replaces the
   READY / UNLOCKED badge rather than appearing alongside it. */
.build-item.has-built > i,
.build-item.has-built > kbd {
  display: none;
}

#researchMenuBtn.locked {
  position: relative;
  cursor: help;
  pointer-events: auto;
}

#researchMenuBtn.locked::after {
  content: "BUILD AND COMMISSION RESEARCH CENTER L1";
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  width: 190px;
  padding: 8px 10px;
  border: 1px solid rgba(240, 160, 75, .3);
  border-radius: 7px;
  background: rgba(5, 15, 20, .96);
  color: #e7c294;
  font: 700 8px/1.25 Barlow Condensed, sans-serif;
  letter-spacing: .7px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 5px);
  transition: opacity 150ms ease, transform 150ms ease;
}

#researchMenuBtn.locked:hover::after,
#researchMenuBtn.locked:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.research-panel {
  overflow-x: hidden;
}

.research-panel .panel-head {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  margin-right: 0;
}

.research-panel .panel-head > div {
  min-width: 0;
}

.research-panel .panel-head h2 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.placement-hint {
  bottom: 104px;
  max-width: min(610px, calc(100vw - 430px));
  transition: opacity 240ms ease, transform 240ms ease;
}

.placement-hint.intro-dismissed {
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
}

.rename-base-dialog {
  position: fixed;
  z-index: 70;
  top: 86px;
  left: 18px;
  width: 286px;
  padding: 15px;
  border-radius: 13px;
  box-shadow: 0 20px 55px rgba(0, 0, 0, .44);
}

.rename-base-dialog h2 {
  margin: 7px 0 13px;
  color: #eff8f7;
  font: 700 20px/1 Barlow Condensed, sans-serif;
}

.rename-base-dialog label {
  display: block;
  margin-bottom: 5px;
  color: #829799;
  font-size: 8px;
}

.rename-base-dialog input {
  box-sizing: border-box;
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 1px solid rgba(94, 216, 211, .32);
  border-radius: 8px;
  outline: 0;
  background: rgba(1, 9, 13, .72);
  color: #ecf8f7;
  font: 700 15px/1 Barlow Condensed, sans-serif;
  letter-spacing: .8px;
}

.rename-base-dialog input:focus {
  border-color: rgba(94, 216, 211, .68);
  box-shadow: 0 0 0 3px rgba(94, 216, 211, .09);
}

.rename-base-dialog > div:last-child {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  margin-top: 12px;
}

.rename-base-dialog button {
  min-width: 74px;
  min-height: 31px;
  border: 1px solid rgba(143, 177, 179, .2);
  border-radius: 7px;
  background: rgba(255, 255, 255, .04);
  color: #a5b7b8;
  cursor: pointer;
  font: 700 9px/1 Barlow Condensed, sans-serif;
}

#saveBaseRename {
  border-color: rgba(94, 216, 211, .38);
  background: rgba(94, 216, 211, .1);
  color: #99eee8;
}

.minimap canvas {
  image-rendering: auto;
}

.research-patent {
  display: block;
  margin-top: 5px;
  color: #e8b86d;
  font: 700 8px "Barlow Condensed", sans-serif;
  letter-spacing: .7px;
}

.patent-research.completed .research-patent {
  color: #79ded7;
}

@media (max-width: 720px) {
  .message-preview {
    top: calc(max(8px, env(safe-area-inset-top)) + 106px);
    right: 8px;
  }

  .message-preview:not(.hidden) + .mission {
    top: calc(max(8px, env(safe-area-inset-top)) + 178px);
  }

  .placement-hint {
    bottom: calc(80px + env(safe-area-inset-bottom));
    max-width: none;
  }

  .rename-base-dialog {
    top: calc(max(8px, env(safe-area-inset-top)) + 105px);
    left: 8px;
    width: min(286px, calc(100vw - 16px));
  }
}

/* Final responsive clock placement: this intentionally follows all earlier
   mobile HUD rules so campaign time can never be hidden by fallback CSS. */
@media (min-width: 721px) and (max-width: 1250px) {
  .topbar {
    height: 72px;
  }

  .campaign-clock {
    display: block !important;
    min-width: 118px;
    padding: 0 9px;
  }

  .mission,
  .inspector,
  .side-panel,
  .message-panel,
  .progress-queue-panel {
    top: 104px;
  }
}

@media (max-width: 720px) {
  .topbar {
    height: 126px !important;
    align-content: center;
  }

  .brand {
    flex: 1 1 calc(100% - 118px);
  }

  .brand span:last-child {
    display: none;
  }

  .campaign-clock {
    order: 3;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr);
    align-content: center;
    flex: 0 0 112px;
    min-width: 112px;
    height: 36px;
    padding: 4px 8px 3px;
    border-top: 1px solid rgba(180, 220, 220, .1);
    border-right: 1px solid rgba(180, 220, 220, .12);
    border-left: 0;
  }

  .campaign-clock span {
    font-size: 6px;
    letter-spacing: .7px;
  }

  .campaign-clock b {
    margin: 2px 0 1px;
    overflow: hidden;
    font-size: 12px;
    text-overflow: ellipsis;
  }

  .campaign-clock small {
    font-size: 6px;
    letter-spacing: .55px;
  }

  .resources {
    order: 4;
    flex: 1 1 calc(100% - 117px);
    width: auto;
  }

  .message-preview,
  .mission,
  .side-panel,
  .message-panel,
  .inspector,
  .progress-queue-panel {
    top: calc(max(8px, env(safe-area-inset-top)) + 134px);
  }

  .message-preview:not(.hidden) + .mission,
  .message-preview:not(.hidden) ~ .progress-queue-panel {
    top: calc(max(8px, env(safe-area-inset-top)) + 206px);
  }

  .rename-base-dialog {
    top: calc(max(8px, env(safe-area-inset-top)) + 133px);
  }
}
