:root {
  --bg: #05060f;
  --bg-2: #0b0f2a;
  --panel: rgba(10, 13, 34, 0.72);
  --panel-solid: #0b0f26;
  --line: rgba(140, 170, 255, 0.14);
  --line-strong: rgba(140, 170, 255, 0.3);
  --text: #e8ecff;
  --muted: #8d95c2;
  --cyan: #19f5ff;
  --magenta: #ff2bd6;
  --lime: #c6ff3d;
  --gold: #ffd23d;
  --amber: #ff9f1c;
  --violet: #8b5cff;
  --danger: #ff4d6d;
  --display: 'Orbitron', system-ui, sans-serif;
  --ui: 'Rajdhani', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--ui); font-size: 17px; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; color: inherit; }

#app { position: fixed; inset: 0; }

/* ------------------------------------------------------------ backgrounds */
.bg { position: absolute; inset: 0; background-size: cover; background-position: center; transition: opacity 0.8s ease, transform 8s ease; }
.bg-hero { background-image: url('../assets/img/menu-hero.jpg'); opacity: 0; transform: scale(1.06); }
.bg-arena { background-image: url('../assets/img/arena-bg.jpg'); opacity: 0; filter: brightness(0.75) saturate(1.1); }
#app[data-screen='menu'] .bg-hero, #app[data-screen='setup'] .bg-hero { opacity: 1; transform: scale(1); }
#app[data-screen='setup'] .bg-hero { filter: blur(6px) brightness(0.5); }
#app[data-screen='game'] .bg-arena, #app[data-screen='lab'] .bg-arena { opacity: 1; }
.bg-vignette { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 40%, transparent 30%, rgba(3, 4, 12, 0.85) 100%); }
.scanlines { position: absolute; inset: 0; pointer-events: none; opacity: 0.12; background: repeating-linear-gradient(0deg, rgba(0,0,0,0.6) 0 1px, transparent 1px 3px); mix-blend-mode: multiply; z-index: 50; }

/* ------------------------------------------------------------ screens */
.screen { position: absolute; inset: 0; display: none; }
#app[data-screen='menu'] #screen-menu,
#app[data-screen='setup'] #screen-setup,
#app[data-screen='game'] #screen-game,
#app[data-screen='lab'] #screen-lab { display: flex; animation: screen-in 0.45s ease both; }
@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------ buttons */
.btn { border: 1px solid var(--line-strong); background: rgba(14, 18, 44, 0.7); padding: 10px 18px; border-radius: 10px; font-family: var(--display); font-size: 13px; letter-spacing: 0.12em; font-weight: 700; transition: all 0.18s ease; backdrop-filter: blur(8px); }
.btn:hover:not(:disabled) { border-color: var(--cyan); box-shadow: 0 0 18px rgba(25, 245, 255, 0.35), inset 0 0 12px rgba(25, 245, 255, 0.12); color: #fff; }
.btn:disabled { opacity: 0.4; cursor: default; }
a.btn { display: inline-block; color: inherit; text-decoration: none; }
.btn.primary { background: linear-gradient(135deg, rgba(25,245,255,0.95), rgba(139,92,255,0.95) 55%, rgba(255,43,214,0.95)); color: #05060f; border: none; text-shadow: none; box-shadow: 0 0 24px rgba(139, 92, 255, 0.45); }
.btn.primary:hover:not(:disabled) { color: #05060f; box-shadow: 0 0 36px rgba(255, 43, 214, 0.6); transform: translateY(-1px); }
.btn.big { padding: 16px 30px; font-size: 16px; }
.btn.small { padding: 6px 10px; font-size: 11px; }
.btn.ghost { background: rgba(10, 13, 34, 0.5); }
.btn.icon { width: 38px; height: 38px; padding: 0; display: grid; place-items: center; font-size: 18px; font-family: var(--ui); }
.btn small { display: block; font-family: var(--ui); font-weight: 600; letter-spacing: 0.04em; color: var(--muted); font-size: 12px; margin-top: 2px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; backdrop-filter: blur(14px) saturate(1.2); box-shadow: 0 20px 60px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.04); }
.panel-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.panel-head h2 { margin: 0; }
.spacer { flex: 1; }
h2 { font-family: var(--display); font-size: 18px; letter-spacing: 0.2em; font-weight: 700; margin: 0 0 16px; }
.fine { color: var(--muted); font-size: 14px; line-height: 1.45; margin: 0; }

/* ------------------------------------------------------------ menu */
#screen-menu { flex-direction: column; align-items: center; justify-content: safe center; gap: clamp(14px, 2.6vh, 30px); padding: calc(var(--pc-bar, 0px) + 16px) 24px clamp(18px, 3vh, 32px); overflow: auto; }
.menu-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 14px 22px; }
.brand { text-align: center; max-width: 820px; }
.kicker { font-family: var(--mono); font-size: 12px; letter-spacing: 0.4em; color: var(--cyan); display: inline-flex; align-items: center; gap: 10px; padding: 6px 14px; border: 1px solid rgba(25,245,255,0.3); border-radius: 99px; background: rgba(25,245,255,0.06); }
.kicker .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 10px var(--cyan); animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: 0.25; } }
.title { position: relative; font-family: var(--display); font-weight: 900; font-size: clamp(44px, 8.5vw, 112px); line-height: 0.95; margin: 20px 0 14px; letter-spacing: 0.04em; color: #f4f7ff;
  text-shadow: 0 0 12px rgba(25,245,255,0.8), 0 0 40px rgba(25,245,255,0.45), 0 0 80px rgba(139,92,255,0.35); }
