:root {
  color-scheme: dark;
  --bg: #151a1d;
  --panel: #20272a;
  --panel-2: #2a3134;
  --line: #455158;
  --text: #f3f0dc;
  --muted: #b8b49f;
  --accent: #55d6c2;
  --warn: #ffcf5a;
  --bad: #ef6c5b;
  --main-menu-art: none;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(85, 214, 194, 0.05) 1px, transparent 1px),
    linear-gradient(rgba(85, 214, 194, 0.04) 1px, transparent 1px),
    #101416;
  background-size: 24px 24px;
  color: var(--text);
  font-family: "Trebuchet MS", Arial, sans-serif;
}

button {
  width: 100%;
  min-height: 34px;
  border: 1px solid #607078;
  border-radius: 4px;
  background: linear-gradient(#3b474b, #2b3437);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 9px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -2px 0 rgba(0, 0, 0, 0.28);
}

button:hover,
button.active {
  border-color: var(--accent);
  background: linear-gradient(#486263, #334749);
  color: #f8fff9;
}

button:disabled {
  color: #837f70;
  border-color: #3a4144;
  background: #282d2f;
  cursor: not-allowed;
}

#app {
  height: 100vh;
  padding: 10px;
  overflow: hidden;
}

#game-shell {
  height: calc(100vh - 20px);
  max-width: none;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  min-width: 0;
  min-height: 0;
}

#topbar {
  display: grid;
  grid-template-columns: minmax(250px, 0.72fr) minmax(520px, 1.85fr) auto;
  align-items: center;
  gap: 10px;
  min-width: 0;
  overflow: hidden;
  padding: 7px 10px;
  border: 2px solid #53636a;
  background:
    linear-gradient(90deg, rgba(85, 214, 194, 0.07), transparent 42%),
    linear-gradient(#253035, #1b2326);
  box-shadow:
    inset 0 0 0 2px #111719,
    0 8px 20px rgba(0, 0, 0, 0.28);
}

#brand-block {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.mission-patch {
  position: relative;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(85, 214, 194, 0.82);
  background:
    linear-gradient(135deg, rgba(255, 207, 90, 0.14), transparent 42%),
    radial-gradient(circle at 68% 30%, rgba(85, 214, 194, 0.24), transparent 26%),
    #101719;
  box-shadow:
    inset 0 0 0 2px rgba(0, 0, 0, 0.55),
    0 0 12px rgba(85, 214, 194, 0.13);
  overflow: hidden;
}

.mission-patch::before,
.mission-patch::after {
  content: "";
  position: absolute;
  border: 1px solid rgba(255, 207, 90, 0.35);
}

.mission-patch::before {
  inset: 7px;
  transform: rotate(45deg);
}

.mission-patch::after {
  left: 8px;
  right: 8px;
  bottom: 8px;
  height: 8px;
  border-top: 0;
  border-color: rgba(85, 214, 194, 0.45);
}

.patch-star,
.patch-ship,
.patch-world {
  position: absolute;
  display: block;
}

.patch-star {
  right: 9px;
  top: 7px;
  width: 5px;
  height: 5px;
  background: var(--warn);
  box-shadow: 0 0 8px rgba(255, 207, 90, 0.9);
}

.patch-ship {
  left: 17px;
  top: 12px;
  width: 8px;
  height: 16px;
  clip-path: polygon(50% 0, 100% 100%, 50% 76%, 0 100%);
  background: linear-gradient(#dff7f2, #55d6c2);
}

.patch-world {
  left: 12px;
  bottom: 9px;
  width: 18px;
  height: 8px;
  border: 2px solid rgba(85, 214, 194, 0.85);
  border-top: 0;
  border-radius: 0 0 20px 20px;
}

#game-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
  align-items: center;
  min-width: 0;
}

#game-actions button {
  width: 32px;
  min-width: 32px;
  min-height: 30px;
  justify-content: center;
  padding: 4px;
  font-size: 15px;
  line-height: 1;
}

#game-actions button.active {
  box-shadow:
    inset 0 0 0 1px rgba(85, 214, 194, 0.85),
    0 0 12px rgba(85, 214, 194, 0.2);
}

#volume-control {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 29px;
  padding: 4px 5px;
  border: 1px solid #607078;
  border-radius: 4px;
  background: #12191b;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

#audio-volume {
  width: 58px;
  accent-color: var(--accent);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 19px;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 10px;
  font-size: 15px;
  color: var(--accent);
}

p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

