/* Trackmaniac live page, styled after F1 TV's broadcast graphics.
   References: formula1.com's own tokens (carbon #15151E, surfaces #26262B/#303037/#47464C,
   F1 red #E10600 used for accents only, never body text), F1 timing colours (purple = fastest
   overall, green = personal best/cleared, yellow = slower/partial), Titillium Web (loaded by
   formula1.com next to its proprietary Formula1 faces) and Saira at a wide stretch for numerals,
   angled parallelogram cuts and team-colour strips. */
:root {
  color-scheme: dark;
  --carbon: #15151e;
  --s1: #1c1c25;
  --s2: #26262b;
  --s3: #303037;
  --s4: #47464c;
  --s5: #606066;
  --text: #f7f4f1;
  --text-2: #c9c7cc;
  --text-3: #8f8e96;
  --red: #e10600;
  --red-dark: #710e10;
  --purple: #b138dd;
  --purple-bg: #5300a6;
  --green: #00d35a;
  --yellow: #ffd800;
  --info: #39b4ff;
  --slant: 14px;
  --gap: 12px;
  --wide: "Saira", "Titillium Web", system-ui, sans-serif;
  --sans: "Titillium Web", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body { background: #0b0b10; color: var(--text); font-family: var(--sans); font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
.hidden { display: none !important; }
.k { font-family: var(--wide); font-stretch: 112%; font-weight: 700; font-size: 11px; letter-spacing: .12em; color: var(--text-3); text-transform: uppercase; }
.empty { color: var(--text-3); padding: 14px 16px; font-size: 15px; }
.purple { color: var(--purple) !important; }
.ok { color: var(--green); }
.bad { color: #ff5a52; }

/* The canvas is always 1920x1080; it scales to fit the window. */
#stage { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
body.controls #stage { bottom: 52px; }
body.program #stage { display: block; }
body.program, body.program * { cursor: none !important; }
#canvas {
  position: relative; width: 1920px; height: 1080px; flex: none; overflow: hidden;
  background: radial-gradient(1200px 600px at 60% -10%, #23232f 0%, transparent 60%), var(--carbon);
  transform-origin: center center;
  display: grid; gap: var(--gap); padding: 0 14px 14px;
  grid-template-columns: 400px 1fr 500px;
  grid-template-rows: 64px 640px 1fr;
}
body.program #canvas { transform: none !important; }
.scene-solo { grid-template-areas: "bar bar bar" "tower video agent" "tower card feed"; }
.scene-multi { grid-template-areas: "bar bar bar" "tower video agent" "tower runs feed"; }
.scene-replay { grid-template-areas: "bar bar bar" "tower video agent" "tower video feed"; }
.scene-solo #runs, .scene-replay #runs, .scene-replay #card, .scene-multi #card { display: none; }

.panel { background: var(--s1); position: relative; min-height: 0; min-width: 0; overflow: hidden; border-top: 3px solid var(--s3); }
/* Panel headings: a slanted block, like F1's graphics tabs. */
.ph { display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 16px 0 0; background: var(--s2); white-space: nowrap; overflow: hidden; flex: none; }
.ph b { font-family: var(--wide); font-stretch: 118%; font-weight: 800; font-style: italic; font-size: 15px; letter-spacing: .04em; background: var(--text); color: var(--carbon); height: 100%; display: flex; align-items: center; padding: 0 22px 0 16px; clip-path: polygon(0 0, 100% 0, calc(100% - var(--slant)) 100%, 0 100%); }
.ph > span:not(.dot) { color: var(--text-3); font-size: 13px; overflow: hidden; text-overflow: ellipsis; }

/* ---------------------------------------------------------------- header */
#bar { grid-area: bar; display: flex; align-items: center; gap: 22px; margin: 0 -14px; padding: 0 22px 0 0; background: linear-gradient(#1d1d27, #15151e); border-bottom: 1px solid var(--s3); white-space: nowrap; }
.logo { display: flex; align-items: center; height: 100%; background: var(--red); padding: 0 30px 0 22px; clip-path: polygon(0 0, 100% 0, calc(100% - 22px) 100%, 0 100%); }
.logo .slash { width: 10px; height: 26px; background: var(--text); transform: skewX(-18deg); margin-right: 12px; }
.logo b { font-family: var(--wide); font-stretch: 125%; font-weight: 900; font-style: italic; font-size: 26px; letter-spacing: .01em; }
.logo b i { font-weight: 400; }
.live-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 3px rgba(225,6,0,.25); animation: pulse 1.4s infinite; flex: none; }
/* view mode: LIVE / RECORDED toggle when a run is live, a plain RECORDED label otherwise */
.mode { display: flex; align-items: center; background: var(--s2); border: 1px solid var(--s3); }
.mode > * { font: inherit; font-family: var(--wide); font-weight: 800; font-stretch: 115%; font-size: 14px; letter-spacing: .1em; display: flex; align-items: center; gap: 8px; padding: 6px 12px; color: var(--text-3); background: none; border: 0; }
.mode button { cursor: pointer; }
.mode button:hover { color: var(--text); }
.mode button.on { background: var(--s4); color: var(--text); }
.mode button:not(.on) .live-dot { animation: none; box-shadow: none; opacity: .6; }
.mode .only { color: var(--text-2); }
body.program .mode button:not(.on) { display: none; }
#feed-sub { display: flex; align-items: center; gap: 8px; }
#feed-sub .live-dot { width: 8px; height: 8px; box-shadow: 0 0 0 2px rgba(225,6,0,.25); }
@keyframes pulse { 50% { opacity: .35; } }
.session { display: flex; align-items: center; gap: 12px; }
.session .track { font-family: var(--wide); font-stretch: 125%; font-weight: 900; font-size: 22px; padding: 2px 12px; background: var(--s3); clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%); }
.session .sub { color: var(--text-3); font-size: 16px; }
#caption { flex: 1; font-size: 18px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; text-align: center; font-style: italic; }
#bar .right { display: flex; align-items: center; gap: 22px; margin-left: auto; }
.counter { display: flex; align-items: baseline; gap: 8px; background: var(--s2); padding: 4px 18px; clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%); }
#runno { font-family: var(--wide); font-stretch: 125%; font-weight: 900; font-size: 26px; line-height: 1; }
#runno small { font-size: 12px; color: var(--green); letter-spacing: .1em; margin-left: 4px; }
#clock { font-family: var(--wide); font-stretch: 110%; font-weight: 600; font-size: 18px; color: var(--text-2); }

