body {
  margin: 0;
  overflow: hidden;
  font-family: system-ui, -apple-system, sans-serif;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.hud-stack {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 10;
  width: min(300px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.hud-footer {
  align-self: center;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #bbb;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  padding: 4px 10px;
  font-size: 12px;
  text-align: center;
  color: #555;
}
.hud-footer a {
  color: inherit;
}

.hud {
  background: rgba(255, 255, 255, 0.92);
  color: #111;
  border: 1px solid #bbb;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.hud-toggle {
  display: block;
  width: 100%;
  padding: 6px 10px;
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  border-radius: 6px;
}
.hud.hud-open .hud-toggle {
  border-bottom: 1px solid #eee;
  border-radius: 6px 6px 0 0;
}
.hud-toggle::before {
  content: '▸ ';
  display: inline-block;
  width: 1em;
}
.hud.hud-open .hud-toggle::before {
  content: '▾ ';
}
.hud:not(.hud-open) .hud-body {
  display: none;
}

.hud-body {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.hud-row {
  display: flex;
  flex-direction: row;
  gap: 10px;
  padding: 8px 26px 8px 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.6);
  position: relative;
}

.hud-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 auto;
  min-width: 0;
}

.hud-vec {
  display: flex;
  gap: 6px;
  align-items: center;
}

.hud-field {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.hud-field span {
  color: #555;
}

.hud-num {
  width: 48px;
  padding: 2px 4px;
  font: inherit;
  border: 1px solid #ccc;
  border-radius: 3px;
}

.hud-piece {
  font: inherit;
  padding: 2px 4px;
  border: 1px solid #ccc;
  border-radius: 3px;
  background: #fff;
  max-width: 100%;
}

.hud-swatches {
  display: flex;
  gap: 4px;
}

.hud-swatch {
  width: 20px;
  height: 20px;
  border: 2px solid transparent;
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
}
.hud-swatch.selected {
  border-color: #222;
  box-shadow: 0 0 0 1px #fff inset;
}
.hud-swatch.disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.hud-preview {
  align-self: center;
  border: 1px solid #aaa;
  image-rendering: pixelated;
  flex: 0 0 auto;
}

.hud-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #888;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.hud-remove:hover {
  background: #f3d6d6;
  color: #a00;
}

.hud-add-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-disclaimer {
  color: #777;
  font-size: 11px;
  font-style: italic;
}

.hud-add {
  align-self: flex-start;
  padding: 4px 10px;
  font: inherit;
  border: 1px dashed #aaa;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
}
.hud-add:hover:not(:disabled) {
  background: #eee;
}
.hud-add:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.hud-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.hud-results-actions {
  display: flex;
  justify-content: flex-start;
  margin-top: 8px;
}
.hud-save-png {
  padding: 4px 10px;
  font: inherit;
  border: 1px solid #ccc;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
}
.hud-save-png:hover {
  background: #eee;
}
.hud-results-general {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 4px;
}
.hud-results-general span {
  color: #555;
}
.hud-result-row {
  padding: 6px 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.6);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.hud-result-head {
  display: flex;
  align-items: center;
  gap: 6px;
}
.hud-result-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.2);
  flex: 0 0 auto;
}
.hud-result-name {
  font-weight: 600;
}
.hud-result-pct {
  margin-left: auto;
  color: #333;
  font-variant-numeric: tabular-nums;
}
.hud-result-seq {
  font-size: 12px;
  color: #333;
  word-break: break-word;
}
.hud-result-seq-label {
  color: #777;
  margin-right: 4px;
}
.hud-result-seq-vals {
  font-variant-numeric: tabular-nums;
}
.hud-oeis {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 8px;
  font-size: 12px;
  color: #111;
  text-decoration: none;
  border: 1px solid #bbb;
  border-radius: 3px;
  background: #fff;
  cursor: pointer;
}
.hud-oeis:hover {
  background: #eee;
}

.hud-seq-link {
  color: #06c;
  cursor: pointer;
  text-decoration: underline;
  margin-left: 6px;
}
.hud-seq-link:hover {
  color: #03a;
}
