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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 900px;
    margin: 0 auto;
}

.screen {
    display: none;
}

.screen.active {
    display: block;
}

h1 {
    text-align: center;
    color: white;
    margin-bottom: 30px;
    font-size: 2.5em;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

h2 {
    margin-bottom: 20px;
    color: #333;
}

.card {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.subjects-list {
    margin-bottom: 20px;
}

.subject-item {
    padding: 15px;
    margin-bottom: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f9f9f9;
}

.subject-item:hover {
    border-color: #667eea;
    background: #f0f0ff;
    transform: translateX(5px);
}

.subject-item.selected {
    border-color: #667eea;
    background: #667eea;
    color: white;
}

.subject-item h3 {
    margin-bottom: 5px;
}

.subject-item p {
    font-size: 0.9em;
    opacity: 0.8;
}

.form-group {
    margin: 20px 0;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.form-group input.invalid {
    border-color: #dc3545;
    background-color: #fff5f5;
}

.form-group input.invalid:focus {
    border-color: #dc3545;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: normal;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    margin: 0;
    cursor: pointer;
}

.checkbox-label span {
    user-select: none;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    margin-top: 10px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

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

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

.btn-link {
    background: none;
    color: #667eea;
    text-decoration: underline;
    padding: 5px 10px;
    width: auto;
    margin: 0;
}

.btn-link:hover {
    color: #5568d3;
}

.test-header {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

.progress-bar {
    width: 100%;
    height: 10px;
    background: #e0e0e0;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 15px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transition: width 0.3s ease;
    width: 0%;
}

.test-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}

.score {
    color: #667eea;
}

.options-container {
    margin: 20px 0;
}

.option {
    padding: 15px;
    margin-bottom: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f9f9f9;
    display: flex;
    align-items: center;
}

.option:hover {
    border-color: #667eea;
    background: #f0f0ff;
}

.option.selected {
    border-color: #667eea;
    background: #667eea;
    color: white;
}

.option.correct {
    border-color: #28a745;
    background: #d4edda;
    color: #155724;
}

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

.option-letter {
    font-weight: bold;
    margin-right: 15px;
    font-size: 1.2em;
    min-width: 30px;
}

.answer-feedback {
    margin: 20px 0;
    padding: 15px;
    border-radius: 8px;
    display: none;
}

.answer-feedback.correct {
    background: #d4edda;
    color: #155724;
    border: 2px solid #28a745;
}

.answer-feedback.incorrect {
    background: #f8d7da;
    color: #721c24;
    border: 2px solid #dc3545;
}

.button-group {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.button-group .btn {
    margin: 0;
    flex: 1;
}

.question-actions {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.difficulty-rating {
    display: flex;
    align-items: center;
    gap: 10px;
}

.difficulty-stars {
    display: flex;
    gap: 5px;
}

.star {
    font-size: 1.5em;
    color: #ddd;
    cursor: pointer;
    transition: color 0.2s;
}

.star:hover,
.star.active {
    color: #ffc107;
}

.results-summary {
    display: flex;
    justify-content: space-around;
    margin: 30px 0;
    padding: 30px 0;
    border-top: 2px solid #e0e0e0;
    border-bottom: 2px solid #e0e0e0;
}

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

.stat-value {
    font-size: 3em;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 10px;
}

.stat-label {
    font-size: 1.1em;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.results-details {
    margin: 20px 0;
}

.result-item {
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 8px;
    border-left: 4px solid;
}

.result-item.correct {
    background: #d4edda;
    border-color: #28a745;
}

.result-item.incorrect {
    background: #f8d7da;
    border-color: #dc3545;
}

.loading {
    text-align: center;
    padding: 20px;
    color: #666;
}

.error {
    background: #f8d7da;
    color: #721c24;
    padding: 15px;
    border-radius: 8px;
    margin: 20px 0;
    border: 2px solid #dc3545;
}

/* Auth Forms */
.auth-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
}

.tab-btn {
    padding: 10px 20px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    color: #666;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
}

.tab-btn:hover {
    color: #667eea;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.auth-form small {
    display: block;
    margin-top: 5px;
    font-size: 0.85em;
    color: #666;
}

.header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.header-bar h1 {
    margin: 0;
    font-size: 2em;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
    color: white;
}

.user-info span {
    font-weight: 600;
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    h1 {
        font-size: 2em;
    }

    .card {
        padding: 20px;
    }

    .test-info {
        flex-direction: column;
        gap: 10px;
    }

    .results-summary {
        flex-direction: column;
        gap: 20px;
    }

    .question-actions {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-bar {
        flex-direction: column;
        gap: 15px;
    }

    .header-bar h1 {
        font-size: 1.5em;
    }
}

.tab-btn {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 10px 20px;
    cursor: pointer;
    font-size: 16px;
    color: #666;
    transition: all 0.3s;
}

.tab-btn:hover {
    color: #333;
    background: #f5f5f5;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
    font-weight: 600;
}

.tab-content {
    margin-top: 20px;
}



/* Image Thumbnails */
.question-images {
    margin: 15px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.image-thumbnail {
    display: inline-block;
    margin: 5px;
    cursor: pointer;
    border: 2px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    max-width: 150px;
    transition: all 0.3s ease;
    background: #f5f5f5;
}

.image-thumbnail:hover {
    border-color: #667eea;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.image-thumbnail img {
    width: 100%;
    height: auto;
    display: block;
    pointer-events: none;
}

/* Image Viewer Modal */
#image-viewer-modal {
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
}

#image-viewer-modal .modal-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
}

#viewer-image {
    max-width: 100%;
    max-height: 95vh;
    object-fit: contain;
    cursor: move;
    user-select: none;
    transition: transform 0.1s ease-out;
}

#viewer-image[style*="scale"] {
    cursor: grab;
}

#viewer-image[style*="scale"]:active {
    cursor: grabbing;
}

#close-image-viewer {
    position: absolute;
    top: 15px;
    right: 15px;
    color: white;
    font-size: 35px;
    font-weight: bold;
    cursor: pointer;
    z-index: 1001;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background 0.3s ease;
}

#close-image-viewer:hover {
    background: rgba(0, 0, 0, 0.8);
}
