:root {
  color-scheme: dark;
  --bg: #05070d;
  --bg-elevated: rgba(10, 13, 25, 0.88);
  --bg-panel: rgba(12, 16, 29, 0.94);
  --bg-soft: rgba(18, 23, 39, 0.92);
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #f5f2ec;
  --muted: #aaa5b9;
  --accent: #ffb357;
  --accent-soft: rgba(255, 179, 87, 0.16);
  --accent-faint: rgba(255, 179, 87, 0.06);
  --brand-wordmark-color: #f4efe7;
  --brand-lockup-gap: 16px;
  --brand-logo-size: 88px;
  --brand-qr-size: 88px;
  --live: #f59e0b;
  --idle: #6b7280;
  --error: #ef4444;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(248, 113, 113, 0.13), transparent 28%),
    radial-gradient(circle at top right, rgba(245, 158, 11, 0.14), transparent 22%),
    linear-gradient(180deg, #090b12 0%, #05070d 100%);
  color: var(--text);
  font-family: "IBM Plex Sans", "Avenir Next", "Segoe UI", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 120px 120px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0.05));
  pointer-events: none;
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1660px;
  margin: 0 auto;
  padding: 18px 22px 24px;
}

.topbar,
.controls,
.summary-grid,
.visual-grid,
.showdown-top-grid,
.showdown-grid {
  margin-bottom: 14px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 24px;
}

.topbar-actions {
  display: flex;
  align-items: flex-end;
  justify-self: end;
}

.hero {
  display: grid;
  gap: 0;
}

.topbar-qr {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-width: 0;
  width: var(--brand-qr-size);
  height: var(--brand-qr-size);
  padding: 4px;
  border-radius: 14px;
  box-shadow:
    0 16px 34px rgba(0, 0, 0, 0.22),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.96);
}

.topbar-qr img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-lockup {
  display: grid;
  grid-template-columns: var(--brand-logo-size) max-content var(--brand-qr-size);
  align-items: center;
  gap: var(--brand-lockup-gap);
  min-width: 0;
}

.brand-badge {
  flex: 0 0 auto;
  width: var(--brand-logo-size);
  height: var(--brand-logo-size);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.brand-badge img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 10px 22px rgba(0, 0, 0, 0.28));
}

.debug-overlay {
  position: fixed;
  inset: 14px 14px auto auto;
  z-index: 20;
  width: min(920px, calc(100vw - 28px));
  pointer-events: none;
}

.debug-panel {
  pointer-events: auto;
  background: rgba(7, 10, 18, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  backdrop-filter: blur(20px);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.36);
  overflow: hidden;
}

.debug-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.03);
}

.debug-panel-actions {
  display: grid;
  gap: 8px;
  justify-items: end;
  min-width: 0;
}

.debug-panel-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: end;
  gap: 8px;
  min-width: 0;
}

.debug-panel-field-row {
  align-items: flex-end;
  flex-wrap: nowrap;
}

.debug-panel-button-row {
  width: 100%;
}

.debug-field {
  display: grid;
  gap: 4px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.72rem;
  justify-items: start;
}

.debug-field input,
.debug-field select {
  width: 96px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(12, 16, 29, 0.78);
  color: var(--text);
  padding: 9px 10px;
  font: inherit;
}

.debug-field select {
  width: 118px;
  padding-right: 28px;
}

.debug-panel-button {
  min-width: 56px;
  padding: 9px 12px;
}

.debug-close-button {
  appearance: none;
  width: 28px;
  height: 40px;
  min-width: 28px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: rgba(245, 242, 236, 0.76);
  padding: 0;
  box-shadow: none;
  cursor: pointer;
}

.debug-close-button svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.debug-close-button:hover,
.debug-close-button:focus-visible {
  color: var(--text);
}

.debug-overlay-content {
  margin: 0;
  padding: 14px 16px 18px;
  max-height: min(74vh, 960px);
  overflow: auto;
  color: rgba(244, 239, 231, 0.96);
  font: 12px/1.45 "IBM Plex Mono", "SFMono-Regular", monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.debug-organoid-inspector-dialog {
  width: min(1080px, calc(100vw - 32px));
  max-height: min(920px, calc(100vh - 32px));
  padding: 0;
  border: 1px solid rgba(255, 179, 87, 0.24);
  border-radius: 18px;
  background: var(--bg-panel);
  color: var(--text);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.56);
}

.debug-organoid-inspector-dialog::backdrop {
  background: rgba(5, 8, 18, 0.76);
  backdrop-filter: blur(4px);
}

.debug-organoid-inspector-panel {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.debug-organoid-inspector-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.debug-organoid-inspector-heading h2 {
  margin: 4px 0 4px;
  font-size: 1.35rem;
}

#debug-organoid-inspector-canvas {
  height: min(72vh, 720px);
  min-height: 420px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  background: #101424;
  touch-action: none;
  cursor: crosshair;
}

.debug-organoid-inspector-footer {
  display: grid;
  grid-template-columns: minmax(180px, 0.35fr) minmax(0, 1fr) auto;
  align-items: end;
  gap: 12px;
}

.debug-organoid-inspector-status {
  grid-column: 1 / -1;
  min-height: 1.2em;
  margin: -2px 0 0;
  color: #86efac;
  font-size: 0.82rem;
  text-align: right;
}

.debug-organoid-inspector-status[data-tone="error"] {
  color: #fca5a5;
}

.debug-stream-visibility-dialog {
  box-sizing: border-box;
  width: min(980px, calc(100vw - 32px));
  max-height: min(860px, calc(100vh - 32px));
  overflow: hidden;
  padding: 0;
  border: 1px solid rgba(255, 179, 87, 0.24);
  border-radius: 18px;
  background: var(--bg-panel);
  color: var(--text);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.56);
}

.debug-stream-visibility-dialog::backdrop {
  background: rgba(5, 8, 18, 0.76);
  backdrop-filter: blur(4px);
}

.debug-stream-visibility-panel {
  box-sizing: border-box;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  height: min(860px, calc(100vh - 32px));
  max-height: min(860px, calc(100vh - 32px));
  overflow: hidden;
  padding: 18px;
}

html.debug-modal-scroll-lock,
body.debug-modal-scroll-lock {
  overflow: hidden;
}

.debug-stream-visibility-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.debug-stream-visibility-heading-actions {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 12px;
  min-width: 180px;
}

.debug-stream-visibility-heading h2 {
  margin: 4px 0 4px;
  font-size: 1.35rem;
}

.debug-stream-visibility-list {
  display: grid;
  gap: 8px;
  min-height: 0;
  overflow: auto;
}

.debug-stream-visibility-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.035);
}

