/* mobile.css — BitPlayZone native-app-like mobile experience.
   EVERYTHING here is scoped under html.is-mobile so desktop/web is untouched.
   Same crawlable HTML for all clients (no cloaking) — this is a pure
   client-side progressive-enhancement skin, SEO-safe.
   Reuses the neon/cyber design tokens from hub.css (--neon-blue, etc). */

/* ============================================================= *
 *  GLOBAL (mobile)                                               *
 * ============================================================= */
.is-mobile, .is-mobile body { overflow-x: hidden; }
/* Stop iOS Safari from inflating text ("text autosizing" / font boosting),
   which made everything look zoomed on real iPhones. */
html.is-mobile { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.is-mobile body {
  padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); /* room for the bottom tab bar */
  font-size: 15px;
}
.is-mobile.m-lock, .is-mobile.m-lock body { overflow: hidden !important; height: 100%; }

/* Slightly larger, thumb-friendly tap targets everywhere on mobile */
.is-mobile a, .is-mobile button { -webkit-tap-highlight-color: transparent; }

/* ============================================================= *
 *  TOP APP BAR (restyle the existing .site-header)              *
 * ============================================================= */
.is-mobile .site-header {
  position: sticky; top: 0; z-index: 80;
  padding: calc(env(safe-area-inset-top, 0px) + 0.55rem) 1rem 0.55rem;
  background: rgba(7,7,10,0.82);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--glass-border);
  flex-wrap: nowrap;
}
.is-mobile .site-header .brand img { height: 34px; }
/* Hide desktop text nav links on mobile — the bottom tab bar replaces them */
.is-mobile .site-nav a[href$="#games"],
.is-mobile .site-nav > a { display: none; }
.is-mobile .site-nav { gap: 0.5rem; }
/* Compact language switcher into an icon-ish pill */
.is-mobile .lang-switch summary { padding: 0.45rem 0.7rem; font-size: 0.82rem; }

/* Search icon button injected into the app bar */
.is-mobile .m-searchbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 12px;
  background: rgba(255,255,255,0.04); border: 1px solid var(--glass-border);
  color: var(--text-main); font-size: 1.1rem; cursor: pointer;
}
.is-mobile .m-searchbtn:active { transform: scale(0.94); }

/* Expanding search field (below app bar) */
.is-mobile .m-searchwrap {
  position: sticky; top: calc(env(safe-area-inset-top,0px) + 52px); z-index: 79;
  background: rgba(7,7,10,0.92); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  padding: 0.6rem 1rem; border-bottom: 1px solid var(--glass-border);
  overflow: hidden; max-height: 0; padding-top: 0; padding-bottom: 0;
  transition: max-height .28s ease, padding .28s ease;
}
.is-mobile .m-searchwrap.open { max-height: 70px; padding-top: 0.6rem; padding-bottom: 0.6rem; }
.is-mobile .m-searchinput {
  width: 100%; box-sizing: border-box; padding: 0.7rem 1rem; border-radius: 12px;
  background: var(--bg-card); border: 1px solid var(--glass-border);
  color: var(--text-main); font-family: var(--font-ui); font-size: 1rem; outline: none;
}
.is-mobile .m-searchinput:focus { border-color: var(--neon-blue); box-shadow: 0 0 0 3px rgba(0,240,255,0.12); }

/* ============================================================= *
 *  HERO (compact on mobile)                                      *
 * ============================================================= */
.is-mobile .hero { padding: 1rem 1.1rem 0.2rem; }
.is-mobile .hero h1 { font-size: 1.4rem; letter-spacing: 0.5px; line-height: 1.15; }
.is-mobile .hero p { font-size: 0.85rem; margin-top: 0.4rem; }

/* ============================================================= *
 *  CATEGORY CHIPS (sticky, app-like)                            *
 * ============================================================= */
.is-mobile .category-bar {
  position: sticky; top: calc(env(safe-area-inset-top,0px) + 52px); z-index: 70;
  margin: 0 0 0.4rem; padding: 0.7rem 1rem;
  background: rgba(7,7,10,0.9); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--glass-border);
  gap: 0.5rem;
}
.is-mobile .category-btn { padding: 0.5rem 0.95rem; font-size: 0.72rem; }

/* ============================================================= *
 *  FEATURED RAIL (injected on homepage)                         *
 * ============================================================= */
