:root {
  color-scheme: dark;
  --bg: #101414;
  --panel: rgba(17, 24, 22, 0.88);
  --panel-strong: rgba(20, 30, 27, 0.96);
  --line: rgba(224, 238, 221, 0.16);
  --text: #f1f4ec;
  --muted: #aab6aa;
  --accent: #d7ef6f;
  --accent-2: #68d4bd;
  --danger: #e57963;
  --soil: #6d5740;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(240, 248, 232, 0.08);
  color: var(--text);
  cursor: pointer;
  transition:
    border-color 140ms ease,
    background 140ms ease,
    transform 140ms ease;
}

button:hover {
  border-color: rgba(215, 239, 111, 0.55);
  background: rgba(215, 239, 111, 0.14);
}

button:active {
  transform: translateY(1px);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  width: 100vw;
  height: 100vh;
  min-width: 320px;
}

.sim-stage {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 42%, rgba(125, 178, 115, 0.2), transparent 40%),
    linear-gradient(180deg, #26362f 0%, #151c1a 100%);
}

#world {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.top-bar {
  position: absolute;
  inset: 20px 20px auto 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
}

.brand,
.run-controls {
  pointer-events: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(11, 17, 15, 0.68);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(14px);
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 64% 34%, #fff 0 8%, transparent 9%),
    radial-gradient(circle at 42% 58%, #f3f0df 0 34%, transparent 35%),
    linear-gradient(135deg, #d7ef6f, #68d4bd);
  box-shadow: 0 0 24px rgba(215, 239, 111, 0.28);
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.05;
  letter-spacing: 0;
}

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.run-controls {
  display: flex;
  gap: 8px;
}

.run-controls button {
  min-width: 78px;
  background: rgba(12, 16, 14, 0.72);
  backdrop-filter: blur(12px);
}

.camera-controls {
  position: absolute;
  left: 20px;
  bottom: 20px;
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.camera-controls button {
  width: 42px;
  min-width: 42px;
  min-height: 42px;
  padding: 0;
  background: rgba(12, 16, 14, 0.72);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  backdrop-filter: blur(12px);
}

.side-panel {
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  padding: 18px;
  border-left: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(25, 35, 31, 0.96), rgba(13, 18, 17, 0.97)),
    var(--panel-strong);
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.25);
  overflow-y: auto;
  touch-action: pan-y;
  overscroll-behavior: contain;
}

.panel-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
}

.section-title,
.traits h2,
.chart-section h2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
}

h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
}

.section-title span {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}

.control-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 38px;
  color: var(--muted);
  font-size: 13px;
}

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

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.experiment-grid {
  margin-top: 8px;
}

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

.stats-grid div {
  min-height: 66px;
  padding: 12px;
  border: 1px solid rgba(224, 238, 221, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.stats-grid span,
.trait-row span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.stats-grid strong {
  display: block;
  margin-top: 7px;
  color: var(--text);
  font-size: 24px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.empty-state {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.inspector-body {
  display: grid;
  gap: 10px;
}

.inspector-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.inspector-summary div {
  min-height: 54px;
  padding: 10px;
  border: 1px solid rgba(224, 238, 221, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.inspector-summary span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.inspector-summary strong {
  display: block;
  margin-top: 6px;
  overflow: hidden;
  color: var(--text);
  font-size: 17px;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.traits {
  display: grid;
  gap: 10px;
}

.trait-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

meter {
  width: 100%;
  height: 9px;
}

meter::-webkit-meter-bar {
  border: 0;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
}

meter::-webkit-meter-optimum-value {
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
}

.chart-section canvas {
  display: block;
  width: 100%;
  height: 150px;
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .side-panel {
    max-height: 42vh;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 620px) {
  .top-bar {
    inset: 10px 10px auto 10px;
    align-items: stretch;
  }

  .brand {
    max-width: min(58vw, 260px);
    padding: 10px;
  }

  .brand h1 {
    font-size: 15px;
  }

  .brand p {
    display: none;
  }

  .run-controls {
    flex-direction: column;
  }

  .run-controls button {
    min-width: 66px;
    min-height: 34px;
  }

  .camera-controls {
    left: 10px;
    bottom: 10px;
    gap: 6px;
  }

  .camera-controls button {
    width: 38px;
    min-width: 38px;
    min-height: 38px;
  }

  .side-panel {
    padding: 10px;
    gap: 10px;
  }

  .panel-section {
    padding: 10px;
  }
}
