/* Phone shell and lobby. Everything here applies only to body.phone, so the computer layout never changes.
   The games have their own phone files: games/*-phone.css */
#mnav,#mtop{display:none}

/* ---------- frame ---------- */
body.phone{--navh:calc(58px + env(safe-area-inset-bottom));padding-bottom:var(--navh);min-height:100dvh;width:100%;overflow-x:clip;-webkit-tap-highlight-color:transparent;background-attachment:scroll}
html:has(body.phone){overflow-x:hidden;width:100%}
body.phone::after{display:none}
body.phone button{touch-action:manipulation}
body.phone button:hover:not(:disabled){filter:none;transform:none}
body.phone button:active:not(:disabled){transform:scale(.97)}
body.phone input,body.phone select{font-size:16px}
body.phone main{display:block;padding:6px;max-width:100vw;min-width:0;overflow-x:clip}
body.phone #game{padding:8px 6px;min-height:0;border-width:4px;border-radius:14px;overflow:hidden}
body.phone #groot{min-width:0}
body.phone .hint{margin-top:60px;font-size:20px}

/* header (lobby only): chips | name | sound */
body.phone header{display:grid;grid-template-columns:1fr auto 1fr;gap:8px;padding:calc(env(safe-area-inset-top) + 8px) 12px 10px;position:sticky;top:0;z-index:40}
body.phone header .logo{grid-area:1/2;font-size:20px;gap:6px;white-space:nowrap}
body.phone header .logo svg{width:28px;height:28px}
body.phone #tabs,body.phone #userbtn,body.phone #friendsbtn,body.phone #bonus{display:none}
body.phone .wallet{display:contents}
body.phone #walletbtn{grid-area:1/1;justify-self:start;max-width:100%;gap:5px;padding:2px 10px}
body.phone #walletbtn b{font-size:17px}
body.phone #debtchip{font-size:10px}
body.phone #mute{grid-area:1/3;justify-self:end;padding:5px 9px}

