/* 数学口算练习样式 */

/* 全屏容器 */
.math-fullscreen {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f0f23 100%);
    overflow: hidden;
}

/* 顶部栏 */
.math-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.math-header .back-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-light);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.math-header .back-btn:hover {
    color: var(--primary-color);
}

.math-header .title {
    font-size: 1.1rem;
    font-weight: 500;
    color: #6b7280;
}

.math-header .header-actions {
    display: flex;
    gap: 0.5rem;
}

.math-header .action-btn {
    width: 2.5rem;
    height: 2.5rem;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.1rem;
}

.math-header .action-btn:hover {
    background: var(--primary-color);
    color: white;
}

/* 主区域 */
.math-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ==================== 开始界面 ==================== */
.start-screen {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    overflow-y: auto;
}

.start-content {
    text-align: center;
    max-width: 500px;
    width: 100%;
}

.start-icon {
    font-size: 4rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
    animation: float 3s ease-in-out infinite;
}

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

.start-content h1 {
    font-size: 2rem;
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

.start-desc {
    color: var(--text-light);
    margin-bottom: 2rem;
}

/* 设置卡片 */
.settings-card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 1rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
    text-align: left;
}

.setting-row {
    margin-bottom: 1.25rem;
}

.setting-row:last-child {
    margin-bottom: 0;
}

.setting-row label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 0.75rem;
}

.setting-row label i {
    color: var(--primary-color);
}

.setting-row select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 1rem;
    cursor: pointer;
}

.setting-row select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.setting-row select option {
    background: var(--card-bg);
    color: var(--text-color);
}

/* 运算按钮 */
.operation-btns {
    display: flex;
    gap: 0.5rem;
}

.op-btn {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    background: transparent;
    color: var(--text-light);
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

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

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

/* 数量按钮 */
.count-btns, .mode-btns {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.count-btn, .mode-btn {
    flex: 1;
    min-width: 70px;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background: transparent;
    color: var(--text-light);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
}

.count-btn:hover, .mode-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.count-btn.active, .mode-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.countdown-setting {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.countdown-setting label {
    margin-bottom: 0;
    white-space: nowrap;
}

.countdown-setting select {
    flex: 1;
}

/* 开始按钮 */
.start-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem 3rem;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    border: none;
    border-radius: 2rem;
    color: white;
    font-size: 1.25rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 20px rgba(79, 70, 229, 0.4);
}

.start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 30px rgba(79, 70, 229, 0.6);
}

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

.start-btn i {
    font-size: 1.5rem;
}

/* ==================== 练习界面 ==================== */
.game-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    gap: 1rem;
    overflow: hidden;
}

/* 状态栏 */
.game-status {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.status-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 0.75rem;
    min-width: 70px;
}

.status-icon {
    font-size: 1rem;
    color: var(--text-light);
    margin-bottom: 0.25rem;
}

.status-item:nth-child(1) .status-icon { color: #22c55e; }
.status-item:nth-child(2) .status-icon { color: #ef4444; }
.status-item:nth-child(3) .status-icon { color: #3b82f6; }
.status-item:nth-child(4) .status-icon { color: #f59e0b; }

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

.status-label {
    font-size: 0.75rem;
    color: var(--text-light);
}

.status-item.timer.warning .status-value {
    color: #f59e0b;
    animation: pulse 1s infinite;
}

.status-item.timer.danger .status-value {
    color: #ef4444;
    animation: pulse 0.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* 进度条 */
.progress-bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #22c55e 0%, #4ade80 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    position: absolute;
    right: 0;
    top: -1.5rem;
    font-size: 0.8rem;
    color: var(--text-light);
}

/* 题目区域 */
.question-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: 200px;
}

.combo-effect {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    font-weight: 700;
    color: #f59e0b;
    opacity: 0;
    pointer-events: none;
    z-index: 10;
}

.combo-effect.show {
    animation: comboPopup 0.8s ease-out forwards;
}

@keyframes comboPopup {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    30% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
    100% { opacity: 0; transform: translate(-50%, -80%) scale(1); }
}

.question-card {
    text-align: center;
    padding: 2rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 1.5rem;
    border: 2px solid var(--border-color);
    min-width: 320px;
    transition: all 0.3s;
}

.question-card.correct {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.1);
}

.question-card.wrong {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    animation: shake 0.3s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
}

.question-number {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 1rem;
}

.question-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-color);
}

.operator {
    color: #f59e0b;
    font-size: 3rem;
    text-shadow: 0 0 10px rgba(245, 158, 11, 0.5), 0 0 20px rgba(245, 158, 11, 0.3);
    padding: 0 0.25rem;
}

.equals {
    color: var(--text-light);
}

