* { margin: 0; box-sizing: border-box; }
body {
  font-family: system-ui, sans-serif;
  background: #0d1117;
  color: #ffffff;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
#canvas-wrap {
  position: fixed;
  inset: 0;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  cursor: crosshair;
}
#canvas-wrap.is-panning {
  cursor: grabbing;
}
#gravity-gpu-canvas,
#gravity-canvas,
#pause-overlay-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
#gravity-gpu-canvas { z-index: 1; }
#gravity-canvas { z-index: 2; }
#pause-overlay-canvas { z-index: 3; pointer-events: none; }
#info {
  position: fixed;
  left: 12px;
  top: 12px;
  right: auto;
  width: min(520px, calc(100vw - 24px));
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.78);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.45;
  pointer-events: auto;
  z-index: 10;
  color: #ffffff;
}
.info-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
#infoToggle {
  border: 1px solid rgba(110, 118, 129, 0.6);
  background: rgba(56, 63, 78, 0.8);
  color: #ffffff;
  border-radius: 6px;
  padding: 3px 8px;
  cursor: pointer;
  font-size: 12px;
}
#infoBody { margin-top: 6px; }
#info.collapsed #infoBody { display: none; }
.space-header-back { color: #8ecbff; text-decoration: none; font-size: 13px; }
.space-header-back:hover { text-decoration: underline; }
#info h1 { font-size: 1rem; margin-bottom: 6px; color: #ffd84d; }
#info p { margin: 4px 0; }
#algoBrief {
  margin-top: 6px;
  color: #d7e2f0;
  font-size: 12px;
  line-height: 1.35;
}
.top-bodies-block {
  margin-top: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 6px;
  border: 1px solid rgba(110, 118, 129, 0.35);
}
.top-bodies-title {
  font-size: 11px;
  font-weight: 700;
  color: #ffd878;
  margin-bottom: 6px;
}
.top-bodies-center-btn {
  display: block;
  width: 100%;
  margin-bottom: 8px;
  border: 1px solid rgba(110, 118, 129, 0.6);
  background: rgba(56, 63, 78, 0.85);
  color: #ffffff;
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 12px;
}
.top-bodies-center-btn:hover {
  background: rgba(110, 118, 129, 0.45);
}
.top-bodies-table-wrap {
  overflow-x: auto;
  max-width: 100%;
}
.top-bodies-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.35;
  color: #c8d2e8;
}
.top-bodies-table th,
.top-bodies-table td {
  padding: 3px 6px 3px 0;
  text-align: right;
  white-space: nowrap;
}
.top-bodies-table th:first-child,
.top-bodies-table td:first-child {
  text-align: left;
  padding-left: 0;
}
.top-bodies-table thead th {
  font-weight: 600;
  color: #9eb0c8;
  border-bottom: 1px solid rgba(110, 118, 129, 0.45);
  padding-bottom: 4px;
}
.top-bodies-table tbody tr[data-body-id] {
  cursor: pointer;
}
.top-bodies-table tbody tr[data-body-id]:hover td {
  color: #ffffff;
  text-decoration: underline;
  text-decoration-color: rgba(255, 255, 255, 0.35);
}
.top-bodies-tr-heavy td {
  font-weight: 700;
  color: #ffa064;
}
.top-bodies-table tbody tr.top-bodies-tr-heavy[data-body-id]:hover td {
  color: #ffc090;
}
.top-bodies-empty td {
  color: rgba(150, 160, 180, 0.75);
  font-style: italic;
  text-align: left;
}
#info code {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
  padding: 1px 4px;
  border-radius: 4px;
}
#status-ok { color: #7ee787; font-weight: 600; }
#status-fail { color: #ff7b72; font-weight: 600; }
#meta {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(110, 118, 129, 0.35);
  font-size: 12px;
  color: #ffffff;
  white-space: pre-wrap;
}
#controls {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.8);
  border-radius: 8px;
  z-index: 10;
  font-size: 12px;
  color: #ffffff;
}
#controls span, #controls label { color: #ffffff; }
#controls button {
  border: 1px solid rgba(110, 118, 129, 0.6);
  background: rgba(56, 63, 78, 0.8);
  color: #ffffff;
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
}
#controls input[type="range"] { accent-color: #8ecbff; }
#controls button:hover { background: rgba(110, 118, 129, 0.5); }
#controls button:disabled { opacity: 0.5; cursor: default; }
#fpsDropHint { display: none; }
#ver {
  margin-top: 8px;
  font-size: 11px;
  color: #ffffff;
}
#logPanel {
  position: fixed;
  right: 12px;
  bottom: 12px;
  width: min(46vw, 560px);
  max-height: 42vh;
  background: rgba(0, 0, 0, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  z-index: 20;
  color: #ffffff;
  font-size: 12px;
  display: flex;
  flex-direction: column;
}
#logPanel.collapsed { max-height: 34px; overflow: hidden; }
#logHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}
#logPanel.collapsed #logHead { border-bottom: none; }
#logToggle {
  border: 1px solid rgba(110, 118, 129, 0.6);
  background: rgba(56, 63, 78, 0.8);
  color: #ffffff;
  border-radius: 6px;
  padding: 3px 8px;
  cursor: pointer;
  font-size: 12px;
}
#logBody {
  padding: 6px 8px;
  overflow: auto;
  white-space: pre-wrap;
  line-height: 1.35;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
