/* Four private rooms and a full-width Breakfast group chat; original game untouched. */
#castle-rooms[hidden],#castle-rooms [hidden]{display:none!important}
#castle-rooms{grid-column:2;grid-row:2;min-width:0;min-height:0;overflow-y:auto;overflow-x:hidden;scrollbar-color:#a78553 #120e0e;z-index:2;padding:18px clamp(14px,3.5vw,38px) 28px;background:linear-gradient(#0c0b0ad9,#160e0cd9),url('/assets/gallery-wall-v3.webp') center/cover}
body.castle-game #app.castle-rooms-view[data-host="false"][data-screen="home"]{grid-template-rows:76px minmax(0,1fr)!important}
body.castle-game #app.castle-rooms-view[data-host="true"][data-screen="chat"]{grid-template-rows:76px minmax(0,1fr)!important}
body.castle-game #app.castle-rooms-view>.chat,body.castle-game #app.castle-rooms-view>.side{display:none!important}
/* Explicitly override old host chat/side-panel rules: social rooms own this screen. */
body.castle-game #app.castle-rooms-view[data-screen="chat"][data-host="true"]>.chat,
body.castle-game #app.castle-rooms-view[data-screen="chat"][data-host="true"]>.side{display:none!important}
body.castle-game #app.castle-rooms-view #castle-rooms{display:block}
/* A temporary Mim bulletin occupies space only while a player is viewing it.
   Once its 120 active seconds have elapsed it fades, disappears, and the
   flex/grid room entrances reclaim their full height automatically. */
