/* 
=================================================================
PFI Replay Local - Modern Stylesheet
Inspired by a modern, dark-themed media gallery UI.
Font: SF Pro Text (via system-ui)
=================================================================
*/

/* Font Definitions */
@font-face {
    font-family: 'SF Pro Text';
    src: url('fonts/sf-pro-text-regular-webfont.woff2') format('woff2');
    font-weight: 400; /* Regular */
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'SF Pro Text';
    src: url('fonts/sf-pro-text-medium-webfont.woff2') format('woff2');
    font-weight: 500; /* Medium */
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'SF Pro Text';
    src: url('fonts/sf-pro-text-semibold-webfont.woff2') format('woff2');
    font-weight: 600; /* Semibold */
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'SF Pro Text';
    src: url('fonts/sf-pro-text-bold-webfont.woff2') format('woff2');
    font-weight: 700; /* Bold */
    font-style: normal;
    font-display: swap;
}


/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* Disable context menu on long press */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Prevent browser zoom while allowing custom video zoom and mobile controls */
html, body {
    touch-action: manipulation; /* Allow single-finger gestures but prevent multi-finger zoom */
    -webkit-text-size-adjust: 100%; /* Prevent auto-zoom on form focus */
    overscroll-behavior: none; /* Prevent bounce scroll which can interfere with zoom */
}

html {
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'SF Pro Text', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    background: #000;
    color: #EAEAEA;
    min-height: 100vh;
    width: 100vw;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100vw;
    margin: 0;
    padding: 0;
}

/* Header */
.header {
    position: relative;
    z-index: 100;
    background: transparent;
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
}

.header-right {
    display: flex;
    align-items: center;
}

.layout-nav {
    display: flex;
    gap: 8px;
}

.nav-link {
    padding: 8px 16px;
    border-radius: 8px;
    text-decoration: none;
    color: #EAEAEA;
    background-color: #3A3A3C;
    font-size: 0.875rem;
    font-weight: 600;
    transition: background-color 0.2s ease;
}

.nav-link:hover {
    background-color: #4A4A4C;
}

.nav-link.active {
    background-color: #4A90E2;
    color: #fff;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-logo {
    height: 36px; /* Adjusted for immersive view */
    width: auto;
}

.header h1 {
    font-size: 1.75rem; /* 28px */
    font-weight: 600;
    letter-spacing: -0.5px;
}

.header h1 i {
    margin-right: 12px;
    color: #4A90E2; /* A subtle, professional blue */
}

/* Status Indicators */
.status {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem; /* 12px */
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid transparent;
}

.status.online {
    background-color: rgba(46, 204, 113, 0.2);
    border-color: #2ECC71;
    color: #2ECC71;
}

.status.offline {
    background-color: rgba(142, 142, 147, 0.2);
    border-color: #8E8E93;
    color: #8E8E93;
}

#connectionStatus {
    padding: 4px 7px;
    border-radius: 12px;
    font-size: 0.45rem;
    letter-spacing: 0.3px;
    position: relative;
    bottom: 3px;
}


/* Controls */
.controls {
    display: none;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem; /* 14px */
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: #3A3A3C;
    color: #EAEAEA;
}

.btn:hover {
    background-color: #4A4A4C;
}

.btn:active {
    transform: scale(0.98);
}

/* Streams Container */
.streams-container {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    position: relative;
    width: 100vw;
    max-width: 100vw;
    margin: 0;
    padding: 0;
}

.stream-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 2px;
    background-color: #000;
    flex: 1;
}

.stream-card {
    position: relative;
    background: #000;
    cursor: pointer;
}

.stream-grid.fullscreen-active .stream-card:not(.fullscreen) {
    display: none;
}

.stream-card.fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9999 !important;
    background: #000 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
}

.fullscreen .header, .stream-card.fullscreen .header {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    z-index: 10000 !important;
    background: transparent !important;
}

/* All Cameras Grid Styles */
.all-cameras-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 4px;
    width: 100%;
    height: 100%;
    position: relative;
}

/* 4-Camera Layout Styles */
.stream-grid.four-cameras {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
}

/* Single Camera Fullscreen Layout */
.stream-grid.single-camera {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    height: 100%;
    min-height: 0;
    width: 100vw;
    max-width: 100vw;
    margin: 0;
    padding: 0;
}

.all-camera-item {
    position: relative;
    background: #1a1a1a;
    border-radius: 8px;
    overflow: hidden;
}

.all-camera-item video {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Preserve aspect ratio for camera grid items */
    background: #000;
}

.camera-label {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    z-index: 10;
}

/* Fullscreen All Cameras */
.stream-card.fullscreen[data-camera="all-cameras"] .all-cameras-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 8px;
    padding: 16px;
}

.stream-card.fullscreen[data-camera="all-cameras"] .all-camera-item {
    border-radius: 12px;
}

.stream-card.fullscreen[data-camera="all-cameras"] .camera-label {
    font-size: 1rem;
    padding: 8px 12px;
    border-radius: 6px;
}

.stream-card.fullscreen .video-container video {
    object-fit: contain;
}

.stream-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 20%;
    background: linear-gradient(to bottom, rgba(0,0,0,0.6), transparent);
    z-index: 1;
    pointer-events: none;
}

.stream-header {
    position: absolute;
    top: 1px;
    right: 7px;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 10px;
}

.stream-header h3 {
    font-size: 0.5rem;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0,0,0,0.7);
    color: white;
    position: relative;
    top: 1px;
}

