:root {
  --bg: #120c0d;
  --bg2: #1c1314;
  --panel: #21171708;
  --panel-solid: #1f1516;
  --line: #3a2a28;
  --text: #f3e6dc;
  --dim: #b39a8c;
  --accent: #e8743b;
  --accent2: #ffb37a;
  --water: #5cc8ff;
  --good: #8fd16a;
  --warn: #f2c14e;
  --bad: #ef5d4f;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: radial-gradient(1200px 600px at 20% -10%, #3a1a12 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font: 14px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.mono { font-family: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace; font-variant-numeric: tabular-nums; }

header { padding: 14px 20px 0; }
.brand { display: flex; gap: 12px; align-items: center; max-width: 1460px; margin: 0 auto; }
.logo {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 35% 30%, #ffb37a, #c4502a 55%, #5a1d10);
  box-shadow: 0 0 18px #e8743b55;
}
h1 { margin: 0; font-size: 20px; letter-spacing: .02em; }
header p { margin: 0; color: var(--dim); font-size: 13px; }

main {
  display: flex; gap: 16px; padding: 14px 20px 24px;
  align-items: flex-start; justify-content: center;
  max-width: 1460px; margin: 0 auto;
}

#stage { position: relative; flex: 1 1 auto; min-width: 0; max-width: 1100px; }
#game {
  display: block; width: 100%; height: auto; aspect-ratio: 28 / 18;
  border-radius: var(--radius); border: 1px solid var(--line);
  box-shadow: 0 10px 40px #0008;
  touch-action: none; cursor: crosshair; background: #9a4a2c;
}

aside { flex: 0 0 320px; width: 320px; display: flex; flex-direction: column; gap: 12px; }

.panel {
  background: var(--panel-solid); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px;
}
.panel h2 {
  margin: 0 0 8px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .12em; color: var(--dim); font-weight: 600;
}
.panel h2:not(:first-child) { margin-top: 12px; }

.sky-panel { padding: 0; overflow: hidden; }
#sky { display: block; width: 100%; height: 90px; }
.clock { display: flex; justify-content: space-between; padding: 8px 12px 0; font-size: 15px; }
.clock #sol { font-weight: 700; }
#weather { color: var(--dim); font-size: 13px; }
#weather.storm { color: var(--warn); }
.speeds { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 8px 12px 12px; }

button {
  font: inherit; color: var(--text); background: #2a1e1e; border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 10px; cursor: pointer;
  transition: background .12s, border-color .12s;
}
button:hover { background: #352524; border-color: #5a4038; }
button.active { background: #4a2617; border-color: var(--accent); color: #fff; }
button.primary { background: var(--accent); border-color: var(--accent); color: #1a0d08; font-weight: 700; }
button.primary:hover { background: var(--accent2); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.stat { display: flex; flex-direction: column; }
.stat span { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; }
.stat b { font-size: 15px; }
.stat small { color: var(--good); font-weight: 400; font-size: 11px; }
.tf { grid-column: 1 / -1; }
.tf-head { display: flex; justify-content: space-between; margin-bottom: 4px; }
.tf-head span { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; }

.bar { height: 7px; background: #120c0c; border-radius: 4px; overflow: hidden; border: 1px solid #2f2220; }
.bar.big { height: 10px; }
.bar > span { display: block; height: 100%; width: 0; background: var(--good); border-radius: 4px; transition: width .25s; }
#tfBar { background: linear-gradient(90deg, #c4502a, #e0a050, #8fd16a, #5cc8ff); }

.tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.seeds { grid-template-columns: repeat(5, 1fr); }
.tool {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 2px 5px; min-width: 0;
}
.tool canvas { width: 40px; height: 40px; }
.tool .nm { font-size: 11px; line-height: 1.1; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tool .cost { font-size: 10px; color: var(--accent2); }
.tool kbd { position: absolute; top: 3px; right: 4px; }
.tool.broke .cost { color: var(--bad); }

kbd {
  font: 10px ui-monospace, Consolas, monospace; color: var(--dim);
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; background: #160f10;
}

#info { min-height: 150px; }
#info h3 { margin: 0; font-size: 16px; display: flex; align-items: center; gap: 8px; }
#info .sub { color: var(--dim); margin: 2px 0 10px; font-size: 13px; }
#info .desc { color: var(--dim); font-size: 13px; margin: 6px 0 10px; }
#info .kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 13px; }
#info .kv span { color: var(--dim); }
#info .kv b { text-align: right; font-weight: 500; }
#info .meter { margin: 6px 0; }
#info .meter .lbl { display: flex; justify-content: space-between; font-size: 12px; color: var(--dim); margin-bottom: 2px; }
#info .status { margin-top: 10px; padding: 6px 8px; border-radius: 6px; font-size: 13px; background: #2a1d1d; }
.status.good { color: var(--good); }
.status.warn { color: var(--warn); }
.status.bad { color: var(--bad); }
.water > span { background: var(--water) !important; }
.health > span { background: #e06a8a !important; }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

#toasts {
  position: absolute; left: 12px; top: 12px; display: flex; flex-direction: column; gap: 6px;
  pointer-events: none; max-width: 60%;
}
.toast {
  background: #1a1112ee; border: 1px solid var(--line); border-left: 3px solid var(--accent);
  padding: 7px 11px; border-radius: 7px; font-size: 13px; box-shadow: 0 4px 16px #0007;
  animation: tin .25s ease-out; transition: opacity .5s, transform .5s;
}
.toast.good { border-left-color: var(--good); }
.toast.warn { border-left-color: var(--warn); }
.toast.bad { border-left-color: var(--bad); }
.toast.out { opacity: 0; transform: translateY(-6px); }
@keyframes tin { from { opacity: 0; transform: translateY(-6px); } }

.overlay {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: #0b0607b8; border-radius: var(--radius); padding: 16px;
}
.overlay.hidden { display: none; }
.card {
  max-width: 560px; background: var(--panel-solid); border: 1px solid var(--line);
  border-radius: 14px; padding: 18px 22px; box-shadow: 0 20px 60px #000a;
  max-height: 100%; overflow: auto;
}
.card h2 { margin: 0 0 8px; }
.card ol { padding-left: 20px; margin: 8px 0; }
.card li { margin-bottom: 6px; }
.card .dim { color: var(--dim); font-size: 13px; }
.card button { margin-top: 6px; padding: 8px 22px; }

@media (max-width: 980px) {
  main { flex-direction: column; align-items: stretch; padding: 12px 16px 20px; }
  header { padding: 12px 16px 0; }
  aside { width: 100%; flex-basis: auto; }
  #stage { max-width: none; }
}