#castle-rooms .castle-room-announcements{
 display:flex;flex:none;flex-direction:column;gap:6px;
 box-sizing:border-box;max-height:min(27dvh,220px);overflow-y:auto;
 padding:12px 15px;margin:0 0 12px;
 border:1px solid #bc985e;border-radius:3px;
 background:linear-gradient(105deg,#43241fef,#2b1b19f2);
 box-shadow:0 5px 16px #0005;
 opacity:1;transform:translateY(0);
 transition:opacity .65s ease,transform .65s ease;
}
#castle-rooms .castle-room-announcements.is-fading{opacity:0;transform:translateY(-9px);pointer-events:none}
#castle-rooms .castle-room-announcements h3{color:#f6d9a0;font:20px/1.2 var(--app-font);margin:0}
#castle-rooms .castle-room-announce{color:#f3d8b8;font-size:13px;line-height:1.45;margin:0;padding:5px 0;overflow-wrap:anywhere}
#castle-rooms .castle-room-announce+.castle-room-announce{border-top:1px solid #80654b62}
@media(max-width:760px){#castle-rooms .castle-room-announcements{max-height:25dvh;padding:9px 12px;margin-bottom:7px}#castle-rooms .castle-room-announcements h3{font-size:17px}}
@media(prefers-reduced-motion:reduce){#castle-rooms .castle-room-announcements{transition:none}}
/* A temporary bulletin also reflows an open room conversation, not just the
   five-door lobby. Preserve message/composer space when the banner appears. */
#castle-rooms:has(.castle-room-inside:not([hidden])){display:flex;flex-direction:column;overflow:hidden}
#castle-rooms:has(.castle-room-inside:not([hidden])) .castle-room-inside{flex:1 1 0;min-height:0;height:auto;overflow:hidden}
#castle-rooms:has(.castle-room-inside:not([hidden])) .castle-room-messages{min-height:0;max-height:none}
#castle-rooms .castle-rooms-intro{text-align:center;margin:6px auto 24px;max-width:710px}
#castle-rooms .castle-rooms-intro h2{font:clamp(28px,4vw,46px) var(--app-font);color:#f8dba1;margin:6px 0 11px;text-shadow:0 2px 10px #000}
#castle-rooms .castle-rooms-intro p{color:#dfcdb2;font-size:13px;line-height:1.65;margin:0}
#castle-rooms .castle-room-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:15px;max-width:1020px;margin:auto}
#castle-rooms .castle-room-door{position:relative;min-height:200px;overflow:hidden;padding:0;text-align:left;border:2px solid #ab824c;background:#1a1110;border-radius:6px;isolation:isolate;box-shadow:0 12px 35px #000a}
#castle-rooms .castle-room-door img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;object-position:center;filter:brightness(.82) saturate(.87)}
#castle-rooms .castle-room-door:before{content:"";position:absolute;inset:0;background:linear-gradient(0deg,#150b0bef 5%,#170e0d90 39%,transparent 90%);z-index:1}
#castle-rooms .castle-room-door:hover:not(:disabled){border-color:#f5ca7b;transform:translateY(-2px)}
#castle-rooms .castle-room-door-info{position:absolute;z-index:2;inset:auto 0 0;padding:15px 18px;display:flex;flex-direction:column;gap:3px}
#castle-rooms .castle-room-door-info strong{font:clamp(20px,2.4vw,28px) var(--app-font);color:#ffdfaa;text-shadow:0 3px 7px #000}
#castle-rooms .castle-room-door-info small{color:#e5d7c7;font-size:12px}
#castle-rooms .castle-room-occupancy{align-self:flex-start;margin-top:7px;border:1px solid #b89354;border-radius:20px;background:#241914e0;padding:5px 10px;color:#f3d6a0;font-size:12px}
#castle-rooms .castle-room-host-panel{max-width:1020px;margin:0 auto 18px}
#castle-rooms .castle-rooms-admin{padding:16px 19px;border:1px solid #bb945c;background:linear-gradient(95deg,#301b22,#191014);border-radius:5px}
#castle-rooms .castle-room-host-top{display:flex;align-items:center;justify-content:space-between;gap:12px}
#castle-rooms .castle-room-host-top>div{display:flex;flex-direction:column;gap:5px}
#castle-rooms .castle-room-host-state,#castle-room-host-state{font:21px var(--app-font);color:#f4d39e}
#castle-room-host-toggle{padding:12px 19px;min-height:44px}
#castle-rooms #castle-room-bedtime-form{display:flex;gap:8px;align-items:end;flex-wrap:wrap;border-top:1px solid #98725080;padding-top:12px;margin-top:14px}
#castle-rooms #castle-room-bedtime-form label{color:#e9d2ae;font-size:12px}
#castle-room-bedtime{width:125px;min-height:44px;padding:8px;font-size:15px}
#castle-room-bedtime-form button{min-height:44px;padding:9px 11px}
#castle-room-host-message{min-height:0;font-size:12px;color:#eeb5a8}
#castle-dashboard>.castle-rooms-admin{margin-top:15px;border:1px solid #aa8b57;padding:14px 17px;background:#261918}
#castle-dashboard>.castle-rooms-admin .castle-room-host-top{display:flex;justify-content:space-between;align-items:center;gap:8px}
#castle-dashboard>.castle-rooms-admin #castle-room-bedtime-form{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin-top:9px}
#castle-rooms .castle-rooms-sleep{text-align:center;max-width:650px;margin:7vh auto;padding:46px 25px;border:2px solid #b7955f;background:linear-gradient(#351e26e8,#160e13f2),url('/assets/tower-v4.webp') center/cover}
#castle-rooms .castle-rooms-sleep h2{color:#f2d09d;font:clamp(29px,4vw,45px) var(--app-font)}
#castle-rooms .castle-rooms-sleep p{font:15px/1.6 var(--app-font);color:#efdbbf}
#castle-rooms .castle-rooms-sleep-icon{font-size:42px;color:#f3c984}
#castle-rooms .castle-room-inside{display:flex;flex-direction:column;min-height:100%;max-width:1060px;margin:auto;border:1px solid #ad8d60;background:#15100fe9;box-shadow:0 15px 45px #0009}
#castle-rooms .castle-room-inside-head{display:flex;align-items:center;justify-content:space-between;gap:15px;padding:15px 20px;background:linear-gradient(90deg,#2d181b,#191213)}
#castle-rooms .castle-room-inside-head h2{color:#f4d7a2;font:clamp(23px,2.9vw,33px) var(--app-font);margin:3px 0}
#castle-rooms .castle-room-inside-head #castle-room-exit{flex:none;padding:10px 13px}
#castle-rooms #castle-room-count{color:#e9cc99;white-space:nowrap;font-size:12px}
#castle-rooms .castle-room-people{display:flex;gap:13px;align-items:center;min-height:98px;padding:12px 20px;overflow-x:auto;border-block:1px solid #98744c77;background:#1f1713}
#castle-rooms .castle-room-people-label{font-size:10px;letter-spacing:.1em;color:#d4b78a;max-width:90px;flex:none}
#castle-rooms .castle-room-person{display:flex;flex-direction:column;align-items:center;gap:4px;flex:0 0 60px;font-size:12px;color:#f5dcb6}
#castle-rooms .castle-room-person img{width:49px;height:53px;object-fit:cover;object-position:50% 22%;border-radius:4px;border:1px solid #d0ab6d}
#castle-rooms .castle-room-spectator{margin:11px 15px 0;padding:10px 14px;border:1px solid #9a6a82;background:#2d1825;color:#f0d5ec;font-size:12px;text-align:center}
#castle-rooms .castle-room-messages{display:flex;flex-direction:column;flex:1;min-height:240px;max-height:min(54dvh,700px);overflow-y:auto;gap:15px;padding:24px clamp(14px,3vw,35px);scrollbar-width:thin}
#castle-rooms .castle-room-message{max-width:min(89%,570px);background:#2a201ab8;border:1px solid #7c5945;border-radius:8px;padding:11px 14px}
#castle-rooms .castle-room-message strong{color:#efce8e;font-size:13px}
#castle-rooms .castle-room-message p{font-size:14px;color:#f6e7d4;line-height:1.5;margin:5px 0 0;overflow-wrap:anywhere}
#castle-rooms .castle-room-event{align-self:center;color:#d9c39f;font:italic 13px var(--app-font);text-align:center;padding:7px 20px;border-block:1px solid #a6804b53}
#castle-rooms .castle-room-compose{display:flex;gap:9px;padding:13px 19px;background:#211614;border-top:1px solid #83603b}
#castle-rooms .castle-room-compose input{flex:1;min-width:0;font-size:16px;min-height:45px;padding:11px}
#castle-rooms .castle-room-compose button{min-height:45px;padding:10px 19px}
#castle-rooms #castle-room-notice{font-size:12px;color:#f1bdab;padding:0 17px;margin:0}
@media(max-width:760px){
 body.castle-game #app.castle-rooms-view[data-screen="home"],body.castle-game #app.castle-rooms-view[data-host="true"][data-screen="chat"]{grid-template-columns:minmax(0,1fr)!important;grid-template-rows:calc(70px + env(safe-area-inset-top)) minmax(0,1fr) calc(70px + env(safe-area-inset-bottom))!important}
 body.castle-game #app.castle-rooms-view #castle-rooms{grid-column:1;grid-row:2;padding:11px 10px 20px}
 body.castle-game #app.castle-rooms-view>#castle-nav{grid-row:3}
 body.castle-game #app.castle-rooms-view #castle-view-heading{grid-column:1;grid-row:1}
 #castle-rooms .castle-room-grid{gap:9px}
 #castle-rooms .castle-room-door{min-height:165px}
 #castle-rooms .castle-room-door-info{padding:10px}
 #castle-rooms .castle-room-door-info strong{font-size:21px}
 #castle-rooms .castle-room-door-info small{font-size:10px}
 #castle-rooms .castle-room-occupancy{font-size:11px;margin-top:3px}
 #castle-rooms .castle-rooms-intro{margin:5px auto 13px}
 #castle-rooms .castle-rooms-intro h2{font-size:30px}
 #castle-rooms .castle-rooms-intro p{font-size:11px}
 #castle-rooms .castle-room-inside-head{padding:10px;gap:7px}
 #castle-rooms .castle-room-inside-head h2{font-size:23px}
 #castle-rooms .castle-room-inside-head #castle-room-exit{padding:8px;font-size:12px;min-width:78px}
 #castle-rooms .castle-room-people{padding:8px 11px;gap:8px;min-height:78px}
 #castle-rooms .castle-room-people-label{font-size:9px;max-width:67px}
 #castle-rooms .castle-room-person{flex-basis:47px;font-size:10px}
 #castle-rooms .castle-room-person img{width:43px;height:47px}
 #castle-rooms .castle-room-messages{min-height:170px;max-height:none;flex:1;padding:15px 12px;gap:10px}
 #castle-rooms .castle-room-message{max-width:96%;padding:9px 11px}
 #castle-rooms .castle-room-compose{padding:8px;gap:6px}
 #castle-rooms .castle-room-compose button{padding:10px}
 #castle-rooms .castle-rooms-admin{padding:12px}
 #castle-rooms #castle-room-bedtime-form{gap:7px}
 #castle-rooms .castle-room-host-top{flex-wrap:wrap}
 #castle-rooms .castle-room-host-top button{width:100%}
 #castle-rooms .castle-rooms-sleep{margin:5vh 5px;padding:26px 15px}
}
@media(max-width:350px){#castle-rooms .castle-room-door{min-height:146px}#castle-rooms .castle-room-door-info strong{font-size:18px}}


/* Keep conversations anchored to the visible mobile viewport when typing. */
@media(max-width:760px){
 html:has(body.castle-game){height:100%;overflow:hidden;overscroll-behavior:none}
 body.castle-game{position:fixed;inset:0;width:100%;height:100%;overflow:hidden;overscroll-behavior:none}
 body.castle-game .shell{
  position:fixed;top:var(--castle-top,0px);left:0;right:0;bottom:auto;
  width:100%;height:var(--castle-height,100dvh);min-height:0;
  max-height:var(--castle-height,100dvh);overflow:hidden;
 }
 body.castle-game #app{min-height:0;overflow:hidden}
 body.castle-game #app.castle-rooms-view #castle-rooms{min-height:0;height:100%;overflow-y:auto;overscroll-behavior:contain}
 body.castle-game #app.castle-rooms-view #castle-rooms:has(.castle-room-inside:not([hidden])){
  overflow:hidden;display:flex;flex-direction:column;padding:6px 7px;
 }
 #castle-rooms .castle-room-inside{
  flex:1;min-height:0;height:100%;max-height:100%;overflow:hidden;
 }
 #castle-rooms .castle-room-messages{
  flex:1 1 0;min-height:0;max-height:none;overflow-y:auto;overscroll-behavior:contain;
 }
 #castle-rooms .castle-room-compose{flex:none}
 body.castle-game.castle-keyboard #app{grid-template-rows:minmax(0,1fr)!important}
 body.castle-game.castle-keyboard #app #castle-view-heading,
 body.castle-game.castle-keyboard #app #castle-nav{display:none!important}
 body.castle-game.castle-keyboard #app>.chat,
 body.castle-game.castle-keyboard #app>.side,
 body.castle-game.castle-keyboard #app>#castle-rooms{
  grid-column:1!important;grid-row:1!important;min-height:0;
 }
 body.castle-game.castle-keyboard #app>.side{
  overflow-y:auto;overscroll-behavior:contain;
 }
 body.castle-game.castle-keyboard #app>.chat .composer{
  flex:none;padding:8px 10px max(8px,env(safe-area-inset-bottom));
 }
 body.castle-game.castle-keyboard #app #castle-rooms .castle-room-people{
  min-height:0;padding-block:5px;
 }
 body.castle-game.castle-keyboard #app #castle-rooms .castle-room-inside-head{
  padding-block:5px;
 }
 body.castle-game.castle-keyboard #app #castle-rooms .castle-room-compose{
  padding:6px;
 }
 body:not(.castle-game) .shell{justify-content:flex-start;padding-top:clamp(28px,7vh,70px)}
}

