:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1c2330;
  --border: #2a3441;
  --text: #d7e0ea;
  --muted: #8b97a6;
  --accent: #4ec9a8;
  --accent-2: #5aa9ff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
}

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

#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

#topbar h1 {
  font-size: 18px;
  margin: 0;
  font-weight: 600;
}

#topbar .sub {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
  margin-left: 6px;
}

#stats {
  display: flex;
  gap: 14px;
  font-variant-numeric: tabular-nums;
}

.stat {
  font-size: 13px;
  color: var(--muted);
  background: var(--panel-2);
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

/* ---- Resursu josla ---- */
#resbar {
  display: flex;
  gap: 10px;
  padding: 7px 18px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.res {
  font-size: 13px;
  color: var(--text);
  font-weight: 600;
}

/* ---- Spēku pogas ---- */
#forceBar { display: flex; flex-direction: column; gap: 6px; }
.force-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 9px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  overflow: hidden;
}
.force-btn:hover:not(:disabled) { border-color: var(--accent-2); }
.force-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.force-btn.armed { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.force-ico { font-size: 14px; }
.force-name { font-weight: 600; }
.force-btn .cost { margin-left: auto; color: var(--muted); font-size: 11px; white-space: nowrap; }
.force-btn .cdbar {
  position: absolute; left: 0; bottom: 0; height: 2px;
  background: var(--accent-2); width: 0%; transition: width .1s linear;
}

/* ---- Evolūcijas panelis ---- */
#evoPanel { display: flex; flex-direction: column; gap: 3px; }
.evo-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid transparent;
  opacity: 0.6;
}
.evo-row.unlocked {
  opacity: 1;
  color: var(--text);
  border-color: var(--accent);
}
.evo-name { flex: 1; }
.evo-req { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.dim { color: var(--muted); font-weight: 400; }
.small { font-size: 11px; line-height: 1.3; margin-top: 4px; }

/* ---- Mutāciju pogas ---- */
#upgPanel { display: flex; flex-direction: column; gap: 5px; }
.upg-btn {
  text-align: left;
  padding: 6px 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  cursor: pointer;
}
.upg-btn:hover:not(:disabled) { border-color: var(--accent-2); }
.upg-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.upg-btn.bought { border-color: var(--accent); opacity: 1; background: rgba(78,201,168,0.12); }
.upg-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.upg-name { font-size: 12px; font-weight: 600; }
.upg-btn .cost { font-size: 11px; color: var(--muted); white-space: nowrap; }
.upg-btn.bought .cost { color: var(--accent); }
.upg-desc { font-size: 10px; color: var(--muted); margin-top: 2px; line-height: 1.25; }

/* ---- Paziņojumi (toasts) ---- */
#toasts {
  position: absolute;
  top: 14px; left: 50%;
  transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 6px;
  align-items: center;
  pointer-events: none;
  z-index: 5;
}
.toast {
  background: rgba(78, 201, 168, 0.92);
  color: #06231b;
  font-weight: 700;
  font-size: 14px;
  padding: 7px 16px;
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
  opacity: 1;
  transition: opacity 1.2s ease, transform 1.2s ease;
}
.toast.fade { opacity: 0; transform: translateY(-12px); }

#main {
  display: flex;
  flex: 1;
  min-height: 0;
}

#palette {
  width: 220px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.palette-group { display: flex; flex-direction: column; gap: 8px; }

.palette-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}

#elements {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.elem-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  transition: border-color .12s, transform .05s;
}

.elem-btn:hover { border-color: var(--muted); }
.elem-btn:active { transform: scale(0.96); }
.elem-btn.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset;
}

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.15);
}

.ctrl {
  padding: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.ctrl:hover { border-color: var(--accent-2); }

#brush { width: 100%; }
.brush-val { font-size: 12px; color: var(--muted); }

.hint p { font-size: 12px; color: var(--muted); margin: 2px 0; line-height: 1.4; }
.hint ol { font-size: 12px; color: var(--muted); margin: 4px 0; padding-left: 18px; line-height: 1.5; }
.hint b { color: var(--text); }

#canvasWrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background:
    radial-gradient(circle at 50% 0%, #16202e 0%, #0d1117 70%);
  min-width: 0;
}

#view {
  image-rendering: pixelated;
  background: #0a1a2a;
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  cursor: crosshair;
  max-width: 100%;
  max-height: 100%;
}

#cursorInfo {
  position: absolute;
  bottom: 10px;
  right: 14px;
  font-size: 12px;
  color: var(--muted);
  background: rgba(13,17,23,0.8);
  padding: 4px 8px;
  border-radius: 6px;
  pointer-events: none;
}
