/**
 * Monopoly UA — touch-телефоны: responsive hub/lobby.
 * Без desktop-canvas, zoom и панорамирования — только адаптивная вёрстка.
 * body.game-active (матч, поле) — НЕ ТРОГАТЬ (см. ниже).
 * @media (max-width: 900px) and (pointer: coarse)
 */

@media (max-width: 900px) and (pointer: coarse) {
  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  html:has(body:not(.game-active)) {
    height: 100%;
    overflow-x: hidden;
  }

  body:not(.game-active) {
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 0;
  }

  /* ── Landing ── */
  #landingScreen {
    position: relative;
    width: 100%;
    max-width: 100vw;
    min-width: 0;
    overflow-x: hidden;
    overflow-y: visible;
  }

  #landingScreen > * {
    min-width: 0;
    max-width: 100%;
  }

  #landingScreen .landing-header {
    flex-wrap: wrap;
    gap: 8px;
    padding-top: max(10px, env(safe-area-inset-top, 0px));
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
  }

  #landingScreen .landing-header-left {
    flex: 1 1 auto;
    min-width: 0;
  }

  #landingScreen .landing-hub-topnav {
    order: 3;
    flex: 1 1 100%;
    justify-content: stretch;
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
    overflow: visible;
  }

  #landingScreen .landing-hub-topnav .hub-topnav-link {
    flex: 1 1 calc(33.333% - 4px);
    min-width: 0;
    min-height: 44px;
    padding: 10px 6px;
    font-size: 12px;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #landingScreen .landing-features-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  /* ── Lobby shell: весь экран, только вертикальный scroll страницы ── */
  #lobbyScreen.lobby-screen,
  #lobbyScreen {
    --hub-gutter: max(10px, env(safe-area-inset-left, 0px));
    --hub-pad-left: max(10px, env(safe-area-inset-left, 0px));
    --hub-pad-right: max(10px, env(safe-area-inset-right, 0px));
    --hub-space-xs: 6px;
    --hub-space-sm: 10px;
    --hub-space-md: 14px;
    --hub-space-lg: 18px;
    --hub-topbar-h: auto;
    --hub-play-sidebar: 100%;
    --hub-play-games: 100%;
    --hub-radius-sm: 10px;
    --hub-radius-md: 14px;
    --hub-radius-lg: 18px;
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior-x: none;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    display: flex;
    flex-direction: column;
  }

  #lobbyScreen .hub-desktop-root {
    flex: 1 0 auto;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow: visible !important;
    padding-inline: var(--hub-pad-left) var(--hub-pad-right);
    box-sizing: border-box;
  }

  #lobbyScreen .hub-stage-slot,
  #lobbyScreen .hub-shell,
  #lobbyScreen .hub-topbar,
  #lobbyScreen .hub-main,
  #lobbyScreen .site-footer {
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  #lobbyScreen .hub-shell {
    margin: 0;
    zoom: 1;
  }

  /* Topbar: компактная многострочная шапка */
  #lobbyScreen .hub-topbar {
    flex-wrap: wrap;
    gap: 8px;
    width: calc(100% + var(--hub-pad-left) + var(--hub-pad-right)) !important;
    max-width: 100vw !important;
    margin-inline: calc(-1 * var(--hub-pad-left)) calc(-1 * var(--hub-pad-right));
    padding:
      max(8px, env(safe-area-inset-top, 0px))
      max(var(--hub-pad-right), env(safe-area-inset-right, 0px))
      8px
      max(var(--hub-pad-left), env(safe-area-inset-left, 0px));
  }

  #lobbyScreen .hub-topbar-left {
    flex: 1 1 auto;
    min-width: 0;
    order: 0;
  }

  #lobbyScreen .hub-logo-text {
    font-size: 15px;
    line-height: 1.2;
  }

  #lobbyScreen .hub-logo-text small {
    font-size: 9px;
    letter-spacing: 0.12em;
  }

  #lobbyScreen .hub-topbar-right {
    order: 2;
    flex: 1 1 100%;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
  }

  #lobbyScreen .hub-progress-strip {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 14px;
  }

  #lobbyScreen .hub-progress-meta {
    min-width: 0;
    max-width: none;
    flex: 1 1 120px;
  }

  #lobbyScreen .hub-xp-caption {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #lobbyScreen .hub-topnav {
    order: 3;
    flex: 1 1 100%;
    justify-content: stretch;
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
    overflow: visible;
    margin-inline: 0;
    padding-inline: 0;
  }

  #lobbyScreen .hub-topnav-link {
    flex: 1 1 calc(50% - 3px);
    min-width: 0;
    min-height: 44px;
    padding: 10px 8px;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    box-sizing: border-box;
  }

  #lobbyScreen .hub-profile-btn {
    padding: 8px 10px;
    max-width: min(160px, 42vw);
    min-width: 0;
    min-height: 44px;
  }

  #lobbyScreen .hub-profile-btn-nick-wrap {
    max-width: 100%;
    min-width: 0;
  }

  #lobbyScreen .hub-profile-btn-nick {
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #lobbyScreen .hub-donate-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
  }

  #lobbyScreen button,
  #lobbyScreen a,
  #lobbyScreen .lobby-btn,
  #lobbyScreen .hub-topnav-link,
  #lobbyScreen .hub-create-game-btn {
    touch-action: manipulation;
  }

  #lobbyScreen .hub-main {
    padding: 12px 0 max(16px, env(safe-area-inset-bottom, 0px));
    overflow: visible;
  }

  /* Грати: одна колонка, без 3-col desktop grid */
  #lobbyScreen .hub-play-layout.hub-panel.is-active {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: unset !important;
    grid-template-areas: unset !important;
    gap: var(--hub-space-sm);
    width: 100%;
    min-width: 0;
  }

  #lobbyScreen .hub-play-col--center {
    order: 1;
  }

  #lobbyScreen .hub-play-col--games {
    order: 2;
  }

  #lobbyScreen .hub-play-col--quests {
    order: 3;
  }

  #lobbyScreen .hub-play-col--quests,
  #lobbyScreen .hub-play-col--games,
  #lobbyScreen .hub-play-col--center {
    position: static;
    max-height: none;
    overflow: visible;
    width: 100%;
    min-width: 0;
  }

  #lobbyScreen .hub-play-card {
    padding: 14px 12px;
    max-width: none;
  }

  #lobbyScreen .hub-home-title {
    font-size: clamp(1.15rem, 4.8vw, 1.45rem);
    line-height: 1.2;
  }

  #lobbyScreen .hub-home-lead {
    font-size: 14px;
    max-width: 100%;
  }

  #lobbyScreen .hub-play-quick {
    flex-direction: column;
    gap: 10px;
  }

  #lobbyScreen .hub-play-quick .hub-create-game-btn,
  #lobbyScreen .hub-play-quick .hub-dev-notice {
    width: 100%;
    flex: 1 1 auto;
  }

  #lobbyScreen .hub-create-game-btn,
  #lobbyScreen .lobby-btn,
  #lobbyScreen .hub-trn-btn,
  #lobbyScreen .hub-trn-subnav-btn,
  #lobbyScreen .hub-shop-buy-btn {
    width: 100%;
    max-width: 100%;
    min-height: 44px;
    padding: 12px 16px;
    font-size: 15px;
    box-sizing: border-box;
  }

  #lobbyScreen .hub-daily-quests,
  #lobbyScreen .hub-global-chat,
  #lobbyScreen .hub-card,
  #lobbyScreen .hub-waiting-list,
  #lobbyScreen .hub-room-list {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  #lobbyScreen .hub-banner-wrap {
    gap: 4px;
    margin-top: 0;
    padding-top: 0;
  }

  #lobbyScreen .hub-banner-slide {
    min-height: clamp(88px, 24vw, 120px);
    padding: 12px 14px 22px;
  }

  #lobbyScreen .hub-banner-nav {
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    font-size: 20px;
  }

  #lobbyScreen .hub-banner-slide--support .hub-banner-copy,
  #lobbyScreen .hub-banner-slide--vip .hub-banner-copy,
  #lobbyScreen .hub-banner-slide--channel .hub-banner-copy {
    max-width: 100%;
  }

  #lobbyScreen .mode-tabs {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
  }

  #lobbyScreen .mode-tab,
  #lobbyScreen .mode-opt,
  #lobbyScreen .lobby-leave-room {
    min-height: 44px;
    max-width: 100%;
    box-sizing: border-box;
  }

  #lobbyScreen .mode-opt {
    min-width: 0;
    overflow: hidden;
  }

  #lobbyScreen .mode-opt span {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #lobbyScreen .hub-create-game-btn,
  #lobbyScreen .lobby-btn,
  #lobbyScreen .hub-waiting-item,
  #lobbyScreen .hub-room-card {
    max-width: 100%;
  }

  /* Профіль */
  #lobbyScreen .hub-profile-hero {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
  }

  #lobbyScreen .hub-profile-nick-row {
    flex-direction: column;
    min-width: 0;
  }

  #lobbyScreen .hub-profile-save {
    width: 100%;
    padding: 14px 20px;
  }

  #lobbyScreen .hub-profile-page .hub-inv-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  #lobbyScreen .hub-profile-stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  /* Магазин */
  #lobbyScreen .hub-shop-head {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  #lobbyScreen .hub-shop-avatar-grid,
  #lobbyScreen .hub-shop-color-grid,
  #lobbyScreen .hub-shop-bg-grid,
  #lobbyScreen .hub-shop-prefix-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 96px), 1fr));
    gap: 8px;
  }

  /* Турніри / топ — широкие таблицы скроллятся внутри блока, не вся страница */
  #lobbyScreen .hub-trn-leader-list,
  #lobbyScreen .hub-leader-list {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }

  #lobbyScreen .hub-trn-leader-row {
    grid-template-columns: 32px minmax(0, 1.2fr) repeat(3, minmax(52px, 1fr)) minmax(52px, 1fr);
    font-size: 12px;
    min-width: min(100%, 520px);
  }

  #lobbyScreen .hub-trn-leader-mmr {
    grid-column: auto;
    text-align: right;
    padding-top: 0;
  }

  #lobbyScreen .hub-leader-row {
    flex-wrap: wrap;
    gap: 4px 8px;
  }

  /* Footer */
  #lobbyScreen .site-footer {
    width: calc(100% + var(--hub-pad-left) + var(--hub-pad-right)) !important;
    margin-left: calc(-1 * var(--hub-pad-left));
    margin-right: calc(-1 * var(--hub-pad-right));
  }

  #lobbyScreen .site-footer__grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  #lobbyScreen .site-footer__social {
    grid-column: auto;
  }

  #lobbyScreen .site-footer__links-grid {
    grid-template-columns: 1fr 1fr;
  }

  #lobbyScreen .hub-invite-stack,
  .lobby-screen .hub-invite-stack {
    left: max(12px, env(safe-area-inset-left, 0px));
    right: max(12px, env(safe-area-inset-right, 0px));
    bottom: max(72px, calc(12px + env(safe-area-inset-bottom, 0px)));
    max-width: min(360px, calc(100vw - 24px));
  }

  .hub-reconnect-btn,
  #globalReconnectBtn {
    touch-action: manipulation;
  }

  .global-reconnect-banner {
    left: max(10px, env(safe-area-inset-left, 0px));
    right: max(10px, env(safe-area-inset-right, 0px));
    bottom: max(10px, env(safe-area-inset-bottom, 0px));
    max-width: none;
  }

  .lobby-input {
    font-size: 16px;
  }
}

