body {
    font-family: sans-serif;
    margin: 0;
    padding: 20px;
    background-color: #f4f4f4;
    color: #333;
    display: flex;
    flex-direction: column;
    align-items: center;
}

h1 {
    color: #007bff;
}

#interactive.viewport {
    position: relative;
    width: 100%;
    max-width: 640px; /* Limit max width */
    height: auto;     /* Maintain aspect ratio */
    min-height: 200px;
    overflow: hidden;
    border: 2px solid #007bff;
    border-radius: 5px;
    background-color: #333; /* Placeholder while camera loads */
}

#interactive.viewport canvas,
#interactive.viewport video {
    width: 100% !important; /* Override Quagga's inline styles */
    height: auto !important;/* Override Quagga's inline styles */
    position: absolute;
    top: 0;
    left: 0;
}

#interactive.viewport canvas.drawingBuffer,
#interactive.viewport video.drawingBuffer {
    /* Ensure these are also responsive if Quagga adds them with fixed sizes */
    width: 100% !important;
    height: auto !important;
}


button {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 10px 20px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    margin: 10px 2px;
    cursor: pointer;
    border-radius: 5px;
}

button:hover {
    background-color: #0056b3;
}
button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

#scan-controls, #results, #activation-form {
    margin-top: 20px;
    background-color: white;
    padding: 15px;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 640px;
}

#activation-form label {
    display: block;
    margin-top: 10px;
    font-weight: bold;
}
#activation-form input[type="text"] {
    width: calc(100% - 22px); /* Full width minus padding and border */
    padding: 10px;
    margin-top: 5px;
    border: 1px solid #ccc;
    border-radius: 3px;
}


#scanned-result-text, #api-response {
    margin-top: 10px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 3px;
    word-break: break-all;
}

#api-response.success {
    background-color: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}

#api-response.error {
    background-color: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}

/* For smaller screens */
@media (max-width: 768px) {
    #interactive.viewport {
        max-width: 95%;
    }
    #scan-controls, #results, #activation-form {
        max-width: 95%;
    }
}