/* ===== DESIGN TOKENS ===== */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #111827;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --primary: #1e90ff;
  --primary-dark: #1872cc;

  --cat-driving: #1ea7fd;
  --cat-girls: #ec4899;
  --cat-action: #f05454;
  --cat-adventure: #22c55e;
  --cat-shooting: #d6a84a;
  --cat-puzzle: #a855f7;
  --cat-sports: #10b981;
  --cat-arcade: #f59e0b;
  --cat-kids: #06b6d4;

  --radius: 14px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);

  --header-h: 64px;
  --drawer-w: 260px;
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font: inherit; border: none; background: none; }
ul, ol { list-style: none; }
select { font: inherit; }

/* ===== UTILITIES ===== */
.container { max-width: 1680px; margin: 0 auto; padding: 0 24px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  white-space: nowrap;
}
.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-dark); }
.btn--outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn--outline:hover { background: var(--primary); color: #fff; }
.btn--icon {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 14px;
  font-size: 13px;
}
.btn--icon:hover { border-color: var(--primary); color: var(--primary); }
.btn--icon svg { flex-shrink: 0; }

/* ===== HEADER ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.site-header__inner {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 100%;
  max-width: 1680px;
  margin: 0 auto;
  padding: 0 24px;
}
.site-logo {
  font-size: 20px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.5px;
  flex-shrink: 0;
}
.site-logo span { color: var(--text); }

/* Search bar */
.header-search {
  flex: 1;
  max-width: 520px;
  position: relative;
}
.header-search__input {
  width: 100%;
  padding: 9px 40px 9px 16px;
  border: 1.5px solid var(--border);
  border-radius: 24px;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.header-search__input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 144, 255, 0.12);
}
.header-search__btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  display: flex;
  align-items: center;
}
.header-search__btn:hover { color: var(--primary); }

/* Live search dropdown */
.live-search-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,.14);
  z-index: 500;
  overflow: hidden;
  max-height: 480px;
  overflow-y: auto;
}
.live-search-dropdown.open { display: block; }
.live-search-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  text-decoration: none;
  color: var(--text);
  transition: background 0.1s;
  border-bottom: 1px solid var(--border);
}
.live-search-item:last-child { border-bottom: none; }
.live-search-item:hover { background: rgba(30,144,255,.07); }
.live-search-item img {
  width: 44px; height: 44px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  background: var(--border);
}
.live-search-item__title {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.live-search-item__cat {
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: var(--primary);
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: capitalize;
  flex-shrink: 0;
}
.live-search-footer {
  display: block;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  text-align: center;
  border-top: 1px solid var(--border);
  text-decoration: none;
}
.live-search-footer:hover { background: rgba(30,144,255,.07); }
.live-search-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* Nav links */
.header-nav { display: flex; align-items: center; gap: 10px; margin-left: auto; }

/* Mobile search toggle button — hidden on desktop */
.btn-search-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  padding: 6px;
  border-radius: 8px;
  transition: background 0.15s;
}
.btn-search-toggle:hover { background: var(--border); }

/* Back arrow inside search — hidden on desktop */
.header-search__back {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  padding: 6px;
  flex-shrink: 0;
}
.btn-hamburger {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px;
  color: var(--text);
  border-radius: 8px;
  transition: background 0.15s;
  flex-shrink: 0;
}
.btn-hamburger:hover { background: var(--border); }
.btn-hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}

/* ===== SIDE DRAWER ===== */
.drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 200;
}
.drawer-overlay.open { display: block; }
.side-drawer {
  position: fixed;
  top: 0;
  left: 0;
  width: 280px;
  height: 100%;
  background: var(--surface);
  z-index: 201;
  transform: translateX(-100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  scrollbar-width: thin;
  padding-bottom: 32px;
}
.side-drawer.open { transform: translateX(0); }
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px 0 16px;
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.drawer-close {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}
.drawer-close:hover { background: var(--border); color: var(--text); }
.drawer-section { padding: 8px 0; }
.drawer-divider { height: 1px; background: var(--border); margin: 4px 0; }
.drawer-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
  border-radius: 0;
}
.drawer-link:hover { background: rgba(0,0,0,.05); }
.drawer-link.active { color: var(--primary); background: rgba(30,144,255,.06); }
.drawer-link__icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: var(--cat-color, #888);
}
.drawer-link__dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.drawer-tags-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.12s;
}
.drawer-tags-link:hover { color: var(--primary); }

