.live .app { padding: 14px clamp(8px, 2vw, 28px); }
.live .topbar { justify-content: flex-start; gap: 10px; padding-bottom: 10px; }
.live .brand { margin-right: auto; }
.live .view-note { display: flex; align-items: center; gap: 8px; text-align: left; }
.live .agent-docs { color: var(--gold); font-size: 12px; }
.live #match-reconnect {
  padding: 20px 32px; text-align: center; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px;
}
.live #match-reconnect::backdrop { background: rgb(0 0 0 / 45%); }
.live #match-reconnect h2 { margin: 0; font-size: 18px; }
.live #match-reconnect p { margin: 6px 0 0; color: var(--muted); }
.live #match-reconnect .agent-docs { display: inline-block; margin-top: 12px; }
.live #match-reconnect button {
  margin: 12px 8px 0 0; min-height: 44px; padding: 6px 12px;
  color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 7px; cursor: pointer;
}
.live .match-strip { grid-template-columns: auto minmax(0, 1fr) auto; gap: clamp(14px, 4vw, 64px); margin-bottom: 10px; }
.live .match-strip[hidden] { display: none; }
.live .score.red { text-align: right; }
.live .timeline { position: relative; margin: 0; }
.live .tl-bar { margin: 17px 0 5px; }
.live #clock {
  position: absolute; bottom: 8px; transform: translateX(-50%); padding: 1px 4px;
  border-radius: 3px; background: #1a262b; font-size: 11px; color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.live #match-result { position: absolute; right: 0; top: 0; color: var(--gold); }
