/* SwarmShield: a paper control sheet with a black instrument display.
   Flat surfaces, hairline rules, square corners, no gradients, no shadows. */
:root {
  --paper: #000000;
  --card: #070706;
  --ink: #e9e5da;
  --ink-2: #b6b1a4;
  --muted: #8b887c;
  --faint: #67645c;
  --rule: #26251f;
  --rule-hard: #3d3b33;
  --display: #000000;
  --signal: #d2492c;
  --ok: #4bb583;
  --arena: min(72vh, 660px);
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  --sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }
a:hover { color: var(--signal); }

kbd {
  font-family: var(--mono); font-size: 11px; padding: 0 4px;
  border: 1px solid var(--rule); background: #111;
}

/* ------------------------------------------------------------------ header */
.top {
  display: flex; align-items: baseline; gap: 20px;
  padding: 14px 22px 13px;
  border-bottom: 1px solid var(--rule-hard);
  background: var(--paper);
}
.brand {
  display: flex; align-items: baseline; gap: 9px; flex: none;
  font-family: var(--mono); font-weight: 600; font-size: 14px;
  letter-spacing: 0.18em; text-transform: uppercase;
}
.pip { width: 6px; height: 6px; background: var(--signal); transform: translateY(-1px); }
.tagline {
  flex: 1; color: var(--muted); font-size: 13px;
  font-family: var(--mono); letter-spacing: -0.01em;
}

/* -------------------------------------------------------------------- main */
main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 316px;
  max-width: 1200px;
  margin: 0 auto;
  border-left: 1px solid var(--rule);
  border-right: 1px solid var(--rule);
}

.stage { padding: 22px; border-right: 1px solid var(--rule); min-width: 0; }

.arena-wrap {
  position: relative;
  aspect-ratio: 1 / 1;
  height: var(--arena);
  width: auto;
  max-width: 100%;
  margin: 0 auto;
  background: var(--display);
  border: 1px solid var(--rule-hard);
}
#arena { display: block; width: 100%; height: 100%; cursor: crosshair; touch-action: manipulation; }
/* A caption under the field, never over it: the world boundary is drawn at the
   very bottom of the canvas and used to strike straight through this line. */
.hint {
  width: var(--arena); max-width: 100%; margin: 9px auto 0;
  font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.02em;
  color: var(--faint); text-align: center;
}
.hint b { color: var(--muted); font-weight: 400; }

/* ----------------------------------------------------------------- readout */
.readout {
  width: var(--arena); max-width: 100%; margin: 18px auto 0;
  display: grid;
  border: 1px solid var(--rule-hard);
}
.stat { padding: 7px 9px 8px; border-right: 1px solid var(--rule); min-width: 0; }
.stat:last-child { border-right: none; }

/* The strip is min(72vh, 660px) wide, so how many labels fit depends on the
   viewport HEIGHT as much as its width: seven columns only hold one line each
   on a tall screen. Four is the default; seven is opted into. */
.readout { grid-template-columns: repeat(4, 1fr); }
.stat:nth-child(-n+4) { border-bottom: 1px solid var(--rule); }
.stat:nth-child(4n) { border-right: none; }
.stat:last-child { grid-column: span 2; border-right: none; }

@media (min-width: 1021px) and (min-height: 880px) {
  .readout { grid-template-columns: repeat(7, 1fr); }
  .stat { border-bottom: none; border-right: 1px solid var(--rule); }
  .stat:last-child { grid-column: auto; border-right: none; }
}
.stat span {
  display: block; font-family: var(--mono); font-size: 9.5px;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stat b {
  display: block; font-family: var(--mono); font-size: 19px; font-weight: 500;
  font-variant-numeric: tabular-nums; margin-top: 1px; letter-spacing: -0.03em;
}
.stat b.good { color: var(--ok); }
.stat b.bad { color: var(--signal); }

/* ------------------------------------------------------------------- panel */
.panel { background: var(--card); }
.group { padding: 16px 18px 18px; border-bottom: 1px solid var(--rule); }
.group:last-child { border-bottom: none; }
.group h2 {
  margin: 0 0 12px; font-family: var(--mono); font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink);
}
.note { margin: 12px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--ink-2); }
.note.dim { color: var(--muted); font-size: 12px; }

