:root {
  font: 12px system-ui, -apple-system, sans-serif;
  color: #302d24;
  background: #efe5cf;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
main { height: 100%; height: 100dvh; display: grid; grid-template-rows: auto auto minmax(0, 1fr); }
button, select, input { font: inherit; color: inherit; }
button, select, input[type=number] {
  min-height: 28px;
  border: 1px solid #baaf99;
  border-radius: 5px;
  background: #fffdf7;
  padding: 3px 7px;
}
button { cursor: pointer; white-space: nowrap; }
button:hover { background: #eae4d6; }
button:disabled { opacity: .45; cursor: default; }
button[aria-pressed=true], button[aria-expanded=true], #pause { background: #365d44; color: #fff; border-color: #365d44; }
:focus-visible { outline: 2px solid #b14a1f; outline-offset: -2px; }
.controls { position: relative; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 5px 9px; padding: 5px 6px; background: #f6f2e9; border-bottom: 1px solid #d1c6b0; }
.control-group { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.transport { padding-right: 9px; border-right: 1px solid #d1c6b0; }
.speed { display: flex; align-items: center; gap: 5px; margin-left: 3px; }
.view-controls { margin-left: auto; gap: 9px; }
.check { display: flex; align-items: center; gap: 4px; min-height: 28px; white-space: nowrap; }
.check input { width: 15px; height: 15px; margin: 0; accent-color: #365d44; }
.icon-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 14px; height: 14px; flex: 0 0 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
button { display: inline-flex; align-items: center; justify-content: center; gap: 4px; }
.settings { position: fixed; inset: 0; margin: auto; width: min(560px, calc(100vw - 16px)); max-width: none; max-height: calc(100dvh - 16px); padding: 0; color: inherit; background: #f6f2e9; border: 1px solid #baaf99; border-radius: 9px; overflow: hidden; box-shadow: 0 10px 36px #302d2440; }
.settings::backdrop { background: #302d2466; }
.settings-shell { display: flex; flex-direction: column; max-height: calc(100dvh - 18px); }
.settings-header, .settings-footer { display: flex; align-items: center; justify-content: space-between; flex: 0 0 auto; gap: 8px; padding: 7px 10px; }
.settings-header { border-bottom: 1px solid #d1c6b0; }
.settings-header strong { font-size: 13px; }
.settings-body { min-height: 0; overflow: auto; overscroll-behavior: contain; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 9px; }
.settings-footer { border-top: 1px solid #d1c6b0; }
.settings-footer .primary { margin-left: auto; background: #365d44; border-color: #365d44; color: white; }
#settings-status { font-size: 11px; }
.speed input { width: 82px; min-width: 0; margin: 0; accent-color: #365d44; }
.speed output { min-width: 26px; font-variant-numeric: tabular-nums; }
fieldset { min-width: 0; margin: 0; padding: 7px; border: 1px solid #d1c6b0; border-radius: 5px; }
legend { font-weight: 650; padding: 0 4px; }
.settings-column { display: flex; flex-direction: column; gap: 8px; }
.slider { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px; margin: 4px 0 8px; }
.slider input { grid-column: 1 / -1; width: 100%; min-height: 24px; margin: 0; accent-color: #365d44; }
.slider output { font-variant-numeric: tabular-nums; color: #665b44; }
.control-note { font-size: 10px; color: #665b44; line-height: 1.4; margin: -4px 0 8px; }
.scenario-controls, .save-controls { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.scenario-controls label { display: flex; gap: 5px; align-items: center; }
.scenario-controls input { width: 94px; min-width: 0; }
.save-controls { margin-top: 7px; }
.stats {
  display: flex; align-items: center; gap: 12px; min-width: 0; min-height: 27px;
  padding: 4px 7px; background: #fffaf0; border-bottom: 1px solid #d5cbb6;
  overflow-x: auto; white-space: nowrap; font-size: 10px; font-variant-numeric: tabular-nums;
  scrollbar-width: thin;
}
.stats > * { flex: 0 0 auto; }
.stats b { font-size: 12px; }
.stats progress { width: 30px; height: 6px; accent-color: #4d7944; margin-left: -7px; }
#clock { margin-left: auto; }
.canvas-stage { position: relative; min-height: 0; min-width: 0; overflow: hidden; }
canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.canvas-footer { position: absolute; bottom: 6px; left: 6px; right: 6px; display: flex; justify-content: space-between; flex-wrap: wrap; align-items: end; gap: 4px; pointer-events: none; }
#selected, .legend { background: #fffaf0e8; padding: 4px 6px; border-radius: 4px; font-size: 10px; margin: 0; }
.legend { display: flex; gap: 9px; margin-left: auto; }
.legend span { display: inline-flex; gap: 4px; align-items: center; }
.legend i { width: 7px; height: 7px; border-radius: 50%; }
.home { background: #338ac7; }
.food { background: #d164a0; }
#colony-state:empty { display: none; }
#colony-state, #status { position: absolute; z-index: 4; left: 6px; right: 6px; width: fit-content; max-width: calc(100% - 12px); margin: 0; padding: 7px 9px; border-radius: 5px; background: #f6dfc1f2; font-size: 12px; }
#colony-state { top: 6px; }
#status { bottom: 28px; background: #fffaf0f5; box-shadow: 0 2px 9px #302d2426; pointer-events: none; }
@media (max-width: 620px) {
  .controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "transport settings" "tools tools" "follow layers"; gap: 4px 6px; }
  .transport { grid-area: transport; }
  .tools { grid-area: tools; }
  #settings-toggle { grid-area: settings; justify-self: end; }
  .layers-control { grid-area: layers; justify-self: end; }
  .follow-control { grid-area: follow; }
  #overview { grid-area: follow; justify-self: end; }
  .transport { border-right: 0; padding-right: 0; }
  .view-controls { display: contents; }
  .speed > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .stats { gap: 10px; }
}
@media (pointer: coarse) { button, select, input[type=number], .check { min-height: 32px; } }
@media (max-width: 360px) {
  .tools { gap: 3px; }
  .tools button { padding-inline: 5px; }
  .settings-body { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .transport button > span, .tools button > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .transport button, .tools button { min-width: 28px; padding-inline: 5px; }
  .speed input { width: 65px; }
}
.speed input { height: 24px; }

.brush-control input { width: 64px; }
@media (max-width: 620px) {
  .brush-control { margin-left: auto; }
  .follow-control { padding-right: 34px; }
}