/* ===== FEATURED ROW ===== */
.featured-row {
  margin-bottom: 24px;
  padding: 16px 20px 20px;
  background: linear-gradient(135deg, rgba(250,204,21,.08) 0%, var(--surface) 60%);
  border: 1px solid rgba(250,204,21,.3);
  border-radius: var(--radius);
}
.featured-row__header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.featured-row__star { color: #f59e0b; flex-shrink: 0; }
.featured-row__title { font-size: 18px; font-weight: 700; }
.featured-row__count { font-size: 13px; color: var(--text-muted); margin-left: 4px; }

/* ===== HOMEPAGE CATEGORY ROWS ===== */
.home-rows { padding: 20px 0 40px; }
.category-row { margin-bottom: 14px; }
.category-row__inner {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

/* Banner card — split design: solid color left, artwork image right */
.cat-banner {
  flex-shrink: 0;
  width: 252px;
  height: 190px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-decoration: none;
  color: #fff;
  background-color: var(--cat-color, var(--primary));
  background-size: auto 115%;
  background-position: right center;
  background-repeat: no-repeat;
  position: relative;
  overflow: hidden;
  transition: filter 0.18s, transform 0.18s;
  padding: 20px 22px;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
/* Left-to-right gradient: solid cat color → transparent, revealing image on right */
.cat-banner::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to right,
    var(--cat-color, #333) 32%,
    transparent 78%
  );
  pointer-events: none;
  z-index: 0;
}
.cat-banner:hover { filter: brightness(1.06); }
.cat-banner__text {
  position: relative;
  z-index: 1;
  max-width: 55%;
}
.cat-banner__name {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.15;
  text-shadow: 0 1px 6px rgba(0,0,0,.3);
  letter-spacing: -0.01em;
}
.cat-banner__count {
  font-size: 13px;
  opacity: 0.95;
  margin-top: 8px;
  font-weight: 600;
  text-shadow: 0 1px 4px rgba(0,0,0,.3);
}

/* Thumbnails row — Y8 style: horizontal scroll, square cards driven by row height */
.games-scroll-wrap {
  flex: 1;
  position: relative;
  height: 190px;
  min-width: 0;
  overflow: hidden;
}
.games-scroll {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  height: 100%;
  align-items: stretch;
  padding-right: 32px;
}
.games-scroll::-webkit-scrollbar { display: none; }
.scroll-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 4;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,.95);
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #333;
  transition: background 0.15s, color 0.15s, transform 0.15s;
  cursor: pointer;
}
.scroll-btn:hover { background: var(--primary); color: #fff; transform: translateY(-50%) scale(1.08); }
.scroll-btn--right { right: 6px; }
[dir="rtl"] .scroll-btn--right { right: auto; left: 6px; }
[dir="rtl"] .scroll-btn--right svg { transform: scaleX(-1); }

/* ===== GAME THUMBNAIL CARD ===== */
.game-card {
  flex-shrink: 0;
  width: 148px;
  scroll-snap-align: start;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

/* In scroll rows: square cards, fixed pixel size driven by row height */
.games-scroll .game-card {
  flex-shrink: 0;
  width: 190px;
  height: 190px;
  scroll-snap-align: start;
  background: transparent;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  border-radius: 8px;
  overflow: hidden;
  transition: transform 0.18s, box-shadow 0.18s;
}
.games-scroll .game-card__thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.games-scroll .game-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,.18);
}
.games-scroll .game-card__thumb-wrap {
  width: 100%;
  height: 100%;
  border-radius: 8px;
}
/* Hide titles inside home scroll rows — Y8 shows image only */
.games-scroll .game-card__title { display: none; }

.game-card__thumb-wrap {
  width: 148px;
  height: 111px;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  /* gradient placeholder for broken/loading images */
  background: linear-gradient(135deg, #dde1e7 0%, #c8cdd6 100%);
}
.game-card__thumb-wrap::before {
  content: '🎮';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  opacity: 0.25;
}
.game-card__thumb {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.22s;
  display: block;
}
.game-card:hover .game-card__thumb { transform: scale(1.06); }
.game-card__ribbon {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 2;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  padding: 3px 7px;
  border-radius: 0 0 0 6px;
  letter-spacing: 0.04em;
}
.game-card__title {
  font-size: 12px;
  font-weight: 600;
  margin-top: 5px;
  padding: 0 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== GAMES GRID (category page / search) ===== */
.games-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 8px;
  margin-top: 16px;
}
.games-grid--small { grid-template-columns: repeat(6, 1fr); }
.games-grid .game-card {
  width: auto;
  background: transparent;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  transition: transform 0.18s, box-shadow 0.18s;
}
.games-grid .game-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
}
.games-grid .game-card__thumb-wrap {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
}
.games-grid--notitle .game-card__title { display: none; }

