Cardmod flashing when it shouldn't be

Hello,
I’m using the following card. I only want it to flash when the little level is below 40%. The card is flashing now, but the litter level is at 50% (shouldn’t be flashing). Any tips would be appreciated! Thanks.

type: custom:mushroom-entity-card
entity: sensor.litter_robot_4_litter_level
name: Litter Level
icon: mdi:cat
layout_options:
  grid_columns: 2
  grid_rows: 1
card_mod:
  style: |
    ha-card {
      animation: flashAnimation 3s infinite;
      animation-play-state: running;
    }
    @keyframes flashAnimation {
      0%, 49% { background-color: inherit; }
      50%, 100% { background-color: orange; }
    }
state_color: true
styles:
  card:
    - animation-play-state: |
        [[[
          return states['sensor.litter_robot_4_litter_level'].state < 40 ? 'running' : 'paused';
        ]]]