/* mobfix v2 (2026-10-24): bigger board + hole cards on phones (portrait <=520px). Load AFTER cardsize/card_size.css. */
@media (orientation:portrait) and (max-width:520px){
  :root{--cs-hero-w:60px;--cs-hero-h:84px;--cs-hero-f:27px;--cs-board-w:54px;--cs-board-h:76px;--cs-board-f:25px;--cs-board-gap:3px}
  #tableWrap.many{--cs-board-w:49px;--cs-board-h:69px;--cs-board-f:23px;--cs-hero-w:54px;--cs-hero-h:76px;--cs-hero-f:25px}
  html,body{touch-action:manipulation;-webkit-text-size-adjust:100%;text-size-adjust:100%}
}
@media (orientation:portrait) and (max-width:520px) and (max-height:820px){
  :root{--cs-hero-w:54px;--cs-hero-h:76px;--cs-hero-f:25px;--cs-board-w:50px;--cs-board-h:70px;--cs-board-f:23px}
  #tableWrap.many{--cs-board-w:45px;--cs-board-h:63px;--cs-board-f:21px;--cs-hero-w:50px;--cs-hero-h:70px;--cs-hero-f:23px}
}
@media (orientation:portrait) and (max-width:520px) and (min-height:900px){
  :root{--cs-hero-w:64px;--cs-hero-h:90px;--cs-hero-f:29px;--cs-board-w:58px;--cs-board-h:81px;--cs-board-f:27px}
  #tableWrap.many{--cs-board-w:53px;--cs-board-h:74px;--cs-board-f:25px;--cs-hero-w:58px;--cs-hero-h:81px;--cs-hero-f:27px}
}
/* PLO 4-card hole cards on phones (2026-11-18): deterministic size + position.
   Do not rely on :has() alone (older CSS) or on JS fit (runs late; iPhone layout
   viewport can be 844px while Safari chrome leaves ~664px). Hold'em and desktop unchanged. */
@media (orientation:portrait) and (max-width:520px){
  /* exactly 4+ hole cards, no :has() required */
  #mine .card:first-child:nth-last-child(n+4),
  #mine .card:first-child:nth-last-child(n+4) ~ .card,
  #tableWrap.n4 #mine .card,
  #meZone.n4 #mine .card,
  #mine.n4 .card{
    --cs-hero-w:40px;--cs-hero-h:56px;--cs-hero-f:18px;
    width:40px!important;height:56px!important;line-height:56px!important;font-size:18px!important;
    margin-left:calc(40px * -.56)!important;box-shadow:-2px 0 4px #0006;
  }
  #mine .card:first-child:nth-last-child(n+4),
  #tableWrap.n4 #mine .card:first-child,
  #meZone.n4 #mine .card:first-child,
  #mine.n4 .card:first-child{margin-left:0!important}
  #mine:has(.card:nth-child(4)),
  #tableWrap.n4 #mine,
  #meZone.n4 #mine,
  #mine.n4{--cs-hero-w:40px;--cs-hero-h:56px;--cs-hero-f:18px;--cs-fan:.56;height:60px!important}
  /* placeMe already pins the BOTTOM of #meZone to the top of the hero seat
     (top + translate(-50%,-100%)). Do not override top/bottom/transform with a
     percentage — that left a large gap on short iPhone viewports. Take the
     hand-name and 'Tap a card to show' hint out of flow so they cannot lift
     the cards. The card bottoms then sit on, or slightly overlap, the avatar. */
  #meZone:has(#mine .card:nth-child(4)),
  #tableWrap.n4 #meZone,
  #meZone.n4{
    width:max-content;max-width:72%;
    z-index:4;
    padding-bottom:0!important;
    pointer-events:none;
  }
  #meZone.n4 #mine,
  #tableWrap.n4 #meZone #mine,
  #meZone:has(#mine .card:nth-child(4)) #mine{position:relative;z-index:2}
  #meZone.n4 #myhand,
  #tableWrap.n4 #meZone #myhand,
  #meZone:has(#mine .card:nth-child(4)) #myhand{
    position:absolute!important;left:50%;bottom:0;transform:translate(-50%,70%);
    height:auto!important;min-height:0!important;line-height:11px!important;
    font-size:10px!important;padding:0 5px!important;margin:0!important;
    z-index:3;pointer-events:none;white-space:nowrap;
  }
  #meZone.n4 #shRow,
  #tableWrap.n4 #meZone #shRow,
  #meZone:has(#mine .card:nth-child(4)) #shRow{
    position:absolute!important;right:100%;top:50%;transform:translate(-6px,-50%);
    margin:0!important;padding:0!important;gap:0!important;
    width:max-content;max-width:58px;white-space:normal;line-height:1.15;
    font-size:8px!important;text-align:right;opacity:.9;z-index:3;
    pointer-events:auto;flex-wrap:nowrap;
  }
  #meZone.n4 #shPill,
  #tableWrap.n4 #meZone #shPill,
  #meZone:has(#mine .card:nth-child(4)) #shPill{
    font-size:8px!important;padding:0!important;line-height:1.15!important;
    white-space:normal;max-width:58px;
  }
}


