/* ===== CSS Variables & Reset ===== */
:root {
    --primary: #4F46E5;
    --primary-light: #818CF8;
    --primary-dark: #3730A3;
    --success: #10B981;
    --success-light: #D1FAE5;
    --danger: #EF4444;
    --danger-light: #FEE2E2;
    --warning: #F59E0B;
    --warning-light: #FEF3C7;
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
}

* {
    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, #EEF2FF 0%, #E0E7FF 50%, #F0FDF4 100%);
    min-height: 100vh;
    color: var(--gray-800);
    line-height: 1.6;
}

/* ===== App Container ===== */
.app-container {
    max-width: 720px;
    margin: 0 auto;
    padding: 16px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== Header ===== */
.app-header {
    text-align: center;
    padding: 24px 16px 16px;
}

.app-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.app-header .subtitle {
    font-size: 0.875rem;
    color: var(--gray-500);
}

/* ===== Main ===== */
.app-main {
    flex: 1;
    padding: 8px 0 24px;
}

/* ===== Page System ===== */
.page {
    display: none;
}

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

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

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

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: var(--radius);
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    font-family: inherit;
}

.btn:active {
    transform: scale(0.97);
}

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

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    box-shadow: var(--shadow-md);
}

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

.btn-warning:hover:not(:disabled) {
    background: #D97706;
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--gray-300);
}

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

.btn-danger:hover:not(:disabled) {
    background: #DC2626;
}

.btn-outline {
    background: transparent;
    color: var(--gray-600);
    border: 1.5px solid var(--gray-300);
}

.btn-outline:hover:not(:disabled) {
    background: var(--gray-100);
    border-color: var(--gray-400);
}

.btn-large {
    width: 100%;
    flex-direction: column;
    padding: 20px;
    gap: 4px;
    margin-bottom: 12px;
}

.btn-large .btn-icon {
    font-size: 2rem;
}

.btn-large small {
    font-size: 0.8rem;
    font-weight: 400;
    opacity: 0.85;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.875rem;
    border-radius: var(--radius-sm);
}

/* ===== Home Page ===== */
.home-actions {
    margin-bottom: 24px;
}

.home-info {
    display: grid;
    gap: 12px;
}

.info-card {
    background: white;
    border-radius: var(--radius);
    padding: 16px 20px;
    box-shadow: var(--shadow);
}

.info-card h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--gray-800);
}

.info-card p, .info-card li {
    font-size: 0.9rem;
    color: var(--gray-600);
}

.info-card ul {
    padding-left: 20px;
}

.info-card li {
    margin-bottom: 4px;
}

/* ===== Practice Page ===== */
.practice-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.progress-bar-container {
    flex: 1;
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.4s ease;
    width: 0%;
}

.progress-text {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-600);
    white-space: nowrap;
    min-width: 50px;
    text-align: right;
}

/* Question Card */
.question-card {
    background: white;
    border-radius: var(--radius);
    padding: 28px 24px;
    box-shadow: var(--shadow-md);
    margin-bottom: 20px;
    animation: slideUp 0.4s ease;
}

.question-number {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 4px;
}

.question-type-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 16px;
}

.badge-tf {
    background: var(--warning-light);
    color: #92400E;
}

.badge-choice {
    background: #DBEAFE;
    color: #1E40AF;
}

.question-text {
    font-size: 1.1rem;
    font-weight: 500;
    line-height: 1.8;
    color: var(--gray-900);
    margin-bottom: 24px;
}

/* Answer Area */
.answer-area {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.answer-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.95rem;
    background: white;
}

.answer-option:hover {
    border-color: var(--primary-light);
    background: #F5F3FF;
}

.answer-option.selected {
    border-color: var(--primary);
    background: #EEF2FF;
    font-weight: 600;
}

.answer-option.correct {
    border-color: var(--success);
    background: var(--success-light);
}

.answer-option.wrong {
    border-color: var(--danger);
    background: var(--danger-light);
}

.answer-option .option-letter {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.answer-option.selected .option-letter {
    background: var(--primary);
    color: white;
}

.answer-option.correct .option-letter {
    background: var(--success);
    color: white;
}

.answer-option.wrong .option-letter {
    background: var(--danger);
    color: white;
}

/* TF Buttons */
.tf-buttons {
    display: flex;
    gap: 12px;
}

.tf-btn {
    flex: 1;
    padding: 18px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    background: white;
    text-align: center;
}

.tf-btn:hover {
    border-color: var(--primary-light);
    background: #F5F3FF;
}

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

.tf-btn.correct {
    border-color: var(--success);
    background: var(--success-light);
    color: var(--success);
}

.tf-btn.wrong {
    border-color: var(--danger);
    background: var(--danger-light);
    color: var(--danger);
}

.tf-btn .tf-symbol {
    display: block;
    font-size: 2rem;
    margin-bottom: 4px;
}

.tf-btn .tf-label {
    font-size: 0.85rem;
    font-weight: 500;
}

/* Feedback */
.feedback {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
    animation: fadeIn 0.3s ease;
}

.feedback.correct-fb {
    background: var(--success-light);
    color: #065F46;
    border: 1px solid var(--success);
}

.feedback.wrong-fb {
    background: var(--danger-light);
    color: #991B1B;
    border: 1px solid var(--danger);
}

/* Practice Footer */
.practice-footer {
    text-align: center;
}

#btn-next {
    min-width: 160px;
}

/* ===== Results Page ===== */
.results-header {
    text-align: center;
    padding: 20px;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.results-header h2 {
    font-size: 2rem;
    margin-bottom: 4px;
}

.results-header p {
    color: var(--gray-500);
}

.results-grid {
    display: grid;
    gap: 12px;
    margin-bottom: 24px;
}

.result-card {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--success);
    animation: slideUp 0.4s ease;
}

.result-card.wrong-card {
    border-left-color: var(--danger);
    border: 2px solid var(--danger);
    background: #FFF5F5;
}

.result-card .result-num {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-400);
    margin-bottom: 4px;
}

.result-card .result-type {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.result-card .result-question {
    font-size: 0.95rem;
    margin-bottom: 12px;
    line-height: 1.7;
}

.result-card .result-answers {
    font-size: 0.85rem;
    color: var(--gray-600);
    padding: 10px;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
}

.result-card .result-answers .your-answer {
    color: var(--danger);
    font-weight: 600;
}

.result-card .result-answers .correct-answer {
    color: var(--success);
    font-weight: 600;
}

.results-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

/* ===== Stats Page ===== */
#stats-page h2 {
    text-align: center;
    margin-bottom: 20px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow);
}

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

.stat-card .stat-label {
    font-size: 0.85rem;
    color: var(--gray-500);
    margin-top: 4px;
}

.stats-actions {
    text-align: center;
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ===== Footer ===== */
.app-footer {
    text-align: center;
    padding: 16px;
    color: var(--gray-400);
    font-size: 0.8rem;
}

/* ===== Modal ===== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: var(--radius);
    padding: 28px 24px;
    max-width: 360px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.modal-content h3 {
    margin-bottom: 8px;
}

.modal-content p {
    color: var(--gray-500);
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
    .app-container {
        padding: 8px;
    }

    .app-header h1 {
        font-size: 1.35rem;
    }

    .question-card {
        padding: 20px 16px;
    }

    .question-text {
        font-size: 1rem;
    }

    .btn-large {
        padding: 16px;
    }

    .results-actions {
        flex-direction: column;
        align-items: stretch;
    }

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