.live .workspace { display: block; }
.live .board-panel {
  --map-height: clamp(400px, calc(100dvh - 170px), 950px);
  max-width: calc(var(--map-height) * 1.55); margin-inline: auto;
  padding: clamp(5px, 1vw, 10px);
}
.live .board-stage { aspect-ratio: auto; min-height: 0; }
.live .board-stage[data-layout="square"] {
  background: radial-gradient(ellipse at 50% 36%, #fffcf1, #eee2ca);
  border-color: #d9c7a6;
}
.live:has(.board-stage[data-layout="square"]) {
  color-scheme: light;
  --bg: #f5eddc;
  --panel: #fff9e9;
  --panel-2: #f8edda;
  --line: #d7c4a2;
  --text: #433727;
  --muted: #74604b;
  --gold: #86601f;
  --blue: #1659a1;
  --red: #a53b28;
  background: radial-gradient(ellipse at 50% 0, #fffaf0, var(--bg));
}
.live:has(.board-stage[data-layout="square"]) .match-strip {
  background: linear-gradient(#fffbef, #f3e5cc);
}
.live .board-panel:has(> .board-stage[data-layout="square"]) {
  background: #fcf3df;
  padding: 5px;
}
.live:has(.board-stage[data-layout="square"]) .tl-bar { background: #dac6a1; }
.live:has(.board-stage[data-layout="square"]) #clock,
.live .board-stage[data-layout="square"] #match-controls {
  background: #fff4dfee;
  border-color: #cbb38a;
  box-shadow: 0 2px 7px #6c4d2725;
}
.live .board-stage[data-layout="square"] #match-error { color: #a53b28; }
.live .board-stage[data-layout="square"] > #match-controls {
  top: 8px;
  left: auto;
  right: 8px;
  transform: none;
  padding: 5px;
}
.live .board-stage[data-layout="square"] #run-demo { padding: 7px 12px; font-size: 13px; }
.live #board { height: var(--map-height); }
.live .board-stage[data-layout="square"] > #board {
  touch-action: none;
  cursor: grab;
}
.live .board-stage[data-layout="square"] > #board:active { cursor: grabbing; }
.selection-box {
  position: absolute; pointer-events: none; z-index: 1;
  border: 2px dashed #d7efff; background: #79bdee38;
}
#match-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.live .board-stage > #match-controls {
  position: absolute; z-index: 3; top: 50%; left: 50%; transform: translate(-50%, -50%);
  flex-direction: column;
  padding: 12px;
  border-radius: 12px;
  background: #1b282d;
  box-shadow: 0 6px 30px #0a1016b0;
}
#match-controls:not(:has(> :not([hidden]))) { display: none; }
#match-error {
  margin: 0; max-width: min(260px, 68vw); color: #ffbbad; font-size: 13px;
}
#match-controls:has(> button[hidden]) > #match-error { font-size: 18px; font-weight: 700; }
.live .board-stage #run-demo {
  background: #ebcb82; color: #241c12; border: 1px solid #f8dfa7; border-radius: 10px;
  padding: 14px 24px; font-weight: 700; font-size: 18px; white-space: nowrap; cursor: pointer;
}
.live .board-stage #run-demo:hover:not(:disabled) { background: #f5d994; }
.live .board-error { z-index: 4; }
#map-inspector {
  position: absolute; z-index: 2; width: max-content;
  min-width: min(108px, calc(100% - 16px)); max-width: min(210px, calc(100% - 16px));
  padding: 8px 12px; border: 1px solid #b08b50; border-radius: 6px;
  color: #48351f; background: linear-gradient(145deg, #fff8e6, #f3e0b7);
  box-shadow: 0 3px 12px #2f261965; font-size: 12px; pointer-events: none;
}
#map-inspector::before {
  position: absolute; width: 10px; height: 10px; content: "";
  background: #f9edcf; border: solid #b08b50; border-width: 0 0 1px 1px;
}
#map-inspector[data-side="right"]::before {
  left: 0; top: var(--inspector-tip-y); transform: translate(-55%, -50%) rotate(45deg);
}
#map-inspector[data-side="left"]::before {
  right: 0; top: var(--inspector-tip-y); transform: translate(55%, -50%) rotate(225deg);
}
#map-inspector[data-side="above"]::before {
  bottom: 0; left: var(--inspector-tip-x); transform: translate(-50%, 55%) rotate(-45deg);
}
#map-inspector[data-side="below"]::before {
  top: 0; left: var(--inspector-tip-x); transform: translate(-50%, -55%) rotate(135deg);
}
.live #selection-card { display: grid; grid-template-columns: auto auto; align-items: baseline; gap: 3px 8px; min-height: 0; }
.live #selection-card strong { font: 700 17px/1.1 Georgia, serif; overflow-wrap: anywhere; }
.live #selection-card small { grid-column: 1 / -1; color: #674b2b; font-size: 12px; overflow-wrap: anywhere; }
.live .unit-strength { color: #79531b; font-variant-numeric: tabular-nums; white-space: nowrap; }
.combat-feedback, .combat-weapons, .unit-hud {
  position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none;
}
.live-announcement, .live :is(#status, #selection-status) {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.combat-hit:not(.landed) { visibility: hidden; }
.combat-spark { fill: #fff4ce; stroke: #a96532; stroke-width: 1px; stroke-linejoin: round; }
.combat-hit.landed .combat-spark { animation: hit-spark 230ms ease-out var(--impact-age, 0ms) both paused; }
.combat-hit.lethal .combat-spark { fill: #ffcf75; stroke: #753f2b; stroke-width: 1.7px; }
.combat-hit text {
  fill: #fff1de; stroke: #39201c; stroke-width: 2.5px; paint-order: stroke; text-anchor: middle;
  font-size: 15px; font-weight: 750;
}
.combat-hit.landed text { animation: floating-damage var(--damage-fade) ease-out var(--impact-age, 0ms) both paused; }
@keyframes hit-spark {
  0% { opacity: 1; transform: scale(.45); }
  30% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.35); }
}
@keyframes floating-damage { from { transform: translateY(0); } to { transform: translateY(-14px); opacity: 0; } }
@media (max-width: 560px) {
  .live .brand { font-size: 16px; gap: 5px; }
  .live .crest { width: 20px; height: 20px; }
  .live .view-note span, .live .view-note a { font-size: 10px; }
  .live .match-strip { padding: 8px 10px; }
  .live .score strong { font-size: 17px; }
  .live .score .team { font-size: 8px; }
  .live .tl-label { font-size: 8px; }
  .live .tl-ticks { font-size: 8px; }
  .live #board { height: auto; aspect-ratio: 1.13; }
  .combat-hit text { font-size: 11px; }
}
@media (max-width: 560px), (max-height: 560px) and (pointer: coarse) {
  .live .app:has(.board-stage[data-layout="square"]) {
    height: 100dvh;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    padding: 6px 8px;
  }
  .live .workspace:has(.board-stage[data-layout="square"]) {
    display: grid;
    grid-area: 3 / 1;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
  }
  .live .board-panel:has(> .board-stage[data-layout="square"]) {
    display: grid;
    grid-template-rows: minmax(0, 1fr);
    width: 100%;
    max-width: none;
  }
  .live .board-stage[data-layout="square"] {
    display: grid;
    grid-template-rows: minmax(0, 1fr);
  }
  .live .board-stage[data-layout="square"] > #board {
    --min-camera-tile-width: 46px;
    height: 100%;
    min-height: 0;
    aspect-ratio: auto;
  }
}