@media (max-width: 900px) and (pointer: coarse) and (max-width: 480px) {
  #landingScreen .landing-hub-topnav .hub-topnav-link {
    flex: 1 1 calc(50% - 3px);
    font-size: 11px;
  }

  #lobbyScreen .mode-tabs {
    flex-direction: column;
  }

  #lobbyScreen .mode-tab {
    width: 100%;
  }
}

  /* ═══ Фаза 2 — активна гра (поле, landscape, модалки) ═══ */

  html:has(body.game-active) {
    height: 100%;
    max-height: 100svh;
    overflow: hidden;
  }

  body.game-active {
    display: grid;
    grid-template-areas: "game";
    grid-template-rows: 1fr;
    grid-template-columns: 1fr;
    width: 100%;
    height: 100%;
    min-height: 0;
    max-height: 100svh;
    padding: 0;
    overflow: hidden;
    box-sizing: border-box;
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
    background-attachment: scroll;
  }

  body.game-active[data-player-game-bg="azure"] {
    background-color: #0a1220;
    background-image:
      radial-gradient(ellipse 85% 65% at 8% 95%, rgba(14, 165, 233, 0.22) 0%, transparent 55%),
      radial-gradient(ellipse 70% 55% at 92% 8%, rgba(20, 184, 166, 0.18) 0%, transparent 50%);
  }

  body.game-active[data-player-game-bg="odesa"] {
    background-color: #160c14;
    background-image:
      radial-gradient(ellipse 90% 70% at 10% 100%, rgba(179, 58, 74, 0.22) 0%, transparent 55%),
      radial-gradient(ellipse 75% 55% at 95% 5%, rgba(212, 175, 55, 0.18) 0%, transparent 50%);
  }

  body.game-active[data-player-game-bg="kharkiv"] {
    background-color: #071510;
    background-image:
      radial-gradient(ellipse 95% 70% at 0% 100%, rgba(34, 197, 94, 0.2) 0%, transparent 58%),
      radial-gradient(ellipse 70% 50% at 100% 0%, rgba(52, 211, 153, 0.1) 0%, transparent 52%);
  }

  body.game-active[data-player-game-bg="dnepr"] {
    background-color: #120a08;
    background-image:
      radial-gradient(ellipse 90% 55% at 50% 0%, rgba(251, 146, 60, 0.28) 0%, transparent 55%),
      radial-gradient(ellipse 80% 60% at 100% 100%, rgba(14, 165, 233, 0.18) 0%, transparent 52%);
  }

  body.game-active[data-player-game-bg="tournament"] {
    background-color: #0d0618;
    background-image:
      radial-gradient(ellipse 90% 70% at 50% 0%, rgba(212, 175, 55, 0.24) 0%, transparent 55%),
      radial-gradient(ellipse 80% 60% at 50% 100%, rgba(139, 41, 66, 0.22) 0%, transparent 52%),
      radial-gradient(ellipse 60% 50% at 100% 50%, rgba(88, 28, 135, 0.15) 0%, transparent 50%);
  }

  body.game-active[data-player-game-bg]::before,
  body.game-active[data-player-game-bg]::after {
    display: none;
  }

  body.game-active > #gameDesktopRoot {
    grid-area: game;
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    max-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    overscroll-behavior: none;
    padding:
      env(safe-area-inset-top, 0px)
      env(safe-area-inset-right, 0px)
      env(safe-area-inset-bottom, 0px)
      env(safe-area-inset-left, 0px);
    box-sizing: border-box;
    background: transparent;
    background-image: none;
  }

  body.game-active #gameArea,
  body.game-active .game-area {
    transform-origin: center center !important;
    flex-shrink: 0;
  }

  body.game-active .board-viewport,
  body.game-active .board-zoom-surface,
  body.game-active .board-scale-slot {
    max-width: 100%;
    max-height: 100%;
  }

  body.game-active[data-player-game-bg] .game-area {
    background-color: transparent;
    background-image: none;
  }

  /* Кубики на touch: плавніша 2D-анімація + компактний розмір */
  body.game-active .bc-dice-col {
    isolation: isolate;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    width: 152px;
    gap: 8px;
  }

  body.game-active .dice-pair {
    gap: 16px;
    justify-content: center;
  }

  body.game-active .dice-scene {
    width: 56px;
    height: 56px;
    perspective: 96px;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    flex-shrink: 0;
  }

  body.game-active .dice {
    width: 56px;
    height: 56px;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
  }

  body.game-active .dice .face {
    width: 56px;
    height: 56px;
    border-radius: 10px;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.1);
  }

  body.game-active .dice .face.f1 { transform: translateZ(28px); }
  body.game-active .dice .face.f2 { transform: rotateY(180deg) translateZ(28px); }
  body.game-active .dice .face.f3 { transform: rotateY(90deg) translateZ(28px); }
  body.game-active .dice .face.f4 { transform: rotateY(-90deg) translateZ(28px); }
  body.game-active .dice .face.f5 { transform: rotateX(90deg) translateZ(28px); }
  body.game-active .dice .face.f6 { transform: rotateX(-90deg) translateZ(28px); }

  body.game-active .dice .dot {
    width: 9px;
    height: 9px;
    box-shadow: none;
  }

  body.game-active .dice-res-num {
    font-size: 34px;
    min-height: 40px;
  }

  body.game-active .game-session-clock {
    max-width: 140px;
  }

  body.game-active .dice-pair.is-rolling .dice {
    will-change: transform;
  }

  body.game-active .dice.rolling {
    animation: diceRollTouch 0.72s linear forwards;
  }

  @keyframes diceRollTouch {
    from {
      transform: rotateY(0deg);
    }
    to {
      transform: rotateY(720deg);
    }
  }


  /*
   * ═══ Фаза 3 — bounds = .board-center, компактні popup
   * Fix: overlay по висоті = safe viewport (без обрізання знизу)
   */

  body.game-active {
    --m-stage-display-w: min(
      calc(100vw - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)),
      calc((100svh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)) * 1190 / 640)
    );
    --m-stage-display-h: min(
      calc(100svh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)),
      calc((100vw - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)) * 640 / 1190)
    );
    --m-bc-left-ratio: 0.2546;
    --m-bc-top-ratio: 0.1391;
    --m-bc-width-ratio: 0.6697;
    --m-bc-height-ratio: 0.7109;
    --m-bc-wrap-pad: 4px;
    --m-bc-edge: var(--board-edge-size, 84px);
    --m-bc-mid-cols: var(--board-mid-cols, 14);
    --m-bc-mid-rows: var(--board-mid-rows, 8);
    --m-bc-mid-size: var(--board-mid-size, 56px);
    --m-bc-grid-gap: 1px;
    --m-safe-h: calc(
      100svh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)
    );
    --m-popup-max-h: calc(var(--m-safe-h) - 8px);
    --m-bc-pad: 5px;
    --m-bc-bounds-w: calc(
      var(--m-stage-display-w) * var(--m-bc-width-ratio) - 2 * var(--m-bc-pad)
    );
    --m-bc-bounds-h: calc(
      var(--m-stage-display-h) * var(--m-bc-height-ratio) - 2 * var(--m-bc-pad)
    );
    --m-bc-bounds-top: calc(
      50% - var(--m-stage-display-h) / 2 +
      var(--m-stage-display-h) * var(--m-bc-top-ratio)
    );
    --m-bc-bounds-left: calc(
      50% - var(--m-stage-display-w) / 2 +
      var(--m-stage-display-w) * var(--m-bc-left-ratio)
    );
    /* Trade: bounds від центру сцени в #gameDesktopRoot (safe-area), не від 50% viewport */
    --m-stage-viewport-x: calc(
      env(safe-area-inset-left, 0px) +
      (
        100vw - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px) -
        var(--m-stage-display-w)
      ) / 2
    );
    --m-stage-viewport-y: calc(
      env(safe-area-inset-top, 0px) +
      (var(--m-safe-h) - var(--m-stage-display-h)) / 2
    );
    --m-trade-overlay-left: calc(
      var(--m-stage-viewport-x) + var(--m-stage-display-w) * var(--m-bc-left-ratio)
    );
    --m-trade-overlay-top: calc(
      var(--m-stage-viewport-y) + var(--m-stage-display-h) * var(--m-bc-top-ratio)
    );
    --m-trade-overlay-w: calc(var(--m-stage-display-w) * var(--m-bc-width-ratio));
    --m-trade-overlay-h: calc(var(--m-stage-display-h) * var(--m-bc-height-ratio));
    --m-trade-bounds-w: calc(var(--m-trade-overlay-w) - 2 * var(--m-bc-pad));
    --m-trade-bounds-h: calc(var(--m-trade-overlay-h) - 2 * var(--m-bc-pad));
  }

  body.game-active .board-center {
    anchor-name: --board-popup-zone;
  }

  body.game-active > #overlay.active,
  body.game-active > .overlay.active,
  body.game-active > .auction-overlay,
  body.game-active > #auctionOverlay.auction-overlay,
  body.game-active > .rent-decision-overlay,
  body.game-active > #rentDecisionOverlay.rent-decision-overlay,
  body.game-active > .lottery-overlay,
  body.game-active > #lotteryOverlay.lottery-overlay,
  body.game-active > .casino-overlay,
  body.game-active > .victory-overlay,
  body.game-active > .payment-surrender-confirm-overlay {
    grid-area: unset;
    position: fixed;
    z-index: 8000;
    inset: auto;
    right: auto;
    bottom: auto;
    left: calc(
      50% - var(--m-stage-display-w) / 2 +
      var(--m-stage-display-w) * var(--m-bc-left-ratio)
    );
    top: env(safe-area-inset-top, 0px);
    width: calc(var(--m-stage-display-w) * var(--m-bc-width-ratio));
    height: var(--m-safe-h);
    max-width: none;
    max-height: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    margin: 0;
    padding: 3px 4px;
    overflow: visible;
    background: rgba(0, 0, 0, 0.32);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    pointer-events: none;
    animation: none;
    transform: none;
  }

  /* Меню гравця: суворо в межах .board-center */
  body.game-active > #playerActionsOverlay {
    grid-area: unset;
    position: fixed;
    z-index: 8000;
    inset: auto;
    right: auto;
    bottom: auto;
    left: var(--m-bc-bounds-left);
    top: var(--m-bc-bounds-top);
    width: calc(var(--m-stage-display-w) * var(--m-bc-width-ratio));
    height: calc(var(--m-stage-display-h) * var(--m-bc-height-ratio));
    max-width: none;
    max-height: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    margin: 0;
    padding: var(--m-bc-pad);
    overflow: hidden;
    background: rgba(0, 0, 0, 0.32);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    pointer-events: none;
    animation: none;
    transform: none;
  }

  /*
   * Trade (#tradeOverlay на body, position:fixed → viewport).
   * Desktop inset:0 + padding:20px з index.html — скидаємо; bounds = .board-center на сцені.
   */
  body.game-active > .trade-overlay,
  body.game-active > #tradeOverlay.trade-overlay {
    grid-area: unset;
    position: fixed;
    z-index: 8000;
    inset: auto;
    top: var(--m-trade-overlay-top);
    left: var(--m-trade-overlay-left);
    right: auto;
    bottom: auto;
    width: var(--m-trade-overlay-w);
    height: var(--m-trade-overlay-h);
    max-width: none;
    max-height: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    margin: 0;
    padding: var(--m-bc-pad);
    overflow: hidden;
    background: rgba(0, 0, 0, 0.16);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    pointer-events: none;
    animation: none;
    transform: none;
  }

  body.game-active .board-wrapper > .casino-overlay,
  body.game-active .board-wrapper > .auction-overlay.buy-dialog-overlay {
    grid-area: unset;
    position: absolute;
    z-index: 100;
    top: calc(var(--board-edge-size, var(--m-bc-edge, 84px)) + var(--m-bc-grid-gap));
    left: calc(var(--board-edge-size, var(--m-bc-edge, 84px)) + var(--m-bc-grid-gap));
    right: calc(var(--board-edge-size, var(--m-bc-edge, 84px)) + var(--m-bc-grid-gap));
    bottom: calc(var(--board-edge-size, var(--m-bc-edge, 84px)) + var(--m-bc-grid-gap));
    width: auto;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    margin: 0;
    padding: 3px 4px;
    overflow: visible;
    background: rgba(0, 0, 0, 0.32);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    pointer-events: none;
    animation: none;
    transform: none;
  }

  /*
   * Колесо (#wheelOverlay на body, position:fixed) — bounds як у trade / .board-center
   */
  body.game-active > #wheelOverlay.wheel-overlay.wheel-overlay--viewport {
    grid-area: unset;
    position: fixed;
    z-index: 8000;
    inset: unset;
    top: var(--m-trade-overlay-top);
    left: var(--m-trade-overlay-left);
    right: auto;
    bottom: auto;
    width: var(--m-trade-overlay-w);
    height: var(--m-trade-overlay-h);
    max-width: none;
    max-height: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    margin: 0;
    padding: var(--m-bc-pad);
    overflow: hidden;
    background: rgba(0, 0, 0, 0.32);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    pointer-events: none;
    animation: none;
    transform: none;
  }

  body.game-active > #wheelOverlay.wheel-overlay .wheel-panel {
    pointer-events: auto;
    width: 100%;
    max-width: 100%;
    max-height: 100%;
    box-sizing: border-box;
    overflow: hidden;
    flex-shrink: 1;
    min-height: 0;
    min-width: 0;
    --m-zone-design-h: 280px;
    --m-zone-design-w: 260px;
    --m-zone-fit: min(
      1,
      calc(var(--m-trade-bounds-h) / var(--m-zone-design-h)),
      calc(var(--m-trade-bounds-w) / var(--m-zone-design-w))
    );
    zoom: var(--m-zone-fit);
    transform: scale(var(--m-zone-fit));
    transform-origin: center center;
  }

  @supports (zoom: 1) {
    body.game-active > #wheelOverlay.wheel-overlay .wheel-panel {
      transform: none;
    }
  }

  body.game-active .board-wrapper > .casino-overlay .casino-panel {
    max-height: 100%;
  }

  body.game-active > #overlay:not(.active) {
    display: none;
  }

  body.game-active > #playerActionsOverlay {
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.22);
  }

  body.game-active > .trade-overlay,
  body.game-active > #tradeOverlay.trade-overlay {
    background: rgba(0, 0, 0, 0.16);
    pointer-events: none;
  }

  body.game-active > .trade-overlay .trade-box,
  body.game-active > #tradeOverlay.trade-overlay .trade-box {
    pointer-events: auto;
    width: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    box-sizing: border-box;
    overflow: hidden;
    flex-shrink: 1;
    min-height: 0;
    min-width: 0;
    animation: none !important;
    --m-trade-zone-design-h: 300px;
    --m-trade-zone-design-w: 340px;
    --m-trade-zone-fit: min(
      1,
      calc(var(--m-trade-bounds-h) / var(--m-trade-zone-design-h)),
      calc(var(--m-trade-bounds-w) / var(--m-trade-zone-design-w))
    );
    zoom: var(--m-trade-zone-fit);
  }

  body.game-active > #playerActionsOverlay .player-menu-panel {
    pointer-events: auto;
    width: 100%;
    max-width: 100%;
    max-height: 100%;
    box-sizing: border-box;
    overflow: hidden;
    flex-shrink: 1;
    min-height: 0;
    min-width: 0;
    --m-zone-design-h: 230px;
    --m-zone-design-w: 280px;
    --m-zone-fit: min(
      1,
      calc(var(--m-bc-bounds-h) / var(--m-zone-design-h)),
      calc(var(--m-bc-bounds-w) / var(--m-zone-design-w))
    );
    zoom: var(--m-zone-fit);
    transform: scale(var(--m-zone-fit));
    transform-origin: center center;
  }

  @supports (zoom: 1) {
    body.game-active > #playerActionsOverlay .player-menu-panel {
      transform: none;
    }
  }

  body.game-active .rent-decision-box,
  body.game-active .payment-surrender-confirm-box {
    pointer-events: auto;
    width: 100%;
    max-width: 100%;
    max-height: var(--m-popup-max-h);
    box-sizing: border-box;
    overflow: hidden;
    flex-shrink: 1;
    min-height: 0;
    min-width: 0;
  }

  body.game-active .popup,
  body.game-active .auction-box,
  body.game-active .lottery-box,
  body.game-active .wheel-panel,
  body.game-active .casino-panel,
  body.game-active .victory-card {
    pointer-events: auto;
    width: 100%;
    max-width: 100%;
    max-height: var(--m-popup-max-h);
    box-sizing: border-box;
    overflow: hidden;
    flex-shrink: 1;
    min-height: 0;
    min-width: 0;
  }

  body.game-active .popup-body {
    max-height: none;
    overflow-y: visible;
  }

  body.game-active .popup.popup--company .popup-body {
    max-height: none;
    overflow: visible;
  }
  /* ── Казино / рулетка ── */
  body.game-active .casino-panel {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 5px 7px 4px;
    border-radius: 12px;
  }

  body.game-active .casino-panel-head {
    margin-bottom: 0;
    gap: 6px;
    flex-shrink: 0;
  }

  body.game-active .casino-panel-title {
    font-size: 13px;
    font-weight: 800;
  }

  body.game-active .slot-reels {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    margin-bottom: 3px;
    flex-shrink: 0;
  }

  body.game-active .slot-reel {
    min-height: 0;
    height: 44px;
    padding: 3px;
    border-radius: 8px;
  }

  body.game-active .slot-reel img {
    width: 32px;
    height: 32px;
  }

  body.game-active .casino-bet-block {
    padding: 4px 6px;
    margin-bottom: 0;
    flex-shrink: 0;
  }

  body.game-active .casino-bet-amount {
    font-size: 15px;
    line-height: 1.2;
  }

  body.game-active .casino-bet-adjust {
    margin-top: 3px;
    gap: 3px;
    flex-wrap: nowrap;
  }

  body.game-active .casino-bet-btn {
    min-width: 0;
    flex: 1;
    padding: 4px 2px;
    font-size: 9px;
    border-radius: 7px;
  }

  body.game-active .casino-spin-row {
    gap: 4px;
    flex-shrink: 0;
  }

  body.game-active .casino-spin-row .btn-buy {
    padding: 7px 8px;
    font-size: 13px;
    font-weight: 800;
    border-radius: 9px;
    min-height: 36px;
  }

  body.game-active .slot-result {
    min-height: 11px;
    margin-top: 2px;
    font-size: 10px;
    line-height: 1.25;
    flex-shrink: 0;
  }

  body.game-active .casino-footer-actions {
    margin-top: 1px;
    flex-shrink: 0;
  }

  body.game-active .casino-skip-link {
    font-size: 10px;
    padding: 2px 6px;
  }

  body.game-active .roulette-visual {
    margin-bottom: 3px;
    flex-shrink: 0;
  }

  body.game-active .rb-wheel-shell {
    width: 88px;
    height: 88px;
    margin: 0 auto;
  }

  body.game-active .roulette-pick-row {
    gap: 4px;
    margin-bottom: 3px;
    flex-shrink: 0;
  }

  body.game-active .roulette-pick {
    padding: 5px 4px;
    font-size: 10px;
    border-radius: 8px;
  }

  body.game-active .casino-overlay.casino-overlay--result .casino-panel {
    padding: 8px 10px;
  }

  body.game-active .casino-result-strip {
    gap: 6px;
    margin-bottom: 6px;
    padding: 6px;
  }

  body.game-active .casino-popup-reel-img {
    width: 36px;
    height: 36px;
  }

  body.game-active .casino-result-msg {
    font-size: 0.9rem;
    line-height: 1.3;
  }

  /* ── Договір (trade) ── */
  body.game-active .trade-box {
    display: flex;
    flex-direction: column;
    border-radius: 12px;
    overflow: hidden;
  }

  body.game-active .trade-head {
    padding: 5px 8px 4px;
    flex-shrink: 0;
  }

  body.game-active .trade-title {
    font-size: 13px;
    line-height: 1.2;
    margin-bottom: 1px;
  }

  body.game-active .trade-sub {
    font-size: 10px;
    line-height: 1.3;
  }

  body.game-active .trade-head > div > div[style*="font-size:11px"] {
    display: none !important;
  }

  body.game-active .trade-team-hint {
    font-size: 9px;
    padding: 4px 6px;
    margin-top: 4px;
    line-height: 1.25;
  }

  body.game-active .trade-comment-wrap,
  body.game-active .trade-hint,
  body.game-active .trade-comment-display {
    display: none !important;
  }

  body.game-active .trade-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    padding: 4px 6px;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
  }

  body.game-active .trade-col {
    padding: 5px;
    gap: 4px;
    min-width: 0;
    overflow: hidden;
  }

  body.game-active .trade-col-label {
    font-size: 8px;
    letter-spacing: 0.5px;
    margin: 0;
  }

  body.game-active .trade-cash-input {
    min-height: 30px;
    padding: 4px 6px;
    font-size: 12px;
  }

  body.game-active .trade-picks {
    min-height: 28px;
    max-height: 64px;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 3px 4px;
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    align-content: flex-start;
  }

  body.game-active .trade-chip {
    font-size: 8px;
    padding: 2px 4px;
    line-height: 1.2;
  }

  body.game-active .trade-empty {
    font-size: 9px;
  }

  body.game-active .trade-summary {
    margin: 0 6px 2px;
    padding: 3px 6px;
    font-size: 8px;
    line-height: 1.1;
    flex-shrink: 0;
    border-radius: 8px;
  }

  body.game-active .trade-summary-minimal {
    grid-template-columns: 1fr 1fr;
    gap: 2px 6px;
    align-items: center;
  }

  body.game-active .trade-summary-minimal .trade-summary-nums {
    font-size: 10px;
    font-weight: 800;
    line-height: 1.1;
  }

  body.game-active .trade-footer {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 5px;
    padding: 5px 6px 6px;
    flex-shrink: 0;
  }

  body.game-active .trade-footer .btn-auction,
  body.game-active .trade-footer .btn-propose {
    flex: 1;
    min-height: 36px;
    padding: 6px 8px;
    font-size: 11px;
    touch-action: manipulation;
  }

  /* ── Меню гравця ── */
  body.game-active .player-menu-panel {
    padding: 8px 10px 7px;
    border-radius: 14px;
  }

  body.game-active .player-menu-head {
    margin-bottom: 6px;
    padding-bottom: 6px;
    gap: 8px;
    flex-shrink: 0;
  }

  body.game-active .player-menu-avatar {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }

  body.game-active .player-menu-name {
    font-size: 13px;
    line-height: 1.25;
  }

  body.game-active .player-menu-actions {
    gap: 5px;
    flex-shrink: 0;
  }

  body.game-active .player-menu-btn {
    min-height: 36px;
    padding: 7px 10px;
    font-size: 12px;
    touch-action: manipulation;
  }

  body.game-active .player-menu-cheat {
    margin-top: 6px;
    padding-top: 6px;
    flex-shrink: 0;
  }

  body.game-active .player-menu-cheat-label {
    font-size: 9px;
    margin-bottom: 4px;
  }

  body.game-active .player-menu-cheat-row input {
    min-height: 32px;
    font-size: 14px;
    padding: 4px 8px;
  }

  body.game-active .player-menu-cheat-row button {
    min-height: 32px;
    padding: 4px 10px;
    font-size: 12px;
  }

  /* ── Покупка / аукціон / оренда / податок / кредит / шанс ── */
  body.game-active .auction-box,
  body.game-active .rent-decision-box,
  body.game-active .payment-surrender-confirm-box {
    padding: 8px 10px;
    border-radius: 14px;
  }

  body.game-active .rent-decision-box {
    padding-right: 34px;
  }

  body.game-active .auction-title {
    font-size: 14px;
    line-height: 1.25;
    margin-bottom: 4px;
  }

  body.game-active .auction-prop {
    font-size: 11px;
    line-height: 1.35;
    margin-bottom: 6px !important;
  }

  body.game-active .auction-hint {
    font-size: 9px;
    margin-top: 4px;
    line-height: 1.3;
  }

  body.game-active .auction-actions {
    display: flex;
    flex-direction: row;
    gap: 5px;
  }

  body.game-active .auction-actions .btn-buy,
  body.game-active .auction-actions .btn-auction {
    flex: 1;
    min-height: 36px;
    padding: 6px 8px;
    font-size: 11px;
    touch-action: manipulation;
  }

  body.game-active .buy-dialog-head {
    gap: 8px;
    margin-bottom: 6px;
  }

  body.game-active .buy-dialog-ico {
    width: 32px;
    height: 32px;
    font-size: 22px;
  }

  body.game-active .buy-dialog-name {
    font-size: 13px;
    line-height: 1.2;
  }

  body.game-active .buy-dialog-cat {
    font-size: 10px;
  }

  body.game-active .buy-dialog-meta {
    font-size: 11px;
    line-height: 1.35;
    margin-bottom: 6px;
  }

  body.game-active .buy-dialog-warn {
    font-size: 10px;
    margin-top: 4px;
    line-height: 1.3;
  }

  body.game-active .popup-owner-tag {
    font-size: 9px !important;
    line-height: 1.3 !important;
    margin-bottom: 6px !important;
  }

  body.game-active .popup-actions {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 0 !important;
  }

  body.game-active .popup-actions .btn-buy,
  body.game-active .popup-actions .btn-auction,
  body.game-active .popup-actions .btn-surrender-no,
  body.game-active .popup-actions .btn-surrender-yes {
    flex: 1 1 calc(50% - 3px);
    min-height: 36px;
    padding: 6px 8px;
    font-size: 11px;
    touch-action: manipulation;
  }

  body.game-active .payment-surrender-flag {
    top: 6px;
    right: 6px;
    width: 26px;
    height: 26px;
  }

  body.game-active .payment-surrender-flag svg {
    width: 14px;
    height: 14px;
  }

  /* ── Колесо фортуни ── */
  body.game-active .wheel-panel {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 5px 7px 4px;
    border-radius: 12px;
  }

  body.game-active .wheel-panel-head {
    margin-bottom: 0;
    flex-shrink: 0;
  }

  body.game-active .wheel-panel-title {
    font-size: 13px;
  }

  body.game-active .wheel-stage {
    width: 96px;
    height: 96px;
    margin: 0 auto 2px;
    flex-shrink: 0;
  }

  body.game-active .wheel-pointer {
    border-left-width: 10px;
    border-right-width: 10px;
    border-top-width: 14px;
  }

  body.game-active .wheel-sector span {
    font-size: 9px;
  }

  body.game-active .wheel-hub {
    width: 34px;
    height: 34px;
    margin: -17px 0 0 -17px;
    font-size: 8px;
    padding: 2px;
  }

  body.game-active .wheel-result-mult {
    font-size: 28px;
    margin: 4px 0;
  }

  /* ── Лотерея / chill zone ── */
  body.game-active .lottery-box {
    padding: 8px 10px;
    border-radius: 14px;
  }

  body.game-active .lottery-box .auction-prop {
    color: #cde8d2;
  }

  body.game-active #lotterySpinVisual {
    font-size: 1.5rem !important;
    min-height: 1.6rem !important;
    margin: 4px 0 !important;
  }

  body.game-active .lottery-result-popup .lottery-result-title {
    font-size: 1rem;
    margin-bottom: 6px;
  }

  body.game-active .lottery-result-popup .lottery-result-amount {
    font-size: 1.2rem;
  }

  /* ── Картки подій / компанії (#overlay) ── */
  body.game-active .popup {
    border-radius: 14px;
    display: flex;
    flex-direction: column;
  }

  body.game-active .popup-head {
    padding: 8px 10px 6px;
    flex-shrink: 0;
  }

  body.game-active .popup-emoji {
    font-size: 24px;
    margin-bottom: 3px;
  }

  body.game-active .popup-emoji img {
    width: 44px;
    height: 44px;
  }

  body.game-active .popup-title {
    font-size: 14px;
    margin-bottom: 4px;
    line-height: 1.2;
  }

  body.game-active .popup-badge {
    font-size: 9px;
    padding: 3px 8px;
  }

  body.game-active .popup-body {
    padding: 6px 8px 8px;
    font-size: 11px;
    line-height: 1.35;
  }

  body.game-active .popup.popup--company .popup-head {
    padding: 8px 10px 5px;
  }

  body.game-active .popup.popup--company .popup-emoji {
    font-size: 22px;
    margin-bottom: 3px;
  }

  body.game-active .popup.popup--company .popup-emoji img {
    width: 40px;
    height: 40px;
  }

  body.game-active .popup.popup--company .popup-body {
    padding: 5px 8px 6px;
  }

  body.game-active .popup.popup--company .rent-row {
    padding: 3px 5px;
  }

  body.game-active .popup.popup--company .info-grid {
    gap: 4px;
    margin-bottom: 5px;
  }

  body.game-active .popup-close {
    top: 5px;
    right: 5px;
    width: 28px;
    height: 28px;
    font-size: 14px;
  }

  /* ── Перемога ── */
  body.game-active .victory-card {
    padding: 10px 12px 9px;
    border-radius: 14px;
  }

  body.game-active .victory-trophy {
    font-size: 28px;
    margin-bottom: 4px;
  }

  body.game-active .victory-headline {
    font-size: 1rem;
    margin-bottom: 4px;
  }

  body.game-active .victory-subline {
    font-size: 11px;
    margin-bottom: 6px;
    line-height: 1.3;
  }

  body.game-active .victory-names {
    gap: 4px;
    margin-bottom: 6px;
  }

  body.game-active .victory-name {
    padding: 3px 8px;
    font-size: 10px;
  }

  body.game-active .victory-hint {
    font-size: 10px;
    line-height: 1.3;
    margin-bottom: 6px;
  }

  body.game-active .victory-hub-btn {
    min-height: 36px;
    padding: 8px 12px;
    font-size: 12px;
    touch-action: manipulation;
  }
  body.game-active .trade-cash-row {
    gap: 3px;
  }

  body.game-active .trade-cash-icon {
    font-size: 11px;
  }

  body.game-active .trade-team-wait {
    font-size: 9px;
    padding: 2px 0;
    line-height: 1.25;
  }

  body.game-active .rent-decision-box--dice-rent .auction-title {
    font-size: 13px;
  }

  body.game-active .rent-decision-box--dice-rent .auction-prop {
    font-size: 10px;
    margin-bottom: 6px !important;
  }

  body.game-active .wheel-stage .wheel-disc-wrap {
    inset: 6px;
  }

  body.game-active .board-wrapper > .auction-overlay.buy-dialog-overlay .buy-dialog-panel {
    pointer-events: auto;
  }

  @media (orientation: portrait) {
    body.game-active > #gameDesktopRoot {
      visibility: hidden;
      opacity: 0;
      pointer-events: none;
    }

    html:has(body.game-active)::after {
      content: "Поверніть пристрій горизонтально";
      position: fixed;
      inset: 0;
      z-index: 25000;
      display: flex;
      align-items: center;
      justify-content: center;
      padding:
        max(20px, env(safe-area-inset-top, 0px))
        max(20px, env(safe-area-inset-right, 0px))
        max(20px, env(safe-area-inset-bottom, 0px))
        max(20px, env(safe-area-inset-left, 0px));
      box-sizing: border-box;
      background: rgba(5, 10, 24, 0.88);
      color: #e0f2fe;
      font-size: clamp(16px, 4.5vw, 20px);
      font-weight: 700;
      line-height: 1.45;
      text-align: center;
      pointer-events: none;
    }
  }

  @media (orientation: landscape) {
    html:has(body.game-active)::after {
      content: none;
      display: none;
    }
  }
}
