/* =====================================================================
   Nanogram Mega Jams: mobile interface (phones and small tablets)
   Loaded last. Everything lives inside the 900px query so desktop is untouched.
   ===================================================================== */
@media (max-width: 900px) {
  :root { --m-pad: 16px; --m-tab-h: 66px; --m-radius: 22px; --m-line: rgba(255,255,255,.08); }
  html { -webkit-text-size-adjust: 100%; }
  body { -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; }
  button, .btn, .filter, .jam-card, .g { touch-action: manipulation; }
  *:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }

  /* ---------- top bar ---------- */
  .mobile-topbar {
    position: sticky; top: 0; z-index: 40;
    display: grid !important; grid-template-columns: 44px 1fr 44px 44px; align-items: center; gap: 8px;
    margin: 0 !important; padding: calc(env(safe-area-inset-top, 0px) + 10px) var(--m-pad) 10px !important;
    background: rgba(13,12,17,.8); -webkit-backdrop-filter: blur(18px) saturate(1.4); backdrop-filter: blur(18px) saturate(1.4);
    border-bottom: 1px solid var(--m-line);
  }
  .mobile-topbar button {
    width: 44px; height: 44px; padding: 0; display: grid; place-items: center;
    border-radius: 14px; border: 1px solid var(--m-line); background: rgba(255,255,255,.05); color: var(--ink);
    font-size: 19px; line-height: 1; cursor: pointer;
  }
  .mobile-topbar button:active { transform: scale(.94); background: rgba(255,255,255,.1); }
  .mobile-brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
  .mobile-brand strong { font: 700 17px/1 var(--d); letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mobile-brand strong span { font-weight: 500; color: var(--mute); }
  .mobile-acct img, .mobile-acct .av { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }
  .mobile-acct { overflow: hidden; }

  /* ---------- page ---------- */
  main { scroll-padding-top: 72px; }
  .page, .page.page-enter {
    padding: 18px var(--m-pad) calc(var(--m-tab-h) + 40px + env(safe-area-inset-bottom, 0px)) !important;
    width: 100% !important; max-width: 640px; margin-inline: auto;
  }
  @media (min-width: 640px) { .page, .page.page-enter { max-width: 720px; } }

  /* ---------- home heading ---------- */
  .home-heading { display: flex !important; flex-direction: column; align-items: stretch !important; gap: 16px; margin: 0 0 22px !important; }
  .home-heading .eyebrow { font-size: 11px; letter-spacing: .16em; margin-bottom: 10px; }
  .home-heading h1 { font-size: clamp(38px, 12vw, 54px) !important; line-height: .98 !important; letter-spacing: -.06em; margin: 0 0 12px; }
  .home-heading .lead { font-size: 16px !important; line-height: 1.5; margin: 0; max-width: 34ch; color: var(--mute); }
  .home-stat {
    display: inline-flex !important; align-self: flex-start; align-items: baseline; gap: 10px;
    min-width: 0 !important; width: auto !important; padding: 12px 18px !important; border-radius: 16px !important;
  }
  .home-stat strong { font-size: 28px !important; line-height: 1; }
  .home-stat span { font-size: 11px !important; letter-spacing: .12em; }

  /* ---------- hero ---------- */
  .hero-card { min-height: 0 !important; padding: 16px !important; border-radius: var(--m-radius) !important; margin-bottom: 30px !important; }
  .hero-art { display: none !important; }
  .hero-copy { padding: 4px 4px 2px; }
  .hero-copy .eyebrow { font-size: 10.5px !important; margin-bottom: 8px; }
  .hero-copy h2, .hero-copy h2.t-md, .hero-copy h2.t-sm { font-size: clamp(28px, 8.4vw, 36px) !important; letter-spacing: -.045em !important; margin-bottom: 8px !important; }
  .hero-copy p { font-size: 15px !important; line-height: 1.5 !important; -webkit-line-clamp: 3 !important; margin-top: 4px !important; }
  .hero-actions { display: flex !important; gap: 10px; align-items: center; margin-top: 14px; }
  .hero-actions .btn { flex: 1 1 auto; height: 50px; border-radius: 15px; font-size: 16px; }
  .hero-link { height: 50px; padding: 0 18px; border-radius: 15px; border: 1px solid var(--m-line); background: rgba(255,255,255,.04); color: var(--ink); font-weight: 600; }
  .readmore { font-size: 14px; margin: 6px 0 2px; padding: 6px 0; }

  /* ---------- section headings + filters ---------- */
  .section-heading { display: flex !important; flex-direction: column !important; align-items: stretch !important; gap: 14px; margin: 0 0 14px !important; }
  .section-heading h2 { font-size: 26px !important; letter-spacing: -.04em; margin: 0; }
  .section-heading p { margin: 4px 0 0; font-size: 14px; }
  .head-right { display: flex !important; flex-direction: column; align-items: stretch !important; gap: 10px; width: 100%; margin: 0 !important; }
  .filter-row {
    display: flex !important; gap: 8px; overflow-x: auto; padding: 2px var(--m-pad); margin: 0 calc(var(--m-pad) * -1) !important;
    background: none !important; border: 0 !important; border-radius: 0 !important; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .filter-row::-webkit-scrollbar { display: none; }
  .filter { flex: none; height: 40px; padding: 0 18px !important; border-radius: 999px !important; font-size: 14px; border: 1px solid var(--m-line) !important; background: rgba(255,255,255,.04) !important; }
  .filter.active { background: var(--ink) !important; color: var(--bg) !important; border-color: transparent !important; }
  .head-right .btn { width: 100%; height: 48px; border-radius: 14px; font-size: 15px; }
  .count-label { font-size: 13px !important; color: var(--mute); }
  .games-heading { margin-top: 30px !important; }

  /* ---------- jam cards: swipeable row ---------- */
  .jam-grid {
    display: flex !important; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
    margin: 0 calc(var(--m-pad) * -1) !important; padding: 2px var(--m-pad) 16px !important; scrollbar-width: none; scroll-padding-inline: var(--m-pad);
  }
  .jam-grid::-webkit-scrollbar { display: none; }
  .jam-card { flex: 0 0 min(80%, 310px) !important; width: auto !important; scroll-snap-align: start; border-radius: 20px !important; min-width: 0; text-align: left; }
  .jam-cover { height: auto !important; aspect-ratio: 1200 / 630; border-radius: 20px 20px 0 0 !important; }
  .jam-info { padding: 14px 15px 14px !important; }
  .jam-info strong { font-size: 17px !important; }
  .jam-info p { font-size: 13.5px !important; margin: 4px 0 8px !important; }
  .jam-meta { font-size: 12.5px; }
  .jam-status { top: 10px !important; left: 10px !important; }
  .jam-arrow { display: none !important; }
  .jam-letter { font-size: 56px; }

  /* ---------- game tiles ---------- */
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 18px 12px !important; }
  .g { min-width: 0; }
  .g .tl { aspect-ratio: 3 / 4 !important; height: auto !important; border-radius: 18px !important; }
  .g strong { font-size: 14.5px !important; line-height: 1.25; margin-top: 8px; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
  .card-arrow { display: none !important; }

  /* ---------- jam page ---------- */
  .jam-page { gap: 0; }
  .jam-top { display: flex !important; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 14px !important; }
  .back { height: 44px; padding: 0 16px; border-radius: 14px; font-size: 14.5px; }
  .top-actions { display: flex !important; flex: 1 1 100%; order: 3; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .top-actions::-webkit-scrollbar { display: none; }
  .top-actions > * { flex: none; height: 42px; border-radius: 13px; white-space: nowrap; }
  .jam-big-cover { height: auto !important; min-height: 0 !important; aspect-ratio: 2 / 1; border-radius: var(--m-radius) !important; margin-bottom: 20px !important; }
  .jam-big-cover.has-banner { max-height: none !important; aspect-ratio: 1200 / 630; }
  .big-letter { font-size: 84px !important; }
  .jam-title-row h1 { font-size: clamp(32px, 10vw, 42px) !important; line-height: 1.02 !important; letter-spacing: -.05em !important; margin: 4px 0 6px !important; }
  .jam-title-row .by { font-size: 14px; }
  .jam-lead { font-size: 16px !important; line-height: 1.62 !important; margin: 14px 0 18px !important; max-width: none !important; }
  .mega-countdown-panel { padding: 16px !important; border-radius: 18px !important; margin: 0 0 14px !important; gap: 12px; }
  .mega-countdown-panel strong { font-size: 28px !important; line-height: 1.05; }
  .mcp-status { font-size: 12px; padding: 7px 12px; }
  .tags { gap: 8px; margin-bottom: 18px; }
  .tags span { font-size: 12.5px; }
  .acts { display: grid !important; grid-template-columns: 1fr 1fr; gap: 10px !important; margin: 0 0 22px !important; }
  .acts > .btn.dark, .acts > .btn:first-child { grid-column: 1 / -1; }
  .acts > .btn:last-child:nth-child(even) { grid-column: 1 / -1; }
  .acts .btn { height: 50px; border-radius: 15px; font-size: 15.5px; justify-content: center; text-align: center; }
  .about-panel { grid-template-columns: 1fr !important; gap: 20px !important; padding: 18px !important; border-radius: 20px !important; }

  /* ---------- floating tab bar ---------- */
  .tabbar {
    position: fixed !important; left: 12px !important; right: 12px !important; bottom: calc(10px + env(safe-area-inset-bottom, 0px)) !important;
    height: var(--m-tab-h) !important; padding: 6px 8px !important; border-radius: 26px !important; z-index: 50;
    display: grid !important; grid-template-columns: repeat(5, 1fr); align-items: center; gap: 2px;
    background: rgba(24,22,31,.86) !important; -webkit-backdrop-filter: blur(22px) saturate(1.5); backdrop-filter: blur(22px) saturate(1.5);
    border: 1px solid rgba(255,255,255,.09) !important; box-shadow: 0 14px 40px rgba(0,0,0,.45) !important;
    max-width: 520px; margin-inline: auto;
  }
  .tb { height: 52px; display: flex !important; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border-radius: 18px; color: var(--mute) !important; background: none !important; border: 0 !important; font-size: 10.5px; min-width: 0; }
  .tb .tbl { font-size: 10.5px; font-weight: 600; letter-spacing: .01em; }
  .tb[aria-current="true"], .tb[aria-current="page"] { color: var(--purple) !important; }
  .tb:active { background: rgba(255,255,255,.07) !important; }
  .tb.tb-add { height: 52px; width: 52px; justify-self: center; border-radius: 18px; background: var(--purple) !important; color: #15101f !important; box-shadow: 0 8px 22px rgba(190,158,226,.35); }
  .tb.tb-add .tbi { background: none !important; box-shadow: none !important; width: auto !important; height: auto !important; margin: 0 !important; border-radius: 0 !important; display: grid; place-items: center; }
  .tb.tb-add .tbi svg { stroke: #15101f !important; width: 24px; height: 24px; }
  .tb.tb-add .tbl { display: none; }
  .tb.tb-add:active { transform: scale(.94); }

  /* tab bar slides away while the Mega Jams sheet is open */
  .tabbar { transition: transform .25s ease, opacity .2s ease; }
  body.drawer-open .tabbar { transform: translateY(140%); opacity: 0; pointer-events: none; }

  /* ---------- toasts, footer ---------- */
  .toasts { left: 14px !important; right: 14px !important; bottom: calc(var(--m-tab-h) + 24px + env(safe-area-inset-bottom, 0px)) !important; top: auto !important; align-items: stretch; }
  .toasts > * { max-width: none !important; width: 100%; }
  .site-credit { padding: 6px var(--m-pad) calc(var(--m-tab-h) + 44px + env(safe-area-inset-bottom, 0px)) !important; font-size: 12px; text-align: center; }

  /* ---------- Mega Jams sheet (sidebar on mobile) ---------- */
  #sidebar { border-radius: 28px 28px 0 0 !important; max-height: 88dvh; padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)) !important; }
  #sidebar .sheet-head { padding: 12px var(--m-pad) 8px; }
  #sidebar .sheet-x { width: 40px; height: 40px; border-radius: 50%; }
  #sidebar .list { overflow-y: auto; -webkit-overflow-scrolling: touch; }
  #sidebar .item { min-height: 58px; border-radius: 16px; }
  #sidebar .btn.discord { height: 50px; border-radius: 15px; }
  #sidebar .search-trigger { height: 50px; border-radius: 15px; }
  #sidebar .search-trigger kbd { display: none; }
  #sidebar .brand { display: none; }

  /* ---------- search palette ---------- */
  .command-dialog { margin: 0 !important; width: 100% !important; max-width: none !important; max-height: 100dvh; height: 100dvh; border-radius: 0 !important; }
  .command { height: 100%; display: flex; flex-direction: column; border-radius: 0 !important; }
  .command-head { padding: calc(env(safe-area-inset-top, 0px) + 12px) var(--m-pad) 10px; }
  .command-search { height: 50px; border-radius: 15px; }
  .command-search input { font-size: 16px; }
  .command-search kbd, .command-footer { display: none !important; }
  .command-results { flex: 1; max-height: none !important; overflow-y: auto; padding: 4px 10px calc(20px + env(safe-area-inset-bottom, 0px)); -webkit-overflow-scrolling: touch; }
  .command-result { min-height: 60px; border-radius: 16px; }

  /* ---------- dialogs become bottom sheets ---------- */
  dialog#dlg, dialog.ndlg {
    margin: auto 0 0 0 !important; width: 100% !important; max-width: none !important;
    max-height: 92dvh !important; border-radius: 28px 28px 0 0 !important;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  dialog::backdrop { background: rgba(5,4,8,.62); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
  .nd-x, .game-modal-x { top: 12px !important; right: 12px !important; width: 40px !important; height: 40px !important; }
  .ndlg input, .ndlg textarea, .ndlg select { font-size: 16px !important; }
  .ndlg input:not([type=checkbox]):not([type=radio]), .ndlg select { min-height: 48px; }
  .ndlg .btn { min-height: 50px; border-radius: 15px; font-size: 16px; }
  .ndlg .field { margin-bottom: 14px; }
  .ndlg .row, .ndlg .btns { gap: 10px; }
  .pub { display: flex !important; flex-direction: column; gap: 16px; padding: 4px 18px 18px !important; }
  .pub .pv-col { display: none !important; }
  .pub-head { padding: 18px 64px 6px 20px !important; }
  .pub-head h2 { font-size: 22px; }
  .pubf { padding: 0 !important; }
  .dtl, .dtl .btn { min-width: 0; }
  #dlg .game-modal-cover { aspect-ratio: 16 / 10; height: auto !important; }
}

/* very small phones */
@media (max-width: 360px) {
  :root { --m-pad: 14px; }
  .tb .tbl { font-size: 10px; }
  .jam-card { flex-basis: 84% !important; }
}

/* =====================================================================
   DESIGN PASS 2: feature-first home, sticky actions, sheets with grab handle
   ===================================================================== */
@media (max-width: 900px) {
  /* ---- calmer surfaces: layered cards with a hairline edge ---- */
  .hero-card, .jam-card, .mega-countdown-panel, .about-panel, .home-stat, .acts {
    border: 1px solid var(--m-line) !important;
  }
  .jam-card { background: linear-gradient(180deg, rgba(255,255,255,.045), rgba(255,255,255,.02)) !important; box-shadow: 0 10px 28px rgba(0,0,0,.28) !important; }
  .jam-card:active, .g:active { transform: scale(.985); transition: transform .12s ease; }

  /* ---- home: compact heading, featured jam first ---- */
  .page { padding-top: 14px !important; }
  .home-heading { flex-direction: row !important; align-items: flex-end !important; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px !important; }
  .home-heading > div:first-child { flex: 1 1 100%; }
  .home-heading h1 { font-size: clamp(34px, 10.5vw, 46px) !important; }
  .home-heading .lead { font-size: 15px !important; max-width: 36ch; }

  /* featured hero: banner on top, short copy, one clear action */
  .hero-card { padding: 12px 12px 16px !important; }
  .hero-card .hero-copy { padding: 4px 6px 0; }
  .hero-card .hero-copy .eyebrow { display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px; margin: 2px 0 10px; border-radius: 999px; background: rgba(255,255,255,.07); font-size: 10.5px !important; letter-spacing: .12em; }
  .hero-card .hero-copy h2 { font-size: clamp(26px, 8vw, 33px) !important; -webkit-line-clamp: 2 !important; }
  .hero-card .hero-copy p { font-size: 14.5px !important; -webkit-line-clamp: 2 !important; color: var(--mute) !important; }
  .hero-card .readmore { display: none !important; }
  .hero-actions { margin-top: 14px !important; }
  .hero-card.has-hb:before { margin-bottom: 14px !important; border-radius: 14px !important; box-shadow: 0 8px 24px rgba(0,0,0,.35); }

  /* jam cards: whole card is the tap target, no read-more clutter */
  .jam-info .readmore { display: none !important; }
  .jam-info p { -webkit-line-clamp: 2 !important; margin-bottom: 10px !important; }
  .jam-meta { padding-top: 10px; border-top: 1px solid var(--m-line); display: flex; justify-content: space-between; align-items: center; }
  .jam-meta * { font-size: 12.5px; }

  /* ---- tab bar: clear active pill ---- */
  .tb { position: relative; transition: color .15s ease; }
  .tb[aria-current="true"]:not(.tb-add), .tb[aria-current="page"]:not(.tb-add), .tb.active:not(.tb-add) { background: rgba(190,158,226,.14) !important; color: var(--purple) !important; }

  /* ---- jam page: pinned action bar + tidy action chips ---- */
  .top-actions > * { display: inline-flex; align-items: center; gap: 6px; padding: 0 14px; font-size: 13.5px; font-weight: 600; border: 1px solid var(--m-line); background: rgba(255,255,255,.04); color: var(--ink); }
  .acts {
    position: sticky; bottom: calc(var(--m-tab-h) + 22px + env(safe-area-inset-bottom, 0px)); z-index: 25;
    padding: 10px !important; margin: 0 -4px 22px !important; border-radius: 22px !important;
    background: rgba(20,19,26,.9) !important; -webkit-backdrop-filter: blur(18px) saturate(1.4); backdrop-filter: blur(18px) saturate(1.4);
    box-shadow: 0 14px 34px rgba(0,0,0,.45);
  }
  .acts .btn { height: 48px; }

  /* ---- game sheet: edge-to-edge cover, one big action, equal secondary buttons ---- */
  #dlg .game-modal-cover { border-radius: 0 !important; aspect-ratio: 16 / 10; width: 100%; }
  #dlg .in { padding: 20px 20px 22px !important; }
  #dlg h3 { font-size: 26px; letter-spacing: -.04em; margin: 4px 0 8px; }
  #dlg .g-actions {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
    margin-top: 16px;
  }
  #dlg .g-actions > .g-play {
    grid-column: 1 / -1 !important;
    height: 52px;
    font-size: 16.5px;
  }
  #dlg .g-actions > .g-close {
    grid-column: 1 / -1 !important;
    height: 48px;
    min-width: 0 !important;
  }
  #dlg .xg-manage {
    grid-column: 1 / -1 !important;
    margin-top: 0;
    padding: 12px;
  }
  #dlg .xg-manage-btns { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #dlg .xg-manage.is-owner .xg-manage-btns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #dlg .xg-manage .btn { height: 44px; font-size: 13.5px; }
  #dlg .xg-up { min-height: 50px; font-size: 15.5px; }
  #dlg .creator { border: 1px solid var(--m-line); border-radius: 16px; padding: 12px 14px; background: rgba(255,255,255,.03); }
  #dlg .xg-thread { margin-top: 4px; }
  #dlg .xg-list { max-height: min(38vh, 320px); }

  /* ---- grab handle on every bottom sheet ---- */
  dialog#dlg:before, dialog.ndlg:before {
    content: ""; position: absolute; top: 8px; left: 50%; width: 40px; height: 5px; margin-left: -20px; border-radius: 99px;
    background: rgba(255,255,255,.28); z-index: 60; pointer-events: none;
  }
  dialog.ndlg { padding-top: 6px; }
  dialog#dlg, dialog.ndlg { will-change: transform; touch-action: pan-y; }

  /* ---- search page polish ---- */
  .command-result { border: 1px solid var(--m-line); margin-bottom: 8px; background: rgba(255,255,255,.03); }
  .command-empty { padding: 60px 20px; color: var(--mute); }
}
@media (max-width: 900px) {
  .top-actions { flex-wrap: nowrap !important; }
  .acts { background: rgba(21,20,28,.98) !important; }
}