.debug-stream-visibility-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.debug-stream-visibility-name {
  min-width: 0;
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.debug-stream-visibility-meta {
  color: var(--muted);
  font: 11px/1.35 "IBM Plex Mono", "SFMono-Regular", monospace;
  overflow-wrap: anywhere;
}

.debug-stream-visibility-empty,
.debug-stream-visibility-status {
  min-height: 1.2em;
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.debug-stream-visibility-status {
  max-width: 320px;
  padding-top: 2px;
  text-align: right;
}

.debug-stream-visibility-status[data-tone="error"] {
  color: #fca5a5;
}

.debug-organoid-inspector-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.debug-organoid-upload-field,
.debug-organoid-points-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
}

.debug-organoid-upload-field input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(12, 16, 29, 0.78);
  color: var(--text);
  padding: 8px 10px;
  font: 12px/1.4 "IBM Plex Mono", "SFMono-Regular", monospace;
}

.debug-organoid-points-field textarea {
  width: 100%;
  min-height: 46px;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(12, 16, 29, 0.78);
  color: var(--text);
  padding: 9px 10px;
  font: 12px/1.4 "IBM Plex Mono", "SFMono-Regular", monospace;
}

.brand-wordmark {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.brand-kicker {
  margin: 0;
  color: var(--muted);
  font-family: "IBM Plex Mono", "SFMono-Regular", monospace;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.brand-wordmark h1 {
  font-family: "Space Grotesk", "IBM Plex Sans", sans-serif;
  font-size: clamp(2.9rem, 5vw, 4.6rem);
  font-weight: 700;
  font-style: normal;
  font-stretch: normal;
  letter-spacing: 0;
  line-height: 0.88;
  color: var(--brand-wordmark-color);
  text-shadow: none;
  text-wrap: nowrap;
}

.brand-rule {
  display: block;
  width: 132px;
  height: 4px;
  margin-top: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 179, 87, 0.95), rgba(255, 179, 87, 0.18));
  box-shadow: 0 0 16px rgba(255, 179, 87, 0.14);
}

.eyebrow,
.panel-eyebrow,
.metric-label {
  margin: 0 0 6px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
}

h1,
h2,
strong {
  margin: 0;
  font-family: "Space Grotesk", "IBM Plex Sans", sans-serif;
}

h1 {
  font-size: clamp(2.2rem, 4vw, 3.25rem);
}

h2 {
  font-size: 1.05rem;
}

.status-cluster {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.015), transparent 38%),
    var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 20px;
  backdrop-filter: blur(18px);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.25);
}

.mode-nav {
  display: flex;
  gap: 6px;
  align-items: flex-end;
  padding: 6px 6px 0;
  border-bottom: 1px solid var(--line);
}

.mode-tab {
  appearance: none;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 14px 14px 0 0;
  background: transparent;
  color: var(--muted);
  padding: 11px 16px 10px;
  font: inherit;
  cursor: pointer;
  margin-bottom: -1px;
  transition: border-color 120ms ease, background 120ms ease, color 120ms ease, transform 120ms ease;
}

.mode-tab:hover {
  transform: translateY(-1px);
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

.mode-tab-active {
  background:
    linear-gradient(180deg, rgba(255, 179, 87, 0.18), rgba(255, 179, 87, 0.06)),
    var(--bg-elevated);
  border-color: rgba(255, 179, 87, 0.34);
  box-shadow: inset 0 1px 0 rgba(255, 219, 168, 0.08);
  color: #ffe0b0;
}

.chrome-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  width: 34px;
  height: 44px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.chrome-toggle:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.spike-chrome-toggle-icon,
.showdown-chrome-toggle-icon {
  width: 9px;
  height: 9px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform 140ms ease;
}

.spike-view-chrome-collapsed .spike-chrome-toggle-icon {
  transform: translateY(1px) rotate(-45deg);
}

.showdown-view-chrome-collapsed .showdown-chrome-toggle-icon {
  transform: translateY(1px) rotate(-45deg);
}

.controls {
  display: grid;
  gap: 16px;
  align-items: end;
  padding: 14px 16px;
}

.controls-spikes,
.controls-showdown {
  grid-template-columns: auto minmax(0, 1fr);
}

.controls-content {
  display: grid;
  gap: 16px;
  align-items: end;
  min-width: 0;
}

.controls-content-spikes {
  grid-template-columns: minmax(0, 1.8fr) minmax(150px, 0.55fr) auto auto auto auto auto;
}

.controls-content-showdown {
  grid-template-columns: minmax(0, 2.2fr) minmax(150px, 0.7fr) auto auto auto;
}

.spike-view-chrome-collapsed .controls-content-spikes,
.showdown-view-chrome-collapsed .controls-content-showdown,
.showdown-view-chrome-collapsed #showdown-score-grid,
.showdown-view-chrome-collapsed #showdown-top-grid {
  display: none;
}

.spike-view-chrome-collapsed .controls-spikes,
.showdown-view-chrome-collapsed .controls-showdown {
  display: inline-flex;
  width: auto;
  min-width: 0;
  gap: 0;
  align-items: center;
  padding: 3px;
  border-radius: 12px;
  background: rgba(12, 16, 29, 0.72);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.18);
}

.spike-view-chrome-collapsed .chrome-toggle,
.showdown-view-chrome-collapsed .chrome-toggle {
  width: 28px;
  height: 28px;
  border-color: var(--line);
  border-radius: 9px;
}

.controls-status {
  justify-content: flex-end;
  align-self: center;
}

.field {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.field span {
  color: var(--muted);
  font-size: 0.85rem;
}

.toggle-field {
  display: grid;
  grid-template-columns: auto 44px;
  grid-template-rows: auto 28px;
  column-gap: 12px;
  row-gap: 7px;
  align-items: center;
  min-width: 150px;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
}

.toggle-field > span:first-child {
  grid-column: 1 / -1;
}

.toggle-field input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-shell {
  position: relative;
  grid-column: 1 / -1;
  width: 44px;
  height: 26px;
  border: 1px solid rgba(107, 114, 128, 0.55);
  border-radius: 999px;
  background: rgba(107, 114, 128, 0.18);
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #c8c6d4;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.32);
  transition: transform 140ms ease, background 140ms ease;
}

.toggle-field input:checked + .toggle-shell {
  border-color: rgba(255, 179, 87, 0.48);
  background: rgba(255, 179, 87, 0.2);
  box-shadow: inset 0 1px 0 rgba(255, 224, 176, 0.08);
}

.toggle-field input:checked + .toggle-shell .toggle-thumb {
  transform: translateX(18px);
  background: #ffe0b0;
}

.toggle-field input:focus-visible + .toggle-shell {
  box-shadow: 0 0 0 3px rgba(255, 179, 87, 0.1);
}

.panel-visibility-field {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-self: end;
  align-items: center;
  min-width: 210px;
  margin: 0;
  padding: 0;
  border: 0;
}

.panel-visibility-field legend {
  float: left;
  padding: 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1;
}

.panel-visibility-options {
  display: grid;
  gap: 5px;
  min-width: 142px;
}

.panel-visibility-toggle {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--muted);
  cursor: pointer;
}

