/* SmileGame factory — CrazyGames-inspired dark purple UI */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-body), system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

.app-shell {
  min-height: 100dvh;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
}
.skip-link:focus {
  left: 12px;
  z-index: 100;
  background: var(--accent);
  color: var(--accent-text);
  padding: 8px 12px;
  border-radius: 8px;
}

/* —— Topbar (CG-like) —— */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: color-mix(in srgb, var(--bg) 92%, #000);
  border-bottom: 1px solid color-mix(in srgb, #fff 6%, transparent);
  backdrop-filter: blur(10px);
}

.brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  white-space: nowrap;
  flex-shrink: 0;
}

.menu-btn {
  appearance: none;
  border: 0;
  background: var(--surface);
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  font-size: 1.1rem;
  cursor: pointer;
  flex-shrink: 0;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  max-width: 560px;
  margin-left: auto;
  padding: 0 12px;
  height: 40px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, #fff 8%, transparent);
}

.search-icon {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
}

.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  outline: none;
}

.search input::placeholder {
  color: var(--muted);
}

/* —— Layout —— */
.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}

.sidebar {
  display: none;
}

.main {
  padding: 12px 14px 72px;
  min-width: 0;
}

/* —— Sidebar / drawer nav —— */
.side-nav {
  padding: 8px 0 24px;
}

.nav-label {
  margin: 18px 12px 6px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-list a {
  display: block;
  padding: 9px 14px;
  margin: 1px 8px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  color: color-mix(in srgb, var(--text) 88%, var(--muted));
}

.nav-list a:hover {
  background: color-mix(in srgb, #fff 6%, transparent);
  color: var(--text);
}

.nav-list a.is-active {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: #fff;
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  visibility: hidden;
}

.drawer.is-open {
  pointer-events: auto;
  visibility: visible;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.drawer.is-open .drawer-backdrop {
  opacity: 1;
}

.drawer-panel {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(300px, 88vw);
  background: #12131c;
  border-right: 1px solid color-mix(in srgb, #fff 6%, transparent);
  padding: 12px;
  transform: translateX(-100%);
  transition: transform 0.22s ease;
  overflow-y: auto;
}

.drawer.is-open .drawer-panel {
  transform: translateX(0);
}

/* —— Category chips —— */
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 14px;
  margin: 0 -14px;
  padding-left: 14px;
  padding-right: 14px;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface);
  font-weight: 700;
  font-size: 0.85rem;
  color: color-mix(in srgb, var(--text) 85%, var(--muted));
  border: 1px solid color-mix(in srgb, #fff 5%, transparent);
}

.chip.is-active,
.chip:hover {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

/* —— Sections —— */
.section {
  margin: 0 0 28px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
}

.section-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

.section-more {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--accent);
  white-space: nowrap;
}

.section-more:hover {
  text-decoration: underline;
}

/* —— Game tiles (CG: rounded art + title overlay) —— */
.game-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.rail {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(132px, 42%);
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 6px;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
}

.game-tile {
  display: block;
  scroll-snap-align: start;
  transition: transform 0.15s ease;
}

.game-tile.is-hidden {
  display: none;
}

.game-tile:hover {
  transform: translateY(-2px);
}

.game-tile__art {
  position: relative;
  aspect-ratio: 1;
  border-radius: 16px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
}

.game-tile__art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.game-tile__shade {
  position: absolute;
  inset: auto 0 0;
  padding: 28px 10px 10px;
  background: linear-gradient(transparent, rgba(8, 9, 16, 0.92));
}

.game-tile__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.82rem;
  line-height: 1.25;
  color: #fff;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.game-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 1;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--accent);
  color: #fff;
}

.game-badge--top {
  background: #ff5a36;
}

.game-badge--hot {
  background: #ff2d78;
}

/* —— Play page —— */
.play-layout {
  display: grid;
  gap: 16px;
}

.play-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: #000;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, #fff 6%, transparent);
}

.play-stage iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.play-meta {
  padding: 14px 4px 0;
}

.play-meta h1 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 800;
}

.play-meta p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.play-rail {
  display: grid;
  gap: 12px;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

/* —— Legal / info pages —— */
.prose {
  max-width: 720px;
}

.prose h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.75rem;
  margin: 0 0 12px;
}

.prose h2 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.15rem;
  margin: 28px 0 8px;
}

.prose p,
.prose li {
  color: color-mix(in srgb, var(--text) 88%, var(--muted));
}

.prose a {
  color: var(--accent);
  text-decoration: underline;
}

.page-title {
  margin: 4px 0 16px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.55rem;
  letter-spacing: -0.02em;
}

.page-hero {
  margin: 4px 0 20px;
}

.page-hero h1 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.75rem;
}

.page-hero p {
  margin: 0;
  color: var(--muted);
}

.play-ads {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

/* —— Ads (newsnovels-style card slots) —— */
.gam-ad-wrap {
  display: flex;
  justify-content: center;
  margin: 0;
  width: 100%;
}

/* Collapse until a creative is actually present — no gray tall boxes */
.gam-ad-wrap:has(.gam-ad-slot:empty),
.gam-ad-wrap.is-empty {
  display: none !important;
  margin: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
}

.gam-ad-slot {
  display: block;
  width: max-content;
  max-width: 100%;
  min-height: 0;
  margin: 0 auto;
  overflow: hidden;
  line-height: 0;
}

.gam-ad-wrap:has(.gam-ad-slot iframe),
.gam-ad-wrap.is-filled {
  display: flex;
  margin: 16px 0;
}

.gam-ad-slot iframe {
  display: block;
  margin: 0 auto;
}

/* —— Footer —— */
.site-footer {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid color-mix(in srgb, #fff 6%, transparent);
  color: var(--muted);
  font-size: 0.85rem;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin-bottom: 10px;
}

.footer-nav a {
  font-weight: 600;
  color: color-mix(in srgb, var(--text) 75%, var(--muted));
}

.footer-nav a:hover {
  color: var(--accent);
}

/* —— Desktop —— */
@media (min-width: 900px) {
  .menu-btn {
    display: none;
  }

  .topbar {
    padding: 12px 20px;
    padding-left: 236px;
  }

  .layout {
    grid-template-columns: 220px 1fr;
  }

  .sidebar {
    display: block;
    position: sticky;
    top: 61px;
    height: calc(100dvh - 61px);
    overflow-y: auto;
    padding: 8px 0 24px;
    border-right: 1px solid color-mix(in srgb, #fff 6%, transparent);
    background: color-mix(in srgb, var(--bg) 70%, #0a0b12);
  }

  .main {
    padding: 18px 24px 48px;
  }

  .chips {
    margin: 0;
    padding-left: 0;
    padding-right: 0;
  }

  .game-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
  }

  .rail {
    grid-auto-columns: minmax(160px, 18%);
  }

  .related-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .play-layout {
    grid-template-columns: 1fr 300px;
    align-items: start;
  }

  .play-stage {
    aspect-ratio: 16 / 9;
    min-height: 480px;
  }

  .play-ads {
    margin-top: 0;
  }

  .play-ads .gam-ad-slot {
    max-width: 300px;
  }

  .game-tile__title {
    font-size: 0.9rem;
  }
}

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

  .rail {
    grid-auto-columns: minmax(170px, 15%);
  }
}
