/* /live and /live/embed keep the 0.5 three-column layout (0.6 moved /play to static/css/layout.css's map-first shell); the sizes it reads
   that the play page no longer has live here. */
:root { --orders-h: calc(var(--tap) + 14px); --tasks-min: 10rem; --coach-max: 28dvh; --side-w: 140px; }
@media (max-width: 600px) { :root { --side-w: 8px; } }
/* /play layout, top-down site: the map fills the screen under a top bar, the tasks sit on the left and the fleet on the right (both
   under the map on a phone), and the page never scrolls (design section 11). Panels scroll only inside themselves (.scroll).
   Functional text never computes under 12 px (tests/test_client_static.py and the edge size check hold it at 11 or more). */
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--ink); height: 100dvh; display: flex; flex-direction: column; overflow: hidden;
  font: clamp(12px, 0.35vw + 10px, 18px)/1.4 var(--font); }
/* The parts the browser draws carry the palette too. */
::selection { background: var(--accent); color: var(--accent-ink); }
* { scrollbar-color: var(--line) transparent; scrollbar-width: thin; }
input, select, textarea { caret-color: var(--accent); }
.num, .stat b, .rep-bar .dim { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.y-kv dd, .card-load, .task-count { font-variant-numeric: tabular-nums; }
#tn-nav-host { flex: none; display: flex; justify-content: flex-end; padding: 3px 8px 0; }
/* Panel heads read like the stencilled header of a form: capitals, heavy, a ruled line under them. */
h2 { margin: 0 0 8px; padding-bottom: 4px; font-size: max(12px, 0.92em); font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em;
  border-bottom: 2px solid var(--rule); }
.sheet-head h2, .overlay h2 { border-bottom: 0; padding-bottom: 0; }
h3 { margin: 12px 0 4px; font-size: 1em; font-weight: 700; }
p { margin: 0 0 6px; }
.dim { color: var(--dim); }
.scroll { overflow: auto; min-height: 0; }

#app { flex: 1; min-height: 0; display: grid; gap: var(--gap); padding: var(--gap);
  grid-template-columns: var(--tasks-w) minmax(0, 1fr) var(--fleet-w); grid-template-rows: auto minmax(var(--tasks-min), 1fr) auto;
  grid-template-areas: "top top top" "tasks stage fleet" "coach stage fleet"; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; min-height: 0; min-width: 0; overflow: hidden;
  display: flex; flex-direction: column; box-sizing: border-box; }
#top { grid-area: top; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; padding: 6px 10px; flex-direction: row; }
#stage { grid-area: stage; position: relative; min-height: 0; min-width: 0; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
#p-fleet { grid-area: fleet; }
#p-tasks { grid-area: tasks; gap: 6px; }
/* The brief folds to a few lines (a click or Enter opens it), so the task list under it keeps its room. */
#j-brief[data-open="0"] { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; cursor: pointer; }
#j-brief[data-open] { cursor: pointer; }
#task-list { min-height: 6rem; }
/* The coach sits under the tasks, beside the map, so it never covers the ground being worked; it takes at most --coach-max of the
   screen height and scrolls inside itself. */
#coach { grid-area: coach; gap: 6px; max-height: var(--coach-max); }
#coach[hidden] { display: none; }
#app:not([data-screen="yard"]) #coach[data-state="off"] { display: none; }

/* top bar */
.stat { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.stat b { font-size: 1.15em; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat.job { max-width: 34ch; }
/* The clock and the cash keep one width while their text grows, so the speed buttons beside them never move (Mill Creek #12). */
#t-clock { display: inline-block; width: 28ch; }   /* fixed: the longest clock, "Day 120, 01:30 (before work)", fits */
#t-cash { display: inline-block; min-width: 8ch; }
.stat .k { color: var(--dim); font-size: max(12px, 0.8em); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.stat.job b { font-family: var(--font); font-weight: 800; }
.grow { flex: 1; }
.speed { display: flex; gap: 4px; }
#t-conn { font-size: max(12px, 0.9em); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; white-space: nowrap; }
#t-conn[data-s="live"]::before { content: "\25CF  "; color: var(--good); }
#t-conn[data-s="wait"]::before, #t-conn[data-s="down"]::before { content: "\25B2  "; color: var(--bad); }
.ic { width: 1.25em; height: 1.25em; vertical-align: -0.25em; margin-right: 0.3em; flex: none; }

/* controls */
.btn { min-height: var(--tap); min-width: var(--tap); box-sizing: border-box; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel2); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; transition: border-color 120ms ease-out, background-color 120ms ease-out; }
.btn:hover { border-color: var(--accent); }
.btn:focus-visible, .card:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn[aria-pressed="true"] { background: var(--sel-bg); color: var(--ink); border: 2px solid var(--accent); font-weight: 800; }
.btn:disabled { opacity: 0.5; cursor: default; }

/* The map. The stage is a grid: the ground in the first row with its floating tools laid over it as grid items, and a fixed row
   under it (--orders-h) for the order bar. The bar stands on the stage's foot and grows upward over the ground when a machine's
   orders take more lines, so the map's size never changes when a machine is picked (Mill Creek run 4 #1: the map jumped 95 px and the
   next click landed on empty ground). */
#stage { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) var(--orders-h); }
#stage > * { grid-column: 1; grid-row: 1; position: relative; }
#view { display: block; width: 100%; height: 100%; min-height: 0; touch-action: none; cursor: crosshair; background: var(--void); }
#view:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.vh { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
#stage > .vh { position: absolute; }
/* The Pixi stage (stage.js) lies over #view in the same cell and lets every pointer through to it. */
#stage > .scene { pointer-events: none; }
#stage > .scene canvas { display: block; width: 100%; height: 100%; }
.float { margin: 0; padding: 6px 10px; border-radius: var(--radius); background: var(--panel); color: var(--ink); border: 1px solid var(--line); }
#readout { align-self: start; justify-self: start; margin: 8px; display: flex; flex-direction: column; gap: 1px; font-variant-numeric: tabular-nums;
  pointer-events: none; z-index: 2; }
#readout[hidden] { display: none; }
#msg, #alert { align-self: start; justify-self: center; margin: 8px 0 0; padding: 6px 10px; border-radius: var(--radius); background: var(--panel);
  color: var(--ink); max-width: min(60ch, calc(100% - 2 * var(--side-w))); z-index: 3; }