/* bottom navigation */
body.phone #mnav{display:grid;grid-template-columns:repeat(5,1fr);position:fixed;left:0;right:0;bottom:0;height:var(--navh);padding-bottom:env(safe-area-inset-bottom);z-index:60;background:linear-gradient(#240509,#12040a);border-top:2px solid var(--gold2);box-shadow:0 -6px 20px #000a;direction:rtl}
body.phone #mnav button{position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;background:none;border:0;border-radius:0;padding:0;color:#f0c35a;font-size:11px}
body.phone #mnav svg{fill:currentColor}
body.phone #mnav button:active{background:#ffffff14}
body.phone #mnav button.new::after{content:"";position:absolute;top:9px;left:calc(50% + 8px);width:9px;height:9px;border-radius:50%;background:#ff5252}
body.phone:has(#login:not(.hide)) #mnav{display:none}

/* table chat: a sheet at the bottom */
body.phone #chat{display:none}
body.phone.chat-open #chat{display:flex;position:fixed;left:6px;right:6px;bottom:calc(var(--navh) + 6px);height:46dvh!important;min-height:0;max-height:none;z-index:65;box-shadow:0 -10px 30px #000d}
body.phone #toast{bottom:calc(var(--navh) + 12px);width:max-content;max-width:92vw;text-align:center;z-index:90}

/* login */
body.phone #login{overflow:auto;padding:16px}
body.phone #loginform{padding:24px 18px}

/* ---------- windows: full width, scrollable, above the navigation ---------- */
body.phone .sc-modal,body.phone .xt-modal,body.phone #profile{padding:8px 8px calc(var(--navh) + 8px);z-index:70;align-items:center}
body.phone .sc-box,body.phone .xt-box,body.phone .modal{width:100%!important;max-width:460px;max-height:100%;overflow-y:auto;padding:14px 12px}
body.phone #sc-pop{left:8px;right:8px;bottom:calc(var(--navh) + 8px);max-width:none;z-index:68}
body.phone .announce{top:calc(env(safe-area-inset-top) + 64px);min-width:0;width:92vw}
body.phone .rain-msg{top:auto;bottom:calc(var(--navh) + 14px);font-size:12px;gap:5px;padding:5px 12px}
body.phone .xt-wheelbox{width:min(100%,calc(100dvh - 380px),330px);min-width:230px}
body.phone .bw-title{letter-spacing:2px}
body.phone #xt-tip{display:none}

/* ---------- lobby: one full screen, and the rest below it with a scroll ---------- */
body.phone.home-on{display:block;height:auto;overflow:visible}
body.phone.home-on main{display:block;padding:0}
body.phone.home-on #game{display:block;overflow:visible;padding:0;border:0;border-radius:0;background:none;box-shadow:none}
body.phone.home-on #groot{display:block}
.ml{display:flex;flex-direction:column;gap:8px;padding:8px 10px 14px}
.ml-first{display:flex;flex-direction:column;gap:8px;height:calc(100dvh - var(--navh) - var(--mlh,58px) - env(safe-area-inset-top) - 14px);min-height:500px}
.ml button{min-width:0}
.ml-hello{flex:none;display:flex;justify-content:space-between;align-items:center;gap:8px;background:#0006;border:1px solid #f0c35a44;border-radius:14px;padding:5px 10px;font-size:14px;min-height:48px}
.ml-hello div{min-width:0;line-height:1.25}.ml-hello div>span{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.ml-hello small{display:block;font-size:11px;opacity:.75}
.ml-hello .act{flex:none;display:flex;align-items:center;gap:5px;padding:7px 12px;font-size:13px}
.ml-next{flex:none;font-size:11px;text-align:center;opacity:.8;line-height:1.3}.ml-next .cd{display:block;color:var(--gold);font-weight:700;font-size:13px;direction:ltr}
.ml .ml-jack{flex:none;text-align:center;border-radius:16px;border:2px solid var(--gold);background:linear-gradient(#3a0b14,#14050a);padding:3px;box-shadow:0 0 16px #f0c35a44}
.ml-jack small{display:block;letter-spacing:4px;font-size:11px;opacity:.85}
.ml-jack b{display:block;font-family:var(--display);font-size:26px;color:#ffd54f;line-height:1.1}
.ml-pair{flex:1;min-height:0;display:grid;grid-template-columns:1fr 1fr;gap:8px}
.ml-grid{flex:2.6;min-height:0;display:grid;grid-template-columns:1fr 1fr;grid-template-rows:minmax(0,1fr) minmax(0,1fr);gap:8px}
.ml .ml-tile{position:relative;border-radius:16px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;border:1px solid #f0c35a66;overflow:hidden;min-height:0;padding:4px}
.ml-tile b{flex:none;font-family:var(--display);font-weight:400;font-size:18px;color:#ffe9a8;line-height:1.2}
.ml-tile small{flex:none;font-size:11px;opacity:.85;line-height:1.2;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
/* the drawing takes whatever height is left in the tile */
.ml-art{flex:1;min-height:0;width:100%;position:relative}
.ml-art>svg,.ml-art>.wheelwrap{position:absolute;inset:0;margin:auto;max-width:100%;max-height:100%}
.ml-art>svg{width:100%;height:100%}
.ml-art>.wheelwrap{height:100%!important;width:auto!important;aspect-ratio:1}
.ml-art .wheelwrap svg{width:100%;height:100%}.ml-art .wheelpin{display:none}
.ml-art .hm-cards{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;direction:ltr}
.ml-art{container-type:size}
.ml-art .hm-cards .pc{--cw:min(46px,60cqh)!important}
.ml .t-wheel{background:linear-gradient(135deg,#6a1b9a,#c2185b 55%,#e65100)}
.ml .t-vault{background:linear-gradient(135deg,#2a1c04,#7a560e)}
.ml .t-vault.owe{border-color:#ff5252;box-shadow:0 0 14px #ff5252aa}
.ml .t-slots{background:linear-gradient(160deg,#8a1a2e,#2a0610)}.ml .t-roulette{background:linear-gradient(160deg,#13804c,#063a22)}
.ml .t-blackjack{background:linear-gradient(160deg,#1d5a94,#0a1f3a)}.ml .t-mines{background:linear-gradient(160deg,#a67a14,#2a1c04)}
.ml .ml-tile.shut{filter:grayscale(.8) brightness(.7)}
.ml .ml-poker{flex:none;display:flex;justify-content:center;align-items:center;gap:8px;font-family:var(--display);font-size:14px;border:1px solid #b388ff88;background:linear-gradient(90deg,#2a0f45,#4a1d78);border-radius:12px;padding:6px;opacity:.75}
.ml-poker small{font-family:var(--body);font-size:11px;opacity:.85}
/* the panels below the first screen (the computer lobby hides them on short screens) */
body.phone.home-on .ml .hm-cols{display:flex;flex-direction:column;gap:8px}
body.phone.home-on .ml .hm-panel{max-height:none;overflow:visible;padding:10px 12px}
body.phone.home-on .ml .hm-panel>button{display:inline-block}
body.phone.home-on .ml .hm-stats{grid-template-columns:1fr 1fr}
@media(max-height:640px){.ml-first{gap:6px;min-height:430px}.ml-grid,.ml-pair{gap:6px}.ml-tile b{font-size:15px}.ml-tile small{display:none}.ml-jack b{font-size:21px}.ml-hello{min-height:40px}}

/* ---------- inside a game: the screen belongs to the game ---------- */
body.phone.ingame{position:fixed;inset:0;display:flex;flex-direction:column;height:100dvh;min-height:0;padding:0;overflow:hidden}
body.phone.ingame header,body.phone.ingame #mnav,body.phone.ingame #gbar{display:none!important}
body.phone.ingame #mtop{flex:none;display:grid;grid-template-columns:116px minmax(0,1fr) 116px;align-items:center;gap:4px;padding:calc(env(safe-area-inset-top) + 6px) 8px 6px;background:linear-gradient(#240509,#12040a);border-bottom:2px solid var(--gold2);position:relative;z-index:20}
#mtop button{display:inline-flex;align-items:center;justify-content:center;height:34px;border-radius:10px}
#mtop .mt-back{justify-self:start;padding:0 12px;font-size:14px;white-space:nowrap}
#mtop .mt-money{justify-self:center;gap:6px;max-width:100%;border-radius:20px;padding:0 12px;background:#0008;border:1px solid #f0c35a55}
.mt-money b{font-family:var(--display);font-weight:400;font-size:18px;color:var(--gold)}.mt-coin{display:flex}
.mt-acts{justify-self:end;display:flex;gap:4px}
.mt-acts button{position:relative;width:36px;padding:0;color:#f0c35a}
.mt-acts button[hidden]{display:none}
.mt-acts svg{fill:currentColor}
#mtop button.new::after{content:"";position:absolute;top:4px;right:4px;width:9px;height:9px;border-radius:50%;background:#ff5252}
body.phone.ingame main{flex:1;width:100%;max-width:none;margin:0;min-height:0;padding:0;display:flex;flex-direction:column;overflow:visible}
body.phone.ingame #game{flex:1;width:100%;min-height:0;display:flex;flex-direction:column;padding:0;border:0;border-radius:0;box-shadow:none;overflow:hidden}
body.phone.ingame #groot{flex:1;min-height:0;display:flex;flex-direction:column}
body.phone.ingame.chat-open #chat{bottom:calc(env(safe-area-inset-bottom) + 6px);height:52dvh!important}
body.phone.ingame #toast{bottom:auto;top:46%}
body.phone.ingame .sc-modal,body.phone.ingame .xt-modal,body.phone.ingame #profile{padding-bottom:calc(env(safe-area-inset-bottom) + 8px)}
/* badges, invites and rain show under the top bar, so they never cover the game buttons */
body.phone.ingame #sc-pop,body.phone.ingame .rain-msg{top:calc(env(safe-area-inset-top) + 54px);bottom:auto}
/* choosing a table */
body.phone.ingame #groot>.lobby{flex:1;min-height:0;overflow-y:auto;display:flex;flex-direction:column;gap:8px;padding:10px}
body.phone .lobby>*{flex:none}
body.phone .lobby h2{margin:0;font-size:20px;text-align:center}
body.phone .lvhead small{margin-inline-start:0}

/* leaving a table */
#mleave{position:fixed;inset:0;z-index:80;display:flex;align-items:center;justify-content:center;padding:20px;background:#000b}
#mleave>div{width:100%;max-width:340px;text-align:center;border-radius:20px;border:2px solid var(--gold);background:linear-gradient(#3a0b14,#14050a);padding:16px}
#mleave h3{margin:0 0 6px;font-family:var(--display);color:var(--gold);font-size:22px}
#mleave p{margin:0 0 14px;font-size:15px;line-height:1.5}
#mleave div div{display:grid;grid-template-columns:1fr 1fr;gap:8px}
#mleave button{height:46px;font-size:16px;border-radius:14px}

/* the games are built for an upright phone */
@media (orientation:landscape) and (max-height:500px){
  body.phone.ingame::after{content:"סובבו את הטלפון לאורך כדי לשחק";display:flex;align-items:center;justify-content:center;position:fixed;inset:0;z-index:95;opacity:1;pointer-events:auto;animation:none;background:#12040a;color:#f0c35a;font-family:var(--display);font-size:22px;text-align:center;padding:20px}
}

/* ---------- before the server answers (a reload): a quiet loading screen, not the empty table ---------- */
body.phone:not(.home-on):not(.ingame) #game,body.phone:not(.home-on):not(.ingame) #walletbtn,body.phone:not(.home-on):not(.ingame) #mnav{visibility:hidden}
body.phone:not(.home-on):not(.ingame) main::after{content:"טוען…";position:fixed;left:0;right:0;top:46%;text-align:center;font-family:var(--display);font-size:24px;color:var(--gold);animation:mload 1s ease-in-out infinite alternate}
@keyframes mload{from{opacity:.35}}
/* the sign-in screen covers the header */
body.phone #login{z-index:45}