.stream-header .status {
    padding: 3px 6px;
    border-radius: 10px;
    font-size: 0.375rem; /* 6px */
    letter-spacing: 0.25px;
    position: relative;
    bottom: 3px;
}

.stream-header h3 i {
    margin-right: 8px;
}

.stream-info {
    display: none;
}

.video-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-width: 100vw;
    max-height: 100vh;
    overflow: hidden;
}

.video-container video {
    width: 100%;
    height: 100%;
    max-width: 100vw;
    max-height: 100vh;
    object-fit: contain; /* Always preserve aspect ratio, never distort */
}

/* Replay & Record Buttons */
.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    visibility: hidden;
    color: white;
}

.replay-controls {
    display: flex;
    gap: 10px;
}

.replay-btn,
.record-btn {
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: rgba(255, 255, 255, 0.15);
    color: white;
    backdrop-filter: blur(10px);
}

.replay-btn:hover,
.record-btn:hover {
    background-color: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

.record-btn.recording {
    background: #E53E3E; /* Red for recording */
    color: white;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(229, 62, 62, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(229, 62, 62, 0); }
    100% { box-shadow: 0 0 0 0 rgba(229, 62, 62, 0); }
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
}

.modal-content {
    background: #1C1C1E;
    margin: 5% auto;
    padding: 0;
    border-radius: 12px;
    border: 1px solid #3A3A3C;
    width: 90%;
    max-width: 1000px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid #3A3A3C;
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.close {
    color: #8E8E93;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s ease;
}

.close:hover {
    color: #EAEAEA;
}

.modal-body {
    padding: 24px;
}

/* Replay Timeline */
.replay-timeline,
.timeline-slider,
.timeline-header,
.timeline-controls {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.timeline-header, .timeline-controls {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
}

.timeline-slider input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #3A3A3C;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.timeline-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #4A90E2;
    cursor: pointer;
}

.timeline-slider input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #4A90E2;
    cursor: pointer;
    border: none;
}

.timeline-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    color: #8E8E93;
}

.replay-video-container {
    width: 100%;
    height: 400px;
    background: #000;
    border-radius: 10px;
    overflow: hidden;
}

.replay-video-container video {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Preserve aspect ratio in replay modal */
}


/* Fullscreen styles */
body.fullscreen-active {
    overflow: hidden;
}

.fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9999 !important;
    background: #000 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 !important;
    padding: 0 !important;
}

.fullscreen .stream-grid {
    height: calc(100vh - 48px);
}


/* Responsive Design */
@media (min-width: 1024px) and (hover: hover) {
    html, body {
        height: 100%;
        width: 100%;
        overflow: hidden;
        margin: 0;
        padding: 0;
    }

    body {
        min-height: auto;
        display: block;
    }

    .container {
        max-width: none;
        width: 100vw;
        height: 100vh;
        position: relative;
        display: block;
        flex: auto;
        margin: 0;
        padding: 0;
    }

    .header {
        position: absolute;
        top: 0;
        left: 0;
        width: 100vw;
        padding: 24px;
        z-index: 100;
    }

    .streams-container {
        height: 100vh;
        width: 100vw;
        flex: auto;
        display: block;
        margin: 0;
        padding: 0;
    }
    
    .stream-grid {
        height: 100vh;
        width: 100vw;
        flex: auto;
    }
    
    .stream-card {
        aspect-ratio: auto;
        width: 100vw;
        height: 100vh;
    }
    
    .video-container {
        width: 100vw;
        height: 100vh;
    }
    
    .video-container video {
        width: 100vw;
        height: 100vh;
        object-fit: contain; /* Always preserve aspect ratio, never distort */
    }

    .stream-header {
        top: 0;
        left: 0;
        right: auto;
        width: 100%;
        padding: 16px;
        justify-content: flex-end;
        transform: none;
    }

    .stream-header h3 {
        font-size: 1rem;
    }

    .stream-header .status {
        padding: 6px 12px;
        border-radius: 20px;
        font-size: 0.75rem; /* 12px */
        letter-spacing: 0.5px;
        position: static;
    }
}

@media (max-width: 1200px) {
    .stream-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(2, 1fr);
        height: auto;
    }
    
    .stream-grid.four-cameras {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .container {
        padding: 16px;
    }
    .header, .controls {
        flex-direction: column;
        gap: 16px;
        align-items: stretch;
    }
    .stream-grid {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(4, 1fr);
    }
    .stream-grid.four-cameras {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(4, 1fr);
    }
    .stream-grid.single-camera {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr;
    }
    .stream-card {
        height: 40vh;
    }
    .layout-nav {
        flex-direction: column;
        gap: 4px;
    }
}

/* Play Overlay for Autoplay Fallback */
.play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 3rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 10;
    visibility: hidden;
    font-family: 'SF Pro Text', -apple-system, BlinkMacSystemFont, sans-serif;
    text-align: center;
    gap: 15px;
    line-height: 1.4;
}

.play-overlay.visible {
    opacity: 1;
    visibility: visible;
}
.play-overlay:hover {
    color: white;
}

/* --- All Cameras Fullscreen Layout Fix --- */
.allcameras-page .container {
    display: flex !important;
    flex-direction: column !important;
    min-height: 100vh !important;
    height: 100vh !important;
    width: 100vw !important;
    max-width: 100vw !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
}

.allcameras-page .streams-container {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: 100vh !important;
    width: 100vw !important;
    max-width: 100vw !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    position: relative !important;
}

