/* Match Three Game Styles */

.match-three-wrapper {
    max-width: 500px;
    margin: 20px auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    user-select: none;
    -webkit-user-select: none;
}

.match-three-header {
    text-align: center;
    margin-bottom: 12px;
}

.match-three-title {
    font-size: 28px;
    margin: 0 0 10px 0;
    color: #333;
}

.match-three-stats {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.match-three-stats .stat-box {
    background: #f0f4ff;
    border: 2px solid #e0e7ff;
    border-radius: 10px;
    padding: 6px 14px;
    text-align: center;
    min-width: 70px;
}

.match-three-stats .stat-label {
    display: block;
    font-size: 12px;
    color: #666;
}

.match-three-stats .stat-value {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: #4f46e5;
}

.stat-box.high-score .stat-value {
    color: #f59e0b;
}

.match-three-combo {
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    color: #f59e0b;
    min-height: 24px;
    margin-top: 4px;
}

.match-three-combo.visible {
    animation: combo-pop 0.3s ease;
}

@keyframes combo-pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.match-three-board {
    display: grid;
    margin: 0 auto;
    background: #e8e0f0;
    border: 3px solid #c4b5d4;
    border-radius: 12px;
    padding: 6px;
    gap: 3px;
    aspect-ratio: 1;
    width: min(100%, 460px);
    box-sizing: border-box;
    overflow: hidden;
    position: relative;
    touch-action: none;
}

.match-three-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(20px, 5vw, 36px);
    background: #fff;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s ease-out, opacity 0.2s ease;
    aspect-ratio: 1;
    border: 2px solid transparent;
    line-height: 1;
    outline: none;
}

.match-three-cell:hover {
    transform: scale(1.05);
}

.match-three-cell:active {
    transform: scale(0.95);
}

.match-three-cell:focus-visible {
    outline: 3px solid #4f46e5;
    outline-offset: 2px;
}

.match-three-cell.selected {
    border-color: #4f46e5;
    background: #e0e7ff;
    transform: scale(1.1);
    box-shadow: 0 0 8px rgba(79, 70, 229, 0.5);
}

.match-three-cell.hint-highlight {
    animation: match-three-pulse 0.6s ease infinite alternate;
}

.match-three-cell.eliminating {
    transition: none !important;
    animation: eliminate-pop 0.25s ease forwards;
    pointer-events: none;
}

@keyframes eliminate-pop {
    0% { transform: scale(1); opacity: 1; }
    60% { transform: scale(1.3); opacity: 0.8; }
    100% { transform: scale(0); opacity: 0; }
}

.match-three-cell.falling {
    transition: transform 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.match-three-cell.filling {
    animation: tile-fill 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes tile-fill {
    0% { transform: translateY(-40px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

@keyframes match-three-pulse {
    from { transform: scale(1); }
    to { transform: scale(1.15); }
}

.score-float {
    position: absolute;
    font-size: 16px;
    font-weight: 700;
    color: #f59e0b;
    pointer-events: none;
    animation: score-float-up 0.8s ease-out forwards;
    z-index: 10;
}

@keyframes score-float-up {
    0% { transform: translateY(0); opacity: 1; }
    100% { transform: translateY(-40px); opacity: 0; }
}

.match-three-controls {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 14px;
}

.match-three-btn {
    background: #4f46e5;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px 20px;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
}

.match-three-btn:hover {
    background: #4338ca;
}

.match-three-btn:active {
    transform: scale(0.95);
}

.match-three-message {
    text-align: center;
    margin-top: 12px;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
}

.match-three-message.success {
    background: #d1fae5;
    color: #065f46;
    display: block !important;
}

.match-three-message.fail {
    background: #fee2e2;
    color: #991b1b;
    display: block !important;
}

/* Game Over Modal */
.match-three-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    align-items: center;
    justify-content: center;
}

.match-three-modal.visible {
    display: flex;
}

.match-three-modal-content {
    background: #fff;
    border-radius: 16px;
    padding: 30px;
    max-width: 320px;
    width: 90%;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.match-three-modal-title {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 10px 0;
    color: #333;
}

.match-three-modal-message {
    font-size: 16px;
    color: #666;
    margin: 0 0 20px 0;
}

.match-three-modal-btn {
    background: #4f46e5;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 12px 30px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    margin-top: 8px;
    transition: background 0.2s ease;
}

.match-three-modal-btn:hover {
    background: #4338ca;
}

.match-three-modal-btn.secondary {
    background: #e0e7ff;
    color: #4f46e5;
}

.match-three-modal-btn.secondary:hover {
    background: #c7d2fe;
}

/* Responsive */
@media (max-width: 480px) {
    .match-three-stats {
        gap: 6px;
    }
    .match-three-stats .stat-box {
        padding: 4px 10px;
        min-width: 60px;
    }
    .match-three-stats .stat-value {
        font-size: 18px;
    }
    .match-three-title {
        font-size: 22px;
    }
    .match-three-btn {
        padding: 6px 14px;
        font-size: 13px;
    }
}
