/* Phone rooms retain the original scene, projection, anchors and avatar frame. */
.mobile-room-bar,.mobile-room-sheet{display:none}
@media(max-width:900px){
  body.mobile-room-focused #house-view>.view-heading{min-height:44px;margin-bottom:8px;gap:8px}
  body.mobile-room-focused #house-view>.view-heading h1{font-size:22px;margin:0}
  body.mobile-room-focused #house-view>.view-heading button{min-width:44px;min-height:44px}
  body.mobile-room-focused .room-shell{height:calc(var(--mobile-viewport-height,100dvh) - var(--mobile-top-height,56px) - var(--mobile-bottom-height,64px) - 76px);min-height:0;display:grid;grid-template-rows:auto minmax(0,1fr) auto auto;border-radius:18px}
  body.mobile-room-focused .room-topbar{padding:4px 10px;min-height:48px;gap:8px;flex-wrap:nowrap}
  body.mobile-room-focused .room-topbar>div{min-width:0}
  body.mobile-room-focused .room-topbar h2{font-size:14px;max-width:40vw;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  body.mobile-room-focused #edit-house{min-width:44px;min-height:44px;padding:6px 8px;margin-left:auto}
  body.mobile-room-focused #connection{font-size:10px;margin:0;gap:4px}
  body.mobile-room-focused .room-layout{min-height:0;min-width:0;display:flex;align-items:center;justify-content:center;overflow:hidden;background:#eee5d4}
  /* Match width and height at 1000:760. Existing stretched artwork and all full-viewBox layers stay aligned. */
  body.mobile-room-focused .room-stage,body.mobile-room-focused .room-stage[data-theme]{flex:none;width:var(--mobile-stage-width,100%);height:auto;min-height:0;aspect-ratio:1000/760}
  body.mobile-room-focused .spot-button{min-width:44px;min-height:44px;touch-action:manipulation}
  body.mobile-room-focused .spot-marker{opacity:.8}
  body.mobile-room-focused .stage-hint{font-size:9px;padding:4px 6px;left:6px;bottom:5px}
  body.mobile-room-focused .player-card{bottom:8px;right:8px}
  body.mobile-room-focused .card-close{min-height:44px;min-width:44px;top:0;right:0}
  body.mobile-room-focused .player-card h3{padding-right:32px}
  body.mobile-room-focused .chat-form{padding:6px 8px;gap:6px;min-width:0}
  body.mobile-room-focused .chat-form input,.mobile-room-sheet .chat-form input{font-size:16px;min-height:44px}
  body.mobile-room-focused .chat-form button,.mobile-room-sheet .chat-form button{min-height:44px;min-width:54px}
  .mobile-room-bar{display:flex;gap:8px;padding:5px 8px;border-top:1px solid #e9ddcc;background:#fffaf2}
  .mobile-room-bar button{flex:1;min-height:44px;min-width:44px;padding:8px;border:1px solid #deceb7;border-radius:12px;background:#fffdf7;color:#614e40;font-size:13px;font-weight:700;touch-action:manipulation}
  .mobile-room-sheet[open]{display:flex;flex-direction:column;position:fixed;inset:auto 0 0;margin:0 auto;width:min(100%,620px);max-width:100%;max-height:calc(var(--mobile-viewport-height,100dvh) - env(safe-area-inset-top) - 16px);padding:12px 12px calc(12px + env(safe-area-inset-bottom));border:1px solid #deceb7;border-radius:22px 22px 0 0;background:#fffaf2;color:#614e40;overflow:hidden;box-shadow:0 -12px 48px #3b34222b}
  .mobile-room-sheet::backdrop{background:#352c234d}
  .mobile-room-sheet-heading{display:flex;justify-content:space-between;align-items:center;gap:12px;flex:none}
  .mobile-room-sheet-heading h2{font-size:20px;margin:0}
  .mobile-room-sheet button{min-width:44px;min-height:44px;touch-action:manipulation}
  .mobile-room-sheet .chat-form{flex:none;padding:8px 0 0;border-top:1px solid #e9ddcc}
  .mobile-room-log{min-height:60px;max-height:45dvh;overflow:auto;overscroll-behavior:contain;padding:12px 0;flex:1}
  .mobile-room-log p{font-size:14px;line-height:1.5;overflow-wrap:anywhere;margin:0 0 10px}
  .mobile-room-log strong{display:block;font-size:12px;color:#477f68}
  .mobile-room-empty{font-size:13px;color:#816c54;padding:12px 0}
  .mobile-room-action-content{overflow:auto;overscroll-behavior:contain;padding:8px 0;min-height:0}
  .mobile-room-directions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-bottom:12px}
  .mobile-room-spots{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
  .mobile-room-spots button,.mobile-room-directions button{white-space:normal;padding:10px;min-width:0}
  body.mobile-house-editing .room-shell{grid-template-rows:auto minmax(0,.8fr) minmax(0,1fr) auto auto}
  body.mobile-house-editing #house-editor{overflow:auto;overscroll-behavior:contain;min-height:0;padding:0 10px 10px}
  body.mobile-house-editing .house-editor-heading{position:sticky;top:0;z-index:2;padding:6px 0;background:#fffaf2;flex-wrap:nowrap;gap:6px;border-bottom:1px solid #e9ddcc}
  body.mobile-house-editing .house-editor-heading h3{font-size:13px;flex:1;margin:0}
  body.mobile-house-editing .house-editor-actions{width:auto;flex-wrap:nowrap;gap:8px}
  body.mobile-house-editing .house-editor-actions button{padding:8px;min-height:44px;min-width:44px;font-size:12px}
  body.mobile-house-editing .house-inventory{grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
  body.mobile-house-editing .house-inventory-item svg{height:44px}
  body.mobile-house-editing .house-inventory-item span{min-height:24px}
  body.mobile-house-editing .house-selection{gap:6px;flex-wrap:wrap}
  body.mobile-house-editing .house-placement-controls{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
  body.mobile-house-editing .house-placement-controls input,body.mobile-house-editing .house-placement-controls select{width:100%;min-width:0;min-height:44px;font-size:16px}
  body.mobile-house-editing #house-rotate,body.mobile-house-editing #house-place,body.mobile-house-editing #house-store{padding:8px;font-size:12px}
  body.mobile-house-editing #house-rotation{align-self:center;text-align:center}
  body.mobile-house-editing #house-editor button{min-height:44px;min-width:44px}
  @media(max-height:500px) and (min-width:550px){
    body.mobile-room-focused #house-view>.view-heading{display:none}
    body.mobile-room-focused .room-shell{height:calc(var(--mobile-viewport-height,100dvh) - var(--mobile-top-height,56px) - var(--mobile-bottom-height,64px) - 24px);grid-template-columns:minmax(0,1fr) 220px;grid-template-rows:48px minmax(0,1fr) auto}
    body.mobile-room-focused .room-topbar{grid-column:1/-1;grid-row:1}
    body.mobile-room-focused .room-layout{grid-column:1;grid-row:2/4}
    body.mobile-room-focused .mobile-room-bar{grid-column:2;grid-row:2;align-self:end;flex-wrap:wrap}
    body.mobile-room-focused .chat-form{grid-column:2;grid-row:3}
    body.mobile-house-editing .room-shell{grid-template-rows:48px minmax(0,1fr) auto}
    body.mobile-house-editing .room-layout{grid-row:2/4}
    body.mobile-house-editing #house-editor{grid-column:2;grid-row:2;padding:0 8px 8px}
    body.mobile-house-editing .mobile-room-bar{grid-row:3}
    /* Keep the floor and editor usable in short landscape. Chat remains in its native sheet. */
    body.mobile-house-editing .room-shell>.chat-form{display:none}
    body.mobile-house-editing .house-editor-heading h3{display:none}
    body.mobile-house-editing .house-inventory{grid-template-columns:repeat(2,minmax(0,1fr))}
  }
  @media(max-height:350px) and (min-width:550px){
    /* A sticky header would cover the entire tiny editor viewport. Let native scroll reach every control. */
    body.mobile-house-editing .house-editor-heading{position:static}
  }
}

/* Only the native, in-room composer with a measured keyboard enters this state.
   Keep the same room-layout and stage fit; spend the visual viewport on room + one composer. */
@media(max-width:900px){
  body.mobile-room-focused.mobile-room-composing #house-view>.view-heading,
  body.mobile-room-focused.mobile-room-composing #house-view>.progression-panel{display:none}
  body.mobile-room-focused.mobile-room-composing #room-container>.room-shell{
    position:fixed;top:var(--mobile-chat-top);left:var(--mobile-chat-left);
    width:var(--mobile-chat-width);height:var(--mobile-chat-height);max-width:none;
    min-width:0;min-height:0;margin:0;border:0;border-radius:0;box-shadow:none;z-index:40;
    grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr) auto;
  }
  body.mobile-room-focused.mobile-room-composing #room-container>.room-shell>:not(.room-layout):not(.chat-form):not(.chat-announcement){display:none}
  body.mobile-room-focused.mobile-room-composing #room-container>.room-shell>.room-layout{
    grid-column:1;grid-row:1;min-width:0;min-height:0;
  }
  body.mobile-room-focused.mobile-room-composing #room-container>.room-shell>.chat-form{
    grid-column:1;grid-row:2;min-width:0;padding:6px 8px;gap:6px;
  }
  body.mobile-room-focused.mobile-room-composing #room-container>.room-shell>.chat-form input{
    width:0;flex:1 1 0;min-width:0;min-height:44px;font-size:16px;
  }
  body.mobile-room-focused.mobile-room-composing #room-container>.room-shell>.chat-form button{
    flex:0 0 auto;min-width:44px;min-height:44px;padding:0 10px;touch-action:manipulation;
  }
  body.mobile-room-focused.mobile-room-composing #mobile-chat-done{background:#e7edde;color:#385e4c}
}
