/* Keep the landscape lobby inside short and narrow viewports. */
@media (orientation: landscape) {
  .layout .profile { grid-template-columns: auto minmax(0, 1fr); min-width: 0; }
  .layout .profile strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .layout .currencies { min-width: 0; }
  .layout .currencies > span { overflow: hidden; }
  .layout .mode-list { min-width: 0; }
  .layout .carousel .mode { min-width: 0; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .layout .profile {
    top: max(5px, env(safe-area-inset-top)); left: max(10px, env(safe-area-inset-left));
    width: 25%; height: 13vh; padding: 1px 5px; gap: 0 5px;
    grid-template-columns: auto minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) minmax(0, 1fr) 4px;
  }
  .layout .profile .avatar { width: min(11vh, 40px); min-width: 0; grid-row: 1 / 4; }
  .layout .profile strong, .layout .profile .level { font-size: clamp(8px, 2.7vh, 11px); line-height: 1.1; }
  .layout .profile .xp { height: 4px; min-height: 4px; }
  .layout .profile small { font-size: clamp(7px, 2vh, 9px); }
  .layout .top { top: max(4px, env(safe-area-inset-top)); height: 13vh; }
  .layout .currencies > span, .layout .lobby-wallet-button { height: clamp(28px, 12vh, 38px); min-height: 0; }
  .layout .currencies .ico-coin, .layout .currencies .ico-gem { width: min(9vh, 27px); height: min(9vh, 27px); }
  .layout .lobby-wallet-button img { width: min(15vh, 45px); height: min(15vh, 45px); }
  .layout .currencies .plain { min-width: 0; min-height: 0; width: min(11vh, 38px); height: min(11vh, 38px); padding: 2px; }
  .layout .sidebar nav { top: 16%; height: 9%; }
  .layout .feature-wrap { top: 30%; height: 42%; }
  .layout .feature-content .hero-label strong { font-size: clamp(15px, 7vh, 32px); }
  .layout .feature-content .hero-label small { font-size: clamp(8px, 3.4vh, 14px); }
  .layout .feature-content .hero-label > div::before { font-size: clamp(7px, 2.6vh, 9px); padding: 2px 8px; }
  .layout .play-clip .play span { font-size: clamp(13px, 6vh, 26px) !important; }
  .layout .carousel { top: 76%; height: 20%; }
  .layout .carousel .mode { height: 100%; max-height: 100%; }
  .layout .carousel .mode span { font-size: clamp(9px, 3.8vh, 17px) !important; }
  .layout .dock { top: 25%; height: min(62vh, 250px) !important; min-height: 0 !important; }
}

@media (orientation:landscape) and (max-height:500px){.layout .dock{transform:none!important}.layout .mode-list{height:100%;align-items:stretch}.layout .carousel .mode{height:100%!important}}

/* Align the XP count with the end of the shorter progress bar. */
@media (orientation:landscape){.layout .profile .xp{width:84%}.layout .profile small{padding-right:16%}}

/* Keep the mode strip clear of the side rail on compact screens. */
@media (orientation:landscape) and (max-width:1100px), (orientation:landscape) and (max-height:600px){.layout .carousel{left:calc(max(1.1vw, env(safe-area-inset-left)) + clamp(48px, 6.4vmin, 80px) + 8px);right:max(8px,env(safe-area-inset-right));width:auto}.layout .mode-list{width:100%;gap:clamp(3px,.6vw,7px)}.layout .carousel .mode{flex:1 1 0;min-width:0}}

/* Compact mobile profile with breathing room above it. */
@media (orientation:landscape) and (max-width:1100px), (orientation:landscape) and (max-height:600px){.layout .profile{width:21%;top:calc(max(5px,env(safe-area-inset-top)) + 6px)}}

/* A slimmer profile on mobile landscape. */
@media (orientation:landscape) and (max-width:1100px), (orientation:landscape) and (max-height:600px){.layout .profile{height:clamp(32px,10.5vh,48px);padding:1px 4px;row-gap:0;grid-template-rows:minmax(0,1fr) minmax(0,1fr) 4px}.layout .profile .avatar{width:clamp(28px,8.5vh,40px);min-width:0;grid-row:1 / 4}.layout .profile .xp{height:4px;min-height:4px}}

@media (orientation:landscape){html.nox-telegram-mobile .layout.layout .sidebar nav{top:calc(var(--nox-tg-top) + clamp(43px, var(--nox-tg-usable)*.18, 55px))!important;height:clamp(20px, calc(var(--nox-tg-usable)*.10), 34px)!important}html.nox-telegram-mobile .layout.layout .feature-wrap{top:calc(var(--nox-tg-top) + clamp(67px, var(--nox-tg-usable)*.32, 96px))!important;height:calc(var(--nox-tg-usable)*.36)!important}html.nox-telegram-mobile .layout.layout .carousel{top:calc(var(--nox-tg-top) + var(--nox-tg-usable)*.76)!important}}

@media (orientation:landscape){html.nox-telegram-mobile .layout.layout .profile{top:calc(var(--nox-tg-top) + 1px)!important}html.nox-telegram-mobile .layout.layout .top{top:calc(var(--nox-tg-top) - 3px)!important}}