/* ===== CATEGORY HERO — Y8 style: rounded banner with icon + artwork ===== */
.category-hero {
  position: relative;
  display: flex;
  align-items: center;
  gap: 20px;
  background-color: var(--cat-color, var(--primary));
  background-size: auto 115%;
  background-position: right center;
  background-repeat: no-repeat;
  color: #fff;
  padding: 22px 28px;
  min-height: 150px;
  border-radius: 12px;
  overflow: hidden;
  margin-top: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.category-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to right,
    var(--cat-color, var(--primary)) 38%,
    transparent 78%
  );
  pointer-events: none;
  z-index: 0;
}
.category-hero__icon {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  width: 68px;
  height: 68px;
  border-radius: 14px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.category-hero__text {
  position: relative;
  z-index: 1;
  flex: 1;
  min-width: 0;
  max-width: 60%;
}
.category-hero h1 {
  font-size: clamp(22px, 3vw, 32px);
  font-weight: 800;
  margin: 0 0 6px;
  line-height: 1.15;
  text-shadow: 0 1px 6px rgba(0,0,0,.25);
}
.category-hero__desc {
  font-size: 14px;
  opacity: 0.95;
  line-height: 1.5;
  text-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.category-hero__count {
  display: inline-block;
  margin-top: 10px;
  font-size: 12px;
  background: rgba(255,255,255,.22);
  border-radius: 20px;
  padding: 3px 12px;
  font-weight: 600;
}

/* ===== POPULAR TAGS BAR ===== */
.tags-bar {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.tags-bar__label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  flex-shrink: 0;
}
.tag-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  font-weight: 500;
  transition: background 0.12s, border-color 0.12s, transform 0.12s;
}
.tag-chip__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.tag-chip:hover { border-color: var(--cat-color, var(--primary)); transform: translateY(-1px); }
.tag-chip.active {
  background: var(--cat-color, var(--primary));
  color: #fff;
  border-color: var(--cat-color, var(--primary));
}
.tag-chip.active .tag-chip__dot { background: #fff !important; }

/* ===== TOOLBAR (sort + pagination) ===== */
.category-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
  flex-wrap: wrap;
}

/* SEO long description + FAQ below the games */
.category-seo {
  margin: 40px 0 24px;
  padding: 24px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.category-seo__title {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 16px;
  color: var(--text);
}
.category-seo__body {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  max-height: 4.8em;
  overflow: hidden;
  position: relative;
  transition: max-height 0.3s ease;
}
.category-seo__body.expanded {
  max-height: 4000px;
}
.category-seo__body p { margin-bottom: 12px; }
.category-seo__body p:last-child { margin-bottom: 0; }
.category-seo__body:not(.expanded)::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 36px;
  background: linear-gradient(to bottom, transparent, var(--surface));
  pointer-events: none;
}
.category-seo__toggle {
  margin-top: 12px;
  color: var(--primary);
  font-size: 14px;
  font-weight: 700;
  padding: 0;
}
.category-seo__toggle:hover { text-decoration: underline; }

.category-faq {
  margin: 24px 0 40px;
  padding: 24px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.category-faq__title {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 16px;
}
.category-faq__list { display: flex; flex-direction: column; gap: 8px; }
.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.faq-item__q {
  padding: 14px 18px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  transition: background 0.15s;
}
.faq-item__q:hover { background: rgba(30,144,255,.04); }
.faq-item__q::-webkit-details-marker { display: none; }
.faq-item__q::after {
  content: '+';
  font-size: 22px;
  font-weight: 400;
  color: var(--primary);
  transition: transform 0.2s;
  line-height: 1;
}
.faq-item[open] .faq-item__q::after { transform: rotate(45deg); }
.faq-item__a {
  padding: 0 18px 16px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
}
.sort-select {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.pagination--bottom { margin: 24px 0 12px; }

/* ===== PAGINATION ===== */
.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  padding: 32px 0 40px;
  flex-wrap: wrap;
}
.page-link {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: background 0.12s, color 0.12s;
}
.page-link:hover, .page-link.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-link--disabled { opacity: 0.4; pointer-events: none; }

/* ===== GAME PAGE ===== */

/* Two-column layout: game fills available space, sidebar fixed 252px */
.game-layout {
  display: grid;
  grid-template-columns: 1fr 252px;
  gap: 20px;
}
.game-layout__main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Ad + game pushed right toward the sidebar */
.game-player-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  align-self: flex-end;
  max-width: 100%;
}
.game-content-stack {
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: calc((100vh - 210px) * var(--aspect-w, 4) / var(--aspect-h, 3));
  max-width: 100%;
}
.ad-slot--skyscraper {
  flex-shrink: 0;
  width: 160px;
  min-height: 600px;
  background: #e2e8f0;
  border-radius: var(--radius);
  border: 2px dashed #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: flex-start;
}
.side-games-grid {
  flex-shrink: 0;
  width: 200px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-self: flex-start;
  position: sticky;
  top: 72px;
  max-height: calc(100vh - 88px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  padding-bottom: 20px;
}
.side-games-grid::-webkit-scrollbar { width: 3px; }
.side-games-grid::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.side-games-grid .game-card {
  width: auto;
  background: transparent;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
  transition: transform 0.18s, box-shadow 0.18s;
}
.side-games-grid .game-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
}
.side-games-grid .game-card__thumb-wrap {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  border-radius: 0;
}
.side-games-grid .game-card__title {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 5px 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0;
}
.game-player-row .game-player {
  min-width: 0;
  margin-top: 0;
  width: 100%;
}
.ad-slot--left-skyscraper {
  flex-shrink: 0;
  width: 160px;
  min-height: 600px;
  background: #e2e8f0;
  border-radius: var(--radius);
  border: 2px dashed #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  position: sticky;
  top: 72px;
}
.ad-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: #94a3b8;
  user-select: none;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  padding: 20px;
  letter-spacing: .3px;
}
.ad-placeholder svg { color: #94a3b8; }
.ad-placeholder__size {
  font-size: 11px;
  font-weight: 400;
  font-family: monospace;
  background: #f1f5f9;
  color: #64748b;
  border-radius: 4px;
  padding: 3px 8px;
  border: 1px solid #e2e8f0;
}

/* Frame fills the game-player (which is already capped by viewport height) */
.game-layout__main .game-player__frame-wrap {
  max-width: none;
  margin: 0;
  width: 100%;
}
.game-layout__main .game-player__controls  { max-width: none; margin-left: 0; margin-right: 0; }
.game-layout__main .game-info              { max-width: none; margin-left: 0; margin-right: 0; }

/* Sticky sidebar that scrolls independently */
.game-layout__sidebar {
  position: sticky;
  top: 72px;
  max-height: calc(100vh - 88px);
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  padding-bottom: 20px;
}
.game-layout__sidebar::-webkit-scrollbar { width: 3px; }
.game-layout__sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.play-next-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--accent);
}
.play-next-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.play-next-grid .game-card {
  width: auto;
  background: transparent;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
  transition: transform 0.18s, box-shadow 0.18s;
}
.play-next-grid .game-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
}
.play-next-grid .game-card__thumb-wrap {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  border-radius: 0;
}
.play-next-grid .game-card__title {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 5px 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0;
}

