@font-face {
    font-family: 'VCR OSD Mono';
    src: url('font/vcr.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

:root {
    /* Color Palette */
    --c-black: #000000;
    --c-zinc-950: #09090b;
    --c-zinc-900: #18181b;
    --c-zinc-800: #27272a;
    --c-zinc-700: #3f3f46;
    --c-zinc-600: #52525b;
    --c-zinc-500: #71717a;
    --c-zinc-400: #a1a1aa;
    --c-zinc-300: #d4d4d8;
    --c-white: #ffffff;
    
    --c-red-500: #ef4444;
    --c-red-600: #dc2626;
    --c-red-800: #991b1b;
    --c-red-900: #7f1d1d;
    --c-red-dim: rgba(127, 29, 29, 0.5);
    
    --c-amber-400: #fbbf24;
    --c-amber-500: #f59e0b;
    --c-amber-600: #d97706;
    --c-amber-900-dim: rgba(120, 53, 15, 0.2);
}

/* Reset & Base */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--c-black);
    color: var(--c-zinc-300);
    font-family: 'Arial Black', 'VCR OSD Mono', monospace;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    user-select: none;
    -webkit-user-select: none;
    overscroll-behavior: none
}

/* Utilities */
.hidden { display: none !important; }
.relative { position: relative; }
.absolute { position: absolute; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.h-full { height: 100%; }
.inset-0 { top: 0; right: 0; bottom: 0; left: 0; }
.z-50 { z-index: 50; }

/* Main Layout */
.app-main {
    position: relative;
    width: 100%;
    height: 100%;
    background-color: var(--c-zinc-950);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Top Bar */
.app-title {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 20;
    opacity: 0.5;
    pointer-events: none;
    color: var(--c-zinc-500);
    font-size: 0.75rem;
    font-weight: bold;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    display: none;
}

@media (min-width: 768px) {
    .app-title { display: block; }
    .btn-flash { left: 5rem !important; }
}

.btn-icon {
    position: absolute;
    top: 1rem;
    z-index: 50;
    color: var(--c-zinc-500);
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    transition: color 0.2s;
    height: 50px;
}
.btn-icon:active { color: var(--c-white); }
.btn-icon svg { display: block; }

.btn-flash { left: 1rem; display: flex; align-items: center; gap: 0.25rem; }
.btn-settings { right: 1rem; }

.flash-icon-wrapper { position: relative; width: 1.5rem; height: 1.5rem; display: flex; align-items: center; justify-content: center; }
.flash-slash { position: absolute; width: 2px; height: 24px; background-color: var(--c-zinc-500); transform: rotate(45deg); }
.flash-auto-badge { 
    position: absolute; bottom: -2px; right: -2px; 
    font-size: 8px; font-weight: bold; color: var(--c-zinc-400); 
    background: rgba(0,0,0,0.5); padding: 0 2px; border-radius: 2px; 
}

/* Modals */
.modal-overlay {
    position: absolute; inset: 0; z-index: 61;
    background-color: transparent;
    display: flex; flex-direction: column;
    padding: 1.5rem;
    overflow-y: auto;
}

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.modal-title { font-size: 1.25rem; font-weight: bold; color: var(--c-zinc-300); margin: 0; font-family: 'VCR OSD Mono', monospace; }
.btn-close { 
    color: blue;
    font-weight: bold;
    padding: 0.5rem 1rem;
    border: 1px solid var(--c-zinc-300);
    background: var(--c-zinc-300);
    cursor: pointer;
    border-radius: 0;
}
.btn-close:active { color: var(--c-white); border-color: var(--c-zinc-500); }

.settings-list { display: grid; gap: 1.5rem; max-width: 28rem; margin: 0 auto; width: 100%; padding-bottom: 2rem; background: blue; border: 10px outset darkblue; }

/* Dynamic Settings Items */
.setting-item {
    display: flex; flex-direction: column; gap: 0.5rem;
    padding: 0.5rem; border-bottom: 1px solid var(--c-zinc-800);
}
.setting-label-row { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--c-zinc-400); }
.setting-select {
    background-color: var(--c-zinc-300);
    color: blue;
    font-size: 0.75rem;
    padding: 0.25rem;
    border-radius: 0;
    border: 1px solid var(--c-zinc-600);
    outline: none;
}
.btn-reset {
    width: 100%; padding: 1rem; margin-top: 1rem;
    font-size: 0.75rem; font-weight: bold; letter-spacing: 0.1em;
    color: var(--c-amber-400);
    border: var(--c-amber-400);
    background: red;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.2s;
}
.btn-reset:active {
    color: var(--c-red-500);
    border-color: var(--c-red-dim);
    background-color: rgba(127, 29, 29, 0.1);
}

/* Backups UI */
.backups-section {
    max-width: 28rem; margin: 2rem auto; width: 100%;
    border-top: 1px solid var(--c-zinc-800);
    padding-top: 1rem;
}
.modal-subtitle {
    font-size: 0.75rem; color: var(--c-zinc-500);
    margin-bottom: 1rem; letter-spacing: 0.1em;
    text-transform: uppercase;
}
.backups-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}
.backup-item {
    aspect-ratio: 1;
    background-color: var(--c-zinc-800);
    cursor: pointer;
    overflow: hidden;
    position: relative;
    border: 1px solid transparent;
}
.backup-item:active { border-color: var(--c-amber-500); }
.backup-thumb {
    width: 100%; height: 100%; object-fit: cover;
}
.backup-video-icon {
    position: absolute; bottom: 2px; right: 2px;
    width: 12px; height: 12px;
    background: red; border-radius: 50%;
    border: 1px solid white;
}
.btn-view-backups {
    width: 100%; padding: 1rem; margin-top: 2rem;
    background: var(--c-zinc-800); color: var(--c-zinc-300);
    border: 1px solid var(--c-zinc-700);
    font-weight: bold; cursor: pointer;
}

