:root {
    --card-height: 280px;
    --card-width: calc(100vw - 2rem);
    --max-card-width: 400px;
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --success-gradient: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    --danger-gradient: linear-gradient(135deg, #fc466b 0%, #3f5efb 100%);
    --warning-gradient: linear-gradient(135deg, #FDBB2D 0%, #22C1C3 100%);
    --glass-bg: rgba(255, 252, 243, 0.82);
    --glass-border: rgba(229, 218, 187, 0.6);
    --text-primary: #1a1812;
    --text-secondary: #4b463a;
    --bg-pattern: radial-gradient(circle at 25% 25%, #667eea20 0%, transparent 50%),
                 radial-gradient(circle at 75% 75%, #764ba220 0%, transparent 50%);

    /* Paper booklet palette */
    --paper: #f7f1e1;
    --paper-2: #efe7d2;
    --paper-edge: #e2d6b6;
    --ink: #1a1812;
    --ink-2: #4b463a;
    --ink-3: #8a8470;
    --card-surface: #fffcf3;
    --card-edge: #e5dabb;
    --card-shadow: 0 1px 0 rgba(26,24,18,0.04), 0 8px 24px -16px rgba(26,24,18,0.18);
    --blue: #1e3fa8;
    --blue-tint: #dde5fa;
    --green: #2a8e4d;
    --green-tint: #d6efd9;
    --red: #b7331e;
    --red-tint: #f4dbd2;
    --highlight: #f4d34a;
    --highlight-soft: #fbe99b;

    /* Typography */
    --serif: "Source Serif 4", "Source Serif Pro", Georgia, serif;
    --sans: "Poppins", system-ui, sans-serif;

    /* Safe area insets for notched devices */
    --safe-area-inset-top: env(safe-area-inset-top, 0);
    --safe-area-inset-right: env(safe-area-inset-right, 0);
    --safe-area-inset-bottom: env(safe-area-inset-bottom, 0);
    --safe-area-inset-left: env(safe-area-inset-left, 0);

    /* Container padding to prevent clipping */
    --container-padding: max(1rem, var(--safe-area-inset-left), var(--safe-area-inset-right));
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    color: var(--text-primary);
    background: var(--paper);
    background-image:
        radial-gradient(1200px 600px at 20% -10%, #fbf7e8, transparent 60%),
        radial-gradient(900px 600px at 110% 110%, #f0e5c9, transparent 55%);
    background-attachment: fixed;
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    margin: 0;
    padding: var(--safe-area-inset-top) var(--safe-area-inset-right) var(--safe-area-inset-bottom) var(--safe-area-inset-left);
    font-size: 14px;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: 0.28;
    mix-blend-mode: multiply;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.4  0 0 0 0 0.36  0 0 0 0 0.27  0 0 0 0.06 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
    z-index: 0;
}
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: var(--container-padding);
    position: relative;
    overflow: visible;
    z-index: 1;
}
#controls {
    min-height: 80px;
}
footer {
    padding: 1.5rem 0;
    color: var(--ink-3);
    text-align: center;
    font-size: 0.85rem;
    background: var(--paper-2);
    border-top: 1px solid var(--paper-edge);
    margin-top: auto;
}
#final-score-screen {
    background: var(--card-surface);
    border-radius: 16px;
    padding: 2rem;
    text-align: center;
    width: 100%;
    max-width: 500px;
    margin: 1rem auto;
    border: 1px solid var(--card-edge);
    box-shadow: var(--card-shadow);
    color: var(--ink);
    position: relative;
    overflow: hidden;
    animation: slideInUp 0.6s ease-out;
}

#final-score-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(244,211,74,0.05), transparent);
    z-index: -1;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}
@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

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

@keyframes glow {
    0%, 100% { box-shadow: 0 8px 24px rgba(102, 126, 234, 0.3); }
    50% { box-shadow: 0 12px 32px rgba(102, 126, 234, 0.5); }
}

@keyframes breathe {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Mode entry list — harirbi-style list items */
.mode-list {
    gap: 10px !important;
}
.mode-entry {
    display: grid;
    grid-template-columns: 48px 1fr auto;
    gap: 14px;
    align-items: center;
    padding: 14px 16px;
    background: var(--card-surface);
    border: 1px solid var(--card-edge);
    border-radius: 14px;
    box-shadow: var(--card-shadow);
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    color: inherit;
    width: 100%;
    transition: border-color 0.15s ease, transform 0.06s ease;
    appearance: none;
}
.mode-entry:hover {
    border-color: var(--blue);
    transform: translateY(-1px);
}
.mode-entry:active {
    transform: scale(0.99);
}
.mode-ico {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-size: 22px;
    flex-shrink: 0;
}
.mode-ico.mains { background: var(--red-tint); }
.mode-ico.mcq { background: var(--highlight-soft); }
.mode-ico.prelims { background: var(--blue-tint); }
.mode-ico.prelims2 { background: linear-gradient(135deg, #f3e5f5, #e8eaf6); }
.mode-ico.streaks { background: var(--green-tint); }
.mode-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.mode-title {
    font-family: var(--serif);
    font-size: 16px;
    font-weight: 600;
    color: var(--ink);
}
.mode-desc {
    font-size: 12.5px;
    color: var(--ink-2);
    margin-top: 2px;
}
.mode-chev {
    color: var(--ink-3);
    font-size: 22px;
    font-weight: 300;
}

/* Performance optimizations */
.btn, .stats-card {
    will-change: transform;
    transform: translateZ(0); /* Force hardware acceleration */
}

/* Optimize for 60fps animations */
.btn, .stats-card {
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Use transform3d for hardware acceleration */
.btn:hover, .btn:active {
    transform: translate3d(0, -2px, 0) scale(1.02);
}


/* Enhanced focus states for accessibility */
.btn:focus, .mcq-option:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
}

/* Ripple effect for buttons */
/* Polished buttons */
.btn {
    position: relative;
    overflow: hidden;
    border-radius: 14px;
    font-weight: 700;
    padding: 12px 20px;
    border: 1px solid rgba(0,0,0,0.06);
    transition: transform .15s ease, box-shadow .2s ease, filter .2s ease;
    box-shadow: 0 10px 24px rgba(0,0,0,0.08);
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.02); }
.btn:active { transform: translateY(0); filter: brightness(.98); }
.btn:focus { outline: none; box-shadow: 0 0 0 4px rgba(102,126,234,0.25); }
.btn::after {
    content: '';
    position: absolute; inset: 0; width: 0; height: 0; margin: auto;
    border-radius: 50%; background: rgba(255,255,255,0.35);
    transform: scale(0); transition: transform .45s ease, opacity .6s ease;
    opacity: 0;
}
.btn:active::after { width: 220px; height: 220px; transform: scale(1); opacity: 1; }

/* Header and Navigation */
.app-header {
    background: var(--card-surface);
    border: 1px solid var(--card-edge);
    padding: 1.25rem 1.25rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--card-shadow);
    width: 100%;
    border-radius: 16px;
    position: relative;
    z-index: 100;
    overflow: hidden;
}

.app-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(244,211,74,0.06), transparent);
    z-index: -1;
}

.app-title {
    color: var(--ink);
    font-family: var(--serif);
    font-size: 1.6rem;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
    text-align: center;
    position: relative;
    z-index: 10;
    letter-spacing: -0.01em;
}

/* Emoji stays native; only title-text gets gradient */
.app-title .title-text {
    background: linear-gradient(135deg, var(--blue) 0%, #4a2fa0 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.app-title .emoji { -webkit-text-fill-color: initial; }

.app-header .text-muted {
    color: var(--ink-2) !important;
    font-weight: 500;
    margin-top: 0.5rem;
}

/* Countdown Timer */
.countdown-timer {
    margin: 1rem auto 0;
    padding: 0.75rem 1rem;
    background: var(--card-surface);
    border: 1px solid var(--card-edge);
    border-radius: 12px;
    max-width: 600px;
    box-shadow: none;
    position: relative;
    overflow: hidden;
}

.countdown-timer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(244,211,74,0.06) 0%, transparent 100%);
    z-index: -1;
}

.countdown-label {
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--ink);
    letter-spacing: 2px;
    margin-bottom: 0.5rem;
}
.countdown-done {
    font-family: var(--serif);
    font-size: 0.95rem;
    color: var(--green);
    font-weight: 600;
    padding: 0.25rem 0;
}

