/* Utility classes for JS state management - avoid direct style manipulation */
.hidden { display: none !important; }
.visible { display: block !important; }
.flex-visible { display: flex !important; }
.opacity-0 { opacity: 0 !important; }
.opacity-1 { opacity: 1 !important; }

/* State-based styles */
.modal-open { display: flex !important; }
.modal-closed { display: none !important; }
.overlay-active { display: flex !important; }
.overlay-inactive { display: none !important; }

#video-container {
    position: relative;
    width: 100%;
    background-color: #0a0a0a;
    border-radius: 8px;
    overflow: hidden;
    min-width: 0;
    aspect-ratio: 3 / 2;
    display: flex;
    align-items: center;
    justify-content: center;
}
#imageDisplay {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    transition: opacity 0.3s ease;
}
#overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 5;
}
#center-controls {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    z-index: 10;
}

.start-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.start-main-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.prompt-edit-btn {
    padding: 8px;
    font-size: 14px;
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.8);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.prompt-edit-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.prompt-edit-btn.has-custom-prompt {
    background: rgba(243, 156, 18, 0.2);
    border-color: rgba(243, 156, 18, 0.4);
    color: #f39c12;
    box-shadow: 0 0 8px rgba(243, 156, 18, 0.2);
    animation: gentle-pulse 2s infinite;
}

.prompt-edit-btn.has-custom-prompt:hover {
    background: rgba(243, 156, 18, 0.3);
    color: #e67e22;
    box-shadow: 0 0 12px rgba(243, 156, 18, 0.3);
    animation: none;
}

.prompt-status {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
    text-align: center;
    max-width: 200px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.prompt-status.visible {
    opacity: 1;
}

/* Stop button in HUD */
#stopButton {
    padding: 6px 16px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 20px;
    width: auto;
    min-width: auto;
    background: #e74c3c;
    border: none;
    box-shadow: none;
}

#streaming-controls {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 10;
    display: none;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

/* Network status - horizontal row of stat pills */
#network-status {
    display: none;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

/* Individual stat pill */
.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 6px 5px 12px;
    background: rgba(0, 0, 0, 0.55);
    border-radius: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.stat-label {
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.stat-badge {
    display: inline-flex;
    align-items: center;
    background: rgba(0, 255, 136, 0.15);
    color: #ffffff;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    transition: color 0.3s ease, background-color 0.3s ease;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.stat-unit {
    font-size: 10px;
    opacity: 0.7;
    margin-left: 1px;
}

.stat-indicator {
    margin-left: 2px;
    font-size: 10px;
    transition: color 0.3s ease;
}

#download-controls {
    position: absolute;
    bottom: 20px;
    left: 20px;
    z-index: 10;
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
#timer-container {
    color: white;
    font-size: 13px;
    font-weight: 600;
    width: auto;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.55);
    border-radius: 20px;
    padding: 6px 12px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#timer {
    text-shadow: none;
    animation: none;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 13px;
}
#timer::before {
    content: '⏱';
    margin-right: 5px;
    font-size: 12px;
}

/* Timer warning pulse animation */
@keyframes timerPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

#timer.timer-warning {
    color: #f39c12;
    font-weight: bold;
}

#timer-container.timer-warning {
    border-color: rgba(243, 156, 18, 0.3);
}

#timer.timer-critical {
    color: #e74c3c;
    font-weight: bold;
    animation: timerPulse 1s ease-in-out infinite;
}

#timer-container.timer-critical {
    border-color: rgba(231, 76, 60, 0.4);
}

.placeholder-image {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}
#fileInput {
    display: none;
}
#keyboard-controls {
    margin-top: 0;
    padding: 0;
    background-color: transparent;
}
#loading-overlay,
#server-finding-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(10, 10, 10, 0.85);
    backdrop-filter: blur(4px);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 15;
}

#loading-overlay .spinner,
#server-finding-overlay .spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: #ffffff;
    margin-bottom: 16px;
}

.loading-message {
    color: #ffffff;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    max-width: 80%;
    margin-bottom: 20px;
    letter-spacing: 0.3px;
}

#server-finding-overlay .btn-danger,
#loading-overlay .btn-danger {
    background: rgba(20, 20, 20, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #e0e0e0;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 13px;
    font-weight: 500;
    padding: 8px 24px;
    border-radius: 6px;
    width: auto;
    box-shadow: none;
    letter-spacing: 0.3px;
}

#server-finding-overlay .btn-danger:hover,
#loading-overlay .btn-danger:hover {
    background: rgba(30, 30, 30, 0.95);
    border-color: rgba(255, 255, 255, 0.25);
}

/* ==========================================
   Image Selector Panel - Left Column
   ========================================== */
