/* ============================================================
   qwer.poki.love — Shared Site Shell Styles
   ------------------------------------------------------------
   Design intent:
   - Every page renders inside a single 375 x 812 mobile container
     (iPhone 13 mini equivalent), regardless of the host browser
     viewport. On a wide desktop, the container is centered on a
     dark gradient canvas with a soft shadow; on a real phone
     (<420px wide), the container fills the screen edge-to-edge.
   - Drawer navigation slides in from the left with a translucent
     black backdrop.
   - Bottom tabbar is fixed at the bottom of the app-shell so the
     Phaser iframe never collides with it (the play page hides it).
   - Poki-style vibrant accents: red #FF4757, yellow #FFA502,
     green #2ED573, blue #1E90FF, plus a 135deg primary gradient.
   - No web fonts are loaded — all typography uses the local
     system stack to keep this site fully static-friendly.
   ============================================================ */

/* ---------- Reset / base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: #1f2333;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: contain;
}

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

button {
  font-family: inherit;
  cursor: pointer;
}

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

/* ---------- Desktop shell wrapper ----------
   On a real mobile device (<420px) we drop the centering and
   shadow so the .app-shell can run edge-to-edge. Above that, the
   body becomes a centered dark canvas that hosts the mobile
   container. */
body {
  background: linear-gradient(135deg, #0F1226 0%, #1A1E3A 50%, #0F1226 100%);
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px 20px 40px;
}

@media (max-width: 419.98px) {
  body {
    padding: 0;
    background: #0F1226;
  }
}

/* ---------- App shell (the 375-wide container) ---------- */
.app-shell {
  position: relative;
  width: 375px;
  min-width: 375px;
  max-width: 375px;
  min-height: 812px;
  background: #ffffff;
  overflow-x: hidden;
  overflow-y: visible;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.5);
  border-radius: 0;
  display: flex;
  flex-direction: column;
}

@media (max-width: 419.98px) {
  .app-shell {
    width: 100vw;
    min-width: 100vw;
    max-width: 100vw;
    min-height: 100vh;
    box-shadow: none;
    border-radius: 0;
  }
}

/* ---------- Top bar ---------- */
.topbar {
  flex: 0 0 auto;
  height: 56px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #ffffff;
  border-bottom: 1px solid #f0f0f5;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.topbar .icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: none;
  background: #f4f5fb;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
}

.topbar .icon-btn:active {
  background: #e8eaf3;
}

.topbar .icon-btn img {
  width: 22px;
  height: 22px;
  display: block;
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 17px;
  color: #1f2333;
  letter-spacing: -0.2px;
  flex: 1 1 auto;
  min-width: 0;
}

.topbar .brand img {
  width: 28px;
  height: 28px;
  border-radius: 8px;
}

.topbar .brand .brand-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar .brand .brand-tag {
  font-size: 10px;
  font-weight: 600;
  color: #FF4757;
  background: rgba(255, 71, 87, 0.12);
  padding: 2px 6px;
  border-radius: 6px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.topbar .search {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: none;
  background: #f4f5fb;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.topbar .search:active {
  background: #e8eaf3;
}

.topbar .search img {
  width: 20px;
  height: 20px;
}

/* ---------- Main page content ---------- */
.page-content {
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 24px;
  background: #fafbfd;
}

.app-shell.play-mode .page-content {
  padding-bottom: 0;
  display: none;
}

/* ---------- Drawer + overlay ---------- */
.drawer {
  position: fixed;
  top: 0;
  left: calc(50vw - 187.5px);
  width: 78%;
  max-width: 295px;
  height: 100vh;
  background: #ffffff;
  box-shadow: 8px 0 24px rgba(0, 0, 0, 0.18);
  transform: translateX(-100%);
  visibility: hidden;
  transition: transform 260ms cubic-bezier(0.22, 0.61, 0.36, 1),
              visibility 0s linear 260ms;
  z-index: 60;
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  overflow-y: auto;
}

.drawer.open {
  transform: translateX(0);
  visibility: visible;
  transition: transform 260ms cubic-bezier(0.22, 0.61, 0.36, 1),
              visibility 0s linear 0s;
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  visibility: hidden;
  transition: opacity 220ms ease, visibility 0s linear 220ms;
  z-index: 50;
}

.drawer-overlay.open {
  opacity: 1;
  visibility: visible;
  transition: opacity 220ms ease;
}

/* On real mobile, app-shell is full viewport width so the drawer
   sits flush against the left edge of the screen. */
@media (max-width: 419.98px) {
  .drawer {
    left: 0;
  }
}

.drawer .drawer-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 18px;
  border-bottom: 1px solid #f0f0f5;
  margin-bottom: 12px;
}

.drawer .drawer-header .avatar {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, #FF4757, #FF6B81);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
}

