A little non-portable but there is an xterm escape sequence[1] that gets the user's background color: \e]11;?\a
You might also be able to use the reverse-video[2] escape sequence to get something that works depending on the user's color scheme.
[1] https://stackoverflow.com/a/7767891
[2] https://en.wikipedia.org/wiki/Reverse_video