:root {
    --primary: #007aff;
    --primary-light: #e0f0ff;
    --success: #34c759;
    --success-bg: #eaffed;
    --danger: #ff3b30;
    --danger-bg: #ffeceb;
    --bg: #f2f2f7;
    --surface: #ffffff;
    --text-main: #1c1c1e;
    --text-secondary: #8e8e93;
    --border: #e5e5ea;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg);
    color: var(--text-main);
    margin: 0;
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

.app {
    width: 100%;
    max-width: 500px;
    background: var(--surface);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.05);
    overflow-x: hidden;
}

.page {
    display: none;
    flex-direction: column;
    padding: 24px;
    flex: 1;
    animation: fadeIn 0.3s ease;
}

.page.active {
    display: flex;
}

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

.text-center { text-align: center; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }

h1 {
    font-size: 28px;
    font-weight: 800;
    color: var(--primary);
    margin: 0 0 8px;
    letter-spacing: -0.5px;
}

p {
    margin: 0 0 20px;
    line-height: 1.6;
    color: var(--text-secondary);
    font-size: 15px;
}

h2 {
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 20px;
}

.btn {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 14px;
    padding: 16px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    margin-bottom: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.2);
}

.btn:active { transform: scale(0.97); }
.btn-secondary { background: var(--primary-light); color: var(--primary); box-shadow: none; }
.btn-outline { background: transparent; color: var(--primary); border: 2px solid var(--primary); box-shadow: none; }
.btn-loading { opacity: 0.5; cursor: not-allowed; }

select {
    width: 100%;
    padding: 14px;
    border-radius: 14px;
    border: 2px solid var(--border);
    font-size: 16px;
    background: var(--surface);
    color: var(--text-main);
    outline: none;
    margin-bottom: 24px;
    font-weight: 500;
}
select:focus { border-color: var(--primary); }

/* Segmented Control Radio Buttons */
.radio-group {
    display: flex;
    background: var(--bg);
    border-radius: 14px;
    padding: 4px;
    margin-bottom: 32px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

.radio-group input[type="radio"] { display: none; }

.radio-group label {
    flex: 1;
    text-align: center;
    padding: 14px 16px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
    margin: 0;
    -webkit-tap-highlight-color: transparent;
}

.radio-group input[type="radio"]:checked + label {
    background: var(--surface);
    color: var(--primary);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.05);
}

/* Quiz Page Elements */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.badge {
    background: var(--primary-light);
    color: var(--primary);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
}

.progress {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
}

.stem {
    font-size: 18px;
    line-height: 1.6;
    font-weight: 600;
    margin-bottom: 24px;
}

.option {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 14px;
    padding: 16px 20px;
    margin-bottom: 12px;
    cursor: pointer;
    display: flex;
    align-items: flex-start;
    font-size: 16px;
    transition: all 0.2s;
    line-height: 1.4;
    font-weight: 500;
}

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

.option:active { transform: scale(0.98); }

.opt-letter {
    font-weight: 700;
    margin-right: 12px;
    color: var(--primary);
}

.option.correct {
    border-color: var(--success);
    background: var(--success-bg);
    color: var(--success);
}
.option.correct .opt-letter { color: var(--success); }

.option.incorrect {
    border-color: var(--danger);
    background: var(--danger-bg);
    color: var(--danger);
}
.option.incorrect .opt-letter { color: var(--danger); }

.nav-buttons {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}
.nav-buttons .btn {
    margin-bottom: 0;
    box-shadow: none;
}

/* Stats Page */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg);
    border-radius: 20px;
    padding: 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.stat-value {
    font-size: 32px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 600;
}

.chart-wrapper {
    width: 100%;
    height: 260px;
    margin-bottom: 32px;
}

/* Tablet (iPad) and Web Overrides for better proportional scaling */
@media (min-width: 768px) {
    .app { 
        max-width: 700px; 
        margin: 40px auto; 
        min-height: calc(100vh - 80px); 
        border-radius: 24px; 
    }
    
    .page { padding: 40px; }
    
    /* Typography Scale */
    h1 { font-size: 36px; }
    p { font-size: 18px; }
    h2 { font-size: 28px; }
    
    /* Controls Scale */
    .btn { font-size: 18px; padding: 20px; border-radius: 18px; margin-bottom: 16px; }
    .radio-group { padding: 6px; border-radius: 18px; }
    .radio-group label { padding: 16px 20px; font-size: 18px; border-radius: 14px; }
    
    /* Quiz Elements Scale */
    .stem { font-size: 22px; margin-bottom: 32px; }
    .option { font-size: 18px; padding: 20px 24px; margin-bottom: 16px; border-radius: 18px; }
    .option .opt-letter { font-size: 18px; }
    .header { margin-bottom: 30px; padding-bottom: 24px; }
    .progress { font-size: 16px; }
    .badge { font-size: 15px; padding: 8px 18px; }
    
    /* Stats Layout */
    .stat-card { padding: 30px; }
    .stat-value { font-size: 48px; }
    .stat-label { font-size: 16px; }
}
