: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, 255, 255, 0.6);
    --glass-border: rgba(255, 255, 255, 0.4);
    --text-primary: #1a1a2e;
    --text-secondary: #4a4a6a;
    --bg-pattern: radial-gradient(circle at 25% 25%, #667eea20 0%, transparent 50%),
                 radial-gradient(circle at 75% 75%, #764ba220 0%, transparent 50%);

    /* 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: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    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;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 20% 20%, rgba(255,255,255,0.08) 0%, transparent 50%),
                radial-gradient(circle at 80% 80%, rgba(255,255,255,0.06) 0%, transparent 50%);
    z-index: -1;
    opacity: 0.5;
}
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: var(--container-padding);
    position: relative;
    overflow: visible;
}
#controls {
    min-height: 80px;
}
footer {
    padding: 1.5rem 0;
    color: #6c757d;
    text-align: center;
    font-size: 0.9rem;
    background: #fff;
    border-top: 1px solid #dee2e6;
    margin-top: auto;
}
#final-score-screen {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 2rem;
    text-align: center;
    width: 100%;
    max-width: 500px;
    margin: 1rem auto;
    border: 1px solid var(--glass-border);
    box-shadow: 0 16px 40px rgba(0,0,0,0.15);
    color: var(--text-primary);
    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: var(--primary-gradient);
    opacity: 0.05;
    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); }
}

/* Floating animations for mode selection buttons */
#mode-selection .btn {
    animation: float 3s ease-in-out infinite;
}

#mode-selection .btn:nth-child(odd) {
    animation-delay: 0.5s;
}

#mode-selection .btn:nth-child(even) {
    animation-delay: 1s;
}

/* 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(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    width: 100%;
    border-radius: 24px;
    position: relative;
    z-index: 100;
    overflow: hidden;
}

.app-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--primary-gradient);
    opacity: 0.1;
    z-index: -1;
}

.app-title {
    color: var(--text-primary);
    font-size: 1.8rem;
    font-weight: 800;
    margin: 0;
    text-shadow: 0 2px 8px rgba(0,0,0,0.1);
    line-height: 1.2;
    text-align: center;
    position: relative;
    z-index: 10;
}

/* Emoji stays native; only title-text gets gradient */
.app-title .title-text {
    background: var(--primary-gradient);
    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(--text-secondary) !important;
    font-weight: 500;
    margin-top: 0.5rem;
}

/* Countdown Timer */
.countdown-timer {
    margin: 1rem auto;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.65);
    border: 2px solid rgba(255,215,0,0.5);
    border-radius: 20px;
    max-width: 600px;
    box-shadow: 0 10px 30px rgba(255,165,0,0.2),
                0 5px 15px rgba(0,0,0,0.08),
                inset 0 1px 0 rgba(255,255,255,0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    position: relative;
    overflow: hidden;
}

.countdown-timer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255,215,0,0.08) 0%, rgba(255,165,0,0.12) 100%);
    z-index: -1;
}

.countdown-label {
    font-size: 1.2rem;
    font-weight: 800;
    color: #ffffff;
    text-shadow: 0 2px 8px rgba(0,0,0,0.3),
                 0 4px 16px rgba(102,126,234,0.4);
    margin-bottom: 0.75rem;
    letter-spacing: 2px;
}

.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: 2.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
    filter: drop-shadow(0 2px 10px rgba(102,126,234,0.3));
    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(--glass-bg);
    backdrop-filter: blur(8px);
    color: var(--text-primary);
    padding: 12px 20px;
    border-radius: 50px;
    font-weight: 700;
    font-size: 0.9rem;
    border: 1px solid var(--glass-border);
    z-index: 1000;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    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(--glass-bg); border:1px solid var(--glass-border); color: var(--text-primary); }
.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(--glass-border); border-radius: 10px; padding: 8px; min-height: 64px; background: var(--glass-bg); }
.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(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 12px 20px;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 1000;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    contain: layout style;
}

.back-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    background: var(--primary-gradient);
    color: #fff;
    box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}

.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: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 24px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 2px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 15px 40px rgba(0,0,0,0.12),
                0 8px 20px rgba(102,126,234,0.08),
                inset 0 1px 0 rgba(255,255,255,0.6);
    position: relative;
    overflow: hidden;
    contain: layout style paint;
    min-height: 350px;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.mcq-container:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 50px rgba(0,0,0,0.15),
                0 10px 25px rgba(102,126,234,0.1),
                inset 0 1px 0 rgba(255,255,255,0.6);
}

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

