/* 配对游戏样式 */
.matching-game {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    grid-auto-rows: minmax(100px, auto);
    gap: 18px;
    width: 100%;
    height: 100%;
    padding: 20px;
    box-sizing: border-box;
    align-content: start;
    overflow-y: auto;
    overflow-x: hidden;
    row-gap: 25px;
    position: relative;
}

/* 确保卡片在grid单元格中保持圆形 */
.matching-game > .matching-card {
    aspect-ratio: 1;
    width: 100%;
    margin: 0 auto;
}

/* 自定义滚动条样式 */
.matching-game::-webkit-scrollbar {
    width: 8px;
}

.matching-game::-webkit-scrollbar-track {
    background: rgba(102, 126, 234, 0.1);
    border-radius: 10px;
}

.matching-game::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.5);
    border-radius: 10px;
}

.matching-game::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.7);
}

/* 小屏幕响应式布局 */
@media (max-width: 768px) {
    .matching-game {
        grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
        gap: 15px;
        padding: 15px;
        row-gap: 20px;
    }
}

@media (max-width: 480px) {
    .matching-game {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
        padding: 10px;
        row-gap: 18px;
    }
}

@media (max-width: 360px) {
    .matching-game {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        padding: 8px;
        row-gap: 15px;
    }
}

/* 共用的配对卡片基础样式 */
.matching-card {
    text-align: center;
    cursor: grab;
    transition: all 0.3s ease;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    aspect-ratio: 1;
    border-radius: 50%;
    width: 100%;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px rgba(102, 126, 234, 0.15);
    will-change: transform, box-shadow, background;
}

/* 只在鼠标悬停时应用bubble动画 */
.matching-card:hover {
    animation: bubble 2s ease-in-out infinite;
}

/* 拖拽占位符样式，确保在Grid布局中正确占位 */
.matching-card.placeholder {
    aspect-ratio: 1;
    min-height: 100px;
    grid-row: auto / span 1;
    grid-column: auto / span 1;
    background: transparent !important;
    border: 2px dashed rgba(102, 126, 234, 0.5) !important;
    border-radius: 50% !important;
    animation: none !important;
    pointer-events: none;
}

/* 图片卡片样式 */
.matching-image {
    border: 2px solid rgba(102, 126, 234, 0.3);
    border-radius: 50%;
    padding: 0;
    box-sizing: border-box;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.matching-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
}

/* 单词卡片样式 */
.matching-word {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 2px solid rgba(102, 126, 234, 0.3);
    border-radius: 50%;
    padding: 6px;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.8);
    word-wrap: break-word;
    word-break: break-word;
    font-size: clamp(5px, 1.6vw, 10px);
    font-weight: bold;
    flex-shrink: 0;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-primary);
    overflow: hidden;
    line-height: 0.95;
    max-width: 100%;
    hyphens: auto;
    -webkit-hyphens: auto;
    -ms-hyphens: auto;
}

/* 调整泡泡大小和字体大小以确保内容显示全 */
@media (min-width: 992px) {
    .matching-word {
        font-size: 9px;
        padding: 8px;
        line-height: 0.95;
    }
}

@media (min-width: 768px) and (max-width: 991px) {
    .matching-word {
        font-size: 8px;
        padding: 7px;
        line-height: 0.95;
    }
}

@media (min-width: 481px) and (max-width: 767px) {
    .matching-word {
        font-size: 6px;
        padding: 5px;
        line-height: 0.9;
    }
}

@media (min-width: 361px) and (max-width: 480px) {
    .matching-word {
        font-size: 5px;
        padding: 4px;
        line-height: 0.9;
    }
}

@media (max-width: 360px) {
    .matching-word {
        font-size: 4px;
        padding: 3px;
        line-height: 0.85;
    }
}

/* 拖拽悬停效果 */
.matching-card.drag-over {
    background: rgba(102, 126, 234, 0.2);
    transform: scale(1.05);
}

/* 匹配成功动画 */
.match-success {
    animation: matchSuccess 0.6s ease-in-out forwards;
}

@keyframes matchSuccess {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0.5;
        transform: scale(0.3);
    }
}

@keyframes bubble {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
}

.matching-image:active,
.matching-word:active {
    cursor: grabbing;
    transform: scale(0.95);
}

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

/* 轮播样式 */
.image-carousel-container {
    width: 100%;
    height: 55%;
    position: relative;
    overflow: hidden;
    border-radius: 30px;
    border: 3px solid #667eea;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(255, 255, 255, 0.8));
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.image-carousel {
    width: 100%;
    height: 100%;
    position: relative;
}

.carousel-slides {
    width: 100%;
    height: calc(100% - 60px);
    position: relative;
    display: flex;
    overflow: hidden;
    cursor: grab;
}

.carousel-slide {
    width: 100%;
    height: 100%;
    flex-shrink: 0;
    display: none;
    justify-content: center;
    align-items: center;
    transition: all 0.5s ease;
}

.carousel-slide.active {
    display: flex;
    opacity: 1;
}

.carousel-slide .matching-image {
    width: 70%;
    height: 70%;
    max-width: 350px;
    max-height: 350px;
    padding: 25px;
    box-sizing: border-box;
    border-radius: 50%;
    background: linear-gradient(135deg, #ffffff, #f0f4ff);
    border: 3px solid #667eea;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.8);
    animation: bubble 4s ease-in-out infinite;
}

.carousel-slide .matching-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
}

.carousel-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 25px;
    /* background: linear-gradient(180deg, rgba(102, 126, 234, 0.1), rgba(102, 126, 234, 0.3)); */
    backdrop-filter: blur(8px);
    border-top: 2px solid rgba(102, 126, 234, 0.3);
}

