body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin: 0;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
    font-size: 2rem;
}

#scanner-container {
    width: 100%;
    height: 400px;
    background: #f8f9fa;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    margin-bottom: 20px;
    border: 3px dashed #dee2e6;
    overflow: hidden;
}

#result {
    font-size: 1.1rem;
    color: #333;
    text-align: center;
    margin-top: 20px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 1px solid #e9ecef;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

button {
    font-family: inherit;
}

.error-message {
    color: #dc3545;
    font-weight: 600;
}

#start-scan {
    display: block;
    margin: 0 auto 20px;
    padding: 15px 30px;
    font-size: 1.1rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.2s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

#start-scan:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

#start-scan:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

#new-scan {
    display: none;
    margin-left: 10px;
    padding: 15px 30px;
    font-size: 1.1rem;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.2s ease;
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.4);
}

#new-scan:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(40, 167, 69, 0.6);
}

.flashlight-button {
    display: none;
    margin: 0 auto 20px;
    padding: 12px 24px;
    font-size: 1rem;
    background: linear-gradient(135deg, #fbbf24 0%, #f97316 100%);
    color: #fff;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 15px rgba(249, 115, 22, 0.35);
    align-items: center;
    gap: 10px;
}

.flashlight-button__icon {
    font-size: 1.2rem;
}

.flashlight-button.flashlight-button--visible {
    display: inline-flex;
}

.flashlight-button.flashlight-button--active {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    box-shadow: 0 6px 20px rgba(217, 119, 6, 0.45);
}

.flashlight-button:hover,
.flashlight-button:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(249, 115, 22, 0.55);
}

.status {
    text-align: center;
    margin-top: 15px;
    font-style: italic;
    color: #6c757d;
}

video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 15px;
}

canvas {
    display: none;
}

.result-popup {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: rgba(40, 167, 69, 0.95);
    color: #fff;
    padding: 12px 24px;
    border-radius: 999px;
    font-size: 1.1rem;
    font-weight: 600;
    box-shadow: 0 12px 24px rgba(40, 167, 69, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 9999;
}

.result-popup--visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

body.modal-open {
    overflow: hidden;
}

.video-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(4px);
    opacity: 0;
    transform: scale(0.98);
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 10000;
}

.video-modal--visible {
    opacity: 1;
    transform: scale(1);
}

.video-modal__content {
    background: linear-gradient(160deg, #0f172a 0%, #1e293b 100%);
    border-radius: 20px;
    box-shadow: 0 30px 60px rgba(15, 23, 42, 0.45);
    width: min(960px, 100%);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: #fff;
}

.video-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    background: rgba(255, 255, 255, 0.04);
}

.video-modal__title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.video-modal__close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.8rem;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    transition: transform 0.2s ease, color 0.2s ease;
}

.video-modal__close:hover {
    color: #f87171;
    transform: scale(1.1);
}

.video-modal__body {
    background: #000;
}

.video-modal__player {
    position: relative;
    background: #000;
}

.video-modal__body video {
    width: 100%;
    height: auto;
    max-height: 65vh;
    border-radius: 0;
    display: block;
    background: #000;
}

.video-modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px 20px;
    background: rgba(255, 255, 255, 0.04);
}

.video-modal__back {
    padding: 12px 24px;
    font-size: 1rem;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
    color: #fff;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 10px 25px rgba(249, 115, 22, 0.35);
}

.video-modal__back:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 30px rgba(249, 115, 22, 0.45);
}

.video-modal__close:focus,
.video-modal__back:focus {
    outline: 2px solid rgba(255, 255, 255, 0.6);
    outline-offset: 2px;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 20px;
        border-radius: 15px;
    }

    h1 {
        font-size: 1.5rem;
        margin-bottom: 20px;
    }

    #scanner-container {
        height: 300px;
    }

    #start-scan,
    #new-scan {
        padding: 12px 25px;
        font-size: 1rem;
    }

    .flashlight-button.flashlight-button--visible {
        display: flex;
        width: 100%;
        justify-content: center;
    }

    #result {
        font-size: 1rem;
        padding: 15px;
    }

.legal-footer {
    margin-top: 40px;
    display: flex;
    justify-content: center;
    gap: 20px;
    font-size: 0.95rem;
}

.legal-footer a,
.legal-footer button {
    color: #0d6efd;
    text-decoration: none;
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    cursor: pointer;
}

.legal-footer a:hover,
.legal-footer button:hover,
.legal-footer a:focus-visible,
.legal-footer button:focus-visible {
    text-decoration: underline;
    outline: none;
}

    .modal {
        border-radius: 16px;
    }

    .modal-video-wrapper {
        padding: 0 16px 16px;
    }

    .modal-actions {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (max-width: 480px) {
    #scanner-container {
        height: 250px;
    }
}