.allcameras-page .stream-grid.single-camera {
    height: 100% !important;
    min-height: 0 !important;
    display: flex !important;
    align-items: stretch !important;
    flex: 1 1 auto !important;
}

.allcameras-page .stream-card.fullscreen {
    z-index: 1 !important;
    height: 100% !important;
    min-height: 0 !important;
    background: #000;
    flex: 1 1 auto !important;
    display: flex !important;
}

.allcameras-page .video-container,
.allcameras-page .video-container video {
    z-index: 1 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #000;
    border: none !important;
    outline: none !important;
    display: block !important;
    flex: 1 1 auto !important;
    cursor: default !important;
    overflow: hidden !important;
}

/* Always preserve aspect ratio across all devices */
.allcameras-page .video-container video {
    object-fit: contain !important; /* Always preserve aspect ratio, never distort */
}

#global-header-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    z-index: 10001;
    pointer-events: none;
}
.header-gradient-bar {
    width: 100vw;
    height: 6px;
    background: linear-gradient(90deg, #4A90E2 0%, #FFD600 100%);
    pointer-events: none;
}
.header-global {
    width: 100vw;
    display: flex;
    align-items: center;
    padding: 16px 0 0 16px;
    background: transparent;
    pointer-events: auto;
}

/* Remove padding-top so header overlays content */
body, .container, .streams-container {
    padding-top: 0 !important;
}

/* Touch-Friendly Control Bar */
.touch-control-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    background: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.8) 100%);
    border-radius: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 30px 40px 40px 40px; /* Back to original padding */
    pointer-events: auto;
    min-height: 200px;
    align-items: stretch; /* Ensure all children stretch */
    /* Mobile responsive animations */
    transition: opacity 0.3s ease, transform 0.3s ease;
    opacity: 1;
    transform: translateY(0);
}

/* Hide controls initially on mobile screens */
@media (max-width: 1024px) and (pointer: coarse), 
       (max-width: 768px) {
    .touch-control-bar {
        opacity: 0 !important;
        pointer-events: none !important;
        transform: translateY(100%) !important;
        visibility: hidden !important;
    }
    
    /* Frame timer always visible - removed hiding rule */
}

.timeline-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    width: 100%;
    max-width: 100vw;
    overflow: hidden;
}

/* Mobile timeline adjustments */
@media (max-width: 768px) {
    .timeline-section {
        gap: 10px;
        padding: 0 5px;
    }
}

@media (max-width: 480px) {
    .timeline-section {
        gap: 5px;
        padding: 0 2px;
    }
}

/* Portrait-specific adjustments to prevent timeline overlap */
@media (max-width: 1024px) and (orientation: portrait) {
    .timeline-section {
        margin-bottom: 15px; /* Add space below timeline */
        padding-bottom: 10px; /* Extra padding to separate from other controls */
    }
    
    /* 50% smaller controls for portrait */
    .touch-control-bar {
        padding: 10px 7px 12px 7px; /* 50% of 20px 15px 25px 15px */
        min-height: 70px; /* 50% of 140px */
        gap: 6px; /* 50% of 12px */
    }
    
    .touch-btn {
        min-height: 27px; /* 50% of 55px */
        min-width: 32px; /* 50% of 65px */
        padding: 4px 5px; /* 50% of 8px 10px */
        gap: 2px; /* 50% of 4px */
        font-size: 0.35rem; /* 50% of 0.7rem */
    }
    
    .touch-btn i {
        font-size: 0.6rem; /* 50% of 1.2rem */
    }
    
    .touch-btn span {
        font-size: 0.32rem; /* 50% of 0.65rem */
        line-height: 1;
    }
    
    .button-group {
        gap: 3px; /* 50% of 6px */
    }
    
    #replayTimelineSlider {
        height: 20px; /* 50% of 40px */
        margin: 2px 0; /* 50% of 5px 0 */
        max-width: 60%;
    }
    
    #replayTimelineSlider::-webkit-slider-thumb {
        width: 8px; /* 50% of 16px */
        height: 20px; /* Match slider height */
    }
    
    #replayTimelineSlider::-webkit-slider-runnable-track {
        height: 20px; /* Match slider height */
    }
    
    #replayTimelineSlider::-moz-range-thumb {
        width: 7px; /* 50% of 14px */
        height: 20px; /* Match slider height */
    }
}

@media (max-width: 768px) and (orientation: portrait) {
    .timeline-section {
        margin-bottom: 20px; /* More space for smaller screens */
        padding-bottom: 15px;
    }
    
    /* Even smaller controls for 768px portrait */
    .touch-control-bar {
        padding: 7px 5px 10px 5px; /* 50% of 15px 10px 20px 10px */
        min-height: 60px !important; /* 50% of 120px */
        gap: 5px; /* 50% of 10px */
    }
    
    .touch-btn {
        min-height: 25px; /* 50% of 50px */
        min-width: 27px; /* 50% of 55px */
        padding: 3px 4px; /* 50% of 6px 8px */
        gap: 1px; /* 50% of 3px */
        font-size: 0.3rem; /* 50% of 0.6rem */
    }
    
    .touch-btn i {
        font-size: 0.5rem; /* 50% of 1rem */
    }
    
    .touch-btn span {
        font-size: 0.27rem; /* 50% of 0.55rem */
        line-height: 1;
    }
    
    .button-group {
        gap: 3px; /* 50% of 6px */
    }
    
    #replayTimelineSlider {
        height: 17px; /* 50% of 35px */
        max-width: 55%; /* Slightly smaller */
    }
    
    #replayTimelineSlider::-webkit-slider-thumb {
        width: 7px; /* 50% of 14px */
        height: 17px; /* Match slider height */
    }
    
    #replayTimelineSlider::-webkit-slider-runnable-track {
        height: 17px; /* Match slider height */
    }
    
    #replayTimelineSlider::-moz-range-thumb {
        width: 6px; /* 50% of 12px */
        height: 17px; /* Match slider height */
    }
}