#image-selector-panel {
    position: absolute;
    left: 12px;
    top: 12px;
    width: 250px;
    height: calc(100% - 24px);
    background-color: rgba(10, 10, 10, 0.95);
    border-radius: 8px;
    padding: 0;
    z-index: 20;
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(8px);
}

#image-selector-panel.collapsed {
    display: none;
}

#image-selector-panel .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(120, 255, 60, 0.05);
    flex-shrink: 0;
}

#image-selector-panel .panel-title {
    color: #ffffff;
    margin: 0;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    flex: 1;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toggle-btn {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: background-color 0.3s ease;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    flex-shrink: 0;
}

.toggle-btn:hover {
    background-color: rgba(120, 255, 60, 0.15);
}

.panel-back-btn {
    background: none;
    border: none;
    color: #ffffff;
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.15s ease;
    flex-shrink: 0;
}

.panel-back-btn:hover {
    background: rgba(120, 255, 60, 0.15);
}

#image-list-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* --- Gallery: Category View --- */
#category-view {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.category-card {
    position: relative;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    flex: 1;
    min-height: 0;
    background: rgba(255, 255, 255, 0.06);
    background-size: cover;
    background-position: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.category-card:hover {
    transform: scale(1.02);
    box-shadow: 0 0 12px rgba(120, 255, 60, 0.25);
}

.category-card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 24px 12px 10px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.4) 60%, transparent 100%);
}

.category-card-name {
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.category-card-desc {
    color: rgba(255, 255, 255, 0.7);
    font-size: 11px;
    line-height: 1.3;
    margin-top: 2px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* --- Gallery: Image Grid View --- */
#image-grid-view {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.gallery-view-hidden {
    display: none !important;
}


/* --- Gallery slide transitions --- */
@keyframes gallerySlideOutLeft {
    from { transform: translateX(0); opacity: 1; }
    to   { transform: translateX(-30%); opacity: 0; }
}
@keyframes gallerySlideInRight {
    from { transform: translateX(30%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}
@keyframes gallerySlideOutRight {
    from { transform: translateX(0); opacity: 1; }
    to   { transform: translateX(30%); opacity: 0; }
}
@keyframes gallerySlideInLeft {
    from { transform: translateX(-30%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

.gallery-slide-out-left {
    animation: gallerySlideOutLeft 0.25s ease forwards;
}
.gallery-slide-in-right {
    animation: gallerySlideInRight 0.25s ease forwards;
}
.gallery-slide-out-right {
    animation: gallerySlideOutRight 0.25s ease forwards;
}
.gallery-slide-in-left {
    animation: gallerySlideInLeft 0.25s ease forwards;
}

#image-grid-container {
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px;
    padding-bottom: 0;
    scrollbar-gutter: stable;
}

#image-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
}

.image-item {
    position: relative;
    cursor: pointer;
    border-radius: 4px;
    overflow: hidden;
    aspect-ratio: 5 / 3;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    background: rgba(255, 255, 255, 0.05);
    min-height: 0;
}

.image-item:hover {
    transform: scale(1.02);
    border-color: rgba(255, 255, 255, 0.5);
}

.image-item.selected {
    border-color: #ffffff;
    box-shadow: 0 0 10px rgba(120, 255, 60, 0.4);
}

.image-item img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    z-index: 1;
}

.image-item .image-overlay {
    display: none;
}

.image-item .remove-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(231, 76, 60, 0.8);
    color: white;
    border: none;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 11px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease;
    z-index: 4;
}

.image-item:hover .remove-btn {
    display: flex;
}

.image-item .remove-btn:hover {
    background: rgba(192, 57, 43, 0.9);
}

#upload-section {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 0 0 0 8px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.action-buttons {
    display: flex;
    gap: 4px;
    width: 100%;
    justify-content: center;
    padding: 0;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.2px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(255, 255, 255, 0.25);
    position: relative;
    overflow: hidden;
    flex: 1;
    max-width: none;
    backdrop-filter: blur(10px);
    background: rgba(120, 255, 60, 0.05);
}

.action-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(120, 255, 60, 0.1) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.action-btn:hover::before {
    opacity: 1;
}

.action-btn .btn-icon {
    font-size: 14px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

.action-btn .btn-text {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.9;
}

/* Upload button styles */
.upload-btn {
    background: rgba(120, 255, 60, 0.08);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.3);
}

.upload-btn:hover {
    background: rgba(120, 255, 60, 0.15);
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.5);
    color: #ffffff;
}

.upload-btn:hover .btn-icon {
    transform: translateY(-2px) scale(1.1);
}

/* Share button styles */
.share-btn {
    background: rgba(120, 255, 60, 0.05);
    color: #80cc50;
    border-color: rgba(255, 255, 255, 0.2);
    position: relative;
}

.share-btn:hover {
    background: rgba(120, 255, 60, 0.12);
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.4);
    color: #ffffff;
}

