body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    margin: 0;
    padding: 20px;
    background-color: #f4f4f4;
    color: #333;
    overflow-x: hidden;
}

/* Modal backdrop for camera preview */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1400;
    backdrop-filter: blur(2px);
}

.hidden {
    display: none !important;
}

#control-panel {
    max-width: 700px;
    margin: auto;
    background: white;
    padding: 32px 48px;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    border: 1px solid #e9ecef;
}

/* 调试模式入口样式 */
.debug-entry {
    position: absolute;
    top: 10px;
    right: 15px;
}

.debug-entry-btn {
    background: none;
    border: none;
    font-size: 18px;
    padding: 8px;
    cursor: pointer;
    border-radius: 4px;
    opacity: 0.6;
    transition: all 0.3s ease;
    color: #6c757d;
}

.debug-entry-btn:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.05);
    transform: scale(1.1);
}

.debug-entry-btn:active {
    transform: scale(0.95);
}

/* 密码输入模态框样式 */
.password-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.password-modal-content {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    text-align: center;
    min-width: 300px;
}

.password-modal h3 {
    margin: 0 0 20px 0;
    color: #333;
    border: none;
    padding: 0;
}

.password-modal input[type="password"] {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    margin-bottom: 20px;
    box-sizing: border-box;
}

.password-modal input[type="password"]:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 3px rgba(0, 123, 186, 0.25);
}

.password-modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.password-modal button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.password-modal .confirm-btn {
    background: #28a745;
    color: white;
}

.password-modal .confirm-btn:hover {
    background: #218838;
}

.password-modal .cancel-btn {
    background: #6c757d;
    color: white;
}

.password-modal .cancel-btn:hover {
    background: #5a6268;
}

.password-error {
    color: #dc3545;
    margin-top: 10px;
    font-size: 14px;
}

/* 参与者信息区域样式 */
.participant-section {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 2px solid #e9ecef;
}

.participant-section .form-group label {
    font-size: 1.1em;
    font-weight: 600;
    color: #495057;
}

.participant-section input[type="text"] {
    font-size: 16px;
    padding: 12px;
    border: 2px solid #ced4da;
    border-radius: 6px;
    background: white;
}

.participant-section input[type="text"]:focus {
    border-color: #80bdff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

.input-help {
    display: block;
    margin-top: 5px;
    color: #6c757d;
    font-size: 0.9em;
    font-style: italic;
}

/* 研究人员控制区域样式 */
.researcher-section {
    border: 2px dashed #28a745;
    border-radius: 8px;
    padding: 20px;
    background: #f8fff9;
    margin-bottom: 20px;
}

.unlock-success {
    text-align: center;
    margin-bottom: 20px;
}

.unlock-success p {
    color: #28a745;
    font-weight: 600;
    margin: 0;
    padding: 10px;
    background: rgba(40, 167, 69, 0.1);
    border-radius: 5px;
    border: 1px solid rgba(40, 167, 69, 0.3);
}

/* 开始按钮区域样式 */
.start-section {
    text-align: center;
    padding: 20px 0;
}

/* 动画效果 */
@keyframes shake {
    0% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
    100% { transform: translateX(0); }
}

h1, h2 {
    color: #333;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 12px;
    margin-bottom: 20px;
}

h1 {
    font-size: 1.8em;
    font-weight: 600;
    text-align: center;
    color: #2c3e50;
}

h2 {
    font-size: 1.4em;
    font-weight: 500;
    color: #34495e;
    margin-top: 32px;
}

.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    font-size: 0.95em;
    color: #495057;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    box-sizing: border-box;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0,123,255,0.1);
}

.form-group input:disabled {
    background-color: #f8f9fa;
    color: #6c757d;
    border-color: #e9ecef;
}

button {
    padding: 12px 20px;
    border: none;
    background-color: #007bff;
    color: white;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.2s;
}

button:hover {
    background-color: #0056b3;
}

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

/* 下载按钮容器样式 */
.download-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    align-items: center;
    margin: 20px 0;
}

.download-buttons button {
    flex: 1;
    min-width: 200px;
    max-width: 280px;
    text-align: center;
    font-size: 0.95em;
    padding: 14px 20px;
    margin: 4px;
}



#view-eye-tracking {
    background-color: #9b59b6;
}