.drawer .drawer-header .greet {
  font-weight: 700;
  font-size: 15px;
  color: #1f2333;
}

.drawer .drawer-header .sub {
  font-size: 11px;
  color: #8a8fa3;
}

.drawer .drawer-section {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: #8a8fa3;
  text-transform: uppercase;
  padding: 14px 4px 6px;
}

.drawer .drawer-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  color: #1f2333;
  transition: background 160ms ease;
}

.drawer .drawer-item:hover,
.drawer .drawer-item:active {
  background: #f4f5fb;
}

.drawer .drawer-item .drawer-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #f4f5fb;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.drawer .drawer-item .drawer-icon img {
  width: 16px;
  height: 16px;
}

.drawer .drawer-item .badge {
  margin-left: auto;
  background: #FF4757;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 8px;
}

/* ---------- Bottom tab bar ---------- */
.bottom-tabbar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: #ffffff;
  border-top: 1px solid #f0f0f5;
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  padding: 6px 4px calc(env(safe-area-inset-bottom, 0px) + 6px) 4px;
  z-index: 40;
}

.tabbar-item {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: none;
  background: transparent;
  padding: 4px 2px;
  color: #8a8fa3;
  font-size: 10px;
  font-weight: 600;
  border-radius: 10px;
  transition: color 160ms ease;
}

.tabbar-item .tabbar-icon {
  width: 26px;
  height: 26px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.55;
}

.tabbar-item.active {
  color: #FF4757;
}

.tabbar-item.active .tabbar-icon {
  opacity: 1;
}

/* Default tab icons — referenced by inline style on each tabbar-item */
.tabbar-icon.icon-home {
  background-image: url("../images/icons/home.png");
}
.tabbar-icon.icon-categories {
  background-image: url("../images/icons/categories.png");
}
.tabbar-icon.icon-favorites {
  background-image: url("../images/icons/favorites.png");
}
.tabbar-icon.icon-profile {
  background-image: url("../images/icons/profile.png");
}

/* ---------- Section headers ---------- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 14px 10px;
}

.section-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #1f2333;
  letter-spacing: -0.2px;
}

.section-header .see-all {
  font-size: 12px;
  font-weight: 600;
  color: #FF4757;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

/* ---------- Horizontal rail ---------- */
.rail-scroll {
  display: flex;
  gap: 10px;
  padding: 0 14px 4px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.rail-scroll::-webkit-scrollbar {
  display: none;
}

.rail-scroll > * {
  scroll-snap-align: start;
}

/* ---------- Game card ---------- */
.game-card {
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(15, 18, 38, 0.06);
  transition: transform 160ms ease, box-shadow 160ms ease;
  text-decoration: none;
  color: inherit;
}

.game-card:active {
  transform: scale(0.98);
}

.game-card .cover-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: #eef0f8;
}

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

.game-card .cover-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: rgba(15, 18, 38, 0.25);
}

.game-card .meta {
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.game-card .meta h4 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: #1f2333;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.game-card .meta .row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* ---------- Game grid ---------- */
.game-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 4px 14px 12px;
}

/* ---------- Game card (mini, used in rails) ---------- */
.game-card-mini {
  flex: 0 0 auto;
  width: 132px;
  background: #ffffff;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(15, 18, 38, 0.06);
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
}

.game-card-mini .cover-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: #eef0f8;
}

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

.game-card-mini .meta {
  padding: 6px 8px 8px;
}

.game-card-mini h5 {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  color: #1f2333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 14px;
  border: none;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.2px;
  text-decoration: none;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, filter 140ms ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, #FF4757, #FF6B81);
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(255, 71, 87, 0.32);
}

.btn-primary:hover {
  filter: brightness(1.05);
}

.btn-secondary {
  background: #ffffff;
  color: #1f2333;
  border: 1px solid #e3e5ef;
}

.btn-ghost {
  background: transparent;
  color: #1f2333;
}

/* ---------- Category chip ---------- */
.category-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(30, 144, 255, 0.12);
  color: #1E90FF;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.category-chip.cat-action {
  background: rgba(255, 71, 87, 0.12);
  color: #FF4757;
}
.category-chip.cat-puzzle {
  background: rgba(30, 144, 255, 0.12);
  color: #1E90FF;
}
.category-chip.cat-card {
  background: rgba(255, 165, 2, 0.14);
  color: #B36B00;
}
.category-chip.cat-arcade {
  background: rgba(46, 213, 115, 0.16);
  color: #1c9d56;
}
.category-chip.cat-strategy {
  background: rgba(120, 90, 230, 0.14);
  color: #5b3ed1;
}

/* ---------- Rating badge ---------- */
.rating-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 700;
  color: #FFA502;
}

