:root {
  --bg: #0b0d12;
  --panel: #12161e;
  --panel-2: #181d27;
  --line: #262d3a;
  --text: #e6e9ef;
  --muted: #8b94a5;
  --accent: #4cc9f0;
  --good: #4ade80;
  --warn: #facc15;
  --bad: #f87171;
  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
}
button, input, textarea { font: inherit; color: inherit; }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex-wrap: wrap;
}
.brand { font-weight: 700; letter-spacing: 0.02em; }
.game-name { color: var(--muted); }
.spacer { flex: 1; }
.rev-chip {
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 999px;
  padding: 2px 10px;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  cursor: pointer;
}
.name-field { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.name-field input {
  width: 140px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 8px;
}
.status { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.status.ok .dot { background: var(--good); }
.status.bad .dot { background: var(--bad); }

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  min-height: 0;
}
.stage-wrap { position: relative; min-width: 0; min-height: 0; padding: 12px; }
.stage {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  background: #0e1116;
  border: 1px solid var(--line);
}
.stage canvas { display: block; transition: filter 180ms ease; }
.stage.patching canvas { filter: grayscale(0.85) brightness(0.75); }

/* The "reality patch": a bright band sweeping across when a revision lands. */
.patch-sweep {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  opacity: 0;
  background: linear-gradient(100deg, transparent 0%, transparent 40%, rgba(76, 201, 240, 0.0) 44%, rgba(76, 201, 240, 0.55) 50%, rgba(255, 255, 255, 0.8) 51%, rgba(76, 201, 240, 0.35) 53%, transparent 60%, transparent 100%);
  background-size: 250% 100%;
  background-position: 120% 0;
}
.patch-sweep.run { animation: sweep 900ms ease-in-out forwards; }
@keyframes sweep {
  0% { opacity: 1; background-position: 120% 0; }
  90% { opacity: 1; }
  100% { opacity: 0; background-position: -30% 0; }
}

.banner {
  position: absolute;
  left: 50%;
  top: 24px;
  transform: translateX(-50%);
  z-index: 3;
  max-width: min(640px, calc(100% - 48px));
  background: rgba(18, 22, 30, 0.94);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 10px 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
.banner.failed { border-left-color: var(--bad); }
.banner.pending { border-left-color: var(--warn); }
.banner-title { font-weight: 600; }
.banner-detail { color: var(--muted); font-size: 13px; white-space: pre-line; }

.panel {
  border-left: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button {
  flex: 1;
  background: none;
  border: 0;
  padding: 10px 0;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tab-body { padding: 12px 16px; overflow: auto; flex: 1; }
.hint { color: var(--muted); margin: 0 0 12px; font-size: 13px; }

.tunable { margin-bottom: 14px; }
.tunable-head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.tunable-head output { font-variant-numeric: tabular-nums; color: var(--accent); }
.tunable input[type="range"] { width: 100%; accent-color: var(--accent); }
.tunable.flash .tunable-head output { color: var(--warn); }

.timeline, .activity { list-style: none; margin: 0; padding: 0; }
.timeline li {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 8px;
  background: var(--panel-2);
}
.timeline .row { display: flex; align-items: center; gap: 8px; }
.timeline code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }
.badge { font-size: 11px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.badge.active { color: var(--good); border-color: var(--good); }
.badge.failed { color: var(--bad); border-color: var(--bad); }
.timeline .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.timeline .err { color: var(--bad); font-size: 12px; margin-top: 4px; word-break: break-word; }
.timeline button, .danger {
  margin-left: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 8px;
  cursor: pointer;
}
.danger { margin-top: 8px; color: var(--bad); border-color: #5b2a2a; }
.activity li { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.activity time { color: var(--muted); font-size: 11px; margin-right: 6px; font-variant-numeric: tabular-nums; }
.activity .error { color: var(--bad); }
.activity .rev { color: var(--accent); }

/* ---- standalone pages: sign-in, access request, admin ---- */
body.page { align-items: center; }
body.page .card {
  width: min(440px, calc(100% - 32px));
  margin: 12vh auto 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.card h1 { margin: 0; font-size: 26px; }
.card .lede { margin: 0; color: var(--muted); }
.fine { font-size: 12px; color: var(--muted); }
.link-btn { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; padding: 0; font: inherit; font-size: 12px; }
.error { color: var(--bad); margin: 0; }
.stack { display: flex; flex-direction: column; gap: 6px; }
.stack input, .card textarea, .search, select {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  font: inherit;
}
a.primary, .big { text-align: center; text-decoration: none; }
a.primary { background: var(--accent); color: #04131a; border-radius: 8px; font-weight: 600; }
.big { padding: 10px 14px; font-size: 15px; }
.who, .person { display: flex; align-items: center; gap: 10px; }
.who img, .person img, .avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; object-fit: cover; }
.avatar { display: grid; place-items: center; background: var(--panel-2); border: 1px solid var(--line); font-weight: 600; }
.ghost-link { color: var(--muted); text-decoration: none; }
body.admin { align-items: stretch; }
.admin-main { width: min(860px, calc(100% - 32px)); margin: 0 auto; padding: 16px 0 40px; }
.admin-main .tabs { margin-bottom: 12px; }
.search { width: 100%; margin-bottom: 8px; }
.admin-list { list-style: none; margin: 0; padding: 0; }
.admin-list li { display: grid; grid-template-columns: minmax(200px, 1fr) 2fr auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.admin-list .message { margin: 4px 0 0; white-space: pre-wrap; }
.admin-list .actions { display: flex; gap: 6px; align-items: center; }
.count { color: var(--warn); }
input.limit { width: 80px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; color: var(--text); font: inherit; }
.me { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.me img { width: 24px; height: 24px; border-radius: 50%; }
.admin-badge { color: var(--warn); text-decoration: none; font-size: 13px; }
@media (max-width: 700px) {
  .admin-list li { grid-template-columns: 1fr; }
}

/* ---- lobby ---- */
a.brand { color: var(--text); text-decoration: none; }
body.lobby { align-items: stretch; }
.lobby-main { width: min(760px, calc(100% - 32px)); margin: 0 auto; padding: 16px 0 48px; display: flex; flex-direction: column; gap: 24px; }
.lobby-main h2 { font-size: 16px; margin: 0 0 10px; }
.new-game { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.templates { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
.templates legend { padding: 0; margin-bottom: 6px; color: var(--muted); }
.template { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.template:has(input:checked) { border-color: var(--accent); }
.template span { display: flex; flex-direction: column; gap: 2px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.game-list { list-style: none; margin: 0; padding: 0; }
.game-list li { display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.game-link { flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 12px 0; color: var(--text); text-decoration: none; }
.game-link:hover strong { color: var(--accent); }
.game-link .badge { margin-left: 6px; vertical-align: middle; }

/* ---- sharing a game ---- */
.share-dialog { width: min(620px, calc(100% - 32px)); background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px 20px; }
.share-dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.share-dialog h3 { font-size: 13px; margin: 16px 0 8px; color: var(--muted); font-weight: 600; }
.share-head { display: flex; align-items: center; justify-content: space-between; margin: 0; }
.share-head h2 { margin: 0; font-size: 17px; }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; cursor: pointer; }
.choice > span { display: flex; flex-direction: column; }
.share-list { list-style: none; margin: 8px 0 0; padding: 0; }
.share-list li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.share-list li > .who-line { flex: 1; min-width: 160px; display: flex; flex-direction: column; }
.invite-url { flex: 1; min-width: 0; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 12px; }

/* ---- art panel ---- */
.panel-title { font-size: 13px; margin: 18px 0 4px; color: var(--text); }
.art-asset { margin-bottom: 12px; }
.art-asset .name { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.art-variants { display: flex; gap: 6px; flex-wrap: wrap; }
.art-variants button {
  width: 48px;
  height: 48px;
  padding: 2px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2) center / contain no-repeat;
  cursor: pointer;
  font-size: 11px;
  color: var(--muted);
}
.art-variants button[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(76, 201, 240, 0.35); }

/* HUD as HTML so it stays readable however small the canvas is scaled. */
.hud {
  position: absolute;
  left: 14px;
  top: 10px;
  z-index: 2;
  pointer-events: none;
  white-space: pre;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
  font-variant-numeric: tabular-nums;
}

/* ---- touch controls ---- */
.touch-layer { position: absolute; inset: 0; z-index: 1; touch-action: none; user-select: none; -webkit-user-select: none; }
.touch-zone { position: absolute; top: 0; bottom: 0; width: 50%; }
.touch-zone.left { left: 0; }
.touch-zone.right { right: 0; }
.stick-base {
  position: absolute;
  width: 112px;
  height: 112px;
  margin: -56px 0 0 -56px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.06);
  pointer-events: none;
}
.stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(76, 201, 240, 0.55);
  transform: translate(-50%, -50%);
}
.touch-buttons { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 8px; }
.touch-btn {
  min-width: 64px;
  min-height: 44px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(18, 22, 30, 0.7);
  font-weight: 600;
  touch-action: none;
}

/* ---- spectator view: the game only ---- */
/* Play mode (/play/<id>): the released game, without the making-of. */
body.play .panel, body.play .art-tier, body.play .spend, body.play .people, body.play .play-link, body.play .release-btn { display: none; }
body.play .layout { grid-template-columns: 1fr; }
body.play .rev-chip { pointer-events: none; }
.play-link { color: var(--good); text-decoration: none; font-size: 13px; border: 1px solid var(--good); border-radius: 999px; padding: 2px 10px; }
.release-btn { background: none; border: 1px solid var(--accent); color: var(--accent); border-radius: 999px; padding: 2px 10px; font-size: 13px; cursor: pointer; }
body.spectate .topbar, body.spectate .panel { display: none; }
body.spectate .layout { grid-template-columns: 1fr; }
body.spectate .stage-wrap { padding: 0; }
body.spectate .stage { border: 0; border-radius: 0; }

/* ---- feed ---- */
.people { color: var(--muted); font-size: 13px; }
.spend { font-size: 12px; font-variant-numeric: tabular-nums; border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; color: var(--muted); }
.spend.near { color: var(--warn); border-color: var(--warn); }
.spend.out { color: var(--bad); border-color: var(--bad); }
.feed .cost { font-variant-numeric: tabular-nums; }
.feed-body { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.feed { list-style: none; margin: 0; padding: 12px 16px; overflow-y: auto; flex: 1; min-height: 120px; }
.feed li { margin-bottom: 12px; }
.feed .who { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.feed .who b { color: var(--text); font-weight: 600; }
.feed .text { white-space: pre-wrap; word-break: break-word; margin-top: 2px; }
.feed li.request .bubble { border: 1px solid var(--line); border-left: 3px solid var(--accent); background: var(--panel-2); border-radius: 8px; padding: 8px 10px; }
.feed li.agent .bubble { border-left: 3px solid var(--good); padding-left: 10px; }
.feed li.system { color: var(--muted); font-size: 12px; }
.feed .status-line { font-size: 12px; color: var(--muted); margin-top: 6px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.feed .st { font-size: 11px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line); }
.feed .st.open { color: var(--warn); border-color: var(--warn); }
.feed .st.claimed, .feed .st.working { color: var(--accent); border-color: var(--accent); }
.feed .st.done { color: var(--good); border-color: var(--good); }
.feed .st.failed { color: var(--bad); border-color: var(--bad); }
.feed .st.cancelled { color: var(--muted); }
.feed .target { font-size: 12px; color: var(--warn); }
.feed .link-btn { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; padding: 0; font-size: 12px; }
.attachments { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.attachments a { display: block; }
.attachments img { width: 72px; height: 72px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); background: #000; image-rendering: pixelated; }
.attachments .file { font-size: 12px; border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; color: var(--text); text-decoration: none; }
.composer { border-top: 1px solid var(--line); padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; background: var(--panel); }
.composer.dragging { outline: 2px dashed var(--accent); outline-offset: -4px; }
.composer textarea {
  width: 100%;
  resize: vertical;
  min-height: 44px;
  max-height: 200px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}
.composer-row { display: flex; gap: 6px; align-items: center; }
.composer-row button { white-space: nowrap; flex: none; }
.composer-hint { font-size: 11px; color: var(--muted); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.feed .chat-note { margin-top: 4px; }
button.small { padding: 2px 10px; font-size: 12px; }
.composer-error { flex: 1; color: var(--bad); font-size: 12px; min-width: 0; }
.composer-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.composer-chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 999px; padding: 2px 4px 2px 8px; font-size: 12px; background: var(--panel-2); }
.chip img { width: 20px; height: 20px; object-fit: cover; border-radius: 4px; }
.chip.target { color: var(--warn); border-color: #6b5a12; }
.chip.uploading { opacity: 0.6; }
.chip button { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0 4px; font-size: 14px; line-height: 1; }
button.ghost, button.primary { border-radius: 6px; padding: 5px 10px; cursor: pointer; border: 1px solid var(--line); background: var(--panel-2); }
button.primary { background: var(--accent); color: #04131a; border-color: var(--accent); font-weight: 600; }
button:disabled { opacity: 0.5; cursor: default; }
button.mic { touch-action: none; user-select: none; -webkit-user-select: none; }
button.mic.recording { background: var(--bad); border-color: var(--bad); color: #fff; }
button.mic.busy { opacity: 0.7; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: auto minmax(320px, 1fr); }
  .hud { font-size: 12px; left: 8px; top: 6px; }
  .stage { height: auto; aspect-ratio: 1280 / 800; }
  .panel { border-left: 0; border-top: 1px solid var(--line); }
  .stage-wrap { padding: 8px; }
  .topbar { padding: 8px 12px; }
  .name-field input { width: 110px; }
}

/* ---- experiments ---- */
.experiment-bar {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100% - 32px);
  background: rgba(18, 22, 30, 0.94);
  border: 1px solid var(--line);
  border-left: 4px solid var(--warn);
  border-radius: var(--radius);
  padding: 8px 10px 8px 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
.experiment-bar[hidden] { display: none; }
.experiment-label { color: var(--warn); font-weight: 600; font-size: 13px; }
.experiment-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46ch; }
.experiment-badge { color: var(--warn); border: 1px solid var(--warn); border-radius: 999px; padding: 0 6px; font-size: 11px; }
.try-toggle { display: inline-flex; align-items: center; gap: 4px; color: var(--text); font-size: 12px; white-space: nowrap; cursor: pointer; }
.try-toggle input { margin: 0; }

/* ---- admin: games, spend, health ---- */
.admin-main h3 { margin: 20px 0 6px; font-size: 14px; color: var(--muted); font-weight: 600; }
.games-admin li.archived { opacity: 0.6; }
.tag { border: 1px solid var(--line); border-radius: 999px; padding: 0 6px; font-size: 11px; color: var(--muted); }
.tag.running { color: var(--good); border-color: #1f5f3a; }
.tag.experiment { color: var(--warn); border-color: #6b5a12; }
.tag.archived { color: var(--bad); border-color: #6b2a2a; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; font-size: 14px; }
.kv .k { color: var(--muted); }
.bars { list-style: none; margin: 0; padding: 0; }
.bars li { display: grid; grid-template-columns: minmax(120px, 200px) 1fr 80px; gap: 10px; align-items: center; padding: 4px 0; }
.bars .bar { height: 8px; background: var(--accent); border-radius: 4px; }
.bars .v { text-align: right; font-variant-numeric: tabular-nums; }
.admin-list.compact li { grid-template-columns: minmax(140px, 1fr) 3fr auto; padding: 6px 0; }
.admin-list .good { color: var(--good); }
.admin-list .bad, .fine.bad, div.bad { color: var(--bad); }
.problems li.error, .problems li.fatal { border-left: 3px solid var(--bad); padding-left: 8px; }
.problems li.warn { border-left: 3px solid var(--warn); padding-left: 8px; }
.budget-form { gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }

/* ---- admin: contributions ---- */
.contributions pre { background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 8px; overflow: auto; max-height: 360px; font-size: 12px; white-space: pre; }
.contributions li.declined { opacity: 0.6; }
.tag.proposed { color: var(--warn); border-color: #6b5a12; }
.tag.accepted { color: var(--good); border-color: #1f5f3a; }
.tag.declined { color: var(--muted); }

/* ---- feed: queue and timers ---- */
.feed .st.waiting { color: var(--warn); border-color: var(--warn); border-style: dashed; }
.feed .timer { font-variant-numeric: tabular-nums; color: var(--accent); }
.feed .timer.stalled { color: var(--warn); }

/* ---- feed: engine requests ---- */
.feed .engine-badge { color: #c084fc; border: 1px solid #7e22ce; border-radius: 999px; padding: 0 6px; font-size: 11px; }
.feed .st.approval { color: #c084fc; border-color: #7e22ce; }
.feed .link-btn.jump { font-size: 12px; }
.feed li.flash .bubble { outline: 2px solid var(--accent); transition: outline-color 1s; }

/* ---- feed: engine work progress ---- */
.feed .steps { display: flex; flex-wrap: wrap; gap: 4px; list-style: none; margin: 4px 0 0; padding: 0; width: 100%; font-size: 11px; }
.feed .steps li { padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.feed .steps li.done { color: var(--good); border-color: #1f5f3a; }
.feed .steps li.done::before { content: '✓ '; }
.feed .steps li.current { color: #c084fc; border-color: #7e22ce; font-weight: 600; }
.feed .steps li.failed { color: var(--bad); border-color: var(--bad); }
.feed .engine-echo { width: 100%; margin-top: 4px; padding: 4px 8px; border-left: 2px solid #7e22ce; font-size: 12px; color: var(--muted); }
.feed .engine-echo .echo-text { color: var(--text); margin-top: 2px; }

/* ---- connection lost ---- */
.stage.disconnected canvas { filter: grayscale(0.8) brightness(0.6); }
/* Play mode: the room picker and a match room's lobby. */
.room-picker { position: absolute; inset: 0; z-index: 6; display: flex; align-items: center; justify-content: center; background: rgba(11, 13, 18, 0.88); overflow: auto; padding: 16px; }
.room-picker[hidden], .lobby-panel[hidden] { display: none; }
.picker-card { width: min(520px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.picker-card h2 { margin: 0; font-size: 18px; }
.picker-card h3 { margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.picker-card input:not([type="checkbox"]), .picker-card select { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; color: var(--text); font: inherit; }
.picker-card #codeInput { text-transform: uppercase; letter-spacing: 2px; width: 9em; }
.lobby-panel { position: absolute; top: 12px; right: 12px; z-index: 5; width: min(260px, calc(100% - 24px)); background: rgba(18, 22, 30, 0.94); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--radius); padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.lobby-panel ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.lobby-panel li { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.lobby-panel code { font-size: 14px; letter-spacing: 2px; }
.conn-overlay { position: absolute; inset: 0; z-index: 4; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.conn-overlay[hidden] { display: none; }
.conn-overlay span { background: rgba(18, 22, 30, 0.94); border: 1px solid var(--line); border-left: 4px solid var(--warn); border-radius: var(--radius); padding: 10px 16px; font-weight: 600; }

/* ---- admin: agent run tables ---- */
.runs { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
.runs th, .runs td { text-align: right; padding: 4px 8px; border-bottom: 1px solid var(--line); }
.runs th:first-child, .runs td:first-child { text-align: left; }
.runs th { color: var(--muted); font-weight: 500; }

/* ---- art level ---- */
.art-tier { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.art-tier select { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; font-size: 13px; }
.art-variants button { position: relative; }
.tier-badge { position: absolute; right: 2px; bottom: 2px; font-size: 9px; line-height: 1; padding: 2px 3px; border-radius: 4px; background: rgba(0, 0, 0, 0.7); color: var(--text); }
@media (max-width: 700px) { .art-tier span { display: none; } }

/* ---- lanes ---- */
.lane-badge { font-size: 11px; padding: 1px 6px; border-radius: 8px; border: 1px solid var(--line); color: var(--muted); }
.lane-tweak, .lane-question { color: #7fd1a8; border-color: #2f6b4f; }
.lane-art { color: #d9a7ff; border-color: #5d3f7a; }
.lane-small { color: #8fc3ff; border-color: #34567d; }

/* ---- big plan ---- */
.tabs button.needs-you::after { content: ''; display: inline-block; width: 7px; height: 7px; margin-left: 5px; border-radius: 50%; background: #ffb454; vertical-align: middle; }
.plan { display: flex; flex-direction: column; gap: 8px; padding: 4px 2px; }
.plan-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.plan-title { margin: 0; font-size: 15px; }
.plan-state { font-size: 12px; padding: 1px 7px; border-radius: 8px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.st-running, .st-approved { color: #8fc3ff; border-color: #34567d; }
.st-proposed, .st-question { color: #ffb454; border-color: #7a5a2a; }
.st-done { color: #7fd1a8; border-color: #2f6b4f; }
.st-failed, .st-cancelled { color: #ff8a80; border-color: #7a3a36; }
.plan-meta, .plan-hold { font-size: 12px; color: var(--muted); margin: 0; }
.plan-summary { margin: 0; font-size: 13px; }
.plan-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.plan-step { display: grid; grid-template-columns: auto 1fr auto auto; gap: 6px; align-items: center; font-size: 13px; padding: 4px 6px; border-radius: 6px; background: var(--panel-2); }
.plan-step .step-more { grid-column: 2 / -1; font-size: 12px; color: var(--muted); }
.plan-step .step-more p { margin: 4px 0; }
.step-running { outline: 1px solid #34567d; }
.step-running .step-mark { animation: plan-pulse 1s ease-in-out infinite; }
.step-failed .step-title { color: #ff8a80; }
.step-done .step-title { color: var(--muted); }
.step-kind { font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.kind-engine { color: #ffb454; }
.plan-questions { margin: 0; padding-left: 18px; font-size: 13px; }
.plan-q-head, .plan-failure, .plan-warn { margin: 0; font-size: 13px; }
.plan-failure, .plan-warn { color: #ffb454; }
.plan-answer { width: 100%; box-sizing: border-box; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 6px; font: inherit; font-size: 13px; }
.plan-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.plan-answers, .plan-result { font-size: 12px; color: var(--muted); }
@keyframes plan-pulse { 50% { opacity: 0.3; } }

/* ---- platform update ---- */
.update-bar { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 6; display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 8px; background: rgba(15, 23, 42, 0.92); border: 1px solid var(--line); color: var(--text); font-size: 13px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4); }
.update-bar[hidden] { display: none; }

/* ---- work sessions ---- */
.session-tabs { display: flex; gap: 4px; padding: 4px 6px; overflow-x: auto; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.session-tab { background: transparent; color: var(--muted); border: 1px solid var(--line); border-radius: 12px; padding: 2px 10px; font-size: 12px; white-space: nowrap; cursor: pointer; }
.session-tab.active { color: var(--text); background: var(--panel-2); border-color: #34567d; }
.session-tab.busy::after { content: ''; display: inline-block; width: 6px; height: 6px; margin-left: 5px; border-radius: 50%; background: #8fc3ff; vertical-align: middle; animation: plan-pulse 1s ease-in-out infinite; }
.session-more { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); border-radius: 12px; font-size: 12px; padding: 1px 6px; }
.session-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; padding: 6px 10px; border-bottom: 1px solid var(--line); font-size: 13px; flex-shrink: 0; }
.session-meta { color: var(--muted); font-size: 12px; flex: 1 1 200px; }
.session-link { font-size: 11px; }
.session-trying { flex-basis: 100%; font-size: 12px; color: #ffb454; }
.session-trying .link-btn { margin-left: 8px; }
.session-tab.trying { border-color: #7a5a2a; }

/* ---- 3D view ---- */
.stage-3d { position: absolute; display: block; }
.labels-3d { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.label-3d { position: absolute; transform: translate(-50%, -50%); font: 12px system-ui, sans-serif; color: #9aa4b2; white-space: nowrap; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8); }
