/* The original portrait composition remains intact in either orientation. */
body[data-phase=memoryRoom] #world{inset:0;background:#111a1d;animation:none;transform:none;filter:none}
body[data-phase=memoryRoom] #world::before,body[data-phase=memoryRoom] #world::after{display:none}
body[data-phase=memoryRoom] .shade{background:radial-gradient(ellipse at 30% 40%,#23302f70,transparent 72%)}
body[data-phase=memoryRoom] #sceneCaption,body[data-phase=memoryRoom] #footer #inputHint,body[data-phase=memoryRoom] #footer .footer-brand{display:none}
body[data-phase=memoryRoom] #brand{display:none}
body[data-phase=memoryRoom] header{justify-content:flex-end}
#memoryRoom{position:absolute;z-index:3;inset:66px 5% calc(max(22px,env(safe-area-inset-bottom)) + 60px);display:flex;flex-direction:column;gap:20px;font-family:'Malgun Gothic','Apple SD Gothic Neo',system-ui,sans-serif}
.memory-heading{flex:none;display:flex;align-items:center;justify-content:space-between;gap:15px;min-height:44px}
.memory-heading h2{margin:0;font:500 27px/1.1 'RageEN',system-ui;letter-spacing:.07em;color:#e6dfcc}
.memory-heading p{margin:5px 0 0;font-size:11px;color:#9ca99f}
.memory-heading>span{font:500 8px/1.4 'RageEN',system-ui;letter-spacing:.13em;color:#a49d83}
.memory-content{display:grid;grid-template-columns:minmax(0,1.1fr) minmax(230px,.9fr);gap:clamp(20px,4vw,65px);flex:1;min-height:0}
.memory-viewer{min-width:0;min-height:0;display:grid;grid-template-rows:minmax(0,1fr) 44px;gap:10px}
.memory-stage{position:relative;min-height:0;min-width:0;display:flex;justify-content:center;align-items:center;background:linear-gradient(120deg,#071014a8,#16211d60);overflow:hidden}
.memory-media{flex:none;aspect-ratio:9/16;overflow:hidden;background:#060c0e}
.memory-media video,.memory-media>img{display:block;width:100%;height:100%;object-fit:contain;background:transparent}
.memory-selection{position:absolute;left:12px;right:12px;top:11px;display:flex;justify-content:space-between;align-items:flex-start;gap:8px;pointer-events:none;text-shadow:0 1px 6px #000}
#memorySelectedTitle{font-size:11px;font-weight:400;color:#e1dece}
#memorySelectedBadge{font-size:9px;color:#d5c6a4}
#memoryStatus{position:absolute;left:8%;right:8%;top:50%;transform:translateY(-50%);margin:0;text-align:center;font-size:11px;line-height:1.7;color:#b3beb2;background:#101a20e6;padding:12px}
.memory-controls{display:flex;align-items:center;gap:4px;min-width:0;background:#07111675}
.memory-controls button{flex:none;display:grid;place-items:center;width:44px;height:44px;min-height:44px;padding:10px;border:0;background:none;color:#cbd1c3}
.memory-controls button:hover{background:#a3905a18;color:#f2e4bf}
.memory-controls button:disabled{opacity:.25;cursor:default}
.memory-controls svg{display:block;width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round}
.memory-time{flex:none;min-width:63px;font:400 9px/1.3 'RageEN',system-ui;color:#9eaa9e;white-space:nowrap;text-align:center}
.memory-time i{font-style:normal;color:#5f7068;padding:0 3px}
#memorySeek{flex:1;width:0;min-width:24px;height:44px;margin:0 3px;accent-color:#c0aa75;cursor:pointer}
#memoryRoom[data-media-type=image] #memoryPlay,#memoryRoom[data-media-type=image] .memory-time,#memoryRoom[data-media-type=image] #memorySeek,#memoryRoom[data-media-type=image] #memoryMute{visibility:hidden}
.memory-library{display:flex;flex-direction:column;gap:16px;min-height:0;min-width:0}
.memory-library-head{display:flex;align-items:center;gap:8px;min-height:44px;border-bottom:1px solid #9fac8b26;flex:none}
.memory-filters{display:flex;gap:14px}
.memory-filters button{border:0;border-bottom:1px solid transparent;background:none;padding:12px 1px;min-height:44px;font-size:11px;color:#7e9186}
.memory-filters button[aria-pressed=true]{border-bottom-color:#bba372;color:#e8dfc7}
#memoryCount{margin-left:auto;font:400 12px 'RageEN',system-ui;color:#9caa98}
#memoryItems{--memory-columns:3;display:grid;grid-template-columns:repeat(var(--memory-columns),minmax(0,1fr));align-content:start;gap:18px 12px;min-height:0;overflow:auto;scrollbar-width:thin;scrollbar-color:#8d9f8055 transparent;padding:0 3px 6px 0}
.memory-tile{min-width:0;width:100%;padding:0;border:0;background:none;text-align:left;color:#9eab9f}
.memory-cover{position:relative;display:block;aspect-ratio:9/16;overflow:hidden;background:#182020;outline:1px solid #8c9b7e20;outline-offset:-1px}
.memory-cover img{width:100%;height:100%;display:block;object-fit:contain;filter:saturate(.78);opacity:.72}
.memory-tile[aria-pressed=true] .memory-cover{outline-color:#c5ad78;outline-width:2px}
.memory-tile[aria-pressed=true] img{opacity:1;filter:none}
.memory-tile strong{display:block;margin:8px 0 4px;font-size:12px;line-height:1.4;font-weight:400;color:#d7daca}
.memory-tile small{display:block;font-size:9px;line-height:1.4;color:#83988b}
.memory-tile-type{position:absolute;left:7px;bottom:7px;font:400 7px 'RageEN',system-ui;letter-spacing:.15em;color:#e7dfca;text-shadow:0 1px 5px #000}
#memoryRetry{align-self:flex-start;min-height:44px;border:1px solid #b4ac7e66;background:#203028;padding:8px 16px;color:#e3ddc8;font-size:11px}
#memoryRoom.memory-expanded .memory-library,#memoryRoom.memory-expanded .memory-heading{display:none}
#memoryRoom.memory-expanded .memory-content{grid-template-columns:minmax(0,1fr)}
#memoryRoom.memory-expanded{inset:62px 5% calc(max(22px,env(safe-area-inset-bottom)) + 60px)}
#memoryRoom.memory-expanded .memory-controls{width:min(520px,100%);justify-self:center}
@media(orientation:portrait){
 #memoryRoom{inset:70px 6% calc(max(25px,env(safe-area-inset-bottom)) + 58px);gap:14px}
 .memory-heading h2{font-size:25px}.memory-heading>span{font-size:7px}
 .memory-content{grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr) clamp(140px,24dvh,220px);gap:14px}
 .memory-viewer{gap:6px}.memory-selection{left:9px;right:9px;top:8px}
 .memory-library{gap:10px}.memory-library-head{min-height:36px}.memory-filters button{padding:8px 1px;min-height:36px}
 #memoryItems{gap:12px;overflow-y:auto}
 .memory-cover{height:clamp(58px,11dvh,108px);aspect-ratio:auto;display:flex;justify-content:center;background:#0a1417a8;outline:0}
 .memory-cover img{width:auto;max-width:100%;height:100%;object-fit:contain}
 .memory-tile[aria-pressed=true] .memory-cover{outline:1px solid #bda675;outline-offset:-1px}
 .memory-tile strong{font-size:11px;margin-top:6px;margin-bottom:2px}.memory-tile small{font-size:8px}
 #memoryRoom.memory-expanded .memory-content{grid-template-rows:minmax(0,1fr)}
 #memoryRoom.memory-expanded{inset:62px 6% calc(max(25px,env(safe-area-inset-bottom)) + 58px)}
}
@media(max-height:700px) and (orientation:portrait){
 #memoryRoom{top:60px;gap:10px}.memory-heading{min-height:38px}.memory-heading h2{font-size:23px}
 .memory-content{grid-template-rows:minmax(0,1fr) 148px;gap:8px}.memory-library{gap:6px}
 .memory-selection{top:5px}#memorySelectedTitle{font-size:10px}#memorySelectedBadge{font-size:8px}
}
@media(max-height:440px) and (orientation:landscape){
 #memoryRoom{inset:55px 5% calc(max(10px,env(safe-area-inset-bottom)) + 60px);gap:10px}
 .memory-heading{min-height:32px}.memory-heading h2{font-size:23px}.memory-heading p{font-size:9px;margin-top:3px}
 .memory-content{grid-template-columns:minmax(0,1.15fr) minmax(210px,.85fr);gap:24px}
 .memory-library{gap:8px}.memory-library-head{min-height:36px}.memory-filters button{min-height:36px;padding-block:8px}
 #memoryItems{gap:10px}
 .memory-cover{height:clamp(56px,20dvh,100px);aspect-ratio:auto}.memory-cover img{object-fit:contain}
 .memory-tile strong{font-size:10px;margin-top:5px;margin-bottom:2px}.memory-tile small{font-size:8px}
 .memory-viewer{gap:6px}.memory-controls{gap:2px}.memory-selection{top:6px;left:8px;right:8px}
 #memorySelectedTitle{font-size:10px}#memorySelectedBadge{font-size:8px}
 #memoryRoom.memory-expanded{inset:50px 5% calc(max(10px,env(safe-area-inset-bottom)) + 60px)}
}
@media(orientation:landscape){
 #memoryRoom:not(.memory-expanded){display:grid;grid-template-columns:minmax(0,1.1fr) minmax(230px,.9fr);grid-template-rows:auto minmax(0,1fr);column-gap:clamp(20px,4vw,65px);row-gap:14px}
 #memoryRoom:not(.memory-expanded) .memory-heading{grid-area:1/2}
 #memoryRoom:not(.memory-expanded) .memory-content{display:contents}
 #memoryRoom:not(.memory-expanded) .memory-viewer{grid-area:1/1/3/2}
 #memoryRoom:not(.memory-expanded) .memory-library{grid-area:2/2}
}
@media(max-height:440px) and (orientation:landscape){
 #memoryRoom:not(.memory-expanded){grid-template-columns:minmax(0,1.15fr) minmax(210px,.85fr);column-gap:24px;row-gap:10px}
}

/* Library first. A movie is loaded only after its cover is opened. */
#memoryRoom[data-view]{display:flex;flex-direction:column}
#memoryRoom[data-view=library] .memory-content{display:flex;flex:1;min-height:0}
#memoryRoom[data-view=library] .memory-viewer{display:none}
#memoryRoom[data-view=library] .memory-library{flex:1;width:100%;gap:18px}
#memoryRoom[data-view=library] .memory-library-head{min-height:44px}
#memoryRoom[data-view=library] .memory-filters{gap:12px}
#memoryRoom[data-view=library] .memory-filters button{min-width:44px;min-height:44px;padding:10px 3px}
#memoryRoom[data-view=library] #memoryItems{flex:1;grid-template-columns:repeat(var(--memory-columns),minmax(0,1fr));gap:24px 18px;align-items:start;padding:2px 3px 8px}
#memoryRoom[data-view=library] .memory-tile{width:100%;max-width:220px;justify-self:center;text-align:center}
#memoryRoom[data-view=library] .memory-cover{width:min(100%,19.125dvh);height:auto;max-height:none;aspect-ratio:9/16;margin:0 auto;display:block;outline:1px solid #9aab832b;background:#071014}
#memoryRoom[data-view=library] .memory-cover img{display:block;width:100%;height:100%;object-fit:contain;opacity:1;filter:saturate(.9)}
#memoryRoom[data-view=library] .memory-tile:hover .memory-cover{outline-color:#bea876}
#memoryLibraryStatus{flex:1;display:grid;place-items:center;min-height:80px;margin:0;padding:24px;text-align:center;color:#92a395;font-size:12px;line-height:1.7}
#memoryRoom[data-view=player]{inset:62px 5% calc(max(22px,env(safe-area-inset-bottom)) + 60px)}
#memoryRoom[data-view=player] .memory-heading,#memoryRoom[data-view=player] .memory-library{display:none}
#memoryRoom[data-view=player] .memory-content{display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr);flex:1;min-height:0}
#memoryRoom[data-view=player] .memory-viewer{grid-area:auto;display:grid;min-height:0}
#memoryRoom[data-view=player] .memory-controls{width:min(520px,100%);justify-self:center}
@media(orientation:portrait){
 #memoryRoom[data-view=library] .memory-library{gap:16px}
 #memoryRoom[data-view=library] #memoryItems{gap:22px 12px}
 #memoryRoom[data-view=library] .memory-cover{width:100%;max-width:180px}
 #memoryRoom[data-view=player]{inset:62px 6% calc(max(25px,env(safe-area-inset-bottom)) + 58px)}
}
@media(max-height:440px) and (orientation:landscape){
 #memoryRoom[data-view=library]{gap:8px}
 #memoryRoom[data-view=library] .memory-heading p{display:none}
 #memoryRoom[data-view=library] .memory-library{gap:8px}
 #memoryRoom[data-view=library] #memoryItems{padding-bottom:4px}
 #memoryRoom[data-view=library] .memory-cover{width:min(100%,18dvh)}
 #memoryRoom[data-view=player]{inset:50px 5% calc(max(10px,env(safe-area-inset-bottom)) + 60px)}
}
@media(max-height:360px) and (orientation:landscape){
 #memoryRoom[data-view=library] .memory-cover{width:min(100%,11.25dvh)}
}
