.game-grid {
  width: min(1600px, 96vw);
  display: grid;
  grid-template-columns: repeat(auto-fill, 320px);
  gap: 24px;
  margin-bottom: 80px;
  justify-content: center;
}

.game-tile {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 1 / 1;
  width: 100%;
  background: rgba(0, 0, 0, 0.25);
  animation: tileFadeIn 0.35s ease both;
}

@keyframes tileFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.game-tile-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}

.game-tile:hover .game-tile-img {
  transform: scale(1.06);
}

.game-tile-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 14px;
  background: linear-gradient(180deg, transparent 20%, rgba(0, 0, 0, 0.85) 100%);
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.game-tile:hover .game-tile-overlay {
  opacity: 1;
}

.game-tile-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.game-tile-plays {
  margin-top: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.75);
}

.game-tile--link .game-tile-desc {
  margin-top: 4px;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.8);
  line-height: 1.35;
}

.game-grid-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.95rem;
}

@media (max-width: 1200px) {
  .game-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

@media (max-width: 900px) {
  .game-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 720px) {
  .game-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
  .game-tile-overlay {
    padding: 10px;
  }
  .game-tile-title {
    font-size: 0.82rem;
  }
}

.popular-games {
  width: min(1200px, 96vw);
  margin: 20px auto 28px;
  display: none;
  padding: 0;
}

.popular-games-title {
  font-size: 0.8rem;
  font-weight: 900;
  margin: 0 0 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.popular-games-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
}

.popular-game-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  border-radius: 12px;
  overflow: hidden;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.popular-game-item:hover {
  transform: translateY(-2px);
  opacity: 0.95;
}

.popular-game-media {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.2);
}

.popular-game-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.popular-game-rank {
  position: absolute;
  top: 6px;
  left: 6px;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.6rem;
  font-weight: 900;
  color: var(--accent-text);
  background: var(--accent);
}

.popular-game-plays {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--accent-strong);
  text-align: center;
}

@media (max-width: 720px) {
  .popular-games-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }

  .popular-game-plays {
    font-size: 0.7rem;
  }
}

.controls {
  width: min(1100px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 10px;
}

.search-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

#game-search {
  flex: 1 1 240px;
  padding: 13px 20px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-weight: 700;
  outline: none;
  box-shadow: 0 8px 18px var(--shadow);
  font-family: inherit;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}

#game-search:focus {
  border-color: var(--accent-soft);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 18px var(--shadow), 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
}

#game-search::placeholder {
  color: var(--muted);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

#sort-dropdown {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  min-width: 180px;
  padding: 10px 42px 10px 16px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background:
    linear-gradient(45deg, transparent 50%, var(--text) 50%),
    linear-gradient(135deg, var(--text) 50%, transparent 50%),
    linear-gradient(90deg, rgba(255,255,255,0.25), rgba(255,255,255,0.25)),
    rgba(255, 255, 255, 0.12);
  background-position:
    calc(100% - 18px) 16px,
    calc(100% - 12px) 16px,
    calc(100% - 2.2rem) 50%,
    0 0;
  background-size: 6px 6px, 6px 6px, 1px 60%, auto;
  background-repeat: no-repeat;
  color: var(--text);
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: lowercase;
  cursor: pointer;
  box-shadow: 0 10px 18px var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#sort-dropdown:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 22px var(--shadow);
}

#sort-dropdown:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.55);
  outline-offset: 3px;
}

#sort-dropdown option {
  background: var(--bg-deep);
  color: var(--text);
  font-weight: 800;
}

.control-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-weight: 800;
  padding: 10px 18px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.25s ease;
  font-family: inherit;
}

.control-btn:hover,
.control-btn.active {
  transform: translateY(-2px);
  box-shadow: 0 10px 18px var(--shadow);
  background: color-mix(in srgb, var(--accent) 25%, transparent);
  border-color: rgba(255, 255, 255, 0.15);
}


.player-shell {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: auto;
}

.player-shell.hidden {
  display: none;
}

.player-content {
  width: 100%;
  max-width: 1100px;
  max-height: 95vh;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  margin: 0 auto;
}

.player-content.is-maximized {
  max-width: 100%;
  max-height: 100vh;
  border-radius: 0;
}

.player-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.player-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.player-btn {
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: var(--text);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  text-transform: lowercase;
}

.player-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.player-iframe {
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 1100px;
  border: none;
  background: #000;
}

@media (max-width: 768px) {
  .player-shell {
    padding: 0;
  }
  
  .player-content {
    max-width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }
  
  .player-header {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }
  
  .player-actions {
    justify-content: stretch;
  }
  
  .player-btn {
    flex: 1;
  }
  
  .player-iframe {
    aspect-ratio: 1 / 1;
    max-height: 600px;
  }
  
  .controls {
    width: 94vw;
  }
  
  .search-wrap {
    flex-direction: column;
    align-items: stretch;
  }
  
  #game-search {
    width: 100%;
  }
  
  .filters {
    flex-direction: column;
  }
  
  #sort-dropdown,
  .control-btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .game-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  
  .player-iframe {
    aspect-ratio: 1 / 1;
    max-height: 400px;
  }
}

@media (orientation: landscape) and (max-height: 600px) {
  .player-iframe {
    aspect-ratio: 1 / 1;
    max-height: 500px;
  }
}

@media (min-width: 1600px) {
  .game-grid {
    grid-template-columns: repeat(10, 1fr);
  }
}

@media (min-width: 2000px) {
  .game-grid {
    grid-template-columns: repeat(12, 1fr);
  }
}