/* Nudge the featured banner on compact landscape screens. */
@media (orientation:landscape) and (max-width:1100px), (orientation:landscape) and (max-height:600px){.layout .feature-wrap{left:max(16%,calc(env(safe-area-inset-left) + 76px));top:32%}html.nox-telegram-mobile .layout.layout .feature-wrap{top:calc(var(--nox-tg-top) + clamp(72px, var(--nox-tg-usable)*.34, 101px))!important}}

@media (orientation:landscape) and (max-width:1100px), (orientation:landscape) and (max-height:600px){.layout .feature-wrap{top:33%}html.nox-telegram-mobile .layout.layout .feature-wrap{top:calc(var(--nox-tg-top) + clamp(76px, var(--nox-tg-usable)*.35, 105px))!important}html.nox-telegram-mobile .layout.layout .top{top:calc(var(--nox-tg-top) - 6px)!important}}

@media (orientation:landscape) and (max-width:1100px), (orientation:landscape) and (max-height:600px){html.nox-telegram-mobile .layout.layout .top{top:calc(var(--nox-tg-top) - 11px)!important}}

@media (orientation:landscape) and (max-width:1100px), (orientation:landscape) and (max-height:600px){html.nox-telegram-mobile .layout.layout .top{top:calc(var(--nox-tg-top) + 1px)!important;align-items:flex-start}html.nox-telegram-mobile .layout.layout .currencies{align-items:start}}

@media (orientation:landscape) and (max-width:1100px), (orientation:landscape) and (max-height:600px){html.nox-telegram-mobile .layout.layout .profile,html.nox-telegram-mobile .layout.layout .top{top:calc(var(--nox-tg-top) - 2px)!important}}

@media (orientation:landscape) and (max-width:1100px), (orientation:landscape) and (max-height:600px){.layout .feature-wrap{top:34%}html.nox-telegram-mobile .layout.layout .feature-wrap{top:calc(var(--nox-tg-top) + clamp(79px, var(--nox-tg-usable)*.36, 108px))!important}}

@media (orientation:landscape) and (max-width:1100px), (orientation:landscape) and (max-height:600px){.layout .carousel{height:16%}html.nox-telegram-mobile .layout.layout .carousel{height:calc(var(--nox-tg-usable)*.16)!important}}

@media (orientation:landscape) and (max-width:1100px), (orientation:landscape) and (max-height:600px){.layout .carousel{top:80%}.layout .mode-list{gap:3px}html.nox-telegram-mobile .layout.layout .carousel{top:calc(var(--nox-tg-top) + var(--nox-tg-usable)*.80)!important}}

@media (orientation:landscape) and (max-width:1100px), (orientation:landscape) and (max-height:600px){.layout .mode-list{gap:0}.layout .carousel .mode + .mode{margin-left:-5px}}

@media (orientation:landscape) and (max-width:1100px), (orientation:landscape) and (max-height:600px){.layout .sidebar nav{left:38%;width:60%;gap:.4%}}

@media (orientation:landscape) and (max-width:1100px), (orientation:landscape) and (max-height:600px){.layout .sidebar nav{gap:0}.layout .sidebar nav button + button{margin-left:-3px}}

@media (orientation:landscape) and (max-width:1100px), (orientation:landscape) and (max-height:600px){.layout .dock{top:23%}html.nox-telegram-mobile .layout.layout .dock{top:calc(var(--nox-tg-top) + var(--nox-tg-usable)*.22)!important}}

@media (orientation:landscape) and (max-width:1100px), (orientation:landscape) and (max-height:600px){.layout .dock{top:21%}html.nox-telegram-mobile .layout.layout .dock{top:calc(var(--nox-tg-top) + var(--nox-tg-usable)*.20)!important}}

/* Bring open panels closer to Telegram's native controls. */
@media (orientation:landscape){html.nox-telegram-mobile .layout-live-frame.inventory-overlay{top:max(0px,calc(var(--nox-tg-top) - 5px))!important;height:calc(100% - max(0px,calc(var(--nox-tg-top) - 5px)) - var(--nox-tg-bottom))!important}}

/* Expand the mobile banner into the space between the shortcut row and mode cards. */
@media (orientation:landscape) and (max-width:1100px), (orientation:landscape) and (max-height:600px){.layout .feature-wrap{top:28%;height:50%}html.nox-telegram-mobile .layout.layout .feature-wrap{top:calc(var(--nox-tg-top) + clamp(43px, var(--nox-tg-usable)*.18, 55px) + clamp(20px, var(--nox-tg-usable)*.10, 34px) + 6px)!important;height:calc(var(--nox-tg-usable)*.80 - clamp(43px, var(--nox-tg-usable)*.18, 55px) - clamp(20px, var(--nox-tg-usable)*.10, 34px) - 12px)!important}}

@media (orientation:landscape) and (max-width:1100px), (orientation:landscape) and (max-height:600px){.layout.layout .play-clip .play{height:clamp(32px,9vh,54px)!important;max-height:38%;width:clamp(120px,27%,240px)!important}.layout .play-clip .play span{font-size:clamp(15px,5vh,26px)!important}}