.carousel-prev,
.carousel-next {
    background: linear-gradient(135deg, #667eea, #5a6fd8);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.carousel-prev:hover,
.carousel-next:hover {
    background: linear-gradient(135deg, #5a6fd8, #4a5dc7);
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.carousel-indicators {
    display: flex;
    gap: 10px;
}

.indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #667eea;
    background: transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.indicator.active {
    background: linear-gradient(135deg, #667eea, #5a6fd8);
    transform: scale(1.3);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.6);
}

/* 晃动动画 */
@keyframes shake {
    0%,
    100% {
        transform: translateX(0);
    }

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

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

.shake-animation {
    animation: shake 0.5s ease-in-out;
}

/* 闪烁红光动画 */
@keyframes redFlash {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(255, 0, 0, 0);
        border-color: transparent;
    }
    50% {
        box-shadow: 0 0 20px 10px rgba(255, 0, 0, 0.8);
        border-color: #ff0000;
    }
}

.red-flash-animation {
    animation: redFlash 0.8s ease-in-out;
}

/* 媒体查询 - 小屏幕适配 */
@media (max-height: 800px) {
    .matching-area {
        height: 100%;
    }

    .image-carousel-container {
        height: 55%;
    }
    
    .words-container {
        gap: 12px;
        padding: 15px;
        height: 35%;
    }

    .matching-word {
        font-size: 18px;
    }
    
    .carousel-slide .matching-image {
        width: 90%;
        height: 90%;
    }
}

@media (max-height: 700px) {
    .matching-area {
        height: 100%;
    }

    .image-carousel-container {
        height: 55%;
    }
    
    .words-container {
        gap: 10px;
        padding: 12px;
        height: 35%;
    }

    .matching-word {
        font-size: 16px;
    }
    
    .carousel-slide .matching-image {
        width: 90%;
        height: 90%;
    }
}

@media (max-height: 600px) {
    .matching-area {
        height: 100%;
    }

    .image-carousel-container {
        height: 55%;
    }
    
    .words-container {
        gap: 8px;
        padding: 10px;
        height: 35%;
    }

    .matching-word {
        font-size: 14px;
    }
    
    .carousel-slide .matching-image {
        width: 95%;
        height: 95%;
    }
    
    .carousel-controls {
        padding: 0 10px;
    }
    
    .carousel-prev,
    .carousel-next {
        width: 25px;
        height: 25px;
        font-size: 16px;
    }
}

@media (max-width: 1024px) {
    .image-carousel-container {
        height: 55%;
    }
    
    .words-container {
        gap: 12px;
        padding: 15px;
        height: 35%;
        grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    }

    .matching-word {
        max-width: 120px;
    }
    
    .carousel-slide .matching-image {
        width: 90%;
        height: 90%;
    }
}

/* 针对小屏幕手机的专门适配 */
@media (max-width: 480px) {
    .matching-area {
        height: 100%;
    }
    
    .image-carousel-container {
        height: 60%;
    }
    
    .words-container {
        gap: 8px;
        padding: 10px;
        height: 30%;
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    }
    
    .matching-word {
        min-height: 50px;
        font-size: 14px;
    }
    
    .carousel-slide .matching-image {
        width: 95%;
        height: 95%;
        padding: 10px;
    }
    
    .carousel-controls {
        padding: 0 8px;
    }
    
    .carousel-prev,
    .carousel-next {
        width: 25px;
        height: 25px;
        font-size: 14px;
    }
    
    .indicator {
        width: 8px;
        height: 8px;
    }
    
    .carousel-indicators {
        gap: 6px;
    }
}

/* 针对超小屏幕手机的适配 */
@media (max-width: 360px) {
    .image-carousel-container {
        height: 60%;
    }
    
    .words-container {
        gap: 6px;
        padding: 8px;
        height: 30%;
        grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
    }
    
    .matching-word {
        min-height: 40px;
        font-size: 12px;
    }
    
    .carousel-slide .matching-image {
        width: 98%;
        height: 98%;
        padding: 5px;
    }
    
    .carousel-controls {
        padding: 0 5px;
    }
    
    .carousel-prev,
    .carousel-next {
        width: 20px;
        height: 20px;
        font-size: 12px;
    }
    
    .indicator {
        width: 6px;
        height: 6px;
    }
    
    .carousel-indicators {
        gap: 4px;
    }
}

.drop-zone {
    background: rgba(102, 126, 234, 0.1);
    padding: 10px;
    transition: all 0.3s ease;
}

/* 为非单词卡片的drop-zone添加边框 */
:not(.matching-word).drop-zone {
    border: 2px dashed #667eea;
    border-radius: 15px;
}

.drop-zone.drag-over {
    background: rgba(102, 126, 234, 0.3);
}

/* 为非单词卡片的drag-over添加边框颜色变化 */
:not(.matching-word).drop-zone.drag-over {
    border-color: #764ba2;
}
