/* ==================== 与系统完全统一的样式（基于043） ==================== */

: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;

    /* 中性色 */
    --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;

    /* 结果页面渐变 */
    --result-gradient: linear-gradient(135deg, #2196f3, #1976d2);
}

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

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

/* 游戏页面固定视口 */
body.game-active {
    height: 100vh;
    overflow: hidden;
    position: fixed;
    width: 100%;
}

.main-container {
    max-width: 900px;
    margin: 2rem auto;
}

.card {
    background: rgba(255, 255, 255, 0.98);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--box-shadow);
    backdrop-filter: blur(10px);
    transition: var(--transition-normal);
    overflow: hidden;
    padding: 0;
    margin-bottom: 20px;
}

.card:hover {
    box-shadow: var(--box-shadow-hover);
}

.hidden {
    display: none !important;
}

.section {
    transition: opacity 0.3s ease;
}

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

.card-title {
    color: white;
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.card-desc {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.95rem;
}

.card-body {
    padding: 2rem;
}

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

.form-label {
    display: block;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

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

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

.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);
}

.user-form {
    margin-bottom: 1.5rem;
}

/* 按钮样式 */
.btn {
    padding: 0.875rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition-normal);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: inherit;
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

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

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

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

.btn-large {
    width: 100%;
    padding: 1rem;
    font-size: 1.125rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--primary-dark) 0%, #1565c0 100%);
    box-shadow: 0 6px 16px rgba(33, 150, 243, 0.4);
}

.btn-secondary {
    background: var(--success-color);
    color: white;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.btn-secondary:hover:not(:disabled) {
    background: #45a049;
    box-shadow: 0 6px 16px rgba(76, 175, 80, 0.4);
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 2px solid var(--border-color);
}

.btn-outline:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-2px);
}

.btn-text {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    padding: 0.5rem 1rem;
}

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

.btn-danger {
    color: var(--error-color);
}

.btn-danger:hover {
    color: #d32f2f;
}

/* 训练说明 */
.instructions {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    margin: 1.5rem 0;
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary-color);
}

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

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

.instructions-list li {
    padding: 0.625rem 0;
    padding-left: 2rem;
    position: relative;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.instructions-list li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--success-color);
    font-weight: 600;
}

/* 按钮组 */
.button-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

@media (min-width: 480px) {
    .button-group {
        flex-direction: row;
    }
}

.button-group .btn {
    flex: 1;
}

/* ==================== 游戏头部 ==================== */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border-bottom: 1px solid var(--border-color);
    gap: 8px;
}

.game-info {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

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

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

.timer-value {
    font-family: 'Courier New', monospace;
    color: var(--primary-color);
    font-size: 1.5rem;
}

.timer-value.urgent {
    color: var(--error-color) !important;
}

.time-highlight {
    color: var(--primary-color);
    font-family: 'Courier New', monospace;
}

    .game-actions {
        display: flex;
        gap: 4px;
        flex-shrink: 0;
    }

    .game-actions .btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.78rem;
        white-space: nowrap;
    }

/* ==================== 游戏内容区 ==================== */
.game-content {
    padding: 1.5rem 2rem;
    min-height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    overflow-y: auto;
}

.phase-label {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 1rem;
    text-align: center;
}

/* 曼陀罗容器 */
.mandala-container {
    display: flex;
    justify-content: center;
    align-items: center;
}

.mandala-large {
    width: 320px;
    height: 320px;
}

/* 曼陀罗图案样式 */
.mandala-svg {
    width: 100%;
    height: 100%;
}

