  .cat-tabs {
    display: flex; gap: 4px;
    justify-content: center;
    margin: 0 0 12px;
    border-bottom: 1px solid var(--border-2);
    flex-wrap: wrap;
    position: sticky; top: 0; z-index: 5;
    background: var(--bg, #0e0e12);
    padding-top: 6px;
  }
  /* Открытый список жанра должен быть НАД плитками игр (их z-index 5–6 в
     my-games.css). .cat-tabs — sticky stacking-контекст с z-index:5, поэтому
     меню внутри (z-index:30) перекрывалось кнопками карточек («Играть» и др.).
     Поднимаем весь контекст бара выше плиток ТОЛЬКО пока список открыт (десктоп;
     на мобиле genre вынесен в верхнюю панель и под это правило не попадает). */
  .cat-tabs:has(.cat-genre.open) { z-index: 60; }

  @media (max-width: 640px) {
    /* App-shell: .main is the scroll container, .side is a separate top row
       OUTSIDE it. So .cat-tabs sticky pins at the TOP of .main's scroll
       viewport (right under the top bar) — top:0, no magic offset needed. */
    .cat-tabs {
      top: 0;
      z-index: 10;
    }
    /* Raise .kv two-column→stacked breakpoint from 560px to 640px so the
       200px label column does not crush values on phone-width screens. */
    .kv { grid-template-columns: 1fr; gap: 2px 0; }
    .kv .k { margin-top: 6px; }
    /* Bump card meta text one step for legibility on small screens. */
    .game-card .meta { font-size: 13px; }
  }

  @media (max-width: 640px), (hover: none) and (pointer: coarse) {
    /* Grow tap target for tab buttons to the 44px WCAG minimum. Use min-height
       so the layout does not break on wider screens. */
    .cat-tab { min-height: 44px; padding: 0 16px; }
  }

  @media (max-width: 560px) {
    /* Detail-hero title: clamp prevents the 32px heading overflowing narrow
       screens; line-clamp keeps it to 2 lines so the poster is still visible. */
    .detail-hero .title-on {
      font-size: clamp(18px, 5vw, 28px);
      left: 16px; bottom: 14px;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      overflow: hidden;
    }
  }

  /* Catalog sits close to the top — trim the page's top gutter, scoped to the
     catalog screen via :has(> .cat-tabs) so no per-route class is needed. */
  .main:has(> .cat-tabs) { padding-top: 12px; }
  .cat-tab {
    padding: 7px 14px;
    background: transparent;
    border: 0;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    font-size: 13px;
    cursor: pointer;
    transition: color 0.12s ease, border-color 0.12s ease;
  }
  @media (hover: hover) { .cat-tab:hover:not(:disabled) { color: var(--text); } }
  .cat-tab.active {
    color: var(--text);
    border-bottom-color: rgba(110, 150, 135, 0.7);
  }
  .cat-tab.disabled, .cat-tab:disabled {
    opacity: 0.4;
    cursor: not-allowed;
  }

  /* ── Mobile category picker — single centered custom dropdown ──────────────
     On phones the 7-tab bar wrapped to 3–4 rows (very tall). Below 640px we hide
     the bar and show one compact centered field that opens a styled dropdown.
     Desktop keeps the inline tab bar. */
  .cat-select { display: none; }

  /* Phones — portrait (≤640) AND landscape (short viewport), mirroring the shell
     nav breakpoint in responsive.css so a landscape phone gets the compact
     dropdown instead of the desktop 7-tab bar. */
  @media (max-width: 640px), (orientation: landscape) and (max-height: 520px) {
    .cat-tabs { display: none; }
    /* Pull the picker flush against the top menu (no big top gutter on the
       catalog screen) — overrides the global 12px + responsive .main padding. */
    .main:has(> .cat-tabs) { padding-top: 4px; }
    .cat-select {
      display: block;
      position: sticky; top: 0; z-index: 10;
      margin: 0 auto 8px;
      width: 100%;            /* shrink below the 340px cap on very narrow phones */
      max-width: 340px;
      box-sizing: border-box; /* never exceed the .main gutter → no right-edge clip */
      background: transparent; /* no dark band — sits flush under the top menu */
      padding-top: 0;
    }
    .cat-select-trigger {
      position: relative;
      display: flex; align-items: center; justify-content: center;
      width: 100%; min-height: 44px;
      padding: 0 40px; /* symmetric room for the chevron → label stays centred */
      background: transparent; /* убран «чёрный фон» — поле без тёмной заливки */
      border: 1px solid var(--border-2);
      border-radius: var(--r-md, 10px);
      color: var(--text);
      font-size: 15px; font-weight: 600;
      cursor: pointer;
    }
    .cat-select-label { text-align: center; line-height: 1.2; }
    .cat-select-chev {
      position: absolute; right: 14px;
      font-size: 12px; color: var(--muted);
      transition: transform 0.18s ease;
    }
    .cat-select.open .cat-select-chev { transform: rotate(180deg); }
    .cat-select.open .cat-select-trigger { border-color: rgba(110, 150, 135, 0.6); }

    .cat-select-menu {
      position: absolute; top: calc(100% + 6px); left: 0; right: 0;
      display: flex; flex-direction: column; gap: 2px;
      padding: 6px;
      background: var(--surface-2, #1c2128);
      border: 1px solid var(--border-2);
      border-radius: var(--r-md, 10px);
      box-shadow: var(--shadow-card, 0 12px 30px rgba(0, 0, 0, 0.5));
      max-height: 60vh; overflow-y: auto;
      z-index: 30;
    }
    .cat-select-menu[hidden] { display: none; }
    .cat-opt {
      width: 100%; min-height: 42px;
      padding: 0 12px;
      background: transparent; border: 0; border-radius: 8px;
      color: var(--muted);
      font-size: 15px; text-align: center;
      cursor: pointer;
      transition: background 0.12s ease, color 0.12s ease;
    }
    .cat-opt.active {
      color: var(--text); font-weight: 600;
      background: var(--accent-glow, rgba(110, 150, 135, 0.18));
    }
    .cat-opt.disabled, .cat-opt:disabled { opacity: 0.4; cursor: not-allowed; }
  }

  /* ── Genre filter — custom dropdown that lives WITH the categories ─────────
     Desktop: it is the last child of .cat-tabs, pinned to the right end of the
     tab row via margin-left:auto (after the last tab). Phones: catalog.js lifts
     it into the shell top bar next to the category picker (see the lifted-bar
     rules near the end of this section). Visual language mirrors .cat-select
     (surface menu, soft border, accent-glow active row). Optional search inside
     the menu when many genres are present. */
  .cat-tabs .cat-genre { margin-left: auto; align-self: center; }
  .cat-genre {
    position: relative;
    display: inline-flex; align-items: center; gap: 8px;
    max-width: 100%;
  }
  .cat-genre-cap {
    font-size: 12px; color: var(--muted);
    white-space: nowrap;
  }
  .cat-genre-trigger {
    position: relative;
    display: inline-flex; align-items: center;
    min-height: 36px;
    padding: 0 34px 0 12px;
    max-width: 260px;
    background: transparent;
    border: 1px solid var(--border-2);
    border-radius: var(--r-md, 10px);
    color: var(--text);
    font-size: 13px; font-weight: 600;
    cursor: pointer;
    transition: border-color 0.12s ease;
  }
  @media (hover: hover) { .cat-genre-trigger:hover { border-color: rgba(110, 150, 135, 0.45); } }
  .cat-genre-val { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cat-genre-chev {
    position: absolute; right: 12px;
    font-size: 11px; color: var(--muted);
    transition: transform 0.18s ease;
  }
  .cat-genre.open .cat-genre-chev { transform: rotate(180deg); }
  .cat-genre.open .cat-genre-trigger { border-color: rgba(110, 150, 135, 0.6); }

  .cat-genre-menu {
    position: absolute; top: calc(100% + 6px); right: 0;
    min-width: 220px; max-width: min(86vw, 320px);
    display: flex; flex-direction: column;
    padding: 6px;
    background: var(--surface-2, #1c2128);
    border: 1px solid var(--border-2);
    border-radius: var(--r-md, 10px);
    box-shadow: var(--shadow-card, 0 12px 30px rgba(0, 0, 0, 0.5));
    z-index: 30;
  }
  .cat-genre-menu[hidden] { display: none; }
  .cat-genre-search-wrap { padding: 2px 2px 6px; }
  .cat-genre-search {
    width: 100%; box-sizing: border-box;
    min-height: 36px; padding: 0 10px;
    background: var(--surface, #0e0e12);
    border: 1px solid var(--border-2);
    border-radius: 8px;
    color: var(--text); font-size: 14px;
  }
  .cat-genre-search:focus { outline: none; border-color: rgba(110, 150, 135, 0.6); }
  .cat-genre-opts {
    display: flex; flex-direction: column; gap: 2px;
    max-height: 50vh; overflow-y: auto;
  }
  .cat-gopt {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    width: 100%; min-height: 38px;
    padding: 0 10px;
    background: transparent; border: 0; border-radius: 8px;
    color: var(--muted);
    font-size: 14px; text-align: left;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
  }
  @media (hover: hover) { .cat-gopt:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); } }
  .cat-gopt.active {
    color: var(--text); font-weight: 600;
    background: var(--accent-glow, rgba(110, 150, 135, 0.18));
  }
  .cat-gopt.is-hidden { display: none; }
  .cat-gopt-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cat-gopt-count {
    flex: none;
    font-size: 12px; color: var(--muted);
    font-variant-numeric: tabular-nums;
  }

  @media (max-width: 640px), (hover: none) and (pointer: coarse) {
    .cat-genre-trigger { min-height: 40px; }
    .cat-gopt { min-height: 42px; }
  }

  /* Genre dropdown lifted into the shell top bar on phones (catalog.js moves the
     node into .side .brand-row, right after the category picker). A compact pill
     mirroring the lifted .cat-select; its menu drops below the bar (.side has
     overflow:visible) and hugs the right edge so it never clips. These match by
     STRUCTURE — the genre node only lives in .brand-row while lifted — so no
     media query is needed (on desktop it stays inside .cat-tabs and is unaffected). */
  .side .brand-row .cat-genre {
    flex: 0 1 auto; min-width: 0; max-width: 130px;
    margin: 0;
  }
  .side .brand-row .cat-genre-cap { display: none; } /* save width in the compact bar */
  .side .brand-row .cat-genre-trigger {
    width: 100%; max-width: none;
    min-height: 34px; padding: 0 26px 0 10px;
    font-size: 13px;
  }
  .side .brand-row .cat-genre-chev { right: 9px; }
  .side .brand-row .cat-genre-menu {
    left: auto; right: 0;
    min-width: 200px; max-width: 80vw;
    z-index: 80;
  }

  /* ============================================================
     FEATURED ROWS (Главная) — три куратор-ряда над общей сеткой.
     Ряд 1 = 2 крупные карточки, ряд 2 = 3 средние, ряд 3 = 4 мелкие.
     Карточки внутри — обычные .my-tile (все кнопки/обложки/щит работают),
     раскладку задаёт фиксированное число колонок на каждый ряд. */
  .cat-rows {
    display: flex; flex-direction: column;
    gap: 18px;
    margin: 0 0 22px;
  }
  .cat-row-grid { display: grid; gap: 18px; }
  .cat-row--1 .cat-row-grid { grid-template-columns: repeat(2, 1fr); }
  .cat-row--2 .cat-row-grid { grid-template-columns: repeat(3, 1fr); }
  .cat-row--3 .cat-row-grid { grid-template-columns: repeat(4, 1fr); }
  /* Лёгкая визуальная иерархия: верхний ряд чуть «дороже». */
  .cat-row--1 .my-tile { box-shadow: var(--shadow-card); }

  /* Планшеты — ужимаем число колонок, чтобы карточки не мельчали. */
  @media (max-width: 1000px) {
    .cat-row--3 .cat-row-grid { grid-template-columns: repeat(3, 1fr); }
  }
  @media (max-width: 760px) {
    .cat-row--1 .cat-row-grid { grid-template-columns: repeat(2, 1fr); }
    .cat-row--2 .cat-row-grid { grid-template-columns: repeat(2, 1fr); }
    .cat-row--3 .cat-row-grid { grid-template-columns: repeat(2, 1fr); }
  }
  @media (max-width: 460px) {
    .cat-row--1 .cat-row-grid { grid-template-columns: 1fr; }
    .cat-row--2 .cat-row-grid,
    .cat-row--3 .cat-row-grid { grid-template-columns: repeat(2, 1fr); }
    .cat-rows { gap: 12px; }
    .cat-row-grid { gap: 12px; }
  }

  .grid-games {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
  }
  .game-card {
    position: relative;
    background:
      linear-gradient(180deg, rgba(255,220,180,0.04), transparent 50%),
      var(--surface);
    border: 1px solid var(--border-2);
    border-radius: var(--r-md);
    overflow: hidden;
    cursor: pointer;
    box-shadow: var(--shadow-card);
    transition: transform 0.12s ease, border-color 0.12s ease;
  }
  @media (hover: hover) {
    .game-card:hover {
      transform: translateY(-2px);
      border-color: rgba(110,150,135,0.35);
    }
  }
  .game-card .poster {
    aspect-ratio: 16/9;
    background:
      radial-gradient(140% 140% at 0% 0%, rgba(255,180,120,0.12), transparent 55%),
      linear-gradient(135deg, #245c49 0%, #143a2c 60%, #1a1714 100%);
    position: relative;
  }
  .game-card .poster .ph {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    color: rgba(255,255,255,0.55); font-weight: 700; letter-spacing: 1px;
    font-size: 18px;
  }
  .game-card .body { padding: 12px 14px; }
  .game-card h3 { margin: 0 0 4px; font-size: 14px; font-weight: 600; }
  .game-card .meta { font-size: 12px; color: var(--muted); }

  /* Game detail */
  .detail-hero {
    aspect-ratio: 21/9;
    border-radius: var(--r-lg);
    background:
      radial-gradient(140% 140% at 0% 0%, rgba(255,180,120,0.14), transparent 55%),
      linear-gradient(135deg, #225e4a 0%, #11362a 60%, #1a1714 100%);
    margin-bottom: 22px;
    border: 1px solid var(--border-2);
    box-shadow: var(--shadow-card);
    position: relative;
  }
  .detail-hero .title-on {
    position: absolute; left: 28px; bottom: 24px;
    font-size: 32px; font-weight: 700;
    text-shadow: 0 2px 18px rgba(0,0,0,0.6);
  }
  .kv { display: grid; grid-template-columns: 200px 1fr; gap: 6px 18px; font-size: 13px; }
  .kv .k { color: var(--muted); }
  .kv .v { color: var(--text); word-break: break-all; }

  /* Джем-бейдж на тайлах/карточках каталога. */
  .applied-badges-jam {
    position: absolute;
    left: 8px; bottom: 8px;
    right: auto; top: auto;
    display: flex; flex-direction: column; gap: 4px;
    align-items: flex-start;
    z-index: 5;
    pointer-events: none;
    max-width: 70%;
  }
  .applied-badge.jam {
    border-color: rgba(220, 180, 60, 0.5);
    background: rgba(48, 38, 8, 0.88);
    color: #f5e0a0;
    pointer-events: auto;
    text-decoration: none;
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    display: inline-block;
  }