/* The Castle room selector fits the available screen rather than scrolling. */
body.castle-game #app.castle-rooms-view #castle-rooms.castle-rooms-lobby{
 display:flex;flex-direction:column;min-height:0;height:100%;overflow:hidden;
 padding-bottom:clamp(7px,1.3vh,15px);
}
#castle-rooms.castle-rooms-lobby .castle-rooms-intro{
 flex:none;margin:3px auto clamp(7px,1.4vh,15px);
}
#castle-rooms.castle-rooms-lobby .castle-room-host-panel,
#castle-rooms.castle-rooms-lobby .castle-room-announcements{flex:none}
#castle-rooms.castle-rooms-lobby .castle-room-grid{
 flex:1 1 0;width:100%;min-height:0;margin:0 auto;
 grid-template-columns:repeat(2,minmax(0,1fr));
 grid-template-rows:repeat(2,minmax(0,1fr)) minmax(0,1.12fr);
 gap:clamp(5px,1.2vh,14px);
}
#castle-rooms.castle-rooms-lobby .castle-room-door{
 min-width:0;min-height:0;height:100%;width:100%;
}
#castle-rooms .castle-room-door.castle-room-breakfast{grid-column:1/-1}
#castle-rooms .castle-room-door.castle-room-breakfast img{object-position:center 48%}
#castle-rooms .castle-room-door.castle-room-breakfast:before{
 background:linear-gradient(0deg,#100a09f7 0%,#24130d9c 48%,#4c271426 100%);
}
#castle-rooms .castle-room-door.castle-room-breakfast .castle-room-door-info{
 inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;
}
#castle-rooms .castle-room-door.castle-room-breakfast .castle-room-door-info strong{
 font-size:clamp(24px,3.5vw,40px);letter-spacing:.04em;
}
#castle-rooms .castle-room-door.castle-room-breakfast .castle-room-occupancy{align-self:center}
@media(max-width:760px){
 body.castle-game #app.castle-rooms-view #castle-rooms.castle-rooms-lobby{
  padding:clamp(5px,1vh,10px) 9px clamp(5px,1vh,10px);
 }
 #castle-rooms.castle-rooms-lobby .castle-rooms-intro{margin:0 auto 7px}
 #castle-rooms.castle-rooms-lobby .castle-rooms-intro h2{font-size:clamp(22px,4vh,30px);margin:2px 0 4px}
 #castle-rooms.castle-rooms-lobby .castle-rooms-intro p{font-size:clamp(10px,1.4vh,12px);line-height:1.35}
 #castle-rooms.castle-rooms-lobby .castle-room-grid{gap:clamp(5px,1vh,9px)}
 #castle-rooms.castle-rooms-lobby .castle-room-door-info{padding:clamp(5px,1vh,10px)}
 #castle-rooms.castle-rooms-lobby .castle-room-door-info strong{font-size:clamp(15px,2.7vh,21px);line-height:1.05}
 #castle-rooms.castle-rooms-lobby .castle-room-door-info small{font-size:10px;line-height:1.2}
 #castle-rooms.castle-rooms-lobby .castle-room-occupancy{padding:2px 8px;font-size:10px;margin-top:2px}
 #castle-rooms .castle-room-door.castle-room-breakfast .castle-room-door-info strong{font-size:clamp(22px,3.6vh,33px)}
 body.castle-game.castle-keyboard #app #castle-rooms .castle-room-inside-head,
 body.castle-game.castle-keyboard #app #castle-rooms .castle-room-people,
 body.castle-game.castle-keyboard #app #castle-rooms .castle-room-spectator{flex:none}
 body.castle-game.castle-keyboard #app #castle-rooms .castle-room-people{max-height:66px}
 body.castle-game.castle-keyboard #app #castle-rooms .castle-room-messages{flex:1 1 0;min-height:0;overflow-y:auto}
 body.castle-game.castle-keyboard #app #castle-rooms .castle-room-compose{flex:none}
}
@media(max-width:760px) and (max-height:650px){
 #castle-rooms.castle-rooms-lobby .castle-rooms-intro{margin-bottom:5px}
 #castle-rooms.castle-rooms-lobby .castle-rooms-intro h2{font-size:22px}
 #castle-rooms.castle-rooms-lobby .castle-room-door-info small{display:none}
 #castle-rooms.castle-rooms-lobby .castle-room-door-info strong{font-size:16px}
 #castle-rooms .castle-room-door.castle-room-breakfast .castle-room-door-info strong{font-size:23px}
}