#view-eye-tracking:hover {
    background-color: #8e44ad;
}


#experiment-view {
    position: relative;
    /* Reset padding for full-screen view */
    padding: 0;
    width: 100vw;
    height: 100vh;
}

#reading-task {
    max-width: 800px;
    margin: 50px auto;
    padding: 0 20px;
    line-height: 1.8;
    font-size: 18px;
    transition: filter 0.3s ease-in-out;
}

#reading-task.blurred {
    filter: blur(5px);
    pointer-events: none;
}

#fixation-cross {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 50px;
    font-weight: bold;
    color: red;
}

#probe-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    z-index: 100;
}

.probe-element {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    display: none; /* Hide all probe elements by default */
}

.probe-element.visible {
    display: block; /* Show the active element */
}


#pre-cue {
    justify-content: center;
    align-items: center;
    font-size: 48px;
    font-weight: bold;
}

#pre-cue.visible {
    display: flex;
}

#stimulus-container, #response-container {
    position: relative;
    width: 100vw;
    height: 100vh;
}

.stimulus-position, .placeholder {
    position: absolute;
    width: 120px;
    height: 120px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.placeholder {
    border: 4px dashed #ccc;
    border-radius: 50%;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s;
}

.placeholder:hover {
    background-color: rgba(0, 123, 255, 0.1);
    border-color: #007bff;
}

.placeholder.correct {
    border-color: #28a745;
    background-color: rgba(40, 167, 69, 0.1);
}

.placeholder.incorrect {
    border-color: #dc3545;
    background-color: rgba(220, 53, 69, 0.1);
}

/* Positioning for corners */
#pos-0, #placeholder-0 { top: 15vh; left: 15vw; }
#pos-1, #placeholder-1 { top: 15vh; right: 15vw; }
#pos-2, #placeholder-2 { bottom: 15vh; left: 15vw; }
#pos-3, #placeholder-3 { bottom: 15vh; right: 15vw; }


#end-screen, #instruction-screen {
    max-width: 800px;
    margin: 20px auto;
    text-align: left;
    padding: 32px 48px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    border: 1px solid #e9ecef;
    line-height: 1.7;
}

#end-screen {
    text-align: center;
    padding: 48px;
}

#end-screen button {
    margin: 8px 12px;
    min-width: 160px;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 500;
}

#instruction-screen .button-group {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 24px;
    justify-content: center;
}

#instruction-screen button {
    flex: 1;
    min-width: 140px;
    max-width: 200px;
    margin: 0;
    padding: 14px 20px;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.3s ease;
}

#instruction-screen button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,123,255,0.3);
}

#instruction-screen button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* 跳过校准按钮的特殊样式 */
#skip-calibration {
    background-color: #ffc107 !important;
    color: #212529 !important;
    border: 2px solid #ffb300;
    position: relative;
}

#skip-calibration:hover:not(:disabled) {
    background-color: #e0a800 !important;
    border-color: #d39e00;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255,193,7,0.3);
}

#skip-calibration::before {
    content: "⚠️ ";
    margin-right: 4px;
}

#instruction-screen h1 {
    text-align: center;
}

#instruction-screen ol, #instruction-screen ul {
    padding-left: 25px;
}

/* Stimulus shapes */
.shape {
    width: 100px;
    height: 100px;
}

.shape.circle {
    border-radius: 50%;
}

.shape.triangle {
    width: 0;
    height: 0;
    background-color: transparent !important; /* Override background color */
    border-left: 50px solid transparent;
    border-right: 50px solid transparent;
    /* The actual color is set on the border - default fallback to red */
    border-bottom: 100px solid #FF0000; 
}

.shape.diamond {
    width: 70px;
    height: 70px;
    transform: rotate(45deg);
} 

/* Button loading state */
button.loading {
    position: relative;
    color: transparent;
}

button.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    color: white;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 眼动追踪相关样式 */
#calibration-screen {
    max-width: 900px;
    margin: 20px auto;
    background: white;
    padding: 48px 40px;
    border-radius: 12px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.1);
    text-align: center;
}

.calibration-instruction {
    text-align: left;
    margin: 0 auto;
    max-width: 520px;
}
.calibration-instruction ul {
    list-style: none;
    padding: 0;
    margin: 8px 0 16px;
}
.calibration-instruction ul li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 6px 0;
}
.calibration-instruction ul li::before {
    content: counter(step);
    counter-increment: step;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #007bff;
    color: #fff;
    font-weight: 600;
}
.calibration-instruction ul {
    counter-reset: step;
}

