/* 全局样式重置与基础配置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Microsoft YaHei", "Heiti SC", sans-serif;
}

body {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    padding: 10px 0; /* 最小化上下内边距 */
}

/* 容器通用样式（极致紧凑） */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 15px 20px; /* 最小化内边距 */
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.game-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 15px 20px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

/* 弹性布局工具类（用于一行显示） */
.flex {
    display: flex;
    align-items: center;
}

.flex-col {
    flex-direction: column;
}

.md:flex-row {
    flex-direction: row;
}

.flex-1 {
    flex: 1;
}

.gap-4 {
    gap: 15px;
}

.gap-6 {
    gap: 20px;
}

/* 拼音标注样式（所有汉字上方显示，小字体浅灰色） */
.pinyin-label {
    font-size: 0.7rem;
    color: #64748b;
    margin-left: 6px;
    font-weight: normal;
}

/* 标题样式（极致紧凑） */
h1 {
    text-align: center;
    color: #2d3748;
    margin-bottom: 15px; /* 最小化标题间距 */
    font-weight: 700;
    letter-spacing: 1px;
    font-size: 1.6rem; /* 缩小标题 */
    position: relative;
}

h1::after {
    content: "";
    display: block;
    width: 60px;
    height: 2px;
    background-color: #4299e1;
    margin: 8px auto 0;
    border-radius: 2px;
}

h2, h3 {
    color: #2d3748;
    margin-bottom: 8px; /* 最小化子标题间距 */
    font-weight: 600;
    font-size: 1rem; /* 最小化子标题字体 */
}

/* 表单区域样式（极致紧凑） */
#gameSettings {
    display: flex;
    flex-direction: column;
    gap: 12px; /* 最小化表单区域间距 */
}

/* 模式/时长/难度选择面板（一行显示，紧凑） */
.game-mode, .game-duration, .difficulty {
    padding: 12px; /* 最小化内边距 */
    background-color: #f8fafc;
    border-radius: 5px;
    border: 1px solid #e2e8f0;
}

.game-mode label, .game-duration label, .difficulty label {
    margin-right: 12px; /* 最小化标签间距 */
    color: #4a5568;
    cursor: pointer;
    font-size: 0.9rem; /* 最小化标签字体 */
    display: inline-flex;
    align-items: center;
}

.game-mode input, .game-duration input, .difficulty input {
    margin-right: 4px;
    accent-color: #4299e1;
}

/* 拼音选择面板（一行显示，紧凑） */
#pinyinTypeSelection, #gradeSelection {
    padding: 12px; /* 最小化内边距 */
    background-color: #f8fafc;
    border-radius: 5px;
    border: 1px solid #e2e8f0;
}

.pinyin-group {
    margin-bottom: 12px; /* 最小化分组间距 */
}

.group-title {
    font-size: 0.95rem; /* 最小化分组标题字体 */
    color: #2d3748;
    margin-bottom: 8px; /* 最小化标题间距 */
    font-weight: 600;
    display: flex;
    align-items: center;
}

/* 拼音选项样式（极致紧凑，小尺寸） */
.pinyin-options {
    display: flex;
    flex-wrap: wrap;
    gap: 6px; /* 最小化选项间距 */
    margin-bottom: 8px; /* 最小化底部间距 */
}

.pinyin-option {
    padding: 6px 10px; /* 最小化选项内边距 */
    background-color: white;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.85rem; /* 最小化选项字体 */
}

.pinyin-option:hover {
    border-color: #4299e1;
    color: #4299e1;
    transform: translateY(-1px);
}

.pinyin-option.selected {
    background-color: #4299e1;
    color: white;
    border-color: #4299e1;
    box-shadow: 0 2px 6px rgba(66, 153, 225, 0.3);
}

/* 年级按钮样式（紧凑，带拼音标注） */
.grade-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px; /* 最小化按钮间距 */
    margin-bottom: 8px; /* 最小化底部间距 */
}

.grade-btn {
    padding: 6px 10px; /* 最小化按钮内边距 */
    background-color: white;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.85rem; /* 最小化按钮字体 */
    display: inline-flex;
    align-items: center;
}

.grade-btn:hover {
    border-color: #10b981;
    color: #10b981;
    transform: translateY(-1px);
}

.grade-btn.selected {
    background-color: #10b981;
    color: white;
    border-color: #10b981;
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
}

/* 按钮组样式（紧凑排列） */
.btn-group {
    display: flex;
    gap: 6px; /* 最小化按钮间距 */
}

/* 按钮通用样式（紧凑，小尺寸） */
button {
    padding: 6px 12px; /* 最小化按钮内边距 */
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem; /* 最小化按钮字体 */
    transition: all 0.2s ease;
    font-weight: 500;
}