.panel-visibility-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.panel-visibility-label {
  min-width: 0;
  color: inherit;
  font-size: 0.84rem;
  line-height: 1;
  white-space: nowrap;
}

.panel-visibility-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  width: 38px;
  height: 21px;
  border: 1px solid rgba(107, 114, 128, 0.5);
  border-radius: 999px;
  background: rgba(107, 114, 128, 0.14);
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.panel-visibility-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #9ca3af;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.32);
  transition: transform 120ms ease, background 120ms ease;
}

.panel-visibility-toggle input:checked ~ .panel-visibility-label {
  color: #ffe0b0;
}

.panel-visibility-toggle input:checked ~ .panel-visibility-switch {
  border-color: rgba(255, 179, 87, 0.48);
  background: rgba(255, 179, 87, 0.2);
}

.panel-visibility-toggle input:checked ~ .panel-visibility-switch .panel-visibility-thumb {
  transform: translateX(17px);
  background: #ffe0b0;
}

.panel-visibility-toggle input:focus-visible ~ .panel-visibility-switch {
  box-shadow: 0 0 0 3px rgba(255, 179, 87, 0.1);
}

.panel-visibility-toggle:hover {
  color: var(--text);
}

.panel-visibility-toggle:hover .panel-visibility-switch {
  border-color: rgba(255, 255, 255, 0.22);
}

.field-stream select {
  min-width: 0;
}

.field-theme {
  min-width: 150px;
}

.select-shell {
  position: relative;
  display: block;
}

.select-shell::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 15px;
  width: 10px;
  height: 10px;
  border-right: 2px solid rgba(255, 255, 255, 0.72);
  border-bottom: 2px solid rgba(255, 255, 255, 0.72);
  transform: translateY(-68%) rotate(45deg);
  pointer-events: none;
}

select,
.button {
  appearance: none;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--bg-soft);
  color: var(--text);
  padding: 13px 15px;
  font: inherit;
  min-width: 0;
}

select {
  width: 100%;
  padding-right: 42px;
  cursor: pointer;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0)),
    var(--bg-soft);
}

.button {
  cursor: pointer;
  background: linear-gradient(180deg, rgba(255, 179, 87, 0.2), rgba(255, 179, 87, 0.08));
  border-color: rgba(255, 179, 87, 0.4);
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.button-ghost {
  background: var(--bg-soft);
  border-color: var(--line-strong);
}

select:hover {
  border-color: rgba(255, 255, 255, 0.22);
}

.select-shell:hover::after,
.select-shell:focus-within::after {
  border-color: rgba(255, 255, 255, 0.92);
}

.select-shell:focus-within select {
  border-color: rgba(255, 179, 87, 0.48);
  box-shadow: 0 0 0 3px rgba(255, 179, 87, 0.08);
  outline: none;
}

.button:hover {
  transform: translateY(-1px);
}

.showdown-help-button,
.showdown-help-close {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0)),
    var(--bg-soft);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.showdown-help-button {
  align-self: end;
  width: 45px;
  height: 45px;
  border-radius: 999px;
  color: #ffe0b0;
  font-size: 1rem;
  font-weight: 800;
}

.showdown-help-button:hover,
.showdown-help-close:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 179, 87, 0.52);
  background:
    linear-gradient(180deg, rgba(255, 179, 87, 0.18), rgba(255, 179, 87, 0.06)),
    var(--bg-soft);
}

.showdown-help-dialog {
  width: min(720px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  padding: 0;
  border: 1px solid rgba(255, 179, 87, 0.26);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 179, 87, 0.08), rgba(255, 255, 255, 0.02)),
    var(--bg-panel);
  color: var(--text);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.52);
}

.showdown-help-dialog::backdrop {
  background: rgba(5, 8, 18, 0.72);
  backdrop-filter: blur(4px);
}

.showdown-help-panel {
  display: grid;
  gap: 20px;
  padding: 24px;
}

.showdown-help-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.showdown-help-heading h2 {
  margin: 4px 0 0;
  font-size: clamp(1.5rem, 3vw, 2rem);
}

.showdown-help-close {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: var(--muted);
}

.showdown-help-content {
  display: grid;
  gap: 16px;
  overflow: auto;
}

.showdown-help-content section {
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.showdown-help-content h3 {
  margin: 0 0 8px;
  color: #ffe0b0;
  font-size: 1rem;
}

.showdown-help-content p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.summary-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric-card {
  display: grid;
  gap: 7px;
  align-content: start;
  min-height: 92px;
  padding: 14px 16px;
  background:
    radial-gradient(circle at top right, rgba(255, 179, 87, 0.08), transparent 42%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.015), transparent 45%),
    var(--bg-elevated);
}

.metric-card-wide {
  grid-column: span 2;
  background:
    radial-gradient(circle at top right, rgba(255, 179, 87, 0.12), transparent 44%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 45%),
    var(--bg-elevated);
}

.metric-card strong {
  font-size: clamp(1.1rem, 1.8vw, 1.45rem);
  line-height: 1.05;
  max-width: none;
  text-wrap: pretty;
}

#showdown-spatial-value {
  display: block;
  max-width: none;
  text-wrap: initial;
}

.visual-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1.7fr) minmax(360px, 1fr);
  align-items: stretch;
}

.visual-grid:has(> [hidden]) {
  grid-template-columns: minmax(0, 1fr);
}

.showdown-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.showdown-top-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
}

.summary-grid-showdown {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.summary-grid-showdown .metric-card {
  position: relative;
  min-height: 0;
  align-content: center;
  overflow: hidden;
  text-align: center;
}

.summary-grid-showdown .metric-card > * {
  position: relative;
  z-index: 1;
}

.summary-grid-showdown .metric-card-timer {
  --showdown-timer-fill: 100%;
  --showdown-timer-color: rgba(35, 187, 105, 0.28);
  --showdown-timer-blink-color: rgba(255, 255, 255, 0.54);
  background:
    linear-gradient(
      90deg,
      var(--showdown-timer-color) 0,
      var(--showdown-timer-color) var(--showdown-timer-fill),
      transparent var(--showdown-timer-fill),
      transparent 100%
    ),
    radial-gradient(circle at top right, rgba(255, 179, 87, 0.08), transparent 42%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.015), transparent 45%),
    var(--bg-elevated);
}

