html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: Arial, Helvetica, sans-serif;
  background: #071016;
  color: #e8f5f0;
}

#application-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

#loadingScreen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: #071016;
  color: #e8f5f0;
}

#campSelectScreen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background:
    linear-gradient(rgba(7, 16, 22, 0.78), rgba(7, 16, 22, 0.92)),
    radial-gradient(circle at 50% 35%, rgba(126, 209, 143, 0.16), transparent 44%);
  color: #e8f5f0;
}

#campSelectScreen.hidden {
  display: none;
}

#campSelectPanel {
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 18px;
  border: 1px solid rgba(148, 235, 208, 0.32);
  border-radius: 8px;
  background: rgba(5, 13, 17, 0.9);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.46);
}

#campSelectPanel h1 {
  margin: 0 0 14px;
  color: #9cefc1;
  font-size: 18px;
  line-height: 1.2;
}

#campSelectOptions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.camp-column {
  display: grid;
  align-content: start;
  gap: 10px;
  min-width: 0;
}

.camp-column h2 {
  margin: 0 0 2px;
  color: #8fcfba;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.2;
  text-transform: uppercase;
}

.camp-option {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px;
  text-align: left;
}

.camp-option span {
  font-size: 15px;
}

.camp-option strong {
  color: #f4d85a;
  font-size: 13px;
}

@media (max-width: 680px) {
  #campSelectPanel {
    width: min(520px, calc(100vw - 32px));
  }

  #campSelectOptions {
    grid-template-columns: 1fr;
  }
}

#loadingScreen.hidden {
  display: none;
}

#loadingPanel {
  width: min(420px, calc(100vw - 48px));
}

#loadingTitle {
  margin-bottom: 12px;
  font-size: 15px;
  font-weight: 700;
}

#loadingTrack {
  height: 12px;
  overflow: hidden;
  border: 1px solid rgba(148, 235, 208, 0.36);
  border-radius: 6px;
  background: rgba(2, 9, 12, 0.8);
}

#loadingBar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #d5a33a, #f4d85a 48%, #7ed18f);
  transition: width 160ms ease;
}

#loadingText {
  min-height: 18px;
  margin-top: 10px;
  color: #b8cac4;
  font-size: 12px;
}

#topbar {
  --topbar-control-height: 34px;
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  pointer-events: none;
  z-index: 2;
}

button {
  border: 1px solid rgba(148, 235, 208, 0.36);
  background: rgba(9, 24, 30, 0.86);
  color: #e8f5f0;
  padding: 8px 10px;
  border-radius: 6px;
  font-weight: 700;
  cursor: pointer;
}

button:hover,
button.active {
  border-color: #60d894;
  background: rgba(18, 68, 54, 0.92);
}

button:disabled {
  color: #758078;
  border-color: rgba(140, 140, 140, 0.22);
  background: rgba(26, 28, 30, 0.75);
  cursor: not-allowed;
}

#backpackButton,
#buildingsButton,
#roversButton,
#backpackDock,
#campSelectButton,
#reloadFreshButton,
#debugControl,
#debugDrawerButton,
#debugDrawerPanel,
#lightingDebugButton,
#debugStartNcButton,
#terrainPackControl,
#terrainPackButton,
#terrainPackPopover,
#skyboxControl,
#skyboxButton,
#skyboxPopover,
#boundsToggle,
.panel,
#yardPanel button,
#boundsDebugPanel button {
  pointer-events: auto;
}

#backpackDock {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  max-height: calc(100vh - 24px);
  z-index: 3;
}

#dockPanels,
#dockButtons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  max-width: calc(100vw - 24px);
}

#dockPanels {
  align-items: flex-end;
  flex-wrap: wrap;
}

#dockButtons {
  align-items: center;
}

#backpackDock .panel {
  position: static;
}

#backpackDock #boundsDebugPanel {
  width: 270px;
  max-height: min(34vh, 260px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: rgba(244, 216, 90, 0.72) rgba(2, 9, 12, 0.62);
  scrollbar-width: thin;
}

#backpackPanel,
#buildingsPanel,
#roversPanel {
  --drawer-visible-items: 5;
  --drawer-row-block: 58px;
  max-height: min(calc(100vh - 116px), calc(45px + var(--drawer-visible-items) * var(--drawer-row-block)));
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: rgba(126, 209, 143, 0.72) rgba(2, 9, 12, 0.62);
  scrollbar-width: thin;
}

#backpackDock #boundsDebugPanel::-webkit-scrollbar,
#backpackPanel::-webkit-scrollbar,
#buildingsPanel::-webkit-scrollbar,
#roversPanel::-webkit-scrollbar {
  width: 9px;
}

#backpackDock #boundsDebugPanel::-webkit-scrollbar-track,
#backpackPanel::-webkit-scrollbar-track,
#buildingsPanel::-webkit-scrollbar-track,
#roversPanel::-webkit-scrollbar-track {
  border-radius: 999px;
  background: rgba(2, 9, 12, 0.62);
  box-shadow: inset 0 0 0 1px rgba(148, 235, 208, 0.12);
}

