/* 游戏页面特定样式 */
.game-page {
    background-color: #f5f6fa;
}

/* 导航栏样式 */
.game-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: #f8f9fa;
    padding: 10px 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 1000;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    position: relative;
    padding: 20px 0;
}

.back-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    color: #4CAF50;
    text-decoration: none;
    font-weight: 500;
    border-radius: 20px;
    transition: all 0.3s ease;
}

.back-button:hover {
    background-color: #e8f5e9;
    transform: translateX(-5px);
}

.back-icon {
    font-size: 1.2em;
    line-height: 1;
}

.game-controls {
    display: flex;
    gap: 1rem;
}

/* 游戏容器样式 */
.game-container {
    max-width: 800px;
    margin: 60px auto 20px;  
    padding: 20px;
    font-family: 'Microsoft YaHei', sans-serif;
    padding-bottom: 40px; /* 为底部文案留出空间 */
}

/* 游戏信息栏 */
.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 10px;
    background-color: #f5f5f5;
    border-radius: 8px;
}

.game-info > div {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* 目标词语显示区 */
.target-word-container {
    text-align: center;
    margin: 20px 0;
    padding: 20px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.target-word {
    font-size: 2em;
    font-weight: bold;
    color: #333;
    margin: 10px 0;
}

.pinyin-hint {
    font-size: 1.2em;
    color: #666;
    margin: 5px 0;
}

/* 字符网格 */
.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
    margin: 20px 0;
}

.character-block {
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5em;
    background-color: #fff;
    border: 2px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    animation: fadeIn 0.5s ease forwards;
}

.character-block:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.character-block.selected {
    background-color: #e3f2fd;
    border-color: #2196f3;
}

.character-block.correct {
    background-color: #c8e6c9;
    border-color: #4caf50;
    animation: correct 0.5s ease forwards;
}

.character-block.wrong {
    background-color: #ffcdd2;
    border-color: #f44336;
    animation: wrong 0.5s ease;
}

/* 选择显示区 */
.selection-display {
    text-align: center;
    margin: 20px 0;
    padding: 20px;
    background-color: #f5f5f5;
    border-radius: 8px;
}

.selected-chars {
    font-size: 1.8em;
    min-height: 1.8em;
    margin: 10px 0;
    color: #333;
}

/* 按钮样式 */
.button-container {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 20px 0;
    margin-bottom: 30px; /* 确保按钮不会被底部文案遮挡 */
}

button {
    padding: 10px 20px;
    font-size: 1em;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#checkWord {
    background-color: #2196f3;
    color: white;
}

#checkWord:hover:not(:disabled) {
    background-color: #1976d2;
}

#clearSelection {
    background-color: #f44336;
    color: white;
}

#clearSelection:hover:not(:disabled) {
    background-color: #d32f2f;
}

#hint {
    background-color: #ff9800;
    color: white;
}

#hint:hover:not(:disabled) {
    background-color: #f57c00;
}

#nextLevel {
    background-color: #4caf50;
    color: white;
}

#nextLevel:hover:not(:disabled) {
    background-color: #388e3c;
}

/* 难度选择和声音控制 */
select, #soundToggle {
    padding: 8px;
    font-size: 1em;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
}

#soundToggle {
    background: none;
    border: none;
    font-size: 1.5em;
}

/* 结果模态框 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    text-align: center;
}

.modal-title {
    font-size: 1.5em;
    color: #333;
    margin-bottom: 10px;
}

.modal-message {
    color: #666;
    margin: 10px 0;
}

.word-explanation {
    text-align: left;
    margin: 15px 0;
    padding: 15px;
    background-color: #f5f5f5;
    border-radius: 4px;
    line-height: 1.6;
}

/* 动画效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes correct {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes wrong {
    0%, 100% {
        transform: translateX(0);
    }
    20%, 60% {
        transform: translateX(-5px);
    }
    40%, 80% {
        transform: translateX(5px);
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }

    .game-controls {
        width: 100%;
        justify-content: center;
    }

    .character-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .character-block {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }

    .controls {
        flex-direction: column;
        align-items: stretch;
    }

    .game-button {
        width: 100%;
    }
}

/* 移动端优化 */
@media (max-width: 768px) {
    .game-container {
        padding: 10px;
        margin-bottom: 60px; /* 为底部footer留出空间 */
    }

    .character-block {
        width: 40px;
        height: 40px;
        font-size: 20px;
        margin: 5px;
    }

    .game-info {
        flex-direction: column;
        gap: 10px;
    }

    .target-word-container {
        font-size: 18px;
    }

    .selection-display {
        font-size: 16px;
    }

    /* 优化按钮大小，方便触摸 */
    button {
        min-width: 44px;
        min-height: 44px;
        padding: 10px;
    }

    /* 优化下拉菜单 */
    select {
        height: 44px;
        font-size: 16px;
        padding: 5px 10px;
    }
}

/* 触摸设备拖拽优化 */
.character-block.dragging {
    opacity: 0.7;
    transform: scale(1.1);
    z-index: 1000;
    transition: transform 0.1s ease-out;
}

/* 禁用文本选择 */
.character-block {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    cursor: pointer;
}

/* 优化触摸反馈 */
.character-block:active {
    transform: scale(0.95);
}

/* 添加触摸涟漪效果 */
@keyframes ripple {
    0% {
        transform: scale(1);
        opacity: 0.4;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

.character-block::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.5);
    border-radius: inherit;
    opacity: 0;
    pointer-events: none;
}

.character-block:active::after {
    animation: ripple 0.4s ease-out;
}