.mandala-sector {
    stroke: #333;
    stroke-width: 2;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mandala-color {
    cursor: default;
}

.mandala-frame:hover {
    filter: brightness(0.95);
}

.mandala-sector.just-filled {
    transition: fill 0.2s ease;
}

/* 中心圆 */
.mandala-center {
    fill: #333;
}

/* 倒计时显示 */
.countdown-timer {
    font-size: 4rem;
    font-weight: 800;
    color: var(--primary-color);
    margin: 1rem 0;
    font-family: 'Courier New', monospace;
}

/* 颜色选择器 */
.color-palette {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 1.5rem;
    padding: 1.25rem;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    border: 2px solid var(--border-color);
    max-width: 400px;
    min-height: 70px;
}

.color-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 3px solid white;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.color-btn:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

.color-btn.selected {
    border-color: #333;
    transform: scale(1.18);
    box-shadow: 0 0 0 3px var(--primary-color);
}

/* 选中的颜色显示 */
.selected-color-display {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 1rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.color-preview {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 2px solid #ccc;
    background: #e0e0e0;
}

/* 反馈阶段 */
.feedback-section {
    text-align: center;
    z-index: 100;
    background: white;
    padding: 1.5rem 2.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    margin: 1rem auto;
}

.feedback-section.hidden {
    display: none;
}

.feedback-icon {
    font-size: 4rem;
    margin-bottom: 0.5rem;
}

.feedback-text {
    font-size: 1.35rem;
    font-weight: 700;
}

.feedback-icon.correct {
    color: var(--success-color);
}

.feedback-icon.wrong {
    color: var(--error-color);
}

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

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

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

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

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

.stat-item {
    text-align: center;
    padding: 1.5rem;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: var(--transition-normal);
}

.stat-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

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

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

.result-feedback {
    padding: 2rem;
    border-top: 1px solid var(--border-color);
}

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

.feedback-content {
    color: var(--text-secondary);
    line-height: 1.8;
}

.result-actions {
    padding: 2rem;
    display: flex;
    gap: 1rem;
    justify-content: center;
    border-top: 1px solid var(--border-color);
}

.result-actions .btn {
    flex: 1;
    min-width: 140px;
}

/* ==================== 记录列表 ==================== */
.records-list {
    padding: 2rem;
    max-height: 500px;
    overflow-y: auto;
}

.record-item {
    background: white;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
    transition: var(--transition-normal);
}

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

.record-rank {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.record-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

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

.record-date {
    font-size: 0.85rem;
    color: var(--text-light);
}

.record-stats {
    display: flex;
    justify-content: space-around;
    font-size: 0.9375rem;
}

.record-correct {
    color: var(--success-color);
    font-weight: 600;
}

.record-accuracy {
    color: var(--primary-color);
    font-weight: 600;
}

.record-time {
    font-weight: 600;
}

.empty,
.error {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-secondary);
}

.error {
    color: var(--error-color);
}

.loading {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.loading::after {
    content: '...';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* ==================== 模态框 ==================== */
.modal {
    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;
}

.modal.show {
    display: flex;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
}

.modal-overlay.show {
    display: block;
}

.modal-content {
    background-color: white;
    border-radius: var(--border-radius-lg);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    z-index: 1001;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.btn-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
}

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

.modal-body {
    padding: 20px;
}

.leaderboard-list,
.records-list-modal {
    overflow-x: auto;
}

/* 排行榜表格 */
.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.leaderboard-table th,
.leaderboard-table td {
    padding: 12px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

.leaderboard-table th {
    background-color: var(--bg-primary);
    font-weight: 600;
    color: var(--text-primary);
}

.leaderboard-table tbody tr:hover {
    background-color: var(--bg-primary);
}

.leaderboard-table .rank {
    font-weight: bold;
    width: 60px;
}

.leaderboard-table .medal {
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    margin-left: 5px;
    vertical-align: middle;
}

.leaderboard-table .medal.medal-1 {
    background: linear-gradient(135deg, #ffd700, #ffb900);
    box-shadow: 0 0 5px #ffd700;
}

.leaderboard-table .medal.medal-2 {
    background: linear-gradient(135deg, #c0c0c0, #a8a8a8);
    box-shadow: 0 0 5px #c0c0c0;
}

.leaderboard-table .medal.medal-3 {
    background: linear-gradient(135deg, #cd7f32, #a05a2c);
    box-shadow: 0 0 5px #cd7f32;
}

.user-name {
    font-weight: 600;
    color: var(--text-primary);
}

.time {
    color: var(--primary-color);
    font-weight: 600;
}

.accuracy {
    color: var(--success-color);
    font-weight: 600;
}

/* ==================== 响应式设计 ==================== */
@media (max-width: 768px) {
    body.game-active {
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
    }

    .main-container {
        margin: 0.5rem;
    }

    .card-header,
    .card-body {
        padding: 1rem;
    }

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

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

    /* 手机端游戏头部保持一行 */
    .game-header {
        padding: 0.75rem 1rem;
        gap: 4px;
    }

    .game-info {
        gap: 0.6rem;
    }

    .info-label {
        font-size: 0.65rem;
    }

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

    .timer-value {
        font-size: 1.2rem;
    }

    .mandala-large {
        width: 280px;
        height: 280px;
    }

    .color-btn {
        width: 42px;
        height: 42px;
    }

    .phase-label {
        font-size: 1rem;
    }

    .countdown-timer {
        font-size: 3rem;
    }

    .game-content {
        padding: 1.25rem;
    }

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

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

    .result-actions {
        flex-wrap: wrap;
    }

    .result-actions .btn {
        min-width: 120px;
        flex: 1 1 45%;
    }

    .result-feedback {
        padding: 1.25rem;
    }

    .feedback-title {
        font-size: 1rem;
    }

    .instructions-list li {
        font-size: 0.9rem;
    }

    .records-list {
        padding: 1.5rem;
    }

    .record-item {
        padding: 1.25rem;
    }

    .modal-content {
        width: 95%;
        max-height: 90vh;
    }

    .leaderboard-table {
        font-size: 0.875rem;
    }

    .leaderboard-table th,
    .leaderboard-table td {
        padding: 0.75rem 0.5rem;
    }
}

@media (max-width: 480px) {
    .card-header {
        padding: 1.25rem;
    }

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

    .card-body {
        padding: 1.25rem;
    }

    .mandala-large {
        width: 240px;
        height: 240px;
    }

    .color-btn {
        width: 38px;
        height: 38px;
    }

    .color-palette {
        gap: 8px;
        padding: 10px;
    }

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

    .result-actions {
        flex-direction: column;
    }

    .result-actions .btn {
        flex: 1 1 100%;
    }

    .button-group {
        flex-direction: column;
    }

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

    .countdown-timer {
        font-size: 2.5rem;
    }

    .phase-label {
        font-size: 0.95rem;
    }

    .instructions-list li {
        font-size: 0.875rem;
    }

    .game-content {
        padding: 1rem;
    }

    .feedback-section {
        padding: 1rem 1.5rem;
    }

    .feedback-icon {
        font-size: 3rem;
    }

    .feedback-text {
        font-size: 1.15rem;
    }
}
