/* Kho game: thanh tìm kiếm, thể loại, chơi gần đây, yêu thích, phân trang (js/browse.js) */
:root {
  --surface: #ffffff;
  --line: #eadfcd;
}
html[data-theme="dark"] {
  --surface: #181d35;
  --line: #303957;
}
html[data-theme="halloween"] {
  --surface: #281333;
  --line: #643356;
}
html[data-theme="christmas"] {
  --surface: #ffffff;
  --line: #d7ece5;
}
html[data-theme="tet"] {
  --surface: #fffaf0;
  --line: #f4d28a;
}

/* CSS của trang đặt display cho các khối này, nên phải ép [hidden] */
#games [hidden] {
  display: none !important;
}
.browse {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}
.browse-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* ---------- ô tìm kiếm ---------- */
.search-box {
  position: relative;
  flex: 1 1 340px;
  display: block;
}
.search-box input {
  width: 100%;
  height: 52px;
  padding: 0 48px 0 50px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--ink);
  font: 500 15px "Space Grotesk", sans-serif;
  outline: none;
  box-shadow: 0 10px 30px rgba(107, 83, 48, 0.06);
  transition:
    border-color 0.2s,
    box-shadow 0.2s,
    background 0.45s;
  -webkit-appearance: none;
  appearance: none;
}
.search-box input::placeholder {
  color: var(--muted);
}
.search-box input::-webkit-search-cancel-button {
  display: none;
}
.search-box input:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--orange) 18%, transparent);
}
.search-ico {
  position: absolute;
  left: 18px;
  top: 50%;
  translate: 0 -50%;
  width: 20px;
  height: 20px;
  color: var(--muted);
  pointer-events: none;
}
.search-box input:focus ~ .search-ico,
.search-box:focus-within .search-ico {
  color: var(--orange);
}
.search-key {
  position: absolute;
  right: 14px;
  top: 50%;
  translate: 0 -50%;
  min-width: 24px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 7px;
  font: 600 12px "Space Grotesk", sans-serif;
  color: var(--muted);
  text-align: center;
  pointer-events: none;
}
.search-box input:focus ~ .search-key,
.search-box input:not(:placeholder-shown) ~ .search-key {
  display: none;
}
.search-clear {
  position: absolute;
  right: 9px;
  top: 50%;
  translate: 0 -50%;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: color-mix(in srgb, var(--ink) 8%, transparent);
  color: var(--ink);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.search-clear:hover {
  background: color-mix(in srgb, var(--ink) 15%, transparent);
}

/* ---------- sắp xếp / số game mỗi trang ---------- */
.browse-opts {
  display: flex;
  gap: 10px;
}
.select-box {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 52px;
  padding: 0 12px 0 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--muted);
  font: 500 12px "Space Grotesk", sans-serif;
  white-space: nowrap;
  transition: background 0.45s;
}
.select-box select {
  height: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: 700 14px "Space Grotesk", sans-serif;
  padding-right: 20px;
  cursor: pointer;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.select-box select option {
  background: var(--surface);
  color: var(--ink);
}
.select-box::after {
  content: "⌄";
  position: absolute;
  right: 13px;
  top: 50%;
  translate: 0 -62%;
  color: var(--ink);
  pointer-events: none;
}
.select-box:focus-within {
  border-color: var(--orange);
}

/* ---------- thể loại ---------- */
.cat-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 6px;
  margin: 0 -2px;
  scrollbar-width: none;
}
.cat-chips::-webkit-scrollbar {
  display: none;
}
.cat-chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 40px;
  padding: 0 14px 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: 600 14px "Space Grotesk", sans-serif;
  cursor: pointer;
  transition:
    transform 0.25s var(--ease-pop, ease),
    background 0.2s,
    color 0.2s,
    border-color 0.2s;
}
.cat-chip:hover {
  transform: translateY(-2px);
  border-color: var(--orange);
}
.cat-chip:active {
  transform: scale(0.95);
}
.cat-chip small {
  min-width: 22px;
  padding: 1px 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 8%, transparent);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}