.share-btn:hover .btn-icon {
    transform: rotate(15deg) scale(1.1);
}

/* Active/clicked state with ripple effect */
.action-btn:active {
    transform: translateY(0) scale(0.98);
}

@keyframes ripple {
    to {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
    }
}

#fileInputSelector {
    display: none;
}

/* Scrollbar styling for webkit browsers */
#image-grid-container::-webkit-scrollbar {
    width: 4px;
}

#image-grid-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 2px;
}

#image-grid-container::-webkit-scrollbar-thumb {
    background: rgba(120, 255, 60, 0.2);
    border-radius: 2px;
}

#image-grid-container::-webkit-scrollbar-thumb:hover {
    background: rgba(120, 255, 60, 0.4);
}

#image-list-content::-webkit-scrollbar {
    width: 4px;
}

#image-list-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 2px;
}

#image-list-content::-webkit-scrollbar-thumb {
    background: rgba(120, 255, 60, 0.2);
    border-radius: 2px;
}

#image-list-content::-webkit-scrollbar-thumb:hover {
    background: rgba(120, 255, 60, 0.4);
}

.download-btn {
    font-size: 0.9rem;
    padding: 10px 20px;
    width: auto;
    min-width: 140px;
    animation: slideInFromRight 0.3s ease-out;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.download-btn.downloading {
    pointer-events: none;
    cursor: wait;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.08));
}
/* Integrated Download Component */
.download-panel {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(10, 10, 10, 0.92);
    border-radius: 10px;
    padding: 10px 14px;
    display: none;
    align-items: center;
    gap: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(16px);
    z-index: 100;
    animation: slideUpFadeIn 0.4s ease-out;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* Close button for download panel */
.download-panel-close-btn {
    position: absolute;
    top: -9px;
    right: -9px;
    width: 22px;
    height: 22px;
    padding: 0;
    background: rgba(15, 15, 15, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.download-panel-close-btn:hover {
    background: rgba(25, 25, 25, 0.95);
    border-color: rgba(255, 255, 255, 0.5);
    color: rgba(255, 255, 255, 0.8);
}

.download-panel-close-btn svg {
    width: 12px;
    height: 12px;
    stroke-width: 2.5;
}

.download-panel.show {
    display: flex;
}

/* Download panel button base */
.video-action-button {
    padding: 8px 14px;
    background: rgba(120, 255, 60, 0.06);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    letter-spacing: 0.2px;
}

.video-action-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(120, 255, 60, 0.08), transparent);
    transition: 0.5s;
}

.video-action-button:hover::before {
    left: 100%;
}

/* Download button specific */
.download-button {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

.download-button:hover {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-1px);
}

.download-button.downloading {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.1);
    cursor: wait;
    pointer-events: none;
    color: rgba(255, 255, 255, 0.35);
}

/* Share button specific */
.share-button {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    position: relative;
}

.share-button:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.35);
    transform: translateY(-1px);
}

.share-button.processing {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.1);
    cursor: wait;
    pointer-events: none;
    color: rgba(255, 255, 255, 0.35);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.share-button.copied {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.4);
    color: #ffffff;
}

.share-button.ready {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

.share-button.error {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.25);
    color: #fca5a5;
}

.video-action-button:active {
    transform: translateY(0);
}

.video-action-button svg {
    width: 15px;
    height: 15px;
    stroke-width: 2;
    flex-shrink: 0;
}

.video-action-button .button-spinner {
    width: 15px;
    height: 15px;
    animation: spin 1s linear infinite;
    flex-shrink: 0;
}

.video-action-button span {
    line-height: 1;
}

.video-action-button .spinner-small {
    animation: spin 1s linear infinite;
}

/* Divider */
.download-divider {
    width: 1px;
    height: 28px;
    background: rgba(255, 255, 255, 0.08);
}

/* Controls option */
.controls-option {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
    user-select: none;
}

.controls-option-label {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.controls-option-title {
    font-weight: 500;
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
}

.controls-option-subtitle {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.35);
}

/* Compact Toggle Switch */
.compact-toggle {
    position: relative;
    width: 36px;
    height: 20px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    transition: background 0.3s ease;
    cursor: pointer;
}

.compact-toggle.active {
    background: rgba(120, 255, 60, 0.35);
}

.compact-toggle-handle {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: #e0e0e0;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.compact-toggle.active .compact-toggle-handle {
    transform: translateX(16px);
    background: #c0ff70;
}

@keyframes slideUpFadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Video Player Modal */
.video-player-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    z-index: 100000;
    display: none;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease-out;
}

.video-player-modal.show {
    display: flex;
}

