/* Race ops page. GitHub-dark palette, as the architecture page's ops mock. No external fonts. */
:root {
  --bg: #0d1117; --panel: #161b22; --inset: #0d1117; --line: #30363d; --line2: #21262d;
  --text: #e6edf3; --muted: #8b949e; --blue: #58a6ff; --green: #3fb950; --purple: #bc8cff;
  --amber: #d29922; --orange: #f0883e; --red: #f85149; --cyan: #39c5cf; --pink: #f778ba;
}
* { box-sizing: border-box; }
html { color-scheme: dark; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; }
button, select { font: inherit; color: var(--text); background: var(--line2); border: 1px solid var(--line); border-radius: 6px; padding: 3px 10px; }
button { cursor: pointer; }
button:hover, select:hover { border-color: #8b949e; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--panel); }
.top h1 { font-size: 17px; margin: 0; letter-spacing: -.01em; }
.top h1 span { color: var(--muted); font-weight: 500; font-size: 14px; margin-left: 8px; }
.status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.status.ok .dot { background: var(--green); }
.status.err { color: var(--red); }
.status.err .dot { background: var(--red); }

.layout { display: grid; gap: 16px; padding: 16px 20px 40px; max-width: 1680px; margin: 0 auto;
  grid-template-columns: minmax(0, 1fr); grid-template-areas: "rooms" "view" "riders"; }
@media (min-width: 1800px) {
  .layout { max-width: none; grid-template-columns: minmax(0, 780px) minmax(0, 1fr); grid-template-areas: "rooms view" "riders view"; align-items: start; }
  .room-view { position: sticky; top: 16px; }
}
.rooms { grid-area: rooms; }
.room-view { grid-area: view; }
.riders { grid-area: riders; }

.pane { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; min-width: 0; }
.pane-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 10px; min-height: 28px; }
.pane-head h2 { font-size: 15px; margin: 0; }
.count, .meta { color: var(--muted); font-size: 13px; }
.meta { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 200px; }
.tools { display: flex; align-items: center; gap: 8px; margin-left: auto; color: var(--muted); font-size: 13px; }
.tools select { max-width: 190px; }
.empty, .view-empty { color: var(--muted); margin: 14px 4px 6px; }
.pane.stale table { opacity: .55; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line2); white-space: nowrap; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }
th.num, td.num { text-align: right; }
tbody tr { cursor: pointer; }
tbody tr:hover td { background: rgba(110, 118, 129, .08); }
tbody tr.sel td { background: rgba(88, 166, 255, .10); }
tbody tr:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
td .cell { display: flex; align-items: center; gap: 6px; min-width: 0; }
td .nm { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
td .sub { color: var(--muted); font-size: 11.5px; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; }
.rooms td:first-child .nm { font-weight: 600; }
.riders td:first-child { max-width: 240px; }
.riders td:first-child .cell { max-width: 240px; }

th[data-key] { cursor: pointer; user-select: none; }
th[data-key]:hover { color: var(--text); }
th[aria-sort="ascending"]::after { content: " \25B2"; font-size: 9px; }
th[aria-sort="descending"]::after { content: " \25BC"; font-size: 9px; }

.warn { color: var(--amber); }
.bad { color: var(--red); }
.dim { color: var(--muted); }
.good { color: var(--green); }

.pill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.ph-warmup { background: rgba(210, 153, 34, .15); color: var(--amber); }
.ph-notice { background: rgba(240, 136, 62, .17); color: var(--orange); }
.ph-countdown { background: rgba(88, 166, 255, .15); color: var(--blue); }
.ph-racing { background: rgba(63, 185, 80, .15); color: var(--green); }
.ph-results { background: rgba(188, 140, 255, .15); color: var(--purple); }
.ph-other { background: var(--line2); color: var(--muted); }
.conn.live { background: rgba(63, 185, 80, .15); color: var(--green); }
.conn.connecting { background: rgba(88, 166, 255, .15); color: var(--blue); }
.conn.reconnecting, .conn.stale { background: rgba(210, 153, 34, .15); color: var(--amber); }
.conn.closed { background: var(--line2); color: var(--muted); }

.kdot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; }
.kdot.human { background: var(--blue); }
.kdot.ai { background: var(--muted); }
.tag { flex: none; font-size: 10.5px; line-height: 15px; padding: 0 5px; border-radius: 4px; font-weight: 600; }
.tag.ai { background: var(--line2); color: var(--muted); }
.tag.off { background: rgba(210, 153, 34, .16); color: var(--amber); }
.tag.wrong { background: rgba(248, 81, 73, .16); color: var(--red); }
.tag.rec { background: rgba(57, 197, 207, .16); color: var(--cyan); }
.tag.fin { background: rgba(63, 185, 80, .16); color: var(--green); }
.tag.item { background: rgba(188, 140, 255, .14); color: var(--purple); font-weight: 500; }

