/* SimPort — SC2000-inspired styling */

:root {
  --ui-bg:           #2a2a2a;
  --ui-bg2:          #333;
  --ui-bg3:          #3d3d3d;
  --ui-border:       #1a1a1a;
  --ui-border-light: #555;
  --ui-text:         #c8c8c8;
  --ui-text-bright:  #e8e8e8;
  --ui-text-dim:     #888;
  --ui-accent:       #4a7a9b;
  --ui-accent2:      #2a5a7b;
  --ui-green:        #4a9b4a;
  --ui-red:          #9b4a4a;
  --ui-yellow:       #9b9b4a;
  --btn-face:        #3a3a3a;
  --btn-hi:          #555;
  --btn-sh:          #1a1a1a;
  --font:            'Courier New', monospace;

  /* zone tints */
  --zone-residential: #1a3a5c;
  --zone-industrial:  #5c3a0a;
  --zone-community:   #1a1a5c;
}

/* ─── RESET ─── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; user-select: none; }
h1, h2, h3 { font: inherit; font-weight: normal; }
dl, dt, dd  { display: block; }
menu        { list-style: none; padding: 0; margin: 0; }
hr          { border: none; }
[hidden]    { display: none !important; }

body {
  background: #111;
  color: var(--ui-text);
  font-family: var(--font);
  font-size: 11px;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

/* ─── MENU BAR ─── */
#menubar {
  height: 24px;
  background: var(--ui-bg);
  border-bottom: 2px solid var(--ui-border);
  display: flex;
  align-items: center;
  padding: 0 4px;
  gap: 4px;
  flex-shrink: 0;
}

.menu-group {
  display: flex;
  gap: 2px;
  flex: 1;
}

.menu-btn {
  background: var(--btn-face);
  color: var(--ui-text-bright);
  border: 1px solid var(--btn-sh);
  border-top-color: var(--btn-hi);
  border-left-color: var(--btn-hi);
  padding: 2px 8px;
  cursor: pointer;
  font: inherit;
  letter-spacing: 0.5px;
}
.menu-btn:hover  { background: var(--btn-hi); }
.menu-btn:active {
  border-top-color: var(--btn-sh); border-left-color: var(--btn-sh);
  border-bottom-color: var(--btn-hi); border-right-color: var(--btn-hi);
}

#date-display {
  color: var(--ui-yellow);
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 1px;
  padding: 0 12px;
  border-inline: 1px solid var(--ui-border-light);
}

#funds-display {
  color: var(--ui-green);
  font-size: 12px;
  font-weight: bold;
  padding: 0 12px;
}

/* ─── MAIN AREA ─── */
#main-area {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ─── TOOLBAR ─── */
#toolbar {
  width: 44px;
  background: var(--ui-bg);
  border-right: 2px solid var(--ui-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 2px;
  gap: 2px;
  overflow-y: auto;
  flex-shrink: 0;
}
#toolbar::-webkit-scrollbar        { width: 4px; }
#toolbar::-webkit-scrollbar-track  { background: var(--ui-bg); }
#toolbar::-webkit-scrollbar-thumb  { background: var(--ui-border-light); }

.tool-group {
  display: contents; /* children lay out in the flex column */
}

.tool-section-label {
  color: var(--ui-text-dim);
  font-size: 7px;
  letter-spacing: 0.5px;
  text-align: center;
  width: 100%;
  margin-top: 4px;
}

.tool-btn {
  position: relative;
  width: 36px;
  height: 30px;
  background: var(--btn-face);
  color: var(--ui-text-bright);
  border: 1px solid var(--btn-sh);
  border-top-color: var(--btn-hi);
  border-left-color: var(--btn-hi);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.tool-btn:hover  { background: var(--btn-hi); color: #fff; }
.tool-btn.tool-locked,
.tool-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}
.tool-btn.active {
  background: var(--ui-accent2);
  border-color: var(--ui-accent);
  color: #fff;
  box-shadow: inset 0 0 4px rgba(0,0,0,.5);
}

/* zone colour variants */
.zone-btn.zone-residential { background: var(--zone-residential); }
.zone-btn.zone-industrial  { background: var(--zone-industrial); }
.zone-btn.zone-community   { background: var(--zone-community); }

.tool-divider {
  width: 32px;
  height: 1px;
  background: var(--ui-border-light);
  margin: 4px 0;
  flex-shrink: 0;
}

/* hr used as divider inside toolbar aside */
#toolbar hr.tool-divider { width: 32px; }

/* ─── VIEWPORT ─── */
#viewport-container {
  flex: 1;
  background: #000;
  position: relative;
  overflow: hidden;
}

