﻿/* ===== 基础样式 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", sans-serif;
    background: linear-gradient(135deg, #E3F2FD 0%, #FFF8E1 50%, #E8F5E9 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 72px 20px 20px;
}

.back-link {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 150;
    min-height: 44px;
    padding: 0 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: linear-gradient(135deg, #66BB6A, #43A047);
    color: white;
    box-shadow: 0 4px 12px rgba(76,175,80,0.35);
    font-size: 16px;
    font-weight: bold;
    text-decoration: none;
    transition: all 0.2s ease;
}

.back-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(76,175,80,0.45);
}

.back-link:active {
    transform: translateY(0);
}

/* ===== 标题区 ===== */
.header {
    text-align: center;
    margin-bottom: 20px;
    animation: fadeInDown 0.8s ease;
}
.header h1 {
    font-size: 42px;
    color: #1565C0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 8px;
}
.header .subtitle {
    font-size: 18px;
    color: #666;
}

/* ===== 统计栏 ===== */
.stats-bar {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    justify-content: center;
    animation: fadeIn 1s ease;
}
.stat-card {
    background: white;
    border-radius: 16px;
    padding: 12px 24px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    text-align: center;
    min-width: 100px;
}
.stat-card .label {
    font-size: 14px;
    color: #888;
    margin-bottom: 4px;
}
.stat-card .value {
    font-size: 28px;
    font-weight: bold;
    color: #333;
}
.stat-card .value.correct { color: #4CAF50; }
.stat-card .value.wrong { color: #FF5722; }
.stat-card .value.streak { color: #FF9800; }

/* ===== 进度条 ===== */
.progress-container {
    width: 100%;
    max-width: 700px;
    margin-bottom: 20px;
}
.progress-bar {
    height: 12px;
    background: #E0E0E0;
    border-radius: 6px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #42A5F5, #66BB6A);
    border-radius: 6px;
    transition: width 0.5s ease;
    width: 0%;
}
.progress-text {
    text-align: center;
    margin-top: 6px;
    font-size: 14px;
    color: #666;
}

/* ===== 主卡片 ===== */
.main-card {
    background: white;
    border-radius: 24px;
    padding: 40px;
    width: 100%;
    max-width: 700px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    text-align: center;
    position: relative;
    overflow: hidden;
    animation: fadeInUp 0.8s ease;
}

/* ===== 单元标签 ===== */
.unit-tag {
    display: inline-block;
    background: #E3F2FD;
    color: #1565C0;
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 14px;
    margin-bottom: 16px;
}

/* ===== 汉字显示 ===== */
.hanzi-display {
    font-size: 80px;
    font-weight: bold;
    color: #333;
    margin: 20px 0;
    letter-spacing: 8px;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== 拼音提示 ===== */
.pinyin-hint {
    font-size: 24px;
    color: #999;
    margin-bottom: 24px;
    font-family: Consolas, "Courier New", monospace;
    min-height: 32px;
}
.pinyin-hint.show {
    color: #42A5F5;
    font-weight: bold;
}

/* ===== 输入框 ===== */
.input-area {
    margin: 20px 0;
}
#pinyinInput {
    width: 100%;
    max-width: 500px;
    font-size: 36px;
    padding: 16px 24px;
    border: 3px solid #BBDEFB;
    border-radius: 16px;
    text-align: center;
    font-family: Consolas, "Courier New", monospace;
    outline: none;
    transition: all 0.3s ease;
    background: #FAFAFA;
}
#pinyinInput:focus {
    border-color: #42A5F5;
    background: white;
    box-shadow: 0 0 0 4px rgba(66,165,245,0.2);
}
#pinyinInput.correct {
    border-color: #4CAF50;
    background: #E8F5E9;
    animation: pulse 0.5s ease;
}
#pinyinInput.wrong {
    border-color: #FF5722;
    background: #FFEBEE;
    animation: shake 0.5s ease;
}
.tone-tools {
    display: none;
    justify-content: center;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
}
.tone-tools.active {
    display: flex;
}
.tone-tools .tip {
    width: 100%;
    font-size: 13px;
    color: #777;
    margin-bottom: 2px;
}
.tone-key {
    min-width: 48px;
    padding: 8px 10px;
    border: 2px solid #FFE0B2;
    border-radius: 10px;
    background: #FFF8E1;
    color: #E65100;
    font-size: 18px;
    cursor: pointer;
    font-family: Consolas, "Courier New", monospace;
    transition: all 0.2s ease;
}
.tone-key:hover {
    background: #FFF3E0;
    transform: translateY(-1px);
}
.tone-key:active {
    transform: translateY(0);
}

