Join up the rooms

Jelly, 17 bytes

ỴḲaLḊṖƊ¦”.KƊ€Z$⁺Y

Try it online!

Tricky -1 thanks to user202729.

Explanation:

ỴḲaLḊṖƊ¦”.KƊ€Z$⁺Y Arguments: S
Ỵ                 Split S on newlines
 ḲaLḊṖƊ¦”.KƊ€Z$   Monadic link
 ḲaLḊṖƊ¦”.KƊ€      Map over left argument
 ḲaLḊṖƊ¦”.KƊ        Monadic link
 Ḳ                   Split on spaces
  aLḊṖƊ¦”.           Dyadic link with right argument '.'
  aLḊṖƊ¦              Apply at specific indices
  a                    Logical AND (vectorizes)
   LḊṖƊ                Monadic link
   L                    Length
    Ḋ                   Range [2..n]
     Ṗ                  Remove last element
          K          Join with spaces
             Z     Zip
               ⁺  Previous link
                Y Join with newlines

Perl 5 -p0, 56 bytes

#!/usr/bin/perl -p0
/
/;$n="(.{@+})*";s%#%/ #*\G#+ |(?= )$n\G$n /s?".":$&%eg

Try it online!


APL+WIN, 87 bytes

Prompts for character matrix:

n←(' '=m←⎕)⋄c←(∨⍀n)+⊖∨⍀⊖n⋄r←(∨\n)+⌽∨\⌽n⋄((,c>1)/,m)←'.'⋄((,r>1)/,m)←'.'⋄((,n)/,m)←' '⋄m