.calibration-point {
    position: fixed;
    width: 20px;
    height: 20px;
    background-color: red;
    border-radius: 50%;
    z-index: 1000;
    transition: all 0.3s ease;
}

.calibration-point.active {
    background-color: #ff4444;
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.5);
    animation: pulse 1s infinite;
}

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

.eye-tracking-status {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 15px;
    border-radius: 5px;
    z-index: 1001;
    display: flex;
    align-items: center;
    gap: 10px;
}

#status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #ff4444;
}

#status-indicator.active {
    background-color: #44ff44;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.3; }
}

#eye-tracking-test {
    max-width: 1000px;
    margin: auto;
    background: white;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#test-targets {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin: 40px 0;
}

.test-target {
    padding: 40px;
    background: #f0f0f0;
    border: 2px solid #ddd;
    border-radius: 8px;
    text-align: center;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.test-target:hover {
    background: #e0e0e0;
    border-color: #007bff;
}

.test-target.active {
    background: #007bff;
    color: white;
    border-color: #0056b3;
}

#eye-tracking-data {
    margin-top: 40px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

#gaze-data {
    font-family: monospace;
    background: #fff;
    padding: 15px;
    border-radius: 4px;
    border: 1px solid #ddd;
    min-height: 100px;
    max-height: 200px;
    overflow-y: auto;
}

.gaze-point {
    position: absolute;
    width: 4px;
    height: 4px;
    background-color: rgba(255, 0, 0, 0.7);
    border-radius: 50%;
    pointer-events: none;
    z-index: 999;
}

/* 眼动追踪数据可视化 */
.eye-tracking-visualization {
    margin: 20px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.heatmap {
    position: relative;
    width: 100%;
    height: 400px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
}

/* 校准进度指示器 */
.calibration-progress {
    margin: 20px 0;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 4px;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background: #e9ecef;
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #007bff, #0056b3);
    transition: width 0.3s ease;
}

/* 眼动追踪数据表格 */
.eye-tracking-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
}

.eye-tracking-table th,
.eye-tracking-table td {
    border: 1px solid #ddd;
    padding: 8px 12px;
    text-align: left;
}

.eye-tracking-table th {
    background: #f8f9fa;
    font-weight: bold;
}

.eye-tracking-table tr:nth-child(even) {
    background: #f8f9fa;
} 

/* ====== EyeMeasure overlay styles (from eye-track demo) ====== */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 1000;
}
.overlay.hidden { display: none; }

.cal-dot {
    position: absolute;
    width: 22px; height: 22px;
    margin: -11px 0 0 -11px;
    border-radius: 50%;
    background: #3b82f6; /* accent */
    border: 2px solid #ffffff;
    box-shadow: 0 0 0 4px rgba(59,130,246,0.25);
    cursor: pointer;
    transition: transform 0.1s ease;
}
.cal-dot:hover { transform: scale(1.08); }
.cal-dot .cal-count {
    position: absolute;
    top: -14px;
    right: -14px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 10px;
    background: #111827;
    color: #fff;
    font-size: 11px;
    line-height: 18px;
    text-align: center;
    border: 1px solid rgba(255,255,255,0.35);
}

.test-dot {
    position: absolute;
    width: 18px; height: 18px;
    margin: -9px 0 0 -9px;
    border-radius: 50%;
    background: #22c55e; /* primary */
    border: 2px solid #02240f;
    box-shadow: 0 0 0 4px rgba(34,197,94,0.25);
}

.legend {
    position: fixed;
    left: 16px;
    bottom: 16px;
    background: rgba(21,23,28,0.9);
    border: 1px solid #262a33;
    color: #9aa0a6;
    padding: 10px 12px;
    border-radius: 8px;
    z-index: 1100;
    font-size: 13px;
}

/* Reading task improvements */
#reading-task {
    max-width: 900px;
    margin: 40px auto;
    padding: 0 32px;
    line-height: 1.9;
    font-size: 17px;
    transition: filter 0.3s ease-in-out;
}

#reading-task.blurred {
    filter: blur(5px);
    pointer-events: none;
}

