* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', sans-serif;
    background-color: #f0f9ff;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.game-container {
    background-color: white;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    width: 90%;
    max-width: 1200px;
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.top-bar {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 20px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.score {
    font-size: 18px;
    color: #666;
    font-weight: normal;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: #f8f9fa;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* 添加得分卡片样式 */
.score #score {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    font-size: 24px;
    font-weight: bold;
    padding: 8px 16px;
    border-radius: 8px;
    min-width: 60px;
    box-shadow: 0 2px 6px rgba(76, 175, 80, 0.3);
    transition: all 0.3s ease;
}

.score #score:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(76, 175, 80, 0.4);
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: white;
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    width: 100%;
}

.controls button {
    padding: 8px 16px;
    border: none;
    border-radius: 5px;
    font-size: 14px;
    cursor: pointer;
    background-color: #4CAF50;
    color: white;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.controls button:hover {
    background-color: #45a049;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.game-area {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    min-height: 0;
}

.target-chars {
    width: 180px;
    padding: 15px;
    background-color: #f5f5f5;
    border-radius: 10px;
    max-height: 70vh;
    overflow-y: auto;
}

.target-chars h3 {
    margin-bottom: 15px;
    color: #333;
    text-align: center;
}

/* 目标汉字拼音样式 */
.target-char {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 10px;
    background-color: #f9f9f9;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.char-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    gap: 2px;
}

.target-char .char {
    font-size: 28px;
    font-weight: bold;
    line-height: 1.2;
}

.target-char .pinyin {
    font-size: 16px;
    color: #666;
    font-weight: normal;
    line-height: 1;
}

.target-char .status {
    font-size: 16px;
    margin-left: 8px;
}

.target-char.completed {
    background-color: #e8f5e9;
}

.target-char.completed .char {
    color: #4CAF50;
}

.grid-container {
    flex: 1;
    min-width: 300px;
    max-width: 100%;
    aspect-ratio: 1;
}

#gameCanvas {
    width: 100%;
    height: 100%;
    border: 2px solid #ddd;
    border-radius: 10px;
}

.library-manager {
    margin-bottom: 15px;
    position: relative;
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.library-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 15px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    white-space: nowrap;
}

.library-toggle-btn:hover {
    background-color: #3e8e41;
}

.btn-icon {
    margin-right: 8px;
    font-size: 18px;
}

.library-panel {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    padding: 20px;
    margin-top: 15px;
    border: 1px solid #e0e0e0;
    z-index: 1000;
    max-height: 80vh;
    overflow-y: auto;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.panel-header h3 {
    margin: 0;
    color: #333;
    font-size: 20px;
}

.library-controls {
    display: flex;
    gap: 10px;
}

.lib-btn {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.import-btn {
    background-color: #4285f4;
    color: white;
}

.import-btn:hover {
    background-color: #3367d6;
}

.export-btn {
    background-color: #34a853;
    color: white;
}

.export-btn:hover {
    background-color: #2d8d46;
}

.character-editor {
    display: flex;
    gap: 30px;
}

.category-list, .character-list-container {
    flex: 1;
}

.category-list h4, .character-list-container h4 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #555;
    font-size: 16px;
}

.category-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.styled-select {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    background-color: #f9f9f9;
}

.add-btn {
    background-color: #fbbc05;
    color: white;
}

.add-btn:hover {
    background-color: #e8a800;
}

.char-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
    max-height: 200px;
    overflow-y: auto;
    padding: 10px;
    background-color: #f9f9f9;
    border-radius: 6px;
}

.character-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: white;
    border: 1px solid #eee;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 18px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.character-item button {
    background: none;
    border: none;
    color: #ff5252;
    cursor: pointer;
    font-size: 16px;
    padding: 0 5px;
}

.character-item button:hover {
    color: #ff1744;
}

.add-character {
    display: flex;
    gap: 10px;
}

.char-input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
}

.add-char-btn {
    background-color: #ea4335;
    color: white;
}

.add-char-btn:hover {
    background-color: #d32f2f;
}

.character-editor {
    display: flex;
    gap: 20px;
}