.summary-grid-showdown .metric-card-timer::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: var(--showdown-timer-blink-color);
  opacity: 0;
  pointer-events: none;
}

.summary-grid-showdown .metric-card-timer-threshold::before {
  animation: showdown-timer-threshold-blink 960ms steps(1, end);
}

@keyframes showdown-timer-threshold-blink {
  0%,
  22%,
  44% {
    opacity: 0.58;
  }

  11%,
  33%,
  55%,
  100% {
    opacity: 0;
  }
}

.panel {
  padding: 16px;
  min-height: 320px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.012), transparent 44%),
    var(--bg-panel);
}

.panel-raster {
  grid-row: span 2;
}

.visual-grid:has(> .panel-raster:not([hidden])):has(> .panel-spatial:not([hidden])) .panel-raster {
  grid-row: auto;
}

.panel-spike-cart[hidden] {
  display: none;
}

.panel-spatial,
.panel-spike-cart,
.showdown-panel-human {
  background:
    radial-gradient(circle at top right, rgba(255, 179, 87, 0.1), transparent 38%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.012), transparent 44%),
    var(--bg-panel);
}

.panel-spike-cart {
  min-height: 360px;
}

.showdown-panel {
  position: relative;
  min-height: 420px;
  overflow: hidden;
}

.showdown-organoid-activity-panel {
  min-height: 420px;
}

.showdown-organoid-activity {
  position: relative;
  display: grid;
  place-items: center;
  height: 310px;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background:
    linear-gradient(180deg, rgba(127, 211, 225, 0.28), rgba(119, 201, 60, 0.18)),
    #101424;
}

.showdown-organoid-activity-figure {
  position: relative;
  width: min(72%, 420px);
  max-height: 82%;
  aspect-ratio: 508 / 372;
}

.showdown-organoid-activity img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 20px 18px rgba(0, 0, 0, 0.24));
}

.showdown-organoid-activity-dots {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.showdown-organoid-dot {
  position: absolute;
  left: var(--dot-x);
  top: var(--dot-y);
  width: 13px;
  height: 13px;
  border-radius: 999px;
  background: #006411;
  border: 2px solid rgba(255, 249, 224, 0.92);
  opacity: var(--dot-opacity, 0.22);
  transform: translate(-50%, -50%) scale(var(--dot-scale, 0.42));
  transform-origin: center;
  box-shadow:
    0 0 0 2px rgba(23, 21, 20, 0.58),
    0 0 var(--dot-glow, 8px) rgba(0, 100, 17, 0.46);
  transition:
    transform 180ms ease,
    opacity 180ms ease,
    box-shadow 180ms ease;
}

.showdown-organoid-dot-active {
  animation: showdown-organoid-dot-pulse 620ms ease-in-out infinite;
}

@keyframes showdown-organoid-dot-pulse {
  0%,
  100% {
    transform: translate(-50%, -50%) scale(var(--dot-scale, 0.42));
    filter: saturate(1);
  }

  50% {
    transform: translate(-50%, -50%) scale(calc(var(--dot-scale, 0.42) * 1.18));
    filter: saturate(1.45) brightness(1.12);
  }
}

.showdown-human-input-panel {
  min-height: 420px;
}

.showdown-human-portrait {
  position: relative;
  display: grid;
  place-items: center;
  height: 310px;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background:
    linear-gradient(180deg, rgba(127, 211, 225, 0.28), rgba(119, 201, 60, 0.18)),
    #101424;
}

.showdown-human-portrait-figure {
  position: relative;
  width: min(86%, 400px);
  max-height: 94%;
  aspect-ratio: 400 / 340;
  transform: translateX(0);
}

.showdown-human-portrait img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 20px 18px rgba(0, 0, 0, 0.26));
}

.showdown-hand-dot {
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #006411;
  border: 3px solid rgba(255, 249, 224, 0.94);
  box-shadow:
    0 0 0 3px rgba(23, 21, 20, 0.74),
    0 0 22px rgba(0, 100, 17, 0.24);
  opacity: 0.34;
  transform: translate(-50%, -50%) scale(0.72);
  transition:
    opacity 140ms ease,
    transform 140ms ease,
    box-shadow 140ms ease;
}

.showdown-hand-dot-left {
  left: 18%;
  top: 37%;
}

.showdown-hand-dot-right {
  left: 83%;
  top: 64%;
}

.showdown-human-input-left .showdown-hand-dot-left,
.showdown-human-input-right .showdown-hand-dot-right {
  opacity: 1;
  animation: showdown-hand-pulse 520ms ease-in-out infinite;
  box-shadow:
    0 0 0 3px rgba(23, 21, 20, 0.82),
    0 0 0 9px rgba(119, 201, 60, 0.18),
    0 0 28px rgba(0, 100, 17, 0.58);
}

.showdown-human-bump-left .showdown-human-portrait-figure {
  animation: showdown-human-bump-left 320ms cubic-bezier(0.22, 0.9, 0.28, 1);
}

.showdown-human-bump-right .showdown-human-portrait-figure {
  animation: showdown-human-bump-right 320ms cubic-bezier(0.22, 0.9, 0.28, 1);
}

@keyframes showdown-human-bump-left {
  0% {
    transform: translateX(0);
  }

  34% {
    transform: translateX(-10px);
  }

  64% {
    transform: translateX(-5px);
  }

  100% {
    transform: translateX(0);
  }
}

@keyframes showdown-human-bump-right {
  0% {
    transform: translateX(0);
  }

  34% {
    transform: translateX(10px);
  }

  64% {
    transform: translateX(5px);
  }

  100% {
    transform: translateX(0);
  }
}

@keyframes showdown-hand-pulse {
  0%,
  100% {
    transform: translate(-50%, -50%) scale(0.94);
  }

  50% {
    transform: translate(-50%, -50%) scale(1.42);
  }
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 12px;
}

.panel-detail {
  margin: 4px 0 0;
  color: rgba(245, 242, 236, 0.72);
  font-size: 0.82rem;
  line-height: 1.35;
}

.panel-heading > .mono {
  max-width: 44%;
}

.panel-heading-meta {
  display: grid;
  gap: 3px;
  justify-items: end;
}

.panel-heading-meta .panel-detail {
  margin: 0;
  text-align: right;
}

.spatial-heading-meta {
  grid-template-columns: auto auto;
  align-items: center;
  gap: 8px 12px;
}

.spatial-zoom-control {
  display: grid;
  grid-template-columns: 26px 26px 48px 26px;
  align-items: center;
  justify-content: end;
  gap: 4px;
  grid-column: 1;
  grid-row: 1;
  color: var(--muted);
}