#game-canvas {
  display: block;
  cursor: crosshair;
  image-rendering: pixelated;
}

/* ─── MINIMAP ─── */
#minimap-container {
  position: absolute;
  bottom: 8px;
  right: 8px;
  border: 2px solid var(--ui-border-light);
  background: #000;
  line-height: 0; /* remove gap under canvas */
}

#minimap { display: block; }

/* ─── SPEED CONTROLS ─── */
#speed-controls {
  position: absolute;
  bottom: 8px;
  left: 8px;
  display: flex;
  gap: 2px;
}

.speed-btn {
  background: var(--btn-face);
  color: var(--ui-text);
  border: 1px solid var(--btn-sh);
  border-top-color: var(--btn-hi);
  border-left-color: var(--btn-hi);
  padding: 2px 6px;
  cursor: pointer;
  font: inherit;
  font-size: 10px;
}
.speed-btn.active { background: var(--ui-accent2); color: #fff; }
.speed-btn:hover  { background: var(--btn-hi); }

/* ─── INFO PANEL ─── */
#info-panel {
  width: 160px;
  background: var(--ui-bg);
  border-left: 2px solid var(--ui-border);
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  flex-shrink: 0;
}
#info-panel::-webkit-scrollbar       { width: 4px; }
#info-panel::-webkit-scrollbar-track { background: var(--ui-bg); }
#info-panel::-webkit-scrollbar-thumb { background: var(--ui-border-light); }

#info-title {
  text-align: center;
  font-size: 16px;
  font-weight: bold;
  color: var(--ui-accent);
  letter-spacing: 3px;
  border-bottom: 1px solid var(--ui-border-light);
  padding-bottom: 6px;
}

.stat-list { display: flex; flex-direction: column; gap: 6px; }

.info-section { display: flex; flex-direction: column; gap: 2px; }

