/* Fit the available browser viewport, including changing mobile browser bars. */
:root{--view-height:100dvh;--safe-top:env(safe-area-inset-top,0px);--safe-bottom:env(safe-area-inset-bottom,0px)}
html,body{width:100%;height:var(--view-height);min-height:0;overflow:hidden}
.grid-container{height:var(--view-height);min-height:0;width:100%;grid-template-columns:repeat(8,minmax(0,1fr));grid-template-rows:repeat(8,minmax(0,1fr));position:relative}
#fullscreen-button{position:fixed;top:calc(12px + var(--safe-top));right:12px;z-index:10000;border:1px solid #ffffff80;border-radius:24px;padding:10px 16px;background:#17213cce;color:#fff;font:700 14px Pretendard,Arial,sans-serif}
#camera-select{top:calc(12px + var(--safe-top));left:12px;font-size:clamp(12px,1.5vw,20px);padding:10px;max-width:55vw}
#start{grid-column:1/9;grid-row:1/9;min-height:0;background-size:contain;background-color:#000}
#start-hint{bottom:calc(7% + var(--safe-bottom));font-size:clamp(18px,3vw,48px);letter-spacing:clamp(2px,.5vw,8px);padding:clamp(12px,2vh,25px) clamp(24px,5vw,80px)}
#step-type-select:not([hidden]){grid-column:1/9;grid-row:1/9;min-height:0;overflow:auto;justify-content:safe center;padding:calc(65px + var(--safe-top)) 16px calc(20px + var(--safe-bottom));gap:18px}
.type-options{flex-direction:row;gap:clamp(12px,3vw,40px)}
.type-card{width:auto;flex-wrap:nowrap;flex-direction:column;padding:clamp(10px,2vw,20px);gap:0;text-align:center}
.type-card canvas{width:auto;height:min(48vw,calc((var(--view-height) - 250px)));max-height:450px;aspect-ratio:2/3;flex:none}
.type-card .type-name{margin:14px 0 0;font-size:clamp(16px,2vw,24px)}
.type-card .type-desc{margin:10px 0 0;font-size:clamp(11px,1.3vw,14px);max-width:260px;line-height:1.4}
.step-title h1{font-size:clamp(24px,3.5vw,48px)}
/* Camera and shutter have separate areas so no device can crop the shutter. */
#booth[data-phase="capture"]{display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr) auto;padding:calc(65px + var(--safe-top)) 16px calc(14px + var(--safe-bottom));gap:12px}
#camera_div:not([hidden]){grid-column:1;grid-row:1;min-height:0;height:100%;width:100%;overflow:hidden}
#camera.has-stream{height:100%;width:auto;max-height:100%;max-width:100%;object-fit:contain;aspect-ratio:2/3}
#camera.landscape{aspect-ratio:3/2}
#start-button:not([hidden]){grid-column:1;grid-row:2;align-self:center;margin:0;max-width:100%;font-size:clamp(18px,2.5vw,32px);letter-spacing:clamp(2px,.4vw,6px);padding:14px clamp(24px,5vw,70px);min-height:54px}
#timer{top:8px;font-size:clamp(28px,4vw,55px);padding:8px 22px}#progress{top:12px;right:8px;font-size:clamp(16px,2vw,24px)}
#camera-fallback:not([hidden]){position:absolute;inset:70px 16px auto;max-width:350px;margin:auto;grid-column:auto;grid-row:auto}
.canvas_grid{grid-column:1/6;grid-row:1/9;min-height:0;padding:65px 16px 20px}
#canvas-wrap #canvas{width:auto;height:100%;max-height:calc(var(--view-height) - 100px - var(--safe-bottom));max-width:100%;aspect-ratio:2/3}
.step-side:not([hidden]){grid-column:6/9;grid-row:1/9;min-height:0;max-height:100%;overflow-y:auto;justify-content:safe center;padding:calc(65px + var(--safe-top)) 18px calc(24px + var(--safe-bottom))}
.step-side h2{font-size:clamp(23px,3vw,40px);flex-shrink:0}
.step-side>.button,.step-actions,.print-picker,.print-note,.web-note{flex-shrink:0}
.select-box{grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;flex-shrink:0}
.photo-wrapper{width:100%;height:auto;aspect-ratio:2/3;max-width:120px}.photo-wrapper.landscape{width:100%;height:auto;aspect-ratio:3/2;max-width:150px}
.frame-box{max-height:none;flex-shrink:0}.frame-button{width:clamp(65px,9vw,100px);height:auto;aspect-ratio:2/3}
#status:not(:empty){bottom:calc(8px + var(--safe-bottom));max-width:calc(100vw - 24px);pointer-events:none}
@media(max-aspect-ratio:4/5){
 .grid-container{grid-template-columns:1fr;grid-template-rows:minmax(0,42%) minmax(0,58%)}
 #start,#step-type-select:not([hidden]){grid-column:1;grid-row:1/3}
 .canvas_grid{grid-column:1;grid-row:1;padding:58px 10px 8px;min-height:0}
 #canvas-wrap #canvas{height:100%;max-height:100%;max-width:90vw}
 .step-side:not([hidden]){grid-column:1;grid-row:2;padding:12px 16px calc(20px + var(--safe-bottom));min-height:0}
 .step-side h2{font-size:25px;margin-bottom:12px}
 .select-box{width:min(100%,420px);max-width:420px;margin-bottom:10px}
 .photo-wrapper{width:100%;max-width:95px;max-height:130px}.photo-wrapper.landscape{max-width:125px;max-height:84px}
 .frame-box{grid-template-columns:repeat(3,1fr);gap:8px;margin-bottom:10px}.frame-button{width:78px;margin:5px}
 .filter-box{margin-bottom:10px;max-width:100%}.filter-item{margin:4px}.filter-item canvas{width:60px;height:90px}
 .step-side .button{padding:1em 2em;margin:6px 0}
 .print-picker{margin-bottom:16px}.print-note{margin-bottom:18px}
}
@media(max-height:480px) and (min-aspect-ratio:4/5){
 .type-card canvas{height:100px}.type-card .type-desc{display:none}.type-card .type-name{margin-top:8px}
 #step-type-select:not([hidden]){padding-top:50px;gap:8px}.step-title h1{font-size:24px}
 .step-side:not([hidden]){padding-top:50px}.step-side h2{font-size:22px;margin-bottom:10px}
 .step-side .button{padding:12px 20px}.filter-item canvas{width:48px;height:72px}.frame-button{width:60px;margin:4px}
}
@media print{html,body{height:auto!important;overflow:visible!important}#fullscreen-button{display:none!important}}
