:root {
    --primary-color: #2563eb;
    --secondary-color: #1e40af;
    --tertiary-color: #059669;
    --accent-color: #3b82f6;
    --correct-color: #10b981;
    --incorrect-color: #ef4444;
    --neutral-color: #f9fafb;
    --text-color: #1f2937;
    --light-text: #6b7280;
    --unanswered-color: #dbeafe;
    --border-radius: 0.5rem;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --transition: all 0.2s ease;
    --vh: 1vh;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    margin: 0;
    padding: 0;
}

html, body {
    width: 100%;
    height: 100%;
    overflow-x: hidden;
}

body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', sans-serif;
    line-height: 1.5;
    color: var(--text-color);
    background-color: #f1f5f9;
    min-height: 100vh;
    min-height: calc(var(--vh, 1vh) * 100);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    cursor: default;
}

.container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
    min-height: calc(var(--vh, 1vh) * 100);
    display: flex;
    flex-direction: column;
}

header {
    text-align: center;
    margin-bottom: 1rem;
    padding: 1.25rem 1rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

header h1 {
    margin: 0;
    font-size: clamp(1.25rem, 4vw, 1.75rem);
    font-weight: 700;
    letter-spacing: -0.025em;
}

header p {
    margin-top: 0.5rem;
    font-size: clamp(0.875rem, 2.5vw, 1rem);
    opacity: 0.9;
}

.controls {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn {
    padding: 0.625rem 0.875rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: calc(var(--border-radius) - 0.125rem);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
}

.btn:hover {
    background-color: var(--secondary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    background-color: #d1d5db;
    color: #6b7280;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-group {
    display: flex;
    gap: 0.375rem;
}

.progress-container {
    background-color: #e5e7eb;
    border-radius: 9999px;
    height: 6px;
    width: 100%;
    margin-bottom: 1rem;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    transition: width 0.4s ease;
}

.quiz-card {
    background-color: white;
    border-radius: var(--border-radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
    transition: var(--transition);
    width: 100%;
}

.quiz-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.question-number {
    font-size: 0.875rem;
    color: var(--accent-color);
    font-weight: 600;
    letter-spacing: 0.025em;
}

.question-text {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    word-wrap: break-word;
    line-height: 1.4;
}

.options-container {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    margin-bottom: 1.25rem;
}

.option {
    padding: 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: calc(var(--border-radius) - 0.125rem);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    word-wrap: break-word;
}

.option:hover {
    border-color: var(--accent-color);
    background-color: #f8fafc;
}

.option.selected {
    border-color: var(--primary-color);
    background-color: rgba(37, 99, 235, 0.08);
}

.option.correct {
    border-color: var(--correct-color);
    background-color: rgba(16, 185, 129, 0.08);
}

.option.incorrect {
    border-color: var(--incorrect-color);
    background-color: rgba(239, 68, 68, 0.08);
}

.option-text {
    margin-left: 0.75rem;
    flex: 1;
}

.feedback-container {
    padding: 0.875rem;
    border-radius: calc(var(--border-radius) - 0.125rem);
    margin-top: 1.25rem;
    display: none;
    word-wrap: break-word;
}

.feedback-container.correct {
    background-color: rgba(16, 185, 129, 0.08);
    border: 1px solid var(--correct-color);
    color: #065f46;
}

.feedback-container.incorrect {
    background-color: rgba(239, 68, 68, 0.08);
    border: 1px solid var(--incorrect-color);
    color: #b91c1c;
}

.explanation {
    margin-top: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-color);
    line-height: 1.5;
}

.results-container {
    text-align: center;
    padding: 1.5rem;
    background-color: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    display: none;
    width: 100%;
}

.results-header {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
    font-weight: 700;
}

.score-container {
    margin: 1.25rem 0;
}

.score-circle {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    background: conic-gradient(var(--primary-color) 0%, var(--accent-color) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    position: relative;
    box-shadow: var(--shadow);
}

.score-circle::before {
    content: "";
    position: absolute;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background-color: white;
}

.score-value {
    position: relative;
    font-size: 1.75rem;
    font-weight: bold;
    color: var(--primary-color);
}

.summary-list {
    list-style: none;
    padding: 0;
    text-align: left;
    max-width: 100%;
    margin: 1.25rem auto;
}

.summary-item {
    padding: 0.75rem;
    border-radius: calc(var(--border-radius) - 0.125rem);
    margin-bottom: 0.625rem;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.summary-item.correct {
    background-color: rgba(16, 185, 129, 0.08);
}

.summary-item.incorrect {
    background-color: rgba(239, 68, 68, 0.08);
}

.summary-item.unanswered {
    background-color: var(--unanswered-color);
}

.summary-question {
    font-weight: 500;
    flex: 1;
    min-width: 60%;
    word-wrap: break-word;
}

.summary-answer {
    font-weight: 600;
    white-space: nowrap;
}

.summary-answer.correct {
    color: var(--correct-color);
}

.summary-answer.incorrect {
    color: var(--incorrect-color);
}

.hidden {
    display: none;
}

.timer {
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    color: var(--light-text);
    white-space: nowrap;
}

.submit-exam-btn {
    background-color: var(--accent-color);
    margin-top: 1rem;
    width: 100%;
}

.submit-exam-btn1:hover {
    background-color: var(--tertiary-color);
}

.submit-exam-btn1 {
    background-color: var(--accent-color);
    margin-top: 1rem;
    width: 20%;
}

.submit-exam-btn:hover {
    background-color: var(--secondary-color);
}

.warning-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.warning-modal.active {
    opacity: 1;
    visibility: visible;
}

.warning-content {
    background-color: white;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    max-width: 90%;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-md);
}

.warning-title {
    font-size: 1.25rem;
    color: var(--incorrect-color);
    margin-bottom: 1rem;
    font-weight: 600;
}

.warning-text {
    margin-bottom: 1.25rem;
}

.warning-buttons {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn-cancel {
    background-color: var(--light-text);
}

.question-detail {
    margin-top: 1rem;
    padding: 1rem;
    background-color: #f9fafb;
    border-radius: calc(var(--border-radius) - 0.125rem);
}

.question-detail .question-text {
    font-size: 1rem;
    margin-bottom: 0.75rem;
}

.question-detail .options-list {
    list-style-type: none;
    padding: 0;
}

.question-detail .option-item {
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    border-radius: calc(var(--border-radius) - 0.25rem);
}

.question-detail .option-item.correct {
    background-color: rgba(16, 185, 129, 0.1);
    border-left: 3px solid var(--correct-color);
}

.question-detail .option-item.selected-incorrect {
    background-color: rgba(239, 68, 68, 0.1);
    border-left: 3px solid var(--incorrect-color);
}

.question-detail .explanation {
    margin-top: 0.875rem;
    padding: 0.75rem;
    background-color: #f3f4f6;
    border-radius: calc(var(--border-radius) - 0.25rem);
    font-size: 0.875rem;
}

.marks-display {
    font-size: 1.125rem;
    margin-top: 0.5rem;
    font-weight: bold;
}

/* View mode switch */
.view-mode-container {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.875rem;
    gap: 0.5rem;
}

.switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #d1d5db;
    transition: .3s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary-color);
}

input:focus + .slider {
    box-shadow: 0 0 1px var(--primary-color);
}

input:checked + .slider:before {
    transform: translateX(22px);
}

.mode-label {
    font-size: 0.875rem;
    color: var(--text-color);
    font-weight: 500;
}

/* All questions view */
.all-questions-container {
    display: none;
}

.all-questions-container.active {
    display: block;
}

.question-block {
    background-color: white;
    border-radius: var(--border-radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
    transition: var(--transition);
    width: 100%;
}

.question-block:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.question-block .question-text {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    word-wrap: break-word;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .container {
        padding: 0.75rem;
        min-height: calc(var(--vh, 1vh) * 100);
        max-width: 90%;
    }
    
    header {
        padding: 1rem;
        margin-bottom: 0.75rem;
        border-radius: calc(var(--border-radius) - 0.125rem);
    }
    
    .controls {
        position: sticky;
        top: 0;
        background-color: rgba(241, 245, 249, 0.95);
        padding: 0.5rem 0;
        z-index: 10;
        margin-bottom: 0.75rem;
        backdrop-filter: blur(5px);
    }
    
    .question-text {
        font-size: 1rem;
        line-height: 1.4;
    }
    
    .option {
        padding: 0.625rem;
    }
    
    .option-text {
        font-size: 0.9375rem;
    }
    
    .btn {
        font-size: 0.8125rem;
        padding: 0.625rem;
    }
    
    .quiz-card, .question-block {
        padding: 1rem;
        border-radius: calc(var(--border-radius) - 0.125rem);
        margin-bottom: 0.75rem;
    }
    
    .score-circle {
        width: 90px;
        height: 90px;
    }
    
    .score-circle::before {
        width: 72px;
        height: 72px;
    }
    
    .score-value {
        font-size: 1.5rem;
    }
    
    .results-header {
        font-size: 1.25rem;
    }
    
    .summary-item {
        padding: 0.625rem;
    }
    
    .feedback-container {
        padding: 0.75rem;
    }
}

/* Enhanced Mobile App-like Experience */
@media (max-width: 480px) {
    body {
        background-color: #ffffff;
    }
    
    .container {
        padding: 0;
        max-width: 90%;
    }
    
    header {
        border-radius: 0;
        margin: 0 0 0.75rem 0;
        padding: 1.25rem 1rem;
        position: sticky;
        top: 0;
        z-index: 20;
    }
    
    .controls {
        padding: 0.5rem 0.75rem;
        margin: 0 0 0.75rem 0;
        border-bottom: 1px solid #e5e7eb;
    }
    
    .quiz-card, .question-block, .results-container {
        border-radius: 0;
        box-shadow: none;
        border-bottom: 1px solid #e5e7eb;
        margin-bottom: 0.5rem;
        padding: 1rem 0.75rem;
    }
    
    .progress-container {
        margin: 0;
        border-radius: 0;
    }
    
    .btn {
        border-radius: 6px;
        padding: 0.625rem 0.75rem;
    }
    
    .option {
        border-radius: 6px;
    }
    
    .warning-content {
        border-radius: 12px;
        padding: 1.25rem 1rem;
    }
    
    /* Bottom Navigation Bar */
    .mobile-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        background-color: white;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
        z-index: 100;
        justify-content: space-around;
        padding: 0.75rem 0;
        border-top: 1px solid #e5e7eb;
    }
    
    .mobile-nav-btn {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        color: var(--light-text);
        font-size: 0.75rem;
        gap: 0.25rem;
        padding: 0.25rem 0;
        width: 25%;
        transition: color 0.2s ease;
    }
    
    .mobile-nav-btn.active {
        color: var(--primary-color);
    }
    
    .mobile-nav-icon {
        font-size: 1.25rem;
    }
    
    /* Add bottom padding to account for navigation */
    .container {
        padding-bottom: 4rem;
    }
}

/* Very Small Devices */
@media (max-width: 360px) {
    header h1 {
        font-size: 1.125rem;
    }
    
    header p {
        font-size: 0.8125rem;
    }
    
    .question-text {
        font-size: 0.9375rem;
    }
    
    .option {
        padding: 0.5rem;
    }
    
    .option-text {
        font-size: 0.875rem;
    }
    
    .btn {
        padding: 0.5rem;
        font-size: 0.75rem;
    }
    
    .timer {
        font-size: 0.75rem;
    }
}