.rating-badge::before {
  content: "\2605";
  font-size: 11px;
}

/* ---------- Play count ---------- */
.play-count {
  font-size: 11px;
  color: #8a8fa3;
  font-weight: 500;
}

/* ---------- Skeleton (loading state) ---------- */
.skeleton {
  position: relative;
  background: #eef0f8;
  border-radius: 12px;
  overflow: hidden;
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.55) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  animation: skeleton-shimmer 1.4s infinite;
}

@keyframes skeleton-shimmer {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(100%);
  }
}

/* ---------- Empty state ---------- */
.empty-state {
  padding: 36px 20px;
  text-align: center;
  color: #8a8fa3;
}

.empty-state h4 {
  margin: 8px 0 4px;
  font-size: 15px;
  color: #1f2333;
}

.empty-state p {
  margin: 0;
  font-size: 12px;
}

/* ---------- Fullscreen iframe (play.html) ---------- */
.fullscreen-iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #06061a;
  display: block;
  z-index: 1;
}

.app-shell.play-mode .fullscreen-iframe {
  inset: 0;
}

/* ---------- Floating buttons (play.html) ---------- */
.floating-btn {
  position: absolute;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  padding: 0;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: transform 140ms ease;
}

.floating-btn:active {
  transform: scale(0.94);
}

.floating-btn.left {
  left: 16px;
  bottom: 24px;
}

.floating-btn.right {
  right: 16px;
  bottom: 24px;
}

.floating-btn img {
  width: 32px;
  height: 32px;
  display: block;
}

.floating-btn.fullscreen {
  width: 52px;
  height: 52px;
}

.floating-btn.fullscreen img {
  width: 28px;
  height: 28px;
}

/* ---------- Play-mode overrides ---------- */
.app-shell.play-mode .topbar {
  display: none;
}

.app-shell.play-mode .page-content {
  display: none;
}

/* ---------- Helpers ---------- */
.muted {
  color: #8a8fa3;
}

.center {
  text-align: center;
}

.hidden {
  display: none !important;
}

.no-tap {
  pointer-events: none;
}

/* ---------- Safe area on real phones ---------- */
@supports (padding: max(0px)) {
  .topbar {
    padding-top: max(8px, env(safe-area-inset-top));
  }
  .page-footer {
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
}

/* ---------- Page footer ---------- */
.page-footer {
  flex: 0 0 auto;
  background: #ffffff;
  border-top: 1px solid #f0f0f5;
  padding: 20px 16px 16px;
  color: #5a5f73;
  font-size: 12px;
  line-height: 1.5;
}

.page-footer .footer-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.page-footer .footer-brand img {
  width: 28px;
  height: 28px;
  border-radius: 8px;
}

.page-footer .footer-brand .footer-brand-name {
  font-weight: 700;
  font-size: 14px;
  color: #1f2333;
}

.page-footer .footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-bottom: 12px;
}

.page-footer .footer-links a {
  color: #5a5f73;
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
}

.page-footer .footer-links a:hover,
.page-footer .footer-links a:active {
  color: #FF4757;
}

.page-footer .footer-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: #8a8fa3;
}

.page-footer .footer-meta a {
  color: #FF4757;
  text-decoration: none;
  font-weight: 600;
}

.page-footer .footer-meta a:hover,
.page-footer .footer-meta a:active {
  text-decoration: underline;
}

.page-footer .footer-divider {
  height: 1px;
  background: #f0f0f5;
  margin: 12px 0;
}

.page-footer .footer-copyright {
  font-size: 11px;
  color: #8a8fa3;
  text-align: center;
  margin-top: 4px;
}

/* ---------- Ad slots (AdSense / AdX banner placeholders) ----------
   The actual <ins class="adsbygoogle"> snippet lives inside each
   page as a comment block; this CSS only paints the dev placeholder
   so layout reserves the correct height before ads are enabled. */
.ad-banner {
  margin: 14px 14px;
  padding: 0;
  background: transparent;
  min-height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ad-banner .ad-banner-placeholder {
  width: 100%;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f4f5fb;
  border: 1px dashed #c8cce0;
  border-radius: 12px;
  font-size: 12px;
  color: #8a8fa3;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.ad-banner .ad-banner-placeholder::before {
  content: "Ad";
  display: inline-block;
  margin-right: 8px;
  padding: 2px 6px;
  background: #ffffff;
  border: 1px solid #c8cce0;
  border-radius: 4px;
  font-size: 10px;
  color: #5b6076;
}

/* When the real <ins class="adsbygoogle"> is rendered, hide the
   placeholder. The page comments include a sibling hint like
   "<!-- ins renders here -->" so we can use CSS-only targeting. */
.ad-banner:has(.adsbygoogle) .ad-banner-placeholder {
  display: none;
}
}