.cat-chip.fav .chip-ico {
  color: #ff4d6d;
}
.cat-chip.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--cream);
}
.cat-chip.active small {
  background: color-mix(in srgb, var(--cream) 22%, transparent);
}
.cat-chip.active.fav .chip-ico {
  color: #ff7a93;
}
html:is([data-theme="christmas"], [data-theme="tet"], [data-theme="halloween"]) .cat-chip.active {
  background: var(--orange);
  border-color: var(--orange);
  color: #fff;
}

/* ---------- chơi gần đây ---------- */
.recent {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 10px 12px 10px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 75%, transparent);
}
.recent-title {
  flex: none;
  font: 700 13px "Space Grotesk", sans-serif;
  color: var(--muted);
}
.recent-list {
  flex: 1;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.recent-list::-webkit-scrollbar {
  display: none;
}
.recent-item {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px 7px 9px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
  font: 600 13px "Space Grotesk", sans-serif;
  transition:
    transform 0.2s,
    border-color 0.2s;
}
.recent-item:hover {
  transform: translateY(-2px);
  border-color: var(--orange);
}
.recent-clear {
  flex: none;
  border: 0;
  background: none;
  color: var(--muted);
  font: 600 12px "Space Grotesk", sans-serif;
  cursor: pointer;
  padding: 6px;
}
.recent-clear:hover {
  color: var(--orange);
}

.result-info {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 14px;
}
.result-info b {
  color: var(--ink);
}

/* ---------- trên thẻ game: tim + nhãn mới ---------- */
.fav-btn {
  position: absolute;
  top: 13px;
  right: 13px;
  z-index: 5;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(16, 22, 38, 0.5);
  backdrop-filter: blur(4px);
  color: rgba(255, 255, 255, 0.9);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition:
    transform 0.25s var(--ease-pop, ease),
    background 0.2s,
    color 0.2s;
}
.fav-btn:hover {
  transform: scale(1.12);
  background: rgba(16, 22, 38, 0.7);
}
.fav-btn.on {
  color: #ff4d6d;
  background: rgba(255, 255, 255, 0.92);
}
.fav-btn.pop span {
  animation: favPop 0.4s var(--ease-pop, ease);
}
@keyframes favPop {
  40% {
    transform: scale(1.5);
  }
}
.new-badge {
  position: absolute;
  left: 21px;
  bottom: 14px;
  z-index: 3;
  padding: 5px 9px;
  border-radius: 6px;
  background: linear-gradient(135deg, #ff7859, #ff4d8d);
  color: #fff;
  font: 700 10px "Space Grotesk", sans-serif;
  letter-spacing: 1.2px;
  box-shadow: 0 4px 14px rgba(255, 77, 141, 0.35);
}

/* ---------- không có kết quả ---------- */
.empty-state {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 48px 20px;
  border: 2px dashed var(--line);
  border-radius: 22px;
  text-align: center;
}
.empty-ico {
  font-size: 44px;
}
.empty-state b {
  font: 700 22px "Baloo 2", sans-serif;
  color: var(--ink);
}
.empty-state p {
  margin: 0 0 8px;
  color: var(--muted);
  max-width: 420px;
}
.empty-state .primary-button {
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

/* ---------- phân trang ---------- */
.pagination {
  flex-wrap: wrap;
  align-items: center;
}
.page-button.step {
  font-size: 19px;
  line-height: 1;
}
.page-button:disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}
.page-gap {
  width: 22px;
  text-align: center;
  color: var(--muted);
  font-weight: 700;
}
.page-info {
  margin-left: 6px;
  color: var(--muted);
  font: 500 12px "Space Grotesk", sans-serif;
}

@media (min-width: 761px) {
  .cat-chips {
    flex-wrap: wrap;
    overflow: visible;
  }
}
@media (max-width: 760px) {
  .search-box {
    flex-basis: 100%;
  }
  .search-box input,
  .select-box {
    height: 48px;
  }
  .browse-opts {
    flex: 1 1 100%;
  }
  .select-box {
    flex: 1;
    justify-content: space-between;
  }
  .search-key {
    display: none;
  }
  .recent {
    padding: 8px 8px 8px 12px;
    gap: 8px;
  }
  .recent-title span {
    display: none;
  }
  .pagination {
    gap: 5px;
  }
  .page-button {
    width: 33px;
    height: 36px;
  }
  .page-gap {
    width: 14px;
  }
  .page-info {
    flex-basis: 100%;
    text-align: center;
    margin: 4px 0 0;
  }
}