.info-label {
  color: var(--ui-text-dim);
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.info-value {
  color: var(--ui-text-bright);
  font-size: 13px;
  font-weight: bold;
}

.power-bar-wrap {
  width: 100%;
  height: 6px;
  background: var(--ui-bg3);
  border: 1px solid var(--ui-border-light);
  margin-bottom: 2px;
}
.power-bar {
  height: 100%;
  width: 0%;
  background: var(--ui-green);
  transition: width .3s, background .3s;
}

/* ─── ZONE DEMAND BARS ─── */
.zone-bars {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 3px;
}
.zone-bar-wrap {
  width: 100%;
  height: 5px;
  background: var(--ui-bg3);
  border: 1px solid var(--ui-border-light);
}
.zone-bar-demand-wrap {
  background: #1a1a1a;
}
.zone-bar {
  height: 100%;
  width: 0%;
  transition: width .4s;
}
/* Fill bar — shows occupancy level */
.zone-bar-fill       { background: #4488cc; }
/* Demand bar — shows appetite for more of this zone type */
.zone-bar-demand-res { background: #44cc88; }
.zone-bar-demand-ops { background: #cc8844; }
.zone-bar-demand-com { background: #8844cc; }

/* ─── SERVICE DEMAND BARS ─── */
.service-bars {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 3px;
}
.service-bar-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.svc-label {
  font-size: 8px;
  color: var(--ui-text-dim);
  width: 20px;
  flex-shrink: 0;
  letter-spacing: 0.5px;
}
.svc-bar-wrap {
  flex: 1;
  height: 4px;
  background: #1a1a1a;
  border: 1px solid var(--ui-border-light);
}
.svc-bar {
  height: 100%;
  width: 0%;
  transition: width 0.3s;
}
.svc-bar-safety   { background: #d47820; }
.svc-bar-hazard   { background: #cc3300; }
.svc-bar-medical  { background: #20b8a0; }
.svc-bar-research { background: #20c0d8; }

/* ─── COMMUNITY SUB-COMPONENTS ─── */
.info-label-sub {
  cursor: pointer;
  color: var(--ui-text-dim);
  font-size: 8px;
  letter-spacing: 0.5px;
}
.info-label-sub:hover { color: var(--ui-text); }
.sub-bar-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 2px;
}
.sub-label {
  font-size: 7px;
  color: var(--ui-text-dim);
  width: 20px;
  flex-shrink: 0;
  letter-spacing: 0.3px;
}
.sub-bar-wrap {
  flex: 1;
  height: 3px;
  background: #1a1a1a;
  border: 1px solid #333;
}
.sub-bar { height: 100%; width: 0%; transition: width 0.4s; }
.sub-val {
  font-size: 7px;
  color: var(--ui-text-dim);
  width: 16px;
  text-align: right;
  flex-shrink: 0;
}
.sub-art  { background: #cc8844; }
.sub-phi  { background: #8844cc; }
.sub-sci  { background: #44aacc; }
.sub-inn  { background: #44cc88; }
.sub-cre  { background: #cc44aa; }

/* ─── INNOVATION ─── */
.inno-bar-wrap {
  width: 100%;
  height: 5px;
  background: #1a1a1a;
  border: 1px solid var(--ui-border-light);
  margin-bottom: 3px;
}
.inno-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #4488ff, #aa44ff);
  transition: width 0.5s;
}
.inno-next {
  font-size: 8px;
  color: var(--ui-text-dim);
  margin-top: 2px;
  line-height: 1.3;
}
.inno-unlocks {
  margin-top: 3px;
  font-size: 7px;
  color: #44cc88;
  line-height: 1.4;
}

/* ─── TERRAIN SELECTOR ─── */
#terrain-selector {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.terrain-type-btn {
  background: var(--btn-face);
  color: var(--ui-text);
  border: 1px solid var(--btn-sh);
  border-top-color: var(--btn-hi);
  border-left-color: var(--btn-hi);
  padding: 3px 4px;
  cursor: pointer;
  font: inherit;
  font-size: 10px;
  letter-spacing: 1px;
  text-align: left;
}
.terrain-type-btn:hover             { background: var(--btn-hi); }
.terrain-type-btn.active,
.terrain-type-btn[aria-pressed="true"] {
  background: var(--ui-accent2);
  color: #fff;
  border-color: var(--ui-accent);
}

.action-btn {
  background: var(--ui-accent2);
  color: #fff;
  border: 1px solid var(--ui-accent);
  padding: 4px;
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  letter-spacing: 1px;
  width: 100%;
}
.action-btn:hover { background: var(--ui-accent); }

/* ─── VIEW CONTROLS ─── */
#view-controls {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
}

.view-btn {
  background: var(--btn-face);
  color: var(--ui-text-bright);
  border: 1px solid var(--btn-sh);
  border-top-color: var(--btn-hi);
  border-left-color: var(--btn-hi);
  width: 32px;
  height: 24px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}
.view-btn:hover  { background: var(--btn-hi); }
.view-btn.active { background: var(--ui-accent2); }

/* ─── QUERY PANEL (sidebar) ─── */
#query-panel {
  background: var(--ui-bg3);
  border: 1px solid var(--ui-border-light);
  padding: 6px;
}

#query-content {
  color: var(--ui-text-bright);
  font-size: 11px;
  line-height: 1.6;
  margin-top: 4px;
}

/* ─── TILE INSPECT POPUP ─── */
#tile-popup {
  position: fixed;
  z-index: 8000;
  background: rgba(10, 14, 20, 0.96);
  border: 1px solid #334;
  border-radius: 3px;
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: #ccd;
  pointer-events: none;
  max-width: 220px;
  line-height: 1.65;
  box-shadow: 0 4px 16px rgba(0,0,0,0.6);
}
#tile-popup .popup-name {
  color: #fff;
  font-size: 12px;
  font-weight: bold;
  margin-bottom: 4px;
  border-bottom: 1px solid #334;
  padding-bottom: 3px;
}
#tile-popup .popup-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
#tile-popup .popup-label { color: #778; }
#tile-popup .popup-val   { color: #dde; }
#tile-popup .popup-desc  { color: #778; font-size: 10px; margin-top: 5px; border-top: 1px solid #223; padding-top: 4px; }

/* ─── STATUS BAR ─── */
#statusbar {
  height: 20px;
  background: var(--ui-bg);
  border-top: 2px solid var(--ui-border);
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 24px;
  flex-shrink: 0;
}
#status-tool { color: var(--ui-accent);    min-width: 120px; }
#status-pos  { color: var(--ui-text-dim);  min-width: 100px; }
#status-msg  { color: var(--ui-text);      flex: 1; }

/* ─── DROPDOWN MENUS ─── */
#menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 99;
}

.dropdown-menu {
  position: fixed;
  top: 24px;
  background: var(--ui-bg2);
  border: 1px solid var(--ui-border-light);
  z-index: 100;
  min-width: 140px;
}

.menu-item {
  padding: 5px 16px;
  cursor: pointer;
  color: var(--ui-text-bright);
  display: block;
}
.menu-item:hover          { background: var(--ui-accent2); color: #fff; }
.menu-item.menu-separator { border-top: 1px solid var(--ui-border-light); }
.menu-item.disabled       { color: var(--ui-text-dim); cursor: default; pointer-events: none; }

/* ─── TOOLTIPS ─── */
.tool-btn[title]:hover::after {
  content: attr(title);
  position: absolute;
  left: calc(100% + 6px);
  top: 50%;
  transform: translateY(-50%);
  background: #000;
  color: #fff;
  padding: 2px 6px;
  font-size: 10px;
  white-space: nowrap;
  border: 1px solid var(--ui-border-light);
  z-index: 200;
  pointer-events: none;
}

/* ─── NOTIFICATIONS ─── */
.notification {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ui-bg2);
  border: 1px solid var(--ui-accent);
  color: var(--ui-text-bright);
  padding: 8px 16px;
  font: inherit;
  font-size: 12px;
  z-index: 300;
  animation: fadeInOut 3s forwards;
  pointer-events: none;
}

/* ─── NEW GAME SCREEN ─── */

#ng-screen {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  font-family: var(--font);
}

#ng-panel {
  background: var(--ui-bg);
  border: 2px solid var(--ui-border-light);
  width: 1040px;
  max-width: 96vw;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

#ng-header {
  background: var(--ui-bg2);
  border-bottom: 2px solid var(--ui-border);
  padding: 10px 14px;
  display: flex;
  align-items: baseline;
  gap: 16px;
}

#ng-title {
  color: var(--ui-accent);
  font-size: 32px;
  font-weight: bold;
  letter-spacing: 5px;
}

#ng-subtitle {
  color: var(--ui-text-dim);
  font-size: 15px;
  letter-spacing: 2px;
}