/* =====================================================================
   FIXES: top bar, full-image game tiles, full-image game sheet
   ===================================================================== */
@media (max-width: 900px) {
  /* ---- top bar: lighter, roomier, brand with its subtitle ---- */
  .mobile-topbar {
    grid-template-columns: 40px 1fr 40px 40px !important; gap: 10px !important;
    padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px 12px !important;
    background: linear-gradient(180deg, rgba(14,13,18,.97), rgba(14,13,18,.86)) !important;
    border-bottom: 0 !important; box-shadow: 0 1px 0 rgba(255,255,255,.05), 0 12px 28px rgba(0,0,0,.28);
  }
  .mobile-topbar button { width: 40px !important; height: 40px !important; border: 0 !important; border-radius: 50% !important; background: rgba(255,255,255,.07) !important; }
  .mobile-topbar #mobileMenu { background: none !important; margin-left: -6px; }
  .mobile-topbar #mobileMenu .ngi { width: 24px; height: 24px; }
  .mobile-topbar .mobile-acct { padding: 0 !important; box-shadow: 0 0 0 2px rgba(190,158,226,.5); }
  .mobile-brand { gap: 10px; }
  .mobile-brand .mk { width: 34px !important; height: 34px !important; border-radius: 10px; flex: none; }
  .mobile-brand strong { display: flex !important; flex-direction: column; gap: 3px; font: 800 18px/1 var(--d) !important; letter-spacing: -.03em; overflow: visible !important; }
  .mobile-brand strong span { display: block !important; font: 700 9.5px/1 var(--b) !important; letter-spacing: .2em; text-transform: uppercase; color: var(--mute) !important; }

  /* ---- game tiles: the whole cover is visible (covers are portrait), blurred fill if the ratio differs ---- */
  .g .tl { aspect-ratio: 9 / 16 !important; }
  .g .tl.has-banner { position: relative; overflow: hidden; background-image: none !important; background-color: #0e0e12 !important; isolation: isolate; }
  .g .tl.has-banner:before { content: ""; position: absolute; inset: -16px; z-index: 0; background: var(--bn) center / cover no-repeat; filter: blur(18px) brightness(.55) saturate(1.2); }
  .g .tl.has-banner:after { content: ""; position: absolute; inset: 0; z-index: 1; opacity: 1; background: var(--bn) center / contain no-repeat; }
  .g .tl .card-arrow, .g .tl .card-del { z-index: 3; }

  /* ---- game sheet: show the full cover ---- */
  #dlg .game-modal-cover.has-banner {
    position: relative; overflow: hidden; isolation: isolate;
    width: 100% !important; height: min(54dvh, 460px) !important; aspect-ratio: auto !important;
    background-image: none !important; background-color: #0e0e12 !important; border-radius: 0 !important;
  }
  #dlg .game-modal-cover.has-banner:before { content: ""; position: absolute; inset: -20px; z-index: 0; background: var(--bn) center / cover no-repeat; filter: blur(24px) brightness(.5) saturate(1.2); }
  #dlg .game-modal-cover.has-banner:after { content: ""; position: absolute; inset: 0; z-index: 1; background: var(--bn) center / contain no-repeat; }
}
@media (max-width: 900px) {
  .g .tl.has-banner:after { display: block !important; }
  .hero-actions .btn { white-space: nowrap; padding: 0 14px !important; font-size: 15.5px !important; }
}

