.mobile-room-bar,.mobile-room-tabs,.mobile-room-tools,.mobile-camera-hint{display:none}
@media (max-width:640px), (max-width:960px) and (max-height:500px){
  body.has-mobile-room{overflow:hidden;padding-bottom:0;height:100dvh}
  .has-mobile-room>header,.has-mobile-room>.demo,.has-mobile-room>footer,.has-mobile-room>#safety-dock{display:none!important}
  .has-mobile-room #app{position:fixed;inset:var(--room-offset,0px) 0 auto;z-index:30;display:grid;grid-template-rows:auto minmax(0,1fr) auto;gap:0;width:100%;max-width:none;height:100vh;height:var(--room-height,100dvh);margin:0;padding:env(safe-area-inset-top) 10px 0;background:var(--bg);overflow:hidden}
  .has-mobile-room .mobile-room-bar{display:flex;align-items:center;gap:7px;min-width:0;padding:7px 0}
  .has-mobile-room .mobile-room-identity{flex:1;min-width:0;display:flex;flex-direction:column}
  .has-mobile-room .mobile-room-identity strong{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:14px}
  .has-mobile-room .mobile-room-identity small{font-size:9px;letter-spacing:.08em;color:var(--muted)}
  .has-mobile-room .mobile-room-bar button{flex:none;font-size:13px;min-height:40px;padding:7px 12px}
  .has-mobile-room .mobile-room-bar button:last-child{border-color:var(--danger-border);color:var(--danger-text);background:var(--danger-bg)}
  .has-mobile-room .cinema{display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:auto auto auto minmax(0,1fr);grid-template-areas:'stage' 'layout' 'heading' 'content';gap:0;min-height:0;min-width:0;margin:0;overflow:hidden}
  .has-mobile-room .cinema>section{display:contents}
  .has-mobile-room #main-stage{grid-area:stage;min-height:0;min-width:0;width:100%;height:clamp(115px,var(--room-stage-height,31dvh),420px);margin:0;overflow:hidden;scroll-margin:0}
  .has-mobile-room #main-stage>.demo-player{height:100%;display:flex;flex-direction:column;min-height:0}
  .has-mobile-room #main-stage .screen{aspect-ratio:auto;flex:1;min-height:0;gap:3px;padding:8px}
  .has-mobile-room #main-stage .screen h2{font-size:26px;letter-spacing:6px;margin:0}
  .has-mobile-room #main-stage .screen p{display:none}
  .has-mobile-room #main-stage .screen .pill{font-size:9px;line-height:1.4;padding:2px 6px;max-width:100%;white-space:normal;text-align:center}
  .has-mobile-room #main-stage .screen button{font-size:13px;padding:5px 13px;min-height:34px}
  .has-mobile-room #main-stage .playback{flex:none;height:30px;margin:0;gap:8px;font-size:11px}
  .has-mobile-room #main-stage .playback input{min-width:0;padding:4px 0}
  .has-mobile-room .layout-bar{grid-area:layout;min-height:26px;margin:0;padding:4px 2px;font-size:11px;align-items:center;gap:5px}
  .has-mobile-room .layout-bar button{font-size:11px;padding:3px 7px;min-height:26px}
  .has-mobile-room .participants-heading{grid-area:heading;margin:0;padding:6px 2px;font-size:12px;min-width:0}
  .has-mobile-room .participants-heading>span{display:none}
  .has-mobile-room .participants-heading>.mobile-camera-hint{display:inline;font-size:11px;text-align:right}
  .has-mobile-room .camera-grid.cams{grid-area:content;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));grid-auto-rows:208px;align-content:start;gap:8px;min-height:0;min-width:0;height:100%;max-height:none;overflow-y:auto;overflow-x:hidden;overscroll-behavior-y:contain;touch-action:pan-y pinch-zoom;-webkit-overflow-scrolling:touch;margin:0;padding:2px 2px 10px;scroll-padding:4px;scrollbar-width:thin;scrollbar-color:var(--border-bright) transparent}
  .has-mobile-room .camera-slot,.has-mobile-room .camera-slot>.cam-tile{height:100%;min-height:0}
  .has-mobile-room .cam-top{padding:7px 7px 0;font-size:9px}
  .has-mobile-room .cam-visual{min-height:30px}
  .has-mobile-room .cam-bottom{padding:4px 8px;gap:0}
  .has-mobile-room .cam-bottom b{font-size:13px}
  .has-mobile-room .cam-status{font-size:10px;max-width:100%}
  .has-mobile-room .cam-actions{padding:3px 7px 6px;gap:4px}
  .has-mobile-room .cam-actions button{font-size:12px;min-height:32px;padding:4px 6px}
  .has-mobile-room .participant-controls{padding:0 7px 6px;gap:2px}
  .has-mobile-room .participant-controls label{margin:2px 0;font-size:11px}
  .has-mobile-room .participant-controls button{font-size:11px;padding:4px;min-height:28px}
  .has-mobile-room #main-stage>.cam-tile{aspect-ratio:auto;width:100%;height:100%;min-height:0;border-radius:12px}
  .has-mobile-room #main-stage>.cam-tile .cam-top{padding:5px 10px 0;font-size:10px}
  .has-mobile-room #main-stage>.cam-tile .cam-visual{min-height:0}
  .has-mobile-room #main-stage>.cam-tile .avatar{height:48px;width:48px;font-size:24px}
  .has-mobile-room #main-stage>.cam-tile .cam-bottom{padding:3px 10px;flex-direction:row;align-items:center}
  .has-mobile-room #main-stage>.cam-tile .cam-bottom b{font-size:16px}
  .has-mobile-room #main-stage>.cam-tile .cam-actions{padding:3px 10px 6px;flex-direction:row}
  .has-mobile-room #main-stage>.cam-tile .cam-actions button{flex:1;font-size:12px;min-height:30px;padding:4px}
  .has-mobile-room #main-stage>.cam-tile .participant-controls{display:flex;flex-direction:row;align-items:center;gap:8px;padding:0 10px 5px}
  .has-mobile-room #main-stage>.cam-tile .participant-controls label{flex:1;min-width:0}
  .has-mobile-room #main-stage>.cam-tile .participant-controls input{min-width:0;width:100%;max-width:100px}
  .has-mobile-room .cinema>.chat{grid-area:content;display:flex;flex-direction:column;min-height:0;height:100%;padding:10px;margin:0;border-radius:12px;overflow:hidden}
  .has-mobile-room .chat h3{font-size:17px;margin:0 0 4px}
  .has-mobile-room .chat>p{font-size:11px;margin:4px 0}
  .has-mobile-room .chat .messages{flex:1;min-height:0;max-height:none;overflow-y:auto;overscroll-behavior:contain;margin:5px 0}
  .has-mobile-room .chat #chat-form{flex:none;display:flex;gap:6px}
  .has-mobile-room .chat #chat-form input{min-width:0;font-size:16px;padding:8px}
  .has-mobile-room .chat #chat-form button{font-size:13px;padding:8px 12px}
  .has-mobile-room .chat .queue-peek{display:none}
  .has-mobile-room .chat .reactions{margin-top:7px}
  .has-mobile-room .mobile-room-tools{grid-area:content;display:block;min-height:0;height:100%;overflow-y:auto;overscroll-behavior:contain;padding:8px 2px 14px}
  .has-mobile-room .mobile-room-tools .room-top{margin:0 0 14px;gap:8px}
  .has-mobile-room .mobile-room-tools .room-top h2{font-size:22px}
  .has-mobile-room .mobile-room-tools .simulation-lab{padding:14px;margin:0 0 14px}
  .has-mobile-room .mobile-room-tools .toolbar{display:flex;flex-wrap:wrap;gap:8px}
  .has-mobile-room .mobile-room-tabs{display:flex;gap:6px;padding:8px 0 max(8px,env(safe-area-inset-bottom));border-top:1px solid var(--border)}
  .has-mobile-room .mobile-room-tabs button{flex:1;min-width:0;font-size:14px;min-height:42px;padding:7px}
  .has-mobile-room .mobile-room-tabs button[aria-selected=true]{border-color:var(--accent);background:var(--glass-raised);box-shadow:inset 0 0 0 1px var(--border-bright)}
  .has-mobile-room .cinema:not([data-mobile-panel=cameras])>.participants-heading,.has-mobile-room .cinema:not([data-mobile-panel=cameras]) .participants-heading,.has-mobile-room .cinema:not([data-mobile-panel=cameras]) .camera-grid{display:none}
  .has-mobile-room .cinema:not([data-mobile-panel=chat])>.chat{display:none}
  .has-mobile-room .cinema:not([data-mobile-panel=tools])>.mobile-room-tools{display:none}
  .has-mobile-room .cinema:not([data-mobile-panel=cameras]){grid-template-rows:auto auto 0 minmax(0,1fr)}
}
@media (max-width:640px), (max-width:960px) and (max-height:500px){
  .has-mobile-room .mobile-pilot-room .camera-grid.cams{grid-auto-rows:240px}
  .has-mobile-room .mobile-pilot-room .cam-actions{flex-direction:row}
}