.countdown-digits {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.countdown-unit {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 70px;
}

.countdown-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--blue);
    line-height: 1;
    letter-spacing: -0.02em;
    animation: countPulse 2s ease-in-out infinite;
}

@keyframes countPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.countdown-unit-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 0.5rem;
}

@media (max-width: 576px) {
    .countdown-timer {
        padding: 0.75rem;
        margin: 0.75rem auto;
    }
    .countdown-label {
        font-size: 1rem;
        margin-bottom: 0.75rem;
    }
    .countdown-value {
        font-size: 2rem;
    }
    .countdown-unit {
        min-width: 60px;
    }
}

/* Timer Display */
.timer-display {
    position: fixed;
    top: calc(16px + var(--safe-area-inset-top));
    right: calc(16px + var(--safe-area-inset-right));
    background: var(--card-surface);
    color: var(--ink);
    padding: 10px 18px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.9rem;
    border: 1px solid var(--card-edge);
    z-index: 1000;
    box-shadow: 0 4px 16px rgba(26,24,18,0.12);
    transition: all 0.2s ease;
    animation: pulse 2s infinite;
    contain: layout style;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.timer-display:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}

/* Streak calendar */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.calendar-grid-headers { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; margin-bottom: 6px; }
.calendar-head { font-weight: 700; color: var(--text-secondary); text-align: center; }
.calendar-grid-body { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.help-tip { margin-left: 8px; cursor: help; color: var(--text-secondary); border-bottom: 1px dotted var(--glass-border); font-size: 0.9rem; }
.calendar-legend { grid-column: 1 / -1; display: flex; justify-content: center; gap: 16px; margin-top: 6px; color: var(--text-secondary); font-size: 0.9rem; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend-dot.met { background: rgba(40,167,69,0.6); }
.legend-dot.partial { background: rgba(255,193,7,0.8); }
.legend-dot.missed { background: rgba(220,53,69,0.7); }
.badge-counter { position: absolute; top: 6px; right: 8px; padding: 2px 8px; border-radius: 12px; font-weight: 700; font-size: 0.75rem; color: #fff; }
.badge-green { background: #28a745; }
.badge-amber { background: #ffc107; color: #222; }
.badge-red { background: #dc3545; }

/* Fancy streak stats */
.streak-stats { display:flex; justify-content:center; gap:12px; flex-wrap:wrap; margin-bottom:10px; }
.stat-chip { display:flex; align-items:center; gap:8px; padding:8px 14px; border-radius:999px; font-weight:800; box-shadow: 0 8px 24px rgba(0,0,0,0.12); letter-spacing: .3px; }
.stat-chip .stat-label{ opacity:0.9; }
.stat-chip .stat-value { font-weight:900; margin-left:4px; }
.stat-chip.current { background: var(--success-gradient); color:#fff; }
.stat-chip.best { background: var(--primary-gradient); color:#fff; }
.stat-chip.today { background: var(--card-surface); border:1px solid var(--card-edge); color: var(--ink); }
.today-progress { display:flex; align-items:center; gap:8px; margin-left:6px; }
.progress-track { width:160px; height:8px; background: rgba(0,0,0,0.08); border-radius:999px; overflow:hidden; }
.progress-fill { height:100%; background: var(--success-gradient); width:0%; display:block; transition: width 0.6s ease; }
.calendar-cell { border: 1px solid var(--card-edge); border-radius: 10px; padding: 8px; min-height: 64px; background: var(--card-surface); }
.calendar-cell .cal-day { font-weight: 700; color: var(--text-secondary); }
.calendar-cell .cal-count { font-size: 0.85rem; color: var(--text-primary); margin-top: 4px; }
.calendar-cell.met { background: rgba(40,167,69,0.12); border-color: rgba(40,167,69,0.35); }
.calendar-cell.partial { background: rgba(255,193,7,0.12); border-color: rgba(255,193,7,0.35); }
.calendar-cell.missed { background: rgba(220,53,69,0.08); border-color: rgba(220,53,69,0.25); }

/* Fix: Use normal text color (no gradient) for MCQ Setup header */
#question-selection .app-title {
    background: none !important;
    -webkit-background-clip: initial !important;
    background-clip: initial !important;
    -webkit-text-fill-color: inherit !important;
    color: var(--text-primary) !important;
}

/* Back Button */
.back-btn {
    position: fixed;
    top: calc(16px + var(--safe-area-inset-top));
    left: calc(16px + var(--safe-area-inset-left));
    background: var(--card-surface);
    border: 1px solid var(--card-edge);
    color: var(--ink);
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 1000;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 4px 16px rgba(26,24,18,0.1);
    contain: layout style;
}

.back-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    background: var(--blue);
    color: #fff;
    border-color: var(--blue);
    box-shadow: 0 6px 18px rgba(30,63,168,0.3);
}

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

.back-btn:active {
    transform: scale(0.95);
}

/* MCQ Styles */
.mcq-container {
    width: 100%;
    max-width: 900px;
    background: var(--card-surface);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--card-edge);
    box-shadow: var(--card-shadow);
    position: relative;
    overflow: hidden;
    contain: layout style paint;
    min-height: 350px;
    display: flex;
    flex-direction: column;
    transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.mcq-container:hover {
    transform: translateY(-1px);
    box-shadow: 0 1px 0 rgba(26,24,18,0.04), 0 12px 32px -12px rgba(26,24,18,0.22);
}

.mcq-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(244,211,74,0.03) 0%, transparent 100%);
    z-index: -1;
}

.mcq-question {
    font-family: var(--serif);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 1.25rem;
    line-height: 1.55;
    min-height: auto;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.mcq-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.mcq-option {
    background: var(--card-surface);
    border: 1px solid var(--card-edge);
    border-radius: 12px;
    padding: 14px 18px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    min-height: 54px;
    position: relative;
    overflow: visible;
}

.mcq-option:hover {
    border-color: var(--blue);
    background: var(--blue-tint);
}

.mcq-option:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(30,63,168,0.12);
}

.mcq-option.selected {
    background: rgba(30, 63, 168, 0.08);
    border-color: var(--blue);
    box-shadow: 0 0 0 2px rgba(30,63,168,0.15);
}

.mcq-option.selected::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(30,63,168,0.03), transparent);
    border-radius: 12px;
}
.mcq-option input[type="radio"] {
    margin: 0;
    width: 18px;
    height: 18px;
    accent-color: var(--blue);
    flex-shrink: 0;
    margin-top: 2px;
}
.mcq-option label {
    cursor: pointer;
    margin: 0;
    flex: 1;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--ink);
    font-weight: 500;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    display: block;
}

/* Mode Selection */
#mode-selection .btn {
    width: 100%;
    max-width: 300px;
    margin-bottom: 1rem;
}