#title-block {
  min-width: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#status-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(68px, 1fr));
  gap: 5px;
  min-width: 0;
  font-size: 10px;
}

#status-strip .status-box {
  --status-accent: var(--accent);
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 5px;
  align-items: center;
  min-width: 0;
  min-height: 42px;
  padding: 5px 6px;
  border: 1px solid color-mix(in srgb, var(--status-accent) 44%, #59686e);
  border-left-width: 3px;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--status-accent) 16%, transparent), transparent 48%),
    #12191b;
  box-shadow:
    inset 0 -3px 0 rgba(0, 0, 0, 0.25),
    inset 0 0 18px rgba(0, 0, 0, 0.12);
  text-transform: uppercase;
  letter-spacing: 0;
}

#status-strip .status-icon {
  grid-row: 1 / span 2;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  color: var(--status-accent);
  border: 1px solid color-mix(in srgb, var(--status-accent) 55%, transparent);
  background: rgba(0, 0, 0, 0.22);
  font-size: 11px;
  line-height: 1;
  text-shadow: 0 0 8px color-mix(in srgb, var(--status-accent) 65%, transparent);
}

#status-strip .status-label {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: color-mix(in srgb, var(--status-accent) 54%, var(--muted));
}

#status-strip strong {
  display: block;
  margin-top: 1px;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--warn);
  text-transform: none;
}

#status-strip small {
  display: block;
  margin-top: 1px;
  color: var(--accent);
  font-size: 10px;
  white-space: nowrap;
}

#status-strip .status-minerals {
  --status-accent: #ffcf5a;
}

#status-strip .status-biomass {
  --status-accent: #80d66d;
}

#status-strip .status-rare {
  --status-accent: #a889ff;
}

#status-strip .status-research {
  --status-accent: #77b7ff;
}

#status-strip .status-power {
  --status-accent: #ffd76a;
}

#status-strip .status-shelter {
  --status-accent: #bdf8ef;
}

#status-strip .status-storage {
  --status-accent: #d68f5d;
}

#status-strip .status-warning {
  border-color: var(--warn);
  background: linear-gradient(#2d2918, #161914);
}

#status-strip .status-critical {
  border-color: var(--bad);
  background: linear-gradient(#3a1f21, #171516);
}

#status-strip .status-critical strong,
#status-strip .status-critical small {
  color: #ff9a8f;
}

#status-strip .status-warning strong,
#status-strip .status-warning small {
  color: var(--warn);
}

#play-area {
  display: grid;
  grid-template-columns: clamp(218px, 17vw, 286px) minmax(420px, 1fr) clamp(220px, 18vw, 300px);
  gap: 10px;
  height: 100%;
  min-width: 0;
  min-height: 0;
  margin-top: 0;
}

aside {
  border: 2px solid #53636a;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px),
    linear-gradient(#242d31, #192124);
  background-size: 12px 12px, auto;
  box-shadow: inset 0 0 0 2px #101618;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: #53636a #141b1e;
}

aside section {
  padding: 10px;
  border-bottom: 2px solid #141b1e;
}

#left-panel section:nth-child(2) {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  align-content: start;
}

#command-actions-title {
  grid-column: 1 / -1;
}

.command-category-title {
  grid-column: 1 / -1;
  margin: 7px 0 0;
  padding: 5px 6px 3px;
  border-top: 1px solid rgba(85, 214, 194, 0.28);
  color: var(--accent);
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 0;
  text-transform: uppercase;
}

#command-actions button {
  display: grid;
  grid-template-columns: 1fr;
  align-items: start;
  gap: 4px;
  min-height: 78px;
  padding: 7px 6px;
  text-align: left;
}

.action-main {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.action-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(85, 214, 194, 0.48);
  border-radius: 3px;
  background:
    linear-gradient(135deg, rgba(85, 214, 194, 0.18), rgba(12, 22, 25, 0.88)),
    #142125;
  color: var(--accent);
  font-size: 18px;
  line-height: 1;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.36);
}

.action-text {
  display: grid;
  min-width: 0;
  gap: 1px;
}

.action-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: 12px;
  font-weight: bold;
}

.action-cost {
  color: var(--warn);
  font-size: 10px;
  white-space: nowrap;
}

.action-desc {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.15;
  text-align: left;
  text-overflow: ellipsis;
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

#command-actions button:hover .action-icon,
#command-actions button.active .action-icon {
  border-color: var(--warn);
  color: var(--warn);
  box-shadow:
    inset 0 0 0 1px rgba(255, 207, 90, 0.24),
    0 0 10px rgba(85, 214, 194, 0.22);
}

