/* ========== 基础重置与变量 ========== */
:root {
    --primary-color: #4A90D9;
    --primary-hover: #357ABD;
    --success-color: #52c41a;
    --warning-color: #faad14;
    --error-color: #ff4d4f;
    --bg-color: #f0f5ff;
    --card-bg: #ffffff;
    --text-primary: #262626;
    --text-secondary: #595959;
    --text-light: #8c8c8c;
    --border-color: #d9d9d9;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 6px 20px rgba(0, 0, 0, 0.15);
    --radius: 12px;
    --transition: all 0.3s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* ========== 屏幕切换 ========== */
.screen {
    display: none;
    min-height: 100vh;
    animation: fadeIn 0.5s ease;
}

.screen.active {
    display: block;
}

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

/* ========== 弹窗 ========== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1001;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-hover);
    padding: 32px;
    max-width: 500px;
    width: 90%;
}

.modal.hidden {
    display: none;
}

.modal-content h3 {
    font-size: 20px;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.modal-content p {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.8;
}

/* ========== 头部 ========== */
.header {
    text-align: center;
    margin-bottom: 32px;
}

.game-title {
    font-size: 36px;
    color: #ffffff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    margin-bottom: 8px;
}

.game-subtitle {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.9);
}

.phase-title {
    font-size: 28px;
    color: #ffffff;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.2);
}

.timer-display {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    margin-top: 16px;
}

.timer {
    font-size: 48px;
    font-weight: bold;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 24px;
    border-radius: 50px;
    min-width: 80px;
}

.timer-unit {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.9);
}

.quiz-progress {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.9);
    margin-top: 12px;
}

/* ========== 警告横幅 ========== */
.warning-banner {
    background: #fff7e6;
    border-left: 4px solid var(--warning-color);
    border-radius: 8px;
    padding: 16px 20px;
    margin: 24px 0;
}

.warning-text {
    font-size: 14px;
    color: #d46b08;
    line-height: 1.8;
}

/* ========== 难度选择 ========== */
.section-title {
    font-size: 24px;
    color: #ffffff;
    text-align: center;
    margin-bottom: 24px;
}

.difficulty-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    margin: 32px 0;
}

.difficulty-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow);
    transition: var(--transition);
    text-align: center;
}

.difficulty-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-hover);
}

.difficulty-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.difficulty-card h3 {
    font-size: 22px;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.difficulty-desc {
    text-align: left;
    margin: 20px 0;
}

.difficulty-desc p {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 8px 0;
}

.difficulty-target {
    font-size: 13px;
    color: var(--text-light);
    font-style: italic;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

/* ========== 按钮 ========== */
.btn-primary,
.btn-secondary {
    padding: 12px 32px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    margin: 8px;
}

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

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

.btn-secondary {
    background: #f0f0f0;
    color: var(--text-primary);
}

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

.btn-start {
    width: 100%;
    padding: 14px;
    background: var(--primary-color);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 16px;
}

.btn-start:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.btn-submit {
    display: block;
    margin: 32px auto;
    padding: 14px 48px;
    font-size: 18px;
}

/* ========== 左上角主站按钮 ========== */
.corner-home {
    position: fixed;
    top: 16px;
    left: 16px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    font-size: 20px;
    text-decoration: none;
    transition: var(--transition);
    z-index: 100;
}

.corner-home:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(1.1);
}

/* ========== 右上角反馈按钮 ========== */
.corner-feedback {
    position: fixed;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    transition: var(--transition);
    z-index: 100;
    color: inherit;
    line-height: 1;
}

.corner-feedback:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(1.1);
}

/* ========== 反馈弹窗遮罩 ========== */
#feedback-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.55);
    z-index: 2000;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

#feedback-overlay.active {
    display: block;
}

/* ========== 反馈弹窗卡片 ========== */
.feedback-modal {
    position: relative;
    margin: 40px auto;
    z-index: 2001;
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 36px 32px 28px;
    max-width: 500px;
    width: 92%;
    animation: feedbackSlideIn 0.35s ease;
}

@keyframes feedbackSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.feedback-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
    text-align: center;
}

.feedback-subtitle {
    font-size: 14px;
    color: var(--text-light);
    margin-bottom: 28px;
    text-align: center;
    line-height: 1.6;
}

/* ========== 反馈表单字段 ========== */
.feedback-field {
    margin-bottom: 16px;
}

.feedback-field label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.feedback-field input,
.feedback-field textarea,
.feedback-field select {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    font-size: 15px;
    font-family: inherit;
    color: var(--text-primary);
    background: #f8f9fc;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
    box-sizing: border-box;
}

.feedback-field input::placeholder,
.feedback-field textarea::placeholder {
    color: #bfbfbf;
}

.feedback-field input:focus,
.feedback-field textarea:focus,
.feedback-field select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.12);
    background: #fff;
}

.feedback-field textarea {
    resize: vertical;
    min-height: 110px;
    line-height: 1.6;
}

/* ========== 评分按钮组 ========== */
.rating-group {
    display: flex;
    gap: 8px;
}

.rating-group .rating-btn {
    flex: 1;
    min-width: 0;
    padding: 12px 4px;
    background: #f8f9fc;
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    line-height: 1.4;
}

.rating-group .rating-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: #e8f0fe;
}