.spatial-zoom-button,
.spatial-pan-toggle-button {
  width: 26px;
  height: 24px;
  border: 1px solid rgba(255, 179, 87, 0.32);
  border-radius: 8px;
  background: rgba(255, 179, 87, 0.12);
  color: #ffe0b0;
  font: 700 0.9rem/1 "Inter", system-ui, sans-serif;
  cursor: pointer;
}

.spatial-pan-toggle-button {
  display: grid;
  place-items: center;
}

.spatial-pan-toggle-button svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.spatial-pan-toggle-active {
  border-color: rgba(255, 224, 176, 0.72);
  background: rgba(255, 179, 87, 0.28);
  color: #fff4da;
  box-shadow: 0 0 0 2px rgba(255, 179, 87, 0.1);
}

.spatial-zoom-button:disabled,
.spatial-pan-toggle-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.spatial-zoom-button:focus-visible,
.spatial-pan-toggle-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 179, 87, 0.12);
}

.spatial-zoom-value {
  min-width: 48px;
  color: rgba(245, 242, 236, 0.76);
  font: 600 0.72rem/1 "IBM Plex Mono", "SFMono-Regular", monospace;
  text-align: center;
}

.spatial-zoom-value-disabled {
  color: rgba(148, 163, 184, 0.42);
}

.spatial-box-toggle {
  display: grid;
  grid-template-columns: auto 36px;
  align-items: center;
  gap: 8px;
  grid-column: 2;
  color: var(--muted);
  font-size: 0.75rem;
  cursor: pointer;
}

.spatial-heading-meta .spatial-box-toggle:first-of-type {
  grid-row: 1;
}

.spatial-heading-meta .spatial-box-toggle:last-of-type {
  grid-row: 2;
}

.spatial-box-toggle:has(input:disabled) {
  cursor: not-allowed;
  opacity: 0.48;
}

.spatial-box-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.spatial-box-toggle-shell {
  position: relative;
  width: 36px;
  height: 22px;
  border: 1px solid rgba(107, 114, 128, 0.55);
  border-radius: 999px;
  background: rgba(107, 114, 128, 0.18);
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.spatial-box-toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #c8c6d4;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.32);
  transition: transform 140ms ease, background 140ms ease;
}

.spatial-box-toggle input:checked + .spatial-box-toggle-shell {
  border-color: rgba(255, 179, 87, 0.48);
  background: rgba(255, 179, 87, 0.2);
}

.spatial-box-toggle input:checked + .spatial-box-toggle-shell .spatial-box-toggle-thumb {
  transform: translateX(14px);
  background: #ffe0b0;
}

.spatial-box-toggle input:focus-visible + .spatial-box-toggle-shell {
  box-shadow: 0 0 0 3px rgba(255, 179, 87, 0.1);
}

canvas {
  width: 100%;
  height: 290px;
  display: block;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.015), transparent 36%),
    #090b14;
}

.panel-spatial canvas {
  border-color: rgba(255, 255, 255, 0.12);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 36%),
    #101424;
}

.panel-spatial canvas.spatial-pan-enabled {
  cursor: grab;
  touch-action: none;
}

.panel-spatial canvas.spatial-pan-dragging {
  cursor: grabbing;
}

.raster-plot-shell {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 4px;
  align-items: stretch;
}

.raster-annotation-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 4px;
  margin-bottom: 4px;
}

.raster-annotation-row[hidden] {
  display: none;
}

.raster-annotation-strip {
  position: relative;
  height: 42px;
  min-width: 0;
  overflow: hidden;
}

.raster-annotation-baseline {
  position: absolute;
  top: 21px;
  height: 1px;
  background: rgba(255, 255, 255, 0.09);
}

.raster-annotation-label {
  position: absolute;
  display: inline-flex;
  align-items: center;
  font-family: "IBM Plex Sans", "Avenir Next", "Segoe UI", sans-serif;
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  color: rgba(245, 242, 236, 0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.raster-annotation-event-pin {
  position: absolute;
  top: 16px;
  width: 3px;
  height: 14px;
  background: currentColor;
  transform: translateX(-50%);
  box-shadow: 0 0 0 1px rgba(9, 11, 20, 0.62);
}

.raster-annotation-event-pin::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -4px;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: currentColor;
  transform: translateX(-50%);
  box-shadow: 0 0 0 2px rgba(9, 11, 20, 0.82);
}

.raster-annotation-label-event {
  height: 12px;
  padding-left: 7px;
  color: rgba(245, 242, 236, 0.9);
}

.raster-annotation-label-event::before {
  content: "";
  position: absolute;
  left: 0;
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: var(--annotation-color, currentColor);
}

.raster-annotation-window-bar {
  position: absolute;
  box-sizing: border-box;
  height: 13px;
  min-width: 2px;
  border-radius: 3px;
  border: 1px solid currentColor;
  background: color-mix(in srgb, currentColor 28%, rgba(9, 11, 20, 0.72));
}

.raster-annotation-label-window {
  box-sizing: border-box;
  justify-content: center;
  height: 12px;
  padding: 0 4px;
  color: rgba(245, 242, 236, 0.92);
  overflow: visible;
  text-overflow: clip;
}

.raster-y-axis {
  position: relative;
  min-width: 0;
  height: 620px;
  color: rgba(233, 226, 214, 0.82);
  font-family: "IBM Plex Sans", "Avenir Next", "Segoe UI", sans-serif;
  font-size: 10px;
  overflow: visible;
}

.raster-y-axis-label {
  position: absolute;
  left: -20px;
  color: rgba(255, 211, 126, 0.88);
  font-size: 21px;
  font-weight: 700;
  line-height: 1;
  transform: translateY(-50%) rotate(-90deg);
  transform-origin: center;
  white-space: nowrap;
}

.raster-y-axis-tick {
  position: absolute;
  right: 0;
  display: flex;
  gap: 3px;
  align-items: center;
  transform: translateY(-50%);
  white-space: nowrap;
}

.raster-y-axis-tick span {
  min-width: 13px;
  text-align: right;
}

.raster-y-axis-tick::after {
  content: "";
  width: 4px;
  height: 1px;
  background: rgba(255, 211, 126, 0.58);
}

.panel-raster canvas {
  height: 620px;
}

.visual-grid .panel-spatial canvas {
  height: 620px;
}

.showdown-panel canvas {
  height: 310px;
}

#spike-cart-canvas {
  height: 260px;
}

.spike-cart-stats {
  margin-top: 10px;
}

#showdown-human-canvas {
  touch-action: none;
}

.showdown-mobile-input-hint {
  display: none;
}