@media (max-width: 480px) and (orientation: portrait) {
    .timeline-section {
        margin-bottom: 25px; /* Even more space for very small screens */
        padding-bottom: 20px;
    }
    
    /* Smallest controls for 480px portrait */
    .touch-control-bar {
        padding: 6px 4px 9px 4px; /* 50% of 12px 8px 18px 8px */
        min-height: 50px !important; /* 50% of 100px */
        gap: 4px; /* 50% of 8px */
    }
    
    .touch-btn {
        min-height: 22px; /* 50% of 45px */
        min-width: 25px; /* 50% of 50px */
        padding: 2px 3px; /* 50% of 4px 6px */
        gap: 1px; /* 50% of 2px */
        font-size: 0.27rem; /* 50% of 0.55rem */
    }
    
    .touch-btn i {
        font-size: 0.45rem; /* 50% of 0.9rem */
    }
    
    .touch-btn span {
        font-size: 0.25rem; /* 50% of 0.5rem */
        line-height: 1;
    }
    
    .button-group {
        gap: 2px; /* 50% of 4px */
    }
    
    #replayTimelineSlider {
        height: 15px; /* 50% of 30px */
        max-width: 50%; /* 50% of previous size */
    }
    
    #replayTimelineSlider::-webkit-slider-thumb {
        width: 6px; /* 50% of 12px */
        height: 15px; /* Match slider height */
    }
    
    #replayTimelineSlider::-webkit-slider-runnable-track {
        height: 15px; /* Match slider height */
    }
    
    #replayTimelineSlider::-moz-range-thumb {
        width: 5px; /* 50% of 10px */
        height: 15px; /* Match slider height */
    }
}

/* Single unified button row - ALL buttons on same baseline */
.touch-buttons-section,
.centered-navigation-section {
    position: fixed !important;
    bottom: 20px !important; /* 20px from viewport bottom */
    display: flex !important;
    align-items: flex-end !important;
    pointer-events: auto !important;
    z-index: 10000 !important;
}

.touch-buttons-section {
    left: 20px !important;
    right: 20px !important;
    justify-content: space-between !important;
    width: auto !important;
}

.centered-navigation-section {
    left: 50% !important;
    transform: translateX(-50%) !important;
    justify-content: center !important;
    width: auto !important;
}

/* Mobile specific adjustments for better spacing */
@media (max-width: 768px) {
    .touch-buttons-section {
        left: 10px !important;
        right: 10px !important;
    }
    
    .centered-navigation-section {
        /* Ensure center controls don't overlap with side controls */
        max-width: calc(100vw - 200px);
    }
}

@media (max-width: 480px) {
    .touch-buttons-section {
        left: 5px !important;
        right: 5px !important;
    }
    
    .centered-navigation-section {
        /* Even more conservative spacing for very small screens */
        max-width: calc(100vw - 150px);
    }
}

.button-group {
    display: flex;
    align-items: flex-end;
    gap: 15px;
    pointer-events: auto;
}

/* Timeline slider is now hidden - using button navigation only */
.timeline-section {
    display: none !important;
}

#replayTimelineSlider {
    display: none !important;
}

#replayTimelineSlider::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    width: 13px;
    height: 32px;
    border-radius: 3px;
    background: #FFFFFF;
    background-image: 
        linear-gradient(to bottom, transparent 10px, #CCCCCC 10px, #CCCCCC 22px, transparent 22px),
        linear-gradient(to bottom, transparent 10px, #CCCCCC 10px, #CCCCCC 22px, transparent 22px),
        linear-gradient(to bottom, transparent 10px, #CCCCCC 10px, #CCCCCC 22px, transparent 22px);
    background-size: 1px 32px, 1px 32px, 1px 32px;
    background-position: 4px 0, 6px 0, 8px 0;
    background-repeat: no-repeat;
    border: none;
    box-shadow: none;
    outline: none;
    cursor: pointer;
}

/* Slow Motion Indicator */
.slow-motion-indicator {
    position: absolute;
    top: 20px;
    right: 20px;
    background: transparent;
    color: white;
    padding: 8px 16px;
    border: 1px solid white;
    border-radius: 6px;
    font-family: 'SF Pro Text', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 600;
    font-size: 14px;
    z-index: 10;
    display: none;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}


@keyframes fadeInOut {
    0% { opacity: 0; transform: translate(-50%, 50%) scale(0.9); }
    20% { opacity: 1; transform: translate(-50%, 50%) scale(1); }
    80% { opacity: 1; transform: translate(-50%, 50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, 50%) scale(0.9); }
}

#replayTimelineSlider::-moz-range-thumb {
    width: 10px;
    height: 32px;
    border-radius: 3px;
    background: #FFFFFF;
    border: none;
    box-shadow: none;
    outline: none;
    cursor: pointer;
}

#replayTimelineSlider::-ms-thumb {
    width: 10px;
    height: 32px;
    border-radius: 3px;
    background: #FFFFFF;
    border: none;
    box-shadow: none;
    outline: none;
    cursor: pointer;
}

#replayTimelineSlider::-webkit-slider-runnable-track {
    height: 32px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    box-shadow: none;
    outline: none;
    border-radius: 2px;
}

