body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f4f7f6;
    color: #333;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
}

.container {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 900px; /* Increased width to accommodate sidebar */
    padding: 30px;
    display: flex;
    flex-direction: column;
    min-height: 600px;
    max-height: 90vh;
    position: relative;
}

.screen {
    display: flex;
    flex-direction: column;
    height: 100%;
    flex: 1;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

/* Header */
header {
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
    text-align: center;
    flex-shrink: 0;
}

header h1 {
    font-size: 1.8rem;
    margin: 0 0 5px 0;
    color: #2c3e50;
}

.subtitle {
    color: #7f8c8d;
    margin: 0;
}

#quiz-info {
    display: flex;
    justify-content: space-between;
    align-items: flex-start; /* Align top to handle taller stats box */
    margin-top: 10px;
    font-weight: bold;
    color: #34495e;
}

#timer {
    color: #e74c3c;
    margin-top: 5px;
}

/* Mode Selection */
.mode-selection {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 20px;
}

.mode-card {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.mode-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
    border-color: #3498db;
}

.mode-card h2 {
    margin-top: 0;
    color: #2980b9;
}

.start-btn, .primary-btn {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 5px;
    font-size: 1rem;
    cursor: pointer;
    margin-top: 15px;
    transition: background-color 0.2s;
}

.start-btn:hover, .primary-btn:hover {
    background-color: #2980b9;
}

/* Quiz Layout with Sidebar */
#quiz-container {
    overflow-y: hidden; /* Handle scrolling in children */
    flex: 1;
    display: flex;
    flex-direction: column;
}

.quiz-layout {
    display: flex;
    gap: 20px;
    height: 100%;
    overflow: hidden;
}

#question-card {
    flex: 1;
    overflow-y: auto;
    padding-right: 10px;
}

/* Sidebar Styles */
#exam-sidebar {
    width: 260px;
    background-color: #f8f9fa;
    border-left: 1px solid #eee;
    padding: 15px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    border-radius: 4px;
    flex-shrink: 0;
}

#exam-sidebar h3 {
    margin-top: 0;
    font-size: 1rem;
    color: #2c3e50;
    margin-bottom: 15px;
    text-align: center;
}

.nav-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-bottom: 15px;
}

.nav-item {
    width: 36px;
    height: 36px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 0.9rem;
    color: #555;
    transition: all 0.2s;
}

.nav-item:hover {
    border-color: #3498db;
}

.nav-item.answered {
    background-color: #d1ecf1;
    border-color: #bee5eb;
    color: #0c5460;
}

.nav-item.current {
    background-color: #3498db;
    color: white;
    border-color: #2980b9;
    font-weight: bold;
}

/* Legend */
.nav-legend {
    display: flex;
    justify-content: space-around;
    font-size: 0.8rem;
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid #e9ecef;
}

.legend-item {
    display: flex;
    align-items: center;
    color: #666;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #fff;
    border: 1px solid #ccc;
    margin-right: 5px;
    display: inline-block;
}

.dot.done {
    background-color: #d1ecf1;
    border-color: #bee5eb;
}

.dot.current {
    background-color: #3498db;
    border-color: #3498db;
}

/* Responsive Sidebar */
@media (max-width: 768px) {
    .container {
        padding: 10px;
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .quiz-layout {
        flex-direction: column;
    }
    
    #exam-sidebar {
        width: 100%;
        height: 150px; /* Reduced height on mobile */
        border-left: none;
        border-top: 1px solid #eee;
        order: -1; /* Show above or below? Let's keep sidebar distinct. Maybe hide and toggle? */
        /* For simplicity, let's keep it below but scrollable */
        order: 2;
    }
}

/* Question Content Styles */
.question-type-label {
    display: inline-block;
    background-color: #e8f6f3;
    color: #16a085;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    margin-bottom: 10px;
    font-weight: bold;
}

.question-text {
    font-size: 1.2rem;
    font-weight: 500;
    margin-bottom: 25px;
    line-height: 1.6;
}

.options-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.option-btn {
    padding: 14px 16px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background-color: #fff;
    cursor: pointer;
    text-align: left;
    font-size: 1rem;
    transition: all 0.2s;
    color: #333;
    line-height: 1.4;
}

.option-btn:hover:not(:disabled) {
    background-color: #f8f9fa;
    border-color: #bdc3c7;
}

.option-btn.selected {
    border-color: #3498db;
    background-color: #ebf5fb;
}