/* Banner: slides in from the left, like F1's fastest-lap / race-control alerts. */
#banner { position: absolute; top: 92px; left: 426px; z-index: 6; display: none; align-items: stretch; height: 58px; filter: drop-shadow(0 6px 18px rgba(0,0,0,.5)); }
#banner.on { display: flex; animation: wipe .45s cubic-bezier(.2,.8,.2,1); }
#banner .tag { background: var(--purple-bg); font-family: var(--wide); font-stretch: 120%; font-weight: 900; font-style: italic; font-size: 18px; padding: 0 26px 0 18px; display: flex; align-items: center; letter-spacing: .06em; clip-path: polygon(0 0, 100% 0, calc(100% - 14px) 100%, 0 100%); }
#banner-text { background: var(--text); color: var(--carbon); font-family: var(--wide); font-stretch: 110%; font-weight: 800; font-size: 26px; padding: 0 34px 0 26px; margin-left: -14px; display: flex; align-items: center; clip-path: polygon(14px 0, 100% 0, calc(100% - 14px) 100%, 0 100%); }
@keyframes wipe { from { clip-path: inset(0 100% 0 0); transform: translateX(-30px); } to { clip-path: inset(0 0 0 0); transform: none; } }

/* ---------------------------------------------------------------- timing tower */
#tower { grid-area: tower; display: flex; flex-direction: column; background: rgba(21,21,30,.92); border-top: 0; }
#tower .th { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--s2); border-top: 3px solid var(--red); }
#tower .flag { width: 34px; height: 24px; flex: none; background: repeating-conic-gradient(var(--text) 0 25%, var(--carbon) 0 50%) 0 0 / 12px 12px; clip-path: polygon(4px 0, 100% 0, calc(100% - 4px) 100%, 0 100%); }
#tower .th b { display: block; font-family: var(--wide); font-stretch: 120%; font-weight: 900; font-style: italic; font-size: 19px; letter-spacing: .03em; }
#tower-sub { display: block; color: var(--text-3); font-size: 13px; }
#tower .cols { display: grid; grid-template-columns: 40px 1fr 92px 96px; gap: 8px; padding: 8px 12px 4px; font-family: var(--wide); font-stretch: 110%; font-weight: 700; font-size: 10px; letter-spacing: .12em; color: var(--text-3); }
#tower .cols span:last-child { text-align: right; }
#tower-list { flex: 1; min-height: 0; overflow: hidden; padding: 0 0 4px; }
.row { display: grid; grid-template-columns: 34px 4px 1fr auto 92px 96px; align-items: center; gap: 0 8px; height: 31px; padding: 0 12px 0 6px; border-bottom: 1px solid rgba(255,255,255,.05); cursor: pointer; font-size: 17px; }
body.program .row { cursor: none; }
.row:hover { background: var(--s2); }
.row .pos { font-family: var(--wide); font-stretch: 115%; font-weight: 800; font-size: 15px; text-align: center; background: var(--text); color: var(--carbon); height: 24px; line-height: 24px; clip-path: polygon(0 0, 100% 0, calc(100% - 5px) 100%, 0 100%); }
.row:nth-child(n+4) .pos { background: transparent; color: var(--text); }
.row .strip { width: 4px; height: 22px; background: var(--s5); }
.row .strip.on { background: var(--green); animation: pulse 1.4s infinite; }
.row .code { font-family: var(--wide); font-stretch: 118%; font-weight: 800; font-size: 17px; letter-spacing: .02em; }
.row .st { font-style: normal; font-family: var(--wide); font-weight: 800; font-size: 10px; letter-spacing: .1em; padding: 1px 6px; }
.st.live { background: var(--green); color: var(--carbon); }
.st.out { background: var(--s3); color: var(--text-3); }
.row .secs { display: flex; gap: 3px; }
i.s { display: inline-block; width: 28px; height: 6px; background: var(--s3); transform: skewX(-20deg); }
i.s.p { background: var(--purple); }
i.s.g { background: var(--green); }
i.s.y { background: var(--yellow); }
.row .best { text-align: right; font-family: var(--wide); font-stretch: 105%; font-weight: 600; font-size: 16px; color: var(--text-2); }
.row.sel { background: linear-gradient(90deg, rgba(225,6,0,.28), rgba(225,6,0,.06)); }
.row.sel .strip { background: var(--red); }
.row.up { animation: up 2.5s ease-out; }
.row.down { animation: down 2.5s ease-out; }
@keyframes up { from { background: rgba(0,211,90,.35); } }
@keyframes down { from { background: rgba(255,90,82,.35); } }
#tower-foot { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 8px 14px; font-size: 12px; color: var(--text-3); border-top: 1px solid var(--s3); }
#tower-foot i.s { width: 16px; margin-right: 6px; vertical-align: middle; }
#tower-foot .ch { margin-left: auto; }