/* Matched room artwork displayed beneath chat text. */
#castle-rooms .castle-room-messages{
 background-color:#100d0d;
 background-image:linear-gradient(180deg,rgba(14,9,10,.80),rgba(14,9,10,.86)),var(--castle-room-landscape);
 background-position:center;
 background-repeat:no-repeat;
 background-size:cover;
}
@media(max-width:760px){
 #castle-rooms .castle-room-messages{
  background-image:linear-gradient(180deg,rgba(14,9,10,.80),rgba(14,9,10,.86)),var(--castle-room-portrait);
 }
}

/* Time-controlled room access and Mim's UK timetable. */
#castle-rooms .castle-room-door.castle-room-locked{opacity:.64;cursor:not-allowed;filter:grayscale(.37)}
#castle-rooms .castle-room-door.castle-room-locked:hover{transform:none;border-color:#ab824c}
#castle-rooms .castle-room-door.castle-room-locked .castle-room-occupancy{border-color:#9c7260;background:#28191ad9;color:#f1c8a8}
#castle-rooms .castle-breakfast-warning{position:relative;flex:none;z-index:1;background:linear-gradient(95deg,#292013,#402615);border-block:1px solid #bc975f;padding:12px 18px;color:#f5dbab;font:15px/1.45 var(--app-font);text-align:center}
#castle-rooms .castle-breakfast-warning.castle-breakfast-countdown{border-color:#ebc276;background:linear-gradient(100deg,#503017,#2c1e1b);box-shadow:inset 0 0 20px #d3a25315}
#castle-room-bedtime-form.castle-room-schedule{display:flex;flex-direction:column;gap:8px;align-items:stretch}
.castle-rooms-admin .castle-schedule-row{display:grid;grid-template-columns:minmax(130px,1fr) 115px minmax(136px,auto);gap:8px;align-items:center}
.castle-rooms-admin .castle-schedule-row label{font-size:12px;color:#ead2ae;margin:0}
.castle-rooms-admin .castle-schedule-row input{width:100%;min-width:0;min-height:44px;margin:0;padding:7px 9px;color:#f7e0bd;background:#170f13;border:1px solid #ad8c5d}
.castle-rooms-admin .castle-schedule-row button{min-height:44px;white-space:normal}
.castle-rooms-admin .castle-schedule-save{align-self:flex-start;min-height:44px}
@media(max-width:560px){
 .castle-rooms-admin .castle-schedule-row{grid-template-columns:minmax(0,1fr) 120px}
 .castle-rooms-admin .castle-schedule-row label{grid-column:1}
 .castle-rooms-admin .castle-schedule-row input{grid-column:2;grid-row:1}
 .castle-rooms-admin .castle-schedule-row button{grid-column:1/-1;min-height:40px}
 #castle-rooms .castle-breakfast-warning{padding:9px;font-size:13px}
}

/* During the 10:30–11:30 crossover Breakfast has the same visual weight as other rooms. */
#castle-rooms.castle-rooms-lobby .castle-room-door.castle-room-breakfast-crossover{
 grid-column:1/-1;justify-self:center;width:calc(50% - clamp(5px,1.2vh,14px)/2);
}
#castle-rooms .castle-room-breakfast-crossover .castle-room-door-info{
 inset:auto 0 0;display:flex;align-items:stretch;justify-content:flex-start;text-align:left;
}
#castle-rooms .castle-room-breakfast-crossover .castle-room-occupancy{align-self:flex-start}
@media(max-width:760px){
 #castle-rooms.castle-rooms-lobby .castle-room-door.castle-room-breakfast-crossover{width:calc(50% - clamp(5px,1vh,9px)/2)}
}

