body, html {
    margin: 0; padding: 0;
    width: 100%; height: 100%;
    overflow: hidden;
    background: #000;
    font-family: sans-serif;
}

#video-container {
    position: absolute;
    top: 0; left: 0;
    width: 100vw; height: 100dvh;
    z-index: 1;
}

video {
    width: 100%; height: 100%;
    object-fit: cover;
}

.mirror { transform: scaleX(-1); }

/* フレーム：初期位置は中央。JSでtransformを上書きする */
.frame-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; /* 初期サイズを画面幅に */
    height: auto;
    z-index: 20;
    touch-action: none; /* ブラウザのスクロール等を防止 */
    will-change: transform;
}

#guide-overlay {
    position: fixed;
    top: 20%; width: 100%;
    text-align: center;
    color: white;
    background: rgba(0,0,0,0.5);
    padding: 10px 0;
    z-index: 30;
    pointer-events: none;
}

.ui-container {
    position: fixed;
    left: 0;
    bottom: calc(40px + env(safe-area-inset-bottom)); 
    width: 100vw;
    height: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 50;
}

.btn {
    border: none;
    background-color: transparent;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    cursor: pointer;
    outline: none;
}

#shutter {
    width: 80px; height: 80px;
    background-image: url('image/shutter.PNG');
}

#switch-camera {
    position: absolute;
    right: 15%;
    width: 50px; height: 50px;
    background-image: url('image/switch.PNG');
}

.btn:active { transform: scale(0.9); }

#flash-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: white; opacity: 0; pointer-events: none; z-index: 100;
}

.flash-active { animation: flash-animation 0.4s ease-out; }
@keyframes flash-animation { 0% { opacity: 1; } 100% { opacity: 0; } }

#preview-container {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 80; background: rgba(0,0,0,0.9);
    flex-direction: column; align-items: center; justify-content: center;
}

#preview-image { max-width: 90%; max-height: 70%; object-fit: contain; }
.preview-buttons { margin-top: 20px; display: flex; gap: 20px; }
.btn-text { background: #eee; border: none; border-radius: 8px; padding: 12px 24px; font-weight: bold; }
.highlight { background: #ffb6c1; }
#capture-canvas { display: none; }