/* Reading header styles */
.reading-header {
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 20px;
    margin-bottom: 30px;
}

.reading-header h2 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 16px;
    font-size: 1.6em;
}

.reading-progress {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: #666;
    background: #f8f9fa;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.reading-time {
    font-weight: 600;
    color: #007bff;
}

/* Reading content styles */
.reading-content {
    margin-bottom: 30px;
}

.material-section {
    margin-bottom: 25px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #007bff;
}

.material-section h4 {
    color: #495057;
    margin-bottom: 15px;
    font-size: 1.1em;
    font-weight: 600;
}

.material-section p {
    margin-bottom: 16px;
    line-height: 1.8;
    text-align: justify;
    text-indent: 2em;
}

.material-section p:last-child {
    margin-bottom: 0;
}

#reading-task h3 {
    color: #34495e;
    margin-top: 28px;
    margin-bottom: 16px;
    font-size: 1.2em;
}

#reading-task p {
    text-align: justify;
    margin-bottom: 20px;
    text-indent: 2em;
}

#reading-task hr {
    margin: 40px 0;
    border: none;
    border-top: 2px solid #e9ecef;
}

/* Reading navigation styles */
.reading-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 30px;
    padding: 20px 0;
    border-top: 2px solid #e9ecef;
    flex-wrap: wrap;
    gap: 16px;
}

.navigation-buttons {
    display: flex;
    gap: 16px;
}

.reading-navigation button {
    min-width: 120px;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.reading-navigation button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #6c757d;
}

.reading-navigation button:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,123,255,0.3);
}

#finish-reading {
    background-color: #28a745 !important;
    color: white;
}

#finish-reading:hover {
    background-color: #218838 !important;
    box-shadow: 0 4px 12px rgba(40,167,69,0.3) !important;
}

/* Status display styles */
.status-display {
    text-align: right;
    font-size: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.answer-status, .stroop-status {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.answer-status #answer-count,
.stroop-status #stroop-count {
    font-weight: 600;
    color: #007bff;
}

.answer-status #answer-hint,
.stroop-status #stroop-hint {
    color: #dc3545;
    font-size: 12px;
}

.answer-status #answer-hint.complete,
.stroop-status #stroop-hint.complete {
    color: #28a745;
}

.stroop-status {
    padding-top: 8px;
    border-top: 1px solid #e9ecef;
}

.stroop-status #stroop-count {
    color: #6c757d;
}

/* 完成阅读按钮禁用状态 */
.reading-navigation button:disabled {
    opacity: 0.4 !important;
    cursor: not-allowed !important;
    background-color: #6c757d !important;
    color: #fff !important;
}

.reading-navigation button:disabled:hover {
    transform: none !important;
    box-shadow: none !important;
    background-color: #6c757d !important;
}

/* Reading questions styles */
.reading-questions {
    background: #f8f9fa;
    padding: 24px;
    border-radius: 8px;
    margin-top: 24px;
    border: 1px solid #e9ecef;
}

.question {
    margin-bottom: 24px;
    padding: 20px;
    background: white;
    border-radius: 8px;
    border-left: 4px solid #007bff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.question > div:first-child {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 12px;
    font-size: 1.05em;
}

.question label {
    display: block;
    margin: 10px 0;
    padding: 12px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.question label:hover {
    background-color: #f8f9fa;
    border-color: #dee2e6;
}

.question input[type="radio"] {
    margin-right: 12px;
    transform: scale(1.1);
}

/* Stroop notification styles */
.stroop-notification {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.notification-content {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    text-align: center;
    max-width: 500px;
    margin: 20px;
}

.notification-content h3 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.5em;
}

.notification-content p {
    color: #495057;
    margin-bottom: 15px;
    line-height: 1.6;
}

.notification-content button {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
}

.notification-content button:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,123,255,0.3);
}

/* ===== 试次进度条（右上角） ===== */
.trial-progress {
    position: fixed;
    top: 70px; /* 避开右上角的眼动状态指示器 */
    right: 20px;
    z-index: 1002; /* 高于状态指示器 */
    display: grid;
    grid-auto-flow: column;
    grid-gap: 6px;
    background: rgba(255,255,255,0.85);
    padding: 6px 8px;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.trial-progress .cell {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    background: #e0e0e0;
}

.trial-progress .cell.active {
    background: #007bff;
}

.trial-progress .cell.done {
    background: #28a745;
}

/* ===== 摄像头预览（校准前） ===== */
#camera-preview-modal {
    max-width: 900px;
    margin: 20px auto;
    background: white;
    padding: 24px 28px;
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-height: 90vh;
    overflow-y: auto;
    z-index: 1500;
}

