* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: #333;
}

/* Welcome Screen Styles - Priority */
.welcome-screen {
    display: flex !important;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #232f3e 0%, #37475a 100%) !important;
    color: white !important;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
}

.welcome-content {
    max-width: 600px;
    text-align: center;
    padding: 40px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    backdrop-filter: blur(10px);
    animation: fadeIn 0.5s ease-in;
}

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

.welcome-content h1 {
    font-size: 28px !important;
    margin-bottom: 10px;
    color: #ff9900 !important;
}

.welcome-branding {
    font-size: 14px;
    color: #ff9900 !important;
    margin-bottom: 30px;
}

.exam-details {
    text-align: left;
    margin: 30px 0;
    background: rgba(255, 255, 255, 0.1);
    padding: 25px;
    border-radius: 10px;
}

.exam-details h2 {
    color: #ff9900 !important;
    margin-bottom: 15px;
    text-align: center;
}

.exam-details ul {
    list-style: none;
    padding: 0;
}

.exam-details li {
    margin: 10px 0;
    padding-left: 20px;
    position: relative;
    color: white !important;
}

.exam-details li:before {
    content: "✓";
    position: absolute;
    left: 0;
    color: #ff9900 !important;
    font-weight: bold;
}

.exam-topics h3 {
    color: #ff9900 !important;
    margin: 20px 0 10px 0;
    text-align: center;
}

.topics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 15px;
}

.topics-grid span {
    background: rgba(255, 153, 0, 0.2);
    padding: 8px 12px;
    border-radius: 5px;
    font-size: 12px;
    text-align: center;
    color: white !important;
}

.exam-mode-selection {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 30px;
}

