:root {
            --body-bg: #e0d8c3;
            --cam-body: #2a2a2a;
            --cam-accent: #ff5e57;
            --cam-leather: #1a1a1a;
            --font-main: 'Courier New', Courier, monospace;
        }

        * { box-sizing: border-box; user-select: none; }

        body {
            margin: 0;
            background-color: var(--body-bg);
            background-image: radial-gradient(#cec4ad 1px, transparent 1px);
            background-size: 20px 20px;
            height: 100vh;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            font-family: var(--font-main);
            overflow: hidden;
        }

        /* --- Header --- */
        header {
            position: absolute;
            top: 20px;
            text-align: center;
            z-index: 10;
            pointer-events: none;
        }
        h1 {
            font-size: 2rem;
            letter-spacing: -2px;
            color: #333;
            margin: 0;
            text-transform: uppercase;
        }
        p.subtitle { font-size: 0.8rem; opacity: 0.6; margin-top: 5px; }

        /* --- The Camera Scene --- */
        .scene {
            perspective: 1000px;
            width: 320px; height: 320px;
            position: relative;
            z-index: 5;
        }

        .camera {
            width: 100%; height: 240px;
            background: var(--cam-body);
            border-radius: 30px;
            position: relative;
            transform-style: preserve-3d;
            box-shadow: 0 20px 50px rgba(0,0,0,0.3), inset 0 2px 5px rgba(255,255,255,0.2);
            display: flex; align-items: center; justify-content: center;
            z-index: 20;
        }

        .camera::before {
            content: ''; position: absolute;
            left: 0; right: 0; top: 50%; height: 100px;
            background: var(--cam-leather);
            transform: translateY(-50%); z-index: 1;
            background-image: url("data:image/svg+xml,%3Csvg width='4' height='4' viewBox='0 0 4 4' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 3h1v1H1V3zm2-2h1v1H3V1z' fill='%23333' fill-opacity='0.4' fill-rule='evenodd'/%3E%3C/svg%3E");
        }

        .stripe {
            position: absolute; bottom: 30px; left: 50%;
            transform: translateX(-50%);
            width: 40px; height: 10px;
            background: linear-gradient(to right, #ff5e57 20%, #ffdd59 20% 40%, #0be881 40% 60%, #4bcffa 60% 80%, #806cdb 80%);
            z-index: 5;
        }

        /* --- The Lens --- */
        .lens-housing {
            width: 140px; height: 140px;
            background: #111; border-radius: 50%;
            z-index: 10; position: relative;
            border: 4px solid #444;
            box-shadow: 0 10px 20px rgba(0,0,0,0.5);
            display: flex; align-items: center; justify-content: center;
            overflow: hidden;
        }

        .power-btn {
            position: absolute; bottom: 20px; left: 20px;
            width: 28px; height: 28px;
            border-radius: 50%;
            background: #111;
            border: 2px solid var(--cam-accent);
            cursor: pointer; z-index: 4;
            box-shadow: 0 3px 8px rgba(0,0,0,0.3);
            display: flex; align-items: center; justify-content: center;
            transition: transform 0.1s, box-shadow 0.2s, background 0.2s, border-color 0.2s;
        }
        .power-btn:active { transform: scale(0.95); }
        .power-btn.on { background: var(--cam-accent); border-color: #fff; box-shadow: 0 0 12px rgba(255,94,87,0.6); }
        .power-btn .power-icon { display: none; }
        .power-btn::after {
            content: '';
            position: absolute; left: 0; top: 0; width: 100%; height: 100%;
            border-radius: 50%; border: 2px solid var(--cam-accent);
            opacity: 0; transform: scale(1);
        }
        .power-btn.pulse::after { animation: btnPulse 300ms ease-out; }
        @keyframes btnPulse {
            0% { opacity: 0.6; transform: scale(1); }
            100% { opacity: 0; transform: scale(1.5); }
        }
        .power-icon {
            width: 30px; height: 30px;
            border: 2px solid #ff5e57;
            border-radius: 50%;
            position: relative;
        }
        .power-icon::after {
            content: ''; position: absolute;
            top: -5px; left: 50%; transform: translateX(-50%);
            width: 2px; height: 15px; background: #ff5e57;
        }

        .lens-glass {
            width: 80px; height: 80px;
            border-radius: 50%; border: 15px solid #222;
            position: relative; overflow: hidden;
            background: #000;
        }

        .filter-dial {
            position: absolute; left: 50%; top: 50%;
            width: 80px; height: 80px;
            transform: translate(-50%, -50%);
            border-radius: 50%;
            background: conic-gradient(
                rgba(255,94,87,0.25) 0deg 90deg,
                rgba(255,221,89,0.25) 90deg 180deg,
                rgba(75,207,250,0.25) 180deg 270deg,
                rgba(128,108,219,0.25) 270deg 360deg
            );
            pointer-events: auto;
            z-index: 3;
            transition: transform 0.35s cubic-bezier(0.25, 1, 0.5, 1);
        }

        .filter-label {
            position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
            font-size: 0.6rem; color: #ddd; background: rgba(0,0,0,0.3);
            padding: 2px 6px; border-radius: 8px;
            z-index: 6;
        }

        /* Video Feed */
        #liveFeed {
            width: 100%; height: 100%;
            object-fit: cover;
            transform: scaleX(-1); /* Mirror */
            opacity: 0; /* Hidden until power on */
            transition: opacity 0.5s;
        }
        #liveFeed.active { opacity: 0.8; }

        /* Lens Reflection */
        .lens-glass::after {
            content: ''; position: absolute;
            top: -10%; left: -10%; width: 120%; height: 120%;
            background: linear-gradient(135deg, rgba(255,255,255,0.3) 0%, transparent 20%, rgba(75, 207, 250, 0.1) 50%, transparent 100%);
            border-radius: 50%; pointer-events: none;
        }

        /* Camera Parts */
        .flash {
            position: absolute; top: 20px; right: 30px;
            width: 50px; height: 30px;
            background: #eee; border-radius: 4px; z-index: 5;
        }
        .flash.firing { animation: flashBurst 0.1s ease-out; }

        .viewfinder {
            position: absolute; top: 25px; left: 30px;
            width: 40px; height: 30px;
            background: #000; border-radius: 4px;
            z-index: 5; border: 2px solid #444;
        }
        /* Red Recording Dot */
        .viewfinder::after {
            content: ''; position: absolute;
            width: 6px; height: 6px; background: red;
            border-radius: 50%; top: 50%; left: 50%;
            transform: translate(-50%, -50%);
            opacity: 0; transition: opacity 0.3s;
        }
        .viewfinder.on::after { opacity: 1; }

        .power-toggle {
            position: absolute; top: 20px; left: 50%;
            transform: translateX(-50%);
            width: 36px; height: 36px;
            border-radius: 50%; border: 2px solid #ff5e57;
            display: none; align-items: center; justify-content: center;
            background: #111; z-index: 25; cursor: pointer;
        }
        .power-toggle span {
            position: absolute; bottom: -14px; font-size: 0.6rem;
            color: #fff; letter-spacing: 1px;
        }
        .power-toggle .power-icon {
            width: 20px; height: 20px;
            border: 2px solid #ff5e57; border-radius: 50%; position: relative;
        }
        .power-toggle .power-icon::after {
            content: ''; position: absolute; top: -4px; left: 50%;
            transform: translateX(-50%);
            width: 2px; height: 10px; background: #ff5e57;
        }

        .shutter-btn {
            position: absolute; top: -10px; right: 40px;
            width: 40px; height: 20px;
            background: var(--cam-accent);
            border-radius: 5px 5px 0 0;
            cursor: pointer; z-index: 4;
            transition: top 0.1s;
            user-select: none;
            -webkit-user-select: none;
            -webkit-tap-highlight-color: transparent;
        }
        .shutter-btn:active { top: -5px; }

        .slot {
            position: absolute; bottom: -5px; left: 50%;
            transform: translateX(-50%);
            width: 220px; height: 15px;
            background: #111; border-radius: 0 0 10px 10px; z-index: 15;
        }

        /* --- Photo Output --- */
        .photo-container {
            position: absolute; top: 120px; left: 50%;
            transform: translateX(-50%) scale(0.9);
            width: 200px; height: 240px;
            background: white; padding: 15px 15px 60px 15px;
            box-shadow: 0 5px 15px rgba(0,0,0,0.2);
            z-index: 2; display: flex; align-items: center; justify-content: center;
        }

        .photo-container.ejecting {
            animation: printPhoto 2.5s cubic-bezier(0.25, 1, 0.5, 1) forwards;
        }

        .photo-container.developed {
            cursor: grab; z-index: 30;
            transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
        }
        .photo-container.developed:active { cursor: grabbing; }

        .film-image {
            width: 100%; height: 100%; background: #111;
            position: relative; overflow: hidden;
        }
        .film-image img {
            width: 100%; height: 100%; object-fit: cover;
            opacity: 0;
            filter: grayscale(100%) contrast(2) brightness(0.2) sepia(0.5);
            transition: opacity 3s ease, filter 5s ease;
            transform: scaleX(-1);
        }
        .film-image.developing img {
            opacity: 1; filter: grayscale(0%) contrast(1) brightness(1) sepia(0);
        }

        .caption-input {
            position: absolute; bottom: 18px; left: 15px; right: 15px;
            height: 24px; border: none; border-bottom: 1px dashed #ccc;
            background: transparent; font-family: var(--font-main);
            font-size: 12px; text-align: center; outline: none;
        }

        .instructions {
            position: absolute; bottom: 30px;
            color: #555; font-size: 0.9rem; text-align: center;
            width: 100%;
        }

        @keyframes flashBurst {
            0% { background: #eee; box-shadow: 0 0 0 0 rgba(255,255,255,0); }
            10% { background: #fff; box-shadow: 0 0 100px 50px rgba(255,255,255,0.9); }
            100% { background: #eee; box-shadow: 0 0 0 0 rgba(255,255,255,0); }
        }
        @keyframes printPhoto {
            0% { top: 120px; transform: translateX(-50%) scale(0.9); }
            100% { top: 320px; transform: translateX(-50%) scale(1) rotate(-5deg); }
        }

        .nav { position: absolute; top: 60px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; z-index: 10; pointer-events: auto; }
        .nav button { background: var(--cam-body); color: #fff; border: 2px solid #444; border-radius: 12px; padding: 6px 10px; cursor: pointer; box-shadow: 0 4px 10px rgba(0,0,0,0.2); }
        .nav button.active { background: var(--cam-accent); }
        .board-view { position: absolute; top: 160px; left: 50%; transform: translateX(-50%); width: 280px; max-width: 88vw; display: none; gap: 12px; }
        #captureLibrary { background: var(--cam-leather); border-radius: 20px; border: 3px solid #444; box-shadow: 0 10px 20px rgba(0,0,0,0.3), inset 0 2px 5px rgba(255,255,255,0.1); padding: 8px; margin-top: 12px; max-height: 140px; overflow: auto; }
        .lib-header { color: #ddd; font-size: 0.9rem; letter-spacing: 1px; text-transform: uppercase; text-align: center; margin-bottom: 8px; }
        .lib-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
        .lib-card { background: #fff; border-radius: 6px; padding: 4px 4px 14px 4px; box-shadow: 0 4px 10px rgba(0,0,0,0.2); position: relative; }
        .lib-card img { width: 100%; aspect-ratio: 1/1; object-fit: cover; transform: scaleX(-1); border-radius: 4px; }
        .lib-card img { -webkit-user-drag: none; }
        .pin-btn { position: absolute; bottom: 4px; right: 6px; border: none; border-radius: 10px; background: var(--cam-accent); color: #fff; font-size: 12px; padding: 2px 6px; cursor: pointer; }

        /* Photo Stack Styles */
        .photo-stack {
            position: relative;
            height: 120px;
            display: flex;
            justify-content: center;
            align-items: center;
            margin-top: 48px;
        }
        .stack-container {
            position: relative;
            width: 120px;
            height: 160px;
            overflow: visible;
        }
        .stack-card {
            position: absolute;
            width: 70px;
            height: 98px;
            padding: 6px 6px 24px 6px;
            background: #fff;
            border-radius: 0;
            box-shadow: 0 4px 12px rgba(0,0,0,0.2);
            cursor: grab;
            transition: transform 0.2s ease, box-shadow 0.2s ease;
        }
        .stack-card.draggable {
            cursor: grab;
        }
        .stack-card.draggable:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(0,0,0,0.25);
        }
        .stack-card.draggable:active {
            cursor: grabbing;
        }
        .stack-film {
            width: 100%;
            height: 70px;
            background: #111;
            overflow: hidden;
        }
        .stack-film img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            transform: scaleX(-1);
            border-radius: 0;
            display: block;
            -webkit-user-drag: none;
            pointer-events: none;
        }
        .stack-caption {
            position: absolute;
            bottom: 10px;
            left: 10px;
            right: 10px;
            height: 20px;
            border: none;
            border-bottom: 1px dashed #ccc;
            background: transparent;
            font-family: var(--font-main);
            font-size: 10px;
            color: #555;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            display: flex;
            align-items: flex-end;
            justify-content: center;
            padding-bottom: 0;
            pointer-events: none;
        }
        /* Stack cards with improved offsets for visible stacking */
        .stack-card:nth-child(1) { z-index: 10; top: 0; left: 0; }
        .stack-card:nth-child(2) { z-index: 8; top: 8px; left: 8px; }
        .stack-card:nth-child(3) { z-index: 6; top: 16px; left: 16px; }
        .stack-card:nth-child(4) { z-index: 4; top: 24px; left: 24px; }
        .stack-card:nth-child(5) { z-index: 2; top: 32px; left: 32px; }
        .stack-card:nth-child(n+6) { z-index: 0; top: 40px; left: 40px; }
        #pinBoard { position: relative; border-radius: 20px; border: 3px solid #444; box-shadow: 0 10px 20px rgba(0,0,0,0.3), inset 0 2px 5px rgba(255,255,255,0.1); padding: 16px 16px 20px; min-height: 420px; background-color: var(--body-bg); background-image: radial-gradient(#cec4ad 1px, transparent 1px); background-size: 20px 20px; }
        .pin-header { color: #ddd; font-size: 0.9rem; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 8px; text-align: center; }
        .pin-accent { position: absolute; height: 6px; background: linear-gradient(to right, #ff5e57 20%, #ffdd59 20% 40%, #0be881 40% 60%, #4bcffa 60% 80%, #806cdb 80%); opacity: 0.6; border-radius: 3px; display: none; }
        .pin-grid { display: none; }
        .pin-card { position: absolute; width: 70px; padding: 6px 6px 24px 6px; background: #fff; border-radius: 0; box-shadow: 0 4px 12px rgba(0,0,0,0.2); cursor: grab; }
        .pin-film { width: 100%; height: 70px; background: #111; overflow: hidden; }
        .pin-film img { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); border-radius: 0; display: block; }
        .pin-dot { position: absolute; top: -6px; left: 50%; transform: translateX(-50%); width: 12px; height: 12px; border-radius: 50%; background: #e74c3c; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.4); }
        .pin-caption { position: absolute; bottom: 10px; left: 10px; right: 10px; height: 20px; border: none; border-bottom: 1px dashed #ccc; background: transparent; font-family: var(--font-main); font-size: 10px; color: #555; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 0; }
        .pin-card.dragging { cursor: grabbing; box-shadow: 0 8px 18px rgba(0,0,0,0.3); }
        .pin-delete { position: absolute; top: 6px; right: 6px; width: 18px; height: 18px; border: none; border-radius: 50%; background: var(--cam-accent); color: #fff; font-size: 12px; line-height: 18px; text-align: center; cursor: pointer; }
        .board-view.visible { display: block; }
        /* Responsive breakpoints for mobile devices */
        @media (min-width: 320px) {
            .board-view { width: 300px; max-width: 90vw; }
        }

        @media (min-width: 375px) {
            .board-view { width: 340px; max-width: 92vw; }
            .pin-card { width: 80px; padding: 6px 6px 28px 6px; }
            .pin-film { height: 80px; }
            .stack-card { width: 80px; height: 112px; padding: 6px 6px 28px 6px; }
            .stack-film { height: 80px; }
        }

        @media (min-width: 414px) {
            .board-view { width: 380px; max-width: 94vw; }
        }

        @media (min-width: 768px) {
            .board-view { width: 520px; max-width: none; }
            .pin-card { width: 100px; padding: 8px 8px 32px 8px; }
            .pin-film { height: 100px; }
            .stack-card { width: 100px; height: 140px; padding: 8px 8px 32px 8px; }
            .stack-film { height: 100px; }
        }