/* Mobile Durak uses one grid; rows cannot drift behind browser controls. */
.mobile-sort{display:none}
.mobile-sort-options{display:grid;gap:12px}.mobile-sort-options [aria-pressed=true]{border-color:#d4b77c!important;background:#35432d!important}
@media(max-width:900px) and (orientation:portrait){
 body.in-game main,.table-world{width:100vw;height:100dvh}
 body.in-game .game:not(.club-table){--mobile-card-width:min(44vw,25dvh,190px);--mobile-hand-height:calc(var(--mobile-card-width)*1.5 + 24px);display:grid!important;grid-template-columns:minmax(0,1fr)!important;grid-template-rows:auto 24px auto minmax(0,1fr) auto var(--mobile-hand-height)!important;gap:8px!important;padding:max(18px,env(safe-area-inset-top)) 16px max(18px,env(safe-area-inset-bottom))!important;box-sizing:border-box;width:100%;height:100%;min-height:0}
 body.in-game .game:not(.club-table) .game-top{top:12px!important;right:12px!important;width:44px!important;height:44px!important}
 body.in-game .game:not(.club-table) .game-menu{width:44px;height:44px}
 body.in-game .game:not(.club-table) .opponents{position:relative!important;inset:auto!important;grid-row:1;width:100%;height:auto;min-height:96px;display:flex;justify-content:space-evenly;gap:6px!important;padding-right:44px!important;box-sizing:border-box}
 body.in-game .game:not(.club-table) .opponent,body.in-game .game:not(.club-table) .opponent:only-child{width:calc((100% - 18px)/4);max-width:112px!important;min-width:0;flex:1}
 body.in-game .game:not(.club-table) .opponent-cards{width:min(100%,88px);height:38px}
 body.in-game .game:not(.club-table) .mini-back{width:25px;height:37.5px;left:calc(50% - 12.5px + var(--fan-index)*6px)}
 body.in-game .game:not(.club-table) .opponent .portrait{width:48px;height:48px;margin-top:-24px}
 body.in-game .game:not(.club-table) .opponent .name{font-size:13px;line-height:18px;padding:4px 0 0;max-width:100%}
 body.in-game .game:not(.club-table) .opponent .status{font-size:11px;line-height:15px;min-height:15px;max-width:100%}
 body.in-game .game:not(.club-table) .opponent-count{width:23px;height:23px;font-size:14px;right:calc(50% - 36px);bottom:-20px}
 body.in-game .game:not(.club-table) .table-stats{position:relative!important;inset:auto!important;grid-row:2;width:100%!important;height:24px!important;font-size:13px;align-self:center}
 body.in-game .game:not(.club-table) .supply{display:flex;align-items:center;justify-content:space-between;height:24px;padding:0;gap:8px}
 body.in-game .game:not(.club-table) .discard-count{font-size:12px}
 body.in-game .game:not(.club-table) .last-action{position:relative;inset:auto!important;grid-row:3;width:100%;min-height:0;padding:0;gap:6px;font-size:11px;line-height:15px}
 body.in-game .game:not(.club-table) .last-action .action-avatar{width:24px;height:24px}
 body.in-game .game:not(.club-table) .play-area{position:relative!important;inset:auto!important;grid-row:4;width:100%;height:100%;min-height:0;align-self:stretch;margin:0}
 body.in-game .game:not(.club-table) .table-empty{font-size:15px;line-height:1.5}
 body.in-game .game:not(.club-table) .player-dock{position:relative;inset:auto!important;grid-row:5;width:100%;display:flex;flex-direction:column;gap:10px;min-width:0;margin:0}
 body.in-game .game:not(.club-table) .turn-text{position:relative;width:100%;display:grid;grid-template-columns:minmax(0,1fr) auto;column-gap:8px;padding-left:44px;font-size:20px;line-height:1.3;align-self:auto}
 body.in-game .game:not(.club-table) .turn-title{grid-column:1;grid-row:1}
 body.in-game .game:not(.club-table) .turn-text small{grid-column:1/-1;grid-row:2;font-size:12px;line-height:16px;margin:2px 0 0}
 body.in-game .game:not(.club-table) .self-avatar{left:1px;top:4px;bottom:auto;width:32px;height:32px}
 body.in-game .game:not(.club-table) .turn-text .hand-count-text{grid-column:2;grid-row:1;display:block;padding:0;margin:0;min-height:0;font-size:12px;align-self:center}
 body.in-game .game:not(.club-table) .ranked-clock{font-size:11px!important;margin:0!important;line-height:14px!important}
 body.in-game .game:not(.club-table) .control-stack{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);grid-template-rows:auto;gap:8px;width:100%;align-self:stretch;margin:0}
 body.in-game .game:not(.club-table) .sort-label,body.in-game .game:not(.club-table) .hand-tools{display:none}
 body.in-game .game:not(.club-table) .mobile-sort{display:block;grid-column:1;grid-row:1;min-height:44px;font:14px/1.3 var(--font-display);padding:8px;border:1px solid #8c754b;border-radius:6px;color:#eadbbd;background:linear-gradient(#28372b,#14251b)}
 body.in-game .game:not(.club-table) .actions{grid-column:2;grid-row:1;height:auto;min-width:0;display:flex}
 body.in-game .game:not(.club-table) .actions button{font-size:15px;line-height:1.25;min-height:44px;padding:6px;width:100%}
 body.in-game .game:not(.club-table) .multi-controls{grid-column:2;grid-row:1;display:flex;gap:6px;min-width:0}
 body.in-game .game:not(.club-table) .multi-controls button{min-height:44px;font-size:12px;line-height:1.25;padding:4px;white-space:normal}
 body.in-game .game:not(.club-table) .control-stack:has(.multi-controls):has(.actions button) .multi-controls{grid-column:1/-1;grid-row:2}
 body.in-game .game:not(.club-table) .hand-area{position:relative!important;inset:auto!important;grid-row:6;width:100%!important;height:auto!important;min-height:0;max-width:none!important;margin:0!important;align-self:stretch}
 body.in-game .game:not(.club-table) .hand .card{--card-w:var(--mobile-card-width);--card-h:calc(var(--card-w)*1.5);bottom:0!important}
 body.in-game .game:not(.club-table) .hand-viewport{height:100%!important}
 body #modal{max-height:calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));overscroll-behavior:contain}
 body #modal .close{min-width:44px;min-height:44px}
}
@media(max-width:900px) and (orientation:portrait) and (max-height:650px){
 body.in-game .game:not(.club-table){--mobile-card-width:min(34vw,18dvh,100px);gap:6px;padding-top:14px;padding-bottom:14px}
 body.in-game .game:not(.club-table) .opponents{min-height:80px}
 body.in-game .game:not(.club-table) .opponent-cards{height:30px}
 body.in-game .game:not(.club-table) .mini-back{width:20px;height:30px;left:calc(50% - 10px + var(--fan-index)*5px)}
 body.in-game .game:not(.club-table) .opponent .portrait{width:40px;height:40px;margin-top:-22px}
 body.in-game .game:not(.club-table) .opponent .name{font-size:12px;line-height:16px}
 body.in-game .game:not(.club-table) .opponent .status{font-size:10px;line-height:13px;min-height:13px}
 body.in-game .game:not(.club-table) .opponent-count{bottom:-17px;right:calc(50% - 30px)}
 body.in-game .game:not(.club-table) .turn-text{font-size:18px}
 body.in-game .game:not(.club-table) .player-dock{gap:6px}
}
@media(max-width:900px) and (max-height:500px) and (orientation:landscape){
 body.in-game main,.table-world{width:100vw;height:100dvh}
 body.in-game .game:not(.club-table) .hand-area{inset:auto 26% 24px!important;height:calc(min(9vw,72px)*1.5 + 28px)!important}
 body.in-game .game:not(.club-table) .hand .card{--card-w:min(9vw,72px);--card-h:calc(var(--card-w)*1.5);bottom:0!important}
 body.in-game .game:not(.club-table) .opponents{top:12px!important;left:29%!important;right:10%!important}
 body.in-game .game:not(.club-table) .opponent .portrait{width:42px;height:42px;margin-top:-30px}
 body.in-game .game:not(.club-table) .opponent-cards{height:46px}
 body.in-game .game:not(.club-table) .opponent .name{font-size:12px;line-height:16px}
 body.in-game .game:not(.club-table) .opponent .status{font-size:10px;line-height:13px}
 body.in-game .game:not(.club-table) .player-dock{top:53%;bottom:18px;left:18px;right:18px;grid-template-columns:23% minmax(0,1fr) 23%}
 body.in-game .game:not(.club-table) .control-stack{grid-column:3}
 body.in-game .game:not(.club-table) .turn-text{font-size:18px}
 body.in-game .game:not(.club-table) .turn-text small{font-size:12px}
 body.in-game .game:not(.club-table) .hand-tools{height:40px}
 body.in-game .game:not(.club-table) .hand-tools button{font-size:12px;padding:4px}
 body.in-game .game:not(.club-table) .actions button{min-height:40px;font-size:14px}
 body.in-game .game:not(.club-table) .play-area{bottom:44%!important}
}
/* Club hands also stay above browser chrome; their game-specific controls remain. */
@media(max-width:900px) and (orientation:portrait){
 body.in-game .game.club-table .hand .card{--card-w:min(24cqw,12cqh,96px);bottom:max(16px,env(safe-area-inset-bottom))!important}
}

@media(max-width:900px) and (orientation:portrait){body.in-game .game:not(.club-table):has(.opponent:only-child) .opponents{padding-right:0!important}}

/* Split sorting control: label repeats the chosen sort; gear changes the mode. */
.mobile-sort-group{display:none}
@media(max-width:900px){
 body.in-game,body.in-game .game{background:#193022!important;border:0!important;border-radius:0!important;box-shadow:none!important}
 body.in-game .game::before,body.in-game .game::after{display:none!important}
}
@media(max-width:900px) and (orientation:portrait){
 body.in-game .game:not(.club-table) .mobile-sort-group{display:flex;grid-column:1;grid-row:1;min-width:0;border:1px solid #8c754b;border-radius:6px;overflow:hidden;background:linear-gradient(#28372b,#14251b)}
 body.in-game .game:not(.club-table) .mobile-sort-group button{min-height:44px;background:none;box-shadow:none;border:0;border-radius:0;color:#eadbbd;padding:5px;font:13px/1.3 var(--font-display)}
 body.in-game .game:not(.club-table) .mobile-sort-group .mobile-sort{flex:1;min-width:0}
 body.in-game .game:not(.club-table) #mobile-sort-settings{flex:0 0 44px;border-left:1px solid #8c754b66;display:grid;place-items:center}
 #mobile-sort-settings svg{width:21px;height:21px;fill:none;stroke:currentColor;stroke-width:1.5;stroke-linejoin:round}
}

@media(max-width:900px) and (orientation:portrait){
 body.in-game .game:not(.club-table) #mobile-sort-settings{order:-1;border-left:0;border-right:1px solid #8c754b66}
}