#moments { flex: none; border-top: 3px solid var(--s3); max-height: 268px; display: flex; flex-direction: column; }
#moments-list { overflow: hidden; padding: 4px 0; }
.mo { display: grid; grid-template-columns: 82px 40px 1fr; gap: 8px; align-items: baseline; padding: 4px 14px; font-size: 14px; cursor: pointer; border-left: 3px solid transparent; }
.mo:hover { background: var(--s2); }
.mo.on { border-left-color: var(--red); background: var(--s2); }
.mo .t { color: var(--text-3); font-size: 12px; font-family: var(--wide); font-stretch: 105%; }
.mo .code { font-family: var(--wide); font-stretch: 115%; font-weight: 800; font-size: 13px; }
.mo .tt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-2); }
.mo.on .tt { color: var(--text); }

/* ---------------------------------------------------------------- video */
#video { grid-area: video; background: #000; border-top: 0; }
#vid { width: 100%; height: 100%; object-fit: contain; background: #000; display: block; }
#vid-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--text-3); font-size: 18px; }
.lower { position: absolute; left: 0; bottom: 28px; display: flex; align-items: stretch; height: 48px; filter: drop-shadow(0 4px 14px rgba(0,0,0,.6)); max-width: 92%; }
.l-tag { background: var(--red); font-family: var(--wide); font-stretch: 118%; font-weight: 900; font-style: italic; font-size: 15px; letter-spacing: .08em; padding: 0 26px 0 20px; display: flex; align-items: center; clip-path: polygon(0 0, 100% 0, calc(100% - 14px) 100%, 0 100%); white-space: nowrap; }
.l-run { background: var(--text); color: var(--carbon); font-family: var(--wide); font-stretch: 120%; font-weight: 900; font-size: 22px; padding: 0 26px 0 24px; margin-left: -14px; display: flex; align-items: center; clip-path: polygon(14px 0, 100% 0, calc(100% - 14px) 100%, 0 100%); white-space: nowrap; }
.l-cap { background: rgba(21,21,30,.92); font-size: 19px; font-weight: 600; padding: 0 28px 0 26px; margin-left: -14px; display: flex; align-items: center; clip-path: polygon(14px 0, 100% 0, calc(100% - 14px) 100%, 0 100%); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.bug { position: absolute; top: 14px; right: 16px; font-family: var(--wide); font-stretch: 120%; font-weight: 800; font-style: italic; font-size: 13px; letter-spacing: .1em; color: rgba(247,244,241,.7); }
#rendering { position: absolute; top: 14px; left: 0; }
#rendering span { display: block; background: var(--yellow); color: var(--carbon); font-family: var(--wide); font-weight: 800; font-size: 12px; letter-spacing: .08em; padding: 6px 22px 6px 14px; clip-path: polygon(0 0, 100% 0, calc(100% - 10px) 100%, 0 100%); }
#rendering:empty { display: none; }
/* playback controls: recorded replays only, never on the program feed; fade in on hover or while paused */
#vc { position: absolute; left: 0; right: 0; bottom: 0; height: 52px; display: flex; align-items: center; gap: 6px; padding: 0 14px; background: linear-gradient(transparent, rgba(11,11,16,.92) 45%); opacity: 0; transition: opacity .2s; }
#video:hover #vc, #video.paused #vc, #vc:focus-within, body.narrow #vc { opacity: 1; }
#video.has-vc .lower { bottom: 64px; transition: bottom .2s; }
#video.is-live #vc { display: none; }
#vc button { background: rgba(48,48,55,.85); border: 0; height: 30px; min-width: 38px; padding: 0 10px; cursor: pointer; font-family: var(--wide); font-weight: 800; font-size: 13px; letter-spacing: .04em; color: var(--text-2); clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%); }
#vc button:hover { background: var(--s4); color: var(--text); }
#vc button.on { background: var(--red); color: var(--text); }
#vc-seek { outline: none; }
#vc button:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }
#vc-play { min-width: 46px !important; color: var(--text) !important; }
#vc-seek { flex: 1; min-width: 60px; height: 30px; margin: 0 6px; accent-color: var(--red); cursor: pointer; background: transparent; }
#vc-time { font-family: var(--mono); font-size: 13px; color: var(--text-2); white-space: nowrap; min-width: 92px; text-align: right; }
body.narrow #vc { height: 44px; padding: 0 8px; gap: 4px; }
body.narrow #vc button { height: 28px; min-width: 32px; padding: 0 7px; font-size: 11px; }
body.narrow #vc-back, body.narrow #vc-fwd { display: none; }
body.narrow #vc-time { font-size: 11px; min-width: 0; }
body.narrow #video.has-vc .lower { bottom: 50px; }

/* ---------------------------------------------------------------- focused run (driver card) */
#card { grid-area: card; padding: 14px 20px 12px; display: flex; flex-direction: column; gap: 9px; border-top-color: var(--red); }
.ctop { display: flex; align-items: center; gap: 16px; }
.ctop .num { font-family: var(--wide); font-stretch: 125%; font-weight: 900; font-style: italic; font-size: 46px; line-height: 1; min-width: 74px; padding: 4px 18px 4px 12px; background: var(--red); text-align: center; clip-path: polygon(0 0, 100% 0, calc(100% - 12px) 100%, 0 100%); }
.who { min-width: 0; flex: 1; }
.who .nm { display: flex; align-items: center; gap: 10px; font-family: var(--wide); font-stretch: 120%; font-weight: 800; font-size: 24px; }
.who .meta { color: var(--text-3); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip { font-style: normal; font-family: var(--wide); font-stretch: 110%; font-weight: 800; font-size: 11px; letter-spacing: .1em; padding: 2px 9px; text-transform: uppercase; background: var(--s3); color: var(--text-2); }
.chip.live { background: var(--green); color: var(--carbon); }
.chip.done { background: var(--s4); color: var(--text); }
.back { margin-left: auto; background: var(--s3); border: 0; padding: 4px 12px; font-family: var(--wide); font-weight: 700; font-size: 11px; letter-spacing: .08em; cursor: pointer; }
.back:hover { background: var(--red); }
.pp { text-align: right; }
.pp b { display: block; font-family: var(--wide); font-stretch: 125%; font-weight: 900; font-style: italic; font-size: 32px; line-height: 1; }
.target, .result, .harness { font-size: 15px; line-height: 1.4; color: var(--text-2); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.target .k, .result .k, .harness .k { margin-right: 10px; }
.result { color: var(--text); -webkit-line-clamp: 3; }
body:not(.narrow) .harness { display: none; }
.sbar { display: flex; gap: 4px; height: 14px; margin-top: 4px; }
.seg { position: relative; background: var(--s3); transform: skewX(-20deg); }
.seg .f { height: 100%; background: var(--text-3); }
.seg.p .f { background: var(--purple); }
.seg.g .f { background: var(--green); }
.seg.y .f { background: var(--yellow); }
.seg span { position: absolute; left: 8px; top: -1px; font-family: var(--wide); font-weight: 800; font-size: 10px; color: var(--carbon); transform: skewX(20deg); mix-blend-mode: normal; }
.seg:not(.p):not(.g):not(.y) span { color: var(--text-3); }
.smarks { position: relative; height: 14px; font-family: var(--wide); font-size: 10px; font-weight: 700; letter-spacing: .1em; color: var(--text-3); }
.smarks span { position: absolute; transform: translateX(-50%); }
.smarks span:first-child { transform: none; left: 0; }
.smarks .fin { right: 0; transform: none; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stats > div { border-left: 3px solid var(--s3); padding-left: 10px; }
.stats b { display: block; font-family: var(--wide); font-stretch: 112%; font-weight: 800; font-size: 26px; line-height: 1.15; white-space: nowrap; }
.stats small { font-size: 13px; color: var(--text-3); font-weight: 600; }

/* live run cards (multi scene) */
#runs { grid-area: runs; display: grid; gap: var(--gap); min-height: 0; }
#runs.n2 { grid-template-columns: 1fr 1fr; }
#runs.n3, #runs.n4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.run { background: var(--s1); border-top: 3px solid var(--s3); padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; overflow: hidden; cursor: pointer; min-height: 0; }
.run.focus { border-top-color: var(--red); }
.run .top { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.run .code { font-family: var(--wide); font-stretch: 120%; font-weight: 900; font-style: italic; font-size: 22px; }
.run .label { color: var(--text-3); font-size: 14px; }
.run .el { margin-left: auto; color: var(--text-3); font-size: 13px; }
.run .target { font-size: 13px; -webkit-line-clamp: 1; }
.run .sbar { height: 10px; }
.run .mini { display: flex; gap: 16px; font-size: 13px; color: var(--text-3); }
.run .mini b { color: var(--text); font-family: var(--wide); font-weight: 800; font-size: 16px; }

/* ---------------------------------------------------------------- team radio */
#agent { grid-area: agent; display: flex; flex-direction: column; border-top-color: var(--info); }
#agent .ph b { background: var(--info); }
#agent-title { color: var(--text-2) !important; font-family: var(--wide); font-weight: 700; font-size: 12px !important; letter-spacing: .08em; }
.tbox { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
#agent.term .tbox { display: none; }
#transcript { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; padding: 12px 14px; gap: 10px; font-size: 15px; line-height: 1.45; scrollbar-width: thin; scrollbar-color: var(--s4) transparent; }
#transcript > * { flex-shrink: 0; }
#transcript > :first-child { margin-top: auto; }
body.program #transcript { overflow: hidden; }
#jump { position: absolute; left: 50%; transform: translateX(-50%); bottom: 12px; z-index: 3; display: none; background: var(--text); color: var(--carbon); border: 0; padding: 5px 16px; font-family: var(--wide); font-weight: 800; font-size: 12px; letter-spacing: .08em; cursor: pointer; clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%); }
#jump.on { display: block; }
.who { }
.t-say, .t-user { position: relative; padding: 8px 12px 9px 14px; background: var(--s2); border-left: 4px solid var(--info); word-break: break-word; }
.t-user { border-left-color: var(--yellow); background: #24231f; white-space: pre-wrap; color: var(--text-2); max-height: 9.5em; overflow: hidden; }
.t-say .who, .t-user .who { display: block; font-family: var(--wide); font-stretch: 115%; font-weight: 800; font-style: italic; font-size: 11px; letter-spacing: .12em; color: var(--info); margin-bottom: 2px; }
.t-user .who { color: var(--yellow); }
.t-say strong { font-weight: 700; }
.t-say code { font-family: var(--mono); font-size: .84em; color: #ffd27a; background: rgba(0,0,0,.3); padding: 0 4px; word-break: break-all; }
.t-say .h { font-weight: 700; margin-top: 4px; }
.t-say .li { padding-left: 14px; position: relative; }
.t-say .li:not(.n)::before { content: ""; position: absolute; left: 2px; top: .65em; width: 6px; height: 3px; background: var(--text-3); transform: skewX(-20deg); }
.t-say .gap { height: 6px; }
.t-say .tw { overflow-x: auto; }
.t-say table { border-collapse: collapse; margin: 4px 0; font-size: 13px; }
.t-say th { text-align: left; font-family: var(--wide); font-weight: 700; color: var(--text-3); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.t-say th, .t-say td { padding: 3px 8px; border-bottom: 1px solid var(--s3); vertical-align: top; }
.t-tool { font-family: var(--mono); font-size: 12px; padding-left: 4px; }
.t-tool .hd { color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-tool .hd::before { content: ""; display: inline-block; width: 8px; height: 8px; background: var(--green); margin-right: 8px; transform: skewX(-20deg); }
.t-tool.err .hd::before { background: #ff5a52; }
.t-tool.run .hd::before { background: var(--yellow); animation: pulse 1s infinite; }
.t-tool .hd b { color: var(--text-2); font-weight: 600; }
.t-tool .out { color: #75747c; white-space: pre-wrap; word-break: break-all; padding-left: 12px; border-left: 1px solid var(--s3); margin: 3px 0 0 3px; max-height: 4.6em; overflow: hidden; }
.t-tool .more { color: var(--s5); padding-left: 16px; }
#terminal { flex: 1; border: 0; display: none; background: var(--carbon); }
#agent.term #terminal { display: block; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--s5); flex: none; display: inline-block; }
.dot.busy { background: var(--green); animation: pulse 1.2s infinite; }
.dot.shell { background: var(--info); }
#subagents { border-top: 1px solid var(--s3); padding: 8px 14px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
#subagents:empty { display: none; }
.sa { display: flex; gap: 8px; align-items: center; white-space: nowrap; overflow: hidden; }
.sa .desc { font-weight: 600; }
.sa .st { color: var(--text-3); font-family: var(--wide); font-size: 10px; font-weight: 700; letter-spacing: .08em; }
.sa .last { color: var(--text-3); overflow: hidden; text-overflow: ellipsis; font-family: var(--mono); font-size: 11px; }
.sa.done { opacity: .5; }
#others { border-top: 1px solid var(--s3); padding: 7px 14px 9px; display: flex; gap: 6px 14px; flex-wrap: wrap; align-items: center; font-size: 12px; max-height: 58px; overflow: hidden; }
#others-list { display: contents; }
.oa { display: inline-flex; gap: 6px; align-items: center; color: var(--text-3); max-width: 300px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------------------------------------------------------------- race control */
#feed { grid-area: feed; display: flex; flex-direction: column; border-top-color: var(--yellow); }
#feed .ph b { background: var(--yellow); }
#feed-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--s4) transparent; display: flex; flex-direction: column; padding: 6px 0; -webkit-mask-image: linear-gradient(transparent, #000 36px); mask-image: linear-gradient(transparent, #000 36px); }
/* newest at the bottom: push a short list down (justify-content: flex-end would make the top unreachable once it scrolls) */
#feed-list > :first-child { margin-top: auto; }
body.program #feed-list { overflow: hidden; }
.ev { display: grid; grid-template-columns: 46px 38px 1fr auto; gap: 8px; align-items: center; padding: 4px 14px; font-size: 13px; white-space: nowrap; border-bottom: 1px solid rgba(255,255,255,.04); }
.ev .t { color: var(--text-3); font-family: var(--wide); font-size: 12px; }
.ev .code { font-family: var(--wide); font-stretch: 115%; font-weight: 800; }
.ev .nm { overflow: hidden; text-overflow: ellipsis; text-transform: uppercase; letter-spacing: .02em; color: var(--text-2); }
.ev .v { font-family: var(--wide); font-weight: 800; font-size: 10px; letter-spacing: .1em; padding: 2px 7px; background: var(--s3); }
.ev .v.ok { background: var(--green); color: var(--carbon); }
.ev .v.bad { background: #ff5a52; color: var(--carbon); }
.ev .v.info { background: var(--info); color: var(--carbon); }
.ev .v.flag { background: repeating-conic-gradient(var(--text) 0 25%, var(--carbon) 0 50%) 0 0 / 8px 8px; color: transparent; text-shadow: none; position: relative; }
.ev .v.flag::after { content: "CHEQUERED"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--text); background: rgba(21,21,30,.6); }
.ev.fresh { animation: flash 3s ease-out; }
@keyframes flash { from { background: rgba(255,216,0,.25); } }

/* ---------------------------------------------------------------- narrow screens: stacked */
body.narrow { overflow-y: auto; height: auto; }
body.narrow html { height: auto; }
body.narrow #stage { position: static; display: block; }
body.narrow #canvas { width: auto; height: auto; transform: none; display: flex; flex-direction: column; padding: 0 0 16px; gap: 10px; }
body.narrow #bar { margin: 0; height: auto; flex-wrap: wrap; padding: 0 16px 10px 0; gap: 10px 16px; }
body.narrow .logo { height: 52px; }
body.narrow .session .sub, body.narrow #caption { display: none; }
body.narrow #bar .right { gap: 12px; }
body.narrow #clock { display: none; }
body.narrow .panel, body.narrow #runs { margin: 0 16px; }
body.narrow #video { order: 1; aspect-ratio: 4 / 3; height: auto; }
body.narrow #card { order: 2; }
body.narrow #runs { order: 3; grid-template-columns: 1fr !important; grid-template-rows: none !important; }
body.narrow #tower { order: 4; }
body.narrow #agent { order: 5; height: 75vh; }
body.narrow #feed { order: 6; height: 50vh; }
body.narrow #tower-list, body.narrow #moments-list { overflow: visible; }
body.narrow #moments { max-height: none; }
body.narrow .target, body.narrow .result, body.narrow .harness { -webkit-line-clamp: unset; display: block; }
body.narrow .stats { grid-template-columns: 1fr 1fr; }
body.narrow .ctop .num { font-size: 34px; min-width: 56px; }
body.narrow .who .nm { font-size: 18px; flex-wrap: wrap; }
body.narrow .pp b { font-size: 24px; }
body.narrow .lower { bottom: 10px; height: 34px; }
body.narrow .l-tag { font-size: 11px; padding: 0 18px 0 10px; }
body.narrow .l-run { font-size: 14px; }
body.narrow .l-cap { font-size: 13px; }
body.narrow .bug { display: none; }
body.narrow #banner { left: 16px; top: 64px; height: 44px; max-width: calc(100% - 32px); }
body.narrow #banner-text { font-size: 16px; }
body.narrow .row { font-size: 15px; grid-template-columns: 30px 4px 1fr auto 78px 82px; gap: 0 6px; }
body.narrow i.s { width: 22px; }
body.narrow .scene-solo #runs, body.narrow .scene-replay #runs { display: none; }
body.narrow.controls { padding-bottom: 60px; }
html:has(body.narrow) { height: auto; overflow: auto; }

/* ---------------------------------------------------------------- preview toolbar (private port only) */
#toolbar { display: none; position: fixed; left: 0; right: 0; bottom: 0; height: 52px; background: var(--s2); border-top: 2px solid var(--red); align-items: center; gap: 18px; padding: 0 16px; font-size: 13px; overflow-x: auto; white-space: nowrap; z-index: 20; }
body.controls #toolbar { display: flex; }
.tb-title { font-family: var(--wide); font-weight: 800; font-style: italic; letter-spacing: .08em; text-transform: uppercase; font-size: 13px; }
.grp { color: var(--text-3); display: inline-flex; gap: 4px; align-items: center; }
#toolbar button { background: var(--s3); color: var(--text-2); border: 0; padding: 4px 12px; cursor: pointer; font-family: var(--wide); font-weight: 700; font-size: 12px; letter-spacing: .04em; clip-path: polygon(5px 0, 100% 0, calc(100% - 5px) 100%, 0 100%); }
#toolbar button.on { background: var(--red); color: var(--text); }
#toolbar button:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }
#tb-status { color: var(--text-3); }

/* ---------------------------------------------------------------- live view (a run is live) */
#live { position: absolute; inset: 0; z-index: 2; background: radial-gradient(900px 500px at 50% 40%, #1c1c27, #0d0d13); }
#video.is-live #vid, #video.is-live .lower, #video.is-live #vid-empty, #video.is-live #rendering { display: none; }
#map { position: absolute; inset: 0; width: 100%; height: 100%; }
#map .road-edge { fill: none; stroke: #2e2e38; stroke-width: 20; stroke-linejoin: round; stroke-linecap: round; }
#map .road { fill: none; stroke: #4a4a55; stroke-width: 8; stroke-linejoin: round; stroke-linecap: round; }
#map .path { fill: none; stroke: rgba(247,244,241,.35); stroke-width: 2.5; stroke-dasharray: 2 5; }
#map .trail { fill: none; stroke: var(--red); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
#map .cpm circle, #map .cpm rect { fill: var(--carbon); stroke: var(--yellow); stroke-width: 3; }
#map .cpm.start rect { stroke: var(--green); }
#map .cpm.fin rect { stroke: var(--text); fill: var(--text); }
#map .cpm text, #map .tipm text { fill: var(--text-2); font-family: var(--wide); font-weight: 800; font-size: 14px; letter-spacing: .08em; paint-order: stroke; stroke: var(--carbon); stroke-width: 4px; }
#map .tipm circle { fill: var(--purple); }
#map .tipm text { fill: var(--purple); }
#map .car { fill: var(--text); stroke: var(--red); stroke-width: 4; }
#map .halo { fill: rgba(225,6,0,.25); }
#m-car.tip .halo { animation: pulse 0.8s infinite; fill: rgba(177,56,221,.45); }
.hud { position: absolute; left: 0; top: 16px; width: 300px; display: flex; flex-direction: column; gap: 10px; }
.hd-tag { display: flex; height: 40px; }
.hd-tag .l-tag { font-size: 13px; }
.hd-tag .l-run { font-size: 18px; }
.hd-speed { margin-left: 18px; display: flex; align-items: baseline; gap: 8px; }
.hd-speed b { font-family: var(--wide); font-stretch: 125%; font-weight: 900; font-style: italic; font-size: 64px; line-height: 1; }
.hd-speed span { font-family: var(--wide); font-weight: 800; color: var(--text-3); letter-spacing: .1em; }
.hd-grid { margin-left: 18px; display: grid; gap: 6px; }
.hd-grid > div { border-left: 3px solid var(--red); padding-left: 10px; }
.hd-grid b { display: block; font-family: var(--wide); font-stretch: 112%; font-weight: 800; font-size: 24px; line-height: 1.1; }
#tl-state { margin-left: 18px; font-size: 13px; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
#tl-state span { font-family: var(--wide); font-weight: 800; font-size: 11px; letter-spacing: .1em; padding: 2px 8px; margin-right: 8px; color: var(--carbon); }
#tl-state .on { background: var(--green); }
#tl-state .over { background: var(--s4); color: var(--text); }
#elev { position: absolute; left: 340px; width: calc(100% - 358px); bottom: 34px; height: 64px; background: rgba(21,21,30,.75); }
#elev .ground { fill: rgba(247,244,241,.06); }
#elev .prof { fill: none; stroke: var(--text-3); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
#elev .cpl { stroke: var(--yellow); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
#elev #e-fill { fill: rgba(225,6,0,.18); }
#elev #e-mark { stroke: var(--red); stroke-width: 3; vector-effect: non-scaling-stroke; }
#tl-note { position: absolute; left: 340px; bottom: 10px; font-size: 12px; color: var(--text-3); }
.remix { position: absolute; top: 16px; right: 16px; display: flex; align-items: center; gap: 10px; }
.remix span { font-family: var(--wide); font-weight: 700; font-size: 12px; letter-spacing: .08em; color: var(--text-3); }
#remix-tl, #remix-pip { background: var(--text); color: var(--carbon); border: 0; cursor: pointer; font-family: var(--wide); font-stretch: 115%; font-weight: 900; font-style: italic; font-size: 14px; letter-spacing: .06em; padding: 7px 20px; clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%); }
#remix-tl:hover, #remix-pip:hover { background: var(--red); color: var(--text); }
body.program .remix button, body.program #remix-pip { display: none; }
#pip { position: absolute; left: 16px; bottom: 16px; width: 300px; background: #000; border-top: 3px solid var(--red); box-shadow: 0 10px 30px rgba(0,0,0,.6); }
#pipv { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.pip-cap { display: flex; align-items: stretch; height: 30px; flex-wrap: nowrap; background: rgba(21,21,30,.95); }
.pip-cap .l-tag { font-size: 11px; padding: 0 18px 0 10px; }
#pip-cap { flex: 1; font-size: 13px; padding: 0 8px; display: flex; align-items: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#remix-pip { padding: 0 14px; font-size: 14px; }
body.narrow .hud { position: static; width: auto; padding: 10px 0; }
body.narrow #video.is-live { aspect-ratio: auto; }
body.narrow #live { position: relative; display: flex; flex-direction: column; }
body.narrow #map { position: relative; height: auto; aspect-ratio: 600 / 495; order: 2; }
body.narrow .hud { order: 1; flex-direction: row; flex-wrap: wrap; align-items: center; }
body.narrow .hd-speed b { font-size: 40px; }
body.narrow .hd-grid { grid-template-columns: repeat(3, auto); gap: 12px; }
body.narrow .hd-grid b { font-size: 17px; }
body.narrow .remix { position: static; order: 3; padding: 6px 16px; justify-content: space-between; }
body.narrow #elev { position: relative; left: auto; bottom: auto; width: auto; margin: 0 16px; order: 4; }
body.narrow #tl-note { position: static; order: 5; padding: 6px 16px; }
body.narrow #pip { position: relative; left: auto; right: auto; bottom: auto; width: auto; margin: 8px 16px 12px; order: 6; }