/* =====================================================================
   PHONE CONSISTENCY
   Same look on every phone: solid dark surfaces (no heavy backdrop blur
   that some devices fail to paint), but animations and transitions stay on
   even if the OS has "Reduce Motion" enabled.
   ===================================================================== */
@media (max-width: 900px) {
  /* fixed ambient orbs can blank out on some GPUs — use a static glow instead */
  .ambient { display: none !important; }
  html, body {
    background-color: #0b0b0e !important;
    background-image: radial-gradient(70% 38% at 10% 0%, rgba(182,154,239,.14), transparent 70%),
                      radial-gradient(60% 30% at 100% 18%, rgba(242,200,223,.06), transparent 70%) !important;
    background-repeat: no-repeat !important; background-attachment: scroll !important;
  }

  /* solid surfaces so cards never disappear on older iOS GPUs */
  .mobile-topbar { background: #0e0d12 !important; }
  .tabbar { background: #18161f !important; }
  .acts { background: #15141c !important; }
  #sidebar { background: #111116 !important; }
  dialog::backdrop { background: rgba(4,3,7,.74) !important; }

  /* heavy blurred fills behind covers can fail to paint — keep covers, drop the blur layer */
  .mcp-orb, .g .tl.has-banner:before, .jam-big-cover.has-banner:before, #dlg .game-modal-cover.has-banner:before { display: none !important; }
  .jam-big-cover.has-banner { background-color: #0e0e12 !important; }

  /* animations stay enabled — do not force animation:none here */

  /* sheet never peeks above the home-indicator area when closed */
  #sidebar:not(.mobile-open) { visibility: hidden; pointer-events: none; transform: translateY(calc(100% + 80px)); }
  #sidebar { transition: transform .32s cubic-bezier(.2,.8,.2,1), visibility 0s linear .32s; }
  #sidebar.mobile-open { visibility: visible; transition-delay: 0s; }

  /* filter chips run edge to edge */
  .filter-row { width: calc(100% + var(--m-pad) * 2) !important; max-width: none !important; box-sizing: border-box; margin-left: calc(var(--m-pad) * -1) !important; margin-right: 0 !important; }

  /* sheets: room for the grab handle, no heavy focus ring on the close button */
  dialog.ndlg { padding-top: 20px !important; }
  .nd-x, .game-modal-x { top: 16px !important; }
  .nd-x:focus, .nd-x:focus-visible, .game-modal-x:focus, .game-modal-x:focus-visible, .mobile-topbar button:focus { outline: none !important; box-shadow: none !important; }
  .ndlg .account-head, .ndlg .account-title { padding-top: 6px; padding-right: 52px; }
}

/* Force motion on even when the phone has Reduce Motion turned on */
@media (max-width: 900px) and (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: revert !important;
    animation-iteration-count: revert !important;
    transition-duration: revert !important;
    scroll-behavior: smooth !important;
  }
}

/* =====================================================================
   CLEAN TOP BAR + FULL-SCREEN JAM MENU + SEARCH / PROFILE POLISH
   ===================================================================== */
@media (max-width: 900px) {

  /* ---- top bar: clean, balanced, no clutter ---- */
  .mobile-topbar {
    position: sticky !important;
    top: 0 !important;
    z-index: 40 !important;
    display: grid !important;
    grid-template-columns: 44px minmax(0, 1fr) 44px 44px !important;
    align-items: center !important;
    gap: 8px !important;
    height: auto !important;
    margin: 0 !important;
    padding: calc(env(safe-area-inset-top, 0px) + 8px) 14px 10px !important;
    background: #0e0d12 !important;
    border-bottom: 1px solid rgba(255,255,255,.06) !important;
    box-shadow: none !important;
  }
  .mobile-topbar button {
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;
    padding: 0 !important;
    display: grid !important;
    place-items: center !important;
    border-radius: 50% !important;
    border: 0 !important;
    background: rgba(255,255,255,.07) !important;
    color: var(--ink) !important;
    flex: none !important;
  }
  .mobile-topbar #mobileMenu {
    background: transparent !important;
    margin-left: -4px !important;
  }
  .mobile-topbar #mobileMenu .ngi {
    width: 22px !important;
    height: 22px !important;
  }
  .mobile-topbar .mobile-search .ngi {
    width: 20px !important;
    height: 20px !important;
  }
  .mobile-topbar .mobile-acct {
    overflow: hidden !important;
    padding: 0 !important;
    box-shadow: 0 0 0 2px rgba(190,158,226,.55) !important;
    background: rgba(255,255,255,.08) !important;
  }
  .mobile-topbar .mobile-acct img,
  .mobile-topbar .mobile-acct .av,
  .mobile-topbar .mobile-acct .profile-avatar-img,
  .mobile-topbar .mobile-acct .avatar {
    width: 100% !important;
    height: 100% !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    display: block !important;
  }
  .mobile-brand {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    min-width: 0 !important;
    overflow: hidden !important;
  }
  .mobile-brand .mk,
  .mobile-brand .small-mark {
    width: 32px !important;
    height: 32px !important;
    border-radius: 9px !important;
    flex: none !important;
    display: block !important;
  }
  .mobile-brand strong {
    display: flex !important;
    flex-direction: column !important;
    gap: 2px !important;
    min-width: 0 !important;
    font: 800 16px/1.05 var(--d) !important;
    letter-spacing: -.03em !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
  .mobile-brand strong span {
    display: block !important;
    font: 700 9px/1 var(--b) !important;
    letter-spacing: .18em !important;
    text-transform: uppercase !important;
    color: var(--mute) !important;
  }

  /* ---- Mega Jams menu: full-screen sheet, account card at top, swipe-down ---- */
  #sidebar {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: #111116 !important;
    box-shadow: none !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 0 !important;
    padding-bottom: env(safe-area-inset-bottom, 0px) !important;
    z-index: 60 !important;
    transform: translateY(105%) !important;
    transition: transform .34s cubic-bezier(.2,.8,.2,1), visibility 0s linear .34s !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }
  #sidebar.mobile-open {
    transform: none !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transition-delay: 0s !important;
  }
  #sidebar:not(.mobile-open) {
    transform: translateY(105%) !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }
  #sidebar .sheet-head {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex: none !important;
    position: relative !important;
    padding: calc(env(safe-area-inset-top, 0px) + 18px) 16px 10px !important;
    touch-action: none !important;
  }
  #sidebar .sheet-head .grab {
    position: absolute !important;
    top: calc(env(safe-area-inset-top, 0px) + 8px) !important;
    left: 50% !important;
    width: 40px !important;
    height: 5px !important;
    margin-left: -20px !important;
    border-radius: 99px !important;
    background: rgba(255,255,255,.22) !important;
  }
  #sidebar .sheet-head strong {
    font: 800 22px/1.1 var(--d) !important;
    letter-spacing: -.04em !important;
  }
  #sidebar .sheet-x {
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    border: 1px solid rgba(255,255,255,.1) !important;
    background: rgba(255,255,255,.06) !important;
    color: var(--ink) !important;
    display: grid !important;
    place-items: center !important;
  }
  /* hide desktop brand + search trigger, keep account card */
  #sidebar .brand,
  #sidebar .side-tools {
    display: none !important;
  }
  #sidebar .acct {
    display: grid !important;
    gap: 10px !important;
    flex: none !important;
    padding: 4px 16px 12px !important;
  }
  #sidebar .acct .acct-me {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    width: 100% !important;
    padding: 10px 12px !important;
    border: 1px solid rgba(255,255,255,.1) !important;
    border-radius: 16px !important;
    background: rgba(255,255,255,.05) !important;
    text-align: left !important;
  }
  #sidebar .acct .acct-me .avatar,
  #sidebar .acct .acct-me img {
    width: 42px !important;
    height: 42px !important;
    border-radius: 50% !important;
    flex: none !important;
  }
  #sidebar .acct .btn.wide,
  #sidebar .acct .btn.dark {
    height: 48px !important;
    border-radius: 14px !important;
    font-size: 15px !important;
  }
  #sidebar .list {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 4px 12px 12px !important;
  }
  #sidebar .item {
    min-height: 56px !important;
    border-radius: 16px !important;
  }
  #sidebar .sf {
    flex: none !important;
    padding: 10px 16px calc(12px + env(safe-area-inset-bottom, 0px)) !important;
  }
  #sidebar .btn.discord {
    height: 50px !important;
    border-radius: 15px !important;
  }

  /* ---- Search: floating sheet, centered, height follows result count ---- */
  .command-dialog {
    margin: auto !important;
    inset: 0 !important;
    width: calc(100% - 28px) !important;
    max-width: 420px !important;
    height: fit-content !important;
    max-height: min(70dvh, 520px) !important;
    border: 1px solid rgba(255,255,255,.1) !important;
    border-radius: 22px !important;
    background: #14131a !important;
    padding: 0 !important;
    box-shadow: 0 24px 60px rgba(0,0,0,.55) !important;
  }
  .command-dialog::backdrop {
    background: rgba(4,3,7,.62) !important;
  }
  .command {
    height: auto !important;
    max-height: min(70dvh, 520px) !important;
    display: flex !important;
    flex-direction: column !important;
    border-radius: 22px !important;
    background: transparent !important;
    overflow: hidden !important;
  }
  .command-head {
    flex: none !important;
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 12px 12px 8px !important;
  }
  .command-search {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    height: 46px !important;
    border-radius: 14px !important;
    background: rgba(255,255,255,.06) !important;
    border: 1px solid rgba(255,255,255,.1) !important;
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 0 14px !important;
  }
  .command-close {
    flex: none !important;
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    border: 0 !important;
    background: rgba(255,255,255,.07) !important;
    color: var(--ink) !important;
    display: grid !important;
    place-items: center !important;
    padding: 0 !important;
  }
  .command-close .ngi {
    width: 18px !important;
    height: 18px !important;
  }
  .command-search:focus-within {
    border-color: rgba(190,158,226,.55) !important;
    box-shadow: 0 0 0 3px rgba(190,158,226,.18) !important;
  }
  .command-search > span {
    display: grid !important;
    place-items: center !important;
    color: var(--mute) !important;
    flex: none !important;
  }
  .command-search input {
    flex: 1 !important;
    min-width: 0 !important;
    height: 100% !important;
    border: 0 !important;
    background: transparent !important;
    color: var(--ink) !important;
    font-size: 16px !important;
    outline: none !important;
  }
  .command-search kbd,
  .command-footer {
    display: none !important;
  }
  .command-results {
    flex: 0 1 auto !important;
    min-height: 0 !important;
    max-height: min(52dvh, 400px) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 4px 10px 14px !important;
  }
  .command-result {
    min-height: 52px !important;
    border-radius: 14px !important;
    border: 1px solid rgba(255,255,255,.06) !important;
    background: rgba(255,255,255,.03) !important;
    margin-bottom: 6px !important;
  }
  .command-empty {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 10px !important;
    padding: 28px 20px 32px !important;
    color: var(--mute) !important;
    text-align: center !important;
    min-height: 0 !important;
  }
  .command-empty > span {
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    background: rgba(255,255,255,.05) !important;
    display: grid !important;
    place-items: center !important;
  }

  /* ---- Profile / account sheet: floating ---- */
  dialog.ndlg {
    margin: auto 12px 12px !important;
    width: auto !important;
    max-width: none !important;
    left: 12px !important;
    right: 12px !important;
    bottom: 12px !important;
    top: auto !important;
    max-height: min(90dvh, 780px) !important;
    height: auto !important;
    border: 1px solid rgba(255,255,255,.1) !important;
    border-radius: 24px !important;
    background: #14131a !important;
    box-shadow: 0 24px 60px rgba(0,0,0,.55) !important;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)) !important;
  }
  dialog.ndlg::backdrop {
    background: rgba(4,3,7,.62) !important;
  }
  .nd-x {
    top: 14px !important;
    right: 14px !important;
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    background: rgba(255,255,255,.08) !important;
  }
}

