:root {
  --ua-blue: #0057B7;
  --ua-yellow: #FFD700;
  --primary-color: var(--ua-yellow); /* Use yellow as primary */
  --bg-color: var(--ua-blue); /* Use blue as main background */
  --card-bg-color: var(--ua-yellow); /* Use yellow for cards */
  --text-color: #000; /* Change text to black for better contrast on yellow */
  --link-text-color: #fff; /* Keep link text white for nav/footer */
}

html {
  font-size: 16px;
}

body {
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 0;
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
}

header {
  background-color: var(--ua-blue); /* Header uses blue background */
  padding: 1rem;
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
}

header h1 {
  font-size: 2rem;
  font-weight: bold;
  color: var(--ua-yellow); /* Title in yellow */
  margin: 0;
  text-transform: uppercase;
}

.ua-flag-icon {
   width: 2.5rem;
   height: 2.5rem;
}

nav {
  background-color: var(--ua-blue); /* Nav uses blue background */
  padding: 0.5rem;
  position: sticky;
  top: 0;
  z-index: 1000;
}

nav ul {
  list-style-type: none;
  padding: 0;
  margin: 0;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
}

nav li {
  margin: 0.3rem;
}

nav a {
  color: var(--link-text-color); /* Use white text for nav links */
  text-decoration: none;
  font-size: 1rem;
  font-weight: bold;
  padding: 0.5rem 0.8rem;
  border-radius: 1.25rem;
  transition: background-color 0.3s, color 0.3s;
}

nav a:hover,
nav a.active {
  background-color: var(--ua-yellow); /* Hover/active uses yellow */
  color: #000; /* Text turns black on yellow */
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

.category-title {
  font-size: 1.5rem;
  font-weight: bold;
  margin: 2rem 0 1rem;
  color: var(--ua-yellow); /* Category titles in yellow */
  border-left: 4px solid var(--ua-yellow);
  padding-left: 0.6rem;
  text-transform: uppercase;
}

.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.link-card {
  background-color: var(--card-bg-color); /* Cards use yellow background */
  border: 1px solid var(--ua-blue); /* Add a blue border */
  border-radius: 8px;
  padding: 1.2rem 0.8rem;
  text-align: center;
  transition: transform 0.2s ease-out, background-color 0.3s, color 0.3s;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 90px;
  position: relative;
  overflow: hidden;
}

.link-card a {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  text-decoration: none;
  z-index: 12;
  display: block;
}

.link-card:hover {
  background-color: var(--ua-blue); /* Hover changes card to blue */
  color: var(--link-text-color); /* Text turns white on blue */
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.link-card i {
  font-size: 1.8rem;
  margin-bottom: 0.7rem;
  color: #000; /* Icon color black for contrast on yellow */
  transition: transform 0.2s ease, color 0.3s; /* Add color transition */
  position: relative;
  z-index: 11;
}

.link-card:hover i {
  color: var(--link-text-color); /* Icon turns white on blue hover */
  transform: scale(1.1);
}

.link-card h3 {
  font-size: 0.9rem;
  margin: 0;
  color: var(--text-color); /* Text color black for contrast on yellow */
  line-height: 1.3;
  font-weight: 500;
  max-width: 100%;
  height: 2.6em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  text-overflow: ellipsis;
  white-space: normal;
  padding: 0 0.3rem;
  position: relative;
  z-index: 11;
}

.link-card:hover h3 {
    color: var(--link-text-color); /* Text turns white on blue hover */
}

footer {
  background-color: var(--ua-yellow); /* Footer uses yellow background */
  color: #000; /* Text in black for contrast */
  text-align: center;
  padding: 1rem;
  font-size: 0.75rem;
}

footer nav {
  margin-top: 0.6rem;
  background-color: transparent;
}

footer nav a {
  color: #000; /* Footer links in black */
  margin: 0 0.6rem;
  font-size: 0.75rem;
}

.footer-ua-text {
   font-weight: bold;
   display: block;
   margin-top: 0.5rem;
}

@media (max-width: 1200px) {
  main {
    padding: 1rem;
    max-width: 95%;
  }

  .link-grid {
    grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
    gap: 1rem;
  }
}

@media (max-width: 768px) {
  html {
    font-size: 15px;
  }

  main {
    padding: 0.8rem;
  }

  .link-grid {
    grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr));
    gap: 0.8rem;
  }

  nav {
    padding: 0.4rem;
  }

  nav a {
    padding: 0.4rem 0.7rem;
    font-size: 0.95rem;
  }

  .category-title {
    font-size: 1.4rem;
    margin: 1.8rem 0 1rem;
  }

  .link-card {
    padding: 1rem 0.6rem;
    min-height: 80px;
  }

  .link-card i {
    font-size: 1.6rem;
    margin-bottom: 0.5rem;
  }

  .link-card h3 {
    font-size: 0.8rem;
    height: 2.4em;
  }
}

@media (max-width: 480px) {
  html {
    font-size: 14px;
  }

  main {
    padding: 0.6rem;
  }

  .link-grid {
    grid-template-columns: repeat(auto-fill, minmax(6rem, 1fr));
    gap: 0.7rem;
  }

  header h1 {
    font-size: 1.6rem;
  }

  nav li {
    margin: 0.25rem;
  }

  nav a {
    padding: 0.35rem 0.6rem;
    font-size: 0.9rem;
  }

  .category-title {
    font-size: 1.4rem;
    margin: 1.8rem 0 1rem;
  }

  .link-card {
    padding: 0.8rem 0.5rem;
    min-height: 70px;
  }

  .link-card i {
    font-size: 1.4rem;
    margin-bottom: 0.4rem;
  }

  .link-card h3 {
    font-size: 0.75rem;
    padding: 0 0.2rem;
    height: 2.4em;
  }

  footer {
    padding: 0.8rem;
  }

  footer nav a {
    margin: 0 0.4rem;
    font-size: 0.7rem;
  }
}

@media (max-width: 360px) {
  html {
    font-size: 13px;
  }

  .link-grid {
    grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr));
    gap: 0.6rem;
  }

  header h1 {
    font-size: 1.4rem;
  }

  .link-card {
    padding: 0.8rem 0.5rem;
    min-height: 70px;
  }

  .link-card i {
    font-size: 1.3rem;
    margin-bottom: 0.3rem;
  }

  .link-card h3 {
    font-size: 0.7rem;
    padding: 0 0.15rem;
    height: 2.2em;
  }
}