#replayTimelineSlider::-ms-fill-lower,
#replayTimelineSlider::-ms-fill-upper {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    box-shadow: none;
    outline: none;
    border-radius: 2px;
}

#replayTimelineSlider::-moz-range-track {
    height: 32px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    box-shadow: none;
    outline: none;
    border-radius: 2px;
}

#goLiveBtn, .live-btn {
    font-family: 'SF Pro Text', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 0.55rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5.5px;
    height: 19.8px;
    padding: 0 8.8px;
    border-radius: 8px;
    letter-spacing: 0.15px;
    white-space: nowrap;
    min-width: auto;
    transition: all 0.2s ease;
    cursor: pointer;
    margin-left: 4px;
    flex-shrink: 0;
}
#goLiveBtn.live-btn-live, .live-btn-live {
    background: transparent;
    color: #fff;
    border: 1px solid #666;
}
.live-btn-live::after {
    content: '';
    width: 8px;
    height: 8px;
    background: #FF3B30;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
    animation: pulse-live 1.5s ease-in-out infinite;
}

/* Remove the pseudo-element for the main touch button version */
#goLiveBtn.live-btn-live::after {
    display: none;
}
@keyframes pulse-live {
    0% { 
        opacity: 1;
    }
    50% { 
        opacity: 0.3;
    }
    100% { 
        opacity: 1;
    }
}
#goLiveBtn.live-btn-replay, .live-btn-replay {
    background: #FFFFFF;
    color: #000;
    border: 2px solid #FFFFFF;
}
#goLiveBtn.live-btn-replay::after, .live-btn-replay::after {
    display: none;
}
.frame-timer-container {
    position: fixed;
    top: 20px; /* Position 20px from the top */
    left: 50%;
    transform: translateX(-50%); /* Center horizontally */
    z-index: 10001; /* Increased z-index to ensure it's always on top */
    display: inline-flex;
    align-items: center;
    gap: 6px; /* Increased gap between date and AM/PM */
    justify-content: center; /* Center content within container */
    text-align: center;
    background: rgba(0, 0, 0, 0.8); /* Stronger background opacity */
    padding: 10px 60px 10px 20px; /* Asymmetric padding for optimal coverage */
    border-radius: 8px; /* Slightly larger border radius */
    backdrop-filter: blur(15px); /* Enhanced blur effect */
    white-space: nowrap; /* Prevent text wrapping */
    pointer-events: none; /* Don't interfere with other interactions */
    /* Always visible - no transitions or opacity changes */
    opacity: 1 !important;
    visibility: visible !important;
    min-width: max-content; /* Ensure background expands to fit content */
    width: fit-content; /* Ensure proper width calculation */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3); /* Add subtle shadow for depth */
}

/* Mobile positioning: different for portrait vs landscape */
@media (max-width: 1024px) and (orientation: portrait) {
    .frame-timer-container {
        top: auto;
        bottom: 180px; /* Above the controls when visible */
        left: 50%;
        right: auto;
        transform: translateX(-50%); /* Center horizontally */
        background: rgba(0, 0, 0, 0.8); /* Stronger background */
        padding: 10px 60px 10px 20px; /* Asymmetric padding for optimal coverage */
        border-radius: 8px; /* Larger border radius */
        backdrop-filter: blur(15px); /* Enhanced blur */
        min-width: max-content; /* Ensure background expands to fit content */
        width: fit-content; /* Ensure proper width calculation */
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3); /* Add shadow */
    }
}

@media (max-width: 1024px) and (orientation: landscape) {
    .frame-timer-container {
        top: 15px;
        bottom: auto;
        left: auto;
        right: 20px;
        transform: none;
        background: rgba(0, 0, 0, 0.8); /* Stronger background */
        padding: 8px 50px 8px 16px; /* Proportional asymmetric padding for landscape */
        border-radius: 8px; /* Larger border radius */
        backdrop-filter: blur(15px); /* Enhanced blur */
        min-width: max-content; /* Ensure background expands to fit content */
        width: fit-content; /* Ensure proper width calculation */
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3); /* Add shadow */
    }
}

@media (max-width: 768px) and (orientation: portrait) {
    .frame-timer-container {
        bottom: 140px; /* Adjust for smaller control bar */
        background: rgba(0, 0, 0, 0.8); /* Stronger background */
        padding: 8px 45px 8px 15px; /* Proportional asymmetric padding for mobile portrait */
        border-radius: 8px; /* Larger border radius */
        backdrop-filter: blur(15px); /* Enhanced blur */
        min-width: max-content; /* Ensure background expands to fit content */
        width: fit-content; /* Ensure proper width calculation */
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3); /* Add shadow */
    }
    
    #frameTimer, #frameTimerAmPm {
        font-size: 0.5rem;
    }
}

@media (max-width: 768px) and (orientation: landscape) {
    .frame-timer-container {
        right: 15px;
        top: 12px;
        background: rgba(0, 0, 0, 0.8); /* Stronger background */
        padding: 6px 40px 6px 12px; /* Proportional asymmetric padding for mobile landscape */
        border-radius: 8px; /* Larger border radius */
        backdrop-filter: blur(15px); /* Enhanced blur */
        min-width: max-content; /* Ensure background expands to fit content */
        width: fit-content; /* Ensure proper width calculation */
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3); /* Add shadow */
    }
    
    #frameTimer, #frameTimerAmPm {
        font-size: 0.5rem;
    }
}