.category-list,
.character-list {
    flex: 1;
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.category-list select {
    width: 100%;
    padding: 8px;
    margin: 10px 0;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.character-list {
    flex: 2;
}

#characterList {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 10px 0;
    min-height: 100px;
    padding: 10px;
    border: 1px solid #eee;
    border-radius: 4px;
}

.character-item {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    background: #f0f0f0;
    border-radius: 4px;
}

.character-item button {
    background: none;
    border: none;
    color: #ff4444;
    cursor: pointer;
    font-size: 16px;
    padding: 0 5px;
}

.add-character {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.add-character input {
    width: 60px;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
}

/* 添加成功消息的样式 */
.success-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(76, 175, 80, 0.9);
    color: white;
    padding: 20px 40px;
    border-radius: 10px;
    font-size: 24px;
    animation: fadeInOut 2s ease-in-out;
    z-index: 1000;
}

@keyframes fadeInOut {
    0% { opacity: 0; }
    20% { opacity: 1; }
    80% { opacity: 1; }
    100% { opacity: 0; }
} 

.grid-size-control {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    width: 100%;
}

/* 控制项容器样式 */
.control-group {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: flex-start;
}

/* 控制项样式优化 */
.control-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.control-item:hover {
    background: #f0f2f5;
}

.control-item label {
    font-size: 14px;
    color: #555;
    white-space: nowrap;
    min-width: 80px;
}

/* 复选框样式优化 */
.control-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    border-radius: 4px;
    border: 2px solid #4CAF50;
    appearance: none;
    -webkit-appearance: none;
    position: relative;
    background: white;
    transition: all 0.2s ease;
}

.control-item input[type="checkbox"]:checked {
    background: #4CAF50;
}

.control-item input[type="checkbox"]:checked::after {
    content: "✓";
    position: absolute;
    color: white;
    font-size: 12px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* 语音设置面板样式优化 */
.speech-settings {
    width: 100%;
    background: white;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    border: 1px solid #eee;
    margin: 0;
}

.speech-control {
    display: grid;
    grid-template-columns: 60px minmax(100px, 1fr) 50px;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.speech-control:last-child {
    margin-bottom: 0;
}

.speech-control label {
    font-size: 14px;
    color: #555;
    white-space: nowrap;
}

/* 滑块样式优化 */
.speech-control input[type="range"] {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #e0e0e0;
    border-radius: 3px;
    outline: none;
}

/* 数值显示样式优化 */
.speech-control span {
    width: 45px;
    text-align: center;
    font-size: 14px;
    color: #666;
    padding: 4px 8px;
    background: #f5f5f5;
    border-radius: 4px;
    white-space: nowrap;
}

/* 语音选择下拉框样式 */
.speech-control select {
    width: 100%;
    grid-column: 2 / span 2;
}

/* 目标数量控制样式优化 */
.target-count-control {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.target-count-control:hover {
    background: #f0f2f5;
}

.target-count-control label {
    font-size: 14px;
    color: #555;
    white-space: nowrap;
    min-width: 80px;
}

/* 添加成功音效的动画效果 */
@keyframes successPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.success-sound {
    animation: successPulse 0.5s ease-in-out;
}

/* 添加游戏控制按钮的样式 */
.game-control-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

/* 手写按钮和练习面板样式 */
#writeBtn {
    padding: 10px 15px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    background-color: #4CAF50;
    color: white;
    white-space: nowrap;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

#writeBtn:hover {
    background-color: #45a049;
    transform: translateY(-1px);
}

.writing-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    touch-action: none;
}

.writing-container {
    background-color: white;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    gap: 20px;
    touch-action: none;
    overflow: hidden;
}

.writing-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.writing-header h2 {
    margin: 0;
    color: #333;
    font-size: 24px;
}

.practice-stats {
    font-size: 14px;
    color: #666;
    padding: 5px 10px;
    background-color: #f5f5f5;
    border-radius: 15px;
    display: flex;
    align-items: center;
}

#practiceProgress {
    font-weight: bold;
    color: #4CAF50;
    margin-right: 4px;
}

.close-writing {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #666;
    padding: 5px;
}

.close-writing:hover {
    color: #333;
}

.writing-canvas-container {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    background-color: #fff;
    border: 2px solid #ddd;
    border-radius: 10px;
    overflow: hidden;
    touch-action: none;
}

#writingCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    touch-action: none;
}

.writing-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.writing-controls button {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    background-color: #4CAF50;
    color: white;
    transition: all 0.3s ease;
}

.writing-controls button:hover {
    background-color: #45a049;
    transform: translateY(-1px);
}

#clearBtn {
    background-color: #f44336;
}

#clearBtn:hover {
    background-color: #d32f2f;
}

#helpBtn, #restartBtn {
    padding: 10px 15px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    background-color: #4CAF50;
    color: white;
    white-space: nowrap;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

#helpBtn:hover, #restartBtn:hover {
    background-color: #45a049;
    transform: translateY(-1px);
}

.settings-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #2196F3;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 15px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    white-space: nowrap;
}

.settings-toggle-btn:hover {
    background-color: #1976D2;
}

.settings-panel {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    padding: 20px;
    margin-top: 15px;
    border: 1px solid #e0e0e0;
    z-index: 1000;
    max-height: 80vh;
    overflow-y: auto;
}

