/* ====== EMOJI PUZZLE GAME - RIGID STABLE VERSION ====== */
/* === EMOJI PUZZLE - RESPONSIVE GRID REWRITE === */

.emojipuzzle-container {
    width: 100%;
    margin: 0 auto;
    /* Use safe padding but rely on inner layout */
    padding: 20px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

@media (max-width: 820px) {
    .emojipuzzle-container {
        padding: 10px 5px;
        /* Minimal padding on mobile */
    }
}

.emojipuzzle-status {
    width: 100%;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(16px, 4vw, 20px);
    font-weight: 500;
    color: var(--secondary);
    margin-bottom: 20px;
    text-align: center;
}

.emojipuzzle-game-area {
    /* No Aspect Ratio - Height is defined by content */
    width: 100%;
    max-width: 1200px;
    /* Slightly wider max */
    margin: 0 auto;
    position: relative;
    /* Prevent total collapse on desktop */
    min-width: 600px;
}

@media (max-width: 820px) {
    .emojipuzzle-game-area {
        min-width: 100%;
        max-width: 100%;
        /* Taller (portrait) aspect to fit big emojis - though flow layout handles scaling naturally now */
    }
}

.emojipuzzle-board {
    /* Flex Row Layout */
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    position: relative;
    width: 100%;
    gap: 40px;
    /* Force minimum separation */

    /* Visual Container */
    background: rgba(15, 23, 42, 0.4);
    border: 2px solid var(--border-subtle);
    border-radius: 24px;
    padding: 24px 3%;
    /* Reduced side padding to allow columns to be wider */
    box-sizing: border-box;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

@media (max-width: 820px) {
    .emojipuzzle-board {
        padding: 16px 2%;
        /* Tighter padding on mobile */
        border-radius: 16px;
        gap: 20px;
    }
}

/* The Columns */
.emojipuzzle-side {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 20px;
    /* Vertical gap between emojis */

    /* Responsive Width Strategy */
    /* Desktop: Percentage based for reactive scaling */
    width: 18%;
    flex-shrink: 0;

    position: relative;
    z-index: 5;
}

@media (max-width: 820px) {
    .emojipuzzle-side {
        /* On Mobile, take up more width -> Bigger Emojis */
        width: 28%;
        gap: 12px;
    }
}

/* The Emojis */
.emojipuzzle-emoji {
    width: 100%;
    /* Fill the column width */
    aspect-ratio: 1 / 1;
    /* Always square */

    background: rgba(255, 255, 255, 0.05);
    border: 2px solid var(--border-subtle);
    border-radius: 20%;

    display: flex;
    align-items: center;
    justify-content: center;

    /* Font size relative to the emoji box itself */
    container-type: size;
    font-size: 50px;
    /* Fallback */

    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    user-select: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Use a clean container query on the emoji element itself */
/* This works because we set aspect-ratio, so height = width */
@container (min-width: 1px) {
    .emojipuzzle-emoji {
        font-size: 60cqw;
        /* 60% of width */
    }
}

.emojipuzzle-emoji:hover {
    border-color: var(--accent-cyan);
    background: rgba(255, 255, 255, 0.08);
    transform: scale(1.05);
}

.emojipuzzle-emoji.selected {
    border-color: var(--accent-cyan);
    background: rgba(6, 182, 212, 0.2);
    box-shadow: 0 0 15px rgba(6, 182, 212, 0.4);
    transform: scale(1.02);
}

.emojipuzzle-emoji.matched {
    opacity: 0.8;
    cursor: default;
    border-color: rgba(34, 197, 94, 0.5);
    background: rgba(34, 197, 94, 0.1);
    transform: scale(1);
}

.emojipuzzle-emoji.incorrect {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.2);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.4);
    animation: shake 0.5s;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

/* Connections Layer */
.emojipuzzle-connections {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
    /* Keep lines inside radius */
    border-radius: inherit;
    /* Match board radius */
}

.emojipuzzle-connection {
    position: absolute;
    height: 6px;
    background: linear-gradient(90deg, var(--accent-cyan), #8b5cf6);
    border-radius: 6px;
    transform-origin: 0 50%;
    box-shadow: 0 0 15px rgba(6, 182, 212, 0.5);
    z-index: 1;
    transition: opacity 0.3s ease;
}

.emojipuzzle-connection.incorrect {
    background: linear-gradient(90deg, #ef4444, #b91c1c);
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.5);
}

/* Result Overlay */
.emojipuzzle-result-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    pointer-events: none;
    background: transparent;
}

.result-content {
    pointer-events: auto;
    text-align: center;
    background: rgba(15, 23, 42, 0.95);
    padding: clamp(20px, 5vw, 40px);
    border-radius: clamp(16px, 4vw, 24px);
    border: 2px solid var(--accent-cyan);
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.8), 0 0 40px rgba(6, 182, 212, 0.2);
    width: min(380px, calc(100% - 24px));
    max-width: 90%;
    transform: scale(0.5);
    opacity: 0;
    animation: resultPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    box-sizing: border-box;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

@keyframes resultPop {
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.result-title {
    font-size: clamp(24px, 6vw, 36px);
    font-weight: 800;
    margin-bottom: clamp(8px, 2vw, 12px);
}

.result-title.win {
    color: #22c55e;
    text-shadow: 0 0 20px rgba(34, 197, 94, 0.4);
}

.result-title.loss {
    color: #ef4444;
    text-shadow: 0 0 20px rgba(239, 68, 68, 0.4);
}

.result-message {
    color: var(--secondary);
    font-size: clamp(14px, 4vw, 18px);
    margin-bottom: clamp(16px, 4vw, 24px);
}

.result-pax {
    font-size: clamp(20px, 5vw, 28px);
    font-weight: 800;
    color: #fbbf24;
    padding: clamp(8px, 2vw, 12px);
    background: rgba(251, 191, 36, 0.1);
    border-radius: 12px;
    display: inline-block;
    margin-bottom: clamp(16px, 4vw, 24px);
}

.result-timer {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.3);
    text-transform: uppercase;
    letter-spacing: 1px;
}