* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, sans-serif;
  background: #15171c;
  color: #e8eaed;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px;
}

.topbar {
  width: 2048px;
  max-width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.credit {
  font-size: 20px;
  font-weight: 700;
  color: #5cd17a;
  font-variant-numeric: tabular-nums;
  margin-left: auto;
  margin-right: 8px;
}

/* ── Asset details (top-left) ── */
.asset {
  width: max-content;        /* width adapts to the content */
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 14px;                 /* fields laid out side by side */
  white-space: nowrap;
  overflow: hidden;          /* never a scrollbar */
  background: #20242c;
  border: 1px solid #353b45;
  border-radius: 8px;
  padding: 4px 12px;
  font-size: 13px;
}
.asset .atitle {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #9aa0aa;
}
.asset .muted { color: #8b919c; }
.asset .ai {
  display: flex;
  flex-direction: column;    /* tiny label over its value */
  line-height: 1.15;
}
.asset .ai i {
  font-style: normal;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #9aa0aa;
}
.asset .ai b { font-weight: 600; }
.asset select {
  background: #2a2e36;
  color: #e8eaed;
  border: 1px solid #3a3f49;
  border-radius: 5px;
  padding: 1px 4px;
  font-size: 12px;
}

h1 {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
}

.tools {
  display: flex;
  align-items: center;
  gap: 18px;
}

.legend {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 14px;
  font-size: 13px;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sw {
  width: 13px;
  height: 13px;
  border-radius: 3px;
  display: inline-block;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

button {
  background: #2c7be5;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
}
button:hover { background: #1f63c0; }

.modes {
  display: flex;
  gap: 6px;
}

.modes .mode {
  background: #2a2f38;
}
.modes .mode:hover { background: #353b45; }
.modes .mode.active {
  background: #2c7be5;
  box-shadow: inset 0 0 0 2px #5cd17a;
}

#invert-dir {
  background: #6b5b95;
}
#invert-dir:hover { background: #574a7c; }

#auto-toggle {
  background: #2f8f5b;
}
#auto-toggle:hover { background: #267a4c; }
#auto-toggle.active {
  background: #36c07a;
  box-shadow: inset 0 0 0 2px #ffd83b;
}

#vehicle-menu .row {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

#vehicle-menu select {
  width: 100%;
  background: #2a2e36;
  color: #e8eaed;
  border: 1px solid #3a3f49;
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
}

main {
  position: relative;
  width: 100%;
  height: 78vh;
  overflow: hidden;
  background: #0e0f12;
  border: 1px solid #2a2e36;
  border-radius: 6px;
}

#mine,
#roads-layer,
#vehicle-layer {
  position: absolute;
  top: 0;
  left: 0;
}
#mine { z-index: 0; cursor: crosshair; }
/* Roads sit above the grid; the vehicles sit above the roads. */
#roads-layer {
  z-index: 1;
  pointer-events: none; /* toggled to "auto" in road / erase mode */
}
#vehicle-layer {
  z-index: 2;
  pointer-events: none; /* let clicks reach the mine canvas */
}

.hint {
  font-size: 12px;
  color: #8b919c;
  margin: 0;
}

/* ── Popup ── */
.popup {
  display: none;
  position: fixed;
  z-index: 10;
  width: 220px;
  background: #20242c;
  border: 1px solid #353b45;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  padding: 10px 12px 12px;
  font-size: 13px;
}

.popup header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  margin-bottom: 8px;
}

.popup .close {
  background: none;
  color: #9aa0aa;
  font-size: 18px;
  line-height: 1;
  padding: 0 4px;
}
.popup .close:hover { color: #fff; background: none; }

.popup .bar {
  display: flex;
  height: 10px;
  width: 100%;
  border-radius: 5px;
  overflow: hidden;
  background: #2a2e36;
  margin-bottom: 10px;
}
.popup .bar .seg { height: 100%; }

.popup .row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
}
.popup .row .label { flex: 1; }
.popup .row .pct { color: #c7ccd4; font-variant-numeric: tabular-nums; }
.popup .row.muted { color: #8b919c; }

.popup .swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.popup .unknown {
  color: #8b919c;
  padding: 6px 0 12px;
}

.popup .note {
  color: #e86a6a;
  font-size: 12px;
  padding-bottom: 8px;
}

.popup .drill {
  width: 100%;
  background: #d98a2b;
  font-weight: 600;
}
.popup .drill:hover { background: #c2761c; }

.popup .total {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #353b45;
  color: #9aa0aa;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* ── Shop (buy assets) ── */
.shop-btn {
  background: #2f8f5b;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.shop-btn:hover { background: #267a4c; }

.shop-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.shop-modal[hidden] { display: none; }

.shop-card {
  width: min(460px, 92vw);
  background: #20242c;
  border: 1px solid #353b45;
  border-radius: 10px;
  padding: 14px 16px;
  color: #e8eaed;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.shop-head {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 8px;
}
.shop-meta { margin-left: auto; font-size: 12px; font-weight: 500; color: #9aa0aa; }
.shop-close {
  background: none; border: none; color: #9aa0aa;
  font-size: 20px; line-height: 1; padding: 0 4px; cursor: pointer;
}
.shop-close:hover { color: #fff; background: none; }

.shop-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid #2a2e36;
}
.shop-info { display: flex; flex-direction: column; gap: 2px; }
.shop-info b { font-size: 14px; }
.shop-spec { font-size: 12px; color: #9aa0aa; }
.shop-price {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  color: #5cd17a;
  font-weight: 600;
}
.shop-buy {
  background: #2c7be5; color: #fff; border: none; border-radius: 6px;
  padding: 6px 10px; font-weight: 600; min-width: 88px; cursor: pointer;
}
.shop-buy:hover:not(:disabled) { background: #1f63c0; }
.shop-buy:disabled { background: #3a3f49; color: #8b919c; cursor: not-allowed; }