/* Keep mobile balances compact and bring the shortcut row closer. */
@media (orientation:landscape) and (max-width:1100px), (orientation:landscape) and (max-height:600px){.layout .currencies>span,.layout .lobby-wallet-button{height:clamp(27px,9vh,34px);min-height:0;padding-top:2px!important;padding-bottom:2px!important}.layout .currencies .ico-coin,.layout .currencies .ico-gem{width:clamp(20px,7vh,26px);height:clamp(20px,7vh,26px)}.layout .lobby-wallet-button img{width:clamp(32px,12vh,42px);height:clamp(32px,12vh,42px)}.layout .currencies .plain{width:clamp(28px,9vh,34px);height:clamp(27px,9vh,34px);min-height:0;min-width:0;padding:3px}.layout .sidebar nav{top:15%}html.nox-telegram-mobile .layout.layout .sidebar nav{top:calc(var(--nox-tg-top) + clamp(39px, var(--nox-tg-usable)*.16, 51px))!important}}

@media (orientation:landscape) and (max-width:1100px), (orientation:landscape) and (max-height:600px){.layout .sidebar nav{top:14%}html.nox-telegram-mobile .layout.layout .sidebar nav{top:calc(var(--nox-tg-top) + clamp(35px, var(--nox-tg-usable)*.14, 47px))!important}}

@media (orientation:landscape) and (max-width:1100px), (orientation:landscape) and (max-height:600px){.layout .sidebar nav{top:13.5%}html.nox-telegram-mobile .layout.layout .sidebar nav{top:calc(var(--nox-tg-top) + clamp(33px, var(--nox-tg-usable)*.135, 45px))!important}}

/* Balance the banner between the shortcuts and the lower mode cards. */
@media (orientation:landscape) and (max-width:1100px), (orientation:landscape) and (max-height:600px){.layout .carousel{top:82%}.layout .feature-wrap{top:26%;height:54%}html.nox-telegram-mobile .layout.layout .carousel{top:calc(var(--nox-tg-top) + var(--nox-tg-usable)*.82)!important}html.nox-telegram-mobile .layout.layout .feature-wrap{top:calc(var(--nox-tg-top) + clamp(33px, var(--nox-tg-usable)*.135, 45px) + clamp(20px, var(--nox-tg-usable)*.10, 34px) + 6px)!important;height:calc(var(--nox-tg-usable)*.82 - clamp(33px, var(--nox-tg-usable)*.135, 45px) - clamp(20px, var(--nox-tg-usable)*.10, 34px) - 12px)!important}}

@media (orientation:landscape){html.nox-telegram-mobile .layout-live-frame.inventory-overlay{left:0!important;right:0!important;width:100%!important;max-width:100%!important}}

/* Put mode artwork on the card surface so it remains visible when the
   Telegram WebView returns from gameplay and recomposites the lobby. */
html.nox-telegram-mobile .layout.layout .carousel .mode > span {
  background:linear-gradient(90deg,#09090eb8 0%,#0d0c1266 42%,#0e0c1408 100%),var(--tab-art) center/cover no-repeat !important;
}
html.nox-telegram-mobile .layout.layout .carousel .mode > span::before { display:none !important; }
html.nox-telegram-mobile .layout.layout .carousel .mode.mode-unavailable > span { filter:grayscale(1) brightness(.7); }

/* Telegram reports its native insets in pixels; keep the mobile positioning
   independent of CSS calc multiplication support in the host WebView. */
@media (orientation:landscape) {
  html.nox-telegram-mobile .layout.layout .profile,
  html.nox-telegram-mobile .layout.layout .top { top:var(--nox-mobile-top) !important; }
  html.nox-telegram-mobile .layout.layout .sidebar nav { top:var(--nox-mobile-nav-top) !important; height:var(--nox-mobile-nav-height) !important; }
  html.nox-telegram-mobile .layout.layout .feature-wrap { top:var(--nox-mobile-banner-top) !important; height:var(--nox-mobile-banner-height) !important; }
  html.nox-telegram-mobile .layout.layout .dock {
    left:max(6px,calc(env(safe-area-inset-left) - 26px)) !important;
    top:var(--nox-mobile-rail-top) !important; height:var(--nox-mobile-rail-height) !important; transform:none !important;
  }
  html.nox-telegram-mobile .layout.layout .carousel {
    left:max(68px,calc(env(safe-area-inset-left) + 32px)) !important;
    right:max(8px,env(safe-area-inset-right)) !important; width:auto !important;
    top:var(--nox-mobile-cards-top) !important; height:var(--nox-mobile-cards-height) !important; bottom:auto !important;
  }
  html.nox-telegram-mobile .layout.layout .mode-list { width:100%; height:100% !important; gap:0; align-items:stretch; }
  html.nox-telegram-mobile .layout.layout .carousel .mode { flex:1 1 0; min-width:0; height:100% !important; }
  html.nox-telegram-mobile .layout.layout .carousel .mode + .mode { margin-left:-5px; }
}

html.nox-telegram-mobile .layout.layout .carousel .mode > span{background:#111115!important}