/* room view */
.room-view .view-body, .room-view .tools, .room-view .meta, .room-view .conn { display: none; }
.room-view.open .view-body { display: grid; }
.room-view.open .tools { display: flex; }
.room-view.open .meta { display: block; }
.room-view.open .conn:not([hidden]) { display: inline-block; }
.room-view.open .view-empty { display: none; }
.view-body { grid-template-columns: minmax(0, 1fr) 380px; gap: 14px; }
@media (max-width: 900px) { .view-body { grid-template-columns: minmax(0, 1fr); } }

.map-wrap { position: relative; height: clamp(340px, calc(100vh - 120px), 860px); background: var(--inset); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
@media (max-width: 900px) { .map-wrap { height: clamp(300px, 58vh, 540px); } }
#map { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#map.dragging { cursor: grabbing; }
#map.hovering { cursor: pointer; }
#map:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--blue); }

.banner { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 20px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 3px 12px; border-radius: 999px; border: 1px solid var(--line); background: rgba(22, 27, 34, .88); color: var(--muted); font-size: 12.5px; pointer-events: none; }
.banner.big { padding: 5px 18px; border-radius: 12px; font-size: 20px; font-weight: 700; color: var(--text); }
.banner.racing { color: var(--green); border-color: rgba(63, 185, 80, .45); }
.banner.notice { border-color: var(--orange); }
.banner.countdown { border-color: var(--blue); }
.banner.results { border-color: var(--purple); }
.map-note { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); max-width: min(420px, calc(100% - 24px)); text-align: center;
  padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line); background: rgba(22, 27, 34, .92); color: var(--text); font-size: 13px; pointer-events: none; }
.map-note.corner { top: auto; bottom: 34px; transform: translateX(-50%); color: var(--muted); font-size: 12px; padding: 4px 10px; }
.legend { position: absolute; left: 8px; bottom: 8px; right: 8px; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11px; color: var(--muted); pointer-events: none; }
.legend span { display: inline-flex; align-items: center; gap: 4px; background: rgba(13, 17, 23, .72); padding: 0 4px; border-radius: 4px; }
.legend .ring { width: 10px; height: 10px; border-radius: 50%; border: 2px solid; }
.legend .ring.off { border-color: var(--amber); }
.legend .ring.wrong { border-color: var(--red); border-style: dashed; }
.legend .ring.rec { border-color: var(--cyan); border-style: dotted; }
.legend .ring.fin { border-color: #fff; border-style: dashed; }
.legend .flash { width: 9px; height: 9px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 1.5px #fff; }
@media (max-width: 600px) { .legend { display: none; } }

.side { min-width: 0; display: flex; flex-direction: column; }
.board th, .board td { padding: 5px 6px; font-size: 12.5px; }
/* the name column takes what is left and ellipsizes, so the board never outgrows its pane */
.board td.who { width: 100%; max-width: 0; }
.board td.who .cell { flex-wrap: wrap; row-gap: 2px; } /* status tags drop under a long name instead of crushing it */
.board tr.sel td { background: rgba(255, 255, 255, .07); }
.board .items { display: flex; gap: 3px; }
.side h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 14px 0 6px; }
.feed { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; font-size: 12.5px; }
.feed li { display: grid; grid-template-columns: 68px minmax(0, 1fr) auto; gap: 8px; padding: 3px 2px; border-bottom: 1px solid var(--line2); }
.feed .k { font-weight: 600; font-size: 11.5px; }
.feed .x { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed .age { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.feed .contact .k { color: var(--red); }
.feed .barrier .k { color: var(--orange); }
.feed .item_hit .k { color: var(--purple); }
.feed .lap .k { color: var(--blue); }
.feed .finished .k { color: var(--green); }
.feed .respawned .k { color: var(--cyan); }
.feed .phase .k, .feed .other .k { color: var(--muted); }
.feed .empty-row { color: var(--muted); display: block; border: 0; }

@media (max-width: 600px) {
  .layout { padding: 10px 8px 30px; gap: 10px; }
  .pane { padding: 10px; border-radius: 10px; }
  .top { padding: 10px 12px; }
  .tools { margin-left: 0; flex-wrap: wrap; }
  th, td { padding: 6px 7px; }
}