#physicsPanel {
  position: fixed;
  left: 12px;
  bottom: 12px;
  width: min(36vw, 420px);
  max-height: 70vh;
  background: rgba(0, 0, 0, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  z-index: 20;
  color: #ffffff;
  font-size: 12px;
  display: flex;
  flex-direction: column;
}
#physicsPanel.collapsed { max-height: 34px; overflow: hidden; }
#physicsHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}
#physicsPanel.collapsed #physicsHead { border-bottom: none; }
#physicsPanel.collapsed #physicsReadback,
#physicsPanel.collapsed #physicsBody { display: none; }
.physics-readback {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 12px;
  max-height: 40vh;
  overflow-y: auto;
}
.physics-readback label { color: #ffffff; }
.physics-readback input[type="range"] {
  flex: 1;
  min-width: 90px;
  max-width: 240px;
  accent-color: #8ecbff;
}
#physicsToggle {
  border: 1px solid rgba(110, 118, 129, 0.6);
  background: rgba(56, 63, 78, 0.8);
  color: #ffffff;
  border-radius: 6px;
  padding: 3px 8px;
  cursor: pointer;
  font-size: 12px;
}
#physicsBody {
  padding: 6px 8px;
  overflow: auto;
  white-space: pre-wrap;
  line-height: 1.35;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
#chartPanel {
  position: fixed;
  right: 12px;
  top: 12px;
  width: min(46vw, 560px);
  max-height: 36vh;
  background: rgba(0, 0, 0, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  z-index: 21;
  color: #ffffff;
  font-size: 12px;
  display: flex;
  flex-direction: column;
}
#chartPanel.collapsed { max-height: 34px; overflow: hidden; }
#chartHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}
#chartPanel.collapsed #chartHead { border-bottom: none; }
#chartControls { display: flex; gap: 6px; }
.mini-btn {
  border: 1px solid rgba(110, 118, 129, 0.6);
  background: rgba(56, 63, 78, 0.8);
  color: #ffffff;
  border-radius: 6px;
  padding: 3px 8px;
  cursor: pointer;
  font-size: 12px;
}
#chartCanvas {
  display: block;
  width: 100%;
  height: 220px;
  background: rgba(8, 12, 18, 0.55);
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
  margin-top: 4px;
}
#distCanvas {
  display: block;
  width: 100%;
  height: 220px;
  background: rgba(8, 12, 18, 0.55);
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
  margin-top: 4px;
}
.hidden-canvas {
  display: none !important;
}
.result-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
}
.result-modal.hidden { display: none; }
.result-card {
  width: min(520px, calc(100vw - 24px));
  background: rgba(9, 14, 20, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 10px;
  padding: 14px 16px;
  color: #fff;
}
.result-card h2 {
  font-size: 1.05rem;
  margin-bottom: 8px;
  color: #ffd84d;
}
.result-card p {
  font-size: 0.92rem;
  margin-bottom: 12px;
  white-space: pre-wrap;
}
.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.result-actions button {
  border: 1px solid rgba(110, 118, 129, 0.6);
  background: rgba(56, 63, 78, 0.8);
  color: #ffffff;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
}
.result-card .bench-resume-hint {
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.65);
  margin-bottom: 10px;
}
.result-actions button.bench-resume-primary {
  background: rgba(46, 110, 72, 0.85);
  border-color: rgba(120, 200, 150, 0.45);
}
