:root {
    /* Light Mode Palette */
    --bg-color: #f8fafc;
    /* Slate 50 */
    --card-bg: #ffffff;
    /* White */
    --text-primary: #0f172a;
    /* Slate 900 */
    --text-secondary: #475569;
    /* Slate 600 */

    /* Orange Accent */
    --accent-color: #f97316;
    /* Orange 500 */
    --accent-hover: #ea580c;
    /* Orange 600 */
    --accent-light: #ffedd5;
    /* Orange 100 */

    --error-color: #ef4444;
    --success-color: #22c55e;
    --border-color: #e2e8f0;
    /* Slate 200 */
    --font-family: 'Inter', sans-serif;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

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

body {
    background-color: var(--bg-color);
    /* Orange Gradient Background */
    background: linear-gradient(135deg, #fffcf9 0%, #fff7ed 50%, #ffffff 100%);
    background-attachment: fixed;
    color: var(--text-primary);
    font-family: var(--font-family);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.app-container {
    width: 100%;
    max-width: 800px;
    padding: 20px;
}

.screen {
    display: none;
    animation: fadeIn 0.4s ease-in-out;
}

.screen.active {
    display: block;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hidden {
    display: none !important;
}

.card {
    background-color: var(--card-bg);
    padding: 2.5rem;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    text-align: center;
}

h1,
h2,
h3 {
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

h1 {
    font-size: 2.25rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    background: linear-gradient(to right, #f97316, #ea580c);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

h2 {
    font-size: 1.75rem;
    font-weight: 700;
}

p {
    color: var(--text-secondary);
    line-height: 1.6;
}

.form-group {
    margin: 1.5rem 0;
    text-align: left;
}

.form-group.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.field {
    display: flex;
    flex-direction: column;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
}

input,
textarea {
    width: 100%;
    padding: 12px 16px;
    border-radius: 10px;
    background-color: #f8fafc;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    transition: all 0.2s;
    font-family: var(--font-family);
}

input:focus,
textarea:focus {
    border-color: var(--accent-color);
    background-color: #fff;
    box-shadow: 0 0 0 4px var(--accent-light);
}

textarea {
    resize: vertical;
}

.btn {
    padding: 12px 24px;
    border-radius: 10px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
    width: 100%;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
}

.btn.primary {
    background: linear-gradient(to right, var(--accent-color), var(--accent-hover));
    color: white;
    box-shadow: 0 4px 6px -1px rgba(249, 115, 22, 0.3);
}

.btn.primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 8px -1px rgba(249, 115, 22, 0.4);
}

.btn.primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn.primary:disabled {
    background: var(--border-color);
    color: var(--text-secondary);
    cursor: not-allowed;
    box-shadow: none;
}

.btn.secondary {
    background-color: white;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.btn.secondary:hover:not(:disabled) {
    background-color: #f8fafc;
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.error-msg {
    color: var(--error-color);
    font-size: 0.9rem;
    margin-top: 1rem;
    font-weight: 500;
}

.instructions-list {
    text-align: left;
    background: var(--accent-light);
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    border: 1px solid #fed7aa;
}

.instructions-list h3 {
    color: #9a3412;
    /* Dark Orange */
    font-size: 1.1rem;
}

.instructions-list ul {
    margin-left: 1.5rem;
    margin-top: 0.5rem;
    color: #7c2d12;
}

.policy-acceptance {
    margin-bottom: 2rem;
    text-align: left;
}

.checkbox-container {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    font-size: 0.95rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.checkbox-container input {
    margin-top: 0.25rem;
    width: 1.1rem;
    height: 1.1rem;
    accent-color: var(--accent-color);
}

#webcam-preview-container {
    margin: 1.5rem auto;
    width: 380px;
    height: 320px;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    border: 2px solid var(--border-color);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 10px;
}

#webcam-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

#webcam-status {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px;
    font-size: 0.85rem;
}

#btn-request-camera {
    position: absolute;
    z-index: 10;
    width: auto;
}

/* Test Screen */
.test-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1rem 1.5rem;
    background: white;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.timer-container {
    font-family: monospace;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--accent-light);
    padding: 4px 12px;
    border-radius: 8px;
}

.question-card {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 2.5rem;
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-md);
}

.badge {
    background: var(--accent-light);
    color: #c2410c;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 1rem;
    display: inline-block;
    letter-spacing: 0.05em;
}

.options-grid {
    display: grid;
    gap: 1rem;
    margin-top: 2rem;
}

.option-item {
    background: white;
    border: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.option-item:hover {
    border-color: var(--accent-color);
    background: #fffaf5;
}

.option-item.selected {
    border-color: var(--accent-color);
    background: #fff7ed;
    box-shadow: 0 0 0 1px var(--accent-color);
}

.option-radio {
    margin-top: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.navigation-buttons {
    display: flex;
    justify-content: flex-end;
    /* Align Next to right */
    gap: 1rem;
}

.navigation-buttons button {
    width: auto;
    min-width: 140px;
}

/* Results Screen */
.score-circle {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    border: 8px solid var(--accent-light);
    border-top-color: var(--accent-color);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin: 2rem auto;
    background: white;
    box-shadow: var(--shadow-md);
}

#final-score {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-primary);
}

#final-percent {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.level-badge {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 2rem;
    padding: 0.5rem 2rem;
    background: var(--accent-light);
    color: #9a3412;
    border-radius: 12px;
    display: inline-block;
}

/* Hide Score Class */
.results-hidden .score-circle,
.results-hidden #final-level {
    display: none !important;
}

/* Thank You Message Styling */
#thank-you-message {
    margin-top: 1rem;
    animation: slideUp 0.5s ease-out;
}

.thank-you-content {
    background: white;
    padding: 2.5rem;
    border-radius: 20px;
}

.thank-you-content h3 {
    font-size: 2.2rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.success-subtitle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 2rem;
    color: #22c55e;
}

.success-subtitle h4 {
    font-size: 1.5rem;
    margin: 0;
    font-weight: 600;
}

.thank-you-content .check-icon {
    font-size: 1.5rem;
}

.thank-you-body {
    color: var(--text-secondary);
    line-height: 1.6;
    text-align: left;
    max-width: 550px;
    margin: 0 auto;
}

.thank-you-body p {
    margin-bottom: 1.2rem;
    font-size: 1.05rem;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Custom Alert Overlay */
#custom-alert-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.custom-alert-card {
    background: white;
    padding: 2rem;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    max-width: 400px;
    width: 90%;
    text-align: center;
    border: 1px solid var(--border-color);
}

.alert-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.alert-message {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.custom-alert-card .btn {
    width: auto;
    min-width: 120px;
}

@media (max-width: 600px) {
    .card {
        padding: 1.5rem;
    }

    .test-header {
        flex-direction: column;
        gap: 1rem;
    }

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

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

/* Video Recorder Styles */
#video-recorder-container {
    margin-top: 2rem;
    text-align: center;
    background: #f8fafc;
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid var(--border-color);
}

.video-wrapper {
    width: 100%;
    max-width: 480px;
    height: 360px;
    background: #000;
    margin: 0 auto 1rem;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    border: 2px solid var(--border-color);
    box-shadow: var(--shadow-md);
}

#video-wrapper video,
#recorder-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.recording-overlay {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(0, 0, 0, 0.75);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: white;
    font-weight: bold;
    backdrop-filter: blur(4px);
}

.pulse-red {
    width: 12px;
    height: 12px;
    background-color: #ef4444;
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

.recorder-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.recorder-status {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 500;
}

#video-fallback-container {
    margin-top: 1.5rem;
    text-align: left;
}