@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600;700&display=swap');

:root {
  --bg: #5cb83a;
  --sidebar-bg: #111;
  --sidebar-width: 60px;
  --card-radius: 12px;
  --gap: 6px;
  --accent: #ff6b35;
  --text: #fff;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }

body {
  font-family: 'Fredoka', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
}

/* === LEFT SIDEBAR === */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem 0;
  gap: 1rem;
  z-index: 100;
  border-right: 2px solid #333;
}

.sidebar-logo {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  text-decoration: none;
}

.sidebar-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #888;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.sidebar-icon:hover {
  background: #333;
  color: #fff;
}

.sidebar-icon.active {
  background: var(--accent);
  color: #fff;
}

.sidebar-spacer { flex: 1; }

.sidebar-cta {
  width: 48px;
  padding: 0.5rem 0;
  background: #222;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  text-decoration: none;
  font-size: 0.5rem;
  color: #aaa;
  text-align: center;
  line-height: 1.1;
}

/* === MAIN CONTENT === */
.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--gap);
}

/* === SEARCH BAR (top) === */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 0.5rem 0;
  display: flex;
  justify-content: center;
  margin-bottom: var(--gap);
}

.search-wrapper {
  position: relative;
  width: 100%;
  max-width: 400px;
}

.search-wrapper input {
  width: 100%;
  padding: 0.6rem 1rem 0.6rem 2.5rem;
  background: rgba(0,0,0,0.25);
  border: 2px solid rgba(0,0,0,0.15);
  border-radius: 99px;
  color: #fff;
  font-family: 'Fredoka', sans-serif;
  font-size: 0.9rem;
  outline: none;
  transition: all 0.2s;
}

.search-wrapper input::placeholder { color: rgba(255,255,255,0.6); }
.search-wrapper input:focus { background: rgba(0,0,0,0.35); border-color: rgba(0,0,0,0.3); }

.search-wrapper::before {
  content: '🔍';
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.8rem;
}

#search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 0.5rem;
  background: #1a1a1a;
  border: 2px solid #333;
  border-radius: 12px;
  max-height: 320px;
  overflow-y: auto;
  display: none;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}

#search-results.active { display: block; }

.search-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  text-decoration: none;
  color: #fff;
  transition: background 0.15s;
}

.search-item:hover { background: #2a2a2a; }
.search-item img { width: 36px; height: 36px; border-radius: 8px; object-fit: cover; }
.search-item strong { font-size: 0.8rem; display: block; }
.search-item small { color: #888; font-size: 0.65rem; }

.search-empty { padding: 1rem; color: #666; text-align: center; font-size: 0.8rem; }

/* === GAME GRID (masonry-style dense) === */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  grid-auto-rows: 100px;
  gap: var(--gap);
}

.games-grid.mixed {
  grid-template-columns: repeat(8, 1fr);
  grid-auto-rows: 100px;
}

.game-card {
  position: relative;
  border-radius: var(--card-radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  text-decoration: none;
  display: block;
}

.game-card:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  z-index: 5;
}

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

/* Sizes */
.game-card.large {
  grid-column: span 3;
  grid-row: span 3;
}

.game-card.tall {
  grid-row: span 2;
}

.game-card.wide {
  grid-column: span 2;
}

.game-card.medium {
  grid-column: span 2;
  grid-row: span 2;
}

/* === HOVER OVERLAY === */
.game-card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.3) 40%, transparent 70%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0.6rem;
  opacity: 0;
  transition: opacity 0.2s;
}

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

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

.overlay-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.game-card.large .overlay-title { font-size: 1.1rem; }

.overlay-cat {
  font-size: 0.6rem;
  color: #aaa;
  margin-top: 0.15rem;
}

.overlay-play {
  display: none;
}

.game-card.large .overlay-play,
.game-card.wide .overlay-play {
  display: inline-block;
  margin-top: 0.4rem;
  background: var(--accent);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.3rem 0.7rem;
  border-radius: 99px;
  width: fit-content;
}

/* === GAME PAGE === */
.game-page-layout {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.game-frame-wrapper {
  position: relative;
  flex: 1;
  background: #000;
  border-radius: var(--card-radius);
  overflow: hidden;
  margin-bottom: var(--gap);
}

.game-frame-wrapper iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.fullscreen-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: rgba(0,0,0,0.7);
  border: none;
  color: #fff;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  z-index: 10;
  transition: background 0.2s;
}

.fullscreen-btn:hover { background: var(--accent); }

.game-info-section {
  padding: 0.75rem;
  background: rgba(0,0,0,0.2);
  border-radius: var(--card-radius);
  margin-bottom: var(--gap);
}

.game-info-section h1 {
  font-size: 1.25rem;
  margin-bottom: 0.25rem;
}

.game-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.5rem;
}

.tag {
  padding: 0.2rem 0.5rem;
  background: rgba(0,0,0,0.2);
  border-radius: 99px;
  font-size: 0.6rem;
  color: rgba(255,255,255,0.7);
}

.game-desc {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.7);
  line-height: 1.5;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

/* === CATEGORY PILLS === */
.categories-bar {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: var(--gap);
  scrollbar-width: none;
}

.categories-bar::-webkit-scrollbar { display: none; }

.cat-pill {
  flex-shrink: 0;
  padding: 0.4rem 0.85rem;
  background: rgba(0,0,0,0.2);
  border: 2px solid rgba(0,0,0,0.1);
  border-radius: 99px;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s;
  white-space: nowrap;
}

.cat-pill:hover, .cat-pill.active {
  background: rgba(0,0,0,0.4);
  border-color: rgba(0,0,0,0.3);
  transform: translateY(-1px);
}

/* === PAGE HEADER === */
.page-header {
  margin-bottom: 1rem;
}

.page-header h1 {
  font-size: 1.5rem;
  text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.page-header p {
  color: rgba(255,255,255,0.7);
  font-size: 0.85rem;
}

/* === AD SLOTS === */
.ad-slot {
  background: rgba(0,0,0,0.1);
  border: 2px dashed rgba(0,0,0,0.15);
  border-radius: var(--card-radius);
  padding: 0.75rem;
  text-align: center;
  color: rgba(255,255,255,0.4);
  font-size: 0.7rem;
  margin: var(--gap) 0;
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* === FOOTER === */
.footer {
  padding: 1.5rem;
  text-align: center;
  color: rgba(255,255,255,0.5);
  font-size: 0.75rem;
}

.footer-inner { max-width: 600px; margin: 0 auto; }
.footer-sub { margin-top: 0.25rem; font-size: 0.65rem; }

/* === RESPONSIVE === */
@media (max-width: 1400px) {
  .games-grid.mixed { grid-template-columns: repeat(7, 1fr); }
}

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

@media (max-width: 900px) {
  .games-grid.mixed { grid-template-columns: repeat(4, 1fr); grid-auto-rows: 90px; }
  .games-grid { grid-template-columns: repeat(4, 1fr); grid-auto-rows: 90px; }
}

@media (max-width: 600px) {
  :root { --sidebar-width: 0px; }
  .sidebar { display: none; }
  .games-grid.mixed, .games-grid { grid-template-columns: repeat(3, 1fr); grid-auto-rows: 80px; }
  .game-card.large { grid-column: span 2; grid-row: span 2; }
  .game-card-overlay { opacity: 1; background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 50%); }
  .overlay-play { display: none !important; }
}
