/* Spectator battlefield HUD. The 3D canvas fills the screen; HUD panels float over it. */
.battle-body { overflow: hidden; background: #0b0c12; }
.battle { position: fixed; inset: 0; color: var(--ink-200); font-family: var(--font-body); }
.battle-canvas { position: absolute; inset: 0; }
.battle-canvas canvas { display: block; width: 100%; height: 100%; outline: none; }
.battle-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.battle-labels.off { display: none; }

.hud {
  position: absolute; z-index: 5;
  background: rgba(11, 12, 18, 0.72); backdrop-filter: blur(8px);
  border: 1px solid rgba(217, 164, 65, 0.22); border-radius: 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.45);
}
.hud-top { top: 14px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 1rem; padding: 0.5rem 1rem 0.5rem 0.6rem; max-width: calc(100% - 32px); }
.hud-back { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--ink-800); color: var(--gold); flex: none; }
.hud-back .icon { width: 24px; height: 24px; }
.hud-title { min-width: 0; }
.hud-name { font-family: var(--font-display); color: var(--parchment); font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-sub { font-size: 0.8rem; color: var(--ink-300); white-space: nowrap; }
.hud-timer { font-family: var(--font-display); font-size: 1.6rem; color: var(--gold-bright); padding-left: 1rem; border-left: 1px solid var(--ink-700); white-space: nowrap; }
.hud-timer.urgent { color: #ff7b8b; }
.hud-agent { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.35rem 0.6rem; border-radius: 8px; border: 1px solid rgba(217, 164, 65, 0.35); color: var(--gold-bright); font-size: 0.8rem; text-decoration: none; white-space: nowrap; }
.hud-agent:hover { background: rgba(217, 164, 65, 0.12); }
@media (max-width: 640px) { .hud-agent span { display: none; } }

.hud-players { top: 14px; left: 14px; width: 270px; padding: 0.5rem; display: flex; flex-direction: column; gap: 0.4rem; max-height: calc(100% - 120px); overflow: auto; }
.pcard { --c: #888; display: grid; grid-template-columns: 6px 1fr; gap: 0.6rem; padding: 0.55rem 0.6rem; border-radius: 10px; background: rgba(255,255,255,0.03); cursor: pointer; border: 1px solid transparent; text-align: left; color: inherit; font: inherit; width: 100%; }
.pcard:hover { border-color: color-mix(in srgb, var(--c) 60%, transparent); background: rgba(255,255,255,0.06); }
.pcard.focused { border-color: var(--c); }
.pcard .fog-eye { margin-left: auto; opacity: 0.35; font-size: 0.85rem; cursor: pointer; filter: grayscale(1); }
.pcard .fog-eye:hover { opacity: 0.8; }
.pcard .fog-eye.on { opacity: 1; filter: none; }
.pcard .stripe { border-radius: 6px; background: var(--c); box-shadow: 0 0 12px var(--c); }
.pcard > span:last-child { display: block; min-width: 0; }
.pcard .pmeta { display: block; }
.pcard .pname { display: flex; justify-content: space-between; gap: 0.4rem; align-items: baseline; }
.pcard .pname strong { font-family: var(--font-display); color: var(--parchment); font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcard .pmeta { font-size: 0.74rem; color: var(--ink-300); }
.pcard .pbar { display: block; height: 7px; border-radius: 999px; background: rgba(0,0,0,0.5); overflow: hidden; margin: 0.3rem 0 0.2rem; }
.pcard .pbar span { display: block; height: 100%; background: linear-gradient(90deg, color-mix(in srgb, var(--c) 70%, #000), var(--c)); transition: width 0.4s ease; }
.pcard .pstats { display: flex; gap: 0.7rem; font-size: 0.74rem; color: var(--ink-300); }
.pcard .pstats b { color: var(--parchment); }
.pcard.out { opacity: 0.55; }
.pcard.out .pname strong { text-decoration: line-through; }
.pcard .tag { font-size: 0.65rem; font-family: var(--font-display); letter-spacing: 0.1em; text-transform: uppercase; padding: 0.05rem 0.4rem; border-radius: 6px; background: rgba(0,0,0,0.4); color: var(--ink-300); flex: none; }
.pcard .tag.win { background: var(--gold); color: var(--ink-950); }
.pcard .tag.agent-off { color: #ffb0bb; }

.hud-feed { top: 14px; right: 14px; width: 320px; max-height: 42vh; display: flex; flex-direction: column; padding: 0.6rem 0.4rem 0.4rem 0.7rem; }
.hud-feed-title { font-family: var(--font-display); font-size: 0.75rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold); margin-bottom: 0.3rem; }
.hud-feed ul { list-style: none; margin: 0; padding: 0 0.3rem 0 0; overflow-y: auto; display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.82rem; }
.hud-feed li { padding: 0.25rem 0.4rem; border-left: 3px solid var(--c, var(--ink-600)); border-radius: 4px; background: rgba(255,255,255,0.03); animation: feed-in 0.35s ease; }
.hud-feed li .t { color: var(--ink-400); font-family: ui-monospace, Menlo, monospace; font-size: 0.7rem; margin-right: 0.35rem; }
.hud-feed li.order { color: var(--ink-300); font-style: italic; }
.hud-feed li.major { color: var(--parchment); font-weight: 700; }
@keyframes feed-in { from { opacity: 0; transform: translateX(10px); } }

.hud-camera { bottom: 14px; right: 14px; display: flex; gap: 0.25rem; padding: 0.3rem; }
.hud-camera button { display: flex; flex-direction: column; align-items: center; gap: 0.1rem; background: transparent; border: 0; color: var(--ink-200); padding: 0.4rem 0.6rem; border-radius: 10px; cursor: pointer; font: inherit; font-size: 0.7rem; }
.hud-camera button:hover, .hud-camera button.active { background: var(--ink-700); color: var(--gold-bright); }
.hud-camera .icon { width: 1.3rem; height: 1.3rem; }

.hud-selection { left: 14px; bottom: 14px; width: 330px; padding: 0.9rem 1rem; }
.sel-head { display: flex; gap: 0.7rem; align-items: center; }
.sel-head .icon { width: 2rem; height: 2rem; color: var(--c); }
.sel-name { font-family: var(--font-display); color: var(--parchment); font-size: 1.1rem; line-height: 1.1; }
.sel-owner { font-size: 0.8rem; color: var(--ink-300); }
.sel-close { margin-left: auto; background: transparent; border: 0; color: var(--ink-300); cursor: pointer; font-size: 1.2rem; }
.sel-bars { display: grid; grid-template-columns: auto 1fr auto; gap: 0.3rem 0.6rem; align-items: center; margin: 0.8rem 0; font-size: 0.8rem; }
.sel-bars .bar { height: 8px; }
.sel-bars .bar.morale span { background: linear-gradient(90deg, #6d4bb3, #b49cff); }
.sel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.3rem 0.8rem; font-size: 0.82rem; }
.sel-grid dt { color: var(--ink-400); }
.sel-grid dd { margin: 0; color: var(--parchment); }
.sel-order { margin-top: 0.7rem; padding: 0.5rem 0.6rem; border-radius: 8px; background: rgba(255,255,255,0.04); font-size: 0.85rem; }
.sel-actions { display: flex; gap: 0.4rem; margin-top: 0.7rem; }

.hud-banner { position: absolute; z-index: 6; top: 26%; left: 50%; transform: translate(-50%, -50%); text-align: center; pointer-events: none; }
.hud-banner .big { font-family: var(--font-display); font-weight: 900; font-size: clamp(2rem, 7vw, 4.5rem); color: var(--parchment); text-shadow: 0 4px 0 rgba(0,0,0,0.5), 0 0 40px rgba(217,164,65,0.6); letter-spacing: 0.06em; }
.hud-banner .small-line { font-size: 1.1rem; color: var(--gold-bright); text-shadow: 0 2px 6px #000; }
.hud-banner .actions { pointer-events: auto; margin-top: 1rem; }
.hud-banner.flash-in { animation: banner-in 0.6s ease; }
@keyframes banner-in { from { opacity: 0; transform: translate(-50%, -40%) scale(0.9); } }

.hud-help { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); font-size: 0.72rem; color: rgba(201, 205, 219, 0.55); pointer-events: none; white-space: nowrap; }

/* Floating regiment labels (positioned by the renderer). */
.rlabel { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); pointer-events: auto; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; will-change: transform; }
.rlabel .rname { font-size: 11px; font-weight: 700; color: #fff; text-shadow: 0 1px 2px #000, 0 0 4px #000; white-space: nowrap; padding: 0 4px; border-radius: 4px; background: color-mix(in srgb, var(--c) 55%, rgba(0,0,0,0.5)); }
.rlabel .rbars { width: 46px; display: flex; flex-direction: column; gap: 1px; }
.rlabel .rbar { height: 4px; background: rgba(0,0,0,0.6); border-radius: 2px; overflow: hidden; }
.rlabel .rbar span { display: block; height: 100%; background: #6be37a; }
.rlabel .rbar.m span { background: #b49cff; }
.rlabel .rstate { font-size: 9px; text-transform: uppercase; letter-spacing: 0.08em; color: #ffd36b; text-shadow: 0 1px 2px #000; }
.rlabel.fleeing .rname { background: rgba(80, 80, 80, 0.8); }
.rlabel.fleeing .rstate { color: #ff8f9c; }
.rlabel.selected .rname { outline: 2px solid var(--gold-bright); }
.rlabel.far .rbars, .rlabel.far .rstate { display: none; }

@media (max-width: 900px) {
  .hud-feed { top: auto; bottom: 80px; right: 8px; width: min(300px, calc(100% - 16px)); max-height: 26vh; }
  .hud-players { width: 200px; left: 8px; top: 80px; max-height: 40vh; }
  .hud-top { top: 8px; }
  .hud-selection { width: calc(100% - 16px); left: 8px; bottom: 76px; }
  .hud-camera { right: 8px; bottom: 8px; }
  .hud-help { display: none; }
  .pcard .pstats { display: none; }
}

/* Replay controls */
.hud-replay { position: absolute; left: 50%; bottom: 3.2rem; transform: translateX(-50%); display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.8rem; width: min(720px, calc(100vw - 32px)); z-index: 5; }
.hud-replay input[type=range] { flex: 1; accent-color: var(--gold, #e7b53f); }
.hud-replay button { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15); color: inherit; border-radius: 8px; padding: 0.25rem 0.6rem; cursor: pointer; font: inherit; min-width: 2.4rem; }
.hud-replay .replay-time { font-variant-numeric: tabular-nums; min-width: 3rem; }

/* Chronicle / highlights tabs */
.hud-feed-tabs { display: flex; gap: 0.3rem; margin-bottom: 0.4rem; }
.hud-feed-tabs button { display: inline-flex; align-items: center; gap: 0.3rem; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--ink-300, #aab); font: inherit; font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; padding: 0.15rem 0.3rem; cursor: pointer; }
.hud-feed-tabs button.active { color: var(--gold, #e7b53f); border-bottom-color: currentColor; }
.hud-highlights li { cursor: pointer; }
.hud-highlights li:hover { background: rgba(255,255,255,0.08); }
.hud-highlights li b { color: var(--gold, #e7b53f); margin-right: 0.3rem; }
.hud-highlights li.w4 b, .hud-highlights li.w5 b { color: #ff9b6b; }
.hud-camera button.active { color: var(--gold, #e7b53f); }
