* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Noto Sans Thai', 'Montserrat', sans-serif;
    background: transparent !important;
    background-color: transparent !important;
    overflow: hidden;
}

/* ── Root wrapper ───────────────────────────────── */
.overlay-root {
    width: 100vw;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.overlay-root.disconnected .sticker-grid {
    opacity: 0.3;
    transition: opacity 0.4s;
}

/* ── Grid ───────────────────────────────────────── */
.sticker-grid {
    display: grid;
    /* columns / rows set dynamically via JS */
    gap: 12px;
    width: 100%;
    max-width: 1700px;
    max-height: 1000px;
    justify-content: center;
    align-content: center;
    overflow: hidden;
    transition: opacity 0.4s;
}

/* ── Cell card ──────────────────────────────────── */
.sticker-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    background: rgba(255, 255, 255, 0.10);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 16px;
    padding: 10px 6px 8px;
    width: 140px;
    min-height: 150px;
    position: relative;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    will-change: transform;
    overflow: visible;
}

.sticker-cell.empty {
    opacity: 0;
    pointer-events: none;
}

/* ── Image wrapper ──────────────────────────────── */
.cell-img-wrap {
    width: 90px;
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
}

.cell-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.5));
    display: none; /* shown only when src is set */
}

.cell-img.loaded {
    display: block;
    animation: imgAppear 0.3s ease forwards;
}

@keyframes imgAppear {
    from { opacity: 0; transform: scale(0.8); }
    to   { opacity: 1; transform: scale(1); }
}

/* Empty cell dot */
.cell-img-wrap .empty-dot {
    /* width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    border: 1px dashed rgba(255, 255, 255, 0.25); */
}

/* ── Label ──────────────────────────────────────── */
.cell-label {
    width: 100%;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-top: 6px;
    position: relative;
}

.cell-label span {
    display: inline-block;
    white-space: nowrap;
    font-family: 'Montserrat', 'Noto Sans Thai', sans-serif;
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    text-shadow:
        -1px -1px 0 #000, 1px -1px 0 #000,
        -1px  1px 0 #000, 1px  1px 0 #000;
    padding: 0 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.cell-label span.marquee {
    overflow: visible;
    text-overflow: unset;
    max-width: unset;
    position: absolute;
    animation: marqueeScroll 8s linear infinite;
    will-change: transform;
}

@keyframes marqueeScroll {
    0%   { transform: translateX(80px); }
    100% { transform: translateX(-100%); }
}

/* ── Trigger animation ──────────────────────────── */
@keyframes cellTrigger {
    0%   {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 215, 50, 0);
    }
    15%  {
        transform: scale(1.18);
        box-shadow:
            0 0 0 3px rgba(255, 215, 50, 0.9),
            0 0 24px 8px rgba(255, 160, 0, 0.7);
    }
    50%  {
        transform: scale(1.10);
        box-shadow:
            0 0 0 2px rgba(255, 215, 50, 0.6),
            0 0 14px 4px rgba(255, 160, 0, 0.4);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 215, 50, 0);
    }
}

.sticker-cell.triggered {
    animation: cellTrigger 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.3) forwards;
    z-index: 10;
}

/* Glow ring that pulses continuously on triggered cells */
@keyframes glowPulse {
    0%, 100% { opacity: 0.4; transform: scale(1); }
    50%       { opacity: 0.9; transform: scale(1.05); }
}

.sticker-cell.triggered .cell-img-wrap::after {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    background: conic-gradient(
        #ff0000, #ff8800, #ffee00,
        #00cc44, #0088ff, #8800ff,
        #ff0088, #ff0000
    );
    filter: blur(8px);
    opacity: 0.5;
    z-index: -1;
    animation: glowPulse 0.8s ease-in-out 2;
}

/* ── Update flash (whole grid received new data) ── */
@keyframes gridFlash {
    0%   { outline: 0px solid rgba(100, 200, 255, 0); }
    30%  { outline: 2px solid rgba(100, 200, 255, 0.5); }
    100% { outline: 0px solid rgba(100, 200, 255, 0); }
}

.sticker-grid.updated {
    animation: gridFlash 0.5s ease forwards;
}