#msg { border: 1px solid var(--accent); }
#msg:empty { display: none; }
#alert { margin-top: calc(var(--tap) + 20px); border: 2px solid var(--bad); font-weight: 700; }
#alert:empty { display: none; }
.side-tools { align-self: start; justify-self: end; margin: 8px; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; z-index: 2; }
#overlay { flex-direction: column; align-items: flex-end; }
#layers { display: none; }
#legend { max-width: 28ch; }
#legend[hidden] { display: none; }
/* The minimap sits under the fleet list, beside the map, so it never covers a corner of the site. */
#mini { flex: none; align-self: center; margin: 8px 0 0; width: min(100%, var(--mini-w)); aspect-ratio: 1; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--void); cursor: pointer; touch-action: none; }
#fleet-list { flex: 1 1 auto; }
/* Paused: a small strip on the map's top edge while the clock stands still, so it never hides a machine; the notes under it move down. */
#paused { align-self: start; justify-self: center; z-index: 3; pointer-events: none; max-width: calc(100% - 32px); margin: 0; padding: 2px 10px;
  border: 2px solid var(--hazard); border-top: 0; border-radius: 0 0 var(--radius) var(--radius); font-size: max(12px, 0.9em); font-weight: 800; text-align: center; }
#paused[hidden] { display: none; }
#stage:has(#paused:not([hidden])) #msg { margin-top: calc(1.6em + 12px); }
#stage:has(#paused:not([hidden])) #alert { margin-top: calc(var(--tap) + 1.6em + 24px); }
/* Every task holds: a banner under the top edge of the map with Hand in and Keep working, over the notes. */
#done-banner { align-self: start; justify-self: center; z-index: 5; margin: 8px 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px;
  border: 2px solid var(--good); max-width: calc(100% - 2 * var(--side-w)); }
#done-banner[hidden] { display: none; }
#stage:has(#paused:not([hidden])) #done-banner { margin-top: calc(1.6em + 12px); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }

/* The order bar: a dispatch strip under the map. The picked machine (its sprite and name), its orders in groups with a rule between
   them, and what a click on the map will do now. */
#stage > #orders { position: absolute; left: 0; right: 0; bottom: 0; grid-row: 1 / span 2; }
#orders { z-index: 4; overflow: visible; border: 0; border-top: 2px solid var(--line); border-radius: 0; padding: 6px 10px; gap: 4px 10px;
  flex-direction: row; flex-wrap: wrap; align-items: center; min-height: var(--orders-h); max-height: 100%; }
#orders #o-pic { --s: 40px; margin: -4px 0; }
#orders[data-picked="0"] #o-pic { display: none; }
#o-name { font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
#o-ops { flex: 1 1 calc(100% - 14rem); min-width: 0; flex-wrap: wrap; gap: 4px; order: 1; }
#orders .o-more { order: 3; flex: 0 1 auto; }
#orders:has(.op-pick) .o-more { flex: 1 1 100%; }
/* A group is not a box: its buttons wrap one by one with the rest; a wider gap and a rule open each group after the first. */
.o-group { display: contents; }
.o-group + .o-group > .o-op:first-child { margin-left: 6px; box-shadow: -7px 0 0 -6px var(--rule); }
.o-op { flex: none; display: inline-flex; align-items: center; padding: 0 10px 0 8px; white-space: nowrap; }
.o-op .ic { width: 1.15em; height: 1.15em; color: var(--dim); }
.o-op[aria-pressed="true"] .ic { color: var(--accent); }
#orders p { margin: 0; flex: 1 1 24ch; }
#orders[data-armed="1"] #o-hint { color: var(--ink); font-weight: 700; }   /* an armed order says so in full ink */
#orders #o-hint { order: 2; flex: 1 1 24ch; min-width: 0; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }   /* width from flex, not from the text: a longer hint never re-wraps the buttons under the pointer */
#orders[data-picked="0"] #o-ops { display: none; }
#orders .o-fix { order: 1; flex: 1 1 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
#orders .o-fix[hidden] { display: none; }
#orders .o-fix p { flex: 1 1 24ch; font-weight: 600; color: var(--ink); }

