/* Tiny Tractors — dark field-office UI around a naturally coloured map.
   Tokens first; components only use tokens. */
:root {
  --bg: #0f1412;
  --surface: #161d1a;
  --surface-2: #1d2622;
  --surface-3: #25302b;
  --line: #2e3a34;
  --line-strong: #3d4b44;
  --text: #e7ebe4;
  --text-2: #b4bfb7;
  --muted: #8b9891;
  --primary: #2f7d43;      /* field green: buttons with white text (5.1:1) */
  --primary-hi: #3a944f;
  --primary-ink: #7fcf8f;  /* green text on dark */
  --accent: #e0a526;       /* harvest amber: money, highlights */
  --accent-ink: #1a1405;
  --danger: #e5534b;
  --danger-bg: #3a1716;
  --warn: #e0a526;
  --info: #6fb3d9;
  --focus: #f2c85b;
  --radius: 9px;
  --radius-lg: 12px;
  --radius-sm: 6px;
  --logo: #5fbf5a;        /* tractor green for the logo */
  --top-h: 52px;
  --rail-w: 76px;
  --drawer-w: 440px;
  --font: "Rubik", "Segoe UI", system-ui, sans-serif;
  --mono: "Rubik", "Segoe UI", system-ui, sans-serif; /* numbers use tabular figures */
  --shadow: 0 8px 24px rgba(0, 0, 0, .35);
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1); /* overshoots a little, then settles */
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
/* hide the browser's scrollbars everywhere (areas still scroll) */
* { scrollbar-width: none; -ms-overflow-style: none; }
*::-webkit-scrollbar { display: none; width: 0; height: 0; }
body {
  background: var(--bg); color: var(--text); font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased; overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--primary-ink); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.num, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.pos { color: var(--primary-ink); }
.neg { color: var(--danger); }
.amber { color: var(--accent); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2.4;
  stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 16px; height: 16px; }

/* ---------- buttons & inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 6px 14px; border-radius: var(--radius); cursor: pointer;
  background: var(--surface-3); border: 1px solid var(--line-strong); color: var(--text);
  font-weight: 500; font-size: 14px; white-space: nowrap; transition: background .15s, border-color .15s;
  touch-action: manipulation;
}
.btn:hover:not(:disabled) { background: #2d3a33; border-color: #4a5a52; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
/* soft-tint buttons: faint colour fill + coloured text */
.btn.primary { background: rgba(92,193,119,.16); border-color: transparent; color: #8fdc9f; font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: rgba(92,193,119,.26); }
.btn.amber { background: rgba(224,165,38,.17); border-color: transparent; color: #f0bd4f; font-weight: 600; }
.btn.amber:hover:not(:disabled) { background: rgba(224,165,38,.28); }
.btn.danger { background: rgba(229,83,75,.12); border-color: transparent; color: #ff8a82; }
.btn.danger:hover:not(:disabled) { background: rgba(229,83,75,.22); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--surface-3); }
.btn.sm { min-height: 30px; padding: 3px 10px; font-size: 13px; }
.btn.icon { padding: 0; width: 36px; }
.btn.block { width: 100%; }
@media (pointer: coarse) { .btn { min-height: 44px; } .btn.sm { min-height: 40px; } .btn.icon { width: 44px; } }

label.f { display: block; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); margin: 12px 0 4px; }
input[type=text], input[type=password], input[type=number], select {
  width: 100%; min-height: 38px; padding: 7px 10px; background: var(--bg); border: 1px solid var(--line-strong);
  border-radius: var(--radius); outline: none; font-size: 15px;
}
input:focus, select:focus { border-color: var(--focus); }
input[type=range] { width: 100%; accent-color: var(--accent); }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; color: var(--text-2); margin-top: 10px; cursor: pointer; }
.check input { margin-top: 4px; accent-color: var(--primary); }
.help { font-size: 13px; color: var(--muted); margin-top: 4px; }
.err { color: #ff8a82; font-size: 14px; margin-top: 8px; min-height: 1em; }

/* ---------- auth & lobby */
.screen { position: fixed; inset: 0; overflow: auto; }
.auth { display: grid; place-items: center; padding: 24px; background:
  linear-gradient(rgba(15,20,18,.86), rgba(15,20,18,.96)), url("img/fields.svg") center/cover; }
.auth-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 28px; }
.wordmark { font-weight: 700; font-size: 26px; letter-spacing: -.02em; display: flex; align-items: center; gap: 10px; }
.wordmark .mark { width: 32px; height: 32px; color: var(--logo); }
.auth-card .tag { color: var(--muted); font-size: 14px; margin: 2px 0 18px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; }
.seg button { background: transparent; border: 0; padding: 8px; cursor: pointer; color: var(--text-2); min-height: 38px; }
.seg button[aria-pressed=true] { background: var(--surface-3); color: var(--text); font-weight: 600; }