.showdown-panel-human::before,
.showdown-panel-human::after {
  content: "";
  position: absolute;
  top: 68px;
  bottom: 64px;
  width: 48%;
  pointer-events: none;
  opacity: 0;
  z-index: 1;
}

.showdown-panel-human::before {
  left: 16px;
  background:
    linear-gradient(90deg, rgba(255, 179, 87, 0.34), rgba(255, 179, 87, 0)),
    linear-gradient(90deg, rgba(255, 244, 218, 0.16), transparent 58%);
}

.showdown-panel-human::after {
  right: 16px;
  background:
    linear-gradient(270deg, rgba(255, 179, 87, 0.34), rgba(255, 179, 87, 0)),
    linear-gradient(270deg, rgba(255, 244, 218, 0.16), transparent 58%);
}

.showdown-human-tap-left::before,
.showdown-human-tap-right::after {
  animation: showdown-human-tap-edge 220ms ease-out;
}

.showdown-human-tap-left .showdown-mobile-input-zone-left,
.showdown-human-tap-right .showdown-mobile-input-zone-right {
  animation: showdown-human-tap-chevron 220ms ease-out;
}

@keyframes showdown-human-tap-edge {
  0% {
    opacity: 0;
  }

  24% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

@keyframes showdown-human-tap-chevron {
  0% {
    opacity: 0.72;
    transform: scale(0.98);
  }

  35% {
    opacity: 1;
    transform: scale(1.03);
  }

  100% {
    opacity: 0;
    transform: scale(1);
  }
}

.showdown-panel-winner {
  border-color: rgba(255, 179, 87, 0.44);
  box-shadow:
    inset 0 0 0 1px rgba(255, 208, 141, 0.14),
    0 18px 48px rgba(245, 158, 11, 0.12);
}

.showdown-panel-loser {
  border-color: rgba(239, 68, 68, 0.18);
}

.showdown-overlay {
  position: absolute;
  inset: 68px 16px 64px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 8px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(5, 7, 13, 0.12), rgba(5, 7, 13, 0.52));
  pointer-events: none;
  text-align: center;
  z-index: 2;
}

.showdown-overlay[hidden],
.showdown-start-button[hidden] {
  display: none;
}

.showdown-overlay-start {
  pointer-events: auto;
}

.showdown-overlay-start .showdown-start-button {
  position: absolute;
  bottom: 25%;
  margin: 0;
  transform: translateY(50%);
}

.showdown-overlay strong {
  font-size: clamp(2rem, 5vw, 3.6rem);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff4da;
  text-shadow: 0 6px 28px rgba(0, 0, 0, 0.42);
}

.showdown-overlay span {
  font-family: "IBM Plex Mono", "SFMono-Regular", monospace;
  font-size: 0.98rem;
  color: rgba(255, 244, 218, 0.88);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.showdown-overlay-countdown strong {
  font-size: clamp(3rem, 9vw, 6rem);
}

.showdown-overlay-waiting strong {
  max-width: 82%;
  font-size: clamp(1.35rem, 3vw, 2.3rem);
  line-height: 1.08;
}

.showdown-start-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
  border: 1px solid rgba(255, 224, 176, 0.48);
  border-radius: 999px;
  background: rgba(255, 179, 87, 0.14);
  color: #fff4da;
  padding: 12px 18px;
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.24);
}

.showdown-start-button:hover {
  border-color: rgba(255, 244, 218, 0.78);
  background: rgba(255, 179, 87, 0.28);
}

.showdown-play-icon {
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 12px solid currentColor;
}

.showdown-stats {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.showdown-stats {
  margin-top: 12px;
}

.showdown-stats .mono:first-child {
  min-width: 0;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.showdown-stats .mono:last-child {
  text-align: right;
  white-space: nowrap;
}

.pill,
.mono {
  font-family: "IBM Plex Mono", "SFMono-Regular", monospace;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-size: 0.85rem;
}

.pill-live {
  border-color: rgba(245, 158, 11, 0.4);
  color: #ffd37e;
  background: rgba(245, 158, 11, 0.14);
}

.pill-warmup {
  border-color: rgba(107, 114, 128, 0.4);
  color: #c8c6d4;
  background: rgba(107, 114, 128, 0.12);
}

.pill-locked {
  border-color: rgba(255, 179, 87, 0.42);
  color: #ffe0b0;
  background: rgba(255, 179, 87, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 224, 176, 0.08);
}

.pill-off {
  border-color: rgba(148, 163, 184, 0.36);
  color: #d4d9e5;
  background: rgba(148, 163, 184, 0.12);
}

.pill-idle {
  color: #c8c6d4;
}

.pill-error {
  border-color: rgba(239, 68, 68, 0.4);
  color: #fecaca;
  background: rgba(239, 68, 68, 0.14);
}

.mono {
  color: var(--muted);
  font-size: 0.77rem;
  line-height: 1.4;
  text-align: right;
}

body.showdown-theme-atari {
  --brand-wordmark-color: #111820;
  background:
    radial-gradient(ellipse at 24% 18%, rgba(255, 252, 210, 0.72) 0 7%, transparent 8%),
    linear-gradient(180deg, #34afd6 0%, #7ed1df 58%, #74c942 58%, #5cae25 100%);
  background-attachment: fixed;
}

body.showdown-theme-atari::before {
  background:
    radial-gradient(ellipse at 14% 29%, rgba(255, 252, 218, 0.86) 0 5%, transparent 5.4%),
    radial-gradient(ellipse at 19% 31%, rgba(255, 252, 218, 0.9) 0 6.5%, transparent 6.9%),
    radial-gradient(ellipse at 24% 29%, rgba(255, 252, 218, 0.86) 0 5%, transparent 5.4%),
    radial-gradient(ellipse at 68% 18%, rgba(255, 252, 218, 0.76) 0 4.4%, transparent 4.8%),
    radial-gradient(ellipse at 73% 19%, rgba(255, 252, 218, 0.82) 0 5.8%, transparent 6.2%),
    linear-gradient(180deg, transparent 0 58%, rgba(255, 252, 218, 0.16) 58.2% 58.8%, transparent 59%),
    linear-gradient(180deg, transparent 0 70%, rgba(40, 114, 30, 0.16) 70.2% 70.6%, transparent 71%);
  mask-image: none;
  opacity: 0.76;
}

body.showdown-theme-atari #showdown-view {
  --bg-panel: rgba(255, 249, 224, 0.76);
  --bg-soft: rgba(255, 246, 211, 0.82);
  --bg-elevated: rgba(255, 252, 230, 0.88);
  --line: rgba(42, 32, 24, 0.26);
  --line-strong: rgba(37, 28, 22, 0.56);
  --text: #111820;
  --muted: #285462;
  --accent: #e74426;
  --accent-soft: rgba(231, 68, 38, 0.2);
  --accent-faint: rgba(255, 203, 54, 0.18);
  color: #111820;
}

body.showdown-theme-atari .mode-nav {
  border-bottom-color: rgba(23, 21, 20, 0.46);
}

body.showdown-theme-atari .mode-tab {
  color: #1d3f4d;
  text-shadow: 0 1px 0 rgba(255, 252, 230, 0.58);
}

body.showdown-theme-atari .mode-tab:hover {
  color: #111820;
  background: rgba(255, 252, 230, 0.52);
}

body.showdown-theme-atari .mode-tab-active {
  background:
    linear-gradient(180deg, rgba(255, 245, 200, 0.96), rgba(255, 204, 48, 0.86));
  border-color: rgba(23, 21, 20, 0.72);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.56),
    0 4px 0 rgba(23, 21, 20, 0.18);
  color: #111820;
}

body.showdown-theme-atari #showdown-view select {
  border: 2px solid rgba(23, 21, 20, 0.68);
  background:
    linear-gradient(180deg, rgba(255, 253, 236, 0.95), rgba(255, 244, 206, 0.88));
  color: #111820;
  box-shadow: 0 4px 0 rgba(23, 21, 20, 0.14);
}