/* Compact the action stack, hand log and Dojo chat on phones so the table gets the room.
   iPhone 14/15 layout viewport is ~844px, so this must NOT be gated on max-height:760/820.
   Buttons stay at least 32px tall. Desktop (landscape / wide) unchanged. */
@media (orientation:portrait) and (max-width:520px){
  :root{--tabs:26px}
  #controls{height:auto!important;max-height:none;overflow:visible;margin-top:2px!important;margin-bottom:0!important;padding:0 6px}
  #controls input[type=range]{height:16px!important;margin:0 0 2px!important}
  #controls .quick{margin-top:2px!important;gap:4px!important}
  #controls .quick button{padding:0 2px!important;font-size:11px!important;min-height:32px;height:32px;line-height:32px;box-sizing:border-box}
  #controls .act{gap:4px!important;margin:0}
  #controls .act button{padding:0 4px!important;font-size:13px!important;min-height:32px;height:32px;line-height:32px;box-sizing:border-box}
  #clk{height:5px!important;margin:3px auto 0!important;width:min(420px,92%)!important}
  #soRow,#fcPre.fc-row{margin:2px 0 0!important;padding:0!important;font-size:11px}
  /* hand-history bar + Dojo chat: shorter row, parked at the bottom */
  .log,.log:not(.open){max-height:28px!important;min-height:28px;padding:2px 8px!important;font-size:10px!important;line-height:24px;bottom:4px!important;border-width:1px!important;border-radius:8px!important}
  #chat.closed,#chat:not(.open){min-width:0;min-height:28px}
  #chat.closed .ch,#chat .ch{padding:3px 8px!important;font-size:11px!important;min-height:28px;line-height:22px;box-sizing:border-box}
  #chat{bottom:4px!important;border-width:1px!important;border-radius:8px!important}
  #table{padding-bottom:var(--tabs,26px)!important}
}

/* Top bar: full "Leave Table" next to the coin balance, BACKGROUND and TOP UP at 390px, no overflow. */
@media (orientation:portrait) and (max-width:520px){
  html body #app header{display:flex;gap:3px;overflow:visible;align-items:center;padding:3px 4px!important}
  html body #app header>span:first-child{flex:0 1 auto;min-width:0;max-width:28%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  html body #app header #info{font-size:10px;letter-spacing:0;max-width:100%}
  html body #app header .logo{height:16px;width:16px;margin-right:2px}
  html body #app header>span:last-child{flex:1 1 auto;min-width:0;display:flex;justify-content:flex-end}
  html body #app header .tbl-btns{flex-wrap:nowrap!important;gap:2px!important;min-width:0;justify-content:flex-end;overflow:visible;max-width:100%}
  html body #app header .tbl-btns>button,
  html body #app header .tbl-btns>button.btn-s,
  html body #app header .tbl-btns>a{
    height:24px!important;min-height:24px!important;font-size:8px!important;padding:0 3px!important;
    letter-spacing:0!important;text-transform:capitalize!important;flex:0 0 auto;white-space:nowrap!important;
    overflow:visible!important;max-width:none!important;
  }
  html body #app header .tbl-btns>#sfxBtn,
  html body #app header .tbl-btns>#musBtn{padding:0 2px!important;font-size:11px!important;width:22px!important;min-width:22px!important}
  html body #app header .tbl-btns>#leaveBtn{padding:0 3px!important}
  html body #app header .tbl-btns>button[onclick="lobbyBtn()"]{width:auto!important;min-width:0!important;padding:0 3px!important;font-size:8px!important;overflow:visible!important}
}
/* lobby bottom nav (phones <=900px): all 5 tabs fit at 360-430px, iOS safe areas respected, help button kept clear */
@media (max-width:900px){
  .lb-nav{height:calc(64px + env(safe-area-inset-bottom,0px));padding:0 env(safe-area-inset-right,0px) env(safe-area-inset-bottom,0px) env(safe-area-inset-left,0px);box-sizing:border-box}
  .lb-nav button{flex:1 1 auto;min-width:0;padding:0 2px;white-space:nowrap;overflow:hidden;text-overflow:clip;font-size:clamp(10px,2.9vw,12.5px);letter-spacing:0}
  .lb-body{padding-bottom:calc(132px + env(safe-area-inset-bottom,0px))!important}
  #sipSupBtn{width:40px;height:40px;font-size:19px;line-height:36px;bottom:calc(74px + env(safe-area-inset-bottom,0px));right:calc(10px + env(safe-area-inset-right,0px))}
}
@media (max-width:400px){.lb-nav button{font-size:clamp(9.5px,2.8vw,11.5px)}}
@media (orientation:landscape) and (max-height:500px){.lb-nav{height:calc(52px + env(safe-area-inset-bottom,0px))} #sipSupBtn{bottom:calc(60px + env(safe-area-inset-bottom,0px))}}
@media (max-width:900px){#stand .sw{padding-bottom:calc(150px + env(safe-area-inset-bottom,0px))!important}}