@media (max-width: 480px) and (orientation: portrait) {
    .frame-timer-container {
        bottom: 120px; /* Adjust for very small control bar */
        background: rgba(0, 0, 0, 0.8); /* Stronger background */
        padding: 6px 35px 6px 10px; /* Proportional asymmetric padding for small mobile portrait */
        border-radius: 8px; /* Larger border radius */
        backdrop-filter: blur(15px); /* Enhanced blur */
        min-width: max-content; /* Ensure background expands to fit content */
        width: fit-content; /* Ensure proper width calculation */
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3); /* Add shadow */
    }
    
    #frameTimer, #frameTimerAmPm {
        font-size: 0.45rem;
    }
}

@media (max-width: 480px) and (orientation: landscape) {
    .frame-timer-container {
        right: 10px;
        top: 10px;
        background: rgba(0, 0, 0, 0.8); /* Stronger background */
        padding: 5px 30px 5px 8px; /* Proportional asymmetric padding for small mobile landscape */
        border-radius: 8px; /* Larger border radius */
        backdrop-filter: blur(15px); /* Enhanced blur */
        min-width: max-content; /* Ensure background expands to fit content */
        width: fit-content; /* Ensure proper width calculation */
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3); /* Add shadow */
    }
    
    #frameTimer, #frameTimerAmPm {
        font-size: 0.45rem;
    }
}

/* When controls are hidden in portrait, move timer closer to bottom */
body.mobile-device .frame-timer-container {
    /* This will be overridden by JavaScript based on orientation */
}

#frameTimer {
    font-family: 'SF Pro Text', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 0.625rem;
    font-weight: 600;
    color: #fff;
    display: inline-block;
    text-align: left;
    letter-spacing: 0;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    white-space: nowrap;
    vertical-align: top;
    overflow: hidden;
}

#frameTimerAmPm {
    font-family: 'SF Pro Text', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 0.625rem;
    font-weight: 600;
    color: #fff;
    width: 20px;
    min-width: 20px;
    display: inline-block;
    text-align: left;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Initially hide speed controls and forward navigation buttons */
.speed-controls,
#forwardFrameBtn,
#forwardSecondBtn {
    visibility: hidden;
}

/* Align speed controls and navigation controls with center play button */
.speed-controls {
    align-items: flex-end; /* Align items to bottom */
}

.navigation-controls {
    align-items: flex-end; /* Align items to bottom */
}

/* Touch-Friendly Button Styles */
.touch-btn {
    font-family: 'SF Pro Text', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 1.1rem; /* 2x bigger text */
    font-weight: 600;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 80px; /* 2x bigger than original 40px */
    min-width: 100px;
    padding: 12px 16px;
    border-radius: 8px;
    border: 2px solid transparent;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
    flex-shrink: 0;
}

.touch-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.touch-btn:active {
    transform: translateY(0);
    background: rgba(255, 255, 255, 0.3);
}

.touch-btn i {
    font-size: 1.8rem;
}

.touch-btn span {
    font-size: 0.9rem;
    font-weight: 600;
    text-align: center;
    line-height: 1;
}

/* Specific Button Styles */
.play-pause-btn {
    background: #FFFFFF;
    color: #000;
    width: 120px; /* Exact width instead of min-width */
}

.play-pause-btn:hover {
    background: #F0F0F0;
}

.live-btn.live-btn-live {
    background: rgba(255, 255, 255, 0.1) !important; /* 10% transparent white background */
    color: #fff !important; /* White text */
    border: none !important; /* No stroke at all */
    position: relative;
    width: 120px; /* Exact same width as play-pause-btn */
    border-radius: 8px; /* Same rounded corners as other buttons */
}

.live-pulse-icon {
    width: 22px; /* Made 10px bigger (was 12px) */
    height: 22px;
    background: #FF3B30;
    border-radius: 50%;
    animation: pulse-live 1.5s ease-in-out infinite;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 5px; /* Move circle up more to increase distance from LIVE text */
    margin-bottom: 3px; /* Reduced by 5px to bring LIVE text closer to circle */
}

.live-btn.live-btn-replay {
    background: #FFFFFF;
    color: #000;
    border: 2px solid #FFFFFF;
    width: 120px; /* Exact same width as play-pause-btn */
    border-radius: 8px; /* Same rounded corners as other buttons */
}

/* Hide pulsing icon when in BACK TO LIVE mode */
.live-btn.live-btn-replay .live-pulse-icon {
    display: none;
}

/* Style text for BACK TO LIVE mode */
.live-btn.live-btn-replay .live-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.1;
    font-size: 0.8rem;
}

/* Mobile adjustments for live text */
@media (max-width: 768px) {
    .live-btn.live-btn-replay .live-text {
        font-size: 0.6rem;
        line-height: 1;
    }
}

@media (max-width: 480px) {
    .live-btn.live-btn-replay .live-text {
        font-size: 0.5rem;
        line-height: 0.9;
    }
}

.speed-btn.active {
    background: #FF9500;
    color: #fff;
    border-color: #FF9500;
}

.nav-btn {
    min-width: 80px;
}

.nav-btn span {
    font-size: 0.7rem;
    margin-top: 4px;
}

/* Double Ray Icon Styling */
.double-ray-icon {
    display: flex;
    gap: 2px;
    font-size: 1.8rem;
}

.double-ray-icon i {
    font-size: inherit;
}

/* Drawing Canvas */
.drawing-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: auto;
    z-index: 100;
    touch-action: none; /* Prevent scrolling while drawing */
}

