/* Reset cơ bản */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: Arial, sans-serif;
  background: #fafafa;
  color: #333;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

h1, h2, h3, h4, h5, h6 {
  color: #0000FF;
}

h1 {
  margin-left: 20%;
  margin-bottom: 8px; /* ~6pt */
  font-size: 24px;
  width: 80%; /* Khớp iframe */
}

ul, p {
  font-size: 14px;
}

/* Header */
header {
  background: #0077cc;
  color: #fff;
  padding: 8px 16px;
}

nav ul {
  display: flex; /* flex */
  list-style: none;


    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
    gap: 25px;
    padding: 5px;
}

nav li {
  margin-right: 12px;
  white-space: nowrap;
}

nav a {
  color: #fff;
  text-decoration: none;
  padding: 4px 8px;
}

nav a:hover {
  background: #444;
  border-radius: 4px;
}

/* Danh sách game */
#game-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 180px));
  gap: 12px;
  padding: 15px;
}

.game-card {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  overflow: hidden;
  text-align: center;
  cursor: pointer;
  transition: transform 0.2s;
}

.game-card:hover {
  transform: scale(1.05);
}

.game-card img {
  width: 100%;
  height: 120px;
  object-fit: cover;
}

.game-card h4 {
  padding: 8px;
  font-size: 16px;
}

/* Search container */
.search-container {
  margin: 20px auto;
  text-align: center;
}

#searchInput {
  padding: 10px;
  width: 300px;
  font-size: 16px;
  border: 2px solid #ccc;
  border-radius: 5px;
  transition: border-color 0.3s;
}

#searchInput:focus {
  outline: none;
  border-color: #6200ea;
}

/* Search results */
.search-results {
  width: 100%;
  max-width: 1200px;
  margin: 20px auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 12px;
  padding: 15px;
  background-color: #222;
  color: #fff;
  position: relative;
  z-index: 1;
}

.search-results[style*="display: block"] {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); /* 3-4 cột trên PC */
}

/* Ẩn .search-results trên trang game */
body:has(#player:not([style*="display: none"])) .search-results {
  display: none !important;
  height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  overflow: hidden !important;
}

.search-results .related-card {
  width: 100%;
  text-align: center;
}

.search-results .related-card img {
  width: 100%;
  height: 100px;
  object-fit: cover;
  border-radius: 5px;
}

.search-results .related-card a {
  text-decoration: none;
  color: #fff;
  font-weight: bold;
}

.search-results .related-card a:hover {
  color: #6200ea;
}

.search-results .no-results {
  color: #ff5555;
  font-style: italic;
  text-align: center;
  padding: 20px;
  width: 100%;
  grid-column: 1 / -1;
}

/* Khu vực player */
#player {
  display: flex;
  gap: 8px;
  padding: 8px;
  background: #f9f9f9;
  max-width: 1200px;
  margin: 0 auto;
  flex-wrap: nowrap;
}

.player-left {
  flex: 3;
  min-width: 300px;
  display: flex;
  flex-direction: column;
}

.player-left iframe {
  width: 80%;
  height: 70vh;
  border-radius: 6px;
  border: 1px solid #ccc;
  display: block;
  margin: 0 auto;
}

.player-left .game-info {
  margin-top: 8px;
  padding: 0 4px;
  position: relative;
  z-index: 3;
}

.player-right {
  flex: 1;
  min-width: 250px;
  color: blue;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#related-games {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.related-games-mobile {
  display: none;
}

.related-card {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  text-align: center;
  overflow: hidden;
  cursor: pointer;
  padding: 3px;
  margin-bottom: 20px;
}

.related-card img {
  width: 100%;
  height: 100px;
  object-fit: cover;
  border-radius: 5px;
}

.related-card a {
  text-decoration: none;
  color: #333;
  font-weight: bold;
}

.related-card a:hover {
  color: #6200ea;
}

/* Game iframe container */
.game-iframe-container {
  position: relative;
  width: 100%;
  max-width: 900px;
  aspect-ratio: 16 / 9;
  margin-bottom: 20px;
  display: block;
}

.game-iframe-container iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  position: relative;
  z-index: 2;
}

.game-iframe-container.fullscreen {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: none !important;
  z-index: 9999 !important;
  background: #000 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
}

.game-iframe-container.fullscreen iframe {
  width: 100vw !important;
  height: 100vh !important;
  z-index: 9998 !important;
}

/* Fullscreen overlay và button */
.fullscreen-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  pointer-events: none;
  z-index: 1;
}

