/* v11.6.6 FINAL SQUARE ENGINE */
#photo-zone-screen, #photo-zone-screen * { box-sizing: border-box; }
#photo-zone-screen {
    position: fixed; inset: 0; z-index: 2000000 !important;
    background: #ffffff; display: none; flex-direction: column; align-items: center; justify-content: flex-start;
    user-select: none; font-family: 'Outfit', sans-serif;
}
#photo-zone-screen.active { display: flex !important; }
.photo-zone-container {
    width: 100%; max-width: 500px; height: 100dvh; display: flex; flex-direction: column;
    padding: 0; background: #ffffff; overflow: hidden;
}
.photo-header {
    display: flex; justify-content: space-between; align-items: center;
    height: 90px; width: 100%; padding: 30px 15px 5px; background: #fff;
    border-bottom: 1px solid #f0f0f0; position: relative; z-index: 500000;
}
.photo-title { font-size: 1.3rem; color: #ff6b81; font-weight: 900; }
.header-group { display: flex; gap: 12px; }
.pz-header-btn {
    width: 44px !important; height: 44px !important; background: #fff !important; 
    border: 1px solid #ffdae0 !important; border-radius: 12px !important;
    cursor: pointer; display: flex !important; align-items: center; justify-content: center;
    background-size: 60% !important; background-position: center !important; background-repeat: no-repeat !important;
    box-shadow: 0 4px 10px rgba(255,107,129,0.1) !important;
    transition: transform 0.1s;
}
.pz-header-btn:active { transform: scale(0.92); }
.icon-flip { background-image: url('assets/flip-btn.png') !important; }
.icon-close { background-image: url('assets/x-btn.png') !important; }

/* [CRITICAL FIX] SQUARE CAMERA VIEWPORT */
.camera-wrapper {
    width: 100vw; height: 100vw; max-width: 500px; max-height: 500px;
    background: #000; position: relative; overflow: hidden; margin: 0 auto;
}
#camera-preview { width: 100%; height: 100%; object-fit: cover; }
#photo-render-canvas { width: 100%; height: 100%; object-fit: contain; display: none; }
#sticker-layer { position: absolute; inset: 0; z-index: 200; pointer-events: none; }

.photo-controls {
    display: flex; justify-content: center; align-items: center;
    height: 100px; background: #fff; flex-shrink: 0;
}
.pz-capture-btn {
    width: 70px; height: 70px; background: #fff; border: 5px solid #ff6b81;
    border-radius: 50%; cursor: pointer; box-shadow: 0 8px 20px rgba(255,107,129,0.3);
}
.pz-save-btn, .pz-retake-btn {
    background: #ff6b81; color: #fff; border: none; padding: 12px 25px;
    border-radius: 25px; font-weight: 800; cursor: pointer; margin: 0 10px;
}

.sticker-shelf {
    flex: 1; min-height: 120px; width: 100%; background: #fff; border-top: 1px solid #eee;
    padding: 0; overflow-x: auto; overflow-y: hidden; display: block;
    -webkit-overflow-scrolling: touch;
}
.sticker-list {
    display: flex; flex-direction: row; align-items: center; padding: 15px 10px;
    min-width: min-content; gap: 10px;
}
.sticker-item {
    width: 80px; height: 80px; background: #fff8f9; border: 2px solid #ffdae0;
    border-radius: 15px; flex-shrink: 0; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.2s;
}
.sticker-item:active { transform: scale(0.95); }
.sticker-item img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }

.placed-sticker {
    position: absolute; width: 100px; height: 100px;
    background-size: contain; background-repeat: no-repeat; background-position: center;
    cursor: move; touch-action: none; z-index: 10; pointer-events: auto;
}
.placed-sticker.selected { outline: 2px dashed #ff6b81; }
.sticker-trash-btn, .sticker-transform-btn {
    position: absolute; width: 30px; height: 30px; background: #ff6b81; color: #fff;
    border: none; border-radius: 50%; display: none; align-items: center; justify-content: center;
    font-size: 14px; cursor: pointer; z-index: 100;
}
.placed-sticker.selected .sticker-trash-btn, .placed-sticker.selected .sticker-transform-btn { display: flex; }
.sticker-trash-btn { top: -15px; right: -15px; }
.sticker-transform-btn { bottom: -15px; right: -15px; }
.hidden { display: none !important; }