#camera-preview-modal h1 {
    margin-top: 0;
    text-align: center;
}

#webgazer-video-container {
    position: relative;
    width: 100%;
    max-width: 720px;
    margin: 16px auto 8px;
    background: #000;
    border-radius: 10px;
    overflow: hidden;
    aspect-ratio: 4/3;
    min-height: 240px;
}

#webgazer-video-container video#webgazerVideoFeed {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    transform: scaleX(-1);
}

#webgazer-video-container canvas#webgazerFaceOverlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
    transform: scaleX(-1);
}

#webgazer-video-container #webgazerFaceFeedbackBox {
    position: absolute !important;
    z-index: 3;
    pointer-events: none;
}

.preview-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.preview-actions button {
    min-width: 120px;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 500;
}

.preview-tips {
    color: #666;
    font-size: 14px;
    margin-top: 16px;
    background: #f8f9fa;
    padding: 16px;
    border-radius: 8px;
    border-left: 4px solid #007bff;
}

.preview-tips ul {
    margin: 6px 0 0;
}

.preview-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #bbb;
    font-size: 14px;
}

/* Debug Panel Styles */
.debug-panel {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 280px;
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    font-family: 'Segoe UI', system-ui, sans-serif;
    font-size: 12px;
    transition: all 0.3s ease;
}

.debug-panel.collapsed .debug-content {
    display: none;
}

.debug-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #333;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    user-select: none;
}

.debug-header span {
    font-weight: 600;
    font-size: 13px;
}

.debug-toggle {
    background: none;
    border: none;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.debug-content {
    padding: 12px;
}

.debug-section {
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #444;
}

.debug-section:last-of-type {
    border-bottom: none;
    margin-bottom: 8px;
}

.debug-section label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: #ccc;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.debug-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.debug-btn {
    background: #007bff;
    color: #fff;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    transition: all 0.2s ease;
    flex: 1;
    min-width: 0;
}

.debug-btn:hover {
    background: #0056b3;
    transform: translateY(-1px);
}

.debug-btn:active {
    transform: translateY(0);
}

.debug-select {
    background: #444;
    color: #fff;
    border: 1px solid #666;
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 11px;
    width: 100%;
    margin-bottom: 6px;
}

.debug-info {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #444;
}

.debug-info small {
    color: #888;
    line-height: 1.3;
}

#current-stage {
    background: #28a745;
    color: #fff;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 600;
    font-size: 11px;
    display: inline-block;
}

/* Debug panel hide on small screens */
@media (max-width: 640px) {
    .debug-panel {
        display: none;
    }
}

/* Mobile responsive design */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    #control-panel,
    #instruction-screen,
    #calibration-screen,
    #end-screen {
        margin: 10px auto;
        padding: 20px 24px;
        max-width: calc(100vw - 20px);
    }
    
    .reading-navigation {
        flex-direction: column;
        align-items: stretch;
    }
    
    .navigation-buttons {
        justify-content: center;
        margin-bottom: 16px;
    }
    
    .status-display {
        text-align: center;
    }
    
    .answer-status, .stroop-status {
        align-items: center;
    }
    
    #camera-preview-modal {
        margin: 10px;
        padding: 20px;
        max-width: calc(100vw - 20px);
        max-height: calc(100vh - 20px);
    }
    
    #webgazer-video-container {
        max-width: 100%;
        margin: 12px 0;
    }
    
    .preview-actions {
        margin-top: 16px;
    }
    
    .preview-actions button {
        min-width: 100px;
        padding: 10px 16px;
        font-size: 15px;
    }
    
    #instruction-screen .button-group {
        flex-direction: column;
        align-items: center;
    }
    
    #instruction-screen button {
        max-width: 300px;
        width: 100%;
    }
    
    .calibration-instruction {
        max-width: 100%;
    }
    
    .trial-progress {
        top: 60px;
        right: 10px;
        padding: 4px 6px;
        grid-gap: 4px;
    }
    
    .trial-progress .cell {
        width: 12px;
        height: 12px;
    }
}