body.showdown-theme-atari #showdown-view select:hover {
  border-color: rgba(23, 21, 20, 0.86);
  background:
    linear-gradient(180deg, rgba(255, 255, 244, 0.98), rgba(255, 238, 177, 0.9));
}

body.showdown-theme-atari #showdown-view .select-shell::after {
  border-color: rgba(17, 24, 32, 0.78);
}

body.showdown-theme-atari #showdown-view .select-shell:hover::after,
body.showdown-theme-atari #showdown-view .select-shell:focus-within::after {
  border-color: rgba(17, 24, 32, 0.96);
}

body.showdown-theme-atari #showdown-view .select-shell:focus-within select {
  border-color: rgba(231, 68, 38, 0.82);
  box-shadow:
    0 0 0 3px rgba(231, 68, 38, 0.16),
    0 4px 0 rgba(23, 21, 20, 0.14);
}

body.showdown-theme-atari .controls-showdown,
body.showdown-theme-atari .showdown-organoid-activity-panel,
body.showdown-theme-atari .showdown-human-input-panel,
body.showdown-theme-atari .summary-grid-showdown .metric-card,
body.showdown-theme-atari .showdown-panel {
  border: 3px solid rgba(23, 21, 20, 0.82);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 253, 236, 0.88), rgba(255, 241, 203, 0.76)),
    rgba(255, 249, 224, 0.78);
  box-shadow:
    0 8px 0 rgba(21, 23, 24, 0.16),
    0 18px 38px rgba(10, 28, 34, 0.18);
  backdrop-filter: blur(8px) saturate(1.1);
}

body.showdown-theme-atari .showdown-panel-human {
  background:
    linear-gradient(180deg, rgba(236, 248, 255, 0.9), rgba(219, 239, 255, 0.76)),
    rgba(236, 248, 255, 0.78);
}

body.showdown-theme-atari .summary-grid-showdown .metric-card-timer {
  background:
    linear-gradient(
      90deg,
      var(--showdown-timer-color) 0,
      var(--showdown-timer-color) var(--showdown-timer-fill),
      transparent var(--showdown-timer-fill),
      transparent 100%
    ),
    linear-gradient(180deg, rgba(255, 253, 236, 0.88), rgba(255, 241, 203, 0.76)),
    rgba(255, 249, 224, 0.78);
}

body.showdown-theme-atari .showdown-help-button,
body.showdown-theme-atari #showdown-view .button {
  border: 2px solid rgba(23, 21, 20, 0.78);
  background: #ffcf30;
  color: #111820;
  box-shadow: 0 4px 0 rgba(23, 21, 20, 0.24);
}

body.showdown-theme-atari .showdown-help-dialog {
  border: 3px solid rgba(23, 21, 20, 0.82);
  background:
    linear-gradient(180deg, rgba(255, 246, 211, 0.98), rgba(242, 224, 178, 0.98)),
    #fff1c7;
  color: #111820;
  box-shadow:
    0 8px 0 rgba(21, 23, 24, 0.22),
    0 28px 90px rgba(0, 0, 0, 0.58);
}

body.showdown-theme-atari .showdown-help-dialog::backdrop {
  background: rgba(7, 10, 14, 0.76);
  backdrop-filter: blur(3px) saturate(0.82);
}

body.showdown-theme-atari .showdown-help-heading h2 {
  color: #111820;
  text-shadow: none;
}

body.showdown-theme-atari .showdown-help-close {
  border: 2px solid rgba(23, 21, 20, 0.72);
  background: rgba(255, 244, 206, 0.92);
  color: #16485b;
  box-shadow: 0 3px 0 rgba(23, 21, 20, 0.18);
}

body.showdown-theme-atari .showdown-help-content section {
  border-top-color: rgba(23, 21, 20, 0.28);
}

body.showdown-theme-atari .showdown-help-content h3 {
  color: #9d391f;
}

body.showdown-theme-atari .showdown-help-content p {
  color: #16485b;
}

body.showdown-theme-atari .button-ghost {
  background: rgba(255, 255, 255, 0.62);
}

body.showdown-theme-atari .debug-panel .debug-panel-button {
  color: #111820;
}

body.showdown-theme-atari .summary-grid-showdown .metric-card strong,
body.showdown-theme-atari .showdown-panel h2,
body.showdown-theme-atari .showdown-organoid-activity-panel h2,
body.showdown-theme-atari .showdown-human-input-panel h2 {
  color: #111820;
  text-shadow: none;
}

body.showdown-theme-atari .summary-grid-showdown .metric-card:nth-child(1) strong {
  color: #e42b18;
}

body.showdown-theme-atari .summary-grid-showdown .metric-card:nth-child(3) strong {
  color: #1b57f2;
}

body.showdown-theme-atari #showdown-view .panel-eyebrow,
body.showdown-theme-atari #showdown-view .metric-label {
  color: #8b351b;
}

body.showdown-theme-atari #showdown-view .mono {
  color: #264a57;
}

body.showdown-theme-atari .showdown-panel canvas,
body.showdown-theme-atari .showdown-organoid-activity,
body.showdown-theme-atari .showdown-human-portrait {
  border: 3px solid rgba(23, 21, 20, 0.88);
  border-radius: 6px;
  background: #7ed1df;
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.16),
    0 5px 0 rgba(23, 21, 20, 0.18);
}