/* Mim's live room controls are on Control Centre and use the same real rooms. */
.castle-rooms-home[hidden]{display:none!important}
.castle-rooms-home{
 border:1px solid #81714f;background:#151b16;padding:12px;
 box-sizing:border-box;max-width:680px;
}
.castle-rooms-home-heading{display:flex;align-items:baseline;justify-content:space-between;gap:9px;margin-bottom:9px}
.castle-rooms-home-heading h2{margin:0;color:#eedbb7;font:20px/1.2 var(--app-font)}
.castle-rooms-home-heading p{margin:0;color:#c7bda9;font-size:11px}
.castle-rooms-home-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:9px}
.castle-rooms-home-grid .castle-room-home-door{
 position:relative;overflow:hidden;box-sizing:border-box;min-width:0;min-height:104px;
 border:1px solid #a18b60;border-radius:2px;background:#211713;
 cursor:pointer;text-align:left;padding:0;isolation:isolate;
}
.castle-room-home-door>img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;filter:brightness(.67)}
.castle-room-home-door:before{
 content:"";position:absolute;inset:0;z-index:1;
 background:linear-gradient(0deg,#0e0d0bf5,transparent 85%);
}
.castle-room-home-door .castle-room-door-info{
 position:absolute;z-index:2;inset:auto 0 0;
 display:flex;flex-direction:column;gap:2px;padding:8px;
}
.castle-room-home-door .castle-room-door-info strong{font:16px/1.15 var(--app-font);color:#f7e1b9}
.castle-room-home-door .castle-room-door-info small{font-size:10px;color:#f6e5c8}
.castle-room-home-door:disabled{cursor:not-allowed;filter:grayscale(.75);opacity:.53}
.castle-room-host-top{display:flex;align-items:center;justify-content:space-between;gap:12px}
.castle-room-host-top>.castle-eyebrow{font-size:10px;letter-spacing:.13em}
#castle-room-host-state{font:15px/1.2 var(--app-font);color:#e9d2a9;text-align:right}
.castle-room-quick-actions{
 display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px;margin-top:11px;
}
.castle-room-quick-actions button{
 box-sizing:border-box;min-height:56px;padding:8px 4px;
 font-size:clamp(10px,2.5vw,12px);line-height:1.2;white-space:normal;
 border:1px solid #8b7954;background:#302e23;color:#f2dfb7;
}
.castle-room-quick-actions button:disabled{opacity:.43;filter:grayscale(.7);cursor:not-allowed}
#castle-room-host-toggle{background:#47292b;border-color:#a87b72;color:#f6dbd3}
.castle-room-opening-hours{margin-top:10px;border-top:1px solid #81714f77}
.castle-room-opening-hours>summary{
 cursor:pointer;display:list-item;list-style-position:inside;
 box-sizing:border-box;min-height:44px;padding:12px 0;
 color:#e8d4ab;font-size:13px;font-weight:650;
}
#castle-room-bedtime-form{
 display:grid;grid-template-columns:repeat(2,minmax(0,1fr));
 gap:10px;padding:10px 0 2px;align-items:end;
}
#castle-room-bedtime-form>label{
 display:flex;flex-direction:column;gap:4px;margin:0;
 color:#dfd4bd;font-size:12px;min-width:0;
}
#castle-room-bedtime-form input[type=time]{
 box-sizing:border-box;width:100%;min-width:0;min-height:45px;
 margin:0;padding:7px;background:#262c22;color:#f5ead3;
 border:1px solid #8f7b58;border-radius:2px;font-size:16px;
}
#castle-room-bedtime-form .castle-schedule-save{
 grid-column:1/-1;width:100%;min-height:46px;margin-top:3px;
}
#castle-room-automation-status{font-size:11px;line-height:1.4;color:#c1b59a;margin:10px 0 0}
#castle-room-host-message:empty{display:none}
#castle-room-host-message{font-size:12px;color:#ffb7b1}
#castle-rooms .castle-room-host-panel .castle-room-quick-actions{grid-template-columns:repeat(2,minmax(0,1fr))}
#castle-rooms .castle-room-host-panel .castle-room-opening-hours{margin-top:10px}
#castle-rooms .castle-room-host-panel #castle-room-bedtime-form{
 display:grid;flex:none;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;
}

