:root {
  /* New, slightly muted primary color for a cleaner look */
  --primary-color: #37b7fa;
  /* Darker shade for text shadow/accents */
  --text-shadow: #1e709e;
  /* Main background and darker component background */
  --background-dark: rgb(20, 20, 30);
  --background-medium: rgb(30, 30, 40);
  --background-light: rgb(40, 40, 50);
  --text-light: rgb(170, 170, 170);
  --text-white: white;
  --border-color: rgb(50, 50, 60);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  /* Updated to a modern, system-friendly font stack */
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
}

body {
  width: 100%;
  background-color: var(--background-dark);
}

/* --- Layout Wrappers & Navigation --- */

.nav {
  background-color: rgba(20, 20, 30, 0.9);
  display: flex;
  align-items: center;
  padding-inline: 4vw; /* Use viewport units for scaling */
  gap: 50px;
  padding-block: 10px;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  backdrop-filter: blur(8px); /* Slightly less blur */
  z-index: 100;
}

.logo img {
  height: 40px;
}

.nav-link {
  color: var(--text-light);
  font-size: 16px;
  padding-block: 10px;
  border-radius: 5px;
  text-decoration: none;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: color 0.2s ease, transform 0.2s ease;
}

.nav-link:hover {
  color: var(--text-white);
  transform: translateY(-2px);
}

.nav-link-icon {
  height: 20px;
}

/* Main Content Wrapper (Used on index.html) */
.wrap {
  padding-inline: 4vw;
  padding-block: 30px;
  max-width: 1400px; /* Center content on very large screens */
  margin: 0 auto;
}

/* --- Typography & Elements --- */

.title {
  color: var(--primary-color);
  font-size: 55px;
  font-weight: 800;
  transition: text-shadow 0.3s ease;
  display: inline-block;
}

.title:hover {
  text-shadow: 0px 0px 15px var(--text-shadow);
}

.description {
  color: var(--text-light);
  font-size: 18px;
  padding-block: 15px 30px;
  line-height: 28px;
}

.subheading {
  color: var(--primary-color);
  font-size: 30px;
  font-weight: 600;
  padding-bottom: 25px;
}

.input,
.dropdown {
  margin-bottom: 30px;
  background-color: var(--background-light);
  border: 1px solid var(--border-color);
  outline: none;
  font-size: 17px;
  padding-inline: 20px;
  padding-block: 10px;
  border-radius: 8px;
  color: var(--text-light);
  width: 100%; /* Make input more responsive */
  max-width: 350px; /* Max width for search field */
  display: block;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(55, 183, 250, 0.3);
  color: var(--text-white);
}

.dropdown {
  margin-bottom: 15px;
  cursor: pointer;
  appearance: none;
}

.dropdown:first-of-type {
  margin-bottom: 30px;
}

/* --- Game Grid Layouts --- */

/* Base container for all game grids (Main Page and Related Games) */
.games {
  display: grid;
  /* FIX: Use 'auto-fill' and a fixed 160px size to prevent cards from stretching 
     when there are few results (e.g., during search). 
  */
  grid-template-columns: repeat(auto-fill, 160px); 
  gap: 20px;
  padding-bottom: 50px;
  /* Center the row of games when it doesn't fill the full width */
  justify-content: center; 
}

/* Specific Layout for Related Games (5 Columns) */
.games-3-column {
    /* Set to 5 columns on large screens for the "You Might Also Like" section */
    grid-template-columns: repeat(5, 1fr); 
    /* The 1fr unit here is fine because the grid is always full/static */
}

/* Game Card Style */
.game {
  border-radius: 10px;
  background-color: var(--background-medium);
  color: var(--text-white);
  text-decoration: none;
  text-align: center;
  font-size: 16px;
  padding-bottom: 10px;
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  /* Ensures all cards are roughly the same height */
  display: flex; 
  flex-direction: column;
}

.game:hover {
  transform: scale(1.03);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
}

.game-thumb {
  width: 100%;
  aspect-ratio: 1/1; /* FIX: Changed to 1/1 for a perfect square thumbnail */
  object-fit: cover;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
}

/* --- Game Page Specific Styles --- */

.game-wrap {
  padding-inline: 0; 
  padding-block: 10px;
  display: flex;
  justify-content: center;
}

.game-container {
  width: 100%;
  max-width: 1000px; 
  height: calc(100vh - 80px); 
  background-color: var(--background-light);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.game-container iframe {
  width: 100%;
  height: calc(100% - 45px); 
  border: none;
}

.game-bar {
  display: flex;
  align-items: center;
  gap: 15px;
  height: 45px; 
  padding-inline: 20px;
  position: relative;
  background-color: var(--background-medium);
}

.game-bar-img {
  height: 30px;
  width: 30px;
  border-radius: 4px;
  object-fit: cover;
}

.game-bar-right {
  position: absolute;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.game-bar-right img {
  height: 22px;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.game-bar-right img:hover {
    opacity: 1;
}

.game-bar-title {
  color: var(--text-white);
  font-size: 18px;
  font-weight: 600;
}

/* Fix for the previous related games alignment issue (centering the container) */
.after-game-content {
  /* Match the max-width of the game container (1000px) and center it */
  max-width: 1000px;
  margin: 0 auto; 
  padding-block: 30px;
  padding-inline: 4vw; 
}

/* --- Footer & Scrollbar --- */

.footer {
  background-color: rgb(10, 10, 20);
  padding-block: 50px;
  text-align: center;
  color: var(--text-light);
  font-size: 16px;
}

::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-thumb {
  background-color: rgb(100, 100, 110);
  border: 2px solid var(--background-dark);
  border-radius: 10px;
}

/* --- Media Queries (Responsiveness) --- */

@media (max-width: 950px) {
  .nav {
    gap: 30px;
  }
  .nav-link-name {
    display: none;
  }
}

@media (max-width: 600px) {
  .title {
    font-size: 40px;
  }
  .games {
    /* On small screens, fix to 140px and center, preventing stretch */
    grid-template-columns: repeat(auto-fill, 140px);
    justify-content: center;
  }
  .games-3-column {
    /* On mobile, even related games should drop to 2 columns */
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .nav,
  .wrap {
    padding-inline: 20px;
  }
  .after-game-content {
      padding-inline: 20px;
  }
}