.mcq-question {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    line-height: 1.5;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
    min-height: auto;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

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

.mcq-option {
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 16px;
    padding: 16px 20px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: flex-start;
    gap: 16px;
    min-height: 60px;
    position: relative;
    overflow: visible;
}

.mcq-option:focus {
    background: rgba(255, 255, 255, 0.6);
    border-color: rgba(33, 150, 243, 0.5);
    box-shadow: 0 4px 12px rgba(33,150,243,0.2);
}

.mcq-option.selected {
    background: rgba(40, 167, 69, 0.2);
    border-color: rgba(40, 167, 69, 0.5);
    box-shadow: 0 8px 24px rgba(40,167,69,0.25);
    transform: scale(1.02);
}

.mcq-option.selected::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--success-gradient);
    opacity: 0.1;
    border-radius: 16px;
}
.mcq-option input[type="radio"] {
    margin: 0;
    width: 20px;
    height: 20px;
    accent-color: #007bff;
    flex-shrink: 0;
    margin-top: 2px;
}
.mcq-option label {
    cursor: pointer;
    margin: 0;
    flex: 1;
    font-size: 0.9rem;
    line-height: 1.5;
    color: #2c3e50;
    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(--glass-bg);
    backdrop-filter: blur(15px);
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid var(--glass-border);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 1rem;
    position: relative;
    overflow: visible;
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
    min-height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.stats-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--success-gradient);
    border-radius: 16px 16px 0 0;
}

.stats-card:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: translate3d(0, -2px, 0) scale(1.01);
    box-shadow: 0 16px 40px rgba(0,0,0,0.2);
}

.stats-card .h2, .stats-card .h3 {
    background: var(--primary-gradient);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
}

/* 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 - Clean and Professional */
.answer-review {
    background: #fff;
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
    text-align: left;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    width: 100%;
    /* Allow natural scrolling with the page */
}

#review-content {
    width: 100%;
    /* Remove any height constraints to allow natural page flow */
}

.answer-item {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    border-left: 4px solid #6c757d;
}

.answer-item.correct {
    border-left-color: #28a745;
    background: #f8fff9;
}

.answer-item.wrong {
    border-left-color: #dc3545;
    background: #fff8f8;
}

.answer-item.skipped {
    border-left-color: #ffc107;
    background: #fffef8;
}

.question-text {
    font-weight: 600;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    color: #2c3e50;
    line-height: 1.4;
}

.answer-option {
    margin: 0.4rem 0;
    font-size: 0.85rem;
    padding: 0.3rem 0;
    color: #495057;
}

.correct-answer {
    color: #28a745;
    font-weight: 600;
    background: #e8f5e8;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
}

.user-answer {
    color: #dc3545;
    font-weight: 600;
    background: #ffe6e6;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
}

.skipped-answer {
    color: #856404;
    font-weight: 600;
    font-style: italic;
    background: #fff3cd;
    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(--primary-gradient); border: none; color: #fff; box-shadow: 0 8px 24px rgba(102, 126, 234, 0.3); }

.btn-primary:hover {
    box-shadow: 0 12px 32px rgba(102, 126, 234, 0.4);
}

.btn-success { background: var(--success-gradient); border: none; color: #fff; box-shadow: 0 8px 24px rgba(17, 153, 142, 0.3); }

.btn-success:hover {
    box-shadow: 0 12px 32px rgba(17, 153, 142, 0.4);
}

.btn-danger { background: var(--danger-gradient); border: none; color: #fff; box-shadow: 0 8px 24px rgba(252, 70, 107, 0.3); }

.btn-danger:hover {
    box-shadow: 0 12px 32px rgba(252, 70, 107, 0.4);
}

.btn-outline-primary { color: var(--text-primary); border: 1px solid var(--glass-border); background: var(--glass-bg); backdrop-filter: blur(20px); }

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

.btn-outline-secondary {
    color: var(--text-secondary);
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
}

.btn-outline-secondary:hover {
    background: linear-gradient(135deg, #6c757d, #495057);
    color: #fff;
    border-color: transparent;
}

/* 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;
    }
}

/* 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;
    }
}