#command-actions button.action-unavailable {
  border-color: rgba(92, 104, 108, 0.5);
  background:
    linear-gradient(180deg, rgba(52, 61, 64, 0.72), rgba(30, 37, 39, 0.76));
  color: #8d9692;
  cursor: not-allowed;
  filter: grayscale(0.75) saturate(0.45);
}

#command-actions button.action-unavailable .action-icon {
  border-color: #3a4144;
  color: #837f70;
  background: #1b2022;
  box-shadow: none;
}

#command-actions button.action-unavailable .action-label,
#command-actions button.action-unavailable .action-cost,
#command-actions button.action-unavailable .action-desc {
  color: #837f70;
}

#command-actions button.action-unavailable:hover {
  border-color: rgba(116, 120, 104, 0.58);
  box-shadow: inset 0 0 0 1px rgba(255, 207, 90, 0.08);
}

#command-actions button.action-unavailable:hover .action-icon {
  border-color: #5a5f57;
  color: #9a967f;
  box-shadow: none;
}

#command-actions button:disabled .action-icon {
  border-color: #3a4144;
  color: #837f70;
  background: #1b2022;
  box-shadow: none;
}

#command-actions button:disabled .action-label,
#command-actions button:disabled .action-cost,
#command-actions button:disabled .action-desc {
  color: #837f70;
}

#selected {
  min-height: 46px;
  color: var(--text);
  line-height: 1.35;
}

.selected-card {
  display: grid;
  gap: 8px;
  padding: 9px;
  border: 1px solid rgba(85, 214, 194, 0.3);
  background:
    linear-gradient(135deg, rgba(85, 214, 194, 0.08), transparent 44%),
    rgba(7, 13, 15, 0.62);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.36);
}

.selected-card-heading {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.selected-card-heading strong {
  min-width: 0;
  overflow: hidden;
  color: var(--warn);
  font-size: 15px;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-card-heading span {
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
  text-transform: uppercase;
}

.selected-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
}

.selected-stat {
  min-width: 0;
  padding: 5px;
  border: 1px solid rgba(85, 214, 194, 0.16);
  background: rgba(18, 27, 30, 0.7);
}

.selected-stat span {
  display: block;
  color: var(--accent);
  font-size: 9px;
  line-height: 1.1;
  text-transform: uppercase;
}

.selected-stat strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: var(--warn);
  font-size: 11px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-card p {
  margin: 0;
  color: var(--text);
  font-size: 11px;
  line-height: 1.35;
}

.panda-research-button {
  justify-self: start;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid rgba(255, 207, 90, 0.58);
  background: linear-gradient(180deg, rgba(85, 214, 194, 0.18), rgba(14, 22, 24, 0.9));
  color: var(--warn);
  font-size: 12px;
  font-weight: bold;
}

.panda-research-button[aria-disabled="true"] {
  border-color: rgba(92, 104, 108, 0.5);
  color: #837f70;
  filter: grayscale(0.7);
}

.build-queue-panel {
  margin-top: 9px;
  padding: 8px;
  border: 1px solid rgba(85, 214, 194, 0.32);
  background: rgba(8, 15, 17, 0.55);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

#right-panel .build-queue-panel {
  min-height: 0;
  margin: 8px 10px;
  border-color: rgba(255, 207, 90, 0.28);
  background:
    linear-gradient(90deg, rgba(255, 207, 90, 0.08), transparent 54%),
    rgba(8, 15, 17, 0.58);
}

.build-queue-panel strong {
  display: block;
  margin-bottom: 5px;
  color: var(--accent);
  text-transform: uppercase;
}

#build-queue-active {
  color: var(--text);
  overflow-wrap: anywhere;
}

#build-queue-list {
  margin: 6px 0 0;
  padding-left: 18px;
}

#build-queue-list li {
  margin: 2px 0;
  overflow-wrap: anywhere;
}

.command-hint {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

#objective-panel ul,
#log {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.4;
  font-size: 14px;
}

#exploration-panel p {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

#research-panel {
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr);
  min-height: 0;
  padding-right: 4px;
  container-type: inline-size;
}

#research-options {
  margin: 10px 0 0;
  padding-left: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  list-style: none;
  max-height: min(48vh, 520px);
  overflow-y: auto;
  padding-right: 14px;
  scrollbar-gutter: stable;
  scrollbar-color: #53636a #141b1e;
}

#research-options li {
  margin-bottom: 7px;
}

