:root {
  --bg: #0d0d0d;
  --fg: #f4f4f4;
  --card-bg: #1b1b1b;
  --accent: #4ea1ff;
  --header-bg: #151515;
  --border: #222;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  line-height: 1.5;
}

header {
  position: sticky;
  top: 0;
  z-index: 30;
  text-align: center;
  padding: 14px;
  font-size: 1.4rem;
  font-weight: 700;
  background: var(--header-bg);
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

#top-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 12px 16px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

#main_div {
  max-width: 1600px;
  margin: 24px auto;
  padding: 0 12px;
  display: grid;
  gap: 24px;
  grid-template-columns: 1fr;
}

@media (min-width: 600px)  { #main_div { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px)  { #main_div { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1200px) { #main_div { grid-template-columns: repeat(4, 1fr); } }

.game-card {
  background: var(--card-bg);
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
}

.game-card:hover {
  transform: translateY(-10px) scale(1.03);
  box-shadow: 0 20px 40px rgba(0,0,0,0.6);
  border-color: var(--accent);
}

.game-card img.game-icon {
  width: 100%;
  height: 180px;
  object-fit: cover;
  border-bottom: 1px solid var(--border);
}

.game-card h2.game-title {
  margin: 16px 12px 8px;
  font-size: 1.35rem;
  color: var(--accent);
  text-align: center;
}

.game-footer {
  margin-top: auto;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0,0,0,0.2);
}

.game-difficulty {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: bold;
  text-transform: uppercase;
}
.game-difficulty.easy    { background: #1e7e34; color: #fff; }
.game-difficulty.medium  { background: #ff9f1c; color: #000; }
.game-difficulty.hard    { background: #d32f2f; color: #fff; }

.play-btn {
  background: var(--accent);
  color: #fff;
  padding: 10px 20px;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 600;
}
.play-btn:hover {
  background: #6bb8ff;
  transform: scale(1.08);
}

@media (max-width: 480px) {
  #main_div { padding: 0 8px; gap: 16px; }
  .game-card img.game-icon { height: 150px; }
}
/*-----------------------------------------------------------*/
/* ====================== SEARCH & CATEGORY BAR ====================== */
#top-bar {
  position: sticky;
  top: 56px;                    /* height of your <header> */
  z-index: 20;
  padding: 14px 20px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: center;
}

/* Category Chips */
#category-chips {
  width: 80%;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  white-space: nowrap;
  padding-bottom: 5px;
  scrollbar-width: none;
}

#category-chips::before,
#category-chips::after {
  content: "";
  flex: 1 0;
}

#category-chips::-webkit-scrollbar {
  display: none;
}

.chip {
  padding: 9px 16px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 50px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
  user-select: none;
}

.chip:hover {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  transform: translateY(-2px);
}

.chip.active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(78, 161, 255, 0.4);
}

/* Search Box + Suggestions */
.search-container {
  position: relative;
  max-width: 420px;
  flex: 1;
}

#search-box {
  width: 60%;
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  border-radius: 50px;
  color: var(--fg);
  font-size: 1rem;
  outline: none;
  transition: all 0.3s ease;
}

#search-box::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

#search-box:focus {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.15);
  box-shadow: 0 0 0 3px rgba(78, 161, 255, 0.2);
}

#search-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 6px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  max-height: 320px;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  display: none;
  z-index: 100;
}

.suggestion-item {
  padding: 14px 20px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.2s;
}

.suggestion-item:hover {
  background: rgba(78, 161, 255, 0.15);
}

.suggestion-item:last-child {
  border-bottom: none;
}

/* Small inline category badge inside each card (optional but nice) */
/* 
  /* <span class="game-category-chip">${escapeHtml(game.category || "General")}</span> */
*/
.game-category-chip {
  flex-shrink: 0;
  background: var(--accent);
  color: #000;
  padding: 5px 12px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  #top-bar {
    flex-direction: column;
    padding: 16px 12px;
  }
  #category-chips {
    order: 2;
  }
  .search-container {
    order: 1;
    width: 100%;
    max-width: none;
  }
}

/* Loading & Empty States */
#main_div:empty::before {
  content: "Loading amazing games...";
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem;
  font-size: 1.2rem;
  color: var(--accent);
  opacity: 0.7;
}
