* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #1a1a2e;
    color: #fff;
    min-height: 100vh;
    overflow-x: hidden;
}

.screen {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    text-align: center;
}

.screen.active {
    display: flex;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: #6c5ce7;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.error-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: #e74c3c;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    margin-bottom: 20px;
}

.permission-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

#camera-permission p {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 24px;
    max-width: 300px;
    line-height: 1.5;
}

#camera-permission .btn {
    width: 100%;
    max-width: 280px;
}

#scanner h2 {
    margin-bottom: 16px;
    font-size: 18px;
    font-weight: 500;
}

#qr-reader {
    width: 100%;
    max-width: 350px;
    border-radius: 12px;
    overflow: hidden;
}

#qr-reader video {
    border-radius: 12px;
}

.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.popup-overlay.active {
    display: flex;
}

.popup {
    background: #16213e;
    border-radius: 16px;
    padding: 32px 24px;
    max-width: 340px;
    width: 100%;
    text-align: center;
}

.popup-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin: 0 auto 16px;
}

.popup-icon.success {
    background: #00b894;
}

.popup-icon.warning {
    background: #fdcb6e;
    color: #333;
}

.popup-icon.error {
    background: #e74c3c;
}

.popup h2 {
    font-size: 18px;
    margin-bottom: 8px;
}

.popup p {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 24px;
    word-break: break-all;
}

.btn {
    background: #6c5ce7;
    color: #fff;
    border: none;
    padding: 14px 28px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    width: 100%;
    transition: background 0.2s;
}

.btn:hover {
    background: #5a4bd1;
}

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

/* Принудительные стили для html5-qrcode */
#qr-reader * {
    box-sizing: border-box;
}

#qr-reader video {
    object-fit: cover !important;
    width: 100% !important;
    height: 100% !important;
}

/* Полупрозрачная маска вокруг области сканирования */
#qr-reader::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 350px;
    height: 350px;
    border: 3px solid #6c5ce7;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6);
    pointer-events: none;
    z-index: 10;
    border-radius: 8px;
}
