/* Stable play surface. Only individual piles, groups and dialogs can scroll. */
html,body{height:100%;margin:0;overflow:hidden;overscroll-behavior:none}
body{
  --rack-height:clamp(185px,29vh,252px);
  --rack-height:clamp(185px,29dvh,252px);
  box-sizing:border-box;width:100%;height:100vh;height:100dvh;
  display:grid;grid-template-rows:clamp(40px,6vh,62px) minmax(0,1fr);
  padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
header,main{width:100%;max-width:1440px;min-width:0;margin:0 auto}
header{height:100%;padding:0 clamp(10px,3vw,48px)}
header .brand{gap:8px}.mark{width:29px;height:34px;font-size:22px}
.brand h1{font-size:1.15rem}.brand small{font-size:.72rem}
main{
  min-height:0;padding:6px clamp(7px,2vw,32px);
  display:grid;grid-template-rows:minmax(0,1fr) var(--rack-height);gap:6px;
}
.room{min-height:0;min-width:0;display:grid;grid-template-rows:3.65rem minmax(0,1fr) 2rem;gap:4px}
.roomhead{margin:0;min-width:0;gap:5px}
.roomhead h2{font-size:clamp(1.12rem,2.6vw,1.8rem)}
.tablemeta{min-width:0}
.felt{
  min-height:0;height:100%;min-width:0;padding:clamp(5px,1.2vw,14px);
  grid-template-rows:minmax(0,1.05fr) minmax(0,1fr) minmax(0,1.35fr) minmax(0,1fr) 1.45rem;
  align-items:center;row-gap:3px;overflow:hidden;
}
.felt .seat,.felt .river{min-height:0;max-height:100%;overflow:auto;overscroll-behavior:contain;scrollbar-width:thin}
.felt .seat{min-width:0}.felt .river{align-self:stretch}
.felt .river:focus-visible,.felt .seat:focus-visible{outline:2px solid var(--gold);outline-offset:-2px}
.felt .center,.wall{max-height:100%}.wall{height:clamp(40px,8vh,75px);width:clamp(48px,8vh,75px)}
.wall span{font-size:clamp(18px,3.5vh,31px)}.wall small{font-size:.68rem}
#callStrip{position:relative;margin:0;padding:2px 9px;min-height:0;display:flex;align-items:center;gap:8px}
#callStrip[hidden]{display:none}
#callDetails{margin:0 0 0 auto;flex:none}
#callNotice{max-height:1.55em;overflow:auto;overscroll-behavior:contain}
#callHistory{
  position:absolute;bottom:100%;right:0;z-index:5;margin:0;width:min(450px,100%);
  max-height:min(32vh,230px);overflow:auto;border:1px solid #8e9d84;border-radius:6px;
  background:#213b30;padding:8px 10px 8px 32px;box-shadow:0 5px 18px #0007
}
.tray{
  --tile:clamp(30px,min(4.25vw,6.5vh),56px);
  min-height:0;min-width:0;margin:0;padding:5px clamp(8px,1.5vw,20px);
  display:grid;grid-template-rows:1.7rem 1.8rem 1.35rem minmax(0,1fr) 2.85rem;gap:1px
}
.turn-ribbon,.trayhead,.actionbar{margin:0;min-width:0;min-height:0;padding:0}
.turn-ribbon{overflow:auto;align-items:center;align-content:start;gap:3px .5rem;scrollbar-width:thin}
.trayhead>div{display:flex;align-items:baseline;gap:8px}.trayhead .smallcap{order:2}
.trayhead h2{font-size:1.15rem}.trayhead{gap:4px}.trayhead #status{font-size:.85rem}
#ownExtras{display:flex;align-items:center;gap:6px;min-width:0;overflow:auto;white-space:nowrap;scrollbar-width:thin}
#myMelds,#myFlowers,#ownExtras .flower-group{margin:0;flex-wrap:nowrap}
#hand{
  --draw-gap:clamp(8px,1.1vw,16px);--face-height:calc(var(--tile)*1.39);
  width:100%;height:100%;max-width:none;max-height:100%;min-width:0;min-height:0;margin:0 auto;padding:3px 4px 6px;
  align-content:center;align-items:center;overflow:auto;gap:clamp(2px,.35vw,5px);
}
.actionbar{display:flex;align-items:center;justify-content:space-between;gap:8px}
.hint-wrap{min-width:0;max-height:100%;overflow:auto;scrollbar-width:thin}
#hint,#discardRule{font-size:.85rem;min-height:0;line-height:1.4;margin:0;text-align:left}
#actions{
  display:flex;min-width:0;max-width:78%;justify-content:flex-start;
  flex-wrap:nowrap;overflow-x:auto;gap:5px;scrollbar-width:thin
}
#actions button{white-space:nowrap;flex:none;padding:7px 10px}
dialog{max-height:calc(100vh - 18px);max-height:calc(100dvh - 18px);overflow:auto;overscroll-behavior:contain}
@media(max-width:700px){
  .room{grid-template-rows:3.8rem minmax(0,1fr) 1.85rem}
  .tablemeta{display:grid;grid-template-columns:auto auto;justify-items:end;gap:2px 5px}
  .session{grid-column:1/-1;font-size:.67rem;max-width:34ch;line-height:1.2}
  .roomhead .smallcap{font-size:.72rem}.roundline{gap:.2rem}.roundline #dealerLabel{font-size:.71rem;padding:1px 4px}
  #callStrip{gap:4px;padding:2px 5px}.call-banner{min-width:0;gap:4px}
  #callNotice p{font-size:.79rem}.call-banner strong{display:none}
  #callSummary{font-size:.76rem}#callNotice{max-height:1.35rem}
}
@media(max-width:560px){
  body{--rack-height:clamp(230px,29vh,250px);--rack-height:clamp(230px,29dvh,250px)}
  .tray{--tile:min(8.6vw,38px);grid-template-rows:1.45rem 1.5rem 1.2rem minmax(0,1fr) 2.95rem}
  #hand{max-width:calc(var(--tile)*9 + 35px);row-gap:5px;align-content:safe center}
  .face{height:calc(var(--tile)*1.25)}#hand{--draw-gap:4px;--face-height:calc(var(--tile)*1.25)}
  .trayhead .smallcap{font-size:.7rem}.trayhead h2{font-size:1rem}
  #turnText{font-size:.87rem}#spokenText{font-size:.7rem}
  .actionbar{display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:1.05rem minmax(0,1fr);gap:1px}
  #actions{max-width:100%;justify-self:end;margin:0}#actions button{padding:3px 8px}
  #hint,#discardRule{font-size:.73rem;white-space:nowrap}
  .hint-wrap:has(#discardRule:not([hidden])) #hint{display:none}
}
@media(orientation:landscape) and (max-height:540px){
  body{grid-template-rows:27px minmax(0,1fr)}
  header .brand small{display:none}header .mark{height:22px;width:22px;font-size:16px}
  header button{padding:2px 8px}
  main{grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr) clamp(112px,30dvh,135px);padding:2px 5px;gap:3px}
  .room{grid-template-rows:1.75rem minmax(0,1fr) 1.35rem;gap:1px}
  .roomhead .smallcap{display:none}.roomhead h2{font-size:1rem}
  .roundline #dealerLabel{font-size:.7rem}.roundline{gap:5px}
  .tablemeta{display:flex;flex-direction:row;align-items:center;gap:5px}
  .tablemeta button{font-size:.73rem;padding:2px 5px}
  .tablemeta .session{font-size:.62rem;max-width:42ch;line-height:1.1}
  #callStrip{padding:0 5px}#callNotice p,#callSummary{font-size:.72rem}
  .tray{
    --tile:min(4.35vw,8.65dvh);padding:2px 8px;
    grid-template-columns:minmax(0,1fr) minmax(0,1fr);
    grid-template-rows:1.13rem .97rem minmax(0,1fr) 1.65rem;
    grid-template-areas:"title turn" "groups groups" "hand hand" "actions actions"
  }
  .trayhead{grid-area:title}.turn-ribbon{grid-area:turn;border:0;justify-content:flex-end}
  #ownExtras{grid-area:groups}#hand{grid-area:hand;max-width:100%;align-content:safe center;gap:2px}
  #hand .face{height:calc(var(--tile)*1.22)}#hand{--draw-gap:4px;--face-height:calc(var(--tile)*1.22)}
  .trayhead h2{font-size:.9rem}.trayhead .smallcap,.turn-ribbon strong,#spokenText{font-size:.66rem}
  #turnText,.trayhead #status{font-size:.75rem}
  .actionbar{grid-area:actions;display:flex;gap:4px}#actions{max-width:78%;margin-left:auto}
  #actions button{padding:2px 7px;font-size:.78rem}#hint,#discardRule{font-size:.7rem}
  .hint-wrap:has(#discardRule:not([hidden])) #hint{display:none}
  #ownExtras .mini,#ownExtras .flower{height:.9rem;font-size:.65rem}
  .felt{padding:3px 6px;row-gap:0;grid-template-rows:minmax(0,1.1fr) minmax(0,1fr) minmax(0,1.3fr) minmax(0,1fr) .95rem}
  .wall{width:40px;height:35px}.wall span{font-size:16px}.wall small,.you{font-size:.59rem}
}
#hand .face{overflow:hidden;min-width:0}
@media(max-width:560px) and (orientation:portrait){
  #hand{
    display:grid;grid-template-columns:repeat(9,minmax(0,1fr));
    grid-auto-rows:calc(var(--tile)*1.25);justify-items:center;
    align-content:center;gap:5px 2px;overflow:visible
  }
}
@media(orientation:landscape) and (max-height:540px){
  #hand{flex-wrap:nowrap;overflow:visible}
}
#dealerLabel:enabled{cursor:pointer;background:#344630}
#openingNotice{
  position:absolute;z-index:4;inset:8px auto auto 50%;transform:translateX(-50%);
  width:min(22rem,calc(100% - 20px));max-height:calc(100% - 16px);overflow:auto;
  padding:9px 13px;border:1px solid #bca572;border-radius:9px;
  background:#17392ff5;box-shadow:0 5px 20px #061e17a8
}
#openingNotice[hidden]{display:none}
.dice-head,.dice-row{display:flex;align-items:center;gap:8px}
.dice-head{justify-content:space-between;font-size:.9rem;color:var(--gold);margin-bottom:4px}
#hideDice{padding:1px 7px;font-size:.75rem}
.dice-row{font-size:.85rem;line-height:1.35;border-bottom:1px solid var(--line);padding:2px 0}
.dice-faces{margin-inline-start:auto;letter-spacing:.08em;font:1.3rem/1 system-ui,sans-serif;white-space:nowrap}
.dice-row b{min-width:3.35em;text-align:right}
#openingResult{font-size:.85rem;color:var(--gold);margin:5px 0 0}
@media(orientation:landscape) and (max-height:540px){
  #openingNotice{padding:4px 8px}.dice-row{font-size:.71rem;padding:0}
  .dice-faces{font-size:1rem}.dice-head{margin-bottom:1px}#openingResult{font-size:.7rem;margin-top:2px}
}
.felt.predeal>:is(.seat,.river,.center,.you){visibility:hidden}
.felt.predeal #openingNotice{
  inset:4px auto 4px 50%;width:min(26rem,calc(100% - 18px));height:auto;max-height:none;
  display:flex;flex-direction:column;justify-content:safe center
}
#rollingDice{display:flex;align-items:center;justify-content:space-between;gap:8px;margin:4px 0;color:#f6e9bc}
#rollingDice[hidden]{display:none}
#rollActor{font-weight:650;font-size:.92rem}
#diceFaces{display:inline-flex;align-items:center;gap:4px;padding:3px}
.rolling-face{display:inline-grid;place-items:center;font:1.65rem/1 system-ui,sans-serif;color:#173a30;background:#fff5d7;border-radius:5px;width:1.18em;height:1.18em;box-shadow:0 2px #aa9975}
.rolling-face.tumble{animation:dice-tumble 1s ease-out both;animation-delay:calc(var(--die-index)*35ms)}
@keyframes dice-tumble{
  0%{transform:translateY(-4px) rotate(-150deg) scale(.8)}
  38%{transform:translateY(1px) rotate(70deg)}
  64%{transform:translateY(-3px) rotate(-32deg)}
  84%{transform:translateY(0) rotate(9deg)}
  100%{transform:none}
}
@media(prefers-reduced-motion:reduce){.rolling-face.tumble{animation:none}}
@media(max-height:540px) and (orientation:landscape){
  #rollingDice{margin:0}.rolling-face{font-size:1.15rem}#rollActor{font-size:.72rem}
  .felt.predeal #openingNotice{inset:2px auto 2px 50%;width:min(31rem,90%)}
  .felt.predeal #openingSeats{display:grid;grid-template-columns:1fr 1fr;gap:0 8px}
}

/* Between turns the concealed hand has 3n+1 tiles. Reserve the drawn tile's
   footprint so centering, wrapping and row height stay identical on draw. */
#hand .face.drawn,
#hand:has(> .face:last-child:nth-child(3n+1))::after{margin-inline-start:var(--draw-gap)}
#hand:has(> .face:last-child:nth-child(3n+1))::after{
  content:"";visibility:hidden;pointer-events:none;box-sizing:border-box;
  flex:0 0 var(--tile);width:var(--tile);height:var(--face-height);
}
