Change Icon Background when Color is White

Hi
I am trying to change the color of the background of the icons (the lighter color) as soon as the color of an icon is white. I am able to do it but not together with the cardmod style code already integrated (see code below). Both of it together doesnt work. Anyone who can help?

image

type: custom:mushroom-template-card
primary: "{{state_attr('sensor.p1s_XXXX_ams_1_slot_1','type')}}"
secondary: ""
icon: mdi:circle
layout: vertical
entity: sensor.p1s_XXXX_ams_1_slot_1
icon_color: "{{state_attr('sensor.p1s_XXXX_ams_1_slot_1','color')}}"
tap_action:
  action: none
hold_action:
  action: more-info
double_tap_action:
  action: more-info
card_mod:
  style: |
    ha-card  {
     border-width:
      {%- set sensor = states('sensor.p1s_XXXX_aktiver_slotindex') %}
      {%- if sensor == '1' %} 2px !important;
      {%- else %} 0px !important;
      {%- endif %}
     border-color:
      {%- set sensor = states('sensor.p1s_XXXX_aktiver_slotindex') %}
      {%- if sensor == '2' %} dark-grey !important;
      {%- else %} 0px !important;
      {%- endif %}
     background: none !important;
     height: 100% !important;
     width: 100%;
                  margin-top: 2px;
              margin-bottom: 0px;
              margin-left: 0px;
              margin-right: 0px;
    }