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

body {
    font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.game-container {
    width: 100%;
    max-width: 600px;
    background: white;
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
    min-height: 600px;
}

/* 页面通用样式 */
.page {
    display: none;
    padding: 30px;
    min-height: 600px;
}

.page.active {
    display: block;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 首页样式 */
.title-area {
    text-align: center;
    margin-bottom: 30px;
}

.title-area h1 {
    font-size: 2.2em;
    color: #5a67d8;
    margin-bottom: 10px;
}

.subtitle {
    color: #718096;
    font-size: 1.1em;
}

.mode-selection h2 {
    text-align: center;
    margin-bottom: 20px;
    color: #2d3748;
}

.mode-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

.mode-btn {
    display: flex;
    align-items: center;
    padding: 20px;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    background: #f7fafc;
    border: 3px solid transparent;
}

.mode-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

.mode-btn.easy {
    border-color: #48bb78;
    background: linear-gradient(135deg, #f0fff4 0%, #c6f6d5 100%);
}

.mode-btn.medium {
    border-color: #ed8936;
    background: linear-gradient(135deg, #fffaf0 0%, #feebc8 100%);
}

.mode-btn.hard {
    border-color: #e53e3e;
    background: linear-gradient(135deg, #fff5f5 0%, #fed7d7 100%);
}

/* 首页模式说明 */
.mode-info {
    margin-top: 25px;
    padding: 20px;
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    border-radius: 16px;
    border: 2px solid #e2e8f0;
}

.mode-info h3 {
    color: #2d3748;
    margin-bottom: 15px;
    font-size: 1.1em;
    text-align: center;
}

.mode-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mode-card {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border-radius: 12px;
    background: white;
    border: 2px solid transparent;
}

.mode-card.easy {
    border-color: #48bb78;
    background: linear-gradient(135deg, #f0fff4 0%, #c6f6d5 100%);
}

.mode-card.medium {
    border-color: #ed8936;
    background: linear-gradient(135deg, #fffaf0 0%, #feebc8 100%);
}

.mode-card.hard {
    border-color: #e53e3e;
    background: linear-gradient(135deg, #fff5f5 0%, #fed7d7 100%);
}

.mode-tag {
    font-size: 1.8em;
    margin-right: 12px;
}

.mode-detail {
    display: flex;
    flex-direction: column;
}

.mode-detail strong {
    color: #2d3748;
    font-size: 0.95em;
}

.mode-detail span {
    color: #718096;
    font-size: 0.85em;
}

.mode-icon {
    font-size: 2.5em;
    margin-right: 15px;
}

.mode-name {
    font-size: 1.3em;
    font-weight: bold;
    color: #2d3748;
    display: block;
}

.mode-desc {
    font-size: 0.9em;
    color: #718096;
}

.instructions {
    background: #edf2f7;
    padding: 20px;
    border-radius: 12px;
}

.instructions h3 {
    color: #2d3748;
    margin-bottom: 10px;
}

.instructions ul {
    list-style: none;
    padding-left: 0;
}

.instructions li {
    padding: 5px 0;
    color: #4a5568;
    padding-left: 25px;
    position: relative;
}

.instructions li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: #48bb78;
    font-weight: bold;
}

.keyboard-hint {
    margin-top: 15px;
    padding: 12px 15px;
    background: linear-gradient(135deg, #ebf8ff 0%, #bee3f8 100%);
    border-radius: 10px;
    color: #2b6cb0;
    font-size: 0.95em;
    border-left: 4px solid #4299e1;
}

.keyboard-hint kbd {
    background: white;
    padding: 3px 10px;
    border-radius: 5px;
    border: 2px solid #cbd5e0;
    font-family: monospace;
    font-size: 0.9em;
    box-shadow: 0 2px 0 #cbd5e0;
}

/* 调试信息 */
.debug-info {
    margin-top: 20px;
    padding: 10px;
    background: #f7fafc;
    border-radius: 8px;
    font-family: monospace;
    font-size: 12px;
    color: #4a5568;
    border: 1px dashed #cbd5e0;
}

.debug-info div {
    margin: 5px 0;
}

/* 游戏页面样式 */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e2e8f0;
}

.back-btn {
    background: #e2e8f0;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s;
}

.back-btn:hover {
    background: #cbd5e0;
}

.level-info {
    font-size: 1em;
    color: #4a5568;
}

.divider {
    margin: 0 10px;
    color: #cbd5e0;
}

#mode-display {
    font-weight: bold;
    color: #5a67d8;
}

.score {
    font-size: 1.2em;
    font-weight: bold;
    color: #ed8936;
}

.progress-bar {
    height: 10px;
    background: #e2e8f0;
    border-radius: 5px;
    margin-bottom: 30px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #48bb78, #38a169);
    border-radius: 5px;
    transition: width 0.5s ease;
    width: 0%;
}

.game-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
}

.pinyin-card {
    width: 200px;
    height: 200px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 15px 35px rgba(102, 126, 234, 0.4);
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.pinyin-letter {
    font-size: 5em;
    font-weight: bold;
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.pinyin-case {
    margin-top: 10px;
}

#pinyin-lower {
    font-size: 2em;
    color: rgba(255,255,255,0.8);
}

.timer-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    margin-bottom: 8px;
    font-size: 1.2em;
    font-weight: bold;
    color: #ed8936;
}

.timer-icon {
    font-size: 1em;
}

.timer-text {
    font-size: 1.5em;
    min-width: 30px;
    text-align: center;
}

.timer-text.warning {
    color: #e53e3e;
    animation: pulse 0.5s ease infinite;
}

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

.timer-unit {
    font-size: 0.9em;
    color: #718096;
}

.timer-bar {
    width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.timer-fill {
    height: 100%;
    background: linear-gradient(90deg, #ed8936, #dd6b20);
    border-radius: 4px;
    width: 100%;
    transition: width 0.1s linear;
}

.voice-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.recording-visualizer {
    width: 100%;
    max-width: 300px;
    background: #f7fafc;
    border-radius: 12px;
    padding: 10px;
    margin-bottom: 10px;
}

#audio-visualizer {
    width: 100%;
    height: 60px;
    border-radius: 8px;
    background: #edf2f7;
}

.recording-time {
    text-align: center;
    font-size: 1.2em;
    font-weight: bold;
    color: #e53e3e;
    margin-top: 8px;
    font-family: monospace;
}

.mic-btn {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
    color: white;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    box-shadow: 0 10px 30px rgba(245, 101, 101, 0.4);
    transition: all 0.3s ease;
    user-select: none;
    -webkit-user-select: none;
}

.mic-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 15px 40px rgba(245, 101, 101, 0.5);
}

.mic-btn:active {
    transform: scale(0.95);
}

/* 录音控制容器 */
#record-controls, #stop-controls {
    display: flex;
    justify-content: center;
}

/* 停止录音按钮 */
.stop-btn {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    box-shadow: 0 10px 30px rgba(72, 187, 120, 0.4);
    animation: pulse 1.5s infinite;
    user-select: none;
    -webkit-user-select: none;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 10px 30px rgba(72, 187, 120, 0.4); }
    50% { box-shadow: 0 10px 40px rgba(72, 187, 120, 0.7); }
}

.stop-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 15px 40px rgba(72, 187, 120, 0.5);
}

.stop-btn:active {
    transform: scale(0.95);
}

.stop-icon {
    font-size: 2.5em;
}

.stop-text {
    font-size: 0.9em;
    font-weight: bold;
}

.mic-icon {
    font-size: 2.5em;
}

.mic-text {
    font-size: 0.9em;
    font-weight: bold;
}

.voice-status {
    min-height: 24px;
    font-size: 1em;
    color: #4a5568;
    text-align: center;
    padding: 8px 16px;
    border-radius: 20px;
    transition: all 0.3s;
}

.voice-status.recording {
    background: linear-gradient(135deg, #fed7d7 0%, #feb2b2 100%);
    color: #c53030;
    font-weight: bold;
    animation: blink 1s ease infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.feedback {
    min-height: 60px;
    text-align: center;
    font-size: 1.2em;
    font-weight: bold;
}

.feedback.correct {
    color: #48bb78;
}

.feedback.wrong {
    color: #e53e3e;
}

.feedback.skipped {
    color: #ed8936;
}

.hint-area {
    margin-top: 20px;
    text-align: center;
}

.letter-hint {
    color: #5a67d8;
    font-size: 1em;
    margin-bottom: 10px;
    font-weight: 500;
}

.hint-text {
    margin-top: 10px;
    color: #718096;
    font-size: 0.9em;
    min-height: 20px;
}

/* 播放控制按钮 */
.playback-controls {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.play-btn, .record-btn, .next-btn {
    padding: 12px 20px;
    border: none;
    border-radius: 25px;
    font-size: 0.95em;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.play-btn {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
}

.play-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(72, 187, 120, 0.4);
}

.record-btn {
    background: linear-gradient(135deg, #ed8936 0%, #dd6b20 100%);
    color: white;
}

.record-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(237, 137, 54, 0.4);
}

.next-btn {
    background: linear-gradient(135deg, #5a67d8 0%, #4c51bf 100%);
    color: white;
}

.next-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(90, 103, 216, 0.4);
}

/* 结果页面 */
.result-content {
    text-align: center;
    padding: 40px 20px;
}

.result-emoji {
    font-size: 5em;
    margin-bottom: 20px;
    animation: bounce 1s ease infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

.result-content h2 {
    font-size: 2em;
    color: #2d3748;
    margin-bottom: 10px;
}

.result-content p {
    color: #718096;
    font-size: 1.1em;
    margin-bottom: 20px;
}

.final-score {
    font-size: 1.5em;
    color: #ed8936;
    font-weight: bold;
    margin-bottom: 20px;
}

/* 成绩报告 */
.result-report {
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
    border: 2px solid #e2e8f0;
}

.report-mode {
    font-size: 1.1em;
    font-weight: bold;
    color: #5a67d8;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px dashed #cbd5e0;
}

.report-stats {
    display: flex;
    justify-content: space-around;
    gap: 15px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-value {
    font-size: 1.8em;
    font-weight: bold;
    color: #2d3748;
}

.stat-label {
    font-size: 0.85em;
    color: #718096;
    margin-top: 5px;
}

/* 学习建议 */
.result-suggestions {
    background: linear-gradient(135deg, #fffaf0 0%, #feebc8 100%);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
    border: 2px solid #fbd38d;
    text-align: left;
}

.result-suggestions h3 {
    color: #c05621;
    margin-bottom: 15px;
    font-size: 1.1em;
    text-align: center;
}

.suggestion-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.suggestion-item {
    background: white;
    padding: 12px 15px;
    border-radius: 10px;
    border-left: 4px solid #ed8936;
    font-size: 0.95em;
    color: #744210;
    line-height: 1.5;
}

/* 下一级推荐 */
.next-level-suggestion {
    background: linear-gradient(135deg, #f0fff4 0%, #c6f6d5 100%);
    border-radius: 12px;
    padding: 15px 20px;
    margin-bottom: 25px;
    border: 2px solid #9ae6b4;
    color: #276749;
    font-weight: 500;
}

/* 复盘按钮 */
.btn-review {
    width: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 30px;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.3s;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-review:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}

/* 复盘页面 */
.review-content {
    padding: 20px;
    min-height: 600px;
}

.review-header {
    text-align: center;
    margin-bottom: 20px;
}

.review-header h2 {
    font-size: 1.8em;
    color: #2d3748;
    margin: 10px 0;
}

.review-header p {
    color: #718096;
}

.review-stats {
    display: flex;
    justify-content: space-around;
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
    border: 2px solid #e2e8f0;
}

.review-stat-item {
    text-align: center;
}

.review-stat-value {
    display: block;
    font-size: 2em;
    font-weight: bold;
    color: #5a67d8;
}

.review-stat-label {
    font-size: 0.9em;
    color: #718096;
}

.review-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 10px;
    margin-bottom: 20px;
}

.review-item {
    background: white;
    border-radius: 16px;
    padding: 15px;
    border: 2px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: all 0.3s;
}

.review-item:hover {
    border-color: #cbd5e0;
    transform: translateX(5px);
}

.review-item-letter {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    flex-shrink: 0;
}

.review-item-letter .letter-big {
    font-size: 1.5em;
    line-height: 1;
}

.review-item-letter .letter-small {
    font-size: 0.8em;
    opacity: 0.9;
}

.review-item-info {
    flex: 1;
}

.review-item-info .pinyin-name {
    font-size: 1.1em;
    font-weight: bold;
    color: #2d3748;
}

.review-item-info .pinyin-sound {
    font-size: 0.9em;
    color: #718096;
}

.review-item-status {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 500;
}

.review-item-status.recorded {
    background: #c6f6d5;
    color: #276749;
}

.review-item-status.skipped {
    background: #feebc8;
    color: #c05621;
}

.review-item-play {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    border: none;
    color: white;
    font-size: 1.2em;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.review-item-play:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(72, 187, 120, 0.4);
}

.review-item-play:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.review-actions {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.result-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.btn-primary, .btn-secondary {
    padding: 15px 40px;
    border: none;
    border-radius: 30px;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(72, 187, 120, 0.4);
}

.btn-secondary {
    background: #e2e8f0;
    color: #4a5568;
}

.btn-secondary:hover {
    background: #cbd5e0;
}

/* 弹窗 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    max-width: 350px;
}

.modal-content h3 {
    margin-bottom: 15px;
    color: #2d3748;
}

.modal-content p {
    color: #4a5568;
    margin-bottom: 10px;
}

.modal-content .small {
    font-size: 0.9em;
    color: #718096;
}

.modal-content .error-detail {
    background: #fff5f5;
    border: 1px solid #fed7d7;
    border-radius: 12px;
    padding: 15px;
    margin: 15px 0;
    color: #c53030;
    font-size: 0.95em;
    text-align: left;
    line-height: 1.6;
}

.modal-content .help-section {
    background: #f0fff4;
    border: 1px solid #c6f6d5;
    border-radius: 12px;
    padding: 15px;
    margin: 15px 0;
    text-align: left;
}

.modal-content .help-title {
    font-weight: bold;
    color: #276749;
    margin-bottom: 10px;
}

.modal-content .help-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.modal-content .help-list li {
    color: #4a5568;
    font-size: 0.9em;
    padding: 5px 0;
    padding-left: 20px;
    position: relative;
}

.modal-content .help-list li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: #48bb78;
    font-weight: bold;
}

.modal-content .btn-secondary {
    background: #e2e8f0;
    color: #4a5568;
    border: none;
    padding: 12px 24px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1em;
    margin-left: 10px;
    transition: all 0.3s;
}

.modal-content .btn-secondary:hover {
    background: #cbd5e0;
}

/* 麦克风设备选择 */
.mic-device-section {
    background: #ebf8ff;
    border: 2px solid #4299e1;
    border-radius: 12px;
    padding: 15px;
    margin: 15px 0;
    text-align: left;
}

.mic-device-select {
    width: 100%;
    padding: 10px;
    border: 2px solid #cbd5e0;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    margin-top: 8px;
    cursor: pointer;
}

.mic-device-select:focus {
    outline: none;
    border-color: #4299e1;
}

.mic-device-hint {
    font-size: 12px;
    color: #718096;
    margin-top: 8px;
    font-style: italic;
}

/* 跳过按钮 */
.skip-btn {
    background: #f7fafc;
    border: 2px solid #cbd5e0;
    color: #718096;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 15px auto 0;
}

.skip-btn:hover {
    background: #edf2f7;
    border-color: #a0aec0;
    transform: translateY(-2px);
}

.skip-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* 响应式 */
@media (max-width: 480px) {
    .game-container {
        border-radius: 0;
        min-height: 100vh;
    }
    
    .page {
        padding: 20px;
    }
    
    .title-area h1 {
        font-size: 1.8em;
    }
    
    .pinyin-card {
        width: 160px;
        height: 160px;
    }
    
    .pinyin-letter {
        font-size: 4em;
    }
}
