:root {
    --primary-color: #2196F3;
    --primary-dark: #1976D2;
    --primary-light: #64B5F6;
    --error-color: #f44336;
    --success-color: #4CAF50;
    --success-light: #81C784;
    --background-color: #f8f9fa;
    --text-color: #2c3e50;
    --card-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    --card-shadow-hover: 0 12px 40px rgba(0, 0, 0, 0.15);
    --transition-speed: 0.3s;
    --border-radius: 16px;
    --gradient-primary: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    --gradient-success: linear-gradient(135deg, var(--success-color), var(--success-light));
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 100vw;
}

header {
    background: rgba(255, 255, 255, 0.95);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    padding: 1.5rem;
    box-shadow: var(--card-shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

h1 {
    text-align: center;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 2rem;
    font-weight: 800;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 1.5rem;
    flex: 1;
}

.scanner-container {
    background: rgba(0, 0, 0, 0.9);
    padding: 0;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
    aspect-ratio: 1;
    max-width: 100%;
    border: 3px solid rgba(255, 255, 255, 0.1);
}

#reader {
    width: 100%;
    height: 100%;
    position: relative;
}

#reader video {
    border-radius: var(--border-radius);
}

#scanning-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--border-radius);
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scanner-animation {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-primary);
    box-shadow: 0 0 20px var(--primary-color);
    animation: scan 2s linear infinite;
    border-radius: 2px;
}

.scanner-frame {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    border: 3px solid var(--primary-color);
    border-radius: 20px;
    box-shadow: 0 0 30px rgba(33, 150, 243, 0.5);
    animation: frame-pulse 2s ease-in-out infinite;
}

.scanner-frame::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border: 2px solid transparent;
    border-radius: 20px;
    background: linear-gradient(45deg, var(--primary-color), transparent, var(--primary-color));
    animation: frame-rotate 3s linear infinite;
}

@keyframes scan {
    0% { top: 0; opacity: 0.8; }
    50% { top: 100%; opacity: 1; }
    100% { top: 0; opacity: 0.8; }
}

@keyframes frame-pulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.05); }
}

@keyframes frame-rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.camera-indicator {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    z-index: 10;
}

.progress-container {
    background: rgba(255, 255, 255, 0.95);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    margin: 2rem 0;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.progress-bar {
    width: 100%;
    height: 16px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 1rem;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: var(--gradient-primary);
    width: 0%;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 8px;
    position: relative;
    overflow: hidden;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: progress-shine 2s infinite;
}

@keyframes progress-shine {
    0% { left: -100%; }
    100% { left: 100%; }
}

#progress-text {
    font-size: 1.1rem;
    color: var(--text-color);
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 2rem 0;
}

.primary-button, .secondary-button {
    padding: 1.2rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-speed);
    text-transform: uppercase;
    letter-spacing: 1px;
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
}

.primary-button {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--card-shadow);
}

.primary-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.primary-button:hover::before {
    left: 100%;
}

.primary-button:hover, .primary-button:active {
    transform: translateY(-3px);
    box-shadow: var(--card-shadow-hover);
}

.primary-button.scanning {
    background: linear-gradient(135deg, var(--error-color), #ff6b6b);
    animation: pulse 2s infinite;
}

.secondary-button {
    background: rgba(255, 255, 255, 0.9);
    color: var(--text-color);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.secondary-button:hover, .secondary-button:active {
    background: rgba(255, 255, 255, 1);
    transform: translateY(-2px);
    box-shadow: var(--card-shadow);
}

.sequence-status {
    background: rgba(255, 255, 255, 0.95);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    margin-bottom: 2rem;
    text-align: center;
    border: 2px solid var(--primary-color);
    position: relative;
    overflow: hidden;
}

.sequence-status::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-primary);
}