.is-mobile .m-rail-title {
  font-family: var(--font-heading); color: var(--neon-blue);
  font-size: 1rem; letter-spacing: 1px; margin: 0.6rem 1rem 0.5rem; text-transform: uppercase;
}
.is-mobile .m-rail {
  display: flex; gap: 0.85rem; overflow-x: auto; padding: 0 1rem 0.4rem;
  scrollbar-width: none; scroll-snap-type: x mandatory;
}
.is-mobile .m-rail::-webkit-scrollbar { display: none; }
.is-mobile .m-rail-card {
  flex: 0 0 45%; scroll-snap-align: start;
  border-radius: 16px; padding: 0.9rem; position: relative; overflow: hidden;
  background: linear-gradient(135deg, rgba(0,240,255,0.14), rgba(176,38,255,0.14));
  border: 1px solid rgba(0,240,255,0.28);
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  color: var(--text-main); min-height: 112px;
  display: flex; flex-direction: column; justify-content: space-between;
}
.is-mobile .m-rail-card .ic { font-size: 2.2rem; filter: drop-shadow(0 0 12px rgba(0,240,255,0.4)); }
.is-mobile .m-rail-card .nm { font-family: var(--font-heading); font-weight: 700; font-size: 0.92rem; margin-top: 0.4rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.is-mobile .m-rail-card .go {
  margin-top: 0.5rem; align-self: flex-start; font-size: 0.65rem; font-weight: 800; letter-spacing: 1px;
  color: #04121a; background: var(--neon-blue); padding: 0.35rem 0.8rem; border-radius: 100px; text-transform: uppercase;
}

/* ============================================================= *
 *  GAME GRID → 2-column app tiles                               *
 * ============================================================= */
.is-mobile .games-grid {
  display: grid !important; grid-template-columns: 1fr 1fr; gap: 0.85rem;
  max-width: 100%; margin: 0; padding: 0.4rem 1rem 1.5rem;
}
.is-mobile .game-card {
  padding: 1.1rem 0.9rem 1rem; border-radius: 18px; align-items: center; text-align: center;
  background: var(--bg-card); transition: transform .15s ease;
}
.is-mobile .game-card:active { transform: scale(0.96); }
.is-mobile .game-card:hover { transform: none; } /* kill desktop hover lift on touch */
.is-mobile .game-icon { font-size: 3rem; margin-bottom: 0.6rem; }
.is-mobile .game-card-title { font-size: 0.98rem; margin-bottom: 0.25rem; }
.is-mobile .game-card-desc { display: none; } /* keep tiles clean & app-like (still in DOM for SEO) */
.is-mobile .game-tags { display: none; }
/* In-feed grid ads span both columns and keep earning */
.is-mobile .ad-grid-span { grid-column: 1 / -1; }
.is-mobile .games-grid .ad-slot { min-height: 100px; }

/* Slim, subtle ad placeholders on mobile (empty dashed boxes looked unfinished).
   Real ad units (<ins>) are unaffected — only the placeholder state shrinks. */
.is-mobile main > .ad-slot { margin: 0.7rem 1rem; min-height: 0; }
.is-mobile .ad-placeholder { min-height: 52px; padding: 0.4rem; font-size: 0.7rem; opacity: 0.45; }
/* Keep the pre-game interstitial ad box tall (more specific rule wins). */
.is-mobile .m-ad-box .ad-placeholder { min-height: 240px; opacity: 0.6; }

/* ============================================================= *
 *  FOOTER (simplify)                                            *
 * ============================================================= */
.is-mobile .site-footer { padding: 1.4rem 1rem 1.6rem; font-size: 0.82rem; }
.is-mobile .site-footer .foot-links { gap: 0.9rem; }

/* Don't show two fixed bars at once: hide the sticky anchor ad on the HOME
   page (bottom tab bar is there). It stays on game pages where there's no tab bar. */
.is-mobile.m-home .ad-slot--anchor { display: none; }

/* ============================================================= *
 *  BOTTOM TAB BAR (injected)                                    *
 * ============================================================= */
.is-mobile .m-tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 85;
  display: flex; justify-content: space-around; align-items: stretch;
  padding: 0.35rem 0.3rem calc(0.35rem + env(safe-area-inset-bottom, 0px));
  background: rgba(9,9,14,0.92); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  border-top: 1px solid var(--glass-border);
}
.is-mobile .m-tab {
  flex: 1; background: none; border: 0; color: var(--text-muted); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-family: var(--font-ui); font-size: 0.62rem; font-weight: 700; letter-spacing: 0.4px;
  padding: 0.35rem 0; text-transform: uppercase; text-decoration: none;
}
.is-mobile .m-tab .ic { font-size: 1.25rem; line-height: 1; }
.is-mobile .m-tab.active { color: var(--neon-blue); text-shadow: 0 0 12px rgba(0,240,255,0.5); }

