#overlay-container {
    display: grid;
    grid-template-columns: max-content auto;
    gap: 12px 20px;
    align-items: center;
}

#overlay-wrapper {
    display: flex;
    flex-direction: column;
    width: max-content; /* This makes the whole widget as wide as the grid requires */
    padding: 20px;
}

#header-section {
    grid-column: 1 / -1;
    grid-row: 1;
    padding: 15px 20px;
    border-radius: 12px;
    margin-bottom: 12px;
    width: 100%;
    box-sizing: border-box;
    min-width: 0;
}

#overlay-title, #overlay-subtitle {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
#overlay-title { margin: 0; font-weight: bold; }
#overlay-subtitle { margin: 5px 0 0 0; opacity: 0.8; }

/* This is the magic: it sits behind the label and value */
.item-bg {
    grid-column: 1 / -1; /* Span across both columns */
    height: 100%;
    width: 100%;
    border-radius: 12px;
    z-index: -1; /* Place behind text */
    grid-row: auto; /* Stays in its own row line */
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.item {
    transition: opacity 0.5s ease-in-out, transform 0.3s ease;
    animation: fadeIn 0.5s;
    display: contents;
}

.label, .value {
    padding: 12px 15px;
    z-index: 1;
    /* Ensure they share the same grid row as the background */
}

.label {
    grid-column: 1;
    text-align: left;
    font-weight: 700;
    padding-right: 0; /* Let the gap handle the spacing */
}

.value {
    grid-column: 2;
    text-align: left;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Update flash to target the background row */
/*
@keyframes highlight-flash {
    0% { filter: brightness(1); transform: scale(1); }
    50% { filter: brightness(1.5); transform: scale(1.03); }
    100% { filter: brightness(1); transform: scale(1); }
}
.animate-flash {
    animation: highlight-flash 0.5s ease-out;
}
 */

@keyframes highlight-flash {
    0% {
        filter: saturate(1) contrast(1);
        transform: scale(1);
    }
    50% {
        /* Double the color intensity and sharpen the contrast */
        filter: saturate(3) contrast(1.2) brightness(0.9);
        transform: scale(1.03);
        /* Add a deep glow that matches the item's feel */
        box-shadow: 0 0 20px rgba(0,0,0,0.5);
    }
    100% {
        filter: saturate(1) contrast(1);
        transform: scale(1);
        box-shadow: none;
    }
}

.animate-flash {
    animation: highlight-flash 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}