.fullscreen-button {
  position: absolute !important;
  top: 10px !important;
  right: 10px !important;
  z-index: 10000 !important;
  padding: 8px 16px !important;
  width: auto !important;
  height: auto !important;
  min-height: 32px !important;
  background: #0077cc !important;
  color: #fff !important;
  border: none !important;
  border-radius: 4px !important;
  cursor: pointer !important;
  font-size: 14px !important;
  line-height: 1.5 !important;
  display: inline-block !important;
  box-sizing: border-box !important;
}

.fullscreen-button:hover {
  background: #005bb5 !important;
}

/* Footer */
footer {
  width: 100%;
  padding: 8px 0;
  text-align: center;
  background-color: #222;
  color: #fff;
  font-size: 14px;
  margin-top: auto;
}

/* Ẩn/hiện */
.hidden {
  display: none !important;
}

#player, .search-results {
  transition: opacity 0.3s ease;
}

#player[style*="display: none"], .search-results[style*="display: none"] {
  opacity: 0;
  height: 0 !important;
  overflow: hidden !important;
}

#player, .search-results {
  opacity: 1;
}

main[style*="display: none"] {
  display: none !important;
  height: 0;
  overflow: hidden;
}

/* Pagination */
.pagination {
  margin: 16px 0 48px;
  text-align: center;
  z-index: 10;
}

.pagination a {
  display: inline-block;
  margin: 0 5px;
  padding: 6px 10px;
  border: 1px solid #d3e3fd;
  border-radius: 6px;
  text-decoration: none;
  color: #1a73e8;
  background: #f5f7fa;
  transition: background 0.3s ease, color 0.3s ease;
}

.pagination a:hover {
  background: #e8f0fe;
  color: #fff;
}

.pagination .current {
  background: #1a73e8;
  color: #fff;
  font-weight: bold;
  border: 1px solid #1a73e8;
}

/* Main */
main {
  flex: 1;
  padding: 16px;
  overflow: visible;
}

/* Ads */
.adsbygoogle {
  max-height: 20px;
  overflow: hidden;
  margin: 8px 0;
}

/* Responsive */
@media (max-width: 768px) {
  #player {
    flex-direction: column;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px;
  }
  .player-left, .player-right {
    flex: 1;
    width: 100%;
    min-width: 0;
  }
  .player-left iframe {
    width: 100%;
    height: 50vh;
    max-height: 60vh;
  }
  .game-iframe-container {
    max-width: 100%;
    transform: scale(0.95);
    transform-origin: top center;
    margin-bottom: 30px;
  }
  .player-left .game-info {
    margin-top: 200px;
    z-index: 3;
    min-height: 120px;
  }
  .player-right {
    display: none !important;
  }
  #related-games {
    display: none !important;
  }
  .related-games-mobile {
    display: block;
    margin-top: 8px;
  }
  nav ul {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
    gap: 8px;
    padding: 8px;
  }
  nav li {
    margin-right: 0;
    margin-bottom: 0;
  }
  nav a {
    display: block;
    padding: 8px;
    font-size: 14px;
    text-align: center;
  }
  .adsbygoogle {
    max-height: 15px;
    overflow: hidden;
  }
}

@media (max-width: 1000px) and (orientation: landscape) {
  .player-left .game-info {
    margin-top: 30px;
    min-height: 100px;
  }
  .related-games-mobile {
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  }
  nav ul {
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr)); /* Tăng để có 2-3 hàng */
    gap: 6px;
  }
  nav a {
    font-size: 13px;
    padding: 6px;
  }
  .search-results {
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  }
}

@media (max-width: 600px) {
  #game-list, .search-results, #related-games, #related-games-mobile {
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 8px;
    padding: 10px;
  }
  .game-card img {
    height: 100px;
  }
  h1 {
    margin-left: 0;
    margin-bottom: 8px;
    font-size: 20px;
    width: 100%;
    text-align: center;
  }
  .player-left .game-info {
    margin-top: 200px;
    z-index: 3;
    min-height: 120px;
  }
  .search-results {
    padding: 10px;
  }
  .search-results .related-card {
    width: 120px;
  }
  .search-results .related-card img {
    height: 80px;
  }
  #searchInput {
    width: 90%;
    max-width: 300px;
  }
  .fullscreen-button {
    padding: 6px 12px !important;
    font-size: 12px !important;
    min-height: 28px !important;
  }
  nav ul {
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
    gap: 6px;
  }
  nav a {
    font-size: 13px;
    padding: 6px;
  }
}