#research-options .research-branch-title {
  margin: 12px 0 5px;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

#research-options button {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
  align-items: start;
  min-height: 86px;
  padding: 7px 6px;
  text-align: left;
}

#research-options .research-item-header {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  min-width: 0;
}

#research-options .research-item-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(85, 214, 194, 0.48);
  border-radius: 3px;
  background:
    linear-gradient(135deg, rgba(85, 214, 194, 0.18), rgba(12, 22, 25, 0.88)),
    #142125;
  color: var(--accent);
  font-size: 18px;
  line-height: 1;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.36);
}

#research-options .research-item-text {
  display: grid;
  min-width: 0;
  gap: 1px;
}

#research-options .research-item-title-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 6px;
  align-items: center;
  min-width: 0;
}

#research-options .research-item-title {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#research-options .research-item-cost {
  color: var(--warn);
  font-size: 11px;
  white-space: nowrap;
}

#research-options .research-item-status {
  padding: 2px 5px;
  border: 1px solid rgba(85, 214, 194, 0.32);
  border-radius: 3px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

#research-options .research-item-status--available {
  color: var(--accent);
  border-color: rgba(85, 214, 194, 0.58);
}

#research-options .research-item-status--in-progress {
  color: var(--warn);
  border-color: rgba(255, 207, 90, 0.62);
}

#research-options .research-item-status--complete {
  color: var(--accent);
  border-color: rgba(85, 214, 194, 0.68);
}

#research-options .research-item-meta,
#research-options .research-item-description,
#research-options .research-item-summary {
  display: block;
}

#research-options .research-item-meta {
  color: var(--accent);
  font-size: 10px;
  line-height: 1.15;
  text-transform: uppercase;
}

#research-options .research-item-description {
  color: var(--text);
  font-size: 11px;
  line-height: 1.25;
}

#research-options .research-item-summary {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

#research-options button.locked {
  opacity: 1;
}

#research-options button.done {
  border-color: var(--accent);
  color: var(--accent);
}

#research-options button.active {
  border-color: var(--warn);
  color: var(--warn);
}

#research-options button.available {
  border-color: rgba(85, 214, 194, 0.72);
}

#research-options button:hover .research-item-icon,
#research-options button.active .research-item-icon {
  border-color: var(--warn);
  color: var(--warn);
  box-shadow:
    inset 0 0 0 1px rgba(255, 207, 90, 0.24),
    0 0 10px rgba(85, 214, 194, 0.22);
}

#research-options button.research-unavailable {
  border-color: rgba(92, 104, 108, 0.5);
  background:
    linear-gradient(180deg, rgba(52, 61, 64, 0.72), rgba(30, 37, 39, 0.76));
  color: #8d9692;
  cursor: not-allowed;
  filter: grayscale(0.75) saturate(0.45);
}

#research-options button.research-unavailable .research-item-icon {
  border-color: #3a4144;
  color: #837f70;
  background: #1b2022;
  box-shadow: none;
}

#research-options button.research-unavailable .research-item-title,
#research-options button.research-unavailable .research-item-cost,
#research-options button.research-unavailable .research-item-status,
#research-options button.research-unavailable .research-item-meta,
#research-options button.research-unavailable .research-item-description,
#research-options button.research-unavailable .research-item-summary {
  color: #837f70;
}

#research-options button.research-unavailable .research-item-status {
  border-color: #3a4144;
}

#research-options button.research-unavailable:hover {
  border-color: rgba(116, 120, 104, 0.58);
  background:
    linear-gradient(180deg, rgba(52, 61, 64, 0.72), rgba(30, 37, 39, 0.76));
  color: #8d9692;
  box-shadow: inset 0 0 0 1px rgba(255, 207, 90, 0.08);
}

#research-options button.research-unavailable:hover .research-item-icon {
  border-color: #5a5f57;
  color: #9a967f;
  box-shadow: none;
}

.research-progress {
  position: relative;
  display: block;
  height: 16px;
  overflow: hidden;
  border: 1px solid rgba(255, 207, 90, 0.38);
  background: rgba(0, 0, 0, 0.28);
}

.research-progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, rgba(255, 207, 90, 0.35), rgba(85, 214, 194, 0.42));
}

.research-progress-label {
  position: relative;
  display: block;
  padding: 1px 5px;
  color: var(--text);
  font-size: 10px;
  line-height: 14px;
  text-align: center;
}

#research-options button.done::after {
  content: none;
}

.explore-stat {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(70px, auto);
  align-items: start;
  gap: 10px;
  min-width: 0;
  padding: 7px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 14px;
}