.rating-group .rating-btn.selected {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: transparent;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.35);
    transform: translateY(-1px);
}

/* ========== 反馈按钮行 ========== */
.feedback-btn-row {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.feedback-btn-row .btn-primary,
.feedback-btn-row .btn-secondary {
    flex: 1;
    margin: 0;
    padding: 13px 24px;
    font-size: 16px;
    border-radius: 10px;
}

/* ========== 错误提示 ========== */
.feedback-error {
    color: var(--error-color);
    font-size: 13px;
    margin-top: 6px;
    display: none;
    padding: 8px 12px;
    background: #fff2f0;
    border-radius: 6px;
    border-left: 3px solid var(--error-color);
}

/* ========== 提交成功状态 ========== */
.feedback-success {
    text-align: center;
    padding: 32px 0 12px;
    display: none;
}

.feedback-success .success-icon {
    font-size: 60px;
    margin-bottom: 16px;
    animation: feedbackSuccessPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes feedbackSuccessPop {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.feedback-success h3 {
    font-size: 22px;
    color: var(--success-color);
    margin-bottom: 8px;
    font-weight: 700;
}

.feedback-success p {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 28px;
    line-height: 1.6;
}

.feedback-success .feedback-btn-row {
    max-width: 320px;
    margin: 0 auto;
}

/* ========== 记忆阶段 ========== */
.memory-items-grid {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 40px;
    min-height: 400px;
    padding: 40px 0;
}

.memory-item {
    width: 180px;
    height: 180px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    justify-content: center;
    align-items: center;
    animation: popIn 0.5s ease backwards;
}

.memory-item:nth-child(1) { animation-delay: 0.1s; }
.memory-item:nth-child(2) { animation-delay: 0.2s; }
.memory-item:nth-child(3) { animation-delay: 0.3s; }
.memory-item:nth-child(4) { animation-delay: 0.4s; }

.memory-item img {
    width: 140px;
    height: 140px;
    object-fit: contain;
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.phase-hint {
    text-align: center;
    color: rgba(255, 255, 255, 0.9);
    font-size: 16px;
    margin-top: 20px;
}

/* ========== 答题阶段 ========== */
.question-container {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 40px;
    box-shadow: var(--shadow);
    max-width: 800px;
    margin: 40px auto;
}

.question-text {
    font-size: 24px;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 32px;
    line-height: 1.8;
}

.answer-area {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.answer-btn {
    padding: 16px 24px;
    background: #fafafa;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
}

.answer-btn:hover {
    background: #e6f7ff;
    border-color: var(--primary-color);
}

.answer-btn.selected {
    background: var(--primary-color);
    color: #ffffff;
    border-color: var(--primary-color);
}

/* ========== 辨认阶段 ========== */
.recall-items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 20px;
    padding: 32px 0;
    max-width: 900px;
    margin: 0 auto;
}

.recall-item {
    width: 100%;
    aspect-ratio: 1;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: var(--transition);
    border: 3px solid transparent;
}

.recall-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
}

.recall-item.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(74, 144, 217, 0.3);
}

.recall-item img {
    width: 120px;
    height: 120px;
    object-fit: contain;
}

/* ========== 结果页面 ========== */
.result-content {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 48px;
    box-shadow: var(--shadow);
    max-width: 700px;
    margin: 40px auto;
    text-align: center;
}

.result-icon {
    font-size: 72px;
    margin-bottom: 20px;
}

.result-title {
    font-size: 28px;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.result-message {
    font-size: 18px;
    color: var(--text-secondary);
    line-height: 1.8;
    margin-bottom: 32px;
}

.result-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin: 32px 0;
    padding: 24px;
    background: #fafafa;
    border-radius: 8px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-label {
    font-size: 14px;
    color: var(--text-light);
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary-color);
}

.daily-limit-display {
    background: #fff7e6;
    border-radius: 8px;
    padding: 16px;
    margin: 24px 0;
    font-size: 16px;
    color: #d46b08;
}

.result-actions {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 32px;
}

/* ========== 每日训练信息 ========== */
.daily-limit-info {
    text-align: center;
    margin-top: 32px;
}

.daily-limit-info p {
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
}

/* ========== 响应式设计 ========== */
@media (max-width: 768px) {
    .game-title {
        font-size: 28px;
    }
    
    .difficulty-cards {
        grid-template-columns: 1fr;
    }
    
    .memory-items-grid {
        gap: 20px;
    }
    
    .memory-item {
        width: 140px;
        height: 140px;
    }
    
    .memory-item img {
        width: 100px;
        height: 100px;
    }
    
    .question-container {
        padding: 24px;
    }
    
    .question-text {
        font-size: 20px;
    }
    
    .answer-area {
        grid-template-columns: 1fr;
    }
    
    .recall-items-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .result-content {
        padding: 32px 24px;
    }
    
    .result-stats {
        grid-template-columns: 1fr;
    }
    
    .timer {
        font-size: 36px;
        padding: 6px 18px;
    }

    .feedback-modal {
        margin: 20px auto;
        padding: 28px 20px 24px;
    }

    .rating-group {
        flex-wrap: wrap;
    }

    .rating-group .rating-btn {
        min-width: 56px;
        font-size: 13px;
        padding: 10px 4px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 16px;
    }
    
    .recall-items-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