.game-player { margin-top: 16px; }
.game-player__frame-wrap {
  position: relative;
  width: 100%;
  max-width: 1024px;
  margin: 0 auto;
  aspect-ratio: calc(var(--aspect-w, 4)) / calc(var(--aspect-h, 3));
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.game-player__frame-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}
.game-player__controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  max-width: 1024px;
  margin-left: auto;
  margin-right: auto;
}
.play-counter { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--text-muted); margin-left: auto; }

.game-info { max-width: 1024px; margin: 24px auto 0; }
.game-info h1 { font-size: clamp(22px, 3vw, 36px); font-weight: 800; }
.game-info__description { color: var(--text-muted); margin-top: 10px; max-width: 680px; line-height: 1.7; }
.game-info__howto { margin-top: 14px; margin-bottom: 18px; max-width: 680px; }
.game-info__howto-title { font-size: 0.85rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--primary); margin-bottom: 8px; }
.game-info__howto-body { color: var(--text-muted); line-height: 1.7; font-size: 0.95rem; }
.game-info__howto-body ul { margin: 8px 0 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 5px; }
.game-info__howto-body li { padding-left: 20px; position: relative; }
.game-info__howto-body li::before { content: '▸'; position: absolute; left: 0; color: var(--primary); font-size: 0.8rem; top: 2px; }
[dir="rtl"] .game-info__howto-body li { padding-left: 0; padding-right: 20px; }
[dir="rtl"] .game-info__howto-body li::before { left: auto; right: 0; }
.game-info__tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; margin-bottom: 18px; }
.game-tag {
  font-size: 13px;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.related-games { max-width: 1024px; margin: 36px auto 48px; }
.related-games h2 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }

