/* Mobile layout comes last so legacy desktop and inline layouts remain intact. */
.mobile-nav,.mobile-picker-links{display:none}
@media(max-width:820px),(max-width:1100px) and (max-height:600px) and (hover:none) and (pointer:coarse){
 html{scroll-padding-top:132px;scroll-padding-bottom:90px}
 body{padding-bottom:calc(76px + env(safe-area-inset-bottom,0px))}
 body :is(button,a,input,select,textarea){touch-action:manipulation}
 body :is(input:not([type=checkbox]):not([type=radio]):not([type=range]),select,textarea){font-size:16px!important;min-width:0}
 button:focus-visible,a:focus-visible{outline:2px solid #ffdb00;outline-offset:3px}
 .top{padding:10px 12px;padding-top:max(10px,env(safe-area-inset-top));gap:8px;flex-wrap:wrap}
 .top .top-left{display:flex;flex-direction:row;align-items:center;justify-content:space-between;width:100%;gap:8px}
 .top .brand{min-height:44px;padding:0;gap:8px}
 .top .logo-text{font-size:21px}
 .top .brand-pickaxe-top{width:32px;height:32px}
 .top .mobile-stats{display:flex;flex-direction:column;align-items:flex-end;gap:4px}
 .top .mobile-online,.top .mobile-upgrades{display:flex;align-items:center;gap:5px;min-height:18px;font-size:10px;line-height:1.2;color:#969ba8;white-space:nowrap}
 .top .mobile-stats b{font-size:11px;color:#e5e9ef}
 .top .mobile-upgrades b{color:#ffdb00}
 .top .mobile-upgrades img{width:13px;height:13px;object-fit:contain}
 .top .mobile-online i{width:6px;height:6px;border-radius:50%;background:#35c66a}
 .top .top-right{width:100%;margin:0;justify-content:flex-end}
 .top #userBar{width:100%;gap:6px;justify-content:flex-end}
 .top :is(.avatar-top,.user-bar>.top-icon-btn,.notification-btn,.telegram-btn){width:44px;height:44px;min-width:44px;flex-basis:44px}
 .top .notification-wrap{height:44px}
 .top .header-wallet{height:44px;margin-right:auto;order:-1;min-width:0}
 .top .header-wallet .bal-pill{height:42px;padding-inline:10px;font-size:14px}
 .top .header-wallet .topup-btn{width:44px;min-width:44px;height:44px;min-height:44px;font-size:0;padding:0!important}
 .top .header-wallet .topup-btn>img{width:22px;height:22px}
 .top #authBtns{width:100%;justify-content:flex-end}
 .top .big-login{min-height:44px;margin-right:auto}
 .top .notification-panel{position:fixed;top:126px;right:12px;left:12px;width:auto;max-height:calc(100dvh - 220px)}
 .notification-head>button{min-width:44px;min-height:44px}
 .notification-actions{flex-wrap:wrap;gap:8px;padding:8px 12px}
 .notification-actions>button{min-height:44px}
 .layout,.layout:not(.feedless){display:block;min-width:0}
 .layout .live{display:none!important}
 main{padding:12px 12px 24px;min-width:0}
 .stage-head{margin:6px 0 10px}.stage-title{font-size:18px}
 #view-upgrade .up-stage{padding:12px 0 16px;overflow:visible}
 #view-upgrade .upgrade-tools{position:static;align-self:center;justify-content:center;height:44px;margin-bottom:12px;gap:8px}
 #view-upgrade .tool-btn,#view-upgrade .tool-btn:is(:hover,:active,:focus-visible,.active){width:44px;height:44px;border-radius:10px;background:#ffffff04}
 #view-upgrade .up-circles{grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:12px!important;align-items:start!important}
 #view-upgrade .up-circles .center{grid-row:1;grid-column:1/-1!important;height:220px}
 #view-upgrade .reference-wheel{width:220px;height:220px}
 #view-upgrade .drop-side{position:relative;gap:8px;height:auto;min-height:218px;padding:8px}
 #view-upgrade .drop-side:first-child{grid-column:1!important;grid-row:2}
 #view-upgrade .drop-side:last-child{grid-column:2!important;grid-row:2}
 #view-upgrade .drop-heading{position:static;min-height:58px;margin:0;text-align:center;gap:4px}
 #view-upgrade .drop-heading b{font-size:12px;line-height:1.4}
 #view-upgrade .drop-heading span{font-size:11px;line-height:1.4}
 #view-upgrade .drop-circle{position:relative!important;inset:auto;height:128px!important;border-radius:12px!important}
 #view-upgrade .drop-item{margin-top:0;height:80%;width:80%}
 #view-upgrade .drop-side.has-selection .drop-clear{min-width:44px;min-height:44px;right:0;top:0}
 #view-upgrade .drop-side.has-selection .drop-meta{position:static;gap:8px;inset:auto;width:100%;pointer-events:none}
 #view-upgrade .drop-side.has-selection .drop-name{padding:0;font-size:12px;-webkit-line-clamp:2}
 #view-upgrade .drop-side.has-selection .drop-price{font-size:14px}
 #view-upgrade .drop-side.has-selection .drop-item{margin:0;height:80%;width:80%}
 #view-upgrade .drop-price{max-width:100%;font-size:12px;padding:5px 8px}
 #view-upgrade .drop-name{max-width:100%;font-size:11px}
 #view-upgrade .up-action-row{grid-template-columns:1fr!important;gap:12px!important;margin-top:12px}
 #view-upgrade .up-action-row>*{grid-column:1!important;min-width:0}
 #view-upgrade .up-action-row>#balBlock{grid-row:1;order:0;width:100%;height:auto;min-height:80px;padding:10px 12px}
 #view-upgrade .up-action-row>.action-options{grid-row:2;order:1;height:auto;min-height:0;width:100%}
 #view-upgrade .up-mults{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:5px;width:100%}
 #view-upgrade .up-mults button{width:auto;min-width:0;height:44px;padding:0;font-size:12px}
 #view-upgrade .up-action-row>.up-btn{grid-row:3;order:2;min-height:52px;margin:0;font-size:16px}
 #view-upgrade input[type=range]{min-height:44px;width:100%}
 .mobile-picker-links{display:grid;grid-template-columns:1fr 1fr;gap:10px;width:100%;margin:8px 0 18px}
 .mobile-picker-links button{min-height:48px;border:1px solid #4b4840;border-radius:10px;background:#26262b;color:#ffe66d;font-weight:700}
 #view-upgrade .bottom{grid-template-columns:1fr;gap:16px}
 #view-upgrade :is(.inventory-head,.shop-head){flex-wrap:wrap;height:auto;padding:12px;gap:8px;min-height:60px}
 #view-upgrade .panel{max-height:none;overflow:hidden}
 #view-upgrade :is(.inventory-sort,#inventorySort,#targetSort){width:44px;height:44px;min-width:44px}
 #view-upgrade #inventoryShopBtn{min-height:44px;font-size:12px!important;padding:8px}
 #view-upgrade .inventory-total{margin-left:auto}
 #view-upgrade .shop-filters{flex:1 0 100%;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
 #view-upgrade .shop-filters .price{height:46px;padding:0 8px;font-size:12px}
 #view-upgrade .price-in{height:44px}
 #view-upgrade .search-box,#view-upgrade .search-box:focus-within{grid-column:1/-1;display:flex;position:relative;inset:auto;width:100%;height:46px;flex-basis:auto;box-shadow:none}
 #view-upgrade .search-box .search-in,#view-upgrade .search-box:focus-within .search-in{flex:1;width:100%;padding:0 12px}
 #view-upgrade .search-box .search-close{display:none}
 #view-upgrade .search-box .search{width:44px;min-width:44px;height:44px}
 #view-upgrade :is(#myGrid,#shopGrid){grid-template-columns:repeat(2,minmax(0,1fr));height:auto;max-height:none;grid-auto-rows:140px;gap:10px;padding:10px}
 #view-upgrade .skin{height:140px;padding:8px}
 #view-upgrade .skin .im-wrap{height:82px}
 #view-upgrade .skin .im-wrap img{max-height:80px}
 #view-upgrade .empty-slot{display:none}
 .upgrade-pager button{min-width:44px;min-height:44px}
 .mobile-nav{position:fixed;z-index:35;bottom:0;left:0;right:0;display:grid;grid-template-columns:repeat(5,minmax(0,1fr));padding:6px max(6px,env(safe-area-inset-left)) calc(6px + env(safe-area-inset-bottom));background:#191b20f5;border-top:1px solid #3c3c40;backdrop-filter:blur(16px);box-shadow:0 -8px 28px #0003}
 .mobile-nav button{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:5px;min-height:56px;min-width:0;padding:6px 2px;border:0;border-radius:10px;background:transparent;color:#b5b7c2;font-family:inherit;font-weight:600;font-size:10px;line-height:1.2;cursor:pointer}
 .mobile-nav button img{width:23px;height:23px;object-fit:contain}
 .mobile-nav button[aria-current=page],.mobile-nav button:active{color:#ffdf36;background:#ffdb0012}
 .mobile-nav .mobile-more-icon{font-size:25px;line-height:23px;letter-spacing:2px}
 body.store-open .mobile-nav,body.mobile-overlay-open .mobile-nav{visibility:hidden;pointer-events:none}
 dialog{box-sizing:border-box;max-width:calc(100vw - 20px)!important;max-height:calc(100dvh - 20px - env(safe-area-inset-top) - env(safe-area-inset-bottom))!important;overflow-y:auto;overscroll-behavior:contain}
 body:has(dialog[open]){overflow:hidden}
 .modal{padding:10px;overscroll-behavior:contain}
 .modal .mbox{width:100%;max-width:100%;min-width:0;max-height:calc(100dvh - 20px);overflow-y:auto;overscroll-behavior:contain}
 :is(.xbtn,.wallet-close,.store-cart-toggle,#storeBack){min-width:44px;min-height:44px}
 #storeModal{padding:0}
 #storeModal .store-window{width:100%;height:100dvh;max-height:100dvh;border-radius:0;border:0}
 #storeModal .store-window-header{padding:10px 12px;padding-top:max(10px,env(safe-area-inset-top));gap:8px}
 #storeModal .store-window-heading h2{font-size:20px}
 #storeModal .store-window-body{padding:12px;min-width:0}
 #storeModal .store-catalog-pages{grid-template-columns:1fr;position:relative;padding-bottom:52px}
 #storeModal .store-edge-arrow{position:absolute;bottom:0;width:44px;height:44px}
 #storeModal .store-edge-arrow:last-child{right:0}
 #storeModal .store-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;grid-auto-rows:160px;grid-template-rows:none}
 #storeModal .store-selection{min-height:96px;max-height:190px}
 #storeModal .store-selected-card{width:148px;flex-basis:148px;min-height:200px}
 #storeModal .store-selected-quantity button{width:44px;height:44px}
 #storeModal .store-selected-card .store-card-top{height:44px}
 #storeModal .store-selected-card .store-card-top button{width:44px;height:44px}
 #storeModal .store-compact-sort,#storeModal .store-search-toggle{width:44px;height:44px;flex-basis:44px}
 #storeModal .store-field>div{height:44px}
 #storeModal .store-field input{height:42px}
 #storeModal .store-price-caption{display:none}
 #storeModal .store-price-jumps button{min-height:44px}
 #storeModal .store-catalog-heading>button{min-height:44px}
 #storeModal .store-window-footer{padding:12px;padding-bottom:max(12px,env(safe-area-inset-bottom));gap:10px;flex-wrap:wrap}
 #storeModal .store-order-button{min-height:48px;flex:1}
 .cart-dialog{width:100%;max-height:calc(100dvh - 20px);overflow:auto}
 .wallet-dialog{padding:20px 16px}.wallet-presets{display:flex;flex-wrap:wrap;gap:8px}.wallet-presets button{min-height:44px;flex:1 0 28%}
 .payment-entry{flex-wrap:wrap}.wallet-amount{width:100%;min-width:0}.wallet-promo-toggle{min-height:44px}
 #settingsModal .quick-groups,#settingsModal .settings-control-grid{grid-template-columns:1fr}
 .settings-tabs button,.settings-save,.profile-tabs button,.profile-sell{min-height:48px}
 #view-profile .profile-overview{grid-template-columns:1fr;gap:16px;padding:16px}
 #view-profile .profile-library-head{flex-wrap:wrap;gap:12px;padding:16px}
 #view-profile .profile-grid{grid-template-columns:repeat(2,minmax(0,1fr));padding:12px;gap:10px}
 .profile-tabs{overflow-x:auto}.profile-history{overflow-x:auto}
 .item-actions button{min-height:44px}
 .help,button[aria-label="Чат поддержки"],.support-staff-launch{bottom:calc(86px + env(safe-area-inset-bottom))!important}
 .help,button[aria-label="Чат поддержки"]{display:none!important}
 .support-panel{bottom:calc(86px + env(safe-area-inset-bottom))!important;max-height:calc(100dvh - 110px);left:10px;right:10px;width:auto}
 body.mobile-overlay-open :is(.help,button[aria-label="Чат поддержки"],.support-staff-launch){visibility:hidden}
 .mobile-menu{width:calc(100% - 20px);padding:18px;border:1px solid #494a50;border-radius:18px;background:#1c1e24;color:#fff}
 .mobile-menu header{display:flex;justify-content:space-between;align-items:center;margin-bottom:12px}.mobile-menu h2{font-size:20px;margin:0}
 .mobile-menu .mobile-menu-grid{display:grid;grid-template-columns:1fr 1fr;gap:10px}
 .mobile-menu-grid button{min-height:64px;padding:12px;border:1px solid #42444b;border-radius:12px;background:#292c33;color:#f1f1f5;font:inherit;text-align:left}
 .mobile-menu-grid button:active{border-color:#ffdb00;background:#343226}
 @media(max-width:360px){.top #userBar>.telegram-btn{display:none}.top #userBar{gap:4px}.top .header-wallet .bal-pill{padding-inline:7px;font-size:12px}#view-upgrade .drop-circle{height:125px!important}#view-upgrade .up-mults{gap:3px}#view-upgrade .up-mults button{font-size:11px}}
}
@media(prefers-reduced-motion:reduce){html{scroll-behavior:auto}}

/* Mobile corrections: let card rows determine their panel height. */
.mobile-upgrade-return,.mobile-withdraw-reason{display:none}
@media(max-width:820px),(max-width:1100px) and (max-height:600px) and (hover:none) and (pointer:coarse){
 #view-upgrade .bottom>.panel{height:auto!important;min-height:0;align-self:start}
 #view-upgrade :is(#myGrid,#shopGrid){height:auto;min-height:0;flex:0 0 auto;grid-template-rows:none;grid-auto-rows:140px;padding:10px!important}
 #view-upgrade .upgrade-pager{position:static;flex-shrink:0;margin-top:4px}
 #view-upgrade .stage-head{display:none}
 #view-upgrade .up-stage{padding-top:4px}
 #view-upgrade .up-circles .center{height:180px}
 #view-upgrade .reference-wheel{width:180px;height:180px}
 #view-upgrade .drop-side{min-height:178px;gap:5px;padding:8px 6px}
 #view-upgrade .drop-heading{min-height:48px}
 #view-upgrade .drop-heading b{font-size:11px}
 #view-upgrade .drop-heading span{font-size:10px}
 #view-upgrade .drop-circle{height:105px!important;width:100%!important}
 #view-upgrade .drop-side.has-selection .drop-meta{gap:5px}
 #view-upgrade .drop-side.has-selection .drop-name{font-size:11px;line-height:1.4}
 #view-upgrade .drop-server{font-size:9px}
 #view-upgrade .up-action-row>.up-btn{grid-row:1;order:0}
 #view-upgrade .up-action-row>.action-options{grid-row:2;order:1}
 #view-upgrade .up-action-row>#balBlock{grid-row:3;order:2}
 #view-upgrade .mobile-picker-links{position:sticky;top:var(--mobile-header-height,126px);z-index:12;padding:8px 0;background:#15161af5;margin-top:0}
 #view-upgrade .mobile-picker-links button{font-size:12px;min-height:44px}
 .mobile-upgrade-return:not([hidden]){position:fixed;z-index:34;left:12px;right:12px;bottom:calc(78px + env(safe-area-inset-bottom));display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:52px;padding:10px 14px;border:1px solid #8a752c;border-radius:12px;background:#25261ff5;box-shadow:0 5px 24px #0008;color:#ffe476;font:700 12px/1.4 Inter,system-ui,sans-serif;text-align:left}
 .mobile-upgrade-return small{display:block;color:#bdc3cb;font-size:10px;font-weight:500}
 .mobile-upgrade-return>span:last-child{font-size:20px;flex-shrink:0}
 body.mobile-return-visible{padding-bottom:calc(146px + env(safe-area-inset-bottom))}
 #storeModal .store-selection{min-height:110px;height:auto;max-height:none;overflow-x:auto;overflow-y:hidden;align-items:stretch;padding:10px;scroll-snap-type:x proximity}
 #storeModal .store-selected-card{min-height:206px;flex-shrink:0;scroll-snap-align:start}
 #storeModal .store-toolbar{flex-wrap:wrap}
 #storeModal .store-field{flex:1;min-width:0}
 #storeModal .store-price-jumps{display:grid;grid-template-columns:1fr 1fr;gap:7px}
 #storeModal .store-price-jumps button{min-width:0;margin:0;font-size:11px;padding:8px 5px}
 #storeModal .store-catalog-heading{flex-wrap:wrap;gap:8px}
 #storeModal .store-catalog-heading>button{margin-left:auto;min-height:44px}
 #storeModal .store-atmosphere,.ambient-dust{display:none}
 #view-profile .profile-item{min-height:250px!important;height:auto!important}
 #view-profile .item-actions{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
 #view-profile .item-actions>button{min-height:54px;display:flex;flex-direction:column;justify-content:center;align-items:center;gap:4px;padding:6px}
 #view-profile .item-actions>button::after{content:'Продать';font-size:10px;font-weight:700}
 #view-profile .item-actions>button.item-withdraw::after{content:'На вывод'}
 #view-profile .mobile-withdraw-reason{display:block;grid-column:1/-1;color:#b8bcc8;font-size:10px;letter-spacing:0;line-height:1.5;margin:0;overflow-wrap:anywhere}
 #view-profile .history-filter-bar{flex-wrap:wrap}
 #view-profile .history-filter-bar button{min-height:44px;padding:8px 11px}
 #view-profile .history-withdraw-actions button,.withdrawal-row-actions button{min-height:44px}
 .profile-history-row{min-width:0;gap:9px;flex-wrap:wrap}
 .profile-history-copy{min-width:0}
 .profile-history-money{max-width:100%;overflow-wrap:anywhere}
 .auth-code-actions button,.auth-tabs button,.ref-prize>.ref-claim-button,.ref-reward-actions button{min-height:44px}
 .auth-form input[type=checkbox]{min-width:20px;min-height:20px}
 .ref-track-arrows button,.ref-copy-code,.ref-link-copy,.ref-stat-foot a{min-height:44px}
 .ref-reward-track{scroll-padding-inline:2px}
 .ref-section-heading{flex-wrap:wrap}
 .ref-section-heading>div:first-child{min-width:0;flex:1 1 160px}
 .ref-reward-controls{flex:0 0 auto;min-width:70px}
 .ref-reward-summary span{max-width:none}
 .ref-channels a,.ref-copy-link,.ref-stat-foot button{min-height:44px;display:inline-flex;align-items:center}
 .top #notificationPanel .notification-head>button{width:44px;height:44px;min-width:44px;min-height:44px}
 .top #notificationPanel .notification-actions>button{min-height:44px}
 .top #notificationPanel{top:calc(var(--mobile-header-height,126px) + 6px);max-height:calc(var(--mobile-vh,100dvh) - var(--mobile-header-height,126px) - 90px)}
 body.mobile-scroll-locked{position:fixed;left:0;right:0;width:100%;overflow:hidden;overscroll-behavior:none}
 body.mobile-keyboard-open .mobile-nav,body.mobile-keyboard-open .mobile-upgrade-return{display:none!important}
 dialog[open]{max-height:calc(var(--mobile-vh,100dvh) - 20px - env(safe-area-inset-top) - env(safe-area-inset-bottom))!important}
 .modal{top:var(--mobile-visual-top,0px);bottom:auto;height:var(--mobile-vh,100dvh);overflow-y:auto;align-items:center}
 .modal .mbox,.cart-dialog{max-height:calc(var(--mobile-vh,100dvh) - 20px)!important}
 #storeModal .store-window{height:var(--mobile-vh,100dvh);max-height:var(--mobile-vh,100dvh)}
 .cart-modal{top:var(--mobile-visual-top,0px);bottom:auto;height:var(--mobile-vh,100dvh);padding:10px}
 .mobile-keyboard-open dialog[open]{position:fixed;top:calc(var(--mobile-visual-top,0px) + 10px);bottom:auto;left:0;right:0;margin:0 auto}
 .mobile-keyboard-open .modal{align-items:flex-start}
 .mobile-keyboard-open .support-panel{top:calc(var(--mobile-visual-top,0px) + 10px);bottom:auto!important;max-height:calc(var(--mobile-vh,100dvh) - 20px)}
 .withdrawal-chat[open]{display:flex;flex-direction:column;overflow:hidden}
 .withdrawal-chat>header{flex-shrink:0;padding:14px}
 #itemActionDialog>header{position:sticky;top:0;z-index:5;background:#11151d}
 #itemActionDialog{scroll-padding-top:100px;scroll-padding-bottom:16px}
 .withdrawal-chat>header button{min-width:44px;min-height:44px}
 .withdrawal-chat .chat-messages{height:340px;min-height:70px;max-height:calc(var(--mobile-vh,100dvh) - 250px);flex:1 1 auto;padding:12px;overflow:auto}
 .withdrawal-chat form{padding:12px;flex-direction:row;gap:8px;flex-shrink:0}
 .withdrawal-chat textarea{min-height:52px;max-height:100px;resize:none}
 .withdrawal-chat #chatSend{padding:9px 12px;font-size:12px;min-height:44px}
 #itemActionDialog>header button,.wallet-close,.ref-help-dialog>header button{min-width:44px;min-height:44px}
 .mobile-menu .mobile-menu-grid button{font-size:13px;line-height:1.4}
 .mobile-menu .mobile-menu-grid button[data-action=referrals]{color:#ffe476;border-color:#7b6a2e;background:#ffdb000c}
 @media(max-height:500px) and (min-width:500px){
  .top{flex-wrap:nowrap;min-height:58px;padding:6px 12px}
  .top .top-left{width:auto}.top .top-right{width:auto;flex:1}.top .mobile-stats,.top .telegram-btn{display:none!important}
  #view-upgrade .up-circles{grid-template-columns:minmax(0,1fr) 160px minmax(0,1fr)!important;gap:10px!important}
  #view-upgrade .up-circles .center{grid-column:2!important;grid-row:1;height:160px}
  #view-upgrade .reference-wheel{width:160px;height:160px}
  #view-upgrade .drop-side:first-child{grid-column:1!important;grid-row:1}
  #view-upgrade .drop-side:last-child{grid-column:3!important;grid-row:1}
  #view-upgrade .drop-side{min-height:160px}
 }
}
