/* Narrow panel fixes; no game coordinates, outcomes or wallet values change. */
@media(max-width:400px){
 .iw-wallet,.ex-exchange{min-width:0;max-width:100%}
 .iw-wallet .iw-balance-card{padding:18px 14px;min-height:124px}
 .iw-wallet .iw-balance-copy{width:100%;padding-right:0}
 .iw-wallet .iw-balance-card strong{font-size:24px;overflow-wrap:anywhere;word-break:normal}
 .iw-wallet .iw-balance-art{position:absolute;right:0;bottom:0;opacity:.17;pointer-events:none;z-index:0}
 .iw-wallet .iw-fields{grid-template-columns:minmax(0,1fr)}
 .iw-wallet .iw-fields select{font-size:16px;min-height:44px}
 .iw-wallet .iw-tabs button{font-size:10px;min-height:46px;white-space:normal}
 .iw-wallet .iw-receipt-paper dl>div{align-items:flex-start;gap:10px}
 .iw-wallet .iw-receipt-paper dt{flex-shrink:0}
 .iw-wallet .iw-receipt-paper dd{min-width:0;overflow-wrap:anywhere}
 .ex-exchange .ex-from-box,.ex-exchange .ex-to-box{flex-wrap:wrap;gap:12px}
 .ex-exchange .ex-from-box input,.ex-exchange .ex-to-box output{flex:0 0 100%;width:100%;font-size:22px}
 .ex-exchange .ex-asset-picker{flex:0 0 100%;width:100%;border-left:0;border-top:1px solid #70548944;padding:9px 0 0}
 .ex-exchange .ex-asset-picker select{font-size:16px;min-height:36px;padding-top:3px;padding-bottom:3px}
 .ex-exchange .ex-asset-picker>.ex-icon{top:23px}
 .ex-exchange .ex-market-grid{grid-template-columns:minmax(0,1fr)}
 .ex-exchange .ex-market-coin{padding:11px 12px;gap:10px}
 .ex-exchange .ex-market-coin small{display:block}
 .ex-exchange .ex-market-price{font-size:11px}
 .ex-exchange .ex-quote-meta{flex-wrap:wrap;gap:7px}
 .ex-exchange .ex-quote-timestamp{min-width:0;overflow-wrap:anywhere}
 .game-dialog .gs-player{max-width:calc(100vw - 16px)}
 .game-dialog .gs-coin strong{min-width:0;overflow-wrap:anywhere}
 .game-dialog .gs-id-actions button{min-width:0;flex-wrap:wrap;line-height:1.35}
 .game-dialog .gs-card-bottom{gap:8px}
 .game-dialog .gs-card-bottom strong{font-size:20px;letter-spacing:-.35px}
 .game-dialog .bj-control .bj-actions{grid-template-columns:repeat(2,minmax(0,1fr))}
 .game-dialog .imperial-roulette .rl-chip-picker{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px;justify-items:center}
 .game-dialog .imperial-roulette .rl-chip{width:min(65px,100%);height:auto;aspect-ratio:65/72;min-width:0;max-width:100%}
 .game-dialog .imperial-roulette .rl-table-controls{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
 .game-dialog .imperial-roulette .rl-table-controls>.rl-table-tool{width:100%;min-width:0;min-height:40px}
 .game-dialog .imperial-roulette .rl-table-total{grid-column:1/3;margin-left:0;text-align:left;min-width:0}
 .game-dialog .imperial-roulette .rl-table-total strong{overflow-wrap:anywhere}
 .game-dialog .imperial-roulette .rl-table-spin{grid-column:3;min-width:0;width:100%;margin-left:0;padding:0 7px;gap:5px;font-size:14px}
}

/* iOS can keep 100dvh at full height while its visual viewport is keyboard-sized.
   The class is active only for a focused editable field and a measured keyboard. */
@media(max-width:760px){
 html.imperial-keyboard-open .mobile-nav{visibility:hidden;pointer-events:none}
 html.imperial-keyboard-open dialog[open]:not(.game-dialog):not(#support){top:calc(var(--imperial-visual-top) + 8px);bottom:auto;margin:0 auto;max-height:calc(var(--imperial-visual-height) - 16px);overflow:auto}
 html.imperial-keyboard-open #support[open]{top:auto;bottom:calc(var(--imperial-keyboard-inset) + 8px);max-height:calc(var(--imperial-visual-height) - 16px)}
 html.imperial-keyboard-open #support .support-head,html.imperial-keyboard-open #support .chat-form,html.imperial-keyboard-open #support .support-bottom{flex-shrink:0}
 html.imperial-keyboard-open #support .messages{min-height:36px;flex:1 1 auto;max-height:calc(var(--imperial-visual-height) * .35);overflow-y:auto}
 html.imperial-keyboard-open dialog.game-dialog{top:var(--imperial-visual-top);bottom:auto;height:var(--imperial-visual-height);max-height:var(--imperial-visual-height)}
 html.imperial-keyboard-open .gs-overlay{bottom:0}
 html.imperial-keyboard-open .ls-slip-open .ls-comparison{bottom:calc(var(--imperial-keyboard-inset) + 8px);max-height:calc(var(--imperial-visual-height) - 16px);overflow-y:auto;overscroll-behavior:contain}
 html.imperial-keyboard-open .ls-comparison .ls-selected{max-height:calc(var(--imperial-visual-height) * .25)}
 html.imperial-keyboard-open .ls-comparison .ls-slip-bottom{flex:0 0 auto;max-height:none;overflow:visible}
 html.imperial-keyboard-open .ls-slip-backdrop:not([hidden]){bottom:var(--imperial-keyboard-inset)}
}
/* Long holdings need the same space on 401–480px phones as narrower phones. */
@media(max-width:480px){
 .iw-wallet .iw-balance-copy{width:100%;min-width:0;padding-right:0}
 .iw-wallet .iw-balance-card strong,.iw-wallet .iw-balance-card strong>span{min-width:0;max-width:100%;overflow-wrap:anywhere;word-break:normal}
 .iw-wallet .iw-balance-art{position:absolute;right:0;bottom:0;opacity:.17;pointer-events:none;z-index:0}
}