@media (max-width: 480px) {
    .eye-tracking-status {
        top: 10px;
        right: 10px;
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .trial-progress {
        top: 50px;
        right: 8px;
        padding: 3px 4px;
        grid-gap: 3px;
    }
    
    .trial-progress .cell {
        width: 10px;
        height: 10px;
    }
    
    h1 {
        font-size: 1.5em;
    }
    
    h2 {
        font-size: 1.3em;
    }
}

/* Stroop测试前校准样式 */
.notification-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

/* 校准进度样式 */
.calibration-progress {
    margin: 20px 0;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background-color: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background-color: #28a745;
    transition: width 0.3s ease;
    border-radius: 4px;
}

#calibration-status {
    font-weight: 500;
    margin-bottom: 15px;
}

/* 校准按钮特殊样式 */
#start-calibration-stroop {
    background-color: #28a745;
}

#start-calibration-stroop:hover {
    background-color: #218838;
}

#skip-calibration-stroop {
    background-color: #6c757d;
}

#skip-calibration-stroop:hover {
    background-color: #5a6268;
}

#retry-calibration {
    background-color: #ffc107;
    color: #212529;
}

#retry-calibration:hover {
    background-color: #e0a800;
}

#continue-without-calibration {
    background-color: #dc3545;
}

#continue-without-calibration:hover {
    background-color: #c82333;
}

/* Stroop测试进度显示 */
.stroop-progress-display {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1200;
    pointer-events: none;
}

.progress-info {
    display: flex;
    gap: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.progress-info span {
    white-space: nowrap;
}

.probe-info {
    color: #ffc107;
}

.test-info {
    color: #28a745;
}

.total-info {
    color: #17a2b8;
}

/* 疲劳自评样式 */
.fatigue-assessment {
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}

.assessment-intro {
    text-align: left;
    margin-bottom: 20px;
    line-height: 1.6;
}

.assessment-intro p {
    margin-bottom: 12px;
    color: #555;
}

.fatigue-options {
    margin: 20px 0;
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    background: #fafafa;
}

.fatigue-option {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    margin: 5px 0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: white;
    border: 2px solid transparent;
}

.fatigue-option:hover {
    background: #f0f8ff;
    border-color: #cce7ff;
}

.fatigue-option input[type="radio"] {
    margin: 0;
    margin-right: 15px;
    transform: scale(1.2);
}

.fatigue-option input[type="radio"]:checked + .option-number {
    background: #007bff;
    color: white;
}

/* 选中状态通过JavaScript动态添加类名 */
.fatigue-option.selected {
    background: #e3f2fd;
    border-color: #007bff;
}

.option-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #e0e0e0;
    color: #666;
    font-weight: bold;
    margin-right: 15px;
    font-size: 14px;
    transition: all 0.2s ease;
}

.option-text {
    flex: 1;
    font-size: 15px;
    line-height: 1.4;
    color: #333;
}

.assessment-footer {
    text-align: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

.assessment-footer p {
    margin-bottom: 15px;
    color: #666;
    font-style: italic;
}

#submit-fatigue-assessment {
    padding: 12px 30px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 6px;
    min-width: 150px;
}

#submit-fatigue-assessment:disabled {
    background-color: #ccc !important;
    cursor: not-allowed;
}

/* 疲劳评估滚动条样式 */
.fatigue-options::-webkit-scrollbar {
    width: 8px;
}

.fatigue-options::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.fatigue-options::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.fatigue-options::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 校准时的小状态指示器 */
#calibration-mini-status {
    position: fixed !important;
    top: 20px !important;
    right: 20px !important;
    background: rgba(0, 0, 0, 0.8) !important;
    color: white !important;
    padding: 10px 15px !important;
    border-radius: 8px !important;
    font-size: 14px !important;
    z-index: 999 !important;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3) !important;
    font-weight: 500 !important;
    pointer-events: none !important;
    user-select: none !important;
}

/* 确保校准点层级高于大部分元素但低于状态指示器 */
.cal-dot, .test-dot {
    z-index: 1100 !important;
}

#overlay {
    z-index: 1100 !important;
}

/* 确保校准进度窗口层级适中 */
#calibration-overlay {
    z-index: 1000 !important;
}