html, body {
    margin: 0;
    font-family: sans-serif;
    /* The background is now set by JS, but a fallback is good. */
    background-color: #f0f0f0;
    height: 100%; /* Use 100% for html and body */
    width: 100vw;
    /* overflow: hidden; */ /* Temporarily removed for debugging */
}

#app-container {
    display: flex;
    flex-direction: column;
    height: 100%; /* Use 100% for app-container */
    width: 100%;
    overflow: hidden; /* Keep overflow hidden here for flex container */
}

.center-box {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    background-color: white;
    padding: 10px;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    z-index: 10;
    margin: 10px auto;
    flex-shrink: 0; /* Prevent header from shrinking */
}

.logo {
    max-width: 142px; /* 150px - 5% */
    margin-right: 15px; /* Add some space between logo and QR code */
}

.qrcode {
    max-width: 142px; /* 150px - 5% */
}

.qr-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center; /* Center items horizontally */
    margin-left: 15px; /* Add some space between logo and QR wrapper */
}

.qr-text {
    font-size: 0.7em; /* Make the text small */
    color: #555; /* A subtle color */
    margin-top: 5px; /* Space between QR code and text */
    text-align: center;
    font-weight: bold;
}

#grid-container {
    flex-grow: 1; /* Allow the grid to fill available space */
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(2, 1fr); /* Use fractional units */
    min-height: 0; /* Crucial for flexbox children */
    gap: 5px; /* Optional gap between cells */
}

.grid-cell {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 0; /* Fix for flexbox/grid sizing issues */
}

.grid-cell canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

/* Responsive adjustments for center-box on mobile */
@media (max-width: 600px) {
    .center-box {
        padding: 5px;
        margin: 5px auto;
    }
    .logo, .qrcode {
        max-width: 100px;
    }
}

/* Media query for mobile */
@media (max-width: 768px) {
    #grid-container {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(2, 1fr); /* Use fractional units */
    }
}