score:4
Time spent in Spain authorized by a Spanish national long-stay (type D) visa or residence permit does not count for the 90/180 day clock. Time spent anywhere else in the Schengen area does.
Unless I'm misunderstanding your story, this means that your trip from Spain is excluded from the 90/180 day calculations, but the one to Germany is included.