.explore-stat strong {
  min-width: 0;
  color: var(--warn);
  text-align: right;
  overflow-wrap: anywhere;
}

#research-panel .explore-stat {
  grid-template-columns: minmax(112px, 0.8fr) minmax(0, 1.2fr);
}

#research-generation-status {
  font-size: 13px;
  line-height: 1.15;
}

@container (max-width: 280px) {
  #research-panel .explore-stat {
    grid-template-columns: minmax(0, 1fr);
    gap: 3px;
  }

  #research-panel .explore-stat strong {
    text-align: left;
  }
}

#active-research {
  max-width: 100%;
  text-align: right;
  overflow-wrap: anywhere;
}

#mission-title {
  margin-bottom: 16px;
  color: var(--text);
  font-size: 15px;
}

#objective-panel h2 + ul,
#tech-objectives {
  padding-left: 0;
  list-style: none;
}

#objective-panel li,
#tech-objectives li {
  position: relative;
  min-height: 24px;
  margin-bottom: 7px;
  padding-left: 26px;
}

#objective-panel li::before,
#tech-objectives li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 3px;
  width: 14px;
  height: 14px;
  border: 1px solid #68777d;
  background: #161c1f;
}

#objective-panel li.done,
#tech-objectives li.done {
  color: var(--accent);
}

#objective-panel li.done::before,
#tech-objectives li.done::before {
  content: "✓";
  border-color: var(--accent);
  background: #1e4a45;
  color: #d9fff7;
  font-size: 12px;
  line-height: 14px;
  text-align: center;
}

#right-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto minmax(170px, 34%);
  min-height: 0;
  overflow: hidden;
  overscroll-behavior: contain;
}

#right-panel section {
  border-bottom: 0;
}

.info-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
  padding: 10px 10px 8px;
  border-bottom: 2px solid #141b1e;
}

.info-tab {
  min-width: 0;
  aspect-ratio: 1 / 1;
  min-height: 36px;
  justify-content: center;
  padding: 4px;
  font-size: 18px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab-icon {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: var(--muted);
}

.tab-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.info-tab.active {
  border-color: var(--accent);
  background: linear-gradient(#486263, #263d3f);
  color: #f8fff9;
}

.info-tab.active .tab-icon {
  color: var(--warn);
}

.info-tab-content {
  min-height: 0;
  overflow: hidden;
  border-bottom: 2px solid #141b1e;
}

.info-tab-panel {
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: #53636a #141b1e;
}

#log {
  max-height: none;
  min-height: 0;
  padding-left: 0;
  padding-right: 8px;
  font-size: 12px;
  line-height: 1.32;
  overflow-wrap: anywhere;
  list-style: none;
}

#log li {
  margin-bottom: 5px;
  padding: 0 0 5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.log-entry {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  color: #d8d5c2;
}

.log-tag {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 1px solid currentColor;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 35%, rgba(255, 255, 255, 0.12), transparent 54%),
    rgba(0, 0, 0, 0.24);
  font-size: 11px;
  font-weight: bold;
  line-height: 1;
  text-align: center;
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.38),
    0 0 7px color-mix(in srgb, currentColor 24%, transparent);
}

.log-text {
  min-width: 0;
}