/* ============================================================= *
 *  GAME PAGE — mobile "Play" cover over the stage               *
 * ============================================================= */
/* On mobile the game does NOT auto-run inline; we show an app-style cover. */
.is-mobile .game-stage .game-head { display: none; }        /* desktop toolbar hidden */
.is-mobile .game-stage .ad-slot[data-ad="game_top"] { display: none; }
/* Inline game frame stays hidden on mobile — the game only appears in the
   fullscreen overlay (#mgame). The mount is moved there on Play, restored here
   (still hidden) on exit. */
.is-mobile .game-stage > .game-frame { display: none; }
.is-mobile #game-mount-container { min-height: 0 !important; }

.is-mobile .m-cover {
  margin: 0.6rem 1rem 0.4rem; border-radius: 22px; overflow: hidden; position: relative;
  background: linear-gradient(160deg, rgba(0,240,255,0.12), rgba(176,38,255,0.14));
  border: 1px solid rgba(0,240,255,0.28); box-shadow: 0 14px 40px rgba(0,0,0,0.55);
  padding: 2.2rem 1.2rem 2rem; text-align: center;
}
.is-mobile .m-cover .ic { font-size: 4.6rem; filter: drop-shadow(0 0 18px rgba(0,240,255,0.45)); }
.is-mobile .m-cover .nm { font-family: var(--font-heading); font-weight: 800; font-size: 1.35rem; margin: 0.6rem 0 0.2rem; color: #fff; }
.is-mobile .m-cover .hint { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 1.2rem; }
.is-mobile .m-playbtn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  background: linear-gradient(90deg, var(--neon-blue), var(--neon-purple)); color: #04121a;
  border: 0; border-radius: 100px; padding: 0.95rem 2.4rem;
  font-family: var(--font-heading); font-weight: 900; font-size: 1.05rem; letter-spacing: 1px;
  text-transform: uppercase; cursor: pointer; box-shadow: 0 8px 26px rgba(0,240,255,0.35);
}
.is-mobile .m-playbtn:active { transform: scale(0.96); }

/* ============================================================= *
 *  PRE-GAME AD INTERSTITIAL (injected)                          *
 * ============================================================= */
