*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #ffffff;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#viewport-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  margin: 0;
  padding: 0;
}

.hud {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 9999;
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: calc(100vw - 24px);
  padding: 4px 6px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 8px 24px rgba(2, 6, 23, 0.28);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #f8fafc;
  font-size: 12px;
  line-height: 1;
  user-select: none;
  opacity: 0.92;
  transition: opacity 0.16s ease, padding 0.16s ease;
}

.hud:hover, .hud:focus-within {
  opacity: 1;
}

.hud.is-collapsed {
  padding: 3px;
  gap: 0;
}

.hud.is-collapsed .hud-controls {
  display: none;
}

.hud-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.hud-roles {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.hud-btn {
  appearance: none;
  border: 0;
  margin: 0;
  padding: 0;
  background: transparent;
  color: #cbd5e1;
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.14s ease, color 0.14s ease;
}

.hud-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
}

.hud-btn:focus-visible, .hud-select:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 2px;
}

.hud-step {
  width: 24px;
  height: 24px;
  font-size: 16px;
}

.hud-role {
  height: 22px;
  padding: 0 8px;
}

.hud-role.is-active {
  background: #f8fafc;
  color: #0f172a;
  font-weight: 600;
}

.hud-slot-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px;
  min-width: 0;
}

.hud-select {
  height: 22px;
  padding: 0 4px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.hud-select option {
  background: #0f172a;
  color: #f8fafc;
}

.hud-style {
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #94a3b8;
  font-size: 11px;
}

.hud-counter, .hud-toggle {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: #e2e8f0;
  white-space: nowrap;
}

.hud-toggle {
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  background: rgba(255, 255, 255, 0.08);
}

@media (max-width: 640px) {
  .hud-style { display: none; }
  .hud-role { padding: 0 6px; }
}