.log-info { color: #d8d5c2; }
.log-discovery { color: #55d6c2; }
.log-success { color: #57df72; }
.log-warning { color: #ffcf5a; }
.log-danger { color: #ff8d6b; }
.log-research { color: #caa8ff; }
.log-diplomacy { color: #86b8ff; }
.log-system { color: #9ca7a5; }

.log-info .log-tag {
  font-style: italic;
}

.log-warning .log-tag,
.log-danger .log-tag {
  border-radius: 3px;
}

.log-danger .log-tag {
  font-size: 9px;
}

.persistent-log-panel {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: #53636a #141b1e;
}

.persistent-log-panel h2 {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 0 0 8px;
  padding: 0 0 7px;
  background: linear-gradient(#242d31, #20282b);
  border-bottom: 1px solid rgba(85, 214, 194, 0.18);
}

#map-wrap {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  height: 100%;
  border: 2px solid #53636a;
  background:
    radial-gradient(circle at 50% 20%, rgba(85, 214, 194, 0.08), transparent 34%),
    linear-gradient(#273033, #171d1f 55%, #111618);
  box-shadow:
    inset 0 0 0 3px #111719,
    0 10px 24px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

#game {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 1120 / 760;
  image-rendering: auto;
  cursor: grab;
  filter: saturate(1.05) contrast(1.02);
}

#game:active {
  cursor: grabbing;
}

#minimap {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: clamp(118px, 13vw, 180px);
  height: clamp(118px, 13vw, 180px);
  border: 2px solid rgba(122, 211, 255, 0.55);
  background: rgba(5, 12, 17, 0.84);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.42);
  image-rendering: pixelated;
  pointer-events: none;
}

#left-panel,
#right-panel {
  position: relative;
}

#left-panel::before,
#right-panel::before {
  content: "";
  position: absolute;
  inset: 6px;
  pointer-events: none;
  border: 1px solid rgba(85, 214, 194, 0.18);
}

#pause-banner {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(6, 9, 10, 0.48);
  color: var(--warn);
  font-size: 42px;
  text-transform: uppercase;
  letter-spacing: 0;
}

#pause-banner[hidden] {
  display: none;
}

.overlay-panel {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(5, 8, 9, 0.78);
}

.menu-screen {
  place-items: start center;
  padding-top: clamp(420px, 52vh, 620px);
  background:
    linear-gradient(90deg, rgba(5, 8, 9, 0.28), rgba(5, 8, 9, 0.76) 56%, rgba(5, 8, 9, 0.92)),
    radial-gradient(circle at 32% 34%, rgba(85, 214, 194, 0.14), transparent 26%),
    radial-gradient(circle at 72% 70%, rgba(255, 207, 90, 0.09), transparent 28%),
    linear-gradient(145deg, #071012 0%, #11191d 48%, #050708 100%);
  overflow: hidden;
}

.menu-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    var(--main-menu-art),
    radial-gradient(circle at 22% 25%, rgba(255,255,255,0.12) 0 1px, transparent 1px),
    radial-gradient(circle at 76% 18%, rgba(255,255,255,0.1) 0 1px, transparent 1px),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.018) 0 1px, transparent 1px 6px);
  background-size: cover, auto, auto;
  background-position: center;
  opacity: 0.6;
  image-rendering: auto;
}

.menu-screen.has-menu-art::before {
  background-position: center top, center, center;
}

.menu-screen:not(.has-menu-art)::before {
  background:
    radial-gradient(circle at 12% 18%, rgba(255,255,255,0.18) 0 1px, transparent 1px),
    radial-gradient(circle at 33% 42%, rgba(255,255,255,0.1) 0 1px, transparent 1px),
    radial-gradient(circle at 73% 26%, rgba(255,255,255,0.13) 0 1px, transparent 1px),
    radial-gradient(ellipse at 36% 75%, rgba(85,214,194,0.18), transparent 0 16%, transparent 17%),
    linear-gradient(180deg, transparent 0 62%, rgba(21, 31, 31, 0.6) 62% 100%),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.018) 0 1px, transparent 1px 22px);
}

.menu-backdrop {
  background:
    linear-gradient(90deg, rgba(5, 8, 9, 0.28), rgba(5, 8, 9, 0.76) 56%, rgba(5, 8, 9, 0.92)),
    radial-gradient(circle at 32% 34%, rgba(85, 214, 194, 0.14), transparent 26%),
    radial-gradient(circle at 72% 70%, rgba(255, 207, 90, 0.09), transparent 28%),
    linear-gradient(145deg, #071012 0%, #11191d 48%, #050708 100%);
  overflow: hidden;
}

.menu-backdrop::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    var(--main-menu-art),
    radial-gradient(circle at 22% 25%, rgba(255,255,255,0.12) 0 1px, transparent 1px),
    radial-gradient(circle at 76% 18%, rgba(255,255,255,0.1) 0 1px, transparent 1px),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.018) 0 1px, transparent 1px 6px);
  background-size: cover, auto, auto;
  background-position: center top, center, center;
  opacity: 0.6;
}

.menu-backdrop > div {
  position: relative;
  z-index: 1;
}