.video-player-container {
    position: relative;
    width: 90%;
    max-width: 1200px;
    max-height: 90vh;
    background: linear-gradient(135deg, rgba(20, 20, 30, 0.98), rgba(30, 30, 40, 0.98));
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7), 0 0 100px rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: slideUp 0.4s ease-out;
}

.video-player-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.video-player-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.video-player-mute-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.video-player-mute-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.video-player-mute-btn svg {
    width: 20px;
    height: 20px;
}

.video-player-title {
    color: #fff;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.video-player-title svg {
    width: 20px;
    height: 20px;
    color: #a78bfa;
}

.video-player-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.video-player-close:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.3);
    transform: rotate(90deg);
}

.video-player-close svg {
    width: 20px;
    height: 20px;
}

.video-player-content {
    position: relative;
    width: 100%;
    min-height: 400px;
    max-height: calc(90vh - 120px);
    overflow: hidden;
    border-radius: 12px;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-player-video {
    width: 100%;
    height: auto;
    max-height: calc(90vh - 120px);
    object-fit: contain;
    display: block;
    position: relative;
    z-index: 1;
}

.video-player-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    z-index: 10;
    padding: 20px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 12px;
    backdrop-filter: blur(5px);
}

.video-player-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(139, 92, 246, 0.2);
    border-top: 3px solid #a78bfa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================
   Bottom Status Bar (#info-panel)
   ========================================== */
#info-panel {
    position: relative;
    width: min(1400px, calc(100vw - 20px), calc((100vh - 160px) * 3 / 2));
    margin: 0 auto;
    z-index: 20;
    background: rgba(15, 15, 15, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-top: none;
    border-radius: 0 0 8px 8px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    height: 48px;
    overflow: hidden;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* Bar sections */
.bar-section {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.bar-status-section {
    flex: 1;
    min-width: 0;
}

.bar-keyboard-section {
    flex-shrink: 0;
}

/* Bar icons */
.bar-icon {
    width: 16px;
    height: 16px;
    color: #ffffff;
    flex-shrink: 0;
    opacity: 0.7;
}

/* Bar labels (STATUS, KEYBOARD CONTROLS) */
.bar-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: rgba(255, 255, 255, 0.45);
    white-space: nowrap;
    flex-shrink: 0;
}

/* Region tag next to STATUS — populated from /get_chatbot_setting.region
   (set by docker/configure.sh based on router region). Rendered as [US] / [UAE]. */
.bar-region {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 4px;
    padding: 1px 5px;
    white-space: nowrap;
    flex-shrink: 0;
    text-transform: uppercase;
}
.bar-region[hidden] {
    display: none;
}
.bar-ip[hidden] {
    display: none;
}

/* Status dot */
.bar-status-dot {
    width: 6px;
    height: 6px;
    background: #78ff3c;
    border-radius: 50%;
    animation: pulse-status 2s infinite;
    flex-shrink: 0;
}

@keyframes pulse-status {
    0%, 100% {
        opacity: 1;
        box-shadow: 0 0 0 0 rgba(120, 255, 60, 0.4);
    }
    50% {
        opacity: 0.7;
        box-shadow: 0 0 0 6px rgba(120, 255, 60, 0);
    }
}

/* Divider between sections */
.bar-divider {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, 0.1);
    margin: 0 16px;
    flex-shrink: 0;
}

/* Status text */
#info-panel #status {
    font-size: 13px;
    font-weight: 500;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Status color variations */
#info-panel.status-success #status { color: #ffffff; }
#info-panel.status-success .bar-status-dot { background: #78ff3c; }

#info-panel.status-error #status { color: #fca5a5; }
#info-panel.status-error .bar-status-dot { background: #ef4444; }

#info-panel.status-warning #status { color: #fbbf24; }
#info-panel.status-warning .bar-status-dot { background: #f59e0b; }

#info-panel.status-playing #status { color: #7dd3fc; }
#info-panel.status-playing .bar-status-dot { background: #0ea5e9; }

#info-panel.status-loading #status { color: #cbd5e1; }
#info-panel.status-loading .bar-status-dot { background: #64748b; }

#info-panel.status-info #status { color: #94a3b8; }
#info-panel.status-info .bar-status-dot { background: #475569; }

.bottom-bar-arrows {
    display: flex;
    flex-direction: column;
    gap: 2px;
    align-items: center;
}

.arrows-top-row {
    display: flex;
    justify-content: center;
}

.arrows-bottom-row {
    display: flex;
    gap: 2px;
}

.kb-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 18px;
    background: rgba(120, 255, 60, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 3px;
    color: #ffffff;
    font-size: 11px;
    font-weight: 600;
    font-family: 'Inter', system-ui, sans-serif;
}

/* Tips Section Styles */
.tips-section {
    position: relative;
    width: min(1400px, calc(100vw - 20px));
    margin: -10px auto 30px;
    background: rgba(15, 15, 15, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-top: 2px solid #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(120, 255, 60, 0.05);
    overflow: hidden;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    animation: slideUpInitial 0.6s ease-out;
}

@keyframes slideUpInitial {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tips-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 12px 28px;
}

.tips-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.tips-icon {
    width: 24px;
    height: 24px;
    color: #ffffff;
    flex-shrink: 0;
}

.tips-icon.pulse {
    animation: iconPulse 2s ease-in-out infinite;
}

@keyframes iconPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

.tips-title {
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: #e0e0e0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.tips-badge {
    display: inline-block;
    padding: 2px 8px;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    font-size: 10px;
    font-weight: 600;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    animation: badgePulse 1.5s ease-in-out infinite;
}

@keyframes badgePulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
    }
}

