* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #000000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: #ffffff;
    user-select: none;
    -webkit-user-select: none;
}

#app-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* Viewport Container for Camera / Image */
#viewport-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #000000;
}

#video-feed {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
}

#image-feed {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    z-index: 1;
}

/* Mirror front camera like standard camera app */
.mirrored {
    transform: scaleX(-1);
}

/* Canvas Overlay for HUD */
#hud-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}

/* Drag & Drop Overlay Indicator */
#drop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 30;
    background: rgba(0, 240, 255, 0.15);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 3px dashed #00F0FF;
    display: none;
    justify-content: center;
    align-items: center;
    pointer-events: none;
}

.drop-box {
    background: rgba(13, 17, 23, 0.9);
    border: 1px solid #00F0FF;
    border-radius: 20px;
    padding: 30px 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    box-shadow: 0 0 30px rgba(0, 240, 255, 0.4);
}

.drop-text {
    font-size: 16px;
    font-weight: 700;
    color: #00F0FF;
}

/* Top HUD Glass Bar */
#top-hud {
    position: absolute;
    top: max(12px, env(safe-area-inset-top));
    left: 12px;
    right: 12px;
    z-index: 10;
    background: rgba(13, 17, 23, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(0, 240, 255, 0.35);
    border-radius: 16px;
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), 0 0 15px rgba(0, 240, 255, 0.15);
}

.brand-section {
    display: flex;
    flex-direction: column;
}

.brand-title {
    font-size: 15px;
    font-weight: 800;
    color: #00f0ff;
    letter-spacing: 1.2px;
    text-shadow: 0 0 10px rgba(0, 240, 255, 0.6);
}

.brand-author {
    font-size: 11px;
    font-weight: 700;
    color: #ffe600;
    letter-spacing: 0.5px;
    text-shadow: 0 0 8px rgba(255, 230, 0, 0.6);
    margin-top: 2px;
}

.stats-section {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.stat-mode {
    background: rgba(0, 240, 255, 0.2);
    border: 1px solid #00f0ff;
    color: #00f0ff;
    padding: 2px 7px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 800;
}

.stat-fps {
    color: #39ff14;
    text-shadow: 0 0 8px rgba(57, 255, 20, 0.6);
}

.stat-latency {
    color: #00f0ff;
}

.stat-faces {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.15);
    padding: 2px 8px;
    border-radius: 10px;
}

/* Desktop Tip Banner */
#desktop-tip-banner {
    position: absolute;
    top: max(68px, calc(env(safe-area-inset-top) + 56px));
    left: 12px;
    right: 12px;
    z-index: 9;
    background: rgba(13, 17, 23, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 230, 0, 0.4);
    border-radius: 12px;
    padding: 8px 14px;
    font-size: 12px;
    color: #e6edf3;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.tip-close {
    background: transparent;
    border: none;
    color: #8b949e;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    padding: 2px 6px;
}

.tip-close:hover {
    color: #ffffff;
}

/* Bottom Controls Toolbar */
#bottom-controls {
    position: absolute;
    bottom: max(16px, env(safe-area-inset-bottom));
    left: 12px;
    right: 12px;
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.control-item {
    flex: 0 0 auto;
}

/* Cyber Camera Select Dropdown */
#camera-select-wrapper {
    background: rgba(13, 17, 23, 0.88);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(0, 240, 255, 0.4);
    border-radius: 24px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    height: 42px;
}

.cyber-select {
    background: transparent;
    border: none;
    color: #00f0ff;
    font-size: 12px;
    font-weight: 700;
    outline: none;
    cursor: pointer;
    max-width: 140px;
    text-overflow: ellipsis;
}

.cyber-select option {
    background: #0d1117;
    color: #ffffff;
}

.cyber-btn {
    background: rgba(13, 17, 23, 0.88);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(0, 240, 255, 0.4);
    color: #ffffff;
    height: 42px;
    padding: 0 16px;
    border-radius: 24px;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
    white-space: nowrap;
}

.cyber-btn:hover {
    border-color: #00f0ff;
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.3);
}

.cyber-btn:active {
    transform: scale(0.95);
    background: rgba(0, 240, 255, 0.2);
    border-color: #00f0ff;
}

.cyber-btn-primary {
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.35), rgba(57, 255, 20, 0.25));
    border-color: #00f0ff;
    color: #00f0ff;
    text-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
}

.cyber-btn-primary:active {
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.6), rgba(57, 255, 20, 0.5));
}

/* Deep Scan Dialog */
#deep-scan-modal {
    position: absolute;
    bottom: max(72px, calc(env(safe-area-inset-bottom) + 65px));
    left: 16px;
    right: 16px;
    max-height: 55vh;
    z-index: 20;
    background: rgba(13, 17, 23, 0.94);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1.5px solid #00f0ff;
    border-radius: 20px;
    padding: 16px;
    display: none;
    flex-direction: column;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.8), 0 0 25px rgba(0, 240, 255, 0.3);
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(0, 240, 255, 0.2);
    padding-bottom: 10px;
    margin-bottom: 10px;
}

.modal-title {
    font-size: 15px;
    font-weight: 800;
    color: #00f0ff;
}

.modal-close-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #ffffff;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
}

.progress-container {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #00f0ff, #39ff14);
    transition: width 0.1s linear;
}

.modal-body {
    overflow-y: auto;
    max-height: 40vh;
    padding-right: 4px;
    font-size: 13px;
    line-height: 1.6;
}

.scan-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 8px;
}

.scan-item.male {
    border-color: rgba(0, 240, 255, 0.4);
}

.scan-item.female {
    border-color: rgba(255, 102, 196, 0.4);
}

/* Loading Overlay */
#loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0d1117;
    z-index: 100;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 16px;
    transition: opacity 0.5s ease;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(0, 240, 255, 0.2);
    border-top: 3px solid #00f0ff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    font-size: 15px;
    font-weight: 600;
    color: #00f0ff;
    letter-spacing: 0.5px;
}

.loading-author {
    font-size: 12px;
    font-weight: 700;
    color: #ffe600;
}

/* Desktop Wide-Screen Media Queries */
@media (min-width: 768px) {
    #top-hud {
        left: 32px;
        right: 32px;
        top: 20px;
        padding: 12px 24px;
    }

    #desktop-tip-banner {
        left: 32px;
        right: 32px;
        top: 82px;
    }

    #bottom-controls {
        bottom: 24px;
        gap: 14px;
    }

    .cyber-select {
        max-width: 220px;
    }

    #deep-scan-modal {
        max-width: 600px;
        left: 50%;
        transform: translateX(-50%);
    }

    @keyframes slideUp {
        from { opacity: 0; transform: translate(-50%, 20px); }
        to { opacity: 1; transform: translate(-50%, 0); }
    }
}