#backpackDock #boundsDebugPanel::-webkit-scrollbar-thumb,
#backpackPanel::-webkit-scrollbar-thumb,
#buildingsPanel::-webkit-scrollbar-thumb,
#roversPanel::-webkit-scrollbar-thumb {
  border: 2px solid rgba(2, 9, 12, 0.72);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(156, 239, 193, 0.86), rgba(96, 216, 148, 0.72));
}

#backpackDock #boundsDebugPanel::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(244, 216, 90, 0.86), rgba(126, 209, 143, 0.7));
}

#backpackDock #boundsDebugPanel::-webkit-scrollbar-thumb:hover,
#backpackPanel::-webkit-scrollbar-thumb:hover,
#buildingsPanel::-webkit-scrollbar-thumb:hover,
#roversPanel::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(244, 216, 90, 0.92), rgba(96, 216, 148, 0.82));
}

@media (max-width: 620px) {
  #dockPanels {
    flex-direction: column;
    align-items: flex-end;
  }

  #backpackDock .panel {
    width: min(270px, calc(100vw - 24px));
  }

  #backpackDock #boundsDebugPanel {
    width: min(270px, calc(100vw - 24px));
  }
}

.debug-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid rgba(148, 235, 208, 0.28);
  border-radius: 6px;
  background: rgba(9, 24, 30, 0.78);
  color: #cfe3dd;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.debug-toggle input {
  width: 14px;
  height: 14px;
  margin: 0;
}

.topbar-popover {
  position: relative;
}

.debug-drawer {
  width: 280px;
}

.debug-drawer,
.debug-drawer .topbar-popover {
  display: grid;
  gap: 8px;
}

.debug-drawer button,
.debug-drawer .debug-toggle {
  width: 100%;
}

.debug-drawer .debug-toggle {
  justify-content: flex-start;
}

#hudReadout {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-control-height);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  color: #e8f5f0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  font-weight: 800;
  line-height: 16px;
  text-align: center;
  white-space: nowrap;
}

#compassReadout,
#resourceReadout {
  box-sizing: border-box;
  height: var(--topbar-control-height);
  min-height: 0;
  padding: 0 14px;
  border: 1px solid rgba(148, 235, 208, 0.28);
  border-radius: 6px;
  background: rgba(9, 24, 30, 0.78);
  align-items: center;
}

#compassReadout,
#tuReadout,
#wellsReadout {
  min-width: max-content;
}

#compassReadout {
  grid-column: 2;
  display: inline-flex;
  justify-self: center;
  color: #f4d85a;
  line-height: 1;
}

#resourceReadout {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  gap: 28px;
}

#minimap {
  position: absolute;
  top: 58px;
  right: 12px;
  width: 184px;
  aspect-ratio: 1;
  box-sizing: border-box;
  overflow: hidden;
  border: 2px solid rgba(220, 190, 86, 0.74);
  border-radius: 8px;
  background: rgba(4, 12, 15, 0.86);
  box-shadow:
    0 0 0 1px rgba(12, 24, 26, 0.92),
    0 13px 30px rgba(0, 0, 0, 0.42),
    inset 0 0 18px rgba(0, 0, 0, 0.52);
  pointer-events: auto;
  z-index: 1;
}

#minimap::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(244, 216, 90, 0.2);
  border-radius: 5px;
  pointer-events: none;
}

#minimap::after {
  content: "";
  position: absolute;
  top: 7px;
  left: 50%;
  width: 0;
  height: 0;
  border-right: 5px solid transparent;
  border-bottom: 10px solid rgba(244, 216, 90, 0.86);
  border-left: 5px solid transparent;
  transform: translateX(-50%);
  pointer-events: none;
}

#minimapCanvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: auto;
}

@media (max-width: 760px) {
  #hudReadout {
    top: 44px;
    left: 12px;
    right: 12px;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    overflow: hidden;
  }

  #compassReadout {
    grid-column: 2;
  }

  #resourceReadout {
    position: absolute;
    right: 0;
    gap: 14px;
    overflow: hidden;
  }

  #minimap {
    top: 94px;
    width: 138px;
  }
}

.popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 148px;
  padding: 6px;
  border: 1px solid rgba(148, 235, 208, 0.32);
  border-radius: 8px;
  background: rgba(5, 13, 17, 0.95);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.38);
}

#debugDrawerPanel .popover {
  position: static;
  width: 100%;
  margin-top: 6px;
  box-shadow: none;
  background: rgba(2, 9, 12, 0.76);
}

.popover button {
  width: 100%;
  margin: 0;
  padding: 7px 8px;
  border-color: transparent;
  background: transparent;
  text-align: left;
}

.popover button.active {
  border-color: rgba(126, 209, 143, 0.52);
  background: rgba(18, 68, 54, 0.92);
}