@media(max-width:760px){
 body.castle-game #app[data-host="true"][data-screen="home"]>.side>.castle-rooms-admin{
  border-radius:2px;
 }
 .castle-rooms-home-heading p{font-size:10px}
 #castle-rooms .castle-room-quick-actions button{font-size:12px}
}

/* Empty optional text should not reserve space. */
#castle-rooms #castle-room-automation-status:empty,#castle-rooms #castle-room-sleep-desc:empty{display:none}

/* Room composer keyboard viewport repair
   The earlier Castle home/host grid rules have higher specificity than the
   generic keyboard rule. Override BOTH screens so the hidden header/nav cannot
   reserve rows behind a mobile on-screen keyboard. */
@media(max-width:760px){
 body.castle-game.castle-keyboard #app.castle-rooms-view[data-host="false"][data-screen="home"],
 body.castle-game.castle-keyboard #app.castle-rooms-view[data-host="true"][data-screen="chat"]{
  grid-template-columns:minmax(0,1fr)!important;
  grid-template-rows:minmax(0,1fr)!important;
 }
 body.castle-game.castle-keyboard #app.castle-rooms-view>#castle-view-heading,
 body.castle-game.castle-keyboard #app.castle-rooms-view>#castle-nav{
  display:none!important;
 }
 body.castle-game.castle-keyboard #app.castle-rooms-view>#castle-rooms{
  display:flex!important;flex-direction:column;
  grid-column:1!important;grid-row:1!important;
  min-height:0;height:100%;max-height:100%;
  box-sizing:border-box;overflow:hidden;
  padding:4px 6px;
 }
 body.castle-game.castle-keyboard #app.castle-rooms-view #castle-rooms>.castle-room-inside:not([hidden]){
  flex:1 1 0;min-height:0;min-width:0;
  width:100%;height:auto;max-height:none;margin:0 auto;
  display:flex;flex-direction:column;overflow:hidden;
 }
 body.castle-game.castle-keyboard #app.castle-rooms-view #castle-rooms .castle-room-messages{
  flex:1 1 0;min-height:0;max-height:none;overflow-y:auto;
  overscroll-behavior:contain;
 }
 body.castle-game.castle-keyboard #app.castle-rooms-view #castle-rooms .castle-room-inside-head,
 body.castle-game.castle-keyboard #app.castle-rooms-view #castle-rooms .castle-room-people,
 body.castle-game.castle-keyboard #app.castle-rooms-view #castle-rooms .castle-breakfast-warning{
  flex:0 0 auto;
 }
 body.castle-game.castle-keyboard #app.castle-rooms-view #castle-room-compose{
  position:relative;z-index:1;display:flex;
  flex:0 0 auto;min-height:0;max-width:100%;
  box-sizing:border-box;padding:6px;
 }
 body.castle-game.castle-keyboard #app.castle-rooms-view #castle-room-compose #castle-room-text{
  min-width:0;max-width:100%;font-size:16px;
 }
 body.castle-game.castle-keyboard #app.castle-rooms-view #castle-room-notice:empty{
  display:none!important;
 }
}
@media(max-width:760px) and (max-height:480px){
 body.castle-game.castle-keyboard #app.castle-rooms-view #castle-rooms .castle-room-people{
  max-height:48px;min-height:0;overflow-y:hidden;
 }
}