.title span { color: #fff; text-shadow: 0 0 12px rgba(255,43,214,0.9), 0 0 42px rgba(255,43,214,0.55), 0 0 90px rgba(255,43,214,0.35); }
.title::before, .title::after { content: attr(data-text); position: absolute; inset: 0; pointer-events: none; opacity: 0; }
.title::before { color: var(--cyan); animation: glitch 5.5s infinite steps(1); }
.title::after { color: var(--magenta); animation: glitch 5.5s 0.08s infinite steps(1); }
@keyframes glitch { 0%, 92%, 100% { opacity: 0; transform: none; clip-path: none; } 93% { opacity: 0.7; transform: translate(-4px, 1px); clip-path: inset(10% 0 60% 0); } 95% { opacity: 0.7; transform: translate(4px, -2px); clip-path: inset(55% 0 12% 0); } 97% { opacity: 0.5; transform: translate(-2px, 0); clip-path: inset(30% 0 40% 0); } }
.tag { color: #c3c9ea; font-size: 18px; line-height: 1.5; margin: 0 auto; max-width: 700px; text-shadow: 0 2px 12px rgba(0,0,0,0.9); }
.tag b { color: var(--magenta); }

.modes { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; width: min(1240px, 100%); }
.mode-card { position: relative; text-align: left; padding: 18px 18px 20px; border-radius: 16px; border: 1px solid var(--line); background: linear-gradient(160deg, rgba(16,20,52,0.82), rgba(8,10,28,0.82)); backdrop-filter: blur(10px); transition: transform 0.2s ease, border-color 0.2s, box-shadow 0.2s; overflow: hidden; }
.mode-card::before { content: ''; position: absolute; inset: 0; background: radial-gradient(circle at 50% 0%, rgba(139,92,255,0.25), transparent 60%); opacity: 0; transition: opacity 0.2s; }
.mode-card:hover { transform: translateY(-4px); border-color: rgba(255,43,214,0.6); box-shadow: 0 12px 40px rgba(255,43,214,0.25), 0 0 0 1px rgba(255,43,214,0.3); }
.mode-card:hover::before { opacity: 1; }
.mode-card.featured { border-color: rgba(255,43,214,0.45); box-shadow: 0 0 30px rgba(255,43,214,0.18); }
.mode-card.featured::after { content: 'FEATURED'; position: absolute; top: 12px; right: 12px; font-family: var(--mono); font-size: 9px; letter-spacing: 0.2em; color: var(--magenta); border: 1px solid rgba(255,43,214,0.5); border-radius: 6px; padding: 3px 6px; }
.mc-avatars { position: relative; display: flex; align-items: center; gap: 6px; height: 64px; margin-bottom: 12px; }
.mc-avatars img { width: 60px; height: 60px; border-radius: 14px; border: 1px solid var(--line-strong); background: #000; box-shadow: 0 0 18px rgba(139,92,255,0.25); }
.mc-avatars .vs { font-family: var(--display); font-size: 12px; font-weight: 900; color: var(--muted); }
.hue-amber { filter: hue-rotate(95deg) saturate(1.3); }
.mc-title { position: relative; font-family: var(--display); font-weight: 900; font-size: 17px; letter-spacing: 0.08em; margin-bottom: 6px; }
.mc-title em { font-style: normal; color: var(--magenta); font-size: 13px; margin: 0 3px; }
.mc-desc { position: relative; color: var(--muted); font-size: 14.5px; line-height: 1.35; }

.menu-actions { display: flex; gap: 12px; }
.status { font-family: var(--mono); font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-radius: 99px; background: rgba(5,6,15,0.7); border: 1px solid var(--line); }
.led { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 8px var(--gold); }
.status.ok .led { background: #3dff9a; box-shadow: 0 0 8px #3dff9a; }
.status.bad .led { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.status.warn .led { background: #ffb020; box-shadow: 0 0 8px #ffb020; }
.status b { color: var(--text); font-weight: 600; }

/* ------------------------------------------------------------ setup */
#screen-setup { align-items: safe center; justify-content: safe center; padding: calc(var(--pc-bar, 0px) + 12px) 24px 24px; overflow: auto; }
.setup { width: min(1080px, 100%); padding: 26px 28px; }
.slots { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-bottom: 22px; }
.slot { --c: var(--cyan); position: relative; display: grid; grid-template-columns: 76px 1fr; gap: 16px; padding: 16px; border-radius: 14px; background: rgba(5,7,20,0.6); border: 1px solid color-mix(in srgb, var(--c) 45%, transparent); box-shadow: inset 0 0 30px color-mix(in srgb, var(--c) 8%, transparent); }
.slot img { width: 76px; height: 76px; border-radius: 14px; background: #000; border: 1px solid color-mix(in srgb, var(--c) 60%, transparent); box-shadow: 0 0 18px color-mix(in srgb, var(--c) 35%, transparent); }
.slot-name { font-family: var(--display); font-weight: 900; letter-spacing: 0.1em; color: var(--c); text-shadow: 0 0 12px color-mix(in srgb, var(--c) 60%, transparent); font-size: 17px; }
.slot-sub { color: var(--muted); font-size: 14px; margin: 2px 0 10px; }
.slot .field { display: grid; gap: 4px; margin-top: 8px; }
.slot .field span { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.18em; color: var(--muted); }
select, input[type='number'] { background: rgba(3,4,12,0.8); border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 10px; font-family: var(--mono); font-size: 13px; color: var(--text); outline: none; width: 100%; }
select:focus, input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(25,245,255,0.15); }
.vision-blurb { font-size: 13px; color: var(--muted); line-height: 1.35; min-height: 2.7em; }
.keys { display: inline-flex; gap: 4px; flex-wrap: wrap; }
kbd { font-family: var(--mono); font-size: 11px; padding: 2px 6px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; background: rgba(255,255,255,0.04); color: var(--text); }

.opts { display: flex; flex-wrap: wrap; gap: 18px 26px; padding: 18px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.opt label { display: block; font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.2em; color: var(--muted); margin-bottom: 8px; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; background: rgba(3,4,12,0.6); }
.seg button { border: 0; background: transparent; padding: 8px 12px; font-family: var(--display); font-size: 11.5px; font-weight: 700; letter-spacing: 0.08em; color: var(--muted); transition: all 0.15s; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.seg button.on { color: #05060f; background: var(--cyan); box-shadow: 0 0 16px rgba(25,245,255,0.5); }
.seg.small button { padding: 5px 9px; font-size: 10px; }
.seed-row { display: flex; gap: 8px; }
.seed-row input { width: 120px; }
.setup-foot { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-top: 20px; }

/* ------------------------------------------------------------ game */
#screen-game { flex-direction: column; padding: 14px 18px 10px; gap: 12px; }
.hud { display: flex; align-items: stretch; gap: 12px; }
.pcard { --c: var(--cyan); flex: 1; display: flex; align-items: center; gap: 12px; padding: 8px 14px 8px 8px; border-radius: 14px; background: var(--panel); border: 1px solid color-mix(in srgb, var(--c) 40%, transparent); backdrop-filter: blur(10px); box-shadow: inset 0 0 26px color-mix(in srgb, var(--c) 8%, transparent); transition: opacity 0.3s, filter 0.3s; min-width: 0; }
.pcard.dead { opacity: 0.45; filter: grayscale(0.8); }
.pcard img { width: 52px; height: 52px; border-radius: 12px; background: #000; border: 1px solid color-mix(in srgb, var(--c) 60%, transparent); }
.pcard .who { min-width: 0; flex: 1; }
.pcard .nm { font-family: var(--display); font-weight: 900; letter-spacing: 0.1em; color: var(--c); font-size: 15px; text-shadow: 0 0 10px color-mix(in srgb, var(--c) 55%, transparent); }
.pcard .ctl { font-family: var(--mono); font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcard .nums { display: flex; gap: 18px; text-align: right; }
.pcard .num b { display: block; font-family: var(--display); font-size: 24px; font-weight: 700; line-height: 1; }
.pcard .num span { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.18em; color: var(--muted); }
.pips { display: flex; gap: 4px; margin-top: 4px; }
.pip { width: 16px; height: 5px; border-radius: 3px; background: rgba(255,255,255,0.1); }
.pip.on { background: var(--c); box-shadow: 0 0 8px var(--c); }
.hud-center { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 0 16px; min-width: 150px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); font-family: var(--mono); }
.hud-center .round { font-family: var(--display); font-weight: 700; letter-spacing: 0.2em; font-size: 13px; }
.hud-center .meta { font-size: 10.5px; color: var(--muted); letter-spacing: 0.1em; margin-top: 3px; }

.stage { flex: 1; display: flex; gap: 14px; min-height: 0; }
.board-wrap { position: relative; flex: 1; display: grid; place-items: center; min-width: 0; min-height: 0; }
#board { display: block; border-radius: 10px; }
.brains { width: 330px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
.brains:empty { display: none; }

.brain { --c: var(--magenta); padding: 14px; border-radius: 14px; background: var(--panel); border: 1px solid color-mix(in srgb, var(--c) 40%, transparent); backdrop-filter: blur(10px); font-family: var(--mono); font-size: 12px; }
.brain-head { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.brain-head img { width: 40px; height: 40px; border-radius: 10px; background: #000; border: 1px solid color-mix(in srgb, var(--c) 60%, transparent); }
.brain-head .t { font-family: var(--display); font-weight: 900; font-size: 13px; letter-spacing: 0.14em; color: var(--c); }
.brain-head .m { color: var(--muted); font-size: 10.5px; margin-top: 2px; }
.brain-state { margin-left: auto; font-size: 10px; letter-spacing: 0.15em; padding: 3px 7px; border-radius: 6px; border: 1px solid var(--line-strong); color: var(--muted); }
.brain-state.live { color: #3dff9a; border-color: rgba(61,255,154,0.45); }
.brain-state.err { color: var(--danger); border-color: rgba(255,77,109,0.5); }
.bars { display: grid; gap: 7px; }
.bar { display: grid; grid-template-columns: 50px 1fr 44px; align-items: center; gap: 8px; }
.bar .lbl { font-weight: 700; color: var(--muted); letter-spacing: 0.06em; }
.bar .trk { height: 10px; border-radius: 5px; background: rgba(255,255,255,0.06); overflow: hidden; }
.bar .fill { height: 100%; width: 0; border-radius: 5px; background: color-mix(in srgb, var(--c) 70%, #1a1f40); transition: width 0.12s ease; }
.bar .pct { text-align: right; color: var(--muted); }
.bar.chosen .lbl, .bar.chosen .pct { color: #fff; }
.bar.chosen .fill { background: var(--c); box-shadow: 0 0 10px var(--c); }
.bar.fatal .lbl { color: var(--danger); }
.bar.empty { opacity: 0.25; }
.brain-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.brain-stats div { background: rgba(3,4,12,0.55); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.brain-stats b { display: block; font-size: 14px; color: #fff; }
.brain-stats span { font-size: 9px; letter-spacing: 0.16em; color: var(--muted); }
.stream { display: flex; gap: 2px; margin-top: 10px; height: 14px; align-items: flex-end; }
.stream i { flex: 1; border-radius: 2px; background: #3a4170; }
.stream i.closer { background: #3dff9a; }
.stream i.farther { background: #ffb23d; }
.stream i.food { background: var(--lime); box-shadow: 0 0 6px var(--lime); }
.stream i.fatal { background: var(--danger); box-shadow: 0 0 6px var(--danger); }
.stream i.risky { background: #b36bff; box-shadow: 0 0 6px #b36bff; }
.stream-legend { display: flex; gap: 10px; margin-top: 5px; font-size: 9.5px; color: var(--muted); }
.stream-legend em { font-style: normal; display: inline-flex; align-items: center; gap: 4px; }
.stream-legend em::before { content: ''; width: 7px; height: 7px; border-radius: 2px; background: var(--k); }
details.prompt { margin-top: 10px; }
details.prompt summary { cursor: pointer; color: var(--muted); font-size: 10.5px; letter-spacing: 0.14em; }
details.prompt pre { margin: 8px 0 0; max-height: 260px; overflow: auto; background: rgba(0,0,0,0.5); border: 1px solid var(--line); border-radius: 8px; padding: 8px; font-size: 10.5px; line-height: 1.4; white-space: pre-wrap; word-break: break-word; color: #b9c2f0; }
.brain .err-msg { color: var(--danger); margin-top: 8px; font-size: 11px; }

.hints { display: flex; justify-content: center; gap: 22px; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.hints span { display: inline-flex; gap: 6px; align-items: center; }

/* overlays */
.overlay { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.overlay > * { pointer-events: auto; }
.count { font-family: var(--display); font-weight: 900; font-size: clamp(90px, 16vw, 200px); color: #fff; text-shadow: 0 0 30px var(--cyan), 0 0 80px var(--magenta); animation: count-pop 0.8s ease-out both; pointer-events: none !important; }
@keyframes count-pop { from { transform: scale(2.2); opacity: 0; filter: blur(8px); } 30% { opacity: 1; filter: none; } to { transform: scale(0.9); opacity: 0; } }
.card { min-width: min(520px, 90%); max-width: 720px; padding: 28px 32px; text-align: center; border-radius: 20px; background: rgba(6, 8, 24, 0.9); border: 1px solid var(--line-strong); backdrop-filter: blur(12px); box-shadow: 0 30px 80px rgba(0,0,0,0.7), 0 0 60px rgba(139,92,255,0.25); animation: card-in 0.35s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes card-in { from { transform: scale(0.9) translateY(10px); opacity: 0; } }
.card .big { font-family: var(--display); font-weight: 900; font-size: clamp(30px, 4.5vw, 52px); letter-spacing: 0.06em; margin: 4px 0 6px; }
.card .sub { color: var(--muted); font-size: 16px; margin-bottom: 18px; }
.card .actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.card table { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 12.5px; margin-top: 8px; }
.card th { color: var(--muted); font-weight: 400; font-size: 10px; letter-spacing: 0.14em; text-align: right; padding: 6px 8px; }
.card td { text-align: right; padding: 7px 8px; border-top: 1px solid var(--line); }
.card th:first-child, .card td:first-child { text-align: left; }
.loading { display: flex; flex-direction: column; align-items: center; gap: 18px; font-family: var(--mono); font-size: 13px; color: var(--muted); letter-spacing: 0.1em; }
.spinner { width: 54px; height: 54px; border-radius: 50%; border: 3px solid rgba(255,43,214,0.2); border-top-color: var(--magenta); box-shadow: 0 0 20px rgba(255,43,214,0.4); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.paused { font-family: var(--display); font-weight: 900; font-size: 44px; letter-spacing: 0.3em; text-shadow: 0 0 20px var(--cyan); }
.pause-card { display: grid; justify-items: center; gap: 14px; }
.pause-card .keys { font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em; color: var(--muted); }

/* ------------------------------------------------------------ lab */
#screen-lab { padding: calc(var(--pc-bar, 0px) + 6px) 18px 18px; }
.lab { flex: 1; display: grid; grid-template-columns: 360px 1fr; grid-template-rows: minmax(0, 1.1fr) minmax(0, 1fr); gap: 14px; min-height: 0; }
.lab-config { grid-row: 1 / span 2; padding: 20px; overflow-y: auto; }
.lab-live { padding: 14px; display: grid; grid-template-columns: 1fr 300px; grid-template-rows: auto 1fr; gap: 10px; min-height: 0; }
.lab-live-head { grid-column: 1 / span 2; display: flex; gap: 14px; align-items: center; font-family: var(--mono); font-size: 12px; }
#lab-now { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60%; }
.progress { flex: 1; height: 6px; border-radius: 3px; background: rgba(255,255,255,0.08); overflow: hidden; }
#lab-progress { height: 100%; width: 0; background: linear-gradient(90deg, var(--cyan), var(--magenta)); box-shadow: 0 0 10px var(--magenta); transition: width 0.2s; }
.lab-board-wrap { position: relative; display: grid; place-items: center; min-height: 0; }
.lab-brain .brain { height: 100%; overflow: auto; }
.lab-results { padding: 16px 18px; display: flex; flex-direction: column; min-height: 0; }
.lab-results .panel-head { margin-bottom: 10px; }
.lab-label { display: block; font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.2em; color: var(--muted); margin: 12px 0 6px; }
.checks { display: grid; gap: 4px; }
.checks label { display: flex; align-items: center; gap: 8px; padding: 3px 8px; border-radius: 8px; font-family: var(--mono); font-size: 12px; cursor: pointer; }
.checks label:hover { background: rgba(255,255,255,0.04); }
.checks label small { margin-left: auto; color: var(--muted); }
.checks input { accent-color: var(--magenta); }
.lab-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.lab-row.stack { grid-template-columns: 1fr; gap: 0; }
.lab-actions { display: flex; gap: 10px; margin-top: 16px; }
.table-wrap { overflow: auto; flex: 1; }
#lab-table { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 12px; }
#lab-table th { position: sticky; top: 0; background: var(--panel-solid); color: var(--muted); font-weight: 400; font-size: 10px; letter-spacing: 0.12em; text-align: right; padding: 8px; white-space: nowrap; }
#lab-table td { text-align: right; padding: 7px 8px; border-top: 1px solid var(--line); white-space: nowrap; }
#lab-table th:nth-child(-n+2), #lab-table td:nth-child(-n+2) { text-align: left; }
#lab-table tr.best td { color: var(--lime); }
#lab-table .meter { display: inline-block; width: 60px; height: 6px; border-radius: 3px; background: rgba(255,255,255,0.08); vertical-align: middle; margin-left: 6px; overflow: hidden; }
#lab-table .meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--cyan), var(--magenta)); }
.empty-note { color: var(--muted); font-family: var(--mono); font-size: 12px; padding: 20px 4px; }

/* ------------------------------------------------------------ dialog */
dialog { color: var(--text); padding: 26px; width: min(420px, 92vw); }
dialog::backdrop { background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); }
.sliders { display: grid; gap: 14px; margin-bottom: 20px; }
.sliders label { display: grid; grid-template-columns: 110px 1fr; align-items: center; font-family: var(--mono); font-size: 12px; letter-spacing: 0.14em; color: var(--muted); }
input[type='range'] { accent-color: var(--magenta); }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1200px) {
  .modes { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .brains { width: 280px; }
}
@media (max-width: 900px) {
  html, body { overflow: auto; }
  .modes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stage { flex-direction: column; }
  .brains { width: 100%; flex-direction: row; overflow-x: auto; }
  .brain { min-width: 280px; }
  .lab { grid-template-columns: 1fr; grid-template-rows: auto; overflow: auto; }
  .lab-config { grid-row: auto; }
  .lab-live { grid-template-columns: 1fr; min-height: 420px; }
  .hud { flex-wrap: wrap; }
}
@media (max-width: 560px) {
  .modes { grid-template-columns: 1fr; }
  .pcard .nums { gap: 10px; }
}