.overlay-panel > div {
  width: min(520px, 100%);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  border: 2px solid var(--line);
  background: #1c2427;
  padding: 24px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

.menu-screen > div,
.overlay-panel > .main-menu-card {
  position: relative;
  z-index: 1;
  pointer-events: auto;
  width: min(720px, 100%);
  margin: 0;
  border-color: rgba(85, 214, 194, 0.65);
  background:
    linear-gradient(90deg, rgba(85,214,194,0.12), transparent 44%),
    rgba(18, 26, 29, 0.92);
  box-shadow:
    inset 0 0 0 2px #081011,
    0 24px 80px rgba(0, 0, 0, 0.6);
}

.main-menu-card h2 {
  color: var(--warn);
  font-size: clamp(24px, 2.4vw, 34px);
  line-height: 1;
  text-align: center;
}

.menu-tagline {
  display: block;
  max-width: 64ch;
  margin: 12px auto 14px;
  color: var(--accent);
  font-size: clamp(15px, 1.35vw, 18px);
  line-height: 1.35;
  text-align: center;
}

.main-menu-card p {
  max-width: 62ch;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
  font-size: 14px;
  line-height: 1.55;
}

.menu-actions {
  display: grid;
  gap: 9px;
  margin-top: 20px;
}

.menu-actions button {
  min-height: 42px;
  justify-content: center;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.menu-note {
  margin-top: 14px;
  font-size: 11px;
  color: #7f918f;
  text-align: center;
}

.credits-card {
  text-align: center;
  width: min(760px, 100%);
}

.credits-card p {
  max-width: 70ch;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
  overflow-wrap: anywhere;
}

.credits-card h2 {
  text-align: center;
  overflow-wrap: anywhere;
}

.credits-logo {
  display: block;
  width: 100%;
  max-width: 520px;
  max-height: 220px;
  object-fit: contain;
  margin: 0 auto 22px;
  padding: 14px;
  border: 2px solid rgba(85, 214, 194, 0.55);
  background:
    linear-gradient(135deg, rgba(85, 214, 194, 0.12), transparent 42%),
    #030607;
  box-shadow:
    inset 0 0 0 2px rgba(0, 0, 0, 0.85),
    0 10px 28px rgba(0, 0, 0, 0.36);
}

.credits-logo[hidden] {
  display: none;
}

.overlay-panel > .briefing-card {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(360px, 1.3fr);
  gap: 22px;
  border-color: rgba(85, 214, 194, 0.62);
  background:
    linear-gradient(135deg, rgba(85, 214, 194, 0.1), transparent 38%),
    linear-gradient(#172225, #101719);
}

@media (max-width: 860px) {
  .overlay-panel > .briefing-card {
    grid-template-columns: 1fr;
  }

  .briefing-portrait-frame {
    min-height: 260px;
  }
}

.briefing-profile {
  display: grid;
  gap: 14px;
  align-content: start;
}

.briefing-portrait-frame {
  position: relative;
  overflow: hidden;
  min-height: 360px;
  border: 2px solid rgba(85, 214, 194, 0.42);
  background:
    linear-gradient(90deg, rgba(85, 214, 194, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(85, 214, 194, 0.06) 1px, transparent 1px),
    #071012;
  background-size: 18px 18px;
  box-shadow: inset 0 0 0 2px #060b0d;
}

.briefing-portrait {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 520px;
  object-fit: contain;
  object-position: center bottom;
}

.briefing-portrait[hidden] {
  display: none;
}

.briefing-portrait-placeholder {
  position: absolute;
  inset: 18px;
  display: grid;
  place-items: center;
  gap: 8px;
  align-content: center;
  border: 1px dashed rgba(85, 214, 194, 0.42);
  color: var(--muted);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.briefing-portrait-placeholder[hidden] {
  display: none;
}

.briefing-portrait-placeholder strong {
  color: var(--accent);
}

.briefing-portrait-placeholder span {
  font-size: 12px;
}

.briefing-profile-text {
  padding: 14px;
  border: 1px solid rgba(255, 207, 90, 0.24);
  background: rgba(5, 9, 10, 0.42);
  text-align: center;
  text-transform: uppercase;
}

.briefing-profile-text span,
.briefing-profile-text em {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  letter-spacing: 0.08em;
}

.briefing-profile-text strong {
  display: block;
  margin: 6px 0;
  color: #d7fbff;
  font-size: clamp(26px, 3vw, 42px);
  line-height: 1;
  letter-spacing: 0.03em;
}

.briefing-content {
  min-width: 0;
}

.briefing-content h2 {
  margin-bottom: 16px;
  color: var(--warn);
  font-size: clamp(22px, 2.4vw, 32px);
}

.briefing-content h3 {
  margin: 18px 0 8px;
  color: var(--accent);
  font-size: 15px;
  text-transform: uppercase;
}

.briefing-content p {
  max-width: 72ch;
  margin: 0 0 12px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
}

.briefing-objectives {
  display: grid;
  gap: 7px;
  margin: 0 0 18px;
  padding-left: 0;
  list-style: none;
}

.briefing-objectives li {
  position: relative;
  padding-left: 24px;
  color: var(--muted);
}

.briefing-objectives li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.45em;
  width: 10px;
  height: 10px;
  border: 1px solid var(--accent);
  background: rgba(85, 214, 194, 0.18);
}

.briefing-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mission-debriefing {
  z-index: 12;
}

.debriefing-card {
  max-height: calc(100vh - 48px);
  overflow: hidden;
}

.debriefing-card .briefing-content {
  overflow: auto;
  padding-right: 4px;
}

.debriefing-outcomes li::before {
  display: grid;
  place-items: center;
  border-color: rgba(77, 224, 120, 0.9);
  background: rgba(77, 224, 120, 0.22);
  color: #4de078;
  content: "✓";
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.debriefing-final-line {
  color: #d7fbff;
  font-weight: 700;
}

.debriefing-milestone {
  display: block;
  margin: 0 0 14px;
  color: var(--accent);
  font-style: normal;
}

.debriefing-milestone[hidden] {
  display: none;
}

.debriefing-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 760px) {
  .debriefing-actions {
    grid-template-columns: 1fr;
  }
}

.settings-row {
  display: grid;
  grid-template-columns: 130px minmax(120px, 1fr);
  align-items: center;
  gap: 12px;
  margin: 14px 0;
  color: var(--muted);
}

.settings-row input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.settings-check {
  grid-template-columns: auto 1fr;
  justify-content: start;
}

.overlay-panel h2 {
  color: var(--warn);
  font-size: 25px;
}

.overlay-panel p,
.overlay-panel li {
  color: var(--muted);
  line-height: 1.45;
}

.overlay-panel ul {
  margin: 14px 0 18px;
  padding-left: 20px;
}

.overlay-panel button {
  justify-content: center;
}

#region-map {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.region-node {
  min-height: 62px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  justify-content: stretch;
  text-align: left;
}

.region-node strong {
  color: var(--text);
}

.region-node span {
  color: var(--warn);
}

.region-node.secured {
  border-color: var(--accent);
}

.region-node.secured span {
  color: var(--accent);
}

.region-node.locked {
  opacity: 0.62;
}

@media (max-width: 1180px) {
  #topbar {
    grid-template-columns: minmax(210px, 0.8fr) minmax(360px, 1.4fr) auto;
    align-items: stretch;
  }

  #status-strip {
    grid-template-columns: repeat(4, minmax(70px, 1fr));
  }

  #game-actions {
    justify-content: flex-end;
    align-content: center;
  }

  #game-actions button {
    min-width: 32px;
  }

  #play-area {
    grid-template-columns: 210px minmax(360px, 1fr) 220px;
    gap: 8px;
  }

  aside {
    font-size: 13px;
  }

  aside section {
    padding: 8px;
  }

  button {
    min-height: 31px;
    padding: 6px 7px;
  }
}

