
:root {
    --primary-color: #10b981; /* Green */
    --primary-hover: #059669;
    --error-color: #ef4444;   /* Red */
    --text-color: #1f2937;
    --bg-color: #f3f4f6;
    --card-bg: #ffffff;
    --border-color: #e5e7eb;
    --secondary-text: #6b7280;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

#app {
    max-width: 800px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    background: var(--card-bg);
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    margin: 0 1rem;
    border-radius: 0 0 0.5rem 0.5rem;
}

.app-title {
    font-size: 1.2rem;
    font-weight: bold;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.timer {
    font-family: monospace;
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--primary-color);
}

/* Main Content */
.app-content {
    padding: 1rem;
    flex: 1;
}

.page {
    display: none;
}

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

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

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: 0.5rem;
    padding: 1.5rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    margin-bottom: 1rem;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 0.375rem;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
    font-weight: 500;
}

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

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

.btn-primary:disabled {
    background-color: #9ca3af;
    cursor: not-allowed;
}

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

.btn-secondary:hover {
    background-color: #d1d5db;
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.btn-large {
    width: 100%;
    margin-bottom: 0.5rem;
    padding: 1rem;
    font-size: 1.1rem;
}

/* Forms & Inputs */
.radio-group label {
    display: block;
    margin-bottom: 0.75rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.25rem;
}

.radio-group label:hover {
    background-color: #f9fafb;
}

/* Question Page */
.question-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    color: var(--secondary-text);
}

.badge {
    background-color: #e0e7ff;
    color: #4338ca;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.8rem;
}

.question-content {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    font-weight: 500;
}

.options-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.option-item {
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: flex-start;
    transition: all 0.2s;
}

.option-item:hover {
    background-color: #f9fafb;
}

.option-item.selected {
    background-color: #ecfdf5;
    border-color: var(--primary-color);
    color: #064e3b;
}

.option-item.correct {
    background-color: #ecfdf5;
    border-color: var(--primary-color);
    color: #064e3b;
}

.option-item.wrong {
    background-color: #fef2f2;
    border-color: var(--error-color);
    color: #7f1d1d;
}

.option-marker {
    margin-right: 0.75rem;
    font-weight: bold;
    min-width: 1.5rem;
}

/* Feedback */
.feedback {
    margin-top: 1.5rem;
    padding: 1rem;
    border-radius: 0.5rem;
    background-color: #f3f4f6;
}

.feedback.hidden {
    display: none;
}

.feedback-msg {
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.feedback-msg.success { color: var(--primary-color); }
.feedback-msg.error { color: var(--error-color); }

.navigation-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: 1.5rem;
}

/* Stats */
.stats-summary, .summary-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin: 1.5rem 0;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    background: #f9fafb;
    border-radius: 0.5rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
}

.stat-value.success { color: var(--primary-color); }
.stat-value.error { color: var(--error-color); }

/* Wrong List */
.wrong-item {
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
}
.wrong-item:last-child { border-bottom: none; }
.wrong-question { font-weight: 500; margin-bottom: 0.5rem; }
.wrong-meta { font-size: 0.9rem; color: var(--secondary-text); }

/* Utility */
.hidden { display: none !important; }

/* Question Header & Progress */
.question-header-container {
    margin-bottom: 1rem;
}

.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    color: var(--secondary-text);
    font-weight: 500;
}

.progress-container {
    height: 8px;
    background-color: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.progress-bar {
    width: 100%;
    height: 100%;
}

.progress-fill {
    height: 100%;
    background-color: var(--primary-color);
    transition: width 0.3s ease;
    /* Add striped pattern for "scale" effect */
    background-image: linear-gradient(
        90deg, 
        transparent 0%, 
        transparent 95%, 
        rgba(255,255,255,0.5) 95%, 
        rgba(255,255,255,0.5) 100%
    );
    background-size: 20px 100%; /* Adjust size for tick density */
}

/* Action Buttons Container */
.action-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.action-buttons .btn {
    flex: 1; /* Make buttons equal width */
}

/* Move navigation buttons inside card style adjustments */
.question-card .navigation-buttons {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* Home Page Layout Updates */
.home-title {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--text-color);
}

.home-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-box {
    background-color: #f9fafb;
    border-radius: 0.5rem;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
}

.stat-box.total {
    background-color: #ecfdf5;
    border-color: #a7f3d0;
}

.stat-box.total .stat-value {
    color: var(--primary-color);
}

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

.stat-value {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--text-color);
}

