:root {
  --bg: #12151c; --panel: rgba(22, 25, 33, 0.88); --line: rgba(255, 255, 255, 0.1); --text: #eef0f4; --muted: #9aa3b2;
  --claude: #e58a6b; --codex: #2fd3ad; --gold: #f2c14e; --bad: #ff7a6e; --ok: #6fdc8c; --warn: #ffc857; --info: #8fb0ff;
  --radius: 12px; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; }
#scene { position: fixed; inset: 0; }
#scene canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.panel { position: fixed; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); backdrop-filter: blur(10px); }
h1, h2, h3 { margin: 0; font-weight: 650; }
h2 { font-size: 13px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
h2 small { text-transform: none; letter-spacing: 0; font-weight: 400; opacity: 0.8; margin-left: 6px; }
.muted { color: var(--muted); }
.spacer { flex: 1; }
button, .btn { font: inherit; color: var(--text); background: rgba(255, 255, 255, 0.07); border: 1px solid var(--line); border-radius: 8px; padding: 6px 11px; cursor: pointer; text-decoration: none; display: inline-block; white-space: nowrap; }
button:hover, .btn:hover { background: rgba(255, 255, 255, 0.14); }
button:focus-visible, .btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary { background: #3b6cf6; border-color: transparent; }
button.danger { background: rgba(255, 90, 80, 0.16); border-color: rgba(255, 110, 100, 0.5); color: #ffb3ac; }
button.small, .btn.small { padding: 3px 8px; font-size: 12px; }
input, select, textarea { font: inherit; color: var(--text); background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px; }
.pill { font-size: 12px; padding: 2px 9px; border-radius: 99px; border: 1px solid var(--line); white-space: nowrap; }
.pill.ok, .pill.delivered, .pill.passed { color: var(--ok); border-color: rgba(111, 220, 140, 0.45); }
.pill.bad, .pill.unfinished, .pill.failed, .pill.stopped { color: var(--bad); border-color: rgba(255, 122, 110, 0.5); }
.pill.building, .pill.working { color: var(--info); border-color: rgba(143, 176, 255, 0.5); }
.pill.warn, .pill.paused, .pill.queued, .pill.skipped { color: var(--warn); border-color: rgba(255, 200, 87, 0.5); }
.claude { --team: var(--claude); } .codex { --team: var(--codex); }

#topbar { top: 10px; left: 10px; right: 10px; display: flex; align-items: center; gap: 8px; padding: 8px 12px; flex-wrap: wrap; }
.brand { font-weight: 700; letter-spacing: 0.02em; margin-right: 6px; }
.challenge { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; min-width: 0; }
.challenge b { font-weight: 650; }
.chip { padding: 3px 10px; border-radius: 8px; background: rgba(255, 255, 255, 0.06); border-left: 3px solid var(--team, var(--gold)); }
.chip small { color: var(--muted); margin-right: 5px; }

#teams { top: calc(var(--top, 60px) + 20px); left: 10px; width: 300px; max-height: calc(100vh - var(--top, 60px) - 90px); overflow: auto; padding: 10px; display: grid; gap: 10px; }
.team { border: 1px solid var(--line); border-top: 3px solid var(--team); border-radius: 10px; padding: 9px 10px; }
.team header { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.team h3 { font-size: 15px; color: var(--team); }
.team .meta { color: var(--muted); font-size: 12px; margin: 4px 0 6px; }
.team .reason { color: var(--bad); font-size: 12px; margin-bottom: 6px; }
.team .actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.agent { display: grid; grid-template-columns: 10px 1fr; gap: 2px 8px; align-items: center; width: 100%; text-align: left; padding: 5px 6px; border: 0; background: none; border-radius: 7px; }
.agent:hover, .agent.selected { background: rgba(255, 255, 255, 0.08); }
.agent .dot { width: 9px; height: 9px; border-radius: 50%; background: #5b6372; }
.agent .dot.working { background: var(--team); box-shadow: 0 0 8px var(--team); } .agent .dot.paused { background: var(--warn); } .agent .dot.error { background: var(--bad); } .agent .dot.waiting { background: var(--info); }
.agent .who small { color: var(--muted); margin-left: 5px; }
.agent .act { grid-column: 2; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#inspector { top: calc(var(--top, 60px) + 20px); right: 10px; width: 340px; max-height: calc(100vh - var(--top, 60px) - 290px); overflow: auto; padding: 12px; }
#inspector h3 { font-size: 17px; } #inspector .close { float: right; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 3px 10px; margin: 10px 0; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; font-size: 12.5px; }
.list li { padding: 4px 6px; border-radius: 6px; background: rgba(255, 255, 255, 0.04); overflow-wrap: anywhere; }
.list time { color: var(--muted); margin-right: 6px; font-variant-numeric: tabular-nums; }
.tag { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; padding: 1px 5px; border-radius: 4px; background: rgba(255, 255, 255, 0.1); margin-right: 5px; }
.tag.error, .tag.tool_error, .tag.blocker, .tag.quota, .tag.stop { background: rgba(255, 110, 100, 0.3); } .tag.test, .tag.delivered { background: rgba(111, 220, 140, 0.25); } .tag.phase, .tag.lottery, .tag.judgment, .tag.control { background: rgba(242, 193, 78, 0.28); }

#feed { right: 10px; bottom: 10px; width: 430px; height: 240px; padding: 10px 12px; display: flex; flex-direction: column; }
#feed-list { list-style: none; margin: 8px 0 0; padding: 0; overflow: auto; flex: 1; display: grid; gap: 3px; align-content: start; font-size: 12.5px; }
#feed-list li { padding: 3px 6px; border-left: 3px solid var(--team, #555); background: rgba(255, 255, 255, 0.035); border-radius: 0 6px 6px 0; overflow-wrap: anywhere; }
#feed-list time { color: var(--muted); margin-right: 6px; font-variant-numeric: tabular-nums; }
#feed-list .who { color: var(--team, var(--muted)); font-weight: 600; margin-right: 5px; }

#cams { left: 50%; bottom: 10px; transform: translateX(-50%); display: flex; gap: 6px; padding: 6px; }

#lottery { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(8, 10, 14, 0.55); pointer-events: none; z-index: 5; }
#lottery[hidden] { display: none; }
.lottery-card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 22px 26px; width: min(760px, 92vw); text-align: center; backdrop-filter: blur(12px); }
.lottery-card h2 { color: var(--gold); font-size: 15px; }
.reels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 16px 0 10px; }
.reel { border: 1px solid var(--line); border-top: 4px solid var(--team, var(--gold)); border-radius: 12px; padding: 12px 8px; background: rgba(0, 0, 0, 0.3); }
.reel-label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.reel-value { display: block; font-size: 22px; font-weight: 700; min-height: 64px; line-height: 1.2; }
.reel.spinning .reel-value { opacity: 0.55; filter: blur(0.6px); } .reel.locked .reel-value { color: var(--team, var(--gold)); }

dialog { color: var(--text); background: #171a22; border: 1px solid var(--line); border-radius: 16px; padding: 0; width: min(560px, 94vw); max-height: 92vh; }
dialog.wide { width: min(1500px, 97vw); height: 94vh; }
dialog::backdrop { background: rgba(5, 6, 9, 0.7); }
.dlg { display: flex; flex-direction: column; height: 100%; max-height: 92vh; }
.dlg > header { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.dlg > header h1 { font-size: 17px; }
.dlg > .body { padding: 14px 16px; overflow: auto; flex: 1; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.site { border: 1px solid var(--line); border-top: 4px solid var(--team); border-radius: 12px; padding: 10px; min-width: 0; }
.site header { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.site h3 { color: var(--team); font-size: 16px; }
.site iframe { width: 100%; height: 46vh; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.site .none { height: 46vh; display: grid; place-items: center; border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); text-align: center; padding: 20px; }
details { margin-top: 8px; } summary { cursor: pointer; color: var(--muted); }
pre { white-space: pre-wrap; overflow-wrap: anywhere; background: rgba(0, 0, 0, 0.35); border-radius: 8px; padding: 10px; font: 12.5px/1.5 ui-monospace, Menlo, Consolas, monospace; margin: 6px 0 0; max-height: 50vh; overflow: auto; }
.checks { display: grid; gap: 4px; font-size: 13px; margin-top: 8px; }
.checks ul { margin: 2px 0 0 18px; padding: 0; color: var(--muted); }
.judge { margin-top: 14px; border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.judge table { border-collapse: collapse; margin: 8px 0; } .judge td, .judge th { padding: 3px 10px 3px 0; text-align: left; font-weight: 400; }
.judge th { color: var(--muted); font-size: 12px; } .judge input[type=number] { width: 64px; }
.judge .winner { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.judge textarea { width: 100%; min-height: 54px; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th, table.grid td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.grid th { color: var(--muted); font-weight: 500; font-size: 12px; }
.board { display: flex; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.board .card { border: 1px solid var(--line); border-left: 4px solid var(--team); border-radius: 10px; padding: 8px 14px; }
.board .card b { font-size: 22px; }
.source { display: grid; grid-template-columns: 260px 1fr; gap: 12px; height: 100%; min-height: 0; }
.source ul { list-style: none; margin: 0; padding: 0; overflow: auto; } .source li button { width: 100%; text-align: left; border: 0; background: none; padding: 4px 6px; font: 12.5px ui-monospace, Menlo, monospace; white-space: normal; overflow-wrap: anywhere; }
.source li button.active { background: rgba(255, 255, 255, 0.1); } .source pre { max-height: none; height: 100%; margin: 0; }
form.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; } form.settings label { display: grid; gap: 3px; font-size: 12.5px; color: var(--muted); }
form.settings .full { grid-column: 1 / -1; } form.settings label.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
.note { font-size: 12.5px; color: var(--muted); border-left: 3px solid var(--warn); padding: 4px 10px; margin: 10px 0; }
#toast { position: fixed; left: 50%; top: calc(var(--top, 60px) + 26px); transform: translateX(-50%); background: #2a1f1f; border: 1px solid rgba(255, 122, 110, 0.6); color: #ffd3ce; padding: 8px 14px; border-radius: 10px; z-index: 20; max-width: 80vw; }
#toast.good { background: #18261d; border-color: rgba(111, 220, 140, 0.5); color: #cdf5d6; }

@media (max-width: 1100px) {
  #teams { width: 250px; } #feed { width: 320px; height: 190px; } #inspector { width: 290px; }
}
@media (max-width: 760px) {
  #teams { top: auto; bottom: 60px; left: 10px; right: 10px; width: auto; max-height: 32vh; grid-template-columns: 1fr 1fr; }
  #feed { display: none; } #inspector { top: 120px; left: 10px; right: 10px; width: auto; max-height: 36vh; }
  .cols, .reels, form.settings, .source { grid-template-columns: 1fr; } #cams { max-width: calc(100vw - 20px); overflow-x: auto; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* phases, wildcards, blind judging */
.phases { display: inline-flex; gap: 4px; font-size: 12px; }
.phases span { padding: 2px 8px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.phases span.done { color: var(--ok); border-color: rgba(111, 220, 140, 0.4); } .phases span.now { color: #fff; background: #3b6cf6; border-color: transparent; }
.phases small { opacity: 0.75; }
.pill.waiting { color: var(--info); border-color: rgba(143, 176, 255, 0.5); }
.site.blind { --team: var(--gold); }
.wild { font-size: 13px; margin-bottom: 6px; } .pitch { margin: 0 0 8px; padding: 6px 10px; border-left: 3px solid var(--team); color: #d5d9e2; font-style: italic; font-size: 13.5px; }
.reel-value.small { font-size: 14px; min-height: 36px; font-weight: 600; } .reel-value.spinning { opacity: 0.55; filter: blur(0.6px); } .reel-value.locked { color: var(--team, var(--gold)); }
.lottery-card { width: min(900px, 94vw); }
.brand .btn { margin-left: 8px; font-weight: 400; }

[hidden] { display: none !important; }
.tag.notice { background: rgba(255, 200, 87, 0.25); }

.models details { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin-bottom: 8px; } .models summary { cursor: pointer; font-weight: 600; }
.model { padding: 8px 0; border-top: 1px solid var(--line); margin-top: 8px; display: grid; gap: 6px; } .model p { margin: 0; font-size: 12.5px; }
.model-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; } .model-head .ok { color: var(--gold); font-size: 12.5px; } .model-head .muted { font-size: 12.5px; }
.model .place { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; } .model .place label { display: grid; gap: 2px; font-size: 12px; color: var(--muted); } .model .place input { width: 110px; }
label.btn { cursor: pointer; }
.model-status { margin: 0 0 8px; padding: 8px 12px; border-radius: 8px; background: rgba(242, 193, 78, 0.14); border: 1px solid var(--gold); } .model-status.bad { background: rgba(255, 120, 110, 0.16); border-color: #ff786e; }
