Change font size of badges

Hi. I’m trying to change the font size of the badges in my front-end and it only partially works:

type: picture-elements
elements:
  - type: state-badge
    entity: sensor.x
    style:
      top: 90%
      left: 60%
    card_mod:
      style: >
        @keyframes blinker { 50% { opacity: 0; } }

        :host {

        color: {% if states('sensor.x')|float > 8 %} red {% else %} black
        {% endif %};

        --label-badge-background-color: {% if states('sensor.x')|float > 8
        %} red {% else %} white {% endif %};

        --label-badge-text-color: black;

        animation: {% if states('sensor.x')|float > 8 %} blinker 2s linear
        infinite {%endif %};

        --ha-label-badge-size: 40px;
          font-size: 12px;

        }  

The above code works fine. However, it doesn’t apply to a second sensor. The first one works regardless, but the second one doesn’t. I just copy the code and change the sensor name.

What am I missing?