.is-mobile .m-interstitial {
  position: fixed; inset: 0; z-index: 120; display: none;
  flex-direction: column; align-items: center; justify-content: center;
  background: rgba(4,4,8,0.97); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  padding: 1.2rem;
}
.is-mobile .m-interstitial.show { display: flex; }
.is-mobile .m-int-label {
  font-family: var(--font-ui); font-size: 0.7rem; letter-spacing: 2px; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 0.8rem;
}
.is-mobile .m-ad-box {
  width: 100%; max-width: 340px; min-height: 260px; border-radius: 16px;
  background: rgba(255,255,255,0.03); border: 1px solid var(--glass-border);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.is-mobile .m-ad-box .ad-slot { margin: 0; width: 100%; min-height: 250px; }
.is-mobile .m-int-count {
  margin-top: 1.1rem; color: var(--text-main); font-size: 0.9rem; text-align: center;
}
.is-mobile .m-int-count b { color: var(--neon-blue); font-family: var(--font-heading); }
.is-mobile .m-skip {
  margin-top: 1rem; background: rgba(255,255,255,0.06); border: 1px solid var(--glass-border);
  color: var(--text-main); border-radius: 100px; padding: 0.7rem 1.8rem; cursor: pointer;
  font-family: var(--font-ui); font-weight: 700; letter-spacing: 1px; opacity: 0.4; pointer-events: none;
  transition: opacity .3s ease;
}
.is-mobile .m-skip.ready { opacity: 1; pointer-events: auto; }
.is-mobile .m-skip.ready:active { transform: scale(0.96); }

/* ============================================================= *
 *  FULLSCREEN GAME OVERLAY (injected #mgame)                    *
 * ============================================================= */
.is-mobile #mgame {
  position: fixed; inset: 0; z-index: 110; display: none;
  flex-direction: column; background: #030305;
}
.is-mobile #mgame.show { display: flex; }
.is-mobile .mgame-bar {
  display: flex; align-items: center; gap: 0.6rem;
  padding: calc(env(safe-area-inset-top,0px) + 0.5rem) 0.9rem 0.5rem;
  background: linear-gradient(to bottom, rgba(0,0,0,0.85), transparent);
}
.is-mobile .mgame-bar .m-icobtn {
  width: 38px; height: 38px; border-radius: 11px; flex: 0 0 auto;
  background: rgba(255,255,255,0.06); border: 1px solid var(--glass-border);
  color: var(--text-main); font-size: 1.1rem; display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.is-mobile .mgame-bar .m-icobtn:active { transform: scale(0.92); }
.is-mobile .mgame-bar .mgame-title {
  flex: 1; font-family: var(--font-heading); font-weight: 700; font-size: 0.95rem; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.is-mobile .mgame-bar .mgame-score,
.is-mobile .mgame-bar .game-score {
  font-family: var(--font-heading); font-weight: 700; font-size: 0.95rem; color: var(--neon-green);
  text-shadow: 0 0 10px rgba(0,255,102,0.4); white-space: nowrap; flex: 0 0 auto;
}
.is-mobile .mgame-stage {
  flex: 1; position: relative; display: flex; align-items: center; justify-content: center;
  overflow: hidden; min-height: 0;
}
.is-mobile #mgame #game-mount-container {
  position: relative; width: 100%; height: 100%; padding: 0.3rem;
  display: flex; align-items: center; justify-content: center; min-height: 0 !important;
}
.is-mobile #mgame #game-mount {
  max-width: 100%; max-height: 100%; display: flex; align-items: center; justify-content: center;
}
.is-mobile #mgame #game-mount canvas {
  max-width: 100%; max-height: calc(100dvh - 130px); width: auto; height: auto;
}
/* game-over screen scoped to the fullscreen stage */
.is-mobile #mgame #game-over-screen { position: absolute; inset: 0; }
.is-mobile #mgame #game-over-screen .neon-red,
.is-mobile #mgame #game-over-screen .neon-blue { font-size: 2.4rem; }

/* ============================================================= *
 *  VIRTUAL GAMEPAD (injected inside #mgame for keyboard games)  *
 * ============================================================= */
.is-mobile .mgame-pad {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem;
  padding: 0.6rem 1.4rem calc(1rem + env(safe-area-inset-bottom,0px));
  background: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
  min-height: 0;
}
.is-mobile .mgame-pad.empty { display: none; }
.is-mobile .m-dpad {
  display: grid; grid-template-columns: repeat(3, 52px); grid-template-rows: repeat(3, 52px);
  gap: 6px;
}
.is-mobile .m-dpad .pad {
  border: 1px solid var(--glass-border); background: rgba(255,255,255,0.06); color: var(--neon-blue);
  border-radius: 12px; font-size: 1.3rem; display: flex; align-items: center; justify-content: center;
  -webkit-user-select: none; user-select: none; touch-action: none;
}
.is-mobile .m-dpad .pad.hidden { visibility: hidden; }
.is-mobile .m-dpad .pad:active, .is-mobile .m-actbtn:active {
  background: rgba(0,240,255,0.25); border-color: var(--neon-blue); color: #fff;
}
.is-mobile .m-acts { display: flex; flex-wrap: wrap-reverse; gap: 0.7rem; align-items: flex-end; justify-content: flex-end; max-width: 55%; }
.is-mobile .m-actbtn {
  min-width: 62px; height: 62px; padding: 0 0.9rem; border-radius: 50%;
  border: 1px solid rgba(176,38,255,0.5); background: rgba(176,38,255,0.16); color: #fff;
  font-family: var(--font-heading); font-weight: 800; font-size: 0.95rem; letter-spacing: 1px;
  display: flex; align-items: center; justify-content: center;
  -webkit-user-select: none; user-select: none; touch-action: none;
}
.is-mobile .m-actbtn.wide { border-radius: 32px; min-width: 96px; }

/* RTL: keep the dpad on the (visual) left, actions on the right — natural for games */
.is-mobile[dir="rtl"] .mgame-pad { flex-direction: row-reverse; }