/* 目标汉字容器样式优化 */
#targetCharsContainer {
    max-height: calc(70vh - 50px);
    overflow-y: auto;
    padding-right: 5px;
}

/* 滚动条样式优化 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #666;
}

/* 响应式布局调整 */
@media screen and (max-width: 768px) {
    .game-area {
        flex-direction: column;
        align-items: center;
    }

    .target-chars {
        width: 100%;
        max-height: 300px;
    }

    .grid-container {
        width: 100%;
    }
    
    #targetCharsContainer {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }
    
    .target-char {
        width: 80px;
    }
    
    .writing-container {
        width: 95%;
        padding: 15px;
        max-height: 80vh;
    }
    
    .writing-header h2 {
        font-size: 20px;
    }
    
    .writing-controls button {
        padding: 8px 16px;
        font-size: 14px;
    }
    
    .current-char {
        font-size: 36px;
    }
    
    .current-pinyin {
        font-size: 16px;
    }
}

.char-with-pinyin {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 10px 0;
    padding: 10px;
    background-color: #f9f9f9;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.current-char {
    font-size: 48px;
    font-weight: bold;
    color: #333;
    line-height: 1.2;
}

.current-pinyin {
    font-size: 18px;
    color: #4CAF50;
    margin-top: 5px;
}

.current-char, .current-pinyin {
    transition: all 0.2s ease;
}

.current-char:hover, .current-pinyin:hover {
    transform: scale(1.05);
    color: #4CAF50;
}

/* 点击动画效果 */
@keyframes charClickPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); color: #2196F3; }
    100% { transform: scale(1); }
}

.char-click-animation {
    animation: charClickPulse 0.3s ease-in-out;
}

#speakBtn {
    background-color: #2196F3;
}

#speakBtn:hover {
    background-color: #0b7dda;
}

/* 字库管理面板的移动端优化 */
.lib-btn-group {
    display: flex;
    gap: 10px;
    width: 100%;
    flex-wrap: wrap;
}

@media screen and (max-width: 768px) {
    /* 调整字库管理面板布局 */
    .panel-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .library-controls {
        width: 100%;
    }
    
    .lib-btn {
        flex: 1;
        justify-content: center;
    }
    
    .character-editor {
        flex-direction: column;
        gap: 15px;
    }
    
    .editor-section {
        width: 100%;
    }
    
    /* 优化分类选择器 */
    .category-selector {
        flex-direction: column;
    }
    
    /* 优化汉字网格显示 */
    .char-grid {
        grid-template-columns: repeat(auto-fill, minmax(45px, 1fr));
        gap: 8px;
        padding: 8px;
    }
    
    .character-item {
        padding: 6px 10px;
        font-size: 16px;
        justify-content: space-between;
    }
    
    /* 增大删除按钮的点击区域 */
    .character-item button {
        font-size: 18px;
        padding: 2px 6px;
        min-width: 30px;
        min-height: 30px;
        display: flex;
        justify-content: center;
        align-items: center;
        background-color: #ff5252;
        color: white;
        border-radius: 4px;
    }
    
    /* 优化添加汉字输入区域 */
    .add-character {
        flex-wrap: nowrap;
    }
    
    .char-input {
        min-width: 60px;
        height: 42px;
        font-size: 18px;
        text-align: center;
    }
    
    .add-char-btn {
        height: 42px;
        min-width: 42px;
    }
}

/* 提高小屏幕上的可点击性 */
@media screen and (max-width: 480px) {
    .lib-btn-group {
        flex-direction: column;
    }
    
    .lib-btn {
        padding: 12px 16px;
        font-size: 16px;
    }
    
    .char-grid {
        grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    }
    
    /* 更突出的添加按钮 */
    #addCategoryBtn, #addCharacterBtn {
        padding: 12px 16px;
        font-size: 16px;
    }
}

/* 移动端按钮交互反馈样式 */
@keyframes buttonPressAnimation {
    0% { transform: scale(1); }
    50% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

.button-pressed {
    animation: buttonPressAnimation 0.2s ease-in-out;
}

.button-active {
    transform: scale(0.95);
    opacity: 0.9;
}

.select-changed {
    background-color: #e8f5e9;
    transition: background-color 0.3s ease;
}

/* 增强移动端视觉反馈 */
@media (hover: none) {
    .lib-btn:active, 
    .add-btn:active, 
    .add-char-btn:active {
        transform: scale(0.95);
        opacity: 0.9;
        transition: transform 0.1s ease-in-out, opacity 0.1s ease-in-out;
    }
    
    .character-item {
        position: relative;
        overflow: hidden;
    }
    
    .character-item:active::after {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.05);
        border-radius: 6px;
    }
}