/* Phone-only Word Dome layout.
   Do NOT transform/zoom the game: that breaks the 11x11 drag hit targets.
   Scale the real boxes, tiles and rack instead. Desktop/tablet art is unchanged.
   Landscape rule includes short touch-phone viewports without affecting iPads. */
@media (max-width:480px), (max-height:500px) and (max-width:950px) and (any-pointer:coarse) {
 body:not(.wd-gate):has(#game:not([hidden])) {
  overflow-x:hidden!important;
 }
 body:not(.wd-gate):has(#game:not([hidden])) main {
  width:100%!important;max-width:100%!important;
  padding:4px 5px max(14px,env(safe-area-inset-bottom))!important;
  margin:0 auto!important;box-sizing:border-box!important;
  overflow-x:clip!important;
 }
 /* Bring the board high enough to reach on a portrait iPhone. */
 body:not(.wd-gate):has(#game:not([hidden])) .brand.brand-art {
  width:90%!important;height:48px!important;min-height:0!important;
  margin:0 auto 2px!important;padding:0!important;
 }
 body:not(.wd-gate):has(#game:not([hidden])) #gameTopInfo.top-info {
  width:100%!important;max-width:100%!important;
  height:50px!important;min-height:50px!important;max-height:50px!important;
  transform:none!important;display:flex!important;
  align-items:center!important;justify-content:center!important;
  gap:3px!important;margin:0 auto 4px!important;padding:0!important;
 }
 body:not(.wd-gate):has(#game:not([hidden])) #gameTopInfo.top-info > :is(.top-goal,.top-mode,.wd-room-info,.rules-button){
  min-width:0!important;max-width:100%!important;
  height:45px!important;min-height:45px!important;max-height:45px!important;
  padding:2px!important;margin:0!important;box-sizing:border-box!important;
  transform:none!important;flex:1 1 0!important;
 }
 body:not(.wd-gate):has(#game:not([hidden])) #gameTopInfo.top-info > .top-mode{
  flex:1.4 1 0!important;
 }
 body:not(.wd-gate):has(#game:not([hidden])) #gameTopInfo.top-info strong{
  font-size:clamp(12px,3.5vw,16px)!important;line-height:1.1!important;
 }
 body:not(.wd-gate):has(#game:not([hidden])) #gameTopInfo.top-info span{
  font-size:8px!important;letter-spacing:0!important;
 }
 /* Keep the two players side-by-side, but replace the oversized stacked cards
    with compact information; nothing is removed from the DOM. */
 body:not(.wd-gate):has(#game:not([hidden])) #game .game-grid {
  display:grid!important;
  width:100%!important;max-width:100%!important;min-width:0!important;
  grid-template-columns:repeat(2,minmax(0,1fr))!important;
  gap:4px!important;align-items:start!important;justify-content:center!important;
  margin:0!important;padding:0!important;
 }
 body:not(.wd-gate):has(#game:not([hidden])) #game .game-grid > :is(.left-panel,.right-panel) {
  grid-row:1!important;display:flex!important;flex-direction:column!important;
  gap:3px!important;align-items:stretch!important;
  min-width:0!important;width:100%!important;
  padding:0!important;margin:0!important;
  transform:none!important;
 }
 body:not(.wd-gate):has(#game:not([hidden])) #game .game-grid > .left-panel{grid-column:1!important}
 body:not(.wd-gate):has(#game:not([hidden])) #game .game-grid > .right-panel{grid-column:2!important}
 body:not(.wd-gate):has(#game:not([hidden])) #game .game-grid > .center-panel{
  grid-row:2!important;grid-column:1/-1!important;
  width:100%!important;min-width:0!important;max-width:100%!important;
  padding:0!important;margin:0 auto!important;transform:none!important;
 }
 body:not(.wd-gate):has(#game:not([hidden])) #game .game-grid > :is(.left-panel,.right-panel) > * {
  box-sizing:border-box!important;max-width:100%!important;
  width:100%!important;min-width:0!important;
  margin:0!important;
 }
 body:not(.wd-gate):has(#game:not([hidden])) #game :is(#playerCard,#opponentCard) {
  order:1!important;height:94px!important;min-height:0!important;
  max-height:94px!important;overflow:hidden!important;
  padding:3px!important;border-width:2px!important;border-radius:8px!important;
  display:flex!important;flex-direction:column!important;
  justify-content:center!important;align-items:center!important;
  gap:1px!important;
 }
 body:not(.wd-gate):has(#game:not([hidden])) #game :is(#playerCard,#opponentCard) .wd-player-name-banner{
  position:relative!important;inset:auto!important;transform:none!important;
  height:17px!important;min-height:17px!important;width:100%!important;
  padding:0 1px!important;margin:0!important;
  flex:0 0 17px!important;background-size:100% 100%!important;
 }
 body:not(.wd-gate):has(#game:not([hidden])) #game :is(#playerCard,#opponentCard) .wd-player-name-banner small{
  font-size:clamp(10px,2.8vw,12px)!important;
  line-height:16px!important;letter-spacing:0!important;
  text-overflow:ellipsis!important;overflow:hidden!important;
  white-space:nowrap!important;max-width:100%!important;
 }
 body:not(.wd-gate):has(#game:not([hidden])) #game :is(#playerCard,#opponentCard) .wd-avatar-identity{
  position:relative!important;inset:auto!important;bottom:auto!important;
  width:100%!important;min-height:0!important;flex:0 0 43px!important;
  display:flex!important;align-items:center!important;justify-content:center!important;
 }
 body:not(.wd-gate):has(#game:not([hidden])) #game :is(#playerAvatar,#opponentAvatar){
  width:43px!important;height:43px!important;
  min-width:43px!important;min-height:43px!important;
  max-width:43px!important;max-height:43px!important;
  flex:0 0 43px!important;aspect-ratio:1/1!important;
  border-width:2px!important;border-radius:7px!important;
  transform:none!important;margin:0 auto!important;
 }
 body:not(.wd-gate):has(#game:not([hidden])) #game .wd-avatar-account-bar{
  position:relative!important;inset:auto!important;
  display:flex!important;align-items:center!important;justify-content:center!important;
  gap:3px!important;width:100%!important;min-height:0!important;
  height:22px!important;padding:0!important;margin:0!important;
  transform:none!important;
 }
 body:not(.wd-gate):has(#game:not([hidden])) #game .wd-avatar-account-bar :is(.wd-rating,.wd-stat-button,.wd-computer-mode-label){
  font-size:clamp(8px,2.5vw,10px)!important;line-height:1.1!important;
  padding:2px 3px!important;margin:0!important;min-width:0!important;
  max-width:100%!important;height:auto!important;min-height:0!important;
  transform:none!important;top:auto!important;
 }
 body:not(.wd-gate):has(#game:not([hidden])) #game :is(#turnCard,#opponentTurnCard){
  order:2!important;height:40px!important;min-height:40px!important;max-height:40px!important;
  padding:2px!important;border-width:2px!important;
  display:flex!important;align-items:center!important;justify-content:center!important;
  flex-direction:column!important;gap:0!important;overflow:hidden!important;
 }
 body:not(.wd-gate):has(#game:not([hidden])) #game :is(#playerScore,#opponentScore){
  font-size:clamp(16px,4.8vw,20px)!important;line-height:1.1!important;
  margin:0!important;white-space:nowrap!important;
 }
 body:not(.wd-gate):has(#game:not([hidden])) #game :is(#turnCard,#opponentTurnCard) > :is(span,strong:not(#playerScore):not(#opponentScore)){
  font-size:9px!important;line-height:1!important;margin:0!important;
 }
 body:not(.wd-gate):has(#game:not([hidden])) #game :is(#clock,#opponentClock){
  order:3!important;display:flex!important;
  flex-direction:column!important;align-items:center!important;justify-content:center!important;
  gap:1px!important;height:48px!important;min-height:48px!important;max-height:48px!important;
  padding:2px!important;border-width:2px!important;line-height:1!important;
  font-size:clamp(13px,4vw,18px)!important;overflow:hidden!important;
 }
 body:not(.wd-gate):has(#game:not([hidden])) #game .wd-blitz-clock-time{
  font-size:clamp(17px,5vw,23px)!important;line-height:1!important;
 }
 body:not(.wd-gate):has(#game:not([hidden])) #game .wd-blitz-clock-status{
  font-size:9px!important;line-height:1!important;
 }
 body:not(.wd-gate):has(#game:not([hidden])) #game .bonus-card{
  order:4!important;
  height:70px!important;min-height:70px!important;max-height:70px!important;
  overflow:hidden!important;padding:4px!important;
  font-size:10px!important;line-height:1.05!important;border-width:2px!important;
 }
 body:not(.wd-gate):has(#game:not([hidden])) #game .bonus-card > span{
  display:block!important;position:static!important;
  width:100%!important;max-width:100%!important;transform:none!important;
  margin:0 0 3px!important;text-align:center!important;
  font-size:11px!important;line-height:12px!important;letter-spacing:0!important;
 }
 body:not(.wd-gate):has(#game:not([hidden])) #game .bonus-card > div{
  position:static!important;top:auto!important;left:auto!important;right:auto!important;
  width:100%!important;max-width:100%!important;transform:none!important;
  margin:0!important;padding:0!important;
  font-size:9px!important;line-height:11px!important;
 }
 body:not(.wd-gate):has(#game:not([hidden])) #game .bonus-card > div > strong{
  font-size:10px!important;line-height:11px!important;
 }
 /* Use the full available screen width for the actual 11x11 hit targets. */
 body:not(.wd-gate):has(#game:not([hidden])) #game #board{
  display:grid!important;
  width:100%!important;max-width:100%!important;min-width:0!important;
  height:auto!important;aspect-ratio:1/1!important;
  grid-template-columns:repeat(11,minmax(0,1fr))!important;
  grid-template-rows:repeat(11,minmax(0,1fr))!important;
  gap:1px!important;padding:3px!important;
  border-width:3px!important;border-radius:7px!important;
  box-sizing:border-box!important;transform:none!important;
  margin:0 auto!important;
 }
 body:not(.wd-gate):has(#game:not([hidden])) #game #board > .sq{
  min-width:0!important;min-height:0!important;width:100%!important;height:100%!important;
  border-radius:2px!important;
  font-size:clamp(12px,3.7vw,17px)!important;
 }
 body:not(.wd-gate):has(#game:not([hidden])) #game #board > .sq :is(sup,small){
  font-size:8px!important;
 }
 /* Keep rack art and its interactive eight slots proportional together.
    Never scale the board or rack visually (touch hit testing). */
 body:not(.wd-gate):has(#game:not([hidden])) #game .center-panel .rack-panel{
  width:100%!important;max-width:100%!important;min-width:0!important;
  left:auto!important;transform:none!important;
  height:auto!important;min-height:0!important;
  margin:2px auto!important;padding:0!important;
 }
 body:not(.wd-gate):has(#game:not([hidden])) #game .center-panel .rack-panel #rack .tile{
  font-size:clamp(10px,3.3vw,15px)!important;
  min-width:0!important;max-width:100%!important;
  margin:0!important;
 }
 /* Fixed desktop pixel offsets break alignment when the rack is <400px wide. */
 body:not(.wd-gate):has(#game:not([hidden])) #game .center-panel .rack-panel #rack .tile[data-slot-index]{
  left:0!important;
 }
 body:not(.wd-gate):has(#game:not([hidden])) #game .opponent-rack-panel{
  width:100%!important;max-width:100%!important;min-width:0!important;
  margin:0 auto 2px!important;padding:2px!important;
 }
 body:not(.wd-gate):has(#game:not([hidden])) #game #opponentRack{
  width:100%!important;max-width:100%!important;
  justify-content:center!important;gap:2px!important;
 }
 body:not(.wd-gate):has(#game:not([hidden])) #game #opponentRack .opponent-tile{
  width:clamp(16px,4.7vw,23px)!important;
  height:clamp(16px,4.7vw,23px)!important;
  min-width:0!important;min-height:0!important;
  margin:0!important;border-radius:3px!important;
 }
 body:not(.wd-gate):has(#game:not([hidden])) #game .center-panel > .wd-under-rack-controls{
  display:grid!important;grid-template-columns:repeat(4,minmax(0,1fr))!important;
  width:100%!important;max-width:100%!important;min-width:0!important;
  gap:4px!important;margin:4px auto 0!important;padding:0!important;
  position:relative!important;inset:auto!important;transform:none!important;
 }
 body:not(.wd-gate):has(#game:not([hidden])) #game .center-panel > .wd-under-rack-controls button{
  width:100%!important;max-width:100%!important;min-width:0!important;
  height:42px!important;min-height:42px!important;max-height:none!important;
  padding:3px 1px!important;margin:0!important;
  font-size:clamp(10px,2.8vw,12px)!important;line-height:1.05!important;
  gap:1px!important;white-space:normal!important;
  touch-action:manipulation!important;
 }
 body:not(.wd-gate):has(#game:not([hidden])) #game .center-panel > .wd-under-rack-controls button .wd-action-icon{
  font-size:13px!important;
 }
 /* Player bonus details are still present and accessible; the board follows
    immediately after the much smaller two-column score summaries. */
 body:not(.wd-gate):has(#game:not([hidden])) #game .hint{
  display:none!important;
 }
}
/* Phone landscape: use width-based board sizing without scaling hit targets.
   Portrait defaults above remain intact and iPad landscape is not affected. */
@media (max-height:500px) and (max-width:950px) and (any-pointer:coarse) {
 body:not(.wd-gate):has(#game:not([hidden])) #game #board{
  max-width:min(100%,470px)!important;
 }
}


/* Small-screen navigation: constrain the existing lobby and game setup to
   the usable iPhone viewport. Keep its original artwork and live controls. */
@media (max-width:480px){
 body:not(.wd-gate):has(#lobby:not([hidden])):has(#game[hidden]) main,
 body:not(.wd-gate):has(#grandHall:not([hidden])):has(#game[hidden]) main {
  box-sizing:border-box!important;
  width:100%!important;max-width:100%!important;min-width:0!important;
  padding-left:5px!important;padding-right:5px!important;
  overflow-x:clip!important;
 }
 body:not(.wd-gate):has(#lobby:not([hidden])):has(#game[hidden]) #lobby {
  box-sizing:border-box!important;
  width:min(92vw,390px)!important;
  max-width:calc(100vw - 12px)!important;min-width:0!important;
 }
 body.wd-grand-hall-modal #onlineOptions {
  box-sizing:border-box!important;
  width:calc(100vw - 12px)!important;max-width:440px!important;
  max-height:calc(100dvh - 16px)!important;
  overflow-y:auto!important;
  overscroll-behavior:contain;
  -webkit-overflow-scrolling:touch;
 }
}


/* Phone polish: homepage and Dome Duel, 2026-10-23.
   Scoped to narrow touch viewports only; iPad, desktop, Grand Hall, Blitz,
   game tile hit areas and all interactions retain their current styling. */
@media (max-width:480px) and (any-pointer:coarse) {
 /* Home: leave a lane for the fixed Options / Friends buttons rather than
    burying the trophy beneath Safari's address bar and those controls. */
 body:not(.wd-gate):has(#lobby:not([hidden])):has(#game[hidden]) main {
  display:flex!important;
  flex-direction:column!important;
  align-items:center!important;
  overflow-x:clip!important;
  min-height:100dvh!important;
  height:auto!important;
 }
 body:not(.wd-gate):has(#lobby:not([hidden])):has(#game[hidden]) .brand.brand-art {
  display:block!important;
  position:relative!important;
  inset:auto!important;
  left:auto!important;
  top:auto!important;
  width:min(270px,74vw)!important;
  height:84px!important;
  min-height:84px!important;
  max-height:84px!important;
  margin:94px auto 0!important;
  padding:0!important;
  transform:none!important;
  flex:0 0 84px!important;
  z-index:4!important;
 }
 body:not(.wd-gate):has(#lobby:not([hidden])):has(#game[hidden]) .brand.brand-art > img.wd-approved-arch-logo {
  display:block!important;
  width:100%!important;
  height:100%!important;
  object-fit:contain!important;
  transform:scale(.9)!important;
  transform-origin:center bottom!important;
 }
 /* Scale only the decorative frame BACK into the viewport, not the lobby
    or controls (which must keep correct clickable dimensions). */
 body:not(.wd-gate):has(#lobby:not([hidden])):has(#game[hidden]) #lobby {
  position:relative!important;
  inset:auto!important;
  left:auto!important;
  top:auto!important;
  transform:none!important;
  translate:none!important;
  zoom:1!important;
  box-sizing:border-box!important;
  width:calc(100vw - 24px)!important;
  max-width:410px!important;
  min-width:0!important;
  margin:4px auto 22px!important;
  padding:188px 20px 26px!important;
  overflow:visible!important;
 }
 body:not(.wd-gate):has(#lobby:not([hidden])):has(#game[hidden]) #lobby::before {
  transform:scale(.87,1)!important;
  transform-origin:center center!important;
 }
 body:not(.wd-gate):has(#lobby:not([hidden])):has(#game[hidden]) #lobby::after {
  transform:none!important;
  transform-origin:center center!important;
  inset-inline:30px!important;
 }
 /* Royal crest and name/rating each get their own centered row above the
    avatar, instead of sharing the same narrow horizontal position. */
 body:not(.wd-gate):has(#lobby:not([hidden])):has(#game[hidden]) #lobby > #wdRoyalMemberPreview:not([hidden]) {
  position:absolute!important;
  left:50%!important;
  top:58px!important;
  right:auto!important;
  width:160px!important;
  max-width:160px!important;
  height:42px!important;
  margin:0!important;
  padding:0!important;
  transform:translateX(-50%)!important;
  z-index:8!important;
 }
 body:not(.wd-gate):has(#lobby:not([hidden])):has(#game[hidden]) #lobby #wdRoyalMemberPreview img {
  transform:scale(2.75)!important;
  transform-origin:center center!important;
 }
 body:not(.wd-gate):has(#lobby:not([hidden])):has(#game[hidden]) #lobby > .wd-home-identity-row {
  position:absolute!important;
  top:120px!important;
  left:50%!important;
  right:auto!important;
  transform:translateX(-50%)!important;
  width:calc(100% - 60px)!important;
  min-height:0!important;
  height:auto!important;
  margin:0!important;
  padding:0!important;
  display:flex!important;
  flex-direction:column!important;
  align-items:center!important;
  justify-content:center!important;
  gap:0!important;
  z-index:8!important;
 }
 body:not(.wd-gate):has(#lobby:not([hidden])):has(#game[hidden]) #lobby.card .wd-home-identity-row #name {
  box-sizing:border-box!important;
  width:min(168px,65vw)!important;
  min-width:0!important;
  max-width:168px!important;
  height:34px!important;
  padding:0!important;
  margin:0 auto!important;
  font-size:24px!important;
  line-height:34px!important;
  text-align:center!important;
  transform:none!important;
  translate:none!important;
 }
 body:not(.wd-gate):has(#lobby:not([hidden])):has(#game[hidden]) #lobby .wd-home-identity-row #lobbyPlayerRating:not([hidden]) {
  min-width:140px!important;
  max-width:175px!important;
  margin:0 auto!important;
  transform:scale(.85)!important;
  transform-origin:top center!important;
 }
 /* Make the avatar selector comfortably tappable while preserving the
    existing avatar artwork and selection handler. */
 body:not(.wd-gate):has(#lobby:not([hidden])):has(#game[hidden]) #lobby > .avatar-section {
  position:relative!important;
  top:auto!important;
  margin:0 auto 12px!important;
  transform:none!important;
  translate:none!important;
  width:100%!important;
 }
 body:not(.wd-gate):has(#lobby:not([hidden])):has(#game[hidden]) #lobby #chooseAvatar {
  min-height:40px!important;
  padding:9px 12px!important;
  font-size:13px!important;
  white-space:nowrap!important;
  touch-action:manipulation!important;
 }
 /* Stop translating the computer bar upward across the avatar, and enlarge
    the REAL menu hit targets rather than magnifying the baked-in PNG. */
 body:not(.wd-gate):has(#lobby:not([hidden])):has(#game[hidden]) #lobby > .computer-launch-row.wd-home-controls-one-line {
  top:auto!important;
  width:calc(100vw - 34px)!important;
  max-width:410px!important;
  height:68px!important;
  min-height:68px!important;
  margin:6px 0 10px!important;
  translate:-50% 0!important;
  transform:none!important;
 }
 body:not(.wd-gate):has(#lobby:not([hidden])):has(#game[hidden]) #lobby > .computer-launch-row.wd-home-controls-one-line > label {
  height:68px!important;
  min-height:68px!important;
 }
 html.wd-home-dropdowns-ready body:not(.wd-gate):has(#lobby:not([hidden])):has(#game[hidden]) #lobby > .computer-launch-row.wd-home-controls-one-line > label > button.wd-home-select-trigger {
  height:28px!important;
  min-height:28px!important;
  max-height:28px!important;
  bottom:8px!important;
  font-size:clamp(11px,3.1vw,13px)!important;
  padding:1px 9px 1px 2px!important;
 }
 body:not(.wd-gate):has(#lobby:not([hidden])):has(#game[hidden]) #lobby > .computer-launch-row.wd-home-controls-one-line > label > select {
  height:28px!important;
  min-height:28px!important;
  bottom:8px!important;
  font-size:12px!important;
 }
 body:not(.wd-gate):has(#lobby:not([hidden])):has(#game[hidden]) #lobby > #wdGrandEntrance {
  top:auto!important;
  width:min(80vw,340px)!important;
  max-width:100%!important;
  margin:10px auto 0!important;
  transform:none!important;
 }
 /* Duel: increase actual score/bonus text sizes and reserve enough vertical
    room so the values don't clip their ornate panels. No game-board zoom. */
 body:not(.wd-gate):not([data-wd-game-type="blitz"]):has(#game:not([hidden])) #game :is(#playerCard,#opponentCard) {
  height:101px!important;
  max-height:101px!important;
 }
 body:not(.wd-gate):not([data-wd-game-type="blitz"]):has(#game:not([hidden])) #game .wd-avatar-account-bar {
  height:26px!important;
  gap:4px!important;
 }
 body:not(.wd-gate):not([data-wd-game-type="blitz"]):has(#game:not([hidden])) #game .wd-avatar-account-bar :is(.wd-rating,.wd-stat-button,.wd-computer-mode-label) {
  font-size:clamp(10px,2.8vw,12px)!important;
  line-height:1.1!important;
  padding:2px 3px!important;
 }
 body:not(.wd-gate):not([data-wd-game-type="blitz"]):has(#game:not([hidden])) #game :is(#turnCard,#opponentTurnCard) > :is(span,strong:not(#playerScore):not(#opponentScore)) {
  font-size:11px!important;
  line-height:1.15!important;
 }
 body:not(.wd-gate):not([data-wd-game-type="blitz"]):has(#game:not([hidden])) #game .bonus-card {
  height:102px!important;
  min-height:102px!important;
  max-height:102px!important;
  padding:8px 7px!important;
  font-size:12px!important;
  line-height:1.15!important;
 }
 body:not(.wd-gate):not([data-wd-game-type="blitz"]):has(#game:not([hidden])) #game .bonus-card > span {
  font-size:13px!important;
  line-height:16px!important;
  margin-bottom:5px!important;
 }
 body:not(.wd-gate):not([data-wd-game-type="blitz"]):has(#game:not([hidden])) #game .bonus-card > div {
  font-size:11px!important;
  line-height:14px!important;
  min-height:14px!important;
 }
 body:not(.wd-gate):not([data-wd-game-type="blitz"]):has(#game:not([hidden])) #game .bonus-card > div > strong {
  font-size:12px!important;
  line-height:14px!important;
 }
}