/* Use one header row and one image scale on every player screen.
   The Castle room view previously swapped grid tracks after fetching room state. */
@media(max-width:760px){
 body.castle-game:not(.castle-keyboard){
  --castle-uniform-header-height:calc(70px + env(safe-area-inset-top));
 }
 body.castle-game:not(.castle-keyboard) #app[data-host="false"][data-screen="home"],
 body.castle-game:not(.castle-keyboard) #app.castle-rooms-view[data-host="false"][data-screen="home"]{
  grid-template-rows:var(--castle-uniform-header-height) minmax(0,1fr) var(--castle-mobile-nav-height,calc(70px + env(safe-area-inset-bottom)))!important;
 }
 body.castle-game:not(.castle-keyboard) #app[data-host="false"]>#castle-view-heading{
  box-sizing:border-box;height:var(--castle-uniform-header-height);
  min-height:var(--castle-uniform-header-height);max-height:var(--castle-uniform-header-height);
  padding-top:calc(5px + env(safe-area-inset-top));padding-bottom:5px;
  background-size:cover,cover;background-position:center center,center center;
 }
}

/* Compact, full-width conversation layout. At 20 occupants the roster stays one
   short, horizontally-scrollable row; the message feed uses the freed height. */
body.castle-game #app.castle-rooms-view #castle-rooms:has(.castle-room-inside:not([hidden])){
 padding:6px clamp(6px,1vw,14px) 7px;
}
#castle-rooms .castle-room-inside{
 box-sizing:border-box;width:100%;max-width:none;margin:0;
 min-width:0;flex:1 1 0;min-height:0;overflow:hidden;
}
#castle-rooms .castle-room-inside-head{
 box-sizing:border-box;display:flex;align-items:center;gap:10px;
 flex:0 0 auto;min-height:43px;padding:5px 11px;
}
#castle-rooms .castle-room-inside-head h2{
 flex:1 1 0;min-width:0;margin:0;text-align:center;
 font:clamp(16px,2vw,21px)/1.2 var(--app-font);
 white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
