:root {
  --a: #f5a623;
  --b: #4f8dff;
  --threat: #ff3b5c;
  --ink: #e6ebf5;
  --dim: #8d97ad;
  --panel: rgba(10, 13, 21, 0.86);
  --rule: rgba(143, 163, 200, 0.18);
  font-family: 'Saira', system-ui, sans-serif;
  font-feature-settings: 'tnum' 1;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #070a12; color: var(--ink); overflow: hidden; }
body { touch-action: manipulation; -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; overscroll-behavior: none; -webkit-text-size-adjust: 100%; }
#view { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; touch-action: none; }
.t0 { --team: var(--a); }
.t1 { --team: var(--b); }

/* Scoreboard */
#scoreboard {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
  display: grid; grid-template-columns: 200px 260px 200px; align-items: stretch;
  font-family: 'Saira Condensed', sans-serif; letter-spacing: 0.02em;
  filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.45));
}
.sb-side { background: var(--panel); padding: 8px 16px 7px; border-bottom: 3px solid var(--team); }
.sb-side.t0 { text-align: right; clip-path: polygon(14px 0, 100% 0, 100% 100%, 0 100%); }
.sb-side.t1 { clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 100%, 0 100%); }
.sb-name { font-size: 26px; font-weight: 800; line-height: 1; color: var(--team); }
.sb-style { font-size: 13px; font-weight: 500; color: var(--dim); text-transform: uppercase; letter-spacing: 0.12em; margin-top: 2px; }
.sb-mid { background: rgba(4, 6, 11, 0.94); padding: 6px 14px 7px; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.sb-clock { font-size: 24px; font-weight: 700; line-height: 1; }
.sb-tug { position: relative; width: 100%; height: 6px; display: flex; background: #1a1f2b; }
.tug-a { background: var(--a); height: 100%; transition: width 0.3s; }
.tug-b { background: var(--b); height: 100%; transition: width 0.3s; margin-left: auto; }
.tug-mid { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 2px; background: var(--ink); opacity: 0.6; }
.sb-lead { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--dim); }
.sb-lead.t0, .sb-lead.t1 { color: var(--team); }

/* Ship cards: compact */
#cards { position: fixed; left: 0; right: 0; bottom: 18px; pointer-events: none; }
.card {
  position: absolute; bottom: 0; width: 244px; background: var(--panel); padding: 8px 12px 10px;
  border-top: 3px solid var(--team); font-size: 12px; font-family: 'Saira Condensed', sans-serif;
  filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.45));
}
.card.t0 { left: 22px; clip-path: polygon(0 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%); }
.card.t1 { right: 22px; clip-path: polygon(0 0, 100% 0, 100% 100%, 12px 100%, 0 calc(100% - 12px)); }
.card-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 5px; }
.card-name { font-size: 19px; font-weight: 800; color: var(--team); letter-spacing: 0.02em; }
.card-plan { flex: 1; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink); text-align: right; }
.card-g { font-size: 13px; font-weight: 700; color: var(--dim); min-width: 42px; text-align: right; }
.card-g.warm { color: #ffb03b; }
.card-g.hot { color: var(--threat); }
.hullbar { position: relative; height: 12px; background: #1a1f2b; margin-bottom: 6px; }
.hullfill { position: absolute; inset: 0 auto 0 0; transition: width 0.25s; }
.hulltxt { position: absolute; right: 5px; top: 0; line-height: 12px; font-size: 11px; font-weight: 700; color: var(--ink); text-shadow: 0 0 3px #000, 0 0 2px #000; }
.weap { display: grid; grid-template-columns: 1.3fr 0.5fr 1fr; gap: 10px; align-items: end; margin-bottom: 6px; }
.wl { font-size: 10px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.1em; display: block; }
.w-rail { display: grid; grid-template-columns: auto 1fr auto; gap: 5px; align-items: center; }
.w-rail .wl { display: inline; }
.ring { height: 5px; background: #1a1f2b; overflow: hidden; }
.ringfill { height: 100%; transform-origin: left; background: var(--team); }
.ring.full .ringfill { animation: pulse 0.35s ease-in-out infinite alternate; }
@keyframes pulse { from { opacity: 1; } to { opacity: 0.45; } }
.pips { font-size: 13px; font-weight: 700; color: var(--ink); line-height: 1; }
.w-torp { display: flex; gap: 5px; align-items: baseline; }
.w-torp b { font-size: 16px; font-weight: 700; line-height: 1; }
.w-pdc { display: grid; grid-template-columns: auto 1fr 1fr 1fr; gap: 3px; align-items: center; }
.pbar { height: 4px; background: #1a1f2b; }
.pbar i { display: block; height: 100%; background: var(--dim); }
.pbar i.firing { background: var(--ink); }
.sys { display: flex; flex-wrap: nowrap; gap: 7px; margin-bottom: 6px; }
.chip { display: flex; align-items: center; gap: 1px; font-size: 10px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.05em; }
.chip i { width: 5px; height: 8px; display: inline-block; background: #9fe0a8; }
.chip span { margin-left: 2px; }
.crew { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 6px; }
.crow { position: relative; display: flex; gap: 4px; align-items: baseline; padding: 1px 4px 3px; background: rgba(255, 255, 255, 0.03); font-size: 12px; font-family: 'Saira', sans-serif; }
.cst { font-family: 'Saira Condensed', sans-serif; font-size: 9px; color: var(--dim); letter-spacing: 0.08em; }
.cname { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cdose { position: absolute; left: 0; bottom: 0; height: 2px; }
.crow.s1 { background: rgba(255, 176, 59, 0.18); }
.crow.s1 .cname { color: #ffb03b; }
.crow.s2 { background: transparent; }
.crow.s2 .cname { color: #59606e; text-decoration: line-through; }
.crow.hurt .cname { color: #ffd7a8; }
/* A lost ship's card dims */
.card.lost { opacity: 0.6; }
.card.lost .card-plan { color: var(--threat); }
/* Radio chatter: one short line above each card */
.chat { position: absolute; bottom: calc(100% + 8px); left: 0; right: 0; font-family: 'Saira', sans-serif; font-size: 13px; color: var(--ink); opacity: 0; transform: translateY(4px); transition: opacity 0.3s, transform 0.3s; white-space: nowrap; text-shadow: 0 1px 4px #000; }
.chat b { color: var(--team); font-weight: 600; margin-right: 4px; }
.chat.on { opacity: 0.92; transform: none; }
.card.t1 .chat { text-align: right; }
.card { overflow: visible; }

/* The killing blow: a brief flash frame */
#flashframe { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
#flashframe.on { animation: flashframe 0.45s ease-out; }
@keyframes flashframe { from { opacity: 0.22; } to { opacity: 0; } }

/* Time scale: a badge whenever the broadcast isn't running at 1×, and an edge treatment in slow motion */
#slowvig { position: fixed; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse 75% 70% at 50% 50%, transparent 55%, rgba(40, 70, 130, 0.30) 100%);
  box-shadow: inset 0 0 0 2px rgba(143, 180, 255, 0.35); }
#timebadge { position: fixed; left: 50%; top: 84px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px;
  padding: 4px 12px 4px 10px; background: var(--panel); font-family: 'Saira Condensed', sans-serif; opacity: 0; pointer-events: none;
  border-bottom: 2px solid #8fb4ff; }
.tb-rate { font-size: 20px; font-weight: 800; line-height: 1; color: #cfe0ff; min-width: 52px; text-align: right; }
.tb-lab { font-size: 13px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--dim); }
.tb-meter { position: relative; width: 64px; height: 5px; background: #1a1f2b; }
.tb-meter i { position: absolute; inset: 0 auto 0 0; background: #8fb4ff; }
.tb-meter::after { content: ''; position: absolute; right: 0; top: -3px; bottom: -3px; width: 1px; background: var(--ink); opacity: 0.6; }

/* Result card */
#result { position: fixed; left: 50%; top: 118px; transform: translateX(-50%); min-width: 420px; background: rgba(6, 8, 14, 0.92); padding: 16px 26px 18px; font-family: 'Saira Condensed', sans-serif; text-align: center; border-top: 3px solid var(--ink); animation: resin 0.5s ease-out; clip-path: polygon(14px 0, 100% 0, 100% calc(100% - 14px), calc(100% - 14px) 100%, 0 100%, 0 14px); }
#result[hidden] { display: none; }
@keyframes resin { from { opacity: 0; transform: translate(-50%, -10px); } to { opacity: 1; transform: translateX(-50%); } }
.res-head { font-size: 44px; font-weight: 800; letter-spacing: 0.03em; line-height: 1; color: var(--team, var(--ink)); }
.res-sub { font-size: 16px; font-weight: 500; color: var(--dim); text-transform: uppercase; letter-spacing: 0.12em; margin: 6px 0 14px; }
.res-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; text-align: left; }
.res-name { font-size: 18px; font-weight: 700; color: var(--team); border-bottom: 1px solid var(--rule); padding-bottom: 3px; margin-bottom: 4px; }
.res-row { display: flex; justify-content: space-between; font-size: 14px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.06em; }
.res-row b { color: var(--ink); font-size: 16px; }

/* Name tags */
#tags { position: fixed; inset: 0; pointer-events: none; }
.tag { position: absolute; left: 0; top: 0; font-family: 'Saira Condensed', sans-serif; font-size: 15px; letter-spacing: 0.08em; color: var(--team); text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9); white-space: nowrap; }
.tag b { font-weight: 700; }
.tag .acc { display: block; font-size: 12px; letter-spacing: 0.06em; color: var(--ink); opacity: 0.9; text-align: center; }
.tag .acc:empty { display: none; }
.tag .acc.done { opacity: 0.55; }
.sb-pips { color: var(--team); letter-spacing: 0.15em; margin: 0 6px; font-size: 11px; }
.sb-lead.live { color: var(--ink); }
.sb-lead.live.t0, .sb-lead.live.t1 { color: var(--team); }
.tag.shrap { color: var(--threat); font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.9; }

/* Fight-wide news, under the scoreboard */
#callouts { position: fixed; left: 50%; top: 122px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.callout {
  font-family: 'Saira Condensed', sans-serif; font-size: 24px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  background: var(--panel); padding: 5px 18px 5px 16px; border-left: 4px solid var(--team, var(--ink)); white-space: nowrap;
  animation: in 0.25s ease-out;
}
.callout.big { font-size: 28px; }
.callout.out { opacity: 0; transform: translateY(6px); transition: opacity 0.35s, transform 0.35s; }
@keyframes in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Side-view inset */
#inset { position: fixed; top: 110px; right: 22px; width: 300px; height: 150px; background: var(--panel); border-top: 2px solid var(--rule); opacity: 0; transition: opacity 0.6s; }
#inset.on { opacity: 1; }

/* Transport + critic */
#transport { position: fixed; bottom: 4px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--dim); display: flex; gap: 14px; opacity: 0.55; font-family: 'Saira Condensed', sans-serif; letter-spacing: 0.06em; }
#transport:hover { opacity: 1; }
#critic { position: fixed; top: 110px; left: 22px; margin: 0; padding: 10px 12px; background: rgba(0, 0, 0, 0.8); color: #cfe; font: 11px/1.45 ui-monospace, Menlo, monospace; white-space: pre-wrap; max-width: 520px; }

/* Storyboard captures: settled states only (a hidden pane doesn't advance CSS animations). */
body.story *, body.story *::before, body.story *::after { animation: none !important; transition: none !important; }

/* ---- Ship plates: everything about a ship, next to the ship ---- */
#leaders { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; overflow: visible; }
#leaders .ld { stroke-width: 1.3; opacity: 0.7; }
#leaders .ld.t0 { stroke: var(--a); } #leaders .ld.t1 { stroke: var(--b); }
.plate { position: absolute; left: 0; top: 0; width: 214px; padding: 7px 11px 8px; background: rgba(7, 10, 18, 0.78);
  border-left: 3px solid var(--team); font-family: 'Saira Condensed', sans-serif; color: var(--ink); pointer-events: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35); }
.pl-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.pl-name { font-size: 21px; font-weight: 800; letter-spacing: 0.03em; line-height: 1; color: var(--team); }
.pl-rail { font-size: 13px; font-weight: 700; letter-spacing: 0.08em; color: var(--team); }
.pl-rail.ready { color: var(--threat); animation: pulse 0.35s ease-in-out infinite alternate; }
.pl-rail.over { color: #ff7a3b; }
.pl-plan { font-size: 14px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; margin: 3px 0 5px; color: var(--ink); }
.pl-plan b { margin-left: 6px; font-weight: 700; }
.pl-plan b.warm { color: #ffb03b; } .pl-plan b.hot { color: var(--threat); }
.pl-hull { position: relative; height: 9px; background: #1a1f2b; margin-right: 38px; }
.pl-hull i { position: absolute; inset: 0 auto 0 0; transition: width 0.25s; }
.pl-hull span { position: absolute; left: calc(100% + 6px); top: -4px; font-size: 14px; font-weight: 700; line-height: 16px; }
.pl-meta { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.pl-crew { display: flex; gap: 4px; }
.pl-crew i { width: 9px; height: 9px; border-radius: 50%; background: var(--team); }
.pl-crew i.hurt { background: #ffb03b; }
.pl-crew i.out { background: transparent; box-shadow: inset 0 0 0 2px #ffb03b; }
.pl-crew i.dead { background: transparent; box-shadow: inset 0 0 0 1.5px #59606e; }
.pl-ammo { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
.pl-outs { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #ff8098; margin-top: 4px; }
.pl-outs:empty, .pl-acc:empty { display: none; }
.pl-outs.fresh { background: rgba(255, 59, 92, 0.9); color: #fff; margin-left: -11px; margin-right: -11px; padding: 3px 11px; font-size: 14px; animation: flagin 0.25s ease-out; }
.pl-acc { font-size: 13px; letter-spacing: 0.05em; margin-top: 4px; color: var(--ink); }
.pl-acc.done { opacity: 0.55; }
.pl-flag { display: none; margin: 6px -11px -8px -14px; padding: 5px 11px 6px 14px; font-size: 17px; font-weight: 800; letter-spacing: 0.05em;
  text-transform: uppercase; background: rgba(255, 176, 59, 0.92); color: #140c02; }
.pl-flag.death { background: rgba(255, 59, 92, 0.95); color: #fff; }
.pl-flag.on { display: block; animation: flagin 0.25s ease-out; }
@keyframes flagin { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.pl-chat { position: absolute; left: 0; top: calc(100% + 6px); width: 280px; font-family: 'Saira', sans-serif; font-size: 14px; color: var(--ink);
  text-shadow: 0 1px 4px #000, 0 0 2px #000; opacity: 0; transition: opacity 0.3s; }
.pl-chat b { color: var(--team); font-weight: 600; margin-right: 3px; }
.pl-chat.on { opacity: 0.95; }
.plate.lost { opacity: 0.6; } .plate.lost .pl-plan { color: var(--threat); }
/* In-scene labels */
.slabel { position: absolute; left: 0; top: 0; font-family: 'Saira Condensed', sans-serif; font-size: 13px; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; white-space: nowrap; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.95); pointer-events: none; }
.slabel.shrap { color: #ff9a70; }
.slabel.torp { color: var(--team); } .slabel.torp.hot { color: var(--threat); }
#inset, #cards { display: none; }

/* ---- Playback controls: a sheet from the bottom (thumb zone), shown on tap ---- */
#controls { position: fixed; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(560px, calc(100vw - 16px));
  padding: 12px 14px 10px; background: rgba(9, 12, 21, 0.97); border-top: 2px solid var(--rule); box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.5);
  font-family: 'Saira Condensed', sans-serif; transition: opacity 0.2s, transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1); z-index: 20; }
#controls.hidden { opacity: 0; transform: translate(-50%, 16px); pointer-events: none; }
.ct-title { display: flex; justify-content: space-between; align-items: baseline; font-size: 15px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 8px; }
.ct-title #ct-count { font-size: 12px; font-weight: 500; color: var(--dim); }
#scrub { padding: 6px 0 2px; }
.sc-track { position: relative; height: 32px; touch-action: none; cursor: pointer; }
.sc-track::before { content: ''; position: absolute; left: 0; right: 0; top: 14px; height: 4px; background: #1d2331; }
.sc-marks i { position: absolute; top: 11px; height: 10px; opacity: 0.85; }
.sc-marks i.t0 { background: var(--a); } .sc-marks i.t1 { background: var(--b); } .sc-marks i.even { background: var(--dim); }
.sc-marks b { position: absolute; top: 7px; width: 2px; height: 18px; background: var(--threat); }
.sc-fill { position: absolute; left: 0; top: 14px; height: 4px; background: var(--ink); opacity: 0.6; }
.sc-knob { position: absolute; top: 6px; width: 20px; height: 20px; margin-left: -10px; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 4px rgba(230, 235, 245, 0.18); }
.sc-times { display: flex; justify-content: space-between; font-size: 12px; color: var(--dim); letter-spacing: 0.06em; }
.ct-row { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.ct-row button { min-width: 48px; min-height: 48px; border: 0; background: none; color: var(--ink); display: grid; place-items: center; border-radius: 24px; cursor: pointer; font: inherit; }
.ct-row button:active { background: rgba(255, 255, 255, 0.08); }
.ct-row button svg { width: 26px; height: 26px; fill: currentColor; }
.ct-row button text { fill: currentColor; font-family: 'Saira Condensed', sans-serif; }
.ct-row button.big { width: 64px; height: 64px; background: var(--ink); color: #070a12; border-radius: 50%; }
.ct-row button.big svg { width: 30px; height: 30px; }
#controls .i-play { display: none; } #controls.paused .i-play { display: block; } #controls.paused .i-pause { display: none; }
.ct-row.small { justify-content: center; gap: 12px; margin-top: 4px; }
.ct-row.small button { padding: 0 18px; font-size: 14px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--dim); background: rgba(255, 255, 255, 0.04); }
/* Double-tap seek feedback */
#tapfx { position: fixed; top: 45%; font-family: 'Saira Condensed', sans-serif; font-size: 22px; font-weight: 700; color: var(--ink); opacity: 0; pointer-events: none;
  padding: 14px 22px; border-radius: 40px; background: rgba(255, 255, 255, 0.1); }
#tapfx.on { animation: tapfx 0.5s ease-out; } #tapfx.back { left: 12%; } #tapfx.fwd { right: 12%; }
@keyframes tapfx { from { opacity: 1; transform: scale(0.9); } to { opacity: 0; transform: scale(1.1); } }
.shiptag { position: absolute; left: 0; top: 0; display: none; font-family: 'Saira Condensed', sans-serif; font-size: 13px; font-weight: 700; letter-spacing: 0.08em;
  color: var(--team); text-shadow: 0 1px 4px rgba(0, 0, 0, 0.95); white-space: nowrap; pointer-events: none; line-height: 16px; }
#dock { display: none; }
body.touch #transport { display: none; }

/* ---- Portrait (phones held upright) ---- */
body.portrait #transport, body.portrait #critic { display: none; }
body.portrait #scoreboard { top: calc(8px + env(safe-area-inset-top)); left: 8px; right: 8px; transform: none; grid-template-columns: 1fr minmax(120px, 34%) 1fr; filter: none; }
body.portrait .sb-side { padding: 6px 10px 5px; border-bottom-width: 2px; }
body.portrait .sb-side.t0 { clip-path: none; } body.portrait .sb-side.t1 { clip-path: none; }
body.portrait .sb-name { font-size: 18px; }
body.portrait .sb-style { font-size: 0; margin-top: 3px; } /* (pips only: the style name is on the plate) */
body.portrait .sb-pips { font-size: 10px; margin: 0; }
body.portrait .sb-mid { padding: 5px 8px 5px; gap: 4px; }
body.portrait .sb-clock { font-size: 18px; }
body.portrait .sb-lead { font-size: 10.5px; letter-spacing: 0.06em; white-space: nowrap; }
body.portrait #callouts { top: calc(66px + env(safe-area-inset-top)); width: calc(100vw - 16px); }
body.portrait .callout { font-size: 16px; white-space: normal; text-align: center; padding: 5px 12px; line-height: 1.2; }
body.portrait .callout.big { font-size: 20px; }
body.portrait #timebadge { top: calc(62px + env(safe-area-inset-top)); left: auto; right: 8px; transform: none; padding: 3px 8px; gap: 6px; }
body.portrait .tb-rate { font-size: 15px; min-width: 0; } body.portrait .tb-lab { font-size: 10px; } body.portrait .tb-meter { width: 36px; }
body.portrait #result { top: calc(66px + env(safe-area-inset-top)); min-width: 0; width: calc(100vw - 16px); padding: 12px 14px 14px; }
body.portrait .res-head { font-size: 30px; } body.portrait .res-sub { font-size: 12px; margin: 4px 0 10px; }
body.portrait .res-cols { gap: 14px; } body.portrait .res-name { font-size: 15px; } body.portrait .res-row { font-size: 11px; } body.portrait .res-row b { font-size: 13px; }
body.portrait #leaders { display: none; }
body.portrait .shiptag { display: block; }
body.portrait #dock { display: grid; position: fixed; left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); grid-template-columns: 1fr 1fr; gap: 8px; align-items: end; }
body.portrait #dock .plate { position: relative; width: auto; transform: none !important; padding: 6px 9px 7px; box-shadow: none; background: rgba(7, 10, 18, 0.86); }
body.portrait #dock .plate.t1 { border-left: 0; border-right: 3px solid var(--team); text-align: right; }
body.portrait #dock .plate.t1 .pl-head { flex-direction: row-reverse; }
body.portrait #dock .plate.t1 .pl-meta { flex-direction: row-reverse; }
body.portrait #dock .plate.t1 .pl-hull { margin-right: 0; margin-left: 34px; }
body.portrait #dock .plate.t1 .pl-hull i { inset: 0 0 0 auto; }
body.portrait #dock .plate.t1 .pl-hull span { left: auto; right: calc(100% + 5px); }
body.portrait .pl-name { font-size: 17px; }
body.portrait .pl-rail { font-size: 11px; }
body.portrait .pl-plan { font-size: 11.5px; margin: 2px 0 4px; letter-spacing: 0.07em; }
body.portrait .pl-hull { height: 7px; margin-right: 34px; }
body.portrait .pl-hull span { font-size: 12px; top: -5px; }
body.portrait .pl-crew i { width: 8px; height: 8px; }
body.portrait .pl-ammo { font-size: 10px; letter-spacing: 0.04em; }
body.portrait .pl-outs { font-size: 10.5px; letter-spacing: 0.04em; }
body.portrait .pl-outs.fresh { font-size: 11.5px; margin-left: -9px; margin-right: -9px; padding: 3px 9px; }
body.portrait .pl-acc { font-size: 11px; letter-spacing: 0.02em; }
body.portrait .pl-flag { font-size: 13px; margin: 5px -9px -7px -12px; padding: 4px 9px 5px 12px; }
body.portrait #dock .plate.t1 .pl-flag { margin: 5px -12px -7px -9px; }
body.portrait .pl-chat { top: auto; bottom: calc(100% + 6px); width: 100%; font-size: 12px; white-space: normal; line-height: 1.25; }
body.portrait .slabel { font-size: 11px; letter-spacing: 0.08em; }
body.portrait #controls { bottom: calc(8px + env(safe-area-inset-bottom)); }

#dock { transition: opacity 0.2s; }
body.portrait.ctl-open #dock { opacity: 0; }

/* ---- Short landscape (a phone held sideways) ---- */
@media (max-height: 520px) and (orientation: landscape) {
  #scoreboard { top: calc(6px + env(safe-area-inset-top)); grid-template-columns: 150px 190px 150px; filter: none; }
  .sb-side { padding: 5px 12px 4px; } .sb-name { font-size: 18px; } .sb-style { font-size: 10px; } .sb-clock { font-size: 17px; }
  .sb-mid { padding: 4px 10px 5px; gap: 3px; } .sb-lead { font-size: 10.5px; }
  #callouts { top: 62px; } .callout { font-size: 16px; padding: 4px 12px; }
  #timebadge { top: 56px; padding: 2px 8px; } .tb-rate { font-size: 14px; } .tb-lab { font-size: 10px; }
  .plate { width: 168px; padding: 5px 8px 6px; }
  .pl-name { font-size: 15px; } .pl-rail { font-size: 10px; } .pl-plan { font-size: 10.5px; margin: 2px 0 3px; }
  .pl-hull { height: 6px; margin-right: 30px; } .pl-hull span { font-size: 11px; top: -5px; }
  .pl-crew i { width: 7px; height: 7px; } .pl-ammo, .pl-outs, .pl-acc { font-size: 10px; }
  .pl-outs.fresh { font-size: 11px; margin-left: -8px; margin-right: -8px; padding: 2px 8px; }
  .pl-flag { font-size: 12px; margin: 4px -8px -6px -11px; padding: 3px 8px 4px 11px; }
  .pl-chat { font-size: 11.5px; width: 220px; }
  #result { top: 58px; min-width: 0; padding: 8px 16px 10px; } .res-head { font-size: 26px; } .res-sub { font-size: 11px; margin: 3px 0 6px; } .res-row { font-size: 11px; }
  #controls { width: min(520px, calc(100vw - 16px)); padding: 6px 12px 4px; bottom: calc(6px + env(safe-area-inset-bottom)); }
  .ct-title { margin-bottom: 0; font-size: 13px; } .sc-track { height: 28px; }
  .ct-row { margin-top: 0; } .ct-row.small { display: none; }
}

/* Measurement labels: |—N m—| */
.mlabel { position: absolute; left: 0; top: 0; font-family: 'Saira Condensed', sans-serif; font-size: 15px; font-weight: 700; letter-spacing: 0.04em;
  color: var(--ink); background: rgba(7, 10, 18, 0.75); padding: 1px 6px; white-space: nowrap; pointer-events: none; }
body.portrait .mlabel { font-size: 13px; }

/* Scoreboard integrity bars (drain toward the centre; the exchange's loss as a bright chunk) */
.sb-bar { position: relative; height: 8px; margin-top: 6px; background: #1a1f2b; }
.sb-bar .fill { position: absolute; top: 0; bottom: 0; background: var(--team); transition: width 0.3s; }
.sb-side.t0 .sb-bar .fill { left: 0; } .sb-side.t1 .sb-bar .fill { right: 0; }
.sb-bar .chunk { position: absolute; top: -2px; bottom: -2px; width: 0; background: #fff; box-shadow: 0 0 6px rgba(255, 255, 255, 0.6); }
.sb-bar .chunk.drain { transition: width 0.7s ease-in; }
.sb-pct { position: absolute; top: 11px; font-size: 12px; font-weight: 700; color: var(--ink); }
.sb-delta { position: absolute; top: 10px; font-size: 14px; font-weight: 800; color: #fff; }
.sb-side.t0 .sb-pct { left: 0; } .sb-side.t1 .sb-pct { right: 0; }
.sb-side.t0 .sb-delta { right: 0; } .sb-side.t1 .sb-delta { left: 0; }
.sb-side { padding-bottom: 22px; }
.sb-cap { font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--dim); margin-top: auto; }
.sb-mid { justify-content: flex-start; }
.sb-lead.live::before { content: '● '; color: var(--threat); }
.callout small { display: block; font-size: 0.66em; font-weight: 600; letter-spacing: 0.06em; color: var(--ink); opacity: 0.85; margin-top: 2px; }
.callout { text-align: center; }
body.portrait .sb-side { padding-bottom: 19px; }
body.portrait .sb-bar { height: 6px; margin-top: 4px; }
body.portrait .sb-pct { top: 8px; font-size: 10.5px; } body.portrait .sb-delta { top: 7px; font-size: 12px; }
body.portrait .sb-cap { font-size: 8.5px; letter-spacing: 0.1em; }

/* The plate's bar is the hull alone (the scoreboard's is overall integrity): say so. */
.pl-hull { margin-left: 30px; }
.pl-hull b { position: absolute; right: calc(100% + 6px); top: -4px; font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--dim); line-height: 16px; }
body.portrait .pl-hull { margin-left: 28px; } body.portrait .pl-hull b { font-size: 9.5px; top: -5px; }
body.portrait #dock .plate.t1 .pl-hull { margin-left: 34px; margin-right: 28px; }
body.portrait #dock .plate.t1 .pl-hull b { right: auto; left: calc(100% + 5px); }


/* Range between the ships (scoreboard centre) */
.sb-range { font-size: 14px; font-weight: 700; letter-spacing: 0.05em; color: var(--ink); line-height: 1; white-space: nowrap; }
.sb-range i { font-style: normal; font-weight: 600; font-size: 12px; margin-left: 4px; color: var(--dim); }
.sb-range i.cl { color: #ffb03b; }
.sb-mid { gap: 4px; }
body.portrait .sb-range { font-size: 12px; } body.portrait .sb-range i { font-size: 10px; margin-left: 3px; }
@media (max-height: 520px) and (orientation: landscape) { .sb-range { font-size: 12px; } .sb-range i { font-size: 10px; } }

/* Hybrid camera: grab cursor; a pill while the viewer has the camera */
#view { cursor: grab; } #view.grabbing { cursor: grabbing; }
#camhud { position: fixed; right: 16px; top: calc(118px + env(safe-area-inset-top)); display: flex; align-items: center; gap: 10px; padding: 4px 4px 4px 12px;
  background: rgba(7, 10, 18, 0.82); border: 1px solid var(--rule); font-family: 'Saira Condensed', sans-serif; font-size: 13px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ink); opacity: 0; transform: translateY(-4px); transition: opacity 0.2s, transform 0.2s; pointer-events: none; z-index: 15; }
#camhud.on { opacity: 1; transform: none; pointer-events: auto; }
#camhud button { min-height: 36px; padding: 0 14px; border: 0; background: var(--ink); color: #070a12; font: inherit; font-weight: 700; letter-spacing: 0.08em; cursor: pointer; }
body.touch #camhud button { min-height: 44px; }
body.portrait #camhud { top: calc(124px + env(safe-area-inset-top)); right: 8px; }

/* Result card actions */
.res-actions { display: flex; gap: 10px; margin-top: 16px; }
.res-actions button { flex: 1; min-height: 48px; display: flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--rule);
  background: rgba(255, 255, 255, 0.05); color: var(--ink); font-family: 'Saira Condensed', sans-serif; font-size: 17px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; cursor: pointer; }
.res-actions button svg { width: 20px; height: 20px; fill: currentColor; flex: none; }
.res-actions button small { font-size: 12px; font-weight: 500; letter-spacing: 0.06em; opacity: 0.7; margin-left: 2px; }
.res-actions button.primary { flex: 1.6; background: var(--ink); color: #070a12; border-color: var(--ink); }
.res-actions button:hover { filter: brightness(1.1); } .res-actions button:active { transform: translateY(1px); }
.res-actions button:focus-visible { outline: 2px solid var(--b); outline-offset: 2px; }
body.portrait .res-actions { margin-top: 12px; } body.portrait .res-actions button { font-size: 15px; }
@media (max-height: 520px) and (orientation: landscape) { .res-actions { margin-top: 8px; } .res-actions button { min-height: 40px; font-size: 14px; } }

/* Music / effects toggles */
.ct-row.small button { display: flex; align-items: center; gap: 7px; }
.ct-row.small button svg { width: 18px; height: 18px; fill: currentColor; opacity: 0.5; }
.ct-row.small button.on { color: var(--ink); background: rgba(255, 255, 255, 0.1); }
.ct-row.small button.on svg { opacity: 1; }

/* Shown only while the browser holds the audio until a first click or key */
#soundhint { position: fixed; left: 16px; bottom: 16px; display: flex; align-items: center; gap: 8px; padding: 6px 12px; background: rgba(7, 10, 18, 0.82);
  border: 1px solid var(--rule); font-family: 'Saira Condensed', sans-serif; font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink);
  opacity: 0; transition: opacity 0.3s; pointer-events: none; z-index: 14; }
#soundhint svg { width: 16px; height: 16px; fill: currentColor; }
#soundhint.on { opacity: 0.9; }
/* Phones: centred just above the team panels (clear of the radio lines, which sit at the sides) */
body.portrait #soundhint { left: 50%; bottom: auto; top: calc(var(--dock-top, 100vh) - 84px); transform: translateX(-50%); font-size: 14px; padding: 8px 14px; }
body.portrait #soundhint.on { opacity: 1; animation: hintpulse 2.4s ease-in-out infinite; }
@keyframes hintpulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

/* Pre-fight dossier: two compact crew grids. */
#prematch { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 20px; background: rgba(5, 7, 10, 0.9); overflow-y: auto; font-family: 'Saira Condensed', sans-serif; }
#prematch[hidden] { display: none; }
.pm-card { width: min(900px, 100%); padding: 18px 20px 12px; background: #171a1e; border: 1px solid #41454b; border-top: 3px solid #c5bca9; color: #e6e1d6; line-height: 1.2; }
.pm-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; color: #aaa69c; font-size: 12px; letter-spacing: 0.12em; }
.pm-brand { color: #e6e1d6; font-size: 15px; font-weight: 800; }
.pm-brand small { color: #aaa69c; font-size: 11px; font-weight: 500; }
.pm-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 8px 0 14px; }
.pm-heading h1 { margin: 0; font-size: 29px; line-height: 1; font-weight: 600; }
.pm-rec { color: #c6c0b3; font-size: 13px; }
.pm-vs { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.pm-ship { min-width: 0; }
.pm-shiphead { display: flex; align-items: end; justify-content: space-between; gap: 8px; padding-bottom: 6px; border-bottom: 2px solid var(--team); }
.pm-team { display: block; line-height: 1; color: var(--team); font-size: 10px; letter-spacing: 0.15em; }
.pm-name { margin: 2px 0 0; font-size: 31px; font-weight: 800; letter-spacing: 0.03em; text-transform: uppercase; line-height: 1; }
.pm-doctrine { color: var(--team); font-size: 12px; text-transform: uppercase; letter-spacing: 0.09em; padding-bottom: 1px; }
.pm-style { font-family: 'Saira', sans-serif; font-size: 10px; line-height: 1.5; color: #bab6ae; margin: 7px 0 10px; min-height: 30px; }
.pm-roster { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.pm-crew { min-width: 0; display: grid; grid-template-columns: 66px minmax(0, 1fr); gap: 0 8px; background: #202328; border: 1px solid #373a3e; }
.pm-who { grid-column: 1 / -1; display: flex; align-items: baseline; justify-content: space-between; gap: 5px; padding: 5px 8px; border-bottom: 1px solid #373a3e; background: #292c30; }
.pm-st { color: #aaa69c; font-size: 10px; text-transform: uppercase; letter-spacing: 0.09em; }
.pm-who b { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.pm-portrait { align-self: stretch; margin: 7px 0 7px 6px; display: grid; place-items: center; background: color-mix(in srgb, var(--portrait-color) 9%, #15171a); border: 1px solid color-mix(in srgb, var(--portrait-color) 25%, #26282c); }
.pm-portrait span { display: block; width: 54px; height: 64px; background: var(--portrait-color); mask: var(--portrait-url) center / 94% no-repeat; -webkit-mask: var(--portrait-url) center / 94% no-repeat; }
.pm-stats { padding: 7px 7px 5px 0; }
.pm-stat-label { display: flex; justify-content: space-between; align-items: baseline; gap: 4px; font-size: 11px; line-height: 1; color: #c6c0b3; }
.pm-stat-label b { color: #eee8dc; font-size: 15px; font-weight: 700; }
.pm-stat-label small { color: #aaa69c; font-size: 9px; font-weight: 400; margin-left: 2px; }
.pm-stat, .pm-gbar { position: relative; height: 5px; margin-top: 4px; background: #101215; }
.pm-stat i, .pm-gbar i { display: block; height: 100%; background: var(--team); }
.pm-stat::after { content: ''; position: absolute; left: 50%; top: -1px; bottom: -1px; width: 1px; background: #f1e8d1; opacity: 0.8; }
.pm-g { margin-top: 9px; }
.pm-gbar i { background: #b6bdac; }
.pm-g-note { color: #aaa69c; font-size: 9px; margin-top: 3px; }
.pm-what { grid-column: 1 / -1; padding: 4px 7px; color: #b8b4aa; font-size: 10px; border-top: 1px solid #33363a; }
.pm-edge { display: flex; align-items: baseline; gap: 7px; margin-top: 8px; font-size: 11px; color: #bab6ae; }
.pm-edge > span:first-child { font-size: 9px; letter-spacing: 0.08em; color: #aaa69c; }
.pm-edge b { color: var(--team); font-weight: 600; }
.pm-edge > span:last-child { margin-left: auto; }
.pm-odds { margin: 16px 0 10px; }
.pm-oddsbar { display: flex; height: 5px; gap: 3px; }
.pm-oddsbar i.t0 { background: var(--a); } .pm-oddsbar i.t1 { background: var(--b); }
.pm-oddsnums { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.pm-oddsnums b { font-size: 27px; line-height: 1; color: var(--team); }
.pm-oddsnums > span { font-size: 10px; letter-spacing: 0.12em; color: #c6c0b3; text-align: center; }
.pm-oddsnums small { display: block; font-size: 9px; letter-spacing: 0; color: #aaa69c; }
.pm-actions { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; }
.pm-pick, .pm-go, .pm-skip { min-height: 44px; cursor: pointer; font-family: inherit; font-size: 15px; font-weight: 700; letter-spacing: 0.05em; border: 1px solid #47494c; }
.pm-pick { display: flex; align-items: center; justify-content: center; gap: 8px; border-color: color-mix(in srgb, var(--team) 60%, #171a1e); background: color-mix(in srgb, var(--team) 12%, #171a1e); color: #eee8dc; }
.pm-pick small { color: var(--team); font-size: 12px; }
.pm-pick.t1 { grid-column: 3; grid-row: 1; }
.pm-pick:hover { background: color-mix(in srgb, var(--team) 25%, #171a1e); }
.pm-skip { grid-column: 2; grid-row: 1; padding: 0 14px; color: #c6c0b3; background: transparent; font-weight: 500; font-size: 12px; }
.pm-skip:hover { background: #303338; }
.pm-locked { grid-column: 1 / 3; align-self: center; color: #c6c0b3; font-size: 14px; }
.pm-locked b { color: var(--team); margin-left: 5px; }
.pm-go { grid-column: 3; color: #171a1e; background: #e6e1d6; }
.pm-pick:focus-visible, .pm-skip:focus-visible, .pm-go:focus-visible, .pm-foot a:focus-visible { outline: 2px solid #e6e1d6; outline-offset: 3px; }
.pm-foot { display: flex; justify-content: space-between; gap: 12px; margin-top: 10px; font-size: 9px; color: #aaa69c; }
.pm-foot a { color: #aaa69c; text-decoration-color: #63625d; }
@media (max-width: 700px) {
  #prematch { place-items: safe center; padding: 12px 8px; }
  .pm-card { padding: 12px; }
  .pm-vs { grid-template-columns: 1fr; gap: 14px; }
  .pm-heading { padding-bottom: 12px; }
  .pm-heading h1 { font-size: 25px; }
  .pm-style { min-height: 0; }
  .pm-name { font-size: 27px; }
  .pm-crew { grid-template-columns: 64px minmax(0, 1fr); }
  .pm-foot { flex-wrap: wrap; gap: 3px; }
  .pm-actions { gap: 6px; grid-template-columns: 1fr 1fr; }
  .pm-pick { font-size: 13px; }
  .pm-pick.t1 { grid-column: 2; }
  .pm-skip { grid-column: 1 / -1; grid-row: 2; min-height: 36px; }
  .pm-locked { grid-column: 1; }
  .pm-go { grid-column: 2; }
}
@media (max-width: 360px) {
  .pm-crew { grid-template-columns: 51px minmax(0, 1fr); gap: 0 5px; }
  .pm-portrait span { width: 43px; }
  .pm-who { padding-inline: 5px; }
  .pm-who b { font-size: 12px; }
  .pm-brand small { display: none; }
}
/* The pick, during and after the fight */
.sb-side.picked .sb-name::after { content: ' ★'; font-size: 0.7em; vertical-align: 0.15em; }
.sb-pick { position: absolute; left: 0; right: 0; bottom: -18px; font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--team); text-align: center; }
.sb-side { position: relative; }
.res-pick { font-family: 'Saira', sans-serif; font-size: 14px; margin: -6px 0 14px; padding: 7px 10px; background: rgba(255, 255, 255, 0.05); color: var(--ink); }
.res-pick.right { background: rgba(120, 220, 140, 0.14); } .res-pick.wrong { background: rgba(255, 59, 92, 0.12); }
body.portrait .sb-pick { display: none; }
body.portrait .res-pick { font-size: 12px; }

/* Broadcast facts, live crew continuity, and the post-fight explanation. */
.tactical { position:absolute; top:88px; left:50%; transform:translateX(-50%); max-width:85vw; text-align:center; font-size:11px; color:#b9bfc7; pointer-events:none; background:#090d13d9; padding:3px 8px; border-radius:2px; }
.tactical:empty {display:none}
.pl-crew {display:flex; gap:4px}
.pl-crew i.crew-face {width:23px; height:25px; border-radius:2px; background:var(--portrait-color); mask:var(--portrait-url) center/contain no-repeat; -webkit-mask:var(--portrait-url) center/contain no-repeat; opacity:1; border:0}
.pl-crew i.crew-face.hurt {background:#ffba65}
.pl-crew i.crew-face.out {background:#f5df63; opacity:.6}
.pl-crew i.crew-face.dead {background:#727783; opacity:.25}
.pl-meta {flex-wrap:wrap; gap:4px}
.pl-ammo {font-size:10px}
.res-story {font-size:12px; color:#bfc6cf; max-width:540px; margin:10px auto; line-height:1.5}
.res-row b {max-width:65%; text-align:right; overflow-wrap:anywhere}
.res-actions {flex-wrap:wrap}
.portrait .tactical {top:82px; font-size:10px; max-width:94vw; width:max-content}
.portrait .pl-crew i.crew-face {width:21px;height:23px}
.portrait .res-story {font-size:11px;margin:6px auto}
.portrait .res-actions button {min-height:36px}
.pm-history {display:flex;flex-wrap:wrap;justify-content:space-between;gap:4px;font-size:10px;color:#aaa79e;margin:8px 0}
.pm-history small {flex-basis:100%;font-size:10px}
.pm-question {font-size:11px;color:#cec8bb;margin:8px 0}
#timebadge {top:auto;bottom:16px;left:auto;right:16px;transform:none}
body.portrait #timebadge {top:auto;bottom:calc(100vh - var(--dock-top) + 8px)}
.sb-cap {letter-spacing:.05em}
body.portrait .sb-cap {letter-spacing:0;font-size:8px}
.pl-crew i.crew-face {pointer-events:auto}
.pl-crew i.crew-face:focus-visible {outline:2px solid #fff;outline-offset:2px}

#fight-fullscreen { position:fixed;right:12px;bottom:calc(12px + env(safe-area-inset-bottom));z-index:60;min-height:36px;padding:5px 12px;border:1px solid #53646c;background:#13212ae6;color:#e0e6df;font:600 12px 'Saira Condensed',sans-serif;letter-spacing:.06em;cursor:pointer; }
#fight-fullscreen[hidden] { display:none; }
#fight-fullscreen:hover { background:#293e4a; }
#fight-fullscreen:focus-visible { outline:2px solid #dfc18c;outline-offset:3px; }
body.portrait #fight-fullscreen { top:calc(124px + env(safe-area-inset-top));bottom:auto;right:8px; }
body.touch #fight-fullscreen { min-height:44px; }