.start-exam-btn, .start-practice-btn, .resume-exam-btn {
    background: #ff9900 !important;
    color: #232f3e !important;
    border: none;
    padding: 15px 40px;
    font-size: 18px;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.start-practice-btn {
    background: #007dbc !important;
    color: white !important;
}

.resume-exam-btn {
    background: #28a745 !important;
    color: white !important;
}

.start-exam-btn:hover, .start-practice-btn:hover, .resume-exam-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.exam-container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.exam-header {
    background: #232f3e;
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.exam-info h1 {
    font-size: 18px;
    margin-bottom: 5px;
}

.branding {
    font-size: 12px;
    color: #ff9900;
    margin-bottom: 10px;
}

.website {
    font-weight: bold;
}

.creator {
    font-style: italic;
}

.exam-progress {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.answer-counter {
    font-size: 14px;
    color: #ff9900;
}

.progress-bar {
    width: 200px;
    height: 8px;
    background: #444;
    border-radius: 4px;
    overflow: hidden;
}

#progress-fill {
    height: 100%;
    background: #ff9900;
    width: 5%;
    transition: width 0.3s ease;
}

.exam-timer {
    font-size: 20px;
    font-weight: bold;
    color: #ff9900;
    transition: all 0.3s ease;
}

.exam-timer.warning {
    color: #ffa500;
    animation: pulse 1s infinite;
}

.exam-timer.warning-critical {
    color: #ff0000;
    animation: pulse 0.5s infinite;
}

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

/* Timer Alert */
.timer-alert {
    position: fixed;
    top: 80px;
    right: 20px;
    background: #ff9900;
    color: #232f3e;
    padding: 15px 25px;
    border-radius: 8px;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    z-index: 2000;
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s ease;
}

.timer-alert.show {
    opacity: 1;
    transform: translateX(0);
}

/* Content Layout */
.exam-content {
    flex: 1;
    padding: 20px;
}

.content-wrapper {
    display: flex;
    gap: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

/* Question Palette */
.question-palette {
    min-width: 200px;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    height: fit-content;
    position: sticky;
    top: 20px;
}

.question-palette h3 {
    margin-bottom: 15px;
    color: #232f3e;
    font-size: 16px;
}

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

.palette-item {
    width: 100%;
    aspect-ratio: 1;
    border: 2px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    font-size: 12px;
    transition: all 0.2s ease;
}

.palette-item:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.palette-item.current {
    background: #007dbc;
    color: white;
    border-color: #007dbc;
}

.palette-item.answered {
    background: #d4edda;
    border-color: #28a745;
}

.palette-item.unanswered {
    background: white;
    border-color: #ddd;
}

.palette-item.flagged {
    background: #fff3cd;
    border-color: #ffc107;
}

.palette-legend {
    font-size: 11px;
    line-height: 1.8;
}

.legend-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 2px;
    margin-right: 5px;
    border: 1px solid #999;
}

.legend-indicator.answered {
    background: #d4edda;
    border-color: #28a745;
}

.legend-indicator.unanswered {
    background: white;
}

.legend-indicator.flagged {
    background: #fff3cd;
    border-color: #ffc107;
}

.legend-indicator.current {
    background: #007dbc;
    border-color: #007dbc;
}

/* Question Area */
.question-area {
    flex: 1;
    max-width: 900px;
}

.question-container {
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.question-text {
    font-size: 16px;
    line-height: 1.6;
    margin-bottom: 25px;
    padding: 20px;
    background: #f8f9fa;
    border-left: 4px solid #007dbc;
    border-radius: 4px;
}

.scenario {
    background: #e8f4f8;
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 4px;
    font-style: italic;
}

.keyboard-hint {
    margin-top: 20px;
    padding: 10px;
    background: #fffbea;
    border-left: 3px solid #ff9900;
    font-size: 13px;
    color: #666;
    border-radius: 4px;
}

.options {
    margin: 20px 0;
}

.option {
    margin: 12px 0;
    padding: 15px;
    border: 2px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.option:hover {
    border-color: #007dbc;
    background: #f0f8ff;
    transform: translateX(5px);
}

.option.selected {
    border-color: #007dbc;
    background: #e6f3ff;
}

.option.correct {
    border-color: #28a745;
    background: #d4edda;
    animation: correctAnswer 0.5s ease;
}

.option.incorrect {
    border-color: #dc3545;
    background: #f8d7da;
    animation: incorrectAnswer 0.5s ease;
}

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

@keyframes incorrectAnswer {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.pulse-animation {
    animation: pulseSelect 0.3s ease;
}

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

.option input[type="radio"] {
    margin-right: 10px;
}

.option label {
    cursor: pointer;
    display: inline;
}

/* Explanation Styles */
.explanation-container {
    margin-top: 30px;
    animation: slideIn 0.3s ease;
}

.explanation {
    padding: 20px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 4px solid #28a745;
}

.explanation.incorrect-answer {
    border-left-color: #dc3545;
}

.explanation h3 {
    color: #28a745;
    margin-bottom: 15px;
}

.explanation.incorrect-answer h3 {
    color: #dc3545;
}

.explanation-text {
    line-height: 1.6;
    margin-bottom: 15px;
}

.incorrect-explanation {
    background: #fff5f5;
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 15px;
}

.correct-explanation {
    background: #f0fff4;
    padding: 15px;
    border-radius: 4px;
}

.doc-links {
    margin-top: 20px;
    cursor: pointer;
}

.doc-links summary {
    color: #007dbc;
    font-weight: bold;
    padding: 10px;
    background: #e8f4f8;
    border-radius: 4px;
    user-select: none;
}

.doc-links summary:hover {
    background: #d0e8f0;
}

.links-list {
    margin-top: 10px;
    padding-left: 20px;
}

.doc-links a {
    color: #007dbc;
    text-decoration: none;
    display: block;
    margin: 8px 0;
    padding: 5px;
    transition: all 0.2s ease;
}

.doc-links a:hover {
    text-decoration: underline;
    background: #f0f8ff;
    padding-left: 10px;
}

/* Footer */
.exam-footer {
    padding: 20px 30px;
    background: #f8f9fa;
    border-top: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.footer-left, .footer-right {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

button {
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.2s ease;
}

button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

button:active:not(:disabled) {
    transform: translateY(0);
}

button:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

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

#prev-btn:hover:not(:disabled) {
    background: #5a6268;
}

.flag-btn {
    background: #ffc107;
    color: #333;
}

.flag-btn:hover {
    background: #e0a800;
}

.flag-btn.flagged-active {
    background: #ff6b6b;
    color: white;
}

#next-btn, #submit-btn {
    background: #007dbc;
    color: white;
}

#next-btn:hover, #submit-btn:hover {
    background: #005a8b;
}

#finish-btn {
    background: #28a745;
    color: white;
}

#finish-btn:hover {
    background: #218838;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 10px;
    max-width: 500px;
    width: 90%;
    animation: slideIn 0.3s ease;
}

.modal-content h2 {
    color: #232f3e;
    margin-bottom: 20px;
}

.finish-stats p {
    margin: 10px 0;
    font-size: 16px;
}

.warning-text {
    color: #dc3545;
}

.info-text {
    color: #007dbc;
}

.confirm-text {
    margin-top: 20px;
    font-weight: bold;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 25px;
    justify-content: flex-end;
}

.primary-btn {
    background: #28a745;
    color: white;
}

.primary-btn:hover {
    background: #218838;
}

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

.secondary-btn:hover {
    background: #5a6268;
}

/* Final Score */
.final-score {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.5s ease;
}

.score-card {
    background: white;
    padding: 40px;
    border-radius: 10px;
    text-align: center;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: slideIn 0.5s ease;
}

.score-card h2 {
    color: #232f3e;
    margin-bottom: 20px;
}

.score-number {
    font-size: 48px;
    font-weight: bold;
    margin: 20px 0;
}

.pass {
    color: #28a745;
}

.fail {
    color: #dc3545;
}

.result-message {
    font-size: 20px;
    font-weight: bold;
    margin: 15px 0;
}

.score-details {
    margin: 20px 0;
    text-align: left;
}

.score-details h3 {
    color: #232f3e;
    margin: 20px 0 10px 0;
    text-align: center;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin: 20px 0;
}

.stat-item {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.stat-item strong {
    color: #666;
    font-size: 13px;
}

.stat-item span {
    font-size: 18px;
    font-weight: bold;
}

.topic-breakdown {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 6px;
}

.topic-stat {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #ddd;
}

.topic-stat:last-child {
    border-bottom: none;
}

.action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 30px;
    justify-content: center;
    flex-wrap: wrap;
}

.restart-btn {
    background: #007dbc;
    color: white;
}

.restart-btn:hover {
    background: #005a8b;
}

.review-btn {
    background: #28a745;
    color: white;
}

.review-btn:hover {
    background: #218838;
}

/* Confetti Animation */
.confetti {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
}

.confetti-piece {
    position: absolute;
    width: 10px;
    height: 10px;
    top: -10px;
    opacity: 0;
    animation: confettiFall 3s linear infinite;
}

@keyframes confettiFall {
    0% {
        top: -10px;
        opacity: 1;
    }
    100% {
        top: 100%;
        opacity: 0;
        transform: translateX(100px) rotate(720deg);
    }
}

/* Review Mode */
.review-mode {
    max-width: 900px;
    margin: 0 auto;
}

.review-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 2px solid #ddd;
}

.review-header h2 {
    color: #232f3e;
}

.return-btn {
    background: #007dbc;
    color: white;
}

.return-btn:hover {
    background: #005a8b;
}

.review-questions {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.review-question {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 8px;
    border-left: 5px solid #ddd;
}

.review-question.correct-review {
    border-left-color: #28a745;
}

.review-question.incorrect-review {
    border-left-color: #dc3545;
}

.review-question h3 {
    margin-bottom: 15px;
    color: #232f3e;
}

.review-options {
    margin: 15px 0;
}

.review-option {
    padding: 12px;
    margin: 8px 0;
    border-radius: 4px;
    background: white;
}

.review-option.correct {
    background: #d4edda;
    font-weight: bold;
}

.review-option.incorrect {
    background: #f8d7da;
}

.review-explanation {
    margin-top: 15px;
    padding: 15px;
    background: white;
    border-radius: 4px;
}

/* Mobile Responsiveness */
@media (max-width: 968px) {
    .content-wrapper {
        flex-direction: column;
    }

    .question-palette {
        position: static;
        width: 100%;
        min-width: unset;
    }

    .palette-grid {
        grid-template-columns: repeat(10, 1fr);
    }

    .exam-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .exam-progress {
        width: 100%;
    }

    .progress-bar {
        flex: 1;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .topics-grid {
        grid-template-columns: 1fr;
    }

    .footer-left, .footer-right {
        width: 100%;
        justify-content: center;
    }

    .exam-footer {
        flex-direction: column;
    }

    button {
        width: 100%;
    }

    .modal-buttons button {
        flex: 1;
    }

    .action-buttons {
        flex-direction: column;
    }

    .action-buttons button {
        width: 100%;
    }
}

@media (max-width: 600px) {
    .welcome-content {
        padding: 20px;
    }

    .welcome-content h1 {
        font-size: 20px !important;
    }

    .exam-info h1 {
        font-size: 14px;
    }

    .palette-grid {
        grid-template-columns: repeat(5, 1fr);
    }

    .score-card {
        padding: 20px;
    }

    .score-number {
        font-size: 36px;
    }

    .timer-alert {
        right: 10px;
        left: 10px;
        top: 60px;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .option {
        border-width: 3px;
    }

    .palette-item {
        border-width: 3px;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus Indicators for Accessibility */
button:focus-visible,
.option:focus-visible,
.palette-item:focus-visible {
    outline: 3px solid #007dbc;
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .exam-header,
    .exam-footer,
    .question-palette,
    .timer-alert {
        display: none !important;
    }

    .exam-container {
        background: white;
    }

    .review-mode {
        max-width: 100%;
    }
}