/* ===== SEARCH PAGE ===== */
.search-page { padding: 32px 0; }
.search-page__header { margin-bottom: 20px; }
.search-page__header h1 { font-size: 24px; font-weight: 700; }
.search-page__header p { color: var(--text-muted); margin-top: 4px; }

/* ===== BREADCRUMB ===== */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.breadcrumb a:hover { color: var(--primary); text-decoration: underline; }

/* ===== SEO TEXT BLOCK ===== */
.seo-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 32px;
  margin: 24px 0 32px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
}
.seo-block h1 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.seo-block h1 .seo-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.seo-block p { margin-bottom: 10px; color: var(--text-muted); }
.seo-block strong { color: var(--text); font-weight: 600; }
.seo-block a { color: var(--primary); text-decoration: underline; }
.seo-block h2 { font-size: 14px; font-weight: 700; margin: 16px 0 4px; color: var(--text); }
.seo-block ul { margin: 6px 0 10px 18px; color: var(--text-muted); }
.seo-block ul li { margin-bottom: 4px; }
.seo-block__collapsed .seo-extra { display: none; }
.seo-block__toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-muted);
  margin-top: 10px;
  transition: border-color 0.15s, color 0.15s;
}
.seo-block__toggle:hover { border-color: var(--primary); color: var(--primary); }