.tips-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 12px;
}

.tip-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 10px;
    background: rgba(120, 255, 60, 0.03);
    border-left: 3px solid #ffffff;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.tip-item:hover {
    background: rgba(120, 255, 60, 0.06);
    transform: translateX(4px);
}

.tip-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #78ff3c, #50cc20);
    color: #0a0a0a;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 700;
    border-radius: 50%;
    flex-shrink: 0;
}

.tip-text {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    color: #94a3b8;
    line-height: 1.5;
    flex: 1;
}

.tip-text strong {
    color: #ffffff;
    font-weight: 600;
}

/* Reset text fill for kbd inside strong */
.tip-text strong kbd {
    -webkit-text-fill-color: initial;
    background-clip: initial;
}

.tip-text kbd {
    display: inline-block;
    padding: 2px 6px;
    margin: 0 2px;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
    font-size: 12px;
    font-weight: 500;
    color: #e0e0e0;
    background: rgba(120, 255, 60, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

/* Arrow key styling in tips */
.tip-text kbd.arrow-key {
    padding: 4px 8px;
}

.tip-text .arrow {
    display: inline-block;
    width: 12px;
    height: 12px;
    vertical-align: middle;
}

.tip-text .arrow-up {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 2 L6 10 M3 5 L6 2 L9 5' fill='none' stroke='%23e0e0e0' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.tip-text .arrow-down {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 2 L6 10 M3 7 L6 10 L9 7' fill='none' stroke='%23e0e0e0' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.tip-text .arrow-left {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 6 L10 6 M5 3 L2 6 L5 9' fill='none' stroke='%23e0e0e0' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.tip-text .arrow-right {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 6 L10 6 M7 3 L10 6 L7 9' fill='none' stroke='%23e0e0e0' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* Optionally hide tips during gameplay to avoid distraction */
body.streaming .tips-section {
    opacity: 0.7;
    transform: scale(0.98);
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .tips-container {
        padding: 10px 16px;
    }

    .tips-content {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .tip-item {
        padding: 6px 8px;
    }

    .tip-text {
        font-size: 13px;
    }

    .tips-title {
        font-size: 14px;
    }

    .tip-number {
        width: 24px;
        height: 24px;
        font-size: 12px;
    }
}

/* Ultra-wide screens */
@media (min-width: 1920px) {
    .tips-content {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Action Buttons Overlay - Three groups layout */
#action-buttons-container {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 19;
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    gap: 20px;
}

/* Button groups */
.button-group {
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    display: flex;
    gap: 6px;
}

/* WASD group special layout */
.button-group.wasd-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 4px;
    padding: 8px;
}

.button-group.wasd-group .direction-button:nth-child(1) {
    grid-column: 2;
    grid-row: 1;
}

.button-group.wasd-group .direction-button:nth-child(2) {
    grid-column: 1;
    grid-row: 2;
}

.button-group.wasd-group .direction-button:nth-child(3) {
    grid-column: 2;
    grid-row: 2;
}

.button-group.wasd-group .direction-button:nth-child(4) {
    grid-column: 3;
    grid-row: 2;
}

/* Arrow keys group special layout */
.button-group.arrow-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 4px;
    padding: 8px;
}

.button-group.arrow-group .direction-button:nth-child(1) {
    grid-column: 2;
    grid-row: 1;
}

.button-group.arrow-group .direction-button:nth-child(2) {
    grid-column: 1;
    grid-row: 2;
}

.button-group.arrow-group .direction-button:nth-child(3) {
    grid-column: 2;
    grid-row: 2;
}

.button-group.arrow-group .direction-button:nth-child(4) {
    grid-column: 3;
    grid-row: 2;
}

/* Square action buttons */
.action-button {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 52px;
    height: 52px;
    padding: 0;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    transition: all 0.15s ease;
    cursor: default;
}

/* Direction buttons (smaller squares) */
.direction-button {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    transition: all 0.15s ease;
    cursor: default;
    color: rgba(255, 255, 255, 0.5);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.action-button img {
    width: 20px;
    height: 20px;
    object-fit: contain;
    opacity: 0.5;
    filter: brightness(0) invert(1);
    transition: all 0.15s ease;
}

.action-button .key-label {
    font-size: 10px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.2px;
    transition: all 0.15s ease;
}

.action-button.active, .direction-button.active {
    background: rgba(120, 255, 60, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.action-button.active img {
    opacity: 0.9;
    filter: brightness(0) invert(1);
}

.action-button.active .key-label {
    color: rgba(255, 255, 255, 0.9);
}

.direction-button.active {
    color: rgba(255, 255, 255, 0.9);
}

/* Arrow symbols for direction buttons */
.direction-button.arrow-up::before {
    content: "↑";
    font-size: 16px;
}

.direction-button.arrow-down::before {
    content: "↓";
    font-size: 16px;
}

/* When backward is disabled via config */
body.backward-disabled .direction-button.arrow-down::before {
    content: "";
}

body.backward-disabled .direction-button.arrow-down {
    opacity: 0.3;
    pointer-events: none;
}

/* Hide ↓ in press-key overlay and instructions panel when backward disabled */
body.backward-disabled .pk-arrow-down,
body.backward-disabled .kb-arrow-down {
    visibility: hidden;
}

/* Unattach mode: show ↓ but visually weakened, controlled by --backward-opacity */
body.backward-unattach .direction-button.arrow-down,
body.backward-unattach .pk-arrow-down,
body.backward-unattach .kb-arrow-down {
    opacity: var(--backward-opacity, 0.35);
}

body.backward-unattach .direction-button.arrow-down {
    pointer-events: none;
}

/* Pause mode: ↓ → ⏸ everywhere, same behavior as unattach (key disabled) */
body.backward-pause .direction-button.arrow-down::before {
    content: "⏸";
}
body.backward-pause .direction-button.arrow-down {
    opacity: var(--backward-opacity, 0.35);
    pointer-events: none;
}
body.backward-pause .pk-arrow-down,
body.backward-pause .kb-arrow-down {
    opacity: var(--backward-opacity, 0.35);
    font-size: 0;
}
body.backward-pause .pk-arrow-down::before {
    content: "⏸";
    font-size: 16px;
}
body.backward-pause .kb-arrow-down::before {
    content: "⏸";
    font-size: 11px;
}

.direction-button.arrow-left::before {
    content: "←";
    font-size: 16px;
}

.direction-button.arrow-right::before {
    content: "→";
    font-size: 16px;
}

/* Hide action buttons initially */
#action-buttons-container {
    display: none;
}

/* Show action buttons during streaming */
body.streaming #action-buttons-container {
    display: flex;
}

/* Debug Action Panel */
/* "Press any key" overlay */
#press-key-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    z-index: 25;
    pointer-events: none;
    animation: pressKeyFadeIn 0.4s ease;
}

@keyframes pressKeyFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.press-key-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.press-key-arrows {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    animation: pressKeyPulse 1.5s ease-in-out infinite;
}

@keyframes pressKeyPulse {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.08); }
}

.pk-row {
    display: flex;
    gap: 4px;
}

.pk-key {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 6px;
    color: #fff;
    font-size: 16px;
    font-family: 'Inter', sans-serif;
}

.press-key-text {
    color: rgba(255, 255, 255, 0.85);
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    letter-spacing: 0.3px;
}

/* Press-key overlay: show desktop/mobile content based on device */
.pk-mobile-content { display: none; }
.mobile-device .pk-desktop-content { display: none; }
.mobile-device .pk-mobile-content { display: flex; }

.mobile-drag-icon {
    animation: pressKeyPulse 1.5s ease-in-out infinite;
}

/* No-action hint overlay — reuses press-key-overlay style */
#no-action-hint {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    z-index: 25;
    pointer-events: none;
    animation: pressKeyFadeIn 0.4s ease;
}

.press-key-hint {
    color: rgba(255, 255, 255, 0.5);
    font-size: 12px;
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    letter-spacing: 0.2px;
}

/* Continuous-mode pre-action countdown — shown under the hint */
.press-key-validity {
    margin-top: 6px;
    color: rgba(255, 255, 255, 0.55);
    font-size: 11px;
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    letter-spacing: 0.2px;
    font-variant-numeric: tabular-nums;
}
.press-key-validity .pk-validity-count {
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
}

#brightness-label {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 2px 8px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 4px;
    font-size: 12px;
    color: #fff;
    font-family: 'Courier New', monospace;
    pointer-events: none;
    z-index: 20;
}