/* Viewfinder */
.viewfinder {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    height: calc(100vh - 200px);
    top: 50px;
    position: fixed;
}

/* Aspect Ratios */
.ratio-4-3 { aspect-ratio: 4/3; }
.ratio-3-4 { aspect-ratio: 3/4; }
.ratio-16-9 { aspect-ratio: 16/9; }
.ratio-9-16 { aspect-ratio: 9/16; }
.ratio-1-1 { aspect-ratio: 1/1; }

.error-overlay {
    position: absolute; inset: 0; z-index: 50;
    display: flex; align-items: center; justify-content: center;
    background-color: var(--c-zinc-900);
    color: var(--c-zinc-500);
    padding: 1.5rem; text-align: center;
}
.error-box { display: flex; flex-direction: column; align-items: center; }
.error-title { font-size: 1.25rem; font-weight: bold; margin-bottom: 0.5rem; }
.error-msg { font-size: 0.75rem; border: 1px solid var(--c-zinc-700); padding: 0.5rem; }

.canvas-container { position: absolute; inset: 0; width: 100%; height: 100%; background: black; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.pixelated {
    width: 100%; height: 100%; object-fit: contain;
}

.indicator-rec {
    position: absolute; top: 1rem; left: 50%; transform: translateX(-50%); z-index: 50;
    display: flex; align-items: center; gap: 0.5rem;
    background-color: rgba(0,0,0,0.5);
    border: 1px solid var(--c-red-dim);
}
.rec-dot { width: 0.75rem; height: 0.75rem; background-color: var(--c-red-600); }
.rec-text { color: var(--c-red-500); font-weight: bold; font-size: 0.75rem; letter-spacing: 0.05em; }

.indicator-zoom {
    position: absolute; bottom: 1rem; right: 1rem; z-index: 40;
    font-size: 0.75rem; font-weight: bold;
    color: rgba(234, 179, 8, 0.5);
    border: 1px solid rgba(234, 179, 8, 0.3);
    padding: 0.25rem 0.5rem;
    background-color: rgba(0,0,0,0.5);
}

/* Flash Overlay - Full Screen */
.flash-overlay {
    position: fixed; /* Changed from absolute to fixed */
    inset: 0; 
    background: white; 
    z-index: 9999; /* Highest Z-Index */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease-out; /* Slower fade */
}
.flash-overlay.active {
    opacity: 1;
    transition: none; /* Instant on */
}

/* Controls */
.controls-area {
    width: 100%;
    padding: 0 2rem;
    display: flex; justify-content: space-between; align-items: center;
    z-index: 50;
    position: fixed;
    bottom: calc(env(safe-area-inset-bottom) + 10px);
}

.counter-display {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    opacity: 0.3; width: 4rem;
    font-family: 'Barlow Condensed', monospace;
}
.counter-text {
    font-size: 1.25rem; font-weight: bold; letter-spacing: 0.1em;
    color: var(--c-zinc-500); user-select: none;
}

/* Shutter Button */
.shutter-wrapper { position: relative; display: flex; flex-direction: column; align-items: center; }

.shutter-btn {
    position: relative; outline: none; background: none; border: none; padding: 0;
    cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent;
}
.shutter-outer {
    width: 5rem;
    height: 5rem;
    background-color: var(--c-amber-400);
    border: 4px solid var(--c-zinc-700);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s;
}
.shutter-inner {
    width: 4rem;
    height: 4rem;
    border-radius: 0;
    background-color: blue;
    transition: all 0.3s;
}

/* Shutter States defined by classes toggled in JS */
.shutter-pressed .shutter-outer { transform: scale(0.95); }
.shutter-recording .shutter-inner {
    background-color: var(--c-red-500);
    border-color: rgba(248, 113, 113, 0.5);
    transform: scale(0.75);
}
.shutter-recording .shutter-outer { transform: scale(0.95); }

.lock-hint {
    position: absolute; top: -4rem;
    display: flex; flex-direction: column; align-items: center;
    opacity: 0.7;
    pointer-events: none;
}
.lock-icon { color: var(--c-zinc-500); margin-bottom: 0.25rem; }
.lock-text { font-size: 10px; color: var(--c-zinc-500); letter-spacing: 0.1em; font-weight: bold; }

@keyframes bounce {
    0%, 100% { transform: translateY(-25%); animation-timing-function: cubic-bezier(0.8,0,1,1); }
    50% { transform: none; animation-timing-function: cubic-bezier(0,0,0.2,1); }
}

.btn-stop-lock {
    display: flex; flex-direction: column; align-items: center;
    background: none; border: none; cursor: pointer;
}
.stop-outer {
    width: 5rem; height: 5rem;
    background-color: var(--c-zinc-800);
    border: 4px solid var(--c-zinc-700);
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
}
.stop-inner { width: 2rem; height: 2rem; background-color: var(--c-zinc-300); }
.stop-label { position: absolute; bottom: -2rem; width: 100%; text-align: center; font-size: 0.75rem; color: var(--c-zinc-500); font-weight: bold; letter-spacing: 0.1em; }

/* Review Controls */
.controls-review { display: flex; gap: 1rem; }
.btn-action {
    height: 3rem; padding: 0 1.5rem;
    font-weight: bold; font-size: 0.875rem; letter-spacing: 0.05em;
    cursor: pointer; transition: background 0.2s;
}
.btn-trash {
    background-color: var(--c-zinc-900);
    color: var(--c-zinc-400);
    border: 1px solid var(--c-zinc-700);
}
.btn-trash:active { color: var(--c-white); background-color: var(--c-zinc-800); }

.btn-save {
    background-color: var(--c-amber-600);
    color: var(--c-zinc-950);
    border: 1px solid var(--c-amber-500);
    box-shadow: 0 10px 15px -3px var(--c-amber-900-dim);
}
.btn-save:active { background-color: var(--c-amber-500); }

.flip-wrapper { width: 4rem; display: flex; justify-content: center; }
.btn-flip {
    padding: 0.75rem; color: var(--c-zinc-600);
    background: none; border: none; cursor: pointer;
    transition: color 0.2s;
}
.btn-flip:active { color: var(--c-zinc-300); }

/* Color States */
.color-amber { color: var(--c-amber-400); }
.color-zinc { color: var(--c-zinc-600); }

/* Range Slider */
input[type=range] {
    -webkit-appearance: none; 
    background: transparent; 
    width: 100%;
}
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 16px;
    width: 16px;
    border-radius: 0;
    background: var(--c-amber-500);
    cursor: pointer;
    margin-top: -6px; 
}
input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: var(--c-zinc-700);
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}
.animate-blink { animation: blink 1s infinite; }