.lobby { padding: 0 0 48px; }
.lobby-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 24px; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 2; }
.lobby-main { max-width: 1040px; margin: 0 auto; padding: 28px 24px; display: grid; gap: 28px; }
.lobby h1 { font-size: 22px; font-weight: 600; }
.section-title { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--line); padding-bottom: 6px; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: baseline; }
.world-list { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
.world-row { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; background: var(--surface); padding: 14px 16px; }
.world-row h3 { font-size: 17px; font-weight: 600; }
.world-row .meta { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; color: var(--muted); margin-top: 2px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.running { color: var(--primary-ink); } .status.paused { color: var(--accent); } .status.ended { color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px; }

/* ---------- game shell */
.game { position: fixed; inset: 0; display: grid; grid-template-rows: var(--top-h) minmax(0, 1fr); grid-template-columns: minmax(0, 1fr); }
.topbar { display: flex; align-items: stretch; overflow: hidden; background: var(--surface); border-bottom: 1px solid var(--line); z-index: 20; min-width: 0; }
.topbar .home { width: 56px; display: grid; place-items: center; border: 0; color: var(--logo); background: none; cursor: pointer; flex: none; }
.topbar .home svg { width: 26px; height: 26px; }
.tb-cell, .tb-stat { display: flex; flex-direction: column; justify-content: center; padding: 0 16px; border-right: 1px solid var(--line); min-width: 0; }
.tb-stat { border-right: 0; border-left: 1px solid var(--line); background: none; border-top: 0; border-bottom: 0; cursor: pointer; text-align: left; color: inherit; }
.tb-stat:hover { background: var(--surface-2); }
.tb-cell .k, .tb-stat .k { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); line-height: 1.2; white-space: nowrap; }
.tb-cell .v, .tb-stat .v { font-size: 16px; font-weight: 600; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 5px; }
.tb-world .v { max-width: 220px; display: block; }
.tb-spacer { flex: 1; }
.tb-btn { display: flex; align-items: center; gap: 8px; padding: 0 14px; background: none; border: 0; border-left: 1px solid var(--line); cursor: pointer; color: var(--text-2); position: relative; }
.tb-btn:hover, .tb-btn[aria-current=page] { background: var(--surface-2); color: var(--text); }
.badge { position: absolute; top: 9px; left: 26px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font: 600 11px/18px var(--font); text-align: center; }
.paused-flag { background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 700; letter-spacing: .06em; padding: 2px 8px; border-radius: 3px; margin-left: 8px; }
.g-good { color: #5cc177; } .g-mid { color: #6fb3d9; } .g-low { color: var(--accent); } .g-bad { color: var(--danger); }

.stage { position: relative; overflow: hidden; }
#map { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; background: #151c18; }
#map.dragging { cursor: grabbing; }
#map.moving { cursor: move; }
.map-tools { position: absolute; left: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 6px; z-index: 5; }
.map-tools .btn { background: rgba(22,29,26,.92); }
.legend { position: absolute; left: 64px; bottom: 12px; background: rgba(22,29,26,.92); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; font-size: 12px; color: var(--text-2); z-index: 5; display: grid; grid-template-columns: auto auto; gap: 3px 14px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 2px; vertical-align: -2px; margin-right: 6px; border: 1px solid rgba(0,0,0,.3); }
.tooltip { position: absolute; pointer-events: none; z-index: 6; background: rgba(15,20,18,.96); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 6px 9px; font-size: 13px; max-width: 250px; box-shadow: var(--shadow); }

/* right-hand sidebar: icon rail on the edge, widens into the panel */
.sidebar { position: absolute; top: 0; right: 0; bottom: 0; display: flex; flex-direction: row; z-index: 12; pointer-events: none; }
.sidebar > * { pointer-events: auto; }
.rail { width: var(--rail-w); background: var(--surface); border-left: 1px solid var(--line); display: flex; flex-direction: column; padding: 6px 0; overflow-y: auto; }
.rail button { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 10px 4px; background: none; border: 0; cursor: pointer; color: var(--muted); font-size: 11.5px; font-weight: 500; border-right: 3px solid transparent; position: relative; }
.rail button:hover { color: var(--text); background: var(--surface-2); }
.rail button[aria-current=page] { color: var(--text); border-right-color: var(--accent); background: var(--surface-2); }
.rail button svg { width: 22px; height: 22px; }
.rail .sep { height: 1px; background: var(--line); margin: 6px 12px; }
.rail .dot { position: absolute; top: 8px; right: 18px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.panel { width: var(--drawer-w); background: var(--surface); border-left: 1px solid var(--line); display: flex; flex-direction: column; box-shadow: var(--shadow); animation: pin .2s var(--ease-out); min-width: 0; }
.panel[hidden] { display: none; }
.sidebar.wide .panel { width: min(820px, calc(100vw - var(--rail-w) - 40px)); }
@keyframes pin { from { transform: translateX(24px); opacity: 0; } }
.d-head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 18px; border-bottom: 1px solid var(--line); min-height: 56px; position: relative; }
.d-head h2 { font-size: 18px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.d-body { flex: 1; overflow-y: auto; padding: 4px 18px 24px; overscroll-behavior: contain; }
.d-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 12px; overflow-x: auto; }
.d-tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 10px 8px; cursor: pointer; color: var(--muted); font-weight: 500; white-space: nowrap; min-height: 42px; }
.d-tabs button[aria-selected=true] { color: var(--text); border-bottom-color: var(--accent); }

/* popups on the map (job menu, building menu) */
.popup { position: absolute; z-index: 14; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-lg); box-shadow: 0 12px 32px rgba(0,0,0,.5); width: 260px; max-height: calc(100% - 16px); display: flex; flex-direction: column; animation: tin .15s var(--ease-out); }
.popup[hidden] { display: none; }
.popup:has(.pop-cols.two) { width: 620px; max-width: calc(100% - 16px); }
.pop-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 8px 8px 12px; border-bottom: 1px solid var(--line); }
.pop-cols { display: grid; grid-template-columns: 1fr; min-height: 0; overflow: hidden; flex: 1; }
.pop-cols.two { grid-template-columns: 220px 1fr; }
.jobs { padding: 4px; overflow-y: auto; }
.pop-cols.two .jobs { border-right: 1px solid var(--line); }
.job { display: flex; flex-direction: column; align-items: flex-start; width: 100%; text-align: left; background: none; border: 0; border-radius: var(--radius); padding: 6px 10px; cursor: pointer; color: var(--text); min-height: 36px; }
.job:hover:not(.blocked) { background: var(--surface-3); }
.job.on { background: var(--surface-3); box-shadow: inset 3px 0 0 var(--accent); }
.job .jn { font-weight: 500; font-size: 14px; }
.job .why { font-size: 11.5px; color: var(--muted); }
.job.optional .jn { color: var(--text-2); font-weight: 400; }
.job.blocked { cursor: not-allowed; }
.job.blocked .jn { text-decoration: line-through; color: #6c7973; }
.jobform { padding: 6px 14px 14px; overflow-y: auto; }
.jobform h4 { font-size: 15px; margin: 4px 0 2px; }
.f { display: block; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 10px 0 4px; }
.pop-foot { border-top: 1px solid var(--line); padding: 6px 8px; display: flex; justify-content: flex-end; }
.menu { display: flex; flex-direction: column; padding: 4px; }
.menu button { display: flex; align-items: center; gap: 8px; background: none; border: 0; border-radius: var(--radius); padding: 8px 10px; cursor: pointer; color: var(--text); text-align: left; min-height: 38px; }
.menu button:hover { background: var(--surface-3); }
.menu button.danger { color: #ff8a82; }
.croplist { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; max-height: 210px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius); padding: 3px; }
.crop { display: flex; flex-direction: column; align-items: flex-start; background: var(--bg); border: 1px solid transparent; border-radius: 3px; padding: 4px 8px; cursor: pointer; color: var(--text); text-align: left; }
.crop:hover { border-color: var(--line-strong); }
.crop[aria-checked=true] { border-color: var(--accent); background: rgba(224,165,38,.1); }
.crop .note { font-size: 11px; color: var(--muted); }
.crop.best .note { color: var(--primary-ink); }
.crop.outwin span { color: var(--accent); font-style: italic; }
.warnline { color: var(--accent); font-size: 13px; margin-top: 8px; display: flex; gap: 6px; align-items: flex-start; }
.warnbox { margin-top: 8px; padding: 8px 10px; background: rgba(224,165,38,.08); border: 1px solid rgba(224,165,38,.35); border-radius: var(--radius); font-size: 13.5px; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--primary-ink); cursor: pointer; font: inherit; text-decoration: underline; text-underline-offset: 2px; }
.linkbtn:hover { color: #a3e2ae; }

/* panel content */
h3.sec { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 20px 0 8px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.chips { margin-top: 12px; display: flex; gap: 6px; flex-wrap: wrap; }
.status-big { font-size: 19px; font-weight: 600; margin: 10px 0; line-height: 1.3; }
.kv { display: grid; grid-template-columns: repeat(2, 1fr); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.kv > div { padding: 8px 10px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); min-width: 0; }
.kv > div:nth-child(2n) { border-right: 0; }
.kv .k { font-size: 11.5px; color: var(--muted); letter-spacing: .02em; }
.kv .v { font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }
.kv.three { grid-template-columns: repeat(3, 1fr); }
.kv.three > div:nth-child(2n) { border-right: 1px solid var(--line); }
.kv.three > div:nth-child(3n) { border-right: 0; }
.flags { list-style: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px 10px; margin-top: 10px; font-size: 13px; }
.flags li.ok { color: var(--primary-ink); } .flags li.bad { color: #ff8a82; }
.flags li::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: 6px; vertical-align: 2px; }
.bar { height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; margin-top: 5px; }
.bar > i { display: block; height: 100%; background: var(--primary-ink); border-radius: 3px; transition: width .4s linear; }
.bar.amber > i { background: var(--accent); } .bar.red > i { background: var(--danger); }
.bar.lg { height: 8px; }
.list { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface); }
.row:last-child { border-bottom: 0; }
.row .t { font-weight: 600; font-size: 14.5px; }
.row .s { font-size: 13px; color: var(--muted); font-weight: 400; }
.row .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.row.warn { box-shadow: inset 3px 0 0 var(--accent); }
.menurow { width: 100%; text-align: left; cursor: pointer; border: 0; border-bottom: 1px solid var(--line); color: inherit; }
.menurow span { display: flex; gap: 10px; align-items: center; }
.sellline { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; margin-top: 8px; }
.sellline input { min-height: 32px; }
.selltotal { font-weight: 600; }
.empty { padding: 18px 12px; color: var(--muted); font-size: 14px; text-align: center; border: 1px dashed var(--line-strong); border-radius: var(--radius); }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: 3px; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.chip.green { background: rgba(92,193,119,.13); color: #7fcf8f; } .chip.red { background: rgba(229,83,75,.14); color: #ff8a82; }
.chip.amber { background: rgba(224,165,38,.14); color: var(--accent); } .chip.blue { background: rgba(111,179,217,.14); color: var(--info); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }
.btn.danger-solid { background: rgba(229,83,75,.18); border-color: transparent; color: #ff8a82; font-weight: 600; }
.btn.danger-solid:hover:not(:disabled) { background: rgba(229,83,75,.28); }
.backbar { display: flex; gap: 10px; align-items: center; margin-top: 12px; padding: 8px 10px; background: var(--surface-2); border-radius: var(--radius); flex-wrap: wrap; }

/* tiles (filters) */
.tiles { display: flex; flex-wrap: wrap; gap: 5px; }
.tiles.brands { max-height: 112px; overflow-y: auto; padding: 1px; }
.tile { display: inline-flex; align-items: center; gap: 5px; background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 4px 10px; cursor: pointer; color: var(--text-2); font-size: 13px; min-height: 30px; }
.tile:hover { color: var(--text); border-color: #4a5a52; }
.tile.on { background: rgba(224,165,38,.12); border-color: var(--accent); color: var(--text); }
.tile .cnt { font-size: 11px; color: var(--muted); }
.qpick { margin-bottom: 8px; }

/* tables */
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line-strong); position: sticky; top: 0; background: var(--surface); white-space: nowrap; z-index: 1; }
table.t th:has(.sorth) { padding: 0; }
.sorth { all: unset; display: block; width: 100%; box-sizing: border-box; padding: 6px 8px; cursor: pointer; }
.sorth:hover { color: var(--text); }
.sorth:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
th.r .sorth { text-align: right; }
.sorth .arrow { font-size: 9px; margin-left: 4px; color: var(--accent); }
table.t td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t td.r, table.t th.r { text-align: right; }
table.t tr:hover td { background: var(--surface-2); }
.tbl-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); max-height: 62vh; }
.nowrap { white-space: nowrap; }
.rowacts { display: inline-flex; gap: 4px; white-space: nowrap; }