/* =====================================================================
   LOCK THE LOOK: same on every device, motion always on
   ===================================================================== */
@media (max-width: 900px) {
  /* tab labels always visible — except the center + (no "Publish" text) */
  .tb .tbl { display: block !important; font-size: 10.5px !important; }
  .tb.tb-add .tbl { display: none !important; }
  .tb { font-size: 10.5px !important; }

  /* brand subtitle stays visible */
  .mobile-brand strong span { display: block !important; }

  /* force dark palette regardless of OS light/dark setting */
  html, body, :root, :root[data-theme] {
    color-scheme: dark !important;
    --bg: #0b0b0e !important;
    --side: rgba(17,17,22,.94) !important;
    --panel: #17171d !important;
    --panel2: #22222b !important;
    --ink: #f5f3f8 !important;
    --mute: #a09baa !important;
    --line: rgba(255,255,255,.105) !important;
  }

  /* keep subtle transitions on interactive chrome */
  .tabbar, .tb, .mobile-topbar button, .btn, .filter, .item, .command-dialog, #sidebar {
    transition: transform .22s ease, opacity .2s ease, background .2s ease, box-shadow .2s ease !important;
  }
}

/* Game cards: real rounded corners on phones (cover clips to radius) */
@media (max-width: 900px) {
  .g .tl,
  .grid .g .tl,
  #pg .g .tl {
    border-radius: 22px !important;
    overflow: hidden !important;
    transform: translateZ(0); /* forces iOS to respect radius clipping */
    -webkit-transform: translateZ(0);
  }
  /* paint the banner on the tile itself so radius always clips the image */
  .g .tl.has-banner {
    background-image: var(--bn) !important;
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    background-color: #121218 !important;
  }
  .g .tl.has-banner:before,
  .g .tl.has-banner:after {
    display: none !important;
    content: none !important;
  }
}
@media (max-width: 900px) {

  /* Mobile BGM: bottom-right floating chip (a bit above tab bar) */
  .bgm-toggle{
    z-index: 80 !important;
    top: auto !important;
    left: auto !important;
    right: max(14px, env(safe-area-inset-right, 0px)) !important;
    bottom: calc(var(--m-tab-h, 66px) + 28px + env(safe-area-inset-bottom, 0px)) !important;
    min-height: 42px !important;
    gap: 7px !important;
    padding: 10px 15px !important;
    font-size: 12.5px !important;
    font-weight: 700 !important;
    letter-spacing: .01em !important;
    border-radius: 999px !important;
    box-shadow: 0 10px 28px rgba(0,0,0,.42) !important;
    transition: transform .28s cubic-bezier(.2,.9,.3,1), opacity .2s, background .2s, color .2s !important;
    pointer-events: auto !important;
  }
  .bgm-toggle .bgm-ico{ font-size: 15px !important; line-height: 1 !important; }
  .bgm-toggle .bgm-txt{ max-width: 90px; overflow: hidden; white-space: nowrap; }
  .bgm-toggle.bgm-tucked{
    transform: translateX(calc(100% - 20px));
    opacity: .95;
    padding-left: 12px !important;
    padding-right: 10px !important;
  }
  .bgm-toggle.bgm-tucked .bgm-txt{ display: none; }

}
