/* 关卡4: 单词对对碰样式 */

/* 加载覆盖层样式 */
.level4-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.level4-loading-content {
    text-align: center;
    color: var(--text-primary);
}

.level4-loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: level4-spin 1s ease-in-out infinite;
    margin: 0 auto 20px;
}

@keyframes level4-spin {
    to { transform: rotate(360deg); }
}

.level4-loading-message {
    font-size: 18px;
    color: var(--text-primary);
    margin: 0;
}

/* 游戏容器样式 */
.level4-game-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background-color: rgba(255, 255, 255, 0.01);
    border-radius: var(--border-radius-xl);
    border: 2px solid var(--border-color);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* 游戏屏幕样式 */
.level4-screen {
    display: none;
}

.level4-screen.active {
    display: flex;
    flex-direction: column;
    min-height: 700px;
    justify-content: space-between;
}

/* 统计信息栏 */
.level4-stats-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.01);
    padding: 15px 20px;
    border-radius: var(--border-radius-large);
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

.level4-level-info h2 {
    margin: 0;
    font-size: 28px;
    color: var(--text-secondary);
    font-weight: 600;
}

.level4-progress-info {
    display: flex;
    gap: 20px;
    font-size: 20px;
    color: var(--text-primary);
}

#question-counter, #score-display {
    font-weight: 500;
}

/* 问题显示区域 */
.level4-question-container {
    background-color: rgba(255, 255, 255, 0.01);
    padding: 30px;
    border-radius: var(--border-radius-large);
    margin-bottom: 20px;
    border: 2px solid var(--border-color);
    flex: 1;
    display: flex;
    flex-direction: column;
}

.level4-question-header {
    text-align: center;
    margin-bottom: 30px;
}

.level4-question-prompt {
    font-size: 24px;
    color: var(--text-primary);
    margin: 0 0 15px 0;
    font-weight: 500;
}

/* 配对游戏区域样式 */
.level4-matching-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    margin-top: 20px;
    width: 100%;
}

/* 统一卡片网格样式 */
.level4-cards-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    width: 100%;
    max-width: 800px;
    justify-content: center;
    align-items: center;
}

/* 卡片容器 - 翻牌效果基础结构 */
.level4-card {
    position: relative;
    width: 100%;
    height: 120px;
    cursor: pointer;
    user-select: none;
    perspective: 1000px;
}

/* 卡片内部容器 - 负责翻转动画 */
.level4-card-inner {
    position: absolute;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s ease;
    transform-style: preserve-3d;
}

/* 卡片翻转状态 */
.level4-card.flipped .level4-card-inner {
    transform: rotateY(180deg);
}

/* 卡片正面和背面共用样式 */
.level4-card-front, .level4-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--border-light);
}

/* 卡片正面 - 显示单词或中文意思 */
.level4-card-front {
    background-color: rgba(255, 255, 255, 0.05);
    font-size: 24px;
    font-weight: bold;
    color: var(--text-primary);
    transform: rotateY(180deg);
}

/* 单词卡片正面特殊样式 */
.level4-word-card .level4-card-front {
    color: var(--primary-color);
    background-color: rgba(255, 255, 255, 0.05);
}

/* 中文意思卡片正面特殊样式 */
.level4-meaning-card .level4-card-front {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.05);
}

/* 卡片背面 - 统一的背面设计 */
.level4-card-back {
    background: linear-gradient(135deg, #34495e 0%, #2c3e50 100%);
    font-size: 32px;
    color: white;
}

/* 卡片背面的图案 */
.level4-card-back::after {
    content: "?";
    font-size: 48px;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.7);
}

/* 悬停效果 */
.level4-card:not(.matched):not(.flipped) .level4-card-inner:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

/* 匹配成功状态 */
.level4-card.matched {
    cursor: default;
}

.level4-card.matched .level4-card-front {
    background-color: #2ecc71;
    color: white;
    border-color: #27ae60;
}

/* 匹配失败状态 */
.level4-card.mismatched .level4-card-front {
    background-color: #e74c3c;
    color: white;
    border-color: #c0392b;
    animation: level4-shake 0.5s ease-in-out;
}

/* 抖动动画 */
@keyframes level4-shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-10px); }
    40%, 80% { transform: translateX(10px); }
}

/* 匹配线样式 */
.level4-connection-line {
    position: absolute;
    background-color: #3498db;
    height: 4px;
    z-index: 10;
    pointer-events: none;
    transition: all 0.3s ease;
    opacity: 0;
}

.level4-connection-line.visible {
    opacity: 1;
}

.level4-connection-line.correct {
    background-color: #2ecc71;
}

.level4-connection-line.incorrect {
    background-color: #e74c3c;
}

/* 反馈区域样式 */
.level4-feedback-container {
    background-color: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    text-align: center;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.level4-feedback-container.hidden {
    display: none;
}

.level4-feedback-text {
    font-size: 18px;
    color: var(--text-primary);
    margin: 0;
    word-wrap: break-word;
}

.level4-feedback-text.correct {
    color: #2ecc71;
}

.level4-feedback-text.incorrect {
    color: #e74c3c;
}

/* 导航按钮区域 */
.level4-navigation-buttons {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.01);
    padding: 20px;
    border-radius: var(--border-radius-large);
    border: 1px solid var(--border-color);
}

.level4-nav-btn {
    padding: 15px 30px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 18px;
    font-weight: 500;
    transition: all 0.3s ease;
    min-width: 120px;
}

.level4-nav-btn:hover:not(:disabled) {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.level4-nav-btn:disabled {
    background-color: #7f8c8d;
    cursor: not-allowed;
    transform: none;
}

#back-to-menu-button {
    background-color: var(--secondary-color);
}

#back-to-menu-button:hover {
    background-color: var(--secondary-dark);
}

/* 响应式设计 */
@media (max-width: 992px) {
    .level4-matching-container {
        flex-direction: column;
        gap: 20px;
    }
    
    .level4-cards-group {
        max-width: none;
    }
    
    .level4-cards-container {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
    
    .level4-word-card, .level4-meaning-card {
        font-size: 20px;
        min-height: 80px;
    }
}

@media (max-width: 768px) {
    .level4-game-container {
        padding: 15px;
    }
    
    .level4-stats-display {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .level4-question-prompt {
        font-size: 20px;
    }
    
    .level4-cards-container {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .level4-word-card, .level4-meaning-card {
        font-size: 18px;
        min-height: 70px;
    }
    
    .level4-navigation-buttons {
        flex-direction: column;
        gap: 10px;
    }
    
    .level4-nav-btn {
        width: 100%;
        max-width: 200px;
    }
}