button, select {
  font-family: var(--mono); font-size: 12px; color: var(--ink);
  background: transparent; border: 1px solid var(--rule);
  border-radius: 0; padding: 7px 10px; cursor: pointer;
  letter-spacing: 0.01em;
}
button:hover:not(:disabled) { border-color: var(--ink); }
button:disabled { color: var(--faint); border-style: dashed; cursor: not-allowed; }
button.on { background: var(--ink); border-color: var(--ink); color: #000; }
button em {
  font-style: normal; font-size: 9.5px; color: var(--faint);
  display: block; letter-spacing: 0.08em; text-transform: uppercase; margin-top: 2px;
}
button.on em { color: #4a4740; }

.seg { display: grid; grid-template-columns: 1fr 1fr; }
.seg button { padding: 9px 8px; text-align: center; }
.seg button:first-child { border-right: none; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { padding: 6px 9px; font-size: 11.5px; }

.row { display: grid; grid-template-columns: 1fr 1fr; }
.row button:first-child { border-right: none; }
.wide { width: 100%; }

select { width: 100%; padding: 7px 8px; }

.slider { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.slider input { flex: 1; accent-color: var(--ink); }
.slider b { font-size: 12.5px; color: var(--ink); min-width: 30px; text-align: right; letter-spacing: 0; }

.tally { display: grid; grid-template-columns: 1fr 1fr; margin-top: 14px; border: 1px solid var(--rule); }
.tally div { padding: 7px 9px; }
.tally div:first-child { border-right: 1px solid var(--rule); }
.tally span {
  display: block; font-family: var(--mono); font-size: 9.5px;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint);
}
.tally b { font-family: var(--mono); font-size: 13.5px; font-weight: 500; font-variant-numeric: tabular-nums; }

.legend { display: flex; flex-direction: column; gap: 5px; margin-top: 14px; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 8px; }
.dot { width: 9px; height: 9px; flex: none; }
.dot.g { background: #3ecf8e; }
.dot.a { background: #e0b04e; }
.dot.r { background: var(--signal); }

/* ------------------------------------------------------------------ footer */
footer {
  max-width: 1200px; margin: 0 auto; padding: 20px 22px 52px;
  border: 1px solid var(--rule); border-top: 1px solid var(--rule-hard); border-bottom: none;
}
footer p { max-width: 78ch; font-size: 13px; color: var(--ink-2); margin: 0 0 10px; }
footer p.dim { color: var(--muted); font-size: 12px; margin-bottom: 0; }
footer b { font-family: var(--mono); font-weight: 500; }

/* -------------------------------------------------------------- responsive */
@media (max-width: 1020px) {
  main { grid-template-columns: 1fr; }
  .stage { border-right: none; border-bottom: 1px solid var(--rule); }
  .panel { display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
  .group { border-right: 1px solid var(--rule); }
  :root { --arena: min(62vh, 560px); }
}
@media (max-width: 700px) {
  .top { flex-wrap: wrap; gap: 8px 14px; padding: 12px 14px; }
  .tagline { order: 3; flex-basis: 100%; font-size: 12px; }
  .stage { padding: 14px; }
  .panel { grid-template-columns: 1fr; }
  .group { border-right: none; }
  .readout { grid-template-columns: repeat(2, 1fr); }
  .stat { border-bottom: 1px solid var(--rule); border-right: none; }
  .stat:nth-child(odd) { border-right: 1px solid var(--rule); }
  .stat:last-child { grid-column: span 2; border-bottom: none; border-right: none; }
  .arena-wrap { height: auto; width: 100%; }
  .readout { width: 100%; }
  footer { padding: 18px 14px 44px; border-left: none; border-right: none; }
}