#debug-action-panel {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.75);
    color: #e0e0e0;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    padding: 8px 10px;
    border-radius: 6px;
    z-index: 60;
    pointer-events: none;
    max-width: 420px;
    line-height: 1.4;
}

.debug-section {
    margin-bottom: 6px;
}

.debug-section:last-child {
    margin-bottom: 0;
}

.debug-label {
    color: #888;
    font-size: 10px;
    text-transform: uppercase;
    margin-bottom: 2px;
}

.debug-value {
    color: #4fc3f7;
    word-break: break-all;
}

.debug-list {
    max-height: 140px;
    overflow-y: auto;
}

.debug-list-item {
    color: #a5d6a7;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    padding: 1px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.debug-list-item:first-child {
    color: #fff;
}

/* Pause Overlay */
#pause-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 50;
    cursor: pointer;
}

.pause-button {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 140px;
    height: 140px;
    background: transparent;
    border-radius: 50%;
    color: rgba(255, 255, 255, 0.95);
    animation: pulse 2s ease-in-out infinite;
    transition: transform 0.2s ease;
}

.pause-button:hover {
    transform: scale(1.1);
    animation: none;
}

.pause-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 3px solid rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    z-index: -1;
}

.pause-button svg {
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
    position: relative;
    z-index: 1;
    margin-bottom: 5px;
}

