/* ==================== 基础样式 ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* 主色调 - 蓝色和绿色 */
    --primary-color: #2196f3;
    --primary-light: #4caf50;
    --primary-dark: #1976d2;
    --primary-gradient: var(--primary-color);

    /* 辅助色 */
    --success-color: #4caf50;
    --warning-color: #ff9800;
    --error-color: #f44336;
    --info-color: #2196f3;
    --danger-color: #e74c3c;

    /* 中性色 */
    --text-primary: #2c3e50;
    --text-secondary: #6c757d;
    --text-light: #95a5a6;
    --bg-primary: #f8f9fa;
    --bg-white: #ffffff;
    --bg-dark: #343a40;

    /* 边框和阴影 */
    --border-color: #e8f0fe;
    --border-radius: 12px;
    --border-radius-lg: 20px;
    --box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --box-shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.12);
    --box-shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.15);

    /* 过渡效果 */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: linear-gradient(135deg, #f6f9fc 0%, #eef2f6 100%);
    min-height: 100vh;
}

/* ==================== 主容器 ==================== */
.main-container {
    max-width: 900px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

/* ==================== 卡片样式 ==================== */
.card {
    background: var(--bg-white);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow-lg);
    overflow: hidden;
    transition: var(--transition-normal);
}

.card:hover {
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
}

.card-header {
    background: var(--primary-gradient);
    color: white;
    padding: 1.75rem 2rem;
    text-align: center;
}

.card-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.card-desc {
    font-size: 1rem;
    opacity: 0.95;
}

.card-body {
    padding: 2rem;
}

/* ==================== Section 样式 ==================== */
.section {
    transition: opacity 0.3s ease;
}

.hidden {
    display: none !important;
}

/* ==================== 表单样式 ==================== */
.user-form {
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9375rem;
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    transition: var(--transition-fast);
    outline: none;
    background: var(--bg-white);
}

.form-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

select.form-input {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236c757d' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

.form-select {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background: white;
    cursor: pointer;
    transition: var(--transition-fast);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236c757d' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

.form-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

/* ==================== 按钮样式 ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-fast);
    outline: none;
    box-shadow: var(--box-shadow);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--box-shadow-hover);
}

.btn:active {
    transform: translateY(0);
}

.btn-icon {
    font-size: 1.125rem;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--primary-light);
    color: white;
}

.btn-secondary:hover {
    background: #388e3c;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
    border: none;
}

.btn-danger:hover {
    background: #c0392b;
    transform: translateY(-1px);
}

.btn-outline {
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn-outline:hover {
    background: var(--bg-primary);
}

.btn-large {
    padding: 1rem 2.5rem;
    font-size: 1.125rem;
}

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

.btn-text {
    background: transparent;
    box-shadow: none;
    padding: 0.5rem 1rem;
}

.btn-text:hover {
    color: var(--primary-color);
}

.btn-group {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

/* ==================== 训练说明 ==================== */
.instructions {
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.instructions-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.instructions-list {
    list-style: none;
}

.instructions-list li {
    position: relative;
    padding-left: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

.instructions-list li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--primary-color);
    font-weight: bold;
    font-size: 1.2em;
}

/* ==================== 游戏控制栏 ==================== */
.game-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1.5rem 2rem;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border-bottom: 1px solid var(--border-color);
}

.control-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.control-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.control-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ==================== 游戏板区域 ==================== */
.game-board-area {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.instruction-box {
    background: rgba(33, 150, 243, 0.1);
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    text-align: center;
    min-width: 300px;
}

#instruction-text {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--primary-color);
    margin: 0;
}

.progress-container {
    width: 100%;
    max-width: 600px;
    margin-bottom: 1.5rem;
}

.progress-bar {
    width: 100%;
    height: 12px;
    background: #e9ecef;
    border-radius: 6px;
    overflow: hidden;
}

#training-progress {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-dark));
    transition: width 0.3s ease;
    border-radius: 6px;
    width: 0%;
}

.game-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
}

/* ==================== 结果卡片 ==================== */
.result-header {
    text-align: center;
    padding: 2rem;
    background: var(--primary-gradient);
    color: white;
}

.result-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: bounce 1s ease;
}

.result-title {
    font-size: 2rem;
    font-weight: 700;
    color: white;
}

.result-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    padding: 2rem;
}

@media (min-width: 768px) {
    .result-stats {
        grid-template-columns: repeat(4, 1fr);
    }
}