#ng-body {
  display: flex;
  gap: 0;
  flex: 1;
}

#ng-left {
  width: 380px;
  flex-shrink: 0;
  border-right: 2px solid var(--ui-border);
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#ng-right {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Allocation bar */
.ng-alloc-wrap { display: flex; flex-direction: column; gap: 3px; }

.ng-alloc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#ng-alloc-track {
  height: 8px;
  background: var(--ui-bg3);
  border: 1px solid var(--ui-border-light);
  display: flex;
  overflow: hidden;
}

#ng-alloc-loc {
  height: 100%;
  background: var(--ui-accent);
  transition: width 0.15s;
}

#ng-alloc-hab {
  height: 100%;
  background: var(--ui-green);
  transition: width 0.15s;
}

#ng-alloc-ep {
  height: 100%;
  background: var(--ui-yellow);
  transition: width 0.15s;
}

#ng-alloc-ends {
  display: flex;
  justify-content: space-between;
  color: var(--ui-text-dim);
  font-size: 9px;
}

/* Sliders */
.ng-slider-group { display: flex; flex-direction: column; gap: 3px; }

.ng-slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ng-label {
  color: var(--ui-text-dim);
  font-size: 13px;
  letter-spacing: 1px;
}

.ng-sval {
  color: var(--ui-text-bright);
  font-size: 15px;
  font-weight: bold;
  min-width: 20px;
  text-align: right;
}

