.matching-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    padding: 1rem;
    max-width: 100%;
    min-height: 100%;
}

/* --- Cards Grid --- */
.matching-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    width: 100%;
    max-width: 700px;
    justify-items: center;
}

/* Tablet: 4 oszlop */
@media (min-width: 600px) {
    .matching-cards-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Mobil: 2 oszlop */
@media (max-width: 599px) {
    .matching-cards-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
}

/* --- Matching Card --- */
.matching-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: linear-gradient(145deg, #ffffff, #f0f0f0);
    border-radius: 16px;
    box-shadow:
        0 4px 6px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    border: 3px solid transparent;
    transition: all 0.3s ease;
    width: 100%;
    max-width: 160px;
}

.matching-card:nth-child(1) {
    border-color: #5B9BD5;
}

.matching-card:nth-child(2) {
    border-color: #C27BA0;
}

.matching-card:nth-child(3) {
    border-color: #E06666;
}

.matching-card:nth-child(4) {
    border-color: #6AA84F;
}

.matching-card:nth-child(5) {
    border-color: #F6B26B;
}

.matching-card:nth-child(6) {
    border-color: #8E7CC3;
}

.matching-card:nth-child(7) {
    border-color: #76A5AF;
}

.matching-card:nth-child(8) {
    border-color: #FFD966;
}

/* --- Image Wrapper --- */
.matching-image-wrapper {
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    padding: 0.5rem;
}

.matching-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* --- Slot --- */
.matching-slot {
    width: 100%;
    min-height: 44px;
    padding: 0.5rem;
    background: #f8f9fa;
    border: 2px dashed #ccc;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    font-weight: bold;
    color: #333;
    transition: all 0.2s ease;
}

.matching-slot.highlight {
    border-color: #1976D2;
    background: rgba(76, 175, 80, 0.1);
    border-style: solid;
}

.matching-slot.filled {
    border-style: solid;
    border-color: #1976D2;
    background: linear-gradient(145deg, #e8eaf5, #c8e6e5);
}

/* --- Tálca --- */
.matching-tray {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    padding: 1rem;

    border-radius: 16px;
    min-height: 60px;
    width: 100%;
    max-width: 700px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* --- Piece --- */
.matching-piece {
    padding: 0.6rem 1rem;
    background: linear-gradient(145deg, #fff, #f5f5f5);
    border: 2px solid #1976D2;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 700;
    color: #1565C0;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    box-shadow:
        0 3px 6px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
    transition: all 0.2s ease;
    white-space: nowrap;
    line-height: 1;
}

.matching-piece:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 12px rgba(0, 0, 0, 0.2);
}

.matching-piece:active {
    cursor: grabbing;
}

.matching-piece.placed {
    background: linear-gradient(145deg, #e8f5e9, #c8e6c9);
    border-color: #4CAF50;
    color: #2E7D32;
}

/* --- Ghost (drag közben) --- */
.dragging-ghost.matching-piece {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    opacity: 0.95;
}

/* --- Status --- */
.matching-status {
    font-size: 1.2rem;
    font-weight: 600;
    padding: 0.5rem 1.5rem;
    border-radius: 20px;
    text-align: center;
}

.matching-status.progress {
    background: #e3f2fd;
    color: #1565C0;
}

.matching-status.success {
    background: linear-gradient(145deg, #c8e6c9, #a5d6a7);
    color: #1B5E20;
    animation: pulse 0.5s ease;
}

.matching-status.error {
    background: linear-gradient(145deg, #ffcdd2, #ef9a9a);
    color: #b71c1c;
    animation: shake 0.4s ease;
}

/* --- Animációk --- */
@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

@keyframes shake {

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

    20%,
    60% {
        transform: translateX(-5px);
    }

    40%,
    80% {
        transform: translateX(5px);
    }
}

/* --- Gombok --- */
.matching-container .button {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.matching-container .button.green {
    background: linear-gradient(145deg, #66bb6a, #43a047);
    color: white;
    box-shadow: 0 4px 8px rgba(67, 160, 71, 0.3);
}

.matching-container .button.green:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(67, 160, 71, 0.4);
}

.matching-container .button.green:active {
    transform: translateY(0);
}

/* --- Mobil optimalizáció --- */
@media (max-width: 480px) {
    .matching-container {
        padding: 0.5rem;
        gap: 1rem;
    }

    .matching-card {
        padding: 0.4rem;
        max-width: 140px;
    }

    .matching-slot {
        min-height: 38px;
        font-size: 1rem;
    }

    .matching-piece {
        padding: 0.5rem 0.8rem;
        font-size: 1rem;
    }

    .matching-tray {
        padding: 0.75rem;
        gap: 0.5rem;
    }

    .matching-status {
        font-size: 1rem;
        padding: 0.4rem 1rem;
    }
}

/* --- Landscape mobil --- */
@media (max-height: 500px) and (orientation: landscape) {
    .matching-cards-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 0.5rem;
    }

    .matching-card {
        padding: 0.3rem;
    }

    .matching-image-wrapper {
        padding: 0.25rem;
    }

    .matching-slot {
        min-height: 32px;
        padding: 0.3rem;
    }
}