.option-btn.correct {
    background-color: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.option-btn.incorrect {
    background-color: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

.feedback {
    margin-top: 25px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 6px;
    border-left: 4px solid #3498db;
}

.feedback.success { border-left-color: #2ecc71; }
.feedback.error { border-left-color: #e74c3c; }

#feedback-message {
    font-weight: bold;
    margin: 0 0 10px 0;
}

.explanation {
    font-size: 0.95rem;
    color: #666;
    margin: 0;
}

/* Footer & Navigation */
.quiz-footer {
    margin-top: 20px;
    padding-top: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.nav-buttons {
    display: flex;
    gap: 10px;
}

.nav-btn, .secondary-btn, .action-btn {
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    border: none;
}

.nav-btn {
    background-color: #ecf0f1;
    color: #2c3e50;
}

.nav-btn:hover {
    background-color: #bdc3c7;
}

.secondary-btn {
    background: none;
    color: #7f8c8d;
    text-decoration: underline;
    padding: 10px 0;
}

.secondary-btn:hover {
    color: #34495e;
}

.action-btn {
    background-color: #27ae60;
    color: white;
}

.action-btn:hover {
    background-color: #219150;
}

.danger-btn {
    background-color: #fff;
    color: #e74c3c;
    border: 1px solid #e74c3c;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}
.danger-btn:hover {
    background-color: #ffebee;
}

/* Result Screen */
.result-content {
    text-align: center;
    overflow-y: auto;
    flex: 1;
    padding-right: 5px;
}

.score-circle {
    width: 120px;
    height: 120px;
    background-color: #3498db;
    color: white;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin: 0 auto 20px;
    box-shadow: 0 4px 10px rgba(52, 152, 219, 0.4);
}

#final-score {
    font-size: 2.5rem;
    font-weight: bold;
    line-height: 1;
}

.score-label {
    font-size: 0.9rem;
}

.result-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    text-align: left;
    max-width: 300px;
    margin: 0 auto;
    padding: 15px;
    background-color: #f9f9f9;
    border-radius: 8px;
}

.result-details p {
    margin: 5px 0;
    font-size: 0.95rem;
}

.text-success { color: #27ae60; font-weight: bold; }
.text-danger { color: #e74c3c; font-weight: bold; }

.wrong-questions-section {
    margin-top: 30px;
    text-align: left;
}

.wrong-questions-section h3 {
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
    color: #e74c3c;
}

.wrong-item {
    background-color: #fff;
    border: 1px solid #ffebee;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 15px;
    text-align: left;
}

.wrong-item-title {
    font-weight: bold;
    margin-bottom: 8px;
}

.wrong-item-answer {
    font-size: 0.9rem;
    color: #555;
}

.your-ans { color: #e74c3c; }
.correct-ans { color: #27ae60; }

/* Review Screen Styles */
.stats-summary {
    display: flex;
    justify-content: space-around;
    padding: 10px 0;
}

.stat-box {
    text-align: center;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.9rem;
    color: #7f8c8d;
}

.review-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.review-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-shrink: 0;
}

.filter-btn {
    background-color: #f0f2f5;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #555;
    transition: all 0.2s;
}

.filter-btn.active {
    background-color: #3498db;
    color: white;
}

.review-list {
    flex: 1;
    overflow-y: auto;
    padding-right: 5px;
    border-top: 1px solid #eee;
    padding-top: 10px;
}

.empty-state {
    text-align: center;
    color: #95a5a6;
    margin-top: 40px;
    font-size: 1.1rem;
}

.status-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    margin-right: 5px;
    font-weight: normal;
}

.status-badge.wrong {
    background-color: #ffebee;
    color: #e74c3c;
    border: 1px solid #ffcdd2;
}

.status-badge.correct {
    background-color: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
}

/* Search Screen Styles */
.search-bar-container {
    margin-top: 15px;
    padding: 0 10px;
}

#search-input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 25px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

#search-input:focus {
    border-color: #3498db;
    box-shadow: 0 0 5px rgba(52, 152, 219, 0.3);
}

.search-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-top: 10px;
}

.highlight {
    background-color: #fff3cd;
    color: #e67e22;
    font-weight: bold;
    padding: 0 2px;
    border-radius: 2px;
}

.site-credit {
    margin-top: 0;
    padding-top: 15px;
    padding-bottom: 5px;
    text-align: center;
    font-size: 0.75rem;
    color: #bdc3c7;
    font-style: italic;
    flex-shrink: 0;
}

/* Practice Stats Dashboard (Scoreboard) */
.practice-board {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 8px 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.03);
    min-width: 220px;
}

.pb-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px dashed #e0e0e0;
}

.pb-label { 
    font-weight: bold; 
    color: #555; 
    margin-right: auto; 
}

.pb-stat-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pb-val-c { color: #27ae60; font-weight: bold; font-size: 0.95rem; }
.pb-val-w { color: #e74c3c; font-weight: bold; font-size: 0.95rem; }
.pb-rate { 
    background: #f0f2f5; 
    padding: 2px 6px; 
    border-radius: 4px; 
    color: #2c3e50; 
    font-weight: bold; 
    font-size: 0.85rem; 
}

.pb-subs {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #7f8c8d;
}

.pb-sub-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pb-sub-label { font-weight: 500; }
.pb-sub-val { font-family: monospace; }