body.showdown-theme-atari .showdown-human-portrait {
  background:
    linear-gradient(180deg, #2aa9d1 0%, #7fd3e1 62%, #77c93c 62%, #77c93c 100%);
}

body.showdown-theme-atari .showdown-organoid-activity {
  background:
    linear-gradient(180deg, #2aa9d1 0%, #7fd3e1 72%, #77c93c 72%, #77c93c 100%);
}

body.showdown-theme-atari .showdown-panel-winner {
  border-color: rgba(31, 124, 40, 0.95);
  box-shadow:
    0 8px 0 rgba(31, 124, 40, 0.2),
    0 18px 38px rgba(10, 28, 34, 0.18);
}

body.showdown-theme-atari .showdown-panel-loser {
  border-color: rgba(174, 46, 28, 0.88);
}

body.showdown-theme-atari .showdown-panel-human::before {
  background:
    linear-gradient(90deg, rgba(255, 207, 48, 0.52), rgba(255, 207, 48, 0)),
    linear-gradient(90deg, rgba(17, 24, 32, 0.12), transparent 60%);
}

body.showdown-theme-atari .showdown-panel-human::after {
  background:
    linear-gradient(270deg, rgba(255, 207, 48, 0.52), rgba(255, 207, 48, 0)),
    linear-gradient(270deg, rgba(17, 24, 32, 0.12), transparent 60%);
}

body.showdown-theme-atari .showdown-overlay {
  background: rgba(52, 175, 214, 0.24);
}

body.showdown-theme-atari .showdown-overlay strong {
  color: #111820;
  -webkit-text-stroke: 1px rgba(255, 247, 213, 0.9);
  text-shadow: 0 4px 0 rgba(23, 21, 20, 0.2);
}

body.showdown-theme-atari .showdown-overlay span {
  color: #111820;
}

body.showdown-theme-atari .showdown-start-button {
  border: 3px solid rgba(23, 21, 20, 0.84);
  background: rgba(255, 207, 48, 0.86);
  color: #111820;
  box-shadow: 0 6px 0 rgba(23, 21, 20, 0.24);
}

body.showdown-theme-atari .showdown-start-button:hover {
  border-color: rgba(23, 21, 20, 0.9);
  background: #ffe16f;
}

@media (pointer: coarse), (any-pointer: coarse) {
  .showdown-mobile-input-hint {
    position: absolute;
    inset: 68px 16px 64px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: hidden;
    border-radius: 14px;
    pointer-events: none;
    z-index: 1;
  }

  .showdown-mobile-input-hint[hidden] {
    display: none;
  }

  .showdown-mobile-input-zone {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    padding: 0 18px;
    color: rgba(255, 244, 218, 0.88);
    font-family: "IBM Plex Mono", "SFMono-Regular", monospace;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.42);
  }

  .showdown-mobile-input-zone-left {
    justify-content: flex-start;
    background: linear-gradient(90deg, rgba(255, 179, 87, 0.18), rgba(255, 179, 87, 0.02));
  }

  .showdown-mobile-input-zone-right {
    justify-content: flex-end;
    background: linear-gradient(270deg, rgba(255, 179, 87, 0.18), rgba(255, 179, 87, 0.02));
  }

  .showdown-mobile-input-chevron {
    width: 18px;
    height: 18px;
    border-top: 3px solid currentColor;
    border-left: 3px solid currentColor;
    filter: drop-shadow(0 2px 10px rgba(0, 0, 0, 0.36));
  }

  .showdown-mobile-input-zone-left .showdown-mobile-input-chevron {
    transform: rotate(-45deg);
  }

  .showdown-mobile-input-zone-right .showdown-mobile-input-chevron {
    transform: rotate(135deg);
  }

  body.showdown-theme-atari .showdown-mobile-input-zone {
    color: #111820;
    text-shadow: 0 1px 0 rgba(255, 252, 230, 0.52);
  }

  body.showdown-theme-atari .showdown-mobile-input-zone-left {
    background: linear-gradient(90deg, rgba(255, 207, 48, 0.42), rgba(255, 207, 48, 0.04));
  }

  body.showdown-theme-atari .showdown-mobile-input-zone-right {
    background: linear-gradient(270deg, rgba(255, 207, 48, 0.42), rgba(255, 207, 48, 0.04));
  }
}

@media (max-width: 1180px) {
  .showdown-grid,
  .showdown-top-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .topbar {
    align-items: flex-start;
  }

  .controls,
  .controls-showdown,
  .visual-grid {
    grid-template-columns: 1fr;
  }

  .controls-spikes,
  .controls-showdown {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .controls-content {
    grid-template-columns: 1fr;
  }

  .summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .summary-grid-showdown {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .metric-card-wide {
    grid-column: span 2;
  }

  .panel-raster {
    grid-row: auto;
  }

  .panel {
    min-height: 340px;
  }

  canvas {
    height: 280px;
  }

  .panel-raster canvas {
    height: 320px;
  }

  .visual-grid .panel-spatial canvas {
    height: 320px;
  }

  #spike-cart-canvas {
    height: 260px;
  }

  .raster-y-axis {
    height: 320px;
  }

  .mono {
    text-align: left;
  }
}

@media (max-width: 680px) {
  .app-shell {
    padding: 22px 16px 28px;
  }

  .topbar {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    width: 100%;
    align-items: stretch;
    justify-self: stretch;
  }

  .topbar-qr {
    justify-content: flex-start;
  }

  .brand-lockup {
    --brand-lockup-gap: 12px;
    --brand-logo-size: 70px;
    --brand-qr-size: 70px;
    grid-template-columns: var(--brand-logo-size) minmax(0, max-content) var(--brand-qr-size);
  }

  .debug-overlay {
    inset: auto 10px 10px 10px;
    width: auto;
  }

  .debug-panel-header {
    display: grid;
  }

  .debug-stream-visibility-heading {
    display: grid;
  }

  .debug-stream-visibility-heading-actions {
    width: 100%;
  }

  .debug-stream-visibility-status {
    max-width: none;
    text-align: left;
  }

  .debug-panel-field-row {
    flex-wrap: wrap;
  }

  .debug-overlay-content {
    max-height: 48vh;
    font-size: 11px;
  }

  .brand-wordmark h1 {
    font-size: clamp(2.3rem, 10vw, 3.3rem);
  }

  .brand-rule {
    width: 96px;
    height: 3px;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .summary-grid-showdown {
    grid-template-columns: 1fr;
  }

  .metric-card-wide {
    grid-column: span 1;
  }

  .status-cluster {
    justify-content: flex-start;
  }

  .mode-nav {
    flex-wrap: wrap;
    justify-content: flex-start;
  }
}
