/* Sandtable UI. A War Office form and a C&C sidebar: sand, khaki, black type, one red.
   Flat fills, square corners, 1px ink rules. No gradients, no glow, no blur. */
:root {
  --st-sand: #d8cba4;
  --st-sand-deep: #c4b68c;
  --st-khaki: #a89a6b;
  --st-khaki-deep: #6f6643;
  --st-paper: #ece3c8;
  --st-ink: #1b1a14;
  --st-red: #a3281d;
  --st-olive: #2e5a2a;
  --st-side: 232px;
  --st-mono: "DejaVu Sans Mono", "Liberation Mono", Consolas, Menlo, monospace;
  --st-type: "Courier Prime", "Courier New", Courier, "Liberation Mono", monospace;
}

/* ---------- HUD ---------- */
.st-hud {
  position: fixed; top: 0; left: 0; right: var(--st-side); z-index: 5;
  pointer-events: none; font: 12px/1.35 var(--st-mono); color: var(--st-ink);
}
.st-k { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--st-khaki-deep); }
.st-bar {
  display: flex; align-items: baseline; gap: 22px; height: 32px; padding: 0 12px;
  background: var(--st-sand); border-bottom: 2px solid var(--st-ink); align-items: center;
  pointer-events: auto;
}
.st-stores b { font-size: 17px; letter-spacing: .02em; }
.st-delivery { min-width: 12ch; }
.st-selected { flex: 1; min-width: 0; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-clock { font-variant-numeric: tabular-nums; color: var(--st-khaki-deep); }
.st-orders {
  width: 310px; margin: 8px 0 0 8px; padding: 6px 12px 8px;
  background: var(--st-paper); border: 1px solid var(--st-ink);
}
.st-orders[hidden] { display: none; }
.st-orders ol { margin: 4px 0 0; padding-left: 18px; }
.st-orders li { margin: 2px 0; }
.st-orders li.done { text-decoration: line-through; color: var(--st-khaki-deep); }
.st-orders li.failed { color: var(--st-red); }
.st-sitrep { list-style: none; margin: 8px 0 0 8px; padding: 0; max-width: 440px; }
.st-sitrep li {
  margin: 0 0 3px; padding: 3px 10px; background: var(--st-paper);
  border: 1px solid var(--st-ink); border-left: 4px solid var(--st-red);
  opacity: 1; transition: opacity 1s linear;
}
.st-sitrep li.fading { opacity: 0; }

/* ---------- sidebar ---------- */
.st-side {
  position: fixed; top: 0; right: 0; bottom: 0; width: var(--st-side); z-index: 6; box-sizing: border-box;
  padding: 8px; overflow-y: auto; background: var(--st-sand-deep); border-left: 2px solid var(--st-ink);
  font: 12px/1.2 var(--st-mono); color: var(--st-ink); user-select: none; -webkit-user-select: none;
}
.st-minimap { margin: 0 0 4px; }
.st-minimap[hidden] { display: none; }
.st-minimap canvas { display: block; width: 200px; height: 200px; margin: 0 auto; cursor: crosshair; }
.st-line h2 {
  margin: 10px 0 6px; padding-bottom: 3px; border-bottom: 1px solid var(--st-ink);
  font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
}
.st-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.st-item {
  position: relative; box-sizing: border-box; width: 100%; aspect-ratio: 1; padding: 0; margin: 0;
  background: var(--st-paper); border: 1px solid var(--st-ink); border-radius: 0; color: var(--st-ink);
  font: inherit; cursor: pointer; text-align: center;
}
.st-item:hover { background: #f4edd6; }
.st-item:focus-visible { outline: 2px solid var(--st-ink); outline-offset: 1px; }
.st-icon { position: absolute; top: 8px; left: 50%; width: 30px; height: 30px; margin-left: -15px; fill: currentColor; }
.st-icon .w { fill: var(--st-paper); stroke: currentColor; stroke-width: 1.5; }
.st-ring { position: absolute; top: 3px; left: 50%; width: 40px; height: 40px; margin-left: -20px; display: none; }
.st-ring circle { fill: none; stroke-width: 3; }
.st-ring .trk { stroke: var(--st-khaki); }
.st-ring .arc { stroke: var(--st-ink); }
.st-item.building .st-ring, .st-item.ready .st-ring { display: block; }
.st-item.ready .st-ring .arc { stroke: var(--st-red); }
.st-name {
  position: absolute; left: 2px; right: 2px; bottom: 15px; font-size: 9px; letter-spacing: -.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.st-cost { position: absolute; left: 0; right: 0; bottom: 2px; font-size: 11px; font-weight: 700; }
.st-tag { position: absolute; top: 2px; right: 3px; font-size: 8px; font-weight: 700; letter-spacing: .06em; color: var(--st-red); }
.st-item.poor .st-cost { color: var(--st-red); }
.st-item.other { opacity: .6; }
.st-item.ready { border: 2px solid var(--st-red); }
.st-item.carried { background: var(--st-khaki); }
.st-item.locked { opacity: .4; filter: grayscale(1); cursor: not-allowed; background: var(--st-sand); }
.st-item.locked:hover { background: var(--st-sand); }

/* ---------- overlay on the map: selection marks, drag box, ghost ---------- */
.st-overlay { position: fixed; left: 0; top: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; }
.st-mark-under { fill: none; stroke: var(--st-ink); stroke-width: 4.5; }
.st-mark { fill: none; stroke: #f6f1dc; stroke-width: 2; }
.st-hpbar-back { fill: var(--st-ink); }
.st-hpbar.ok { fill: #4f7d2f; }
.st-hpbar.mid { fill: #c2a02e; }
.st-hpbar.low { fill: var(--st-red); }
.st-footprint { fill: none; stroke: #f6f1dc; stroke-width: 2; stroke-dasharray: 6 3; }
.st-ghost.ok { fill: rgba(46, 90, 42, .45); stroke: var(--st-olive); stroke-width: 2; }
.st-ghost.bad { fill: rgba(163, 40, 29, .45); stroke: var(--st-red); stroke-width: 2; }
.st-box { fill: rgba(246, 241, 220, .1); stroke: #f6f1dc; stroke-width: 1.5; }
.st-box[hidden] { display: none; }
canvas[data-cursor="attack"], canvas[data-cursor="place"] { cursor: crosshair; }
canvas[data-cursor="move"] { cursor: pointer; }
canvas[data-cursor="haul"] { cursor: copy; }
canvas[data-cursor="unload"] { cursor: alias; }

/* ---------- briefing sheet and its reverse ---------- */
.st-briefing {
  position: fixed; inset: 0; z-index: 100; overflow: auto; display: flex; padding: 24px 16px; box-sizing: border-box;
  background: #2a281f;
}
.st-sheet {
  box-sizing: border-box; width: calc(66ch + 76px); max-width: 100%; margin: auto; padding: 26px 38px 30px;
  background: var(--st-paper); color: var(--st-ink); border: 1px solid #000; box-shadow: 6px 6px 0 #14130e;
  font: 14px/1.4 var(--st-type);
}
.st-sheet.reverse { background: #e3d9ba; }
.st-sheet.turn { animation: st-turn .45s ease-out; }
@keyframes st-turn { from { transform: perspective(1400px) rotateY(88deg); } to { transform: perspective(1400px) rotateY(0); } }
.st-sheet .ln { white-space: pre; min-height: 1.4em; }
.st-sheet .ln-title { color: var(--st-red); font-size: 22px; line-height: 1.5; font-weight: 700; letter-spacing: .05em; }
.st-sheet .ln-head { font-weight: 700; letter-spacing: .18em; margin-top: 2px; }
.st-sheet .ln-rule { color: var(--st-khaki-deep); overflow: hidden; }
.st-sheet .ln-small { font-size: 11px; line-height: 1.45; letter-spacing: .03em; color: #3d3a2b; }
.st-sheet .ln-dispatch { color: #2c2a20; }
.st-sheet .ln-map { white-space: normal; margin: 4px 0 10px; }
.st-sheet .ln-map[hidden] { display: none; }
.st-strip { display: block; width: 100%; max-width: 560px; height: auto; }
.st-strip .road { fill: none; stroke: var(--st-ink); stroke-width: 2.5; }
.st-strip path { stroke: var(--st-ink); stroke-width: 1.5; fill: none; }
.st-strip .lead { stroke: var(--st-khaki-deep); stroke-width: .6; }
.st-strip text { font: 10px var(--st-type); fill: var(--st-ink); stroke: none; }
.st-strip .pin { fill: var(--st-red); stroke: var(--st-red); }
.st-strip text.pin { stroke: none; font-weight: 700; font-size: 11px; letter-spacing: .08em; }
.st-sheet .cap { font-size: 10px; color: #3d3a2b; margin-top: 2px; }
.st-sheet .ln-prompt { color: var(--st-red); font-weight: 700; letter-spacing: .12em; }
.st-sheet .ln-prompt.ready { cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.st-sheet .caret {
  display: inline-block; width: .6em; height: 1.05em; margin-left: 1px; vertical-align: text-bottom;
  background: var(--st-ink); animation: st-blink 1s steps(1) infinite;
}
@keyframes st-blink { 50% { opacity: 0; } }
@media (max-width: 760px) { .st-sheet { font-size: 12px; padding: 18px 16px 22px; width: 100%; } }
@media (prefers-reduced-motion: reduce) { .st-sheet.turn, .st-sheet .caret { animation: none; } }

/* ---------- engine-v7: the info card, autoplay's strip, the sheet's "watch it played" ---------- */
/* The card: a printed slip at the bottom left of the view, never over the sidebar. */
.st-info {
  position: fixed; left: 8px; bottom: 8px; z-index: 7; box-sizing: border-box;
  width: min(380px, calc(100vw - var(--st-side) - 16px)); max-height: max(260px, calc(100vh - 230px)); overflow-y: auto;
  padding: 8px 12px 10px; background: var(--st-paper); color: var(--st-ink);
  border: 1px solid var(--st-ink); border-left: 4px solid var(--st-ink); box-shadow: 3px 3px 0 rgba(20, 19, 14, .55);
  font: 12px/1.4 var(--st-mono);
}
.st-info[hidden] { display: none; }
.st-info[data-side="enemy"] { border-left-color: var(--st-red); }
.st-info header { display: flex; justify-content: space-between; align-items: baseline; }
.st-info-x {
  margin: -4px -6px 0 8px; padding: 0 6px; background: none; border: 0; color: var(--st-ink);
  font: 18px/1 var(--st-mono); cursor: pointer;
}
.st-info-x:focus-visible { outline: 1px solid var(--st-ink); }
.st-info h3 { margin: 2px 0 2px; font: 700 16px/1.25 var(--st-type); letter-spacing: .03em; }
.st-info p { margin: 2px 0 6px; }
.st-info .st-info-what { margin-bottom: 8px; }
.st-info .st-k { margin-top: 6px; padding-bottom: 1px; border-bottom: 1px solid var(--st-khaki); }
.st-info-stats { width: 100%; margin: 3px 0 6px; border-collapse: collapse; font-size: 11.5px; }
.st-info-stats th {
  width: 7.5em; padding: 1px 8px 1px 0; text-align: left; vertical-align: top; font-weight: 400;
  color: var(--st-khaki-deep);
}
.st-info-stats td { padding: 1px 0; font-variant-numeric: tabular-nums; }
.st-info-src { margin-top: 4px; font-size: 10px; color: #3d3a2b; }
.st-info-rowsrc { font-size: 10px; color: #3d3a2b; }
@media (max-width: 760px) { .st-info { max-height: 45vh; font-size: 11px; } }

/* Autoplay: one strip under the bar, at the right of the view. */
.st-auto {
  position: fixed; top: 40px; right: calc(var(--st-side) + 8px); z-index: 7; display: flex; flex-wrap: wrap;
  align-items: center; gap: 4px 10px; max-width: calc(100vw - var(--st-side) - 16px); box-sizing: border-box;
  padding: 4px 8px; background: var(--st-paper); border: 1px solid var(--st-ink);
  font: 11px/1.3 var(--st-mono); color: var(--st-ink);
}
.st-auto-label { font-weight: 700; letter-spacing: .1em; text-transform: uppercase; font-size: 10px; }
.st-auto-group { display: inline-flex; }
.st-auto button {
  padding: 2px 7px; margin: 0; background: var(--st-sand); border: 1px solid var(--st-ink); border-radius: 0;
  color: var(--st-ink); font: inherit; cursor: pointer;
}
.st-auto-group button + button { border-left: 0; }
.st-auto button:hover { background: #f4edd6; }
.st-auto button.on { background: var(--st-ink); color: var(--st-paper); }
.st-auto button:focus-visible { outline: 2px solid var(--st-ink); outline-offset: 1px; }
.st-auto-check { color: var(--st-khaki-deep); font-variant-numeric: tabular-nums; }
.st-auto-check.bad { color: var(--st-red); }
.st-auto .st-auto-take { border-color: var(--st-red); color: var(--st-red); background: var(--st-paper); font-weight: 700; }

/* The briefing sheet's second way in. */
.st-sheet .st-watch { margin-top: 10px; white-space: normal; font-size: 11px; color: #3d3a2b; }
.st-sheet .st-watch button {
  padding: 2px 8px; margin-right: 6px; background: none; border: 1px solid var(--st-ink); border-radius: 0;
  color: var(--st-ink); font: 700 12px var(--st-type); letter-spacing: .12em; cursor: pointer;
}
.st-sheet .st-watch button:hover { background: #f4edd6; }