.video-container {
    position: relative;
    /* Allow single touches for mobile controls, custom zoom handling in JS */
    touch-action: manipulation; /* Allow single-finger gestures, JS handles pinch */
    /* Enable smooth zoom transformations */
    overflow: hidden;
    /* Prevent text selection but allow touch events */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    /* Allow tapping for mobile controls */
    -webkit-tap-highlight-color: transparent;
}

/* Zoom functionality for video elements */
.video-container video {
    /* Enable smooth transformations for zoom */
    transform-origin: center center;
    will-change: transform;
    /* Ensure video stays within bounds during zoom */
    max-width: none;
    max-height: none;
    /* Isolate video transforms from affecting other elements */
    isolation: isolate;
    /* Allow single touches, prevent browser zoom, custom pinch handling in JS */
    touch-action: manipulation;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

/* Ensure logos, controls, and UI elements maintain original scale */
.header-logo,
.touch-control-bar:not(.mobile-show),
.touch-btn,
#frameTimer,
#frameTimerAmPm,
.timeline-section,
#replayTimelineSlider,
.button-group,
.status-indicator {
    /* Prevent zoom transforms from affecting UI elements while preserving position transforms */
    transform-style: flat !important;
    /* Ensure elements are not affected by video zoom */
    isolation: isolate;
    /* Reset zoom-related properties */
    transform-origin: initial !important;
    /* Prevent inheriting video zoom scale */
    backface-visibility: hidden;
}

/* Specifically ensure the frame timer container maintains its positioning transforms */
.frame-timer-container {
    /* Allow positioning transforms but prevent scale inheritance */
    isolation: isolate;
    transform-style: flat !important;
    backface-visibility: hidden;
    /* Preserve existing transform functionality for mobile positioning */
}

/* Clear Drawings Button */
.clear-drawings-btn {
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    border: none;
    width: 120px; /* Same width as other buttons */
    border-radius: 8px; /* Same rounded corners as other buttons */
    animation: slideDown 0.3s ease-out;
}

.clear-drawings-btn:hover {
    background: rgba(0, 0, 0, 0.9);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.live-controls {
    position: relative;
    display: flex;
    gap: 15px; /* Same gap as other button groups */
    align-items: flex-end; /* Align to bottom like other controls */
}

/* Position CLEAR button above LIVE button without moving it */
.live-controls .clear-drawings-btn {
    position: absolute;
    bottom: calc(100% + 15px); /* Position above with same gap */
    right: 0; /* Align with right edge of LIVE button */
}

/* Update existing slider thumb styles for larger size and better responsiveness */
#replayTimelineSlider::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    width: 24px; /* 2x bigger */
    height: 64px; /* Match slider height */
    border-radius: 6px;
    background: #FFFFFF;
    background-image: 
        linear-gradient(to bottom, transparent 28px, #CCCCCC 28px, #CCCCCC 36px, transparent 36px),
        linear-gradient(to bottom, transparent 28px, #CCCCCC 28px, #CCCCCC 36px, transparent 36px),
        linear-gradient(to bottom, transparent 28px, #CCCCCC 28px, #CCCCCC 36px, transparent 36px);
    background-position: 7px center, 11px center, 15px center;
    background-size: 2px 64px, 2px 64px, 2px 64px;
    background-repeat: no-repeat;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    /* Enhanced for smooth dragging */
    transition: none; /* Remove transitions for immediate response */
    will-change: auto; /* Optimize for frequent position changes */
    /* Smooth interaction feedback */
    transform: scale(1);
}

/* Active/dragging state for better visual feedback */
#replayTimelineSlider:active::-webkit-slider-thumb {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

#replayTimelineSlider:focus::-webkit-slider-thumb {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

#replayTimelineSlider::-webkit-slider-runnable-track {
    height: 64px; /* Match slider height */
    background: rgba(255, 255, 255, 0.1);
    border: none;
    box-shadow: none;
    outline: none;
    border-radius: 4px;
}

/* Firefox slider updates with enhanced responsiveness */
#replayTimelineSlider::-moz-range-thumb {
    width: 20px;
    height: 64px;
    border-radius: 6px;
    background: #FFFFFF;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    outline: none;
    cursor: pointer;
    transition: none; /* Remove transitions for immediate response */
    transform: scale(1);
}

/* Firefox active state */
#replayTimelineSlider:active::-moz-range-thumb {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

#replayTimelineSlider::-moz-range-track {
    height: 64px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    box-shadow: none;
    outline: none;
    border-radius: 4px;
}



/* Smooth dragging cursor feedback */
#replayTimelineSlider:active {
    cursor: grabbing;
}

/* Mobile-Responsive Controls */
@media (max-width: 1024px) and (pointer: coarse) {
    /* Touch device specific styles - smaller for mobile */
    .touch-control-bar {
        padding: 20px 15px 25px 15px;
        min-height: 140px;
        gap: 12px;
    }
    
    .touch-btn {
        min-height: 55px;
        min-width: 65px;
        padding: 8px 10px;
        gap: 4px;
        font-size: 0.7rem;
    }
    
    .touch-btn i {
        font-size: 1.2rem;
    }
    
    .touch-btn span {
        font-size: 0.65rem;
        font-weight: 600;
        line-height: 1;
    }
    
    /* Smaller timeline slider for mobile */
    #replayTimelineSlider {
        height: 40px;
        margin: 5px 0;
        max-width: 60%;
    }
    
    #replayTimelineSlider::-webkit-slider-thumb {
        width: 16px;
        height: 40px;
        background-size: 2px 40px, 2px 40px, 2px 40px;
        background-position: 5px center, 8px center, 11px center;
    }
    
    #replayTimelineSlider::-webkit-slider-runnable-track {
        height: 40px;
    }
    
    #replayTimelineSlider::-moz-range-thumb {
        width: 14px;
        height: 40px;
    }
    
    #replayTimelineSlider::-moz-range-track {
        height: 40px;
    }
    
    /* Adjust button groups spacing */
    .button-group {
        gap: 8px;
    }
    
    /* Make play/pause and live buttons smaller */
    .play-pause-btn,
    .live-btn {
        width: 70px !important;
        min-width: 70px !important;
    }
}

