.section { margin-top: 14px; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.section-title {
  margin: 0;
  font-size: 14px;
  color: var(--text);
}

.muted { color: var(--muted); font-size: 12px; }

.link-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 10px;
}
.link-btn:hover { background: rgba(255,255,255,0.05); }

/* Carousel */
.carousel {
  margin-top: 10px;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(240px, 1fr);
  gap: 12px;

  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  padding-bottom: 6px;
}

.carousel.small {
  grid-auto-columns: minmax(160px, 1fr);
}

.carousel::-webkit-scrollbar { height: 10px; }
.carousel::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.12);
  border-radius: 999px;
}

/* Carousel cards */
.game-card.featured {
  min-height: 190px;
  scroll-snap-align: start;
  position: relative;
}

.game-card.compact {
  min-height: 150px;
  scroll-snap-align: start;
  position: relative;
}

.badge {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 11px;
  padding: 5px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(2, 6, 23, 0.7);
  backdrop-filter: blur(6px);
  color: var(--text);
}
.badge.ok { border-color: rgba(34,197,94,0.5); }

/* Make thumbs slightly larger for featured */
.game-card.featured .thumb { aspect-ratio: 16 / 8; }

/* ---------- THEME (Dark/Light) ---------- */
html[data-theme="dark"] {
  --bg: #0f172a;
  --panel: #020617;
  --border: #1e293b;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --accent: #22c55e;
  --accentText: #022c22;
}

html[data-theme="light"] {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --border: #e5e7eb;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #0ea5e9;
  --accentText: #072b3a;
}

body {
  background: var(--bg);
  color: var(--text);
}

/* Top bar minor tweaks */
.top-bar__search {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 12px 12px;
}

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  cursor: pointer;
}

.icon-btn:active { transform: translateY(1px); }

.brand {
  margin: 0;
  font-size: 16px;
  letter-spacing: 1px;
}

/* Views */
.view.hidden { display: none; }

/* Categories row */
.category-row {
  margin-top: 10px;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(120px, 1fr);
  gap: 10px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding-bottom: 6px;
}

.category-tile {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  display: grid;
  gap: 6px;
  align-content: center;
  min-height: 70px;
  cursor: pointer;
  scroll-snap-align: start;
}

.category-tile .emoji { font-size: 18px; }
.category-tile .label { font-size: 13px; color: var(--text); }
.category-tile:active { transform: translateY(1px); }

/* Categories full page grid */
.category-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

/* Bottom nav */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: var(--panel);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 8px 6px env(safe-area-inset-bottom);
}

.nav-item {
  border: 0;
  background: transparent;
  color: var(--muted);
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 6px 4px;
  border-radius: 12px;
  cursor: pointer;
}

.nav-item span {
  font-size: 11px;
}

.nav-item.active {
  color: var(--text);
  background: rgba(255,255,255,0.06);
}

.with-bottom-nav {
  padding-bottom: 90px; /* keep content above bottom nav */
}

/* Card quick actions (favorite + offline download) */
.card-icons {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  gap: 8px;
  z-index: 2;
}

.mini-btn {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(2, 6, 23, 0.65);
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
  backdrop-filter: blur(6px);
}

html[data-theme="light"] .mini-btn {
  background: rgba(255,255,255,0.7);
  border-color: rgba(15,23,42,0.15);
}

.mini-btn:active { transform: translateY(1px); }

/* ---------- FULLSCREEN PLAY MODAL (fix) ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.72);
  z-index: 9999;              /* MUST be above bottom nav */
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
  pointer-events: auto;       /* ensure backdrop accepts clicks */
}

.modal {
  width: 100%;
  height: 100%;
  background: var(--panel);
  border: 0;
  border-radius: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.modal-header h2 {
  font-size: 14px;
  margin: 0;
  color: var(--text);
}

.modal-close {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  cursor: pointer;
}

.modal-body {
  flex: 1 1 auto;
  background: #000;
  position: relative;
  overflow: hidden;
}

.modal-body iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  pointer-events: auto;  /* MUST allow clicks inside iframe */
}

body.modal-open {
  overflow: hidden;
  touch-action: none;
}
/* ---------- PLAY PAGE ---------- */
.play-page {
  margin: 0;
  height: 100vh;
  overflow: hidden;
}

.play-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  z-index: 9999;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
}

.play-title {
  flex: 1;
  min-width: 0;
  display: grid;
}

.play-title__name {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.play-title__meta {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.play-actions {
  display: flex;
  gap: 8px;
}

.play-btn {
  height: 40px;
  min-width: 40px;
  padding: 0 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  cursor: pointer;
}

.play-btn:active { transform: translateY(1px); }

.play-stage {
  position: fixed;
  inset: 56px 0 0 0; /* below top bar */
  background: #000;
}

.play-stage iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  pointer-events: auto;
}
/* Featured row container */
.carousel {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding: 10px 8px 14px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.carousel::-webkit-scrollbar { display: none; }

/* Each card */
.carouselItem {
  flex: 0 0 auto;
  width: min(78vw, 320px);
  scroll-snap-align: start;
}

/* Thumbnail */
.thumb {
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 18px;
  overflow: hidden;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
