@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Manrope:wght@400;500;600;700&display=swap');

:root {
  --ink: #17251c;
  --muted: #6f776f;
  --forest: #173d2a;
  --forest-2: #0d281b;
  --lime: #c9eb70;
  --paper: #f3f0e6;
  --line: #d7d4ca;
  --mono: "DM Mono", ui-monospace, monospace;
  --sans: "Manrope", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background: #0b1a12;
  font-family: var(--sans);
  overscroll-behavior: none;
}

button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible { outline: 3px solid #a9d54c; outline-offset: 2px; }
svg { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }

.app {
  width: min(1540px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--paper);
}

.topbar {
  height: 74px;
  display: flex;
  align-items: center;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: #f8f6ef;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--forest);
  text-decoration: none;
}
.brand svg { width: 32px; height: 32px; stroke-width: 1.9; }
.brand span { display: grid; line-height: 1; }
.brand strong { font-size: 15px; letter-spacing: .18em; }
.brand small { margin-top: 6px; color: #798078; font: 500 8px/1 var(--mono); letter-spacing: .17em; }

.top-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  color: #6c756d;
  font: 500 9px/1 var(--mono);
  letter-spacing: .08em;
}
.top-status b { margin-left: 4px; color: var(--forest); font-weight: 500; }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: #70a83f; box-shadow: 0 0 0 5px #70a83f1a; }

.icon-button {
  width: 38px;
  height: 38px;
  margin-left: 24px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}
.icon-button svg { width: 18px; vertical-align: middle; }
.icon-button:hover { background: #ebe9df; }

.workspace {
  height: calc(100vh - 74px);
  min-height: 680px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
}

.stage {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background: #d6dfcd;
  user-select: none;
  touch-action: none;
}
.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset -1px 0 #cad0c3, inset 0 0 90px #274a3130;
}
#world { width: 100%; height: 100%; display: block; cursor: grab; }
#world[data-tool="stone"] { cursor: crosshair; }
#world.grabbing { cursor: grabbing; }

.stage-heading {
  position: absolute;
  top: 32px;
  left: 36px;
  pointer-events: none;
}
.eyebrow {
  color: #385946;
  font: 500 9px/1 var(--mono);
  letter-spacing: .16em;
}
.stage-heading h1 {
  margin: 9px 0 2px;
  color: #173324;
  font-size: clamp(26px, 3vw, 43px);
  font-weight: 500;
  letter-spacing: -.045em;
}
.stage-heading p { margin: 0; color: #526559; font-size: 12px; }

.weather {
  position: absolute;
  top: 34px;
  right: 30px;
  display: grid;
  grid-template-columns: 22px auto auto;
  align-items: baseline;
  column-gap: 5px;
  color: #294737;
  font: 400 10px/1 var(--mono);
  pointer-events: none;
}
.weather > span { grid-row: 1 / 3; color: #50755d; font-size: 18px; }
.weather b { font-size: 18px; font-weight: 500; }
.weather small { grid-column: 2 / 4; margin-top: 6px; color: #6c7f72; font: 400 8px/1 var(--mono); letter-spacing: .08em; }

.canvas-hint {
  position: absolute;
  left: 34px;
  bottom: 34px;
  display: flex;
  align-items: center;
  gap: 11px;
  max-width: 280px;
  padding: 11px 14px;
  border: 1px solid #ffffff70;
  border-radius: 9px;
  color: #eaf0e8;
  background: #173d2ade;
  box-shadow: 0 12px 30px #0e241740;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
}
.canvas-hint.used { opacity: .58; transform: translateY(4px); }
.canvas-hint svg { width: 22px; flex: 0 0 auto; }
.canvas-hint span { display: grid; }
.canvas-hint b { font-size: 11px; font-weight: 600; }
.canvas-hint small { margin-top: 2px; color: #bfd0c2; font-size: 9px; }

.scale {
  position: absolute;
  right: 27px;
  bottom: 28px;
  display: flex;
  align-items: center;
  color: #4f6557;
  font: 500 8px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: .06em;
  pointer-events: none;
}
.scale i { width: 38px; height: 7px; border: solid #607266; border-width: 0 0 1px 1px; }
.scale i:last-child { transform: scaleX(-1); }
.scale span { padding: 0 6px; }

.panel {
  min-height: 0;
  overflow-y: auto;
  background: #f8f6ef;
  scrollbar-width: thin;
}
.panel-section { padding: 25px 25px 23px; border-bottom: 1px solid var(--line); }
.section-title { display: flex; align-items: center; margin-bottom: 19px; }
.section-title > span { color: #8a918a; font: 500 9px/1 var(--mono); }
.section-title h2 { margin: 0 0 0 11px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }

.tool-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border-radius: 8px;
  background: #e7e4da;
}
.tool {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 7px 10px;
  border: 0;
  border-radius: 6px;
  color: #6c746d;
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.tool.active { color: var(--forest); background: #fff; box-shadow: 0 2px 8px #17251c10; }
.tool svg { width: 19px; }
.tool span { display: grid; font-size: 10px; font-weight: 700; }
.tool small { margin-top: 3px; color: #8b918c; font-size: 8px; font-weight: 500; }

.primary-action, .animal-action {
  width: 100%;
  display: flex;
  align-items: center;
  border: 0;
  cursor: pointer;
  text-align: left;
}
.primary-action {
  min-height: 61px;
  margin-top: 13px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #eef4e7;
  background: var(--forest);
  box-shadow: 0 8px 20px #173d2a20;
}
.primary-action:hover, .primary-action.pressed { background: #215539; }
.primary-action svg { width: 22px; margin-right: 10px; color: var(--lime); }
.primary-action span, .animal-action span { display: grid; }
.primary-action b, .animal-action b { font-size: 10px; font-weight: 700; }
.primary-action small { margin-top: 3px; color: #b4c9ba; font-size: 8px; }
kbd { margin-left: auto; padding: 4px 5px; border: 1px solid #63806c; border-radius: 4px; color: #9eb6a5; background: #0f2f20; font: 500 7px/1 var(--mono); }

.range-label { display: flex; justify-content: space-between; margin-top: 17px; color: #697169; font-size: 9px; }
.range-label output { color: var(--forest); font: 500 9px/1 var(--mono); }
input[type="range"] {
  width: 100%;
  height: 3px;
  margin: 12px 0 16px;
  accent-color: var(--forest);
  cursor: pointer;
}

.animal-action {
  min-height: 57px;
  padding: 9px 11px;
  border: 1px solid #d9d5c9;
  border-radius: 8px;
  background: transparent;
}
.animal-action:hover { border-color: #9daf99; background: #f1f3e9; }
.animal-action svg { width: 23px; margin-right: 10px; color: #466b52; }
.animal-action small { margin-top: 3px; color: #858c85; font-size: 8px; }
.animal-action i { width: 23px; height: 23px; margin-left: auto; border-radius: 50%; color: var(--forest); background: #dce8c4; font: normal 16px/22px var(--sans); text-align: center; }

.physics-panel { background: #f1efe6; }
.metrics { margin: 0; }
.metrics div { display: flex; justify-content: space-between; padding: 6px 0; }
.metrics dt { color: #747b75; font-size: 9px; }
.metrics dd { margin: 0; color: #263c2e; font: 500 9px/1 var(--mono); }
.strain-head { display: flex; justify-content: space-between; margin-top: 16px; padding-top: 15px; border-top: 1px solid #d9d6cc; font-size: 9px; }
.strain-head span { color: #747b75; }
.strain-head b { color: #31533e; font: 500 9px/1 var(--mono); }
.strain-track { position: relative; height: 5px; margin-top: 10px; border-radius: 4px; background: #d7d5cb; overflow: hidden; }
.strain-track i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #759847, #d7b543, #b95938); transition: width .12s; }
.strain-track mark { position: absolute; top: 0; left: 72%; width: 1px; height: 100%; background: #7e3d2e; }
.strain-legend { display: flex; justify-content: space-between; margin-top: 7px; color: #9a9e99; font: 400 7px/1 var(--mono); letter-spacing: .08em; }

.event-panel { min-height: 170px; }
.live { margin-left: auto; padding: 4px 6px; border-radius: 3px; color: #4f7d48; background: #e4edd7; font: 500 7px/1 var(--mono); letter-spacing: .08em; }
.events { margin: 0; padding: 0; list-style: none; }
.events li {
  position: relative;
  display: grid;
  grid-template-columns: 42px 1fr;
  padding: 7px 0 7px 13px;
  color: #4c5b51;
  font-size: 9px;
}
.events li::before { content: ""; position: absolute; top: 11px; left: 0; width: 5px; height: 5px; border: 1px solid #749070; border-radius: 50%; }
.events li:not(:last-child)::after { content: ""; position: absolute; top: 18px; bottom: -4px; left: 3px; width: 1px; background: #d4d9d0; }
.events time { color: #999f99; font: 400 7px/1.5 var(--mono); }

@media (max-width: 900px) {
  .workspace { height: auto; min-height: 0; grid-template-columns: 1fr; }
  .stage { height: 68vh; min-height: 520px; }
  .panel { display: grid; grid-template-columns: 1fr 1fr; overflow: visible; }
  .panel-section:first-child { grid-row: span 2; }
}

@media (max-width: 620px) {
  .topbar { height: 62px; padding: 0 16px; }
  .top-status { display: none; }
  .icon-button { margin-left: auto; }
  .workspace { height: auto; }
  .stage { height: 64vh; min-height: 470px; }
  .stage-heading { top: 23px; left: 20px; }
  .stage-heading p { display: none; }
  .weather { top: 24px; right: 16px; }
  .canvas-hint { left: 16px; bottom: 19px; }
  .scale { display: none; }
  .panel { display: block; }
  .panel-section { padding: 23px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