@media (max-width:960px) and (max-height:500px){
  .has-mobile-room .chat>p{display:none}
  .has-mobile-room .chat h3{font-size:14px;line-height:1.3;margin:0 0 3px}
  .has-mobile-room .chat .messages{margin:2px 0;min-height:0}
  .has-mobile-room #main-stage>.cam-tile .cam-visual{position:absolute;inset:0;min-height:0}
  .has-mobile-room #main-stage>.cam-tile .cam-top{display:none}
  .has-mobile-room #main-stage>.cam-tile .cam-bottom{position:absolute;z-index:2;top:3px;left:0;max-width:55%;padding:3px 8px;background:var(--glass-surface);border-radius:8px;flex-direction:column;align-items:start}
  .has-mobile-room #main-stage>.cam-tile .cam-bottom b{font-size:13px}
  .has-mobile-room #main-stage>.cam-tile .cam-status{font-size:9px}
  .has-mobile-room #main-stage>.cam-tile .cam-actions{position:absolute;z-index:2;bottom:0;left:0;right:0;padding:4px 8px}
  .has-mobile-room #main-stage>.cam-tile .participant-controls{position:absolute;z-index:2;right:3px;top:3px;max-width:44%;background:var(--glass-surface);border-radius:8px;padding:3px;gap:4px;border:0}
  .has-mobile-room #main-stage>.cam-tile .participant-controls label{font-size:9px;gap:4px}
  .has-mobile-room #main-stage>.cam-tile .participant-controls input{max-width:75px}
  .has-mobile-room #main-stage>.cam-tile .participant-controls button{font-size:10px}
}
@media (max-width:960px) and (max-height:500px){
  .has-mobile-room #main-stage .screen{padding:4px;gap:2px}
  .has-mobile-room #main-stage .screen h2{font-size:20px;line-height:1.2;letter-spacing:4px}
  .has-mobile-room #main-stage .screen .pill{font-size:8px;line-height:1.2;padding:1px 4px}
  .has-mobile-room #main-stage .screen button{min-height:26px;font-size:12px;line-height:1.4;padding:2px 8px}
}

@media (max-width:640px), (max-width:960px) and (max-height:500px){
  .has-mobile-room #toast{z-index:65;bottom:calc(70px + env(safe-area-inset-bottom));width:max-content;max-width:calc(100% - 28px);padding:10px 14px;font-size:13px;line-height:1.5;overflow-wrap:anywhere;pointer-events:none}
  .has-mobile-room #layout-summary{min-width:0;overflow-wrap:anywhere;line-height:1.4}
  .has-mobile-room .layout-bar>button{flex:none}
}

@media (max-width:400px){.hero h1{font-size:clamp(34px,10vw,40px);line-height:1.1}.hero p{font-size:16px}}
/* Long user-entered names must not push nearby controls off the screen. */
header #account{min-width:0;max-width:240px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.room-top>div:first-child{min-width:0}.room-top h2,dialog h2,.message,.card h3{overflow-wrap:anywhere}
#modal-body>h2:first-child{padding-right:26px}
@media(max-width:720px){header #account{max-width:min(190px,50vw)}}