@media (max-height: 760px) {
  #app {
    padding: 6px;
  }

  #game-shell {
    height: calc(100vh - 12px);
    gap: 6px;
  }

  #topbar {
    padding: 6px 8px;
  }

  h1 {
    font-size: 18px;
  }

  h2 {
    margin-bottom: 7px;
    font-size: 13px;
  }

  p,
  #objective-panel ul,
  #log,
  .explore-stat {
    font-size: 12px;
  }

  #status-strip .status-box {
    padding: 4px 6px;
  }

  #status-strip strong {
    font-size: 12px;
  }

  #status-strip .status-box {
    min-height: 38px;
  }

  .menu-screen {
    padding-top: clamp(245px, 40vh, 340px);
  }

  .main-menu-card {
    padding: 18px;
  }

  .menu-actions {
    gap: 7px;
    margin-top: 14px;
  }

  .overlay-panel > .briefing-card {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .briefing-portrait-frame {
    min-height: 220px;
  }

  .briefing-content p,
  .briefing-objectives li {
    font-size: 12px;
  }
}
.loading-status {
  position: fixed;
  left: 50%;
  top: 14px;
  z-index: 1000;
  transform: translateX(-50%);
  padding: 8px 14px;
  border: 1px solid rgba(122, 211, 255, 0.45);
  background: rgba(7, 15, 24, 0.92);
  color: #d7f4ff;
  font-size: 13px;
  letter-spacing: 0.02em;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.loading-status--error {
  border-color: rgba(255, 105, 94, 0.8);
  color: #ffd7d2;
  background: rgba(43, 12, 15, 0.95);
}

.loading-status--hidden {
  display: none;
}