/* Start Mode Selection */
.start-section h3 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
    color: var(--text-color);
}

.mode-selection {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.mode-card {
    display: flex;
    align-items: center;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    background-color: white;
}

.mode-card:hover {
    border-color: var(--primary-color);
    background-color: #f9fafb;
}

.mode-card input[type="radio"] {
    margin-right: 1rem;
    transform: scale(1.2);
    accent-color: var(--primary-color);
}

/* Style when radio is checked */
.mode-card:has(input:checked) {
    border-color: var(--primary-color);
    background-color: #ecfdf5;
}

.mode-content {
    display: flex;
    flex-direction: column;
}

.mode-title {
    font-weight: 500;
    color: var(--text-color);
}

.mode-desc {
    font-size: 0.8rem;
    color: var(--secondary-text);
}

/* Disclaimer */
.disclaimer {
    margin-top: 2rem;
    padding: 1rem;
    background-color: #fffbeb; /* Light yellow background for notice */
    border-radius: 0.5rem;
    color: #92400e;
    font-size: 0.9rem;
    text-align: center;
    border: 1px solid #fcd34d;
}

.progress-info {
    text-align: center;
    margin-top: 1rem;
    color: var(--secondary-text);
    font-size: 0.9rem;
}

/* Responsive updates for home */
@media (max-width: 768px) {
    .home-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .mode-selection {
        grid-template-columns: 1fr;
    }
}

/* Intro Text */
.intro-text {
    margin-bottom: 2rem;
    padding: 0 1rem;
    text-align: center;
    color: var(--secondary-text);
    font-size: 1rem;
    line-height: 1.6;
}

.intro-text p {
    max-width: 700px;
    margin: 0 auto;
}

/* Intro Text */
.intro-text {
    margin-bottom: 2rem;
    padding: 0;
    text-align: left;
    color: var(--secondary-text);
    font-size: 1rem;
    line-height: 1.6;
}

.intro-text p {
    margin: 0;
}

/* Mode Selection Updates */
.mode-card .mode-title {
    font-size: 1.1rem;
    font-weight: 600;
}

/* Center content in mode card if only title exists */
.mode-card {
    justify-content: center;
}

.mode-content {
    align-items: flex-start;
}

/* Mobile Header Optimization */
.btn-icon {
    display: none;
}

@media (max-width: 768px) {
    /* 1. Header Layout */
    .app-header {
        padding: 0.5rem 1rem; /* Reduce vertical padding */
        align-items: center;
        gap: 0.5rem;
    }

    /* 2. Title Optimization */
    .header-left {
        flex: 1;
        min-width: 0; /* Critical for text-overflow to work in flex */
        margin-right: 0.25rem;
    }

    .app-title {
        font-size: 1rem; /* Smaller font size */
        white-space: nowrap; /* No wrapping */
        overflow: hidden;
        text-overflow: ellipsis; /* Add "..." if too long */
        line-height: 1.5;
    }

    /* 3. Right Side Optimization */
    .header-right {
        gap: 0.5rem; /* Reduce gap between timer and button */
        flex-shrink: 0; /* Prevent shrinking */
    }

    .timer {
        font-size: 0.9rem; /* Smaller timer */
    }

    /* 4. Button Optimization */
    #wrong-review-btn {
        padding: 0.3rem 0.6rem; /* Compact padding */
        font-size: 0.9rem;
        white-space: nowrap; /* Force horizontal text */
        display: flex;
        align-items: center;
        justify-content: center;
        min-width: auto; /* Allow button to shrink to fit content */
        height: auto;
    }

    /* Switch to Icon on Mobile */
    #wrong-review-btn .btn-text {
        display: none;
    }
    
    #wrong-review-btn .btn-icon {
        display: flex;
        align-items: center;
        justify-content: center;
        line-height: 1;
    }
    
    #wrong-review-btn .btn-icon svg {
        width: 1.2rem;
        height: 1.2rem;
    }
    
    /* Optional: Remove border to make it look like an icon button */
    #wrong-review-btn.btn-outline {
        border: none;
        padding: 0.25rem;
        background: transparent;
    }
}