.pause-text {
    font-size: 16px;
    font-weight: bold;
    letter-spacing: 2px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
    margin: 0;
}

.pause-hint {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
    letter-spacing: 0.5px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
    margin-top: 3px;
}

/* Environment Update Waiting Overlay */
#env-waiting-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 99999;
    backdrop-filter: blur(4px);
    border-radius: 8px;
}

.env-waiting-content {
    text-align: center;
    color: white;
}

.env-waiting-content .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
    margin: 0 auto 16px;
}

.env-waiting-text {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 8px;
    color: #fff;
}

.env-waiting-hint {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
}

/* Loading Placeholder (shown before images load) */
.loading-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #0a0a0a;
    z-index: 2;
    transition: opacity 0.5s ease;
}

.loading-placeholder.fade-out {
    opacity: 0;
    pointer-events: none;
}

.loading-logo {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 2rem;
    font-weight: 400;
    color: #ffffff;
    letter-spacing: 3px;
    text-shadow: none;
    margin: 0 0 20px 0;
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.loading-logo .pan { font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-weight: 700; color: #ffffff; }
.loading-logo .arcadia { font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-weight: 400; color: #ffffff; }

.loading-placeholder.fade-out .loading-logo {
    transform: translateY(-40px) scale(0.7);
    opacity: 0;
}

.loading-text {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 1rem;
    font-weight: 400;
    color: #ffffff;
    letter-spacing: 1px;
    margin: 0;
    animation: loading-blink 1.5s ease-in-out infinite;
    transition: opacity 0.3s ease;
}

.loading-placeholder.fade-out .loading-text {
    opacity: 0;
}

@keyframes loading-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Title fade-in animation */
.modern-title.title-reveal {
    animation: titleReveal 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes titleReveal {
    from {
        opacity: 0;
        transform: translateY(20px);
        visibility: visible;
    }
    to {
        opacity: 1;
        transform: translateY(0);
        visibility: visible;
    }
}

/* Image panel slide-in animation */
#image-selector-panel.panel-slide-in {
    display: flex !important;
    animation: panelSlideIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes panelSlideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Panel slide-out animation (collapse) */
#image-selector-panel.panel-slide-out {
    animation: panelSlideOut 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    pointer-events: none;
}

@keyframes panelSlideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(-20px);
    }
}

/* Badge fade-in animation */
.image-count-badge.badge-fade-in {
    animation: badgeFadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes badgeFadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Image reveal animation */
#imageDisplay.image-reveal {
    animation: imageReveal 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes imageReveal {
    from {
        opacity: 0;
        transform: scale(1.03);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Overlay fade-in */
#overlay.overlay-reveal {
    animation: overlayReveal 0.5s ease forwards;
}

@keyframes overlayReveal {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Start button / center controls reveal */
#center-controls.controls-reveal {
    animation: controlsReveal 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes controlsReveal {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.85);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Bottom bar slide up */
#info-panel.bar-reveal {
    animation: barReveal 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes barReveal {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Image Count Badge (shown when panel collapsed) — icon only */
.image-count-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 25;
    background: rgba(10, 10, 10, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
    width: 48px;
    height: 48px;
    box-sizing: border-box;
}

.image-count-badge:hover {
    border-color: rgba(255, 255, 255, 0.5);
    background: rgba(15, 15, 15, 0.95);
}

/* Hide text, show album icon via ::before */
.badge-count,
.badge-label {
    display: none;
}

.image-count-badge::before {
    content: '';
    display: block;
    width: 30px;
    height: 30px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='18' height='18' rx='2' ry='2'/%3E%3Ccircle cx='8.5' cy='8.5' r='1.5'/%3E%3Cpolyline points='21 15 16 10 5 21'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
}

/* Image Loading States */

.image-item.loading {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.1) 50%, rgba(255, 255, 255, 0.05) 100%);
    background-size: 200% 200%;
    animation: shimmer 1.5s ease-in-out infinite;
}

.image-item .loading-spinner {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: auto;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: none;
    z-index: 10;
    pointer-events: none;
}

.image-item.loading .loading-spinner {
    display: block;
}

.image-item.loading img {
    opacity: 0;
}

.image-item img {
    transition: opacity 0.3s ease;
}

/* Image loading state */
#imageDisplay.loading {
    opacity: 0;
}

/* Image crossfade transition */
#imageDisplay.image-fade-in {
    animation: imageFadeIn 0.35s ease-out forwards;
}

@keyframes imageFadeIn {
    from { opacity: 0; transform: scale(1.012); }
    to { opacity: 1; transform: scale(1); }
}

.image-loading-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    z-index: 10;
}