.safe-top { padding-top: env(safe-area-inset-top); }
.safe-bottom { padding-bottom: env(safe-area-inset-bottom); }

/* LANDSCAPE ORIENTATION */
@media (orientation: landscape) {
    .app-main {
        flex-direction: row;
        justify-content: space-between;
    }

    .viewfinder {
        flex: 1;
        height: 100vh;
        margin: 0;
        max-width: calc(100vw - 130px);
        position: fixed;
        top: 0;
        right: 130px;
    }

    .controls-area {
        margin-top: 0;
        width: 8rem;
        max-width: none;
        height: 100%;
        padding: 2rem 1rem;
        flex-direction: column;
        justify-content: space-around;
        border-left: 1px solid var(--c-zinc-900);
        bottom: 0;
        right: 0;
        background: var(--c-zinc-900);
    }

    /* Adjust Lock Hint direction or position for landscape */
    .lock-hint {
        top: 50%;
        left: -4rem;
        transform: translateY(-50%) rotate(-90deg);
    }
    
    @keyframes bounceHorizontal {
        0%, 100% { transform: translateY(-50%) rotate(-90deg) translateX(25%); animation-timing-function: cubic-bezier(0.8,0,1,1); }
        50% { transform: translateY(-50%) rotate(-90deg) translateX(0); animation-timing-function: cubic-bezier(0,0,0.2,1); }
    }

    /* Review controls vertical stack */
    .controls-review {
        flex-direction: column;
        gap: 1rem;
        width: 100%;
    }
    .btn-action {
        width: 100%;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 0;
    }
    
    .btn-settings {
        right: 9rem; /* 8rem sidebar + 1rem gap */
    }
}