/* market chart */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin: 14px 0 10px; }
.stats > div { background: var(--surface); padding: 8px 12px; }
.stats .k { font-size: 11.5px; color: var(--muted); }
.stats .v { font-size: 18px; font-weight: 600; }
.small-seg { display: inline-grid; grid-template-columns: auto auto; }
.small-seg button { padding: 4px 12px; min-height: 30px; }
.chart { position: relative; margin: 8px 0 0; }
.chart figcaption { margin-bottom: 4px; }
.linechart { width: 100%; height: auto; display: block; }
.linechart .grid { stroke: #2a3530; stroke-width: 1; }
.linechart .axis { fill: var(--muted); font: 11px var(--mono); }
.linechart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.linechart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.linechart .xh { stroke: var(--text-2); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-tip { position: absolute; pointer-events: none; background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 5px 8px; font-size: 12.5px; box-shadow: var(--shadow); white-space: nowrap; }

/* finance */
.fin-top { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.k-label { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.credit-head { display: flex; gap: 14px; align-items: center; }
.credit-badge { width: 70px; height: 70px; border-radius: var(--radius-lg); border: 2px solid currentColor; display: grid; place-items: center; text-align: center; flex: none; }
.credit-badge b { font: 700 26px/1 var(--mono); display: block; }
.credit-badge span { font-size: 11px; color: var(--muted); }
.factors { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.fboxes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fbox { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.fbox-h { padding: 8px 12px; font-weight: 600; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.fline { display: flex; justify-content: space-between; gap: 10px; padding: 6px 12px; font-size: 14px; border-bottom: 1px solid var(--line); }
.fline:last-child { border-bottom: 0; }
.fline.tot { font-weight: 700; background: var(--surface-2); }
.fnet { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface-2); }
.fnet b { font-size: 20px; }
.fnet.pos b { color: var(--primary-ink); } .fnet.neg b { color: var(--danger); }

.notif { padding: 10px 14px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: auto 1fr; gap: 10px; font-size: 14px; }
.notif .when { font-size: 12px; color: var(--muted); }
.notif.danger svg { color: var(--danger); } .notif.warn svg { color: var(--accent); } .notif.info svg { color: var(--info); }
.est { margin-top: 12px; padding: 10px 12px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); font-size: 14px; }

.toast-wrap { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; pointer-events: none; }
.toast { background: var(--surface-3); border: 1px solid var(--line-strong); border-left: 3px solid var(--primary-ink); padding: 10px 14px; border-radius: var(--radius); box-shadow: var(--shadow); font-size: 14px; max-width: min(520px, 92vw); animation: tin .2s var(--ease-out); }
.toast.error { border-left-color: var(--danger); }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }
.modal-back { position: fixed; inset: 0; background: rgba(5,8,7,.6); z-index: 90; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-lg); width: min(460px, 100%); padding: 20px; box-shadow: var(--shadow); }
.modal h2 { font-size: 18px; margin-bottom: 8px; }
.modal .acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.bottom-nav { display: none; }

/* ---------- phone */
@media (max-width: 760px) {
  :root { --top-h: 50px; }
  .game { grid-template-rows: var(--top-h) minmax(0, 1fr) 60px; }
  .topbar .home { width: 46px; }
  .tb-cell, .tb-stat { padding: 0 9px; }
  .tb-hide-m { display: none !important; }
  .tb-btn { padding: 0 10px; }
  .tb-btn .lbl { display: none; }
  .tb-stat .k { display: none; }
  .tb-stat .v { font-size: 15px; }
  .tb-cell .k { font-size: 10px; letter-spacing: .04em; }
  .rail { display: none; }
  .sidebar { left: 0; top: auto; height: 80%; }
  .sidebar:not(.open) { display: none; }
  .panel, .sidebar.wide .panel { width: 100%; border-left: 0; border-top: 1px solid var(--line-strong); border-radius: 10px 10px 0 0; animation: sheet .22s var(--ease-out); }
  @keyframes sheet { from { transform: translateY(40px); opacity: 0; } }
  .d-head::before { content: ""; position: absolute; top: 5px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 2px; background: var(--line-strong); }
  .bottom-nav { display: grid; grid-template-columns: repeat(5, 1fr); background: var(--surface); border-top: 1px solid var(--line); z-index: 20; padding-bottom: env(safe-area-inset-bottom); }
  .bottom-nav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; background: none; border: 0; color: var(--muted); font-size: 11px; position: relative; }
  .bottom-nav button[aria-current=page] { color: var(--accent); }
  .bottom-nav .dot { position: absolute; top: 6px; right: calc(50% - 16px); width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
  .legend { display: none; }
  .popup, .popup:has(.pop-cols.two) { width: calc(100% - 16px); max-height: 75%; }
  .pop-cols.two { grid-template-columns: 1fr; overflow-y: auto; }
  .pop-cols.two .jobs { border-right: 0; border-bottom: 1px solid var(--line); max-height: 150px; }
  .fin-top, .fboxes { grid-template-columns: 1fr; }
  .flags { grid-template-columns: repeat(2, 1fr); }
  .stats { grid-template-columns: 1fr; }
  .lobby-main { padding: 20px 14px; }
  .world-row { grid-template-columns: 1fr; }
  body { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}


/* ================= Styling pass (Kyle's choices, 2026-11-25) =================
   Rubik font · soft corners · compact spacing · soft-tint buttons · bold icons ·
   top bar without dividers + chips · lively motion · messages top right. */

/* small rounded bits that had hard-coded corners */
.chip, .paused-flag, .tooltip, .legend, .chart-tip, .crop, .tile, .warnbox, .est { border-radius: var(--radius-sm); }
.toast { border-radius: var(--radius); }

/* compact spacing */
.btn { min-height: 32px; padding: 4px 12px; }
.btn.sm { min-height: 28px; padding: 2px 9px; }
.btn.icon { width: 32px; }
.d-head { min-height: 48px; padding: 8px 10px 8px 14px; }
.d-body { padding: 2px 14px 18px; }
.d-tabs button { min-height: 38px; padding: 8px 9px 6px; }
h3.sec { margin: 14px 0 6px; }
.kv > div { padding: 6px 9px; }
.row { padding: 7px 10px; gap: 8px; }
.list .row .t { font-size: 14px; }
table.t td { padding: 5px 7px; }
.sorth, table.t th { padding: 5px 7px; }
.fline { padding: 4px 10px; }
.status-big { margin: 6px 0 8px; font-size: 18px; }
.chips { margin-top: 10px; }
.job { min-height: 32px; padding: 5px 10px; }
.menu button { min-height: 34px; padding: 6px 10px; }
.rail button { padding: 8px 4px; }
label.f, .f { margin: 8px 0 3px; }
input[type=text], input[type=password], input[type=number], select { min-height: 34px; padding: 5px 9px; border-radius: var(--radius-sm); }
@media (pointer: coarse) { .btn, .btn.sm { min-height: 44px; } .btn.icon { width: 44px; } .job, .menu button { min-height: 44px; } }

/* top bar: no dividers; workers and money as chips */
.tb-cell, .topbar .home { border: 0; }
.tb-btn { border-left: 0; border-radius: var(--radius); margin: 6px 2px; padding: 0 10px; }
.tb-stat { border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface-2); margin: 8px 4px; padding: 0 14px; flex-direction: row; align-items: center; gap: 8px; }
.tb-stat .k { display: none; }
.tb-stat .v { font-size: 15px; }
.tb-stat.money { background: rgba(224,165,38,.13); border-color: rgba(224,165,38,.35); }
.tb-stat:hover { background: var(--surface-3); }
.tb-stat.money:hover { background: rgba(224,165,38,.22); }

/* lively motion (reduced-motion users still get none — see the rule at the end of the file) */
@keyframes pin { 0% { transform: translateX(70px) scale(.96); opacity: 0; } 65% { transform: translateX(-6px) scale(1.01); opacity: 1; } 100% { transform: none; } }
.panel { animation: pin .42s var(--ease-out); }
@keyframes popin { 0% { transform: scale(.85); opacity: 0; } 70% { transform: scale(1.03); opacity: 1; } 100% { transform: none; } }
.popup { animation: popin .3s var(--ease-out); transform-origin: top left; }
.modal { animation: popin .3s var(--ease-out); }
@keyframes tin { 0% { transform: translateX(60px); opacity: 0; } 70% { transform: translateX(-6px); opacity: 1; } 100% { transform: none; } }
.btn, .tile, .job, .crop, .rail button, .tb-stat, .tb-btn { transition: background .15s, border-color .15s, transform .25s var(--spring); }
.btn:active:not(:disabled), .tile:active, .crop:active, .tb-stat:active { transform: scale(.94); }
.rail button:hover svg { transform: translateY(-2px); transition: transform .25s var(--spring); }

/* messages bottom centre (above the phone tab bar) */
.toast-wrap { left: 50%; right: auto; top: auto; bottom: 24px; transform: translateX(-50%); justify-items: center; }
@keyframes tin { 0% { transform: translateY(40px); opacity: 0; } 70% { transform: translateY(-5px); opacity: 1; } 100% { transform: none; } }
@media (max-width: 760px) { .toast-wrap { bottom: 72px; width: calc(100% - 16px); } .tb-stat { margin: 7px 2px; padding: 0 10px; } }
/* two-press confirm: armed buttons turn solid amber so the second press is obvious */
.btn.armed { background: var(--accent) !important; color: var(--accent-ink) !important; border-color: var(--accent) !important; animation: popin .25s var(--ease-out); }
@media (prefers-reduced-motion: reduce) { .panel, .popup, .modal, .toast { animation: none !important; } }

/* job menu: queued jobs on this field + compact crop list */
.fq { padding: 4px 6px 2px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.fq-h { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 2px 4px; }
.fq-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 13px; padding: 2px 4px; min-height: 28px; border-radius: var(--radius-sm); }
.fq-row.active { color: var(--primary-ink); }
.fq-tag { font-size: 11px; color: var(--primary-ink); }
.fq-x { background: none; border: 0; color: #ff8a82; cursor: pointer; width: 26px; height: 26px; display: grid; place-items: center; border-radius: var(--radius-sm); }
.fq-x:hover { background: rgba(229,83,75,.16); }
.croplist { grid-template-columns: 1fr; gap: 1px; max-height: 220px; padding: 2px; }
.crop { flex-direction: row; justify-content: space-between; align-items: center; padding: 3px 8px; min-height: 28px; }
.crop .cn { font-size: 13.5px; }
.crop .note { font-size: 11.5px; }
@media (pointer: coarse) { .crop, .fq-row { min-height: 38px; } .fq-x { width: 38px; height: 38px; } }

/* scheduled jobs */
.fq-when { font-size: 11px; color: var(--accent); background: rgba(224,165,38,.13); border-radius: var(--radius-sm); padding: 0 5px; margin-left: 4px; }
.pop-foot { justify-content: space-between; align-items: center; gap: 4px 8px; flex-wrap: wrap; }
.pop-foot .tiny { flex: 1 1 100%; text-align: center; }
@media (pointer: coarse) { .hide-coarse { display: none; } }

/* "server needs a restart" banner */
.stale { position: fixed; top: 0; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; gap: 8px; align-items: center;
  background: var(--accent); color: var(--accent-ink); padding: 8px 14px; border-radius: 0 0 var(--radius) var(--radius); font-size: 14px; box-shadow: var(--shadow); max-width: calc(100% - 16px); }

/* workers dropdown under the top-bar chip */
.wpop { position: fixed; z-index: 30; width: 300px; max-width: calc(100vw - 16px); background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg); box-shadow: 0 12px 32px rgba(0,0,0,.5); padding: 12px; animation: popin .25s var(--ease-out); transform-origin: top center; }
#wchip[aria-expanded=true] { background: var(--surface-3); border-color: var(--accent); }

/* problems: a job that was skipped or is waiting for money */
.flagtxt { color: #f3c55a; font-weight: 600; }
.toast.warn { border-left-color: #e0a526; }