#castle-rooms .castle-room-inside-head #castle-room-exit{
 flex:0 0 auto;min-width:54px;min-height:31px;
 padding:5px 8px;font-size:11px;line-height:1.1;
}
#castle-rooms #castle-room-count{
 flex:0 0 auto;min-width:54px;text-align:right;
 font-size:11px;font-variant-numeric:tabular-nums;
}
#castle-rooms .castle-room-people{
 box-sizing:border-box;display:flex;flex:0 0 auto;align-items:center;
 height:53px;min-height:53px;max-height:53px;gap:5px;
 padding:4px 9px;overflow-x:auto;overflow-y:hidden;
 scrollbar-width:thin;scrollbar-color:#856748 transparent;
 overscroll-behavior-x:contain;touch-action:pan-x;
}
#castle-rooms .castle-room-person{
 box-sizing:border-box;display:flex;flex-direction:column;align-items:center;
 justify-content:flex-start;flex:0 0 42px;max-width:42px;
 min-width:0;gap:1px;margin:0;overflow:hidden;
 color:#e9d9b9;text-align:center;
}
#castle-rooms .castle-room-person img,
#castle-rooms .castle-room-person-initial{
 box-sizing:border-box;display:grid;place-items:center;
 width:30px;height:30px;min-width:30px;min-height:30px;
 border:1px solid #c9a56d;border-radius:50%;
 object-fit:cover;object-position:center 20%;
 background:#3e2b22;color:#eacfa1;font-size:13px;
}
#castle-rooms .castle-room-person-name{
 display:block;max-width:100%;width:100%;min-width:0;
 overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
 font:9px/11px var(--app-font);
}
#castle-rooms .castle-room-messages{
 flex:1 1 0;min-height:0;max-height:none;overflow-y:auto;
 gap:7px;padding:10px clamp(9px,1.5vw,18px);
}
#castle-rooms .castle-room-message{
 max-width:min(96%,650px);padding:6px 9px;border-radius:7px;
}
#castle-rooms .castle-room-message strong{
 display:block;font-size:12px;line-height:1.2;
}
#castle-rooms .castle-room-message p{
 margin:2px 0 0;font-size:13px;line-height:1.35;
}
#castle-rooms .castle-room-message:has(.brm-voice-player){padding:5px 9px}
#castle-rooms .castle-room-message p:has(.brm-voice-player){
 margin:1px 0 0;line-height:1;
}
#castle-rooms .castle-room-event{font-size:11px;padding:4px 9px}
#castle-rooms .castle-room-compose{
 flex:0 0 auto;gap:7px;padding:6px 10px;
}
#castle-rooms .castle-room-compose input{min-height:42px}
#castle-rooms .castle-room-compose button[type="submit"]{
 min-height:42px;padding:7px 13px;
}
@media(max-width:760px){
 body.castle-game #app.castle-rooms-view #castle-rooms:has(.castle-room-inside:not([hidden])){
  padding:3px 5px 4px;
 }
 #castle-rooms .castle-room-inside-head{min-height:40px;padding:4px 7px;gap:6px}
 #castle-rooms .castle-room-inside-head h2{font-size:clamp(15px,4.2vw,19px)}
 #castle-rooms .castle-room-inside-head #castle-room-exit{
  min-width:48px;min-height:30px;padding:4px 6px;font-size:10px;
 }
 #castle-rooms #castle-room-count{min-width:48px;font-size:10px}
 #castle-rooms .castle-room-people{
  height:49px;min-height:49px;max-height:49px;gap:4px;padding:3px 6px;
 }
 #castle-rooms .castle-room-person{flex-basis:39px;max-width:39px}
 #castle-rooms .castle-room-person img,
 #castle-rooms .castle-room-person-initial{
  width:28px;height:28px;min-width:28px;min-height:28px;
 }
 #castle-rooms .castle-room-messages{gap:6px;padding:8px 8px}
 #castle-rooms .castle-room-message{max-width:96%;padding:5px 8px}
 #castle-rooms .castle-room-compose{gap:5px;padding:5px 6px}
 #castle-rooms .castle-room-compose input{min-height:42px}
 body.castle-game.castle-keyboard #app #castle-rooms .castle-room-people{
  height:43px;min-height:43px;max-height:43px;padding-block:2px;
 }
}

/* Mim's room tiles use exactly the same two-column arrangement as players:
   Breakfast is the full-width fifth tile, not a half-width card. */
.castle-rooms-home-grid>.castle-room-home-door[data-room="breakfast"]{
 grid-column:1/-1!important;justify-self:stretch!important;width:100%!important;
 min-height:116px;
}
.castle-rooms-home-grid>.castle-room-home-door[data-room="breakfast"] .castle-room-door-info{
 left:0;right:0;align-items:center;text-align:center;
}
.castle-rooms-home-grid>.castle-room-home-door[data-room="breakfast"] .castle-room-door-info strong{
 font-size:clamp(19px,3vw,25px);
}
/* Room interiors are identical for Mim and players: room name, visible-player
   roster, chat and composer; administration is never part of this surface. */
#castle-rooms .castle-room-people:not([hidden])::before{
 content:"Visible in room";display:flex;align-items:center;
 flex:0 0 58px;min-height:30px;padding-right:5px;
 border-right:1px solid #9c825d6c;
 color:#cbb896;font:9px/1.25 var(--app-font);
}
body.castle-game #app.castle-rooms-view[data-host="true"] #castle-rooms{
 padding-top:5px;
}
@media(max-width:760px){
 .castle-rooms-home-grid>.castle-room-home-door[data-room="breakfast"]{
  min-height:100px;
 }
 #castle-rooms .castle-room-people:not([hidden])::before{flex-basis:46px;font-size:8px}
}