.image-loading-overlay.active {
    display: flex;
}

.image-loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.image-loading-text {
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    font-weight: 500;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Video Download Loading Enhancement - disabled */
.download-button.downloading::after {
    display: none;
}

/* Video-ready share toast */
.video-ready-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    padding: 14px 22px;
    background: rgba(20, 20, 20, 0.92);
    color: #ffffff;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.3px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}
.video-ready-toast.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* Video Player Loading Enhancement */
.video-loading-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    z-index: 10;
    padding: 30px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 16px;
    backdrop-filter: blur(10px);
}

.video-loading-ring {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(139, 92, 246, 0.1);
    border-radius: 50%;
    position: relative;
}

.video-loading-ring::before {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border-radius: 50%;
    border: 4px solid transparent;
    border-top-color: #a78bfa;
    animation: spin 1s linear infinite;
}

.video-loading-text {
    color: rgba(255, 255, 255, 0.9);
    font-size: 16px;
    font-weight: 500;
}

.video-loading-progress {
    width: 200px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 8px;
}

.video-loading-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #a78bfa 0%, #8b5cf6 100%);
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s ease;
}

/* Animations */
@keyframes shimmer {
    0% {
        background-position: 200% 0%;
    }
    100% {
        background-position: -200% 0%;
    }
}

@keyframes slideLoading {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Movement Tooltip */
.movement-tooltip {
    position: absolute;
    bottom: 120px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(30, 30, 30, 0.95);
    color: #fff;
    padding: 12px 40px 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    white-space: nowrap;
    z-index: 10000;
    display: none;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.movement-tooltip.show {
    display: block;
}

.movement-tooltip-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 20px;
    height: 20px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s ease;
    background: none;
    border: none;
    padding: 0;
    color: #fff;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.movement-tooltip-close:hover {
    opacity: 1;
}

.movement-tooltip-icon {
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 8px;
    vertical-align: middle;
    animation: tooltip-pulse 1.5s ease-in-out infinite;
}

@keyframes tooltip-pulse {
    0%, 100% {
        opacity: 0.7;
    }
    50% {
        opacity: 1;
    }
}

/* Shift Button Flash Effect */
.action-button[data-key="shift"].flash {
    animation: shift-flash 0.6s ease-in-out 3;
    background: linear-gradient(135deg, #ffd700, #ffa500) !important;
    border-color: #ffd700 !important;
}

@keyframes shift-flash {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 2px 8px rgba(255, 215, 0, 0.4);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 4px 16px rgba(255, 215, 0, 0.8);
    }
}

/* Init Image Tooltip */
.init-image-tooltip {
    position: absolute;
    top: calc(100% + 15px);
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, rgba(45, 45, 50, 0.98), rgba(40, 40, 45, 0.98));
    color: #fff;
    padding: 12px 18px;
    border-radius: 10px;
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    line-height: 1.4;
    white-space: nowrap;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25),
                0 2px 8px rgba(0, 0, 0, 0.15),
                inset 0 1px 0 rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    gap: 10px;
}

.init-image-tooltip::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid rgba(43, 43, 48, 0.98);
}

.init-image-tooltip.show {
    opacity: 1;
    visibility: visible;
}

.init-tooltip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, rgba(100, 180, 255, 0.2), rgba(120, 200, 255, 0.15));
    border-radius: 50%;
    flex-shrink: 0;
}

.init-tooltip-icon::after {
    content: '💡';
    font-size: 10px;
    filter: saturate(0.8);
}

.init-tooltip-text {
    display: inline;
    color: #f0f0f0;
    letter-spacing: 0.3px;
    font-weight: 400;
}

/* Responsive adjustments for init tooltip */
@media (max-width: 768px) {
    .init-image-tooltip {
        font-size: 12px;
        padding: 8px 14px;
    }
}
