/* NCAL Study App Styles */

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
}

/* Accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Layout */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem 1rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

.header-left {
    text-align: left;
    flex: 1;
}

.logo-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80px;
    flex-shrink: 0;
}

.header-logo {
    height: 80px;
    width: auto;
    max-width: 200px;
    transition: transform 0.2s ease;
    object-fit: contain; /* Ensure logo maintains aspect ratio */
    display: block; /* Ensure proper display */
}

.header-logo:hover {
    transform: scale(1.05);
    filter: drop-shadow(0 0 8px rgba(255,255,255,0.3)); /* Add glow effect on hover */
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

footer {
    text-align: center;
    padding: 2rem;
    color: #666;
    border-top: 1px solid #e9ecef;
    margin-top: 3rem;
}

/* Screen Management */
.screen {
    display: none;
}

.screen.active {
    display: block;
}

/* Typography */
h2 {
    font-size: 2rem;
    margin-bottom: 1.5rem;
    color: #2c3e50;
}

h3 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: #34495e;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-toggle {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0056b3, #004085);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,123,255,0.3);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

.btn-toggle {
    background: #e9ecef;
    color: #495057;
    border: 1px solid #dee2e6;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.btn-toggle:hover {
    background: #dee2e6;
}

.btn-icon {
    font-size: 1.1rem;
}

/* Setup Screen */
.setup-container {
    max-width: 1200px;
    margin: 0 auto;
}

.setup-header {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.setup-header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.setup-icon {
    font-size: 1.5rem;
    opacity: 0.7;
    color: #6c757d;
}

/* Control Groups */
.control-group {
    margin-bottom: 2rem;
    padding: 2rem;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.control-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #495057;
    font-size: 1.1rem;
}

/* Subject Selector */
.subject-selector {
    display: flex;
    gap: 2rem;
    margin-bottom: 1rem;
    justify-content: space-between;
}

.subject-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.subject-group {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid #e9ecef;
}

.subject-group h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: #495057;
    border-bottom: 2px solid #dee2e6;
    padding-bottom: 0.5rem;
    font-weight: 700;
}

.section-header {
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    user-select: none;
}

.section-header:hover {
    color: #007bff;
    border-bottom-color: #007bff;
    transform: translateY(-1px);
}

.section-header::after {
    content: '▼';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.8rem;
    opacity: 0.6;
    transition: all 0.2s ease;
}

.section-header:hover::after {
    opacity: 1;
    color: #007bff;
}

.section-header.all-selected::after {
    content: '✓';
    color: #28a745;
    opacity: 1;
}

.section-header.none-selected::after {
    content: '○';
    color: #6c757d;
    opacity: 0.6;
}

.section-header.mixed-selected::after {
    content: '◐';
    color: #ffc107;
    opacity: 1;
}

.subject-group label {
    display: flex;
    align-items: center;
    margin-bottom: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

.subject-group label:hover {
    background: #e9ecef;
}

.subject-group input[type="checkbox"] {
    margin-right: 0.75rem;
    transform: scale(1.3);
    cursor: pointer;
    min-width: 18px;
    min-height: 18px;
}

.subject-toggle {
    grid-column: 1 / -1;
    text-align: center;
    margin-top: 1rem;
}

.pool-preview-card {
    background: linear-gradient(135deg, #e3f2fd, #f3e5f5);
    border: 1px solid #e1bee7;
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 1rem;
    text-align: center;
}

.pool-preview-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.pool-icon {
    font-size: 1.2rem;
}

.pool-preview-header h4 {
    margin: 0;
    color: #4a148c;
    font-size: 1rem;
    font-weight: 600;
}

.pool-preview {
    font-size: 1.25rem;
    font-weight: 700;
    color: #4a148c;
    margin-bottom: 0.5rem;
}

.pool-hint {
    font-size: 0.9rem;
    color: #6a1b9a;
    opacity: 0.8;
}

/* Level Selector */
.level-selector {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.level-option {
    display: flex;
    align-items: center;
    margin-bottom: 0;
    cursor: pointer;
    padding: 0.75rem 1.5rem;
    background: #f8f9fa;
    border-radius: 25px;
    border: 2px solid #dee2e6;
    transition: all 0.2s ease;
    font-weight: 500;
}

.level-option:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.level-option input[type="radio"] {
    margin-right: 0.5rem;
    transform: scale(1.2);
    cursor: pointer;
    min-width: 18px;
    min-height: 18px;
}

.level-option input[type="radio"]:checked + span {
    color: #007bff;
}

.level-note {
    font-size: 0.9rem;
    color: #6c757d;
    font-style: italic;
}

/* Settings Row Layout */
.settings-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.setting-item label {
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #495057;
    font-size: 1.1rem;
}

/* Timer Control */
.timer-control {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    max-width: 100%;
}

/* Timer Slider */
input[type="range"] {
    width: 100%;
    height: 12px; /* Increased for better touch */
    border-radius: 6px;
    background: #dee2e6;
    outline: none;
    -webkit-appearance: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 28px; /* Larger for better touch */
    height: 28px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    transition: all 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0,123,255,0.4);
}

input[type="range"]::-moz-range-thumb {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.timer-icon {
    font-size: 1.5rem;
}

.timer-value {
    font-weight: 600;
    color: #007bff;
    font-size: 1.1rem;
    min-width: 3rem;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    margin-top: 2.5rem;
}

/* Practice Screen */
.practice-container {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 2.5rem;
    max-width: 1600px;
    margin: 0 auto;
}

/* Use more horizontal space on larger screens */
@media (min-width: 1400px) {
    .practice-container {
        max-width: 1800px;
        grid-template-columns: 1fr 400px;
        gap: 3rem;
    }
}

@media (min-width: 1800px) {
    .practice-container {
        max-width: 2000px;
        grid-template-columns: 1fr 450px;
        gap: 3.5rem;
    }
}

.practice-main {
    background: white;
    border-radius: 16px;
    padding: 2.5rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.practice-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e9ecef;
    flex-wrap: wrap;
    gap: 1rem;
}

.practice-header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.question-context {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.context-tag {
    background: #e9ecef;
    color: #495057;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
}

.question-counter {
    font-weight: 700;
    color: #007bff;
    font-size: 1.1rem;
}

/* Question Card */
.question-card {
    margin-bottom: 2rem;
}

.question-text {
    font-size: 1.8rem;
    margin-bottom: 2rem;
    color: #2c3e50;
    line-height: 1.4;
    font-weight: 600;
    min-height: 2.5rem; /* Ensure consistent height during reveal */
    transition: opacity 0.3s ease;
    text-transform: none; /* Override h3 uppercase rule for question text */
}

.question-text.revealing {
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
}

.question-text.revealing:hover {
    background: rgba(0,123,255,0.05);
    border-radius: 8px;
    padding: 0.5rem;
    margin: -0.5rem;
}

.question-text.revealing::after {
    content: '|';
    animation: blink 1s infinite;
    color: #007bff;
    margin-left: 2px;
}

.question-text.revealing::before {
    content: '💡 Click to show full question instantly';
    position: absolute;
    top: -2rem;
    left: 0;
    font-size: 0.8rem;
    color: #6c757d;
    opacity: 0;
    animation: fadeInHint 3s ease-in-out;
}

@keyframes fadeInHint {
    0%, 20% { opacity: 0; }
    30%, 70% { opacity: 0.8; }
    100% { opacity: 0; }
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.answer-section {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    align-items: center;
}

#answer-input {
    flex: 1;
    padding: 1rem 1.25rem;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    font-size: 1.1rem;
    transition: all 0.2s ease;
    -webkit-appearance: none; /* Remove iOS styling */
    -moz-appearance: none;
    appearance: none;
    background: white;
    min-height: 48px; /* Touch target size */
}

#answer-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0,123,255,0.1);
    transform: scale(1.02); /* Subtle feedback */
}

#answer-input::placeholder {
    color: #6c757d;
    opacity: 0.8;
}

/* Timer Display */
.timer-display {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    justify-content: center;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: 12px;
}

.timer-ring {
    position: relative;
    width: 80px;
    height: 80px;
}

.timer-ring svg {
    width: 100%;
    height: 100%;
}

.timer-ring circle {
    transition: stroke-dashoffset 0.1s linear;
}

.timer-countdown {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.2rem;
    font-weight: 700;
    color: #495057;
}

.timer-info {
    text-align: center;
}

.timer-seconds {
    font-size: 1.5rem;
    font-weight: 700;
    color: #495057;
    margin-bottom: 0.25rem;
}

.timer-note {
    font-size: 0.9rem;
    color: #6c757d;
}

.pause-hint {
    font-size: 0.9rem;
    color: #6c757d;
    text-align: center;
    margin-top: 0.5rem;
}

/* Practice Sidebar */
.practice-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.sidebar-section {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.sidebar-section h3 {
    margin-bottom: 1rem;
    color: #495057;
    font-size: 1rem;
}

/* Stats Cards */
.stats-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

/* Desktop: Use 2-column layout for better space utilization */
@media (min-width: 1200px) {
    .stats-cards {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }
    
    .stat-card {
        padding: 1rem 0.75rem;
    }
    
    .stat-label {
        font-size: 0.8rem;
    }
    
    .stat-value {
        font-size: 1.4rem;
    }
    
    /* Make progress card span both columns */
    .stat-card.progress {
        grid-column: 1 / -1;
    }
}

.stat-card {
    text-align: center;
    padding: 1rem 0.5rem;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.stat-card.correct {
    background: #d4edda;
    border-color: #c3e6cb;
}

.stat-card.incorrect {
    background: #f8d7da;
    border-color: #f5c6cb;
}

.stat-card.progress {
    background: #e2e3e5;
    border-color: #d6d8db;
}

.stat-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #495057;
}

/* Progress Bar */
.progress-bar {
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #28a745, #20c997);
    transition: width 0.3s ease;
    width: 0%;
}

.accuracy-display {
    text-align: center;
    font-weight: 600;
    color: #495057;
    font-size: 0.9rem;
}

/* Filter Tags */
.filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.filter-tag {
    background: #e9ecef;
    color: #495057;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

/* Shortcuts */
.shortcuts-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.shortcut-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    background: #f8f9fa;
    border-radius: 6px;
}

.shortcut-key {
    background: #495057;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: monospace;
}

.shortcut-action {
    font-size: 0.9rem;
    color: #495057;
}

/* Reading Speed Control in Practice */
.reading-speed-practice {
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.speed-icon {
    font-size: 1.1rem;
    min-width: 20px;
}

.speed-control input[type="range"] {
    flex: 1;
    height: 6px;
    background: #dee2e6;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

.speed-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.speed-control input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
    border: none;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.speed-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: #007bff;
    min-width: 60px;
    text-align: right;
}

.speed-hint {
    font-size: 0.8rem;
    color: #6c757d;
    text-align: center;
    font-style: italic;
}

/* Result Display */
.result-display {
    text-align: center;
    padding: 2rem;
    background: #f8f9fa;
    border-radius: 12px;
    border: 1px solid #e9ecef;
}

.result-display.hidden {
    display: none;
}

.result-status {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

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

.result-status.incorrect {
    color: #dc3545;
}

.result-status.timeout {
    color: #ff6b35;
    font-weight: 700;
    font-size: 1.8rem;
    text-shadow: 0 0 10px rgba(255, 107, 53, 0.3);
    animation: timeoutPulse 1s ease-in-out;
}

.canonical-answer {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    border: 1px solid #dee2e6;
    font-size: 1.1rem;
    font-weight: 500;
}

.canonical-answer::before {
    content: "Correct Answer: ";
    font-weight: 600;
    color: #495057;
}



/* Summary Screen */
.summary-container {
    max-width: 1400px;
    margin: 0 auto;
}

.summary-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e9ecef;
}

.summary-header h2 {
    margin-bottom: 0;
}

/* Summary Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.summary-card {
    background: white;
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.summary-card.overall {
    text-align: center;
}

.score-display {
    margin-bottom: 1.5rem;
}

.score {
    font-size: 2.5rem;
    font-weight: 700;
    color: #495057;
    margin-right: 1rem;
}

.percentage {
    font-size: 1.5rem;
    color: #6c757d;
}

.overall-progress {
    max-width: 400px;
    margin: 0 auto;
}

.subject-accuracy {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.subject-stat {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
    border: 1px solid #e9ecef;
}

.subject-stat h4 {
    margin-bottom: 0.5rem;
    color: #495057;
}

/* Missed Questions */
.missed-questions {
    background: white;
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
}

.missed-table {
    overflow-x: auto;
}

.missed-table table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.missed-table th,
.missed-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}

.missed-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #495057;
}

.summary-actions {
    text-align: center;
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Error Panel */
.error-panel {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
}

.error-panel.hidden {
    display: none;
}

.error-panel h3 {
    color: #721c24;
    margin-bottom: 0.75rem;
}

.error-actions {
    margin-top: 1rem;
    display: flex;
    gap: 0.5rem;
}

/* Responsive Design */

/* Large Desktop (1400px+) */
@media (min-width: 1400px) {
    .setup-container {
        max-width: 1400px;
    }
    
    .question-text {
        font-size: 2rem;
    }
    
    .control-group {
        padding: 2.5rem;
    }
    
    .practice-main {
        padding: 3rem;
    }
    
    .sidebar-section {
        padding: 2.5rem;
    }
}

/* Extra Large Desktop (1800px+) */
@media (min-width: 1800px) {
    .setup-container {
        max-width: 1600px;
    }
    
    .practice-main {
        padding: 3.5rem;
    }
    
    .sidebar-section {
        padding: 3rem;
    }
    
    .control-group {
        padding: 3rem;
    }
}

/* Desktop (1200px - 1399px) */
@media (max-width: 1399px) and (min-width: 1200px) {
    .practice-container {
        gap: 1.5rem;
    }
    
    .practice-sidebar {
        width: 300px;
    }
}

/* Tablet & Small Desktop (768px - 1199px) */
@media (max-width: 1199px) {
    .practice-container {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .practice-sidebar {
        order: -1;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 1rem;
    }
    
    .sidebar-section {
        margin-bottom: 0;
    }
    
    .stats-cards {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Large Mobile & Small Tablet (600px - 767px) */
@media (max-width: 767px) {
    header {
        padding: 1rem 0.75rem;
    }
    
    .header-content {
        flex-direction: column;
        text-align: center;
        gap: 0.75rem;
    }
    
    .header-left {
        text-align: center;
    }
    
    .header-logo {
        height: 50px;
        max-width: 120px;
    }
    
    header h1 {
        font-size: 1.75rem;
    }
    
    header p {
        font-size: 0.9rem;
    }
    
    main {
        padding: 0.75rem;
    }
    
    /* Setup Screen Mobile */
    .subject-selector {
        flex-direction: column;
        gap: 1rem;
    }
    
    .subject-column {
        gap: 1rem;
    }
    
    .subject-group {
        padding: 1rem;
    }
    
    .level-selector {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .level-option {
        justify-content: center;
        padding: 1rem;
    }
    
    .settings-row {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .timer-control {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .action-buttons {
        flex-direction: column;
        align-items: stretch;
    }
    
    /* Practice Screen Mobile */
    .practice-main {
        padding: 1.5rem;
    }
    
    .practice-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
        margin-bottom: 1.5rem;
        padding-bottom: 0.75rem;
    }
    
    .practice-header-left {
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .question-context {
        justify-content: center;
        order: 3;
        gap: 0.5rem;
    }
    
    .question-counter {
        text-align: center;
        order: 2;
        font-size: 1.1rem;
    }
    
    .question-text {
        font-size: 1.3rem;
        line-height: 1.3;
        margin-bottom: 1.5rem;
    }
    
    .answer-section {
        flex-direction: column;
        gap: 0.75rem;
        margin-bottom: 1rem;
        background: #f8f9fa;
        padding: 1rem;
        border-radius: 12px;
        border: 2px solid #e9ecef;
        position: relative;
    }
    
    .answer-section::before {
        content: "Type your answer below:";
        display: block;
        font-size: 0.9rem;
        font-weight: 600;
        color: #495057;
        margin-bottom: 0.5rem;
        text-align: center;
    }
    
    #answer-input {
        font-size: 1.1rem;
        padding: 1rem;
        -webkit-tap-highlight-color: rgba(0,123,255,0.2);
        border-radius: 8px;
        border: 2px solid #007bff;
        background: white;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    #answer-input:focus {
        border-color: #0056b3;
        box-shadow: 0 0 0 3px rgba(0,123,255,0.25);
        outline: none;
    }
    
    #submit-answer {
        font-size: 1.1rem;
        padding: 1rem;
        font-weight: 600;
        box-shadow: 0 4px 8px rgba(0,123,255,0.3);
    }
    
    .timer-display {
        flex-direction: column;
        gap: 0.75rem;
        padding: 0.75rem;
        margin-top: 1rem;
    }
    
    .timer-ring {
        width: 80px;
        height: 80px;
    }
    
    .timer-countdown {
        font-size: 1.3rem;
    }
    
    /* Sidebar Mobile */
    .practice-sidebar {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .sidebar-section {
        padding: 1rem;
        margin-bottom: 0.5rem;
    }
    
    .stats-cards {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }
    
    .stat-card {
        padding: 0.5rem;
    }
    
    .stat-label {
        font-size: 0.7rem;
    }
    
    .stat-value {
        font-size: 1.2rem;
    }
    
    .shortcuts-list {
        display: none; /* Hide shortcuts on mobile to save space */
    }
    
    /* Compact reading speed control on mobile */
    .reading-speed-practice {
        padding: 0.5rem;
    }
    
    .speed-control {
        gap: 0.5rem;
    }
    
    .speed-value {
        font-size: 0.8rem;
        min-width: 50px;
    }
    
    .filter-tags {
        gap: 0.25rem;
    }
    
    .filter-tag {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
    }
    
    /* Summary Screen Mobile */
    .summary-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .summary-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .missed-table {
        font-size: 0.85rem;
    }
    
    .missed-table th,
    .missed-table td {
        padding: 0.5rem 0.25rem;
    }
    
    .summary-cards {
        grid-template-columns: 1fr;
    }
    
    .score {
        font-size: 2rem;
    }
}

/* Small Mobile (320px - 599px) */
@media (max-width: 599px) {
    .header-content {
        gap: 0.75rem;
    }
    
    .header-logo {
        height: 50px;
        max-width: 120px;
    }
    
    header h1 {
        font-size: 1.75rem;
    }
    
    main {
        padding: 0.75rem 0.5rem;
    }
    
    /* Touch-friendly buttons */
    .btn-primary, .btn-secondary, .btn-toggle {
        padding: 1rem 1.5rem;
        font-size: 1.1rem;
        min-height: 48px; /* Touch target size */
        min-width: 48px;
        touch-action: manipulation; /* Disable double-tap zoom */
    }
    
    /* Mobile-specific enhancements */
    input[type="checkbox"], input[type="radio"] {
        transform: scale(1.4);
        margin: 0.5rem;
    }
    
    /* Better mobile timer slider */
    input[type="range"] {
        height: 16px;
        padding: 8px 0;
    }
    
    input[type="range"]::-webkit-slider-thumb {
        width: 32px;
        height: 32px;
    }
    
    input[type="range"]::-moz-range-thumb {
        width: 32px;
        height: 32px;
    }
    
    /* Setup Screen */
    .setup-container {
        max-width: none;
    }
    
    .control-group {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .subject-group label {
        padding: 0.75rem;
        margin-bottom: 0.5rem;
    }
    
    .pool-preview-card {
        padding: 1rem;
    }
    
    /* Practice Screen */
    .practice-main {
        padding: 1rem;
        border-radius: 12px;
    }
    
    .question-card {
        margin-bottom: 1rem;
    }
    
    .question-text {
        font-size: 1.25rem;
        margin-bottom: 1.5rem;
    }
    
    #answer-input {
        padding: 1rem;
    }
    
    .timer-display {
        padding: 0.75rem;
    }
    
    .timer-ring {
        width: 80px;
        height: 80px;
    }
    
    .timer-countdown {
        font-size: 1.25rem;
    }
    
    .result-display {
        padding: 1rem;
    }
    
    .canonical-answer {
        padding: 1rem;
        font-size: 1rem;
    }
    
    /* Context tags mobile */
    .context-tag {
        font-size: 0.8rem;
        padding: 0.25rem 0.5rem;
    }
    
    /* Summary mobile */
    .summary-card {
        padding: 1rem;
    }
    
    .missed-table {
        font-size: 0.8rem;
    }
    
    /* Hide non-essential elements on very small screens */
    .pause-hint {
        display: none;
    }
    
    .timer-note {
        font-size: 0.8rem;
    }
}

/* Very Small Mobile (max 360px) */
@media (max-width: 360px) {
    .header-content {
        gap: 0.5rem;
    }
    
    .header-logo {
        height: 40px;
        max-width: 100px;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    .question-text {
        font-size: 1.1rem;
    }
    
    .practice-header-left {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .timer-ring {
        width: 70px;
        height: 70px;
    }
    
    .timer-countdown {
        font-size: 1.1rem;
    }
    
    .score {
        font-size: 1.75rem;
    }
}

/* Landscape Orientation Mobile */
@media (max-height: 600px) and (orientation: landscape) {
    header {
        padding: 1rem;
    }
    
    .header-content {
        gap: 1rem;
    }
    
    header h1 {
        font-size: 1.75rem;
        margin-bottom: 0.25rem;
    }
    
    main {
        padding: 1rem;
    }
    
    .practice-header {
        margin-bottom: 1rem;
        padding-bottom: 0.5rem;
    }
    
    .question-text {
        font-size: 1.25rem;
        margin-bottom: 1rem;
    }
    
    .timer-display {
        padding: 0.75rem;
        gap: 1rem;
    }
    
    .timer-ring {
        width: 60px;
        height: 60px;
    }
}

/* Focus Styles for Accessibility */
button:focus,
input:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Animation for transitions */
.screen {
    animation: fadeIn 0.3s ease-in-out;
}

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

/* Pause state styling */
.timer-display.paused #timer-countdown {
    color: #ffc107;
}

.timer-display.paused #timer-progress {
    stroke: #ffc107;
}

/* Timeout state styling */
.timer-display.timeout {
    animation: timeoutFlash 0.5s ease-in-out;
}

.timer-display.timeout #timer-countdown {
    color: #ff6b35;
    font-weight: 700;
    text-shadow: 0 0 8px rgba(255, 107, 53, 0.5);
}

.timer-display.timeout #timer-progress {
    stroke: #ff6b35;
    stroke-width: 6;
}

@keyframes timeoutFlash {
    0% { 
        background-color: transparent;
        transform: scale(1);
    }
    50% { 
        background-color: rgba(255, 107, 53, 0.1);
        transform: scale(1.02);
    }
    100% { 
        background-color: transparent;
        transform: scale(1);
    }
}

/* Loading state */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes timeoutPulse {
    0% { 
        transform: scale(1);
        opacity: 1;
    }
    50% { 
        transform: scale(1.1);
        opacity: 0.8;
    }
    100% { 
        transform: scale(1);
        opacity: 1;
    }
}

/* Enhanced smooth scrolling for mobile */
@media (max-width: 767px) {
    html {
        scroll-behavior: smooth;
        scroll-padding-top: 20px;
    }
    
    /* Ensure smooth transitions for mobile interactions */
    * {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Add visual feedback for touch interactions */
    .btn-primary:active,
    .btn-secondary:active,
    #submit-answer:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
    
    /* Improve touch targets */
    button, input, select, textarea {
        min-height: 44px;
        min-width: 44px;
    }
}