.answer-box input {
    width: 100px;
    height: 60px;
    text-align: center;
    font-size: 2rem;
    font-weight: 700;
    border: 3px solid var(--primary-color);
    border-radius: 0.75rem;
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-color);
    outline: none;
    transition: all 0.2s;
}

.answer-box input:focus {
    border-color: #7c3aed;
    box-shadow: 0 0 20px rgba(124, 58, 237, 0.3);
}

.feedback {
    margin-top: 1rem;
    font-size: 1rem;
    min-height: 1.5rem;
}

.feedback.correct {
    color: #22c55e;
}

.feedback.wrong {
    color: #ef4444;
}

/* 数字键盘 */
.numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    max-width: 320px;
    margin: 0 auto;
    padding-bottom: env(safe-area-inset-bottom);
}

.num-btn {
    padding: 1rem;
    font-size: 1.5rem;
    font-weight: 600;
    border: none;
    border-radius: 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.num-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.num-btn:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.25);
}

.num-btn.backspace {
    color: #f59e0b;
}

.num-btn.clear {
    color: #ef4444;
}

.num-btn.negative {
    font-size: 1rem;
    color: var(--text-light);
}

.num-btn.submit {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: white;
}

.num-btn.submit:hover {
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
}

/* ==================== 结果界面 ==================== */
.result-screen {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    overflow-y: auto;
}

.result-content {
    text-align: center;
    max-width: 500px;
    width: 100%;
}

.result-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.result-icon.gold { color: #f59e0b; }
.result-icon.silver { color: #94a3b8; }
.result-icon.bronze { color: #cd7f32; }
.result-icon.fail { color: #ef4444; }

.result-title {
    font-size: 2rem;
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

.result-stars {
    font-size: 2rem;
    margin-bottom: 1.5rem;
}

.result-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 0.75rem;
    border: 1px solid var(--border-color);
}

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

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 0.25rem;
}

.result-message {
    color: var(--text-light);
    margin-bottom: 1.5rem;
    font-size: 1rem;
}

/* 错题回顾 */
.wrong-review {
    background: rgba(239, 68, 68, 0.1);
    border-radius: 0.75rem;
    padding: 1rem;
    margin-bottom: 1.5rem;
    text-align: left;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.wrong-review h3 {
    font-size: 1rem;
    color: #ef4444;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.wrong-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 150px;
    overflow-y: auto;
}

.wrong-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 0.5rem;
    font-size: 0.9rem;
}

.wrong-item .question {
    color: var(--text-color);
}

.wrong-item .your-answer {
    color: #ef4444;
    text-decoration: line-through;
}

.wrong-item .correct-answer {
    color: #22c55e;
    margin-left: 0.5rem;
}

/* 结果按钮 */
.result-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.btn-primary, .btn-secondary, .btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 0.75rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(79, 70, 229, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.3);
}

/* ==================== 记录弹窗 ==================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

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

.modal-box {
    background: var(--card-bg);
    border-radius: 1rem;
    padding: 1.5rem;
    max-width: 400px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    border: 1px solid var(--border-color);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.modal-header h3 {
    font-size: 1.25rem;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-header h3 i {
    color: #f59e0b;
}

.close-btn {
    width: 2rem;
    height: 2rem;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-color);
}

.record-list {
    margin-bottom: 1rem;
}

.empty-record {
    text-align: center;
    color: var(--text-light);
    padding: 2rem;
}

.record-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
}

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

.record-item .record-info .grade {
    color: var(--primary-color);
}

.record-item .record-stats {
    text-align: right;
}

.record-item .record-stats .accuracy {
    font-size: 1.1rem;
    font-weight: 600;
    color: #22c55e;
}

.record-item .record-stats .time {
    font-size: 0.8rem;
    color: var(--text-light);
}

/* ==================== 响应式 ==================== */
@media (max-width: 480px) {
    .question-content {
        font-size: 2rem;
    }

    .answer-box input {
        width: 80px;
        height: 50px;
        font-size: 1.5rem;
    }

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

    .numpad {
        gap: 0.4rem;
    }

    .num-btn {
        padding: 0.75rem;
        font-size: 1.25rem;
    }
}

@media (max-height: 700px) {
    .start-icon {
        font-size: 3rem;
    }

    .start-content h1 {
        font-size: 1.5rem;
    }

    .settings-card {
        padding: 1rem;
    }

    .setting-row {
        margin-bottom: 1rem;
    }

    .question-card {
        padding: 1.5rem;
    }

    .game-status {
        gap: 0.5rem;
    }

    .status-item {
        padding: 0.4rem 0.75rem;
        min-width: 60px;
    }

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