/* Controls */
#controls, #mcq-controls {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
    min-height: 80px;
    align-items: center;
    position: relative;
}

/* Fixed container to prevent bouncing */
.mcq-container {
    min-height: 300px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.mcq-question-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.mcq-options {
    flex: 0 0 auto;
}

/* Results Screen - Now handled by #final-score-screen */

.stats-card {
    background: var(--card-surface);
    border-radius: 14px;
    padding: 1.25rem;
    border: 1px solid var(--card-edge);
    transition: transform 0.15s ease;
    margin-bottom: 0.75rem;
    position: relative;
    overflow: visible;
    box-shadow: var(--card-shadow);
    min-height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.stats-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--blue);
    border-radius: 14px 14px 0 0;
}

.stats-card:hover {
    transform: translateY(-1px);
}

.stats-card .h2, .stats-card .h3 {
    color: var(--blue);
    font-family: var(--serif);
    font-weight: 700;
    -webkit-text-fill-color: initial;
}

/* Mobile-first typography */
.display-4 {
    font-size: 2rem !important;
}

.results-screen h2 {
    font-size: 1.25rem !important;
}

.stats-card .h2, .stats-card .h3 {
    font-size: 1.5rem !important;
    margin-bottom: 0.25rem !important;
}

.stats-card .small {
    font-size: 0.8rem !important;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Mobile-first button layout */
.d-flex.gap-3.justify-content-center.flex-wrap {
    flex-direction: column !important;
    gap: 0.75rem !important;
}

.btn-lg {
    padding: 0.75rem 1rem !important;
    font-size: 1rem !important;
    width: 100% !important;
    max-width: 280px !important;
    margin: 0 auto !important;
}

/* Compact margins for mobile */
.mb-4 {
    margin-bottom: 1.5rem !important;
}

/* Mobile-first: All containers optimized for mobile */
.mcq-container {
    width: 100%;
    max-width: 380px;
    margin: 0 auto;
    padding: 0.75rem;
}

.app-title {
    font-size: 1.5rem !important;
}

.mcq-question {
    font-size: 1rem !important;
}

/* Answer Sheet Styles */
.answer-review {
    background: var(--card-surface);
    border-radius: 14px;
    padding: 1rem;
    margin-top: 1rem;
    text-align: left;
    border: 1px solid var(--card-edge);
    box-shadow: var(--card-shadow);
    width: 100%;
}

#review-content {
    width: 100%;
}

