php – trying to put an active hover to my custom nav category buttons

I have a custom category buttons which each of buttons link and echoed the specific category at the same page. my goal is to put a active background hover color on the active link. here is my code so far:

<?php
  $args = array(
  'orderby' => 'slug',
  'order' => 'ASC',
  'parent' => 0,
  'hide_empty' => false
   );
  $categories = get_categories( $args );
  foreach( $categories as $category ){
  echo '<li><a class="ctg" href="' . get_category_link( $category->term_id ) .' ">' . $category->name . '</a></li>';
   }
   ?>

and my css:

    .ctg:hover {
      background: #A6EBF2;
    }
    .ctg:active {
      background-color: #A6EBF2;
    }

any help is appreciated.