:root {
  --bg: #0b0b0b;
  --panel: #000;
  --border: #333;
  --muted: #777;
  --accent: #8fd;
  --grid-size: 10;
  --cell-size: 20px;
  --cell-gap: 2px;
  --grid-pad: 6px;
}

body {
  font-family: "Courier New", monospace;
  background: var(--bg);
  color: #e2e2e2;
  margin: 0;
  padding: 20px;
}

body.spectator {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body.tick-flash::after {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(200, 255, 255, 0.22);
  mix-blend-mode: screen;
  pointer-events: none;
  animation: tickFlash 0.6s ease-out;
  z-index: 1000;
}

@keyframes tickFlash {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

.site-header {
  margin-bottom: 12px;
}

.status-row {
  display: flex;
  gap: 16px;
  color: #aaa;
  font-size: 12px;
  flex-wrap: wrap;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}

.nav a {
  color: var(--accent);
  text-decoration: none;
}

.nav a:hover {
  text-decoration: underline;
}

.button-link {
  display: inline-block;
  background: #111;
  color: #8fd;
  border: 1px solid #333;
  padding: 8px 16px;
  text-decoration: none;
}

.button-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 12px;
  margin-bottom: 12px;
}

.label {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.process-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.spectator-shell {
  display: grid;
  grid-template-columns: 1fr 5fr;
  grid-template-rows: 1fr;
  gap: 12px;
  flex: 1;
  align-content: start;
  align-items: stretch;
  min-height: 0;
}

.spectator-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
  min-width: 0;
  min-height: 0;
}

.spectator-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: stretch;
  flex: 1;
  min-height: 0;
}

.spectator-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: stretch;
  flex: 1;
  margin-top: 16px;
}

.spectator-row .panel {
  margin-bottom: 0;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
}

.shard-index {
  height: 100%;
}

.chat-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
}

.column {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

pre {
  background: #000;
  padding: 12px;
  border: 1px solid #333;
  min-height: 120px;
  white-space: pre-wrap;
}

.grid {
  display: grid;
  gap: var(--cell-gap);
  background: #050505;
  border: 1px solid #222;
  padding: var(--grid-pad);
  min-width: calc(
    (var(--grid-size) * var(--cell-size)) + ((var(--grid-size) - 1) * var(--cell-gap))
  );
  min-height: calc(
    (var(--grid-size) * var(--cell-size)) + ((var(--grid-size) - 1) * var(--cell-gap))
  );
}

.grid-cell {
  width: var(--cell-size);
  height: var(--cell-size);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  border: 1px solid #111;
  font-size: 11px;
  color: #777;
  cursor: pointer;
}

.grid-cell.process {
  color: #cfd;
  border-color: #1c3;
}

.grid-cell.defragger {
  color: #f66;
  border-color: #a22;
}

.grid-cell.gate {
  color: #6cf;
  border-color: #246;
}

.grid-cell.echo {
  color: #999;
  border-color: #333;
  font-style: italic;
}

.grid-cell.preview {
  background: #221;
  border-color: #663;
}

.grid-cell.preview-next {
  background: #311;
  border-color: #a33;
}

.grid-cell.target {
  border-color: #ff5;
  color: #ff5;
}

.grid-cell.wall-e {
  border-right: 2px solid #444;
}

.grid-cell.wall-s {
  border-bottom: 2px solid #444;
}

.status-line {
  font-size: 11px;
  color: #999;
  margin-bottom: 6px;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.controls input[type="range"] {
  flex: 1;
}

button,
input {
  font-family: "Courier New", monospace;
}

button {
  margin: 4px 4px 4px 0;
  background: #111;
  color: #e2e2e2;
  border: 1px solid #333;
  padding: 6px 10px;
}

button.active {
  border-color: var(--accent);
  color: var(--accent);
}

.command-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.command-bar input {
  flex: 1;
  min-width: 240px;
  background: #000;
  color: #e2e2e2;
  border: 1px solid #333;
  padding: 8px;
}

#chatlog {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  background: #000;
  padding: 8px;
  border: 1px solid #333;
}

.trace-log {
  max-height: 220px;
  overflow-y: auto;
  background: #000;
  padding: 8px;
  border: 1px solid #333;
  white-space: pre-wrap;
  font-family: "Courier New", monospace;
  font-size: 12px;
}

.chat-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.chat-panel .chat-row {
  margin-top: auto;
}

.traces-panel {
  display: flex;
  flex-direction: column;
}

.traces-panel .trace-log {
  flex: 1;
}

.chat-row input {
  flex: 1;
  background: #000;
  color: #e2e2e2;
  border: 1px solid #333;
  padding: 6px;
}

#flavor {
  margin: 8px 0 12px;
  color: #888;
  font-style: italic;
  max-width: 720px;
  white-space: pre-wrap;
}

.inspect-tooltip {
  position: fixed;
  display: none;
  max-width: 240px;
  padding: 8px 10px;
  background: #050505;
  border: 1px solid #444;
  color: #e2e2e2;
  font-size: 11px;
  white-space: pre-wrap;
  z-index: 1200;
  pointer-events: none;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.6);
}

#saylog {
  color: #777;
  max-width: 720px;
  white-space: pre-wrap;
}

.ad-slot {
  border: 1px dashed #444;
  color: #666;
  padding: 10px;
  text-align: center;
}

.death-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 5, 0.95);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.death-overlay.active {
  display: flex;
}

.death-card {
  border: 1px solid #444;
  background: #000;
  padding: 24px;
  max-width: 560px;
  text-align: center;
}

.death-card h2 {
  margin: 0 0 12px;
  font-size: 22px;
  color: #f66;
}

@media (max-width: 900px) {
  .process-shell,
  .spectator-shell {
    grid-template-columns: 1fr;
  }

  .spectator-row {
    grid-template-columns: 1fr;
  }

  .spectator-bottom {
    grid-template-columns: 1fr;
  }
}