.sequence-status h2 {
    color: var(--primary-color);
    font-size: 1.6rem;
    margin-bottom: 1rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.hint {
    color: #666;
    font-size: 1rem;
    margin-top: 0.5rem;
    font-style: italic;
}

.warning {
    color: var(--error-color);
    font-size: 0.9rem;
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(244, 67, 54, 0.1);
    border-radius: var(--border-radius);
    border: 1px solid var(--error-color);
    font-weight: 600;
}

.result-container {
    text-align: center;
    margin-top: 2rem;
    animation: fadeIn 0.5s ease-out;
}

.result-message {
    padding: 2rem;
    border-radius: var(--border-radius);
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    box-shadow: var(--card-shadow);
}

.result-message.success {
    background: rgba(76, 175, 80, 0.1);
    color: var(--success-color);
    border: 2px solid var(--success-color);
}

.result-message.error {
    background: rgba(244, 67, 54, 0.1);
    color: var(--error-color);
    border: 2px solid var(--error-color);
}

.icon-container {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    font-size: 2rem;
}

.result-message.success .icon-container {
    background: var(--gradient-success);
    color: white;
    box-shadow: 0 4px 20px rgba(76, 175, 80, 0.3);
}

.result-message.error .icon-container {
    background: linear-gradient(135deg, var(--error-color), #ff6b6b);
    color: white;
    box-shadow: 0 4px 20px rgba(244, 67, 54, 0.3);
}

.hidden {
    display: none !important;
}

footer {
    background: rgba(255, 255, 255, 0.95);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    padding: 1.5rem;
    text-align: center;
    margin-top: auto;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    font-size: 0.9rem;
    color: #666;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

/* Animations */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

#reader.flash {
    animation: flash 0.3s;
}

@keyframes flash {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* Responsive Design */
@media (max-width: 600px) {
    .container {
        padding: 1rem;
    }

    h1 {
        font-size: 1.5rem;
    }

    .scanner-container {
        border-radius: 12px;
    }

    .sequence-status {
        padding: 1.5rem;
    }

    .sequence-status h2 {
        font-size: 1.3rem;
    }

    .primary-button, .secondary-button {
        padding: 1rem;
        font-size: 1rem;
    }
}

/* Orientation Landscape */
@media (max-height: 500px) and (orientation: landscape) {
    .scanner-container {
        max-width: 50vh;
        margin: 0 auto 1rem;
    }

    .controls {
        flex-direction: row;
        justify-content: center;
    }

    .primary-button, .secondary-button {
        max-width: 200px;
    }
}

#next-button, #reset-button, #retry-button {
    margin-top: 1rem;
    padding: 0.8rem 1.5rem;
    border-radius: var(--border-radius);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#next-button {
    background: var(--gradient-success);
    color: white;
    box-shadow: var(--card-shadow);
}

#reset-button, #retry-button {
    background: linear-gradient(135deg, var(--error-color), #ff6b6b);
    color: white;
    box-shadow: var(--card-shadow);
}

#next-button:hover, #reset-button:hover, #retry-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--card-shadow-hover);
}

#victory-message {
    text-align: center;
    padding: 3rem;
    background: var(--gradient-success);
    color: white;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow-hover);
    animation: victory-pop 0.5s ease-out;
    position: relative;
    overflow: hidden;
}

#victory-message::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><text y="50" font-size="50" fill="rgba(255,255,255,0.1)">🎉</text></svg>') repeat;
    opacity: 0.1;
}

#victory-message h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    font-weight: 900;
}

#restart-button {
    margin-top: 1.5rem;
    padding: 1rem 2rem;
    background: rgba(255, 255, 255, 0.9);
    color: var(--success-color);
    border: none;
    border-radius: var(--border-radius);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

#restart-button:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    background: white;
}

#confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

.confetti {
    position: absolute;
    width: 12px;
    height: 12px;
    background-color: #f00;
    opacity: 0.8;
    animation: confetti-fall 4s linear infinite;
    border-radius: 2px;
}

@keyframes confetti-fall {
    0% {
        transform: translateY(-100vh) rotate(0deg) scale(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
        transform: translateY(-90vh) rotate(36deg) scale(1);
    }
    100% {
        transform: translateY(100vh) rotate(360deg) scale(0);
        opacity: 0;
    }
}

@keyframes victory-pop {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
} 