@media (max-width: 768px) {
    /* Extra small mobile devices - even smaller controls */
    .touch-control-bar {
        padding: 15px 10px 20px 10px;
        gap: 10px;
        min-height: 120px;
    }
    
    .button-group {
        gap: 6px;
    }
    
    .touch-btn {
        min-height: 50px;
        min-width: 55px;
        padding: 6px 8px;
        gap: 3px;
        font-size: 0.6rem;
    }
    
    .touch-btn i {
        font-size: 1rem;
    }
    
    .touch-btn span {
        font-size: 0.55rem;
        line-height: 1;
    }
    
    /* Adjust timeline for smaller screens */
    .timeline-section {
        gap: 8px;
    }
    
    #replayTimelineSlider {
        max-width: 55%;
        height: 35px;
    }
    
    #replayTimelineSlider::-webkit-slider-thumb {
        width: 14px;
        height: 35px;
    }
    
    #replayTimelineSlider::-webkit-slider-runnable-track {
        height: 35px;
    }
    
    #replayTimelineSlider::-moz-range-thumb {
        width: 12px;
        height: 35px;
    }
    
    #replayTimelineSlider::-moz-range-track {
        height: 35px;
    }
    
    /* Frame timer positioning handled by main mobile query */
    
    #frameTimer, #frameTimerAmPm {
        font-size: 0.5rem;
    }
    
    /* Make play/pause and live buttons even smaller */
    .play-pause-btn,
    .live-btn {
        width: 60px !important;
        min-width: 60px !important;
    }
}

/* Touch interaction improvements */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects on touch devices */
    .touch-btn:hover {
        background: rgba(255, 255, 255, 0.1);
        transform: none;
        box-shadow: none;
    }
    
    /* Enhanced touch feedback */
    .touch-btn:active {
        background: rgba(255, 255, 255, 0.3);
        transform: scale(0.95);
    }
    
    /* Improve slider touch interaction */
    #replayTimelineSlider {
        /* Larger touch target */
        padding: 10px 0;
        touch-action: manipulation;
    }
    
    /* Prevent text selection during touch */
    * {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }
    
    /* Allow text selection for specific elements if needed */
    input, textarea {
        -webkit-user-select: auto;
        -moz-user-select: auto;
        -ms-user-select: auto;
        user-select: auto;
    }
}

/* Hidden controls state for mobile */
.touch-control-bar.hidden {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: translateY(100%) !important;
}

.frame-timer-container.hidden {
    opacity: 0 !important;
}

/* Mobile device specific controls hiding */
body.mobile-device .touch-control-bar {
    opacity: 0;
    pointer-events: none;
    transform: translateY(100%);
    visibility: hidden;
}

body.mobile-device .frame-timer-container {
    opacity: 1 !important;
    visibility: visible !important;
}

/* Override for when controls should be shown */
body.mobile-device .touch-control-bar.mobile-show {
    opacity: 1 !important;
    pointer-events: auto !important;
    transform: translateY(0) !important;
    visibility: visible !important;
    display: flex !important;
}

body.mobile-device .frame-timer-container.mobile-show {
    opacity: 1 !important;
    visibility: visible !important;
}

/* Video container touch feedback */
.video-container {
    /* Add subtle touch feedback */
    transition: filter 0.1s ease;
}

.video-container:active {
    filter: brightness(0.95);
}

/* Ensure controls are accessible on very small screens */
@media (max-width: 480px) {
    .touch-control-bar {
        padding: 12px 8px 18px 8px;
        min-height: 100px;
        gap: 8px;
    }
    
    .touch-buttons-section {
        left: 10px !important;
        right: 10px !important;
    }
    
    .button-group {
        gap: 4px;
    }
    
    .touch-btn {
        min-height: 45px;
        min-width: 50px;
        padding: 4px 6px;
        gap: 2px;
        font-size: 0.55rem;
    }
    
    .touch-btn i {
        font-size: 0.9rem;
    }
    
    .touch-btn span {
        font-size: 0.5rem;
        line-height: 1;
    }
    
    /* Very small timeline */
    #replayTimelineSlider {
        max-width: 50%;
        height: 30px;
    }
    
    #replayTimelineSlider::-webkit-slider-thumb {
        width: 12px;
        height: 30px;
    }
    
    #replayTimelineSlider::-webkit-slider-runnable-track {
        height: 30px;
    }
    
    #replayTimelineSlider::-moz-range-thumb {
        width: 10px;
        height: 30px;
    }
    
    #replayTimelineSlider::-moz-range-track {
        height: 30px;
    }
    
    .play-pause-btn,
    .live-btn {
        width: 50px !important;
        min-width: 50px !important;
    }
    
    /* Frame timer positioning handled by main mobile query */
    
    #frameTimer, #frameTimerAmPm {
        font-size: 0.45rem;
    }
}

 