.ng-slider-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ng-edge {
  color: var(--ui-text-dim);
  font-size: 11px;
  letter-spacing: 0.5px;
  white-space: nowrap;
  min-width: 58px;
}

.ng-edge:last-child { text-align: right; }

.ng-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--ui-bg3);
  border: 1px solid var(--ui-border-light);
  outline: none;
  cursor: pointer;
}

.ng-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 16px;
  background: var(--ui-text-bright);
  border: 1px solid var(--ui-border);
  cursor: pointer;
}

.ng-slider::-webkit-slider-thumb:hover { background: #fff; }

.ng-divider {
  height: 1px;
  background: var(--ui-border-light);
  margin: 2px 0;
}

/* Buttons */
#ng-buttons {
  display: flex;
  gap: 6px;
  margin-top: auto;
  padding-top: 8px;
}

#ng-btn-reroll {
  background: var(--btn-face);
  color: var(--ui-text);
  border: 1px solid var(--btn-sh);
  border-top-color: var(--btn-hi);
  border-left-color: var(--btn-hi);
  padding: 10px 10px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  letter-spacing: 1px;
  flex: 1;
}

#ng-btn-reroll:hover { background: var(--btn-hi); color: #fff; }

#ng-btn-start {
  background: var(--ui-accent2);
  color: #fff;
  border: 1px solid var(--ui-accent);
  padding: 10px 10px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  letter-spacing: 1px;
  flex: 2;
}

#ng-btn-start:hover { background: var(--ui-accent); }

/* Preview canvas */
#ng-preview {
  display: block;
  width: 100%;
  height: 200px;
  image-rendering: pixelated;
  border: 2px solid var(--ui-border-light);
}

/* Readouts */
#ng-readouts {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border: 1px solid var(--ui-border-light);
  background: var(--ui-bg3);
  padding: 6px 8px;
}

.ng-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.ng-rlabel {
  color: var(--ui-text-dim);
  font-size: 13px;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.ng-rval {
  color: var(--ui-text-bright);
  font-size: 14px;
  text-align: right;
  flex: 1;
}

/* Flavour text */
#ng-flavour {
  color: var(--ui-text);
  font-size: 13px;
  line-height: 1.9;
  border-left: 2px solid var(--ui-accent2);
  padding-left: 8px;
  font-style: italic;
  flex: 1;
}

@keyframes fadeInOut {
  0%   { opacity: 0; transform: translateX(-50%) translateY(10px); }
  15%  { opacity: 1; transform: translateX(-50%) translateY(0); }
  70%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ─── FLOATING WINDOWS (SC2000-style panels) ─── */
.floating-window {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--ui-bg);
  border: 2px solid var(--ui-border-light);
  box-shadow: 4px 4px 0 #000;
  z-index: 200;
  min-width: 420px;
}
.floating-window-title {
  background: var(--ui-accent2);
  color: var(--ui-text-bright);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 6px;
  font-size: 11px;
  letter-spacing: 1px;
  cursor: default;
}
.floating-window-close {
  background: none;
  border: 1px solid var(--ui-border-light);
  color: var(--ui-text);
  cursor: pointer;
  font-size: 10px;
  padding: 0 4px;
  line-height: 1.4;
}
.floating-window-close:hover { background: var(--ui-red); color: #fff; }
.floating-window-body {
  padding: 8px;
}

/* ─── GRAPHS WINDOW ─── */
.graphs-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 10px;
}
.graphs-key {
  padding: 1px 5px;
  border-radius: 2px;
  font-weight: bold;
  letter-spacing: 0.5px;
}
.graphs-key-r    { background: #224488; color: #88aaff; }
.graphs-key-o    { background: #442200; color: #ff8844; }
.graphs-key-c    { background: #332266; color: #bb88ff; }
.graphs-key-e    { background: #334400; color: #aacc44; }
.graphs-key-flow { background: #003333; color: #44ccbb; }
.graphs-key-sep  { flex: 1; }
#graphs-canvas   { display: block; background: #111; border: 1px solid var(--ui-border); }