.answer-item {
    background: var(--paper-2);
    border: 1px solid var(--paper-edge);
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    border-left: 4px solid var(--ink-3);
}

.answer-item.correct {
    border-left-color: var(--green);
    background: var(--green-tint);
}

.answer-item.wrong {
    border-left-color: var(--red);
    background: var(--red-tint);
}

.answer-item.skipped {
    border-left-color: var(--highlight);
    background: var(--highlight-soft);
}

.question-text {
    font-family: var(--serif);
    font-weight: 600;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    color: var(--ink);
    line-height: 1.4;
}

.answer-option {
    margin: 0.4rem 0;
    font-size: 0.85rem;
    padding: 0.3rem 0;
    color: var(--ink-2);
}

.correct-answer {
    color: var(--green);
    font-weight: 600;
    background: rgba(42,142,77,0.1);
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
}

.user-answer {
    color: var(--red);
    font-weight: 600;
    background: rgba(183,51,30,0.08);
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
}

.skipped-answer {
    color: #6e5407;
    font-weight: 600;
    font-style: italic;
    background: rgba(244,211,74,0.2);
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
}

.answer-status {
    display: inline-block;
    padding: 0.3rem 0.8rem;
    border-radius: 16px;
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-correct {
    background: #28a745;
    color: #fff;
}

.status-wrong {
    background: #dc3545;
    color: #fff;
}

.status-skipped {
    background: #ffc107;
    color: #212529;
}

.review-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.review-tab {
    padding: 0.5rem 0.8rem;
    border-radius: 6px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    color: #495057;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.8rem;
    font-weight: 500;
}

.review-tab.active {
    background: #007bff;
    border-color: #007bff;
    color: #fff;
}

.review-tab:hover:not(.active) {
    background: #e9ecef;
    border-color: #adb5bd;
}

/* Professional button enhancements */
.btn {
    border-radius: 16px;
    font-weight: 600;
    padding: 14px 28px;
    border: 1px solid transparent;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 1rem;
    min-height: 48px;
    touch-action: manipulation;
    min-width: 48px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    backdrop-filter: blur(10px);
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.6s ease;
}

.btn:hover::before {
    left: 100%;
}

.btn:hover, .btn:active {
    transform: translate3d(0, -2px, 0) scale(1.02);
    box-shadow: 0 12px 32px rgba(0,0,0,0.25);
}

.btn:active {
    transform: translateY(-1px) scale(1.02);
}

.btn-primary { background: var(--blue); border: 1px solid var(--blue); color: #fff; box-shadow: 0 6px 18px -8px rgba(30,63,168,0.5); }

.btn-primary:hover {
    background: #2a52d9;
    box-shadow: 0 8px 22px -6px rgba(30,63,168,0.6);
}

.btn-success { background: var(--green); border: 1px solid var(--green); color: #fff; box-shadow: 0 6px 18px -8px rgba(42,142,77,0.5); }

.btn-success:hover {
    background: #35a35a;
    box-shadow: 0 8px 22px -6px rgba(42,142,77,0.6);
}

.btn-secondary { background: var(--paper-2); border: 1px solid var(--paper-edge); color: var(--ink); }

.btn-secondary:hover { background: var(--card-edge); }

.btn-warning { background: var(--highlight); border: 1px solid #e9cb5c; color: var(--ink); }

.btn-warning:hover { background: #f0c830; }

.btn-danger { background: var(--red); border: 1px solid var(--red); color: #fff; box-shadow: 0 6px 18px -8px rgba(183,51,30,0.5); }

.btn-danger:hover {
    box-shadow: 0 8px 22px -6px rgba(183,51,30,0.6);
}

.btn-outline-primary { color: var(--ink); border: 1px solid var(--card-edge); background: var(--card-surface); }

.btn-outline-primary:hover { background: var(--blue); color: #fff; border-color: var(--blue); }

.btn-outline-secondary {
    color: var(--ink-2);
    border: 1px solid var(--card-edge);
    background: var(--card-surface);
}

.btn-outline-secondary:hover {
    background: var(--ink);
    color: var(--paper);
    border-color: var(--ink);
}

/* Outline info variant used by Streaks button */
.btn-outline-info {
    color: #fff;
    border: 1px solid #138496;
    background: #17a2b8; /* darker teal default */
    box-shadow: 0 8px 24px rgba(23, 162, 184, 0.35);
}
.btn-outline-info:hover {
    background: linear-gradient(135deg, #17a2b8, #138496);
    color: #fff;
    border-color: transparent;
}


/* Desktop Styles */
@media (min-width: 1025px) {
    :root {
        --card-width: 700px;
        --max-card-width: 700px;
        --card-height: 400px;
    }
    main {
        justify-content: center;
        padding: 1rem;
    }
    .app-header {
        padding: 1rem 0;
        margin-bottom: 2rem;
    }
    .app-title {
        font-size: 2rem;
    }
    .mcq-container {
        padding: 2rem;
    }
    .mcq-question {
        font-size: 1.2rem;
        margin-bottom: 1.5rem;
    }
    .mcq-option {
        padding: 16px 20px;
        min-height: 60px;
        gap: 15px;
    }
    .mcq-option label {
        font-size: 1rem;
    }
    .timer-display {
        top: 20px;
        right: 20px;
        padding: 12px 20px;
        font-size: 1rem;
    }
    .back-btn {
        top: 20px;
        left: 20px;
        padding: 10px 20px;
        font-size: 0.9rem;
    }
}

/* Mobile Responsive Improvements */
@media (max-width: 767px) {
    body {
        font-size: 14px;
    }
    main {
        padding: 0.5rem;
    }
    .app-header {
        padding: 1rem;
        margin-bottom: 1rem;
        border-radius: 20px;
    }
    .app-title {
        font-size: 1.4rem;
        text-align: center;
    }

    #mode-selection .btn {
        animation: none; /* Disable floating animation on mobile for better performance */
        margin-bottom: 1rem;
    }

    .btn {
        min-height: 48px;
        border-radius: 12px;
        font-size: 0.9rem;
    }

    /* Reduce transforms on mobile to prevent clipping */
    .btn:hover, .btn:active {
        transform: translate3d(0, -1px, 0) scale(1.01);
    }

    .stats-card:hover {
        transform: translate3d(0, -1px, 0) scale(1.005);
    }

    /* Reduce blur effects on mobile for performance */
    .mcq-container {
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }

    .timer-display, .back-btn {
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }

    #final-score-screen {
        padding: 1.5rem;
        margin: 0.5rem;
        border-radius: 20px;
    }
    .stats-card {
        padding: 0.75rem;
    }
    .answer-review {
        padding: 0.75rem;
    }
    .review-tabs {
        justify-content: center;
        gap: 0.2rem;
    }
    .review-tab {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
    }
    .question-text {
        font-size: 0.85rem;
        margin-bottom: 0.5rem;
    }
    .answer-option {
        font-size: 0.8rem;
        margin: 0.25rem 0;
    }
    .mcq-container {
        padding: 0.75rem;
        margin-bottom: 0.75rem;
    }
    .mcq-question {
        font-size: 0.9rem;
        margin-bottom: 0.75rem;
    }
    .mcq-option {
        padding: 10px 12px;
        min-height: 45px;
        gap: 8px;
    }
    .mcq-option label {
        font-size: 0.85rem;
    }
    .timer-display, .back-btn {
        position: relative;
        top: auto;
        right: auto;
        left: auto;
        margin: 0.25rem;
        display: inline-block;
        font-size: 0.8rem;
        padding: 6px 12px;
    }
    .btn {
        padding: 10px 20px;
        font-size: 0.9rem;
        min-height: 40px;
    }
    .answer-status {
        font-size: 0.7rem;
        padding: 0.2rem 0.6rem;
    }
    :root {
        --card-height: 280px;
        --card-width: 98vw;
    }
    /* Ensure buttons wrap properly on small screens */
    .d-flex.gap-3 {
        flex-direction: column;
        gap: 0.75rem !important;
    }
    .d-flex.gap-3 .btn {
        width: 100%;
        max-width: 300px;
        margin: 0 auto;
    }
    /* Make results screen more mobile friendly */
    .results-screen {
        padding: 0.75rem;
        margin: 0.5rem;
    }
    .col-6.col-md-3, .col-4 {
        margin-bottom: 0.5rem;
    }
    .stats-card {
        padding: 0.75rem;
    }
    .stats-card .h2, .stats-card .h3 {
        font-size: 1.5rem;
        margin-bottom: 0.25rem;
    }
    .stats-card .small {
        font-size: 0.75rem;
        line-height: 1.4;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    /* Stack buttons vertically on very small screens */
    .d-flex.gap-3 {
        flex-direction: column;
        gap: 0.5rem !important;
    }
    .btn-lg {
        padding: 0.5rem 1rem;
        font-size: 1rem;
    }
}

/* Extra small screens (under 576px) */
@media (max-width: 575.98px) {
    .results-screen {
        padding: 0.5rem;
        margin: 0.25rem;
        border-radius: 8px;
    }
    .display-4 {
        font-size: 2rem;
    }
    .results-screen h2 {
        font-size: 1.25rem;
    }
    .stats-card {
        padding: 0.5rem;
    }
    .stats-card .h2, .stats-card .h3 {
        font-size: 1.25rem;
        margin-bottom: 0.1rem;
    }
    .stats-card .small {
        font-size: 0.7rem;
        line-height: 1.4;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    /* Make buttons smaller on tiny screens */
    .btn-lg {
        padding: 0.375rem 0.75rem;
        font-size: 0.9rem;
    }
    /* Reduce margins between sections */
    .mb-4 {
        margin-bottom: 1rem !important;
    }
}

/* Accessibility improvements */
.btn:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

.mcq-option:focus-within {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Print styles for answer sheet */
@media print {
    .results-screen {
        box-shadow: none;
        border: 1px solid #000;
    }
    .review-tabs, .btn {
        display: none !important;
    }
    .answer-review {
        display: block !important;
        overflow: visible;
    }
}

/* Match-the-Following Question Styles */
.match-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin: 1rem -0.75rem;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.6);
    width: calc(100% + 1.5rem);
    box-sizing: border-box;
    overflow: visible;
}

.match-column {
    background: rgba(255, 255, 255, 0.7);
    padding: 0.5rem;
    border-radius: 8px;
    border: 1px solid rgba(102, 126, 234, 0.2);
    min-width: 0;
    overflow: hidden;
}

.match-column-header {
    font-weight: 700;
    font-size: 0.85rem;
    color: #667eea;
    margin-bottom: 0.5rem;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid #667eea;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.match-item {
    padding: 0.5rem;
    margin: 0.35rem 0;
    background: white;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    font-size: 0.75rem;
    line-height: 1.4;
    transition: all 0.2s ease;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.match-item:hover {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

.match-item strong {
    color: #667eea;
    margin-right: 0.5rem;
    display: inline-block;
    min-width: 20px;
}

/* Question Image Styles */
.question-image {
    text-align: center;
    margin: 1rem 0;
}

.question-image img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.6);
}

/* Responsive adjustments for match-the-following */
@media (max-width: 768px) {
    .match-container {
        grid-template-columns: 1fr;
        gap: 0.75rem;
        margin: 1rem -0.5rem;
        padding: 0.5rem;
        width: calc(100% + 1rem);
    }

    .match-column {
        padding: 0.75rem;
    }

    .match-column-header {
        font-size: 0.9rem;
        white-space: normal;
    }

    .match-item {
        font-size: 0.8rem;
        padding: 0.6rem;
    }
}

/* Mains important points styling */
.important-points-content {
    background-color: #f8f9fa;
    line-height: 1.8;
    font-size: 0.95rem;
    color: #212529;
    text-align: left;
}

.important-points-content h1,
.important-points-content h2,
.important-points-content h3,
.important-points-content h4,
.important-points-content h5,
.important-points-content h6 {
    font-weight: 700;
    margin-top: 1.2rem;
    margin-bottom: 0.8rem;
    color: #198754;
}

.important-points-content strong {
    font-weight: 700;
    color: #0d6efd;
}

.important-points-content ul,
.important-points-content ol {
    margin-left: 0;
    margin-bottom: 1rem;
    padding-left: 1.25rem;
    list-style-position: outside;
}

.important-points-content li {
    margin-bottom: 0.6rem;
    line-height: 1.8;
}

.important-points-content ul li {
    list-style-type: disc;
}

.important-points-content p {
    margin-bottom: 0.8rem;
    line-height: 1.8;
}

.important-points-content p:first-child {
    margin-top: 0;
}

.important-points-content code {
    background-color: #e9ecef;
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
    font-size: 0.9em;
}

.important-points-content pre {
    background-color: #e9ecef;
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    overflow-x: auto;
}

/* Extra small screens */
@media (max-width: 480px) {
    .match-container {
        padding: 0.4rem;
        gap: 0.5rem;
        margin: 0.75rem -0.4rem;
        width: calc(100% + 0.8rem);
    }

    .match-column {
        padding: 0.4rem;
    }

    .match-item {
        font-size: 0.7rem;
        padding: 0.4rem;
        margin: 0.3rem 0;
    }

    .match-column-header {
        font-size: 0.8rem;
    }
}

/* Desktop - wider screens */
@media (min-width: 769px) {
    .match-container {
        gap: 0.75rem;
        padding: 0.75rem;
        margin: 1rem -1rem;
        width: calc(100% + 2rem);
    }

    .match-column {
        padding: 0.75rem;
    }

    .match-column-header {
        font-size: 0.9rem;
    }

    .match-item {
        font-size: 0.8rem;
        padding: 0.6rem;
    }
}

/* ═══════════════════════════════════════════════════
   Study Mode — toggle, banner, answer reveal
   ═══════════════════════════════════════════════════ */

/* Home screen toggle card */
.study-mode-toggle {
    display: grid;
    grid-template-columns: 42px 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 14px 16px;
    margin: 18px auto 0;
    max-width: 500px;
    width: 100%;
    background: var(--card-surface);
    border: 1px solid var(--card-edge);
    border-radius: 14px;
    cursor: pointer;
    text-align: left;
    transition: transform 0.06s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    box-shadow: var(--card-shadow);
}
.study-mode-toggle:hover {
    border-color: rgba(102, 126, 234, 0.6);
    transform: translateY(-1px);
    box-shadow: 0 12px 32px rgba(102, 126, 234, 0.15);
}
.study-mode-toggle:active {
    transform: scale(0.99);
}
.study-toggle-ico {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(102,126,234,0.15), rgba(118,75,162,0.15));
    display: grid;
    place-items: center;
    font-size: 20px;
}
.study-toggle-title {
    font-family: var(--serif);
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
}
.study-toggle-sub {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}
.study-switch {
    width: 44px;
    height: 24px;
    border-radius: 999px;
    background: rgba(0,0,0,0.12);
    border: 1px solid rgba(0,0,0,0.08);
    position: relative;
    transition: background 0.2s ease;
}
.study-switch::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transition: transform 0.2s ease;
}
.study-switch.on {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-color: transparent;
}
.study-switch.on::after {
    transform: translateX(20px);
}

/* Active state: tint the toggle card */
body.study-mode .study-mode-toggle {
    background: rgba(102, 126, 234, 0.12);
    border-color: rgba(102, 126, 234, 0.4);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1), 0 8px 24px rgba(102, 126, 234, 0.15);
}

/* Study banner in quiz view */
.study-banner {
    display: none;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 7px 12px;
    border-radius: 8px;
    font-size: 12px;
    color: #3a1d8e;
    background:
        repeating-linear-gradient(135deg, rgba(102,126,234,0.08) 0 8px, transparent 8px 18px),
        rgba(102, 126, 234, 0.1);
    border: 1px solid rgba(102, 126, 234, 0.3);
    position: relative;
    overflow: hidden;
}
.study-banner .sb-txt {
    flex: 1;
    line-height: 1.35;
}
.study-banner .sb-txt strong {
    font-weight: 700;
}
.study-banner::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg, transparent 35%, rgba(255,255,255,0.5) 50%, transparent 65%);
    transform: translateX(-120%);
    animation: studyShineLoop 4.2s ease-out 0.4s infinite;
    pointer-events: none;
}
body.study-mode .study-banner {
    display: flex;
    animation: studyBannerStripe 12s linear infinite,
        studyBannerEnter 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* Pulsing dot */
.sb-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #667eea;
    box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.55);
    animation: studyDotPulse 1.6s ease-in-out infinite;
    flex-shrink: 0;
}

/* Study mode answer reveal */
.mcq-option.study-correct {
    background: rgba(40, 167, 69, 0.15) !important;
    border-color: rgba(40, 167, 69, 0.5) !important;
    box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.2);
}
.mcq-option.study-correct label {
    color: #1a7a34 !important;
    font-weight: 700;
}
.mcq-option.study-correct::before {
    content: "✓";
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    color: #28a745;
    font-weight: 700;
}
.mcq-option.study-wrong {
    background: rgba(220, 53, 69, 0.1) !important;
    border-color: rgba(220, 53, 69, 0.4) !important;
    box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.15);
}
.mcq-option.study-wrong label {
    color: #a71d2a !important;
    text-decoration: line-through;
    opacity: 0.8;
}
.mcq-option.study-wrong::before {
    content: "✗";
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    color: #dc3545;
    font-weight: 700;
}
.mcq-option.study-correct,
.mcq-option.study-wrong {
    position: relative;
    pointer-events: none;
}

/* Keyframes */
@keyframes studyDotPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.55); transform: scale(1); }
    50% { box-shadow: 0 0 0 5px rgba(102, 126, 234, 0); transform: scale(1.15); }
}
@keyframes studyBannerStripe {
    from { background-position: 0 0, 0 0; }
    to { background-position: 51px 0, 0 0; }
}
@keyframes studyBannerEnter {
    0% { opacity: 0; transform: translateY(-6px) scaleY(0.6); }
    100% { opacity: 1; transform: translateY(0) scaleY(1); }
}
@keyframes studyShineLoop {
    0% { transform: translateX(-120%); }
    25% { transform: translateX(120%); }
    100% { transform: translateX(120%); }
}

@media (prefers-reduced-motion: reduce) {
    .sb-dot, .study-banner::after, body.study-mode .study-banner {
        animation: none !important;
    }
}