/* ===== FOOTER ===== */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 32px 0;
  margin-top: auto;
}
.site-footer__inner {
  max-width: 1680px;
  margin: 0 auto;
  padding: 0 24px;
  display: grid;
  grid-template-columns: 2fr repeat(3, 1fr);
  gap: 32px;
}
.footer-brand__logo { font-size: 18px; font-weight: 800; color: var(--primary); }
.footer-brand__logo span { color: var(--text); }
.footer-brand p { font-size: 13px; color: var(--text-muted); margin-top: 8px; max-width: 220px; }
.footer-col h4 { font-size: 13px; font-weight: 700; margin-bottom: 12px; }
.footer-col a {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
  transition: color 0.12s;
}
.footer-col a:hover { color: var(--primary); }
.site-footer__bottom {
  max-width: 1680px;
  margin: 24px auto 0;
  padding: 16px 24px 0;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

/* ===== ERROR PAGE ===== */
.error-page__inner { text-align: center; padding: 80px 16px; }
.error-page__inner h1 { font-size: 96px; font-weight: 900; color: var(--border); }
.error-page__inner p { font-size: 18px; color: var(--text-muted); margin: 16px 0 24px; }

/* ===== LOADING SKELETON ===== */
.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, #eef0f4 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ===== BREAKPOINTS ===== */
@media (max-width: 1680px) {
  .games-grid { grid-template-columns: repeat(8, 1fr); }
}
@media (max-width: 1280px) {
  .games-grid { grid-template-columns: repeat(7, 1fr); }
}
@media (max-width: 1024px) {
  .games-grid { grid-template-columns: repeat(5, 1fr); }
  .games-grid--small { grid-template-columns: repeat(4, 1fr); }
  .site-footer__inner { grid-template-columns: 1fr 1fr; gap: 24px; }
  .cat-banner { width: 210px; height: 160px; }
  .games-scroll-wrap { height: 160px; }
  .games-scroll .game-card { width: 160px; height: 160px; }
  .game-card { width: 130px; }
  .game-card__thumb-wrap { width: 130px; height: 98px; }
  /* Collapse sidebar below game on tablet — hide side rails */
  .game-layout { grid-template-columns: 1fr; max-width: none; }
  .ad-slot--left-skyscraper,
  .ad-slot--skyscraper,
  .side-games-grid { display: none; }
  .game-player-row { display: block; }
  .game-layout__sidebar { position: static; max-height: none; overflow: visible; }
  .game-layout__main .game-player__frame-wrap { max-width: 1024px; margin: 0 auto; }
  .game-layout__main .game-player__controls  { max-width: 1024px; margin-left: auto; margin-right: auto; }
  .game-layout__main .game-info              { max-width: 1024px; margin-left: auto; margin-right: auto; }
  .play-next-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 640px) {
  .header-nav .btn--outline, .header-nav .btn--primary { display: none; }

  /* Hide search bar by default on mobile */
  .header-search { display: none; }

  /* Show search toggle icon */
  .btn-search-toggle { display: flex; }

  /* When search is open — show search as full overlay */
  .site-header.search-open .header-search {
    display: flex;
    position: absolute;
    inset: 0;
    z-index: 200;
    background: var(--surface);
    padding: 0 12px;
    align-items: center;
    gap: 6px;
    border-bottom: 1px solid var(--border);
  }
  .site-header.search-open .header-search__back { display: flex; }
  .site-header.search-open .btn-search-toggle { display: none; }
  .site-header.search-open .btn-hamburger,
  .site-header.search-open .site-logo { visibility: hidden; }

  /* Dropdown full width on mobile */
  .live-search-dropdown { left: 0; right: 0; border-radius: 0; border-left: none; border-right: none; }

  /* Mobile: banner full-width on top, thumbnails scroll below */
  .category-row__inner { flex-direction: column; gap: 8px; }
  .cat-banner { width: 100%; height: 110px; }
  .cat-banner__name { font-size: 20px; }
  .games-scroll-wrap { width: 100%; height: 130px; }
  .games-scroll .game-card { width: 130px; height: 130px; }
  .games-scroll { gap: 6px; }

  .games-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .games-grid--small { grid-template-columns: repeat(2, 1fr); }
  .site-footer__inner { grid-template-columns: 1fr; }
  .category-hero { min-height: 120px; }
  .play-next-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
}

/* ===== LANGUAGE SWITCHER ===== */
.lang-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 16px 8px;
}
.lang-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.lang-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.lang-btn--active { background: var(--primary); color: #fff; border-color: var(--primary); }
.lang-btn__flag { width: 20px; height: 15px; object-fit: cover; border-radius: 2px; display: inline-block; vertical-align: middle; }
.lang-btn__code { letter-spacing: 0.03em; }

/* ===== RTL SUPPORT (Arabic) ===== */
[dir="rtl"] {
  text-align: right;
}
[dir="rtl"] .site-header__inner {
  flex-direction: row-reverse;
}
[dir="rtl"] .side-drawer {
  left: auto;
  right: 0;
  transform: translateX(100%);
}
[dir="rtl"] .side-drawer.open {
  transform: translateX(0);
}
[dir="rtl"] .drawer-link {
  flex-direction: row-reverse;
}
[dir="rtl"] .drawer-link__icon {
  margin-right: 0;
  margin-left: 10px;
}
[dir="rtl"] .site-footer__inner {
  direction: rtl;
}
[dir="rtl"] .category-hero__breadcrumb {
  flex-direction: row-reverse;
}
[dir="rtl"] .games-grid {
  direction: rtl;
}
[dir="rtl"] .game-card__ribbon {
  left: 6px;
  right: auto;
}
[dir="rtl"] .header-search {
  flex-direction: row-reverse;
}
[dir="rtl"] .lang-switcher {
  flex-direction: row-reverse;
}

/* ===== STATIC PAGES ===== */
.static-page {
  max-width: 800px;
  margin: 32px auto;
  padding: 0 16px;
}
.static-page__content {
  background: var(--surface);
  border-radius: 12px;
  padding: 32px;
  margin-top: 16px;
  line-height: 1.8;
  color: var(--text);
}
.static-page__content h2 { font-size: 1.5rem; margin: 0 0 12px; }
.static-page__content h3 { font-size: 1.1rem; margin: 24px 0 8px; color: var(--primary); }
.static-page__content p  { margin: 0 0 14px; }
.static-page__content a  { color: var(--primary); }