.panel {
  position: absolute;
  top: 56px;
  left: 12px;
  width: 270px;
  padding: 10px;
  border: 1px solid rgba(148, 235, 208, 0.28);
  border-radius: 8px;
  background: rgba(6, 14, 18, 0.84);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.35);
}

#yardPanel {
  left: auto;
  right: 12px;
}

#boundsDebugPanel {
  left: auto;
}

.panel.hidden,
.hidden {
  display: none;
}

.panel h2 {
  font-size: 13px;
  margin: 0 0 8px;
  letter-spacing: 0;
  color: #9cefc1;
}

.queue-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.debug-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.debug-row.single-action {
  grid-template-columns: 1fr auto;
}

.debug-row.debug-icon-row.single-action {
  grid-template-columns: 45px minmax(0, 1fr) auto;
}

.debug-row.debug-meter-row {
  grid-template-columns: auto minmax(86px, 1fr) auto;
}

.debug-row.building-action-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.debug-heading {
  display: grid;
  grid-template-columns: 45px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.debug-heading h2 {
  margin: 0;
}

.debug-row span {
  font-size: 12px;
  color: #cfe3dd;
}

.debug-row strong {
  font-size: 12px;
  color: #e8f5f0;
}

.debug-meter {
  display: block;
  height: 7px;
  overflow: hidden;
  border: 1px solid rgba(148, 235, 208, 0.22);
  border-radius: 4px;
  background: rgba(2, 9, 12, 0.72);
}

.debug-meter span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #32ff70, #b8ff7c);
}

.build-row {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding: 8px 10px;
  text-align: left;
}

.build-row.backpack-build-row,
.build-row.icon-only-row {
  grid-template-columns: 45px minmax(0, 1fr);
}

.build-row.icon-build-row {
  grid-template-columns: 45px minmax(0, 1fr) auto;
}

.build-icon {
  width: 45px;
  height: 34px;
  box-sizing: border-box;
  padding: 2px;
  border: 1px solid rgba(148, 235, 208, 0.38);
  border-radius: 4px;
  background: rgba(2, 9, 12, 0.48);
  object-fit: contain;
  image-rendering: pixelated;
}

.backpack-build-copy {
  min-width: 0;
}

.build-row span,
.queue-row span {
  font-size: 12px;
  color: #cfe3dd;
}

.build-row strong {
  font-size: 12px;
  color: inherit;
}

.build-row .row-title,
.build-row .row-subtitle,
.build-row .row-meter {
  display: block;
}

.build-row .row-subtitle {
  margin-top: 3px;
  color: #95aaa4;
}

.build-row .row-meter {
  height: 6px;
  margin-top: 5px;
  overflow: hidden;
  border: 1px solid rgba(148, 235, 208, 0.22);
  border-radius: 3px;
  background: rgba(2, 9, 12, 0.72);
}

.build-row .row-meter span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #32ff70, #b8ff7c);
}

.build-row .row-meter.building span {
  background: linear-gradient(90deg, #d5a33a, #f4d85a);
}

#statusText {
  position: absolute;
  left: 12px;
  bottom: 12px;
  max-width: min(320px, calc(100vw - 24px));
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid rgba(148, 235, 208, 0.22);
  background: rgba(2, 9, 12, 0.72);
  color: #cfe3dd;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  pointer-events: none;
  white-space: pre-line;
}

#prompt {
  position: absolute;
  top: 58px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(860px, calc(100vw - 32px));
  padding: 7px 12px;
  border-radius: 6px;
  border: 1px solid rgba(148, 235, 208, 0.2);
  background: rgba(4, 13, 16, 0.78);
  color: #e8f5f0;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
  pointer-events: none;
}

#prompt:empty {
  display: none;
}

@media (max-width: 760px) {
  #prompt {
    top: 102px;
    max-width: calc(100vw - 24px);
  }
}

#crosshair {
  position: absolute;
  width: 18px;
  height: 18px;
  top: calc(50% - 9px);
  left: calc(50% - 9px);
}

#crosshair::before,
#crosshair::after {
  content: "";
  position: absolute;
  background: rgba(232, 245, 240, 0.75);
}

#crosshair::before {
  left: 8px;
  top: 0;
  width: 2px;
  height: 18px;
}

#crosshair::after {
  top: 8px;
  left: 0;
  height: 2px;
  width: 18px;
}

#selectionBox {
  position: absolute;
  border: 1px solid #70e0ff;
  background: rgba(112, 224, 255, 0.12);
  display: none;
}

.build-progress-sprite {
  position: absolute;
  width: 96px;
  height: 12px;
  overflow: hidden;
  border: 1px solid rgba(22, 255, 105, 0.9);
  border-radius: 2px;
  background: rgba(2, 18, 9, 0.72);
  box-shadow: 0 0 10px rgba(48, 255, 126, 0.24);
  pointer-events: none;
}

.build-progress-sprite.hidden {
  display: none;
}

.build-progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #32ff70, #b8ff7c);
}