/* ===== 按钮区 ===== */
.btn-group {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}
.btn {
    padding: 12px 28px;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }
.btn-primary {
    background: linear-gradient(135deg, #42A5F5, #1E88E5);
    color: white;
    box-shadow: 0 4px 12px rgba(66,165,245,0.4);
}
.btn-primary:hover { box-shadow: 0 6px 16px rgba(66,165,245,0.5); }
.btn-secondary {
    background: #F5F5F5;
    color: #666;
}
.btn-secondary:hover { background: #EEEEEE; }
.btn-hint {
    background: #FFF3E0;
    color: #E65100;
}
.btn-speak {
    background: #E8F5E9;
    color: #2E7D32;
}

/* ===== 反馈区 ===== */
.feedback {
    margin-top: 20px;
    min-height: 60px;
    font-size: 20px;
}
.feedback .correct-msg {
    color: #4CAF50;
    font-weight: bold;
}
.feedback .wrong-msg {
    color: #FF5722;
}
.feedback .wrong-msg .correct-answer {
    color: #4CAF50;
    font-weight: bold;
    margin-left: 8px;
}

/* ===== 答案对比 ===== */
.answer-compare {
    margin-top: 12px;
    font-size: 22px;
    font-family: Consolas, monospace;
}
.answer-compare .correct-part { color: #4CAF50; }
.answer-compare .wrong-part { 
    color: #FF5722; 
    text-decoration: underline;
    text-decoration-color: #FF5722;
    text-decoration-thickness: 3px;
}

/* ===== 控制面板 ===== */
.control-panel {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px dashed #E0E0E0;
}
.control-row {
    display: flex;
    gap: 16px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.control-label {
    font-size: 15px;
    color: #666;
}
.tone-note {
    width: 100%;
    text-align: center;
    font-size: 13px;
    color: #E65100;
    margin-top: -4px;
}
select {
    padding: 8px 16px;
    border-radius: 8px;
    border: 2px solid #E0E0E0;
    font-size: 15px;
    outline: none;
    cursor: pointer;
}
select:focus { border-color: #42A5F5; }

/* ===== 错题本按钮 ===== */
.mistake-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #FF5722;
    color: white;
    border: none;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(255,87,34,0.4);
    transition: all 0.3s ease;
    z-index: 100;
}
.mistake-btn:hover { transform: scale(1.1); }
.mistake-btn .badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #FFC107;
    color: #333;
    font-size: 12px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* ===== 弹窗 ===== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
}
.modal-overlay.active { display: flex; }
.modal {
    background: white;
    border-radius: 24px;
    padding: 32px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    animation: zoomIn 0.3s ease;
}
.modal h2 {
    color: #1565C0;
    margin-bottom: 20px;
    text-align: center;
}
.modal .close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #F5F5F5;
    cursor: pointer;
    font-size: 20px;
}
.mistake-list {
    max-height: 400px;
    overflow-y: auto;
}
.mistake-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid #EEE;
}
.mistake-item .hz { font-size: 24px; font-weight: bold; }
.mistake-item .py { color: #666; font-family: monospace; }
.mistake-item .wrong-py { color: #FF5722; text-decoration: line-through; margin-right: 8px; }

/* ===== 成绩单 ===== */
.report-card {
    text-align: center;
}
.report-score {
    font-size: 64px;
    font-weight: bold;
    color: #4CAF50;
    margin: 16px 0;
}
.report-detail {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin: 20px 0;
}
.report-item {
    background: #F5F5F5;
    border-radius: 12px;
    padding: 12px;
}
.report-item .num { font-size: 28px; font-weight: bold; color: #333; }
.report-item .txt { font-size: 14px; color: #888; margin-top: 4px; }

/* ===== 星星动画 ===== */
.star {
    position: absolute;
    font-size: 32px;
    animation: starPop 1s ease forwards;
    pointer-events: none;
}
@keyframes starPop {
    0% { transform: scale(0) rotate(0deg); opacity: 1; }
    50% { transform: scale(1.5) rotate(180deg); opacity: 1; }
    100% { transform: scale(0) rotate(360deg) translateY(-50px); opacity: 0; }
}

/* ===== 纸屑动画 ===== */
.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    animation: confettiFall 3s ease forwards;
    pointer-events: none;
    z-index: 50;
}
@keyframes confettiFall {
    0% { transform: translateY(-10px) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* ===== 键盘提示 ===== */
.keyboard-hint {
    margin-top: 24px;
    padding: 16px;
    background: #FAFAFA;
    border-radius: 12px;
    font-size: 14px;
    color: #666;
}
.keyboard-hint kbd {
    display: inline-block;
    padding: 2px 8px;
    background: white;
    border: 1px solid #CCC;
    border-radius: 4px;
    box-shadow: 0 2px 0 #CCC;
    font-family: monospace;
    margin: 0 2px;
}

/* ===== 动画定义 ===== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInDown { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes zoomIn { from { opacity: 0; transform: scale(0.8); } to { opacity: 1; transform: scale(1); } }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.02); } }
@keyframes shake {
    0%,100% { transform: translateX(0); }
    20% { transform: translateX(-10px); }
    40% { transform: translateX(10px); }
    60% { transform: translateX(-6px); }
    80% { transform: translateX(6px); }
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .header h1 { font-size: 28px; }
    .hanzi-display { font-size: 56px; }
    #pinyinInput { font-size: 28px; padding: 12px 16px; }
    .main-card { padding: 24px; }
    .btn { min-height: 44px; padding: 10px 20px; font-size: 16px; }
    .tone-key { min-height: 44px; }
    select { min-height: 44px; }
    .modal .close-btn { width: 44px; height: 44px; }
    .control-row label {
        min-height: 44px;
        padding: 10px 8px;
    }
    .report-detail { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    body {
        padding: calc(52px + env(safe-area-inset-top, 0px)) 10px 10px;
    }
    .back-link {
        top: calc(8px + env(safe-area-inset-top, 0px));
        left: 10px;
        min-height: 34px;
        padding: 0 11px;
        border-radius: 10px;
        font-size: 13px;
    }
    .header {
        margin-bottom: 8px;
    }
    .header h1 {
        margin-bottom: 3px;
        font-size: 20px;
        line-height: 1.2;
    }
    .header .subtitle {
        font-size: 12px;
        line-height: 1.3;
    }
    .stats-bar {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 5px;
        width: 100%;
        margin-bottom: 8px;
    }
    .stat-card {
        min-width: 0;
        padding: 5px 3px;
        border-radius: 10px;
    }
    .stat-card .label {
        margin-bottom: 1px;
        font-size: 10px;
    }
    .stat-card .value {
        font-size: 18px;
    }
    .progress-container {
        margin-bottom: 8px;
    }
    .progress-bar {
        height: 8px;
    }
    .progress-text {
        margin-top: 3px;
        font-size: 12px;
    }
    .main-card {
        padding: 10px 10px 12px;
        border-radius: 16px;
        overflow: visible;
    }
    .unit-tag {
        max-width: 100%;
        margin-bottom: 6px;
        padding: 3px 8px;
        font-size: 12px;
        line-height: 1.25;
    }
    .hanzi-display {
        flex-wrap: wrap;
        min-height: auto;
        margin: 7px 0;
        font-size: 34px;
        line-height: 1.15;
        letter-spacing: 2px;
        white-space: normal;
        word-break: break-all;
        overflow-wrap: anywhere;
    }
    .pinyin-hint {
        min-height: 20px;
        margin-bottom: 8px;
        font-size: 16px;
        overflow-wrap: anywhere;
    }
    .input-area {
        margin: 8px 0;
    }
    #pinyinInput {
        font-size: 20px;
        padding: 8px 10px;
        border-width: 2px;
        border-radius: 12px;
    }
    .tone-tools {
        gap: 5px;
        margin-top: 6px;
    }
    .tone-tools .tip {
        font-size: 11px;
        line-height: 1.25;
    }
    .tone-key {
        min-width: 42px;
        min-height: 34px;
        padding: 5px 7px;
        font-size: 14px;
    }
    .btn-group {
        gap: 6px;
        margin-top: 8px;
    }
    .btn {
        flex: 1 1 calc(50% - 8px);
        min-height: 36px;
        padding: 7px 8px;
        border-radius: 10px;
        font-size: 14px;
    }
    .feedback {
        min-height: 30px;
        margin-top: 8px;
        font-size: 15px;
        line-height: 1.3;
        overflow-wrap: anywhere;
    }
    .answer-compare {
        max-width: 100%;
        margin-top: 6px;
        font-size: 15px;
        line-height: 1.3;
        white-space: normal;
        word-break: break-word;
        overflow-wrap: anywhere;
    }
    .control-panel {
        margin-top: 9px;
        padding-top: 9px;
    }
    .control-row {
        justify-content: flex-start;
        align-items: stretch;
        gap: 6px;
        margin-bottom: 6px;
    }
    .control-label {
        font-size: 12px;
        line-height: 34px;
    }
    select {
        min-height: 34px;
        min-width: 0;
        max-width: 100%;
        padding: 5px 8px;
        font-size: 13px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    #unitSelect {
        flex: 1 1 100%;
        width: 100%;
    }
    #countSelect {
        flex: 1 1 100px;
        max-width: 140px;
    }
    .control-row label {
        flex: 1 1 calc(50% - 8px);
        justify-content: flex-start;
        min-height: 32px;
        padding: 4px 4px;
        font-size: 12px !important;
    }
    .tone-note {
        font-size: 11px;
        line-height: 1.25;
    }
    .keyboard-hint {
        display: none;
    }
    .mistake-btn {
        right: 16px;
        bottom: 16px;
    }
    .modal-overlay {
        align-items: flex-start;
        padding: 12px;
        overflow-y: auto;
    }
    .modal {
        width: 100%;
        max-height: calc(100vh - 24px);
        padding: 24px 16px;
        border-radius: 18px;
    }
    .modal h2 {
        margin-bottom: 14px;
    }
    .mistake-list {
        max-height: none;
    }
    .mistake-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
        padding: 10px 0;
    }
    .mistake-item > div,
    .mistake-item > span {
        max-width: 100%;
        text-align: left;
        overflow-wrap: anywhere;
    }
    .report-score {
        margin: 6px 0;
        font-size: 36px;
        line-height: 1.05;
    }
    .report-detail {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
        margin: 8px 0;
    }
    .report-card {
        max-height: calc(100dvh - 24px);
        overflow: hidden;
    }
    .report-card h2 {
        margin-bottom: 6px;
        font-size: 20px;
        line-height: 1.2;
    }
    .report-item {
        padding: 7px 6px;
        border-radius: 9px;
    }
    .report-item .num {
        font-size: 20px;
        line-height: 1.1;
    }
    .report-item .txt {
        margin-top: 2px;
        font-size: 11px;
    }
    .report-card .btn-group {
        margin-top: 8px !important;
    }
    .report-card .btn {
        min-height: 36px;
        padding: 7px 10px;
        font-size: 14px;
    }
}

