:root {
    --primary-color: #0066cc;
    --primary-hover: #0052a3;
    --error-color: #cc0000;
    --success-color: #00aa00;
    --text-dark: #333;
    --text-light: #666;
    --bg-light: #f5f5f5;
    --border-radius: 8px;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.2);
}

body {
    background: var(--bg-light);
    min-height: 100vh;
    font-family: system-ui, -apple-system, sans-serif;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Watermark */
.watermark-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    user-select: none;
    overflow: hidden;
}

.watermark-text {
    position: absolute;
    font-size: 2.5em;
    font-weight: bold;
    color: rgba(0, 0, 0, 0.03);
    white-space: nowrap;
}

/* Main container */
.viewer-container {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 1400px;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
}

/* Header */
.viewer-header {
    text-align: center;
    animation: fadeInDown 0.6s ease-out;
}

.viewer-title {
    font-size: 32px;
    color: var(--text-dark);
    margin: 0 0 10px 0;
    font-weight: 600;
}

.viewer-subtitle {
    font-size: 16px;
    color: var(--text-light);
    margin: 0;
}

/* Picture frame */
.picture-frame {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    width: fit-content;
    max-width: 95vw;
    min-height: 500px;
    min-width: 500px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: visible;
    transition: all 0.3s ease;
    animation: fadeInUp 0.6s ease-out 0.2s backwards;
    padding: 30px;
}

/* QR code corner markers - all on picture-frame */
.picture-frame::before,
.picture-frame::after,
.picture-frame .qr-corner-bl,
.picture-frame .qr-corner-br {
    content: '';
    position: absolute;
    width: 60px;
    height: 60px;
    border: 4px solid #000;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

/* Top left */
.picture-frame::before {
    top: 20px;
    left: 20px;
    border-right: none;
    border-bottom: none;
}

/* Top right */
.picture-frame::after {
    top: 20px;
    right: 20px;
    border-left: none;
    border-bottom: none;
}

/* Bottom left */
.picture-frame .qr-corner-bl {
    bottom: 20px;
    left: 20px;
    border-right: none;
    border-top: none;
}

/* Bottom right */
.picture-frame .qr-corner-br {
    bottom: 20px;
    right: 20px;
    border-left: none;
    border-top: none;
}

.picture-frame.has-image {
    min-height: 0;
    min-width: 0;
    padding: 20px;
}

.picture-frame.has-image::before,
.picture-frame.has-image::after,
.picture-frame.has-image .qr-corner-bl,
.picture-frame.has-image .qr-corner-br {
    opacity: 0;
}

.picture-frame:hover {
    box-shadow: var(--shadow-lg);
}

#hint {
    text-align: center;
    padding: 60px 40px;
    color: var(--text-light);
    animation: pulse 2s ease-in-out infinite;
}

.hint-icon {
    font-size: 80px;
    display: block;
    margin-bottom: 20px;
    opacity: 0.6;
}

.hint-text {
    font-size: 24px;
    font-weight: 500;
}

#picture {
    max-width: 90vw;
    max-height: 85vh;
    display: none;
    object-fit: contain;
    animation: zoomIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#picture.active {
    display: block;
}

/* Scan effect */
.scan-line {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(0, 102, 204, 0.3) 20%,
        rgba(0, 102, 204, 0.8) 50%,
        rgba(0, 102, 204, 0.3) 80%,
        transparent 100%);
    box-shadow: 0 0 10px rgba(0, 102, 204, 0.8);
    display: none;
    z-index: 1000;
}

.scan-line.active {
    display: block;
    animation: scan 1.5s ease-in-out;
}

/* Message overlay */
#message {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--error-color);
    color: white;
    padding: 16px 32px;
    border-radius: var(--border-radius);
    font-size: 16px;
    font-weight: 500;
    display: none;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    animation: slideDown 0.3s ease-out;
}

#message.active {
    display: block;
}

/* Hidden input for scanner */
#scanner {
    opacity: 0;
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
}

/* Animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

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

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

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

@keyframes scan {
    0% {
        top: 0;
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        top: 100%;
        opacity: 0;
    }
}

/* Mobile responsive */
@media (max-width: 640px) {
    .viewer-title {
        font-size: 24px;
    }

    .viewer-subtitle {
        font-size: 14px;
    }

    .picture-frame {
        min-height: 400px;
    }

    .hint-icon {
        font-size: 60px;
    }

    .hint-text {
        font-size: 18px;
    }
}