/* 功能按钮配色 */
.select-all-initials, .select-all-finals, .select-all-whole {
    background-color: #4299e1;
    color: white;
}

.select-all-initials:hover, .select-all-finals:hover, .select-all-whole:hover {
    background-color: #3182ce;
}

.deselect-all-initials, .deselect-all-finals, .deselect-all-whole, #backBtn, #backToMainBtn {
    background-color: #718096;
    color: white;
}

.deselect-all-initials:hover, .deselect-all-finals:hover, .deselect-all-whole:hover, #backBtn:hover, #backToMainBtn:hover {
    background-color: #4a5568;
}

#startGameBtn, #playAgainBtn {
    background-color: #10b981;
    color: white;
    padding: 8px 20px; /* 适当尺寸 */
    font-size: 0.95rem;
    margin-top: 5px; /* 最小化顶部间距 */
    display: inline-flex;
    align-items: center;
}

#startGameBtn:hover, #playAgainBtn:hover {
    background-color: #059669;
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
}

#restartBtn {
    background-color: #f59e0b;
    color: white;
}

#restartBtn:hover {
    background-color: #d97706;
}

#replayBtn {
    background-color: #8b5cf6;
    color: white;
}

#replayBtn:hover {
    background-color: #7c3aed;
}

/* 游戏页面样式（紧凑，带拼音标注） */
.game-info {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 10px; /* 最小化内边距 */
    background-color: #f8fafc;
    border-radius: 5px;
    border: 1px solid #e2e8f0;
    margin-bottom: 15px; /* 最小化底部间距 */
}

.game-info div {
    color: #2d3748;
    font-size: 0.9rem; /* 最小化字体 */
    font-weight: 500;
    display: flex;
    align-items: center;
}

.game-info span {
    color: #4299e1;
    margin-left: 4px;
    font-weight: 700;
}

.current-target {
    text-align: center;
    padding: 12px; /* 最小化内边距 */
    background-color: #f8fafc;
    border-radius: 5px;
    border: 1px solid #e2e8f0;
    margin-bottom: 15px; /* 最小化底部间距 */
}

#currentPinyinDisplay {
    color: #8b5cf6;
    font-size: 1.2rem; /* 最小化字体 */
    font-weight: 700;
}

/* 游戏区域样式 */
.game-area {
    width: 100%;
    height: 500px; /* 适当高度 */
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    background-color: #fefeff;
    margin-bottom: 15px; /* 最小化底部间距 */
}

/* 游戏卡片样式（无拼音，仅汉字/拼音） */
.game-card {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px; /* 缩小卡片尺寸 */
    height: 80px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1.6rem; /* 适当字体 */
    font-weight: 700;
    color: #2d3748;
    border: 2px solid #e2e8f0;
}

.game-card:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.game-card.bg-green-100 {
    background-color: #dcfce7;
    border-color: #22c55e;
    color: #166534;
}

.game-card.bg-red-100 {
    background-color: #fee2e2;
    border-color: #ef4444;
    color: #991b1b;
}

/* 游戏结束弹窗样式（紧凑，带拼音标注） */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background-color: white;
    padding: 20px; /* 最小化内边距 */
    border-radius: 8px;
    text-align: center;
    width: 90%;
    max-width: 400px; /* 缩小弹窗宽度 */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.modal-content h2 {
    color: #2d3748;
    margin-bottom: 15px; /* 最小化底部间距 */
    font-size: 1.4rem; /* 缩小标题字体 */
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content div {
    color: #4a5568;
    font-size: 0.95rem; /* 最小化字体 */
    margin-bottom: 8px; /* 最小化底部间距 */
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content span {
    font-weight: 700;
    margin-left: 4px;
}

#finalScore {
    color: #10b981;
}

#finalCorrect {
    color: #10b981;
}

#finalWrong {
    color: #ef4444;
}

/* 隐藏类 */
.hidden {
    display: none;
}

/* 响应式适配（移动端极致紧凑） */
@media (max-width: 768px) {
    .container, .game-container {
        padding: 10px 8px;
    }

    .pinyin-group {
        flex-direction: column; /* 移动端垂直排列 */
    }

    .game-info {
        flex-wrap: wrap;
        gap: 5px;
    }

    .pinyin-options, .grade-buttons {
        gap: 4px;
    }

    .pinyin-option, .grade-btn {
        padding: 5px 8px;
        font-size: 0.8rem;
    }

    button {
        padding: 5px 10px;
        font-size: 0.8rem;
    }

    #startGameBtn, #playAgainBtn {
        padding: 7px 15px;
        font-size: 0.9rem;
    }
}