/* A phone: the map takes most of the height; the top bar is one row that slides sideways; the order bar's groups slide sideways in one
   row; tasks and the fleet are short strips under the map; the readout and the legend give the map its room. */
@media (max-width: 600px) {
  #app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto auto auto;
    grid-template-areas: "top" "stage" "coach" "tasks" "fleet"; }
  #rt-dock { grid-area: tasks; }   /* the routine form under the map, in the tasks panel's place */
  #rt-dock .rt-form { max-height: 60dvh; }
  #top { flex-wrap: nowrap; gap: 4px 6px; padding: 4px 8px; }
  #top > * { flex: none; }
  #t-clock, #t-cash { min-width: 0; width: auto; }
  .stat.job { display: none; }
  #t-conn { display: none; }
  #coach { max-height: 20dvh; padding: 6px; }
  #coach[data-state="off"] { display: none; }      /* Help brings it back; the map keeps the room */
  .coach-steps { display: none; }
  #p-tasks { padding: 6px; gap: 4px; }
  #p-tasks h2, #j-client, #j-brief { display: none; }
  #p-tasks #task-list { flex-direction: row; overflow-x: auto; overflow-y: hidden; }
  #task-list .task { flex: 0 0 auto; width: 78%; grid-template-columns: minmax(0, 1fr) auto auto; padding: 4px 6px; }
  #task-list .task .task-head { grid-column: 1; }
  #task-list .task progress, #task-list .task .task-dig, #task-list .task .task-haul, #task-list .task .task-fill { display: none; }
  #p-tasks { max-height: none; }
  #layers { display: inline-block; }
  .side-tools:not([data-open="1"]) #overlay { display: none; }
  #p-fleet { padding: 6px; }
  #p-fleet h2 { display: none; }
  #fleet-list { display: flex; gap: 6px; overflow-x: auto; overflow-y: hidden; }
  #fleet-list .card { flex: 0 0 auto; width: 44%; min-height: var(--tap); margin: 0; }
  #fleet-list .card .card-op, #fleet-list .card .card-load { display: none; }
  #readout { display: none; }
  #orders { padding: 4px 6px; }
  #o-ops { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; }
  #orders #o-hint, #submit-why { display: none; }   /* the words by the pointer still say what a tap will do */
  #fleet-list .card > .y-pic { --s: 32px; grid-row: 1 / span 2; }
  #fleet-list .card .card-row .k { display: none; }
  #msg, #alert { max-width: calc(100% - 16px); }
  #overlay { max-width: 18ch; }
  #legend { display: none; }
  #mini { display: none; }
}

/* A short screen (a phone on its side, client.layouts.short_max_h): the map on the left at full height, tasks, coach and fleet stacked
   in a column on the right, the top bar without the job name, the order bar one sliding row with no hint. */
@media (max-height: 500px) and (min-width: 601px) {
  #app { grid-template-columns: minmax(0, 1fr) var(--fleet-w); grid-template-rows: auto minmax(0, 1fr) auto minmax(0, 1fr);
    grid-template-areas: "top top" "stage tasks" "stage coach" "stage fleet"; }
  #rt-dock { grid-column: 2; grid-row: 2 / span 2; }
  #top { gap: 2px 8px; padding: 2px 8px; }
  .stat.job, #t-conn { display: none; }
  #coach { max-height: 30dvh; padding: 6px; }
  #coach[data-state="off"] { display: none; }
  #p-tasks, #p-fleet { padding: 6px; }
  #p-tasks h2, #j-client, #j-brief, #submit-why, #p-fleet h2 { display: none; }
  #orders { padding: 2px 6px; }
  #orders #o-hint, #orders #o-pic { display: none; }
  #o-ops { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; }
  #readout, #legend, #mini { display: none; }
  #layers { display: inline-block; }
  .side-tools:not([data-open="1"]) #overlay { display: none; }
}
/* A touch screen gets thumb-sized controls whatever its width. */
@media (pointer: coarse) {
  :root { --tap: 44px; }
}
/* The notch and the home bar: keep the page inside the safe area. */
#app { padding-left: max(var(--gap), env(safe-area-inset-left)); padding-right: max(var(--gap), env(safe-area-inset-right));
  padding-bottom: max(var(--gap), env(safe-area-inset-bottom)); }