.stat-item {
    text-align: center;
    padding: 1.5rem;
    background: var(--bg-primary);
    border-radius: 8px;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.time-highlight {
    color: var(--warning-color);
}

/* ==================== 结果反馈 ==================== */
.result-feedback {
    padding: 1.5rem 2rem;
}

.feedback-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.feedback-content {
    margin-top: 1rem;
}

/* 答案序列 */
.answer-sequence {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    padding: 1rem;
    background: var(--bg-primary);
    border-radius: var(--border-radius);
}

.answer-bead {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    font-size: 0.875rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.answer-bead.red {
    background: linear-gradient(135deg, #f44336 0%, #d32f2f 100%);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

.answer-bead.yellow {
    background: linear-gradient(135deg, #ffeb3b 0%, #fbc02d 100%);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.15);
}

.answer-bead.blue {
    background: linear-gradient(135deg, #2196f3 0%, #1976d2 100%);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

.answer-bead.green {
    background: linear-gradient(135deg, #4caf50 0%, #388e3c 100%);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

.answer-bead.black {
    background: linear-gradient(135deg, #212121 0%, #000000 100%);
    box-shadow: inset 0 2px 4px rgba(255,255,255,0.1);
}

/* ==================== 操作按钮 ==================== */
.result-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    padding: 1.5rem 2rem;
}

/* ==================== 错误记录区域 ==================== */
.mistakes-section {
    margin-top: 1.5rem;
    padding: 1.25rem;
    background: linear-gradient(135deg, #fff9c4 0%, #fff59d 100%);
    border-radius: var(--border-radius);
    border: 2px solid #ffd700;
}

.mistakes-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.mistakes-textarea {
    width: 100%;
    padding: 0.875rem;
    font-size: 1rem;
    border: 2px solid #ffd700;
    border-radius: var(--border-radius);
    background: white;
    transition: var(--transition-fast);
    font-family: inherit;
    resize: vertical;
    min-height: 80px;
    margin-bottom: 0.75rem;
}

.mistakes-textarea:focus {
    outline: none;
    border-color: #ffb300;
    box-shadow: 0 0 0 3px rgba(255, 179, 0, 0.1);
}

.mistakes-content {
    color: var(--text-primary);
    line-height: 1.8;
    padding: 0.75rem;
    background: white;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* ==================== 记录界面 ==================== */
.empty-message, .loading {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-light);
    background: var(--bg-primary);
    border-radius: 8px;
    border: 2px dashed var(--border-color);
}

.empty-message {
    font-size: 1.1rem;
}

.records-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 500px;
    overflow-y: auto;
}

.record-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    transition: var(--transition-fast);
}

.record-item:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.record-rank {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.record-rank.rank-1 {
    background: linear-gradient(135deg, #ffd700 0%, #ffb300 100%);
    color: white;
}

.record-rank.rank-2 {
    background: linear-gradient(135deg, #c0c0c0 0%, #a0a0a0 100%);
    color: white;
}

.record-rank.rank-3 {
    background: linear-gradient(135deg, #cd7f32 0%, #b87333 100%);
    color: white;
}

.record-info {
    flex: 1;
    min-width: 0;
}

.record-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.record-date {
    font-size: 0.875rem;
    color: var(--text-light);
    margin-bottom: 0.25rem;
}

.record-details {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.record-time {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 1.125rem;
    margin-right: 1rem;
}

.record-accuracy {
    font-weight: 700;
    color: var(--success-color);
    font-size: 1.125rem;
}

.record-mistakes {
    font-size: 0.875rem;
    color: var(--warning-color);
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: rgba(255, 152, 0, 0.1);
    border-radius: 6px;
    border-left: 3px solid var(--warning-color);
}

.records-actions {
    display: flex;
    justify-content: center;
    padding: 1.5rem 2rem;
}

/* ==================== 动画 ==================== */
@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-20px);
    }
}

/* ==================== 响应式设计 ==================== */
@media (max-width: 768px) {
    body {
        padding: 1rem 0;
    }

    .main-container {
        margin: 1rem auto;
        padding: 0 1rem;
    }

    .card-header {
        padding: 1.5rem;
    }

    .card-title {
        font-size: 1.5rem;
    }

    .card-body {
        padding: 1.25rem;
    }

    .game-controls {
        gap: 0.75rem;
        padding: 1rem;
    }

    .control-label {
        font-size: 0.75rem;
    }

    .control-value {
        font-size: 1rem;
    }

    .game-board-area {
        padding: 1rem;
    }

    .result-stats {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .stat-value {
        font-size: 1.25rem;
    }

    .result-actions, .btn-group {
        grid-template-columns: 1fr;
    }
}

/* 超小屏幕优化 */
@media (max-width: 480px) {
    .game-controls {
        padding: 0.4rem 0.5rem;
        gap: 0.3rem;
    }

    .control-label {
        font-size: 0.6rem;
    }

    .control-value {
        font-size: 0.85rem;
    }
}
