/* ===== 全局 ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
    background: #f5f7fa;
    color: #333;
    user-select: none;
    -webkit-user-select: none;
}

/* ===== 页面切换 ===== */
.page {
    display: none;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.page.active {
    display: flex;
}

/* ===== 登记页（浅色） ===== */
#page-register {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #e8edf5 0%, #f0f4fa 50%, #e8edf5 100%);
    position: relative;
    overflow: hidden;
}

/* 装饰性背景元素 */
#page-register::before {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(74, 158, 255, 0.08), rgba(108, 99, 255, 0.08));
    top: -80px;
    right: -80px;
    z-index: 0;
}

#page-register::after {
    content: '';
    position: absolute;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(74, 222, 128, 0.06), rgba(74, 158, 255, 0.06));
    bottom: -60px;
    left: -60px;
    z-index: 0;
}

.register-deco-dot-1 {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(74, 158, 255, 0.15);
    top: 15%;
    right: 12%;
    z-index: 0;
}

.register-deco-dot-2 {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(108, 99, 255, 0.12);
    bottom: 20%;
    left: 10%;
    z-index: 0;
}

.register-deco-dot-3 {
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(74, 222, 128, 0.10);
    bottom: 30%;
    right: 20%;
    z-index: 0;
}

.register-container {
    background: #ffffff;
    border-radius: 20px;
    padding: 40px;
    width: 420px;
    max-width: 90vw;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    border: 1px solid #e8e8e8;
    position: relative;
    z-index: 1;
}

.register-container h1 {
    font-size: 24px;
    text-align: center;
    margin-bottom: 30px;
    color: #2c3e50;
}

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

.form-group label {
    display: block;
    font-size: 14px;
    color: #666;
    margin-bottom: 6px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid #ddd;
    background: #fafafa;
    color: #333;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    border-color: #4a9eff;
    box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.12);
}

.form-group input.readonly-field {
    background: #f0f2f5;
    color: #555;
    cursor: default;
}

.form-group input.readonly-field:focus {
    border-color: #ddd;
    box-shadow: none;
}

.form-group select option {
    background: #fff;
    color: #333;
}

.form-actions {
    margin-top: 24px;
}

.btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, #87CEEB, #B0E0F6);
    color: #fff;
    font-weight: bold;
    box-shadow: 0 2px 12px rgba(135, 206, 235, 0.3);
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary:hover:not(:disabled) {
    opacity: 0.9;
}

.btn-primary:active:not(:disabled) {
    transform: scale(0.98);
}

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

.btn-primary:disabled:active {
    transform: none;
}

.btn-primary.active {
    opacity: 1;
    cursor: pointer;
    box-shadow: 0 2px 16px rgba(135, 206, 235, 0.5);
}

.error-msg {
    color: #ff6b6b;
    font-size: 13px;
    margin-top: 10px;
    text-align: center;
}

/* ===== 加载页 ===== */
#page-loading {
    justify-content: center;
    align-items: center;
    background: #1a1a2e;
}

.loading-container {
    text-align: center;
}

.loading-container p {
    margin-top: 20px;
    font-size: 16px;
    color: #aaa;
}

.spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: #4a9eff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== 测试页 ===== */
#page-experiment {
    position: fixed;
    inset: 0;
    background: #000;
    overflow: hidden;
}

.experiment-header {
    display: none; /* 默认隐藏，由测试控制 */
    justify-content: space-between;
    padding: 10px 20px;
    background: rgba(0,0,0,0.8);
    font-size: 14px;
    color: #aaa;
    z-index: 10;
}

#experiment-canvas {
    display: block;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    /* 宽高由 JS resizeCanvas 动态设置 */
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.overlay.hidden {
    display: none;
}

.overlay-content {
    text-align: center;
    color: #fff;
}

.overlay-content p {
    font-size: 24px;
}

/* ===== 下载报告按钮（深色） ===== */

/* ===== 完成页 ===== */
#page-complete {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #e8edf5 0%, #f0f4fa 50%, #e8edf5 100%);
    position: relative;
    overflow: hidden;
}

#page-complete::before {
    content: '';
    position: absolute;
    width: 250px;
    height: 250px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(74, 222, 128, 0.08), rgba(108, 99, 255, 0.06));
    top: -60px;
    left: -60px;
    z-index: 0;
}

#page-complete::after {
    content: '';
    position: absolute;
    width: 180px;
    height: 180px;
    border-radius: 30%;
    background: linear-gradient(135deg, rgba(74, 158, 255, 0.06), rgba(74, 222, 128, 0.06));
    bottom: -40px;
    right: -40px;
    z-index: 0;
    transform: rotate(45deg);
}

.complete-container {
    text-align: center;
    background: #ffffff;
    border-radius: 20px;
    padding: 48px;
    width: 420px;
    max-width: 90vw;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    border: 1px solid #e8e8e8;
    position: relative;
    z-index: 1;
}

.complete-icon {
    font-size: 72px;
    color: #4ade80;
    margin-bottom: 16px;
}

.complete-container h1 {
    font-size: 26px;
    margin-bottom: 12px;
    color: #2c3e50;
}

.complete-tip {
    font-size: 15px;
    color: #666 !important;
    margin-top: 4px;
    margin-bottom: 8px;
}

.complete-deco-plus {
    position: absolute;
    color: rgba(74, 158, 255, 0.10);
    font-size: 40px;
    font-weight: bold;
    top: 18%;
    right: 15%;
    z-index: 0;
    pointer-events: none;
}

.complete-deco-star {
    position: absolute;
    color: rgba(108, 99, 255, 0.08);
    font-size: 32px;
    bottom: 22%;
    left: 12%;
    z-index: 0;
    pointer-events: none;
}

.btn-download {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 8px;
    padding: 12px 36px;
    font-size: 16px;
    font-weight: bold;
    color: #fff;
    background: linear-gradient(135deg, #87CEEB, #B0E0F6);
    border: none;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(135, 206, 235, 0.3);
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    min-width: 180px;
    position: relative;
}

.btn-download:hover:not(:disabled):not(.loading):not(.success) {
    opacity: 0.9;
}

.btn-download:active:not(:disabled) {
    transform: scale(0.98);
}

.btn-download:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* 按钮图标 */
.btn-download-icon {
    display: inline-flex;
    align-items: center;
    font-size: 18px;
    line-height: 1;
}

/* 加载旋转动画 */
@keyframes btn-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.btn-download.loading .btn-download-icon {
    animation: btn-spin 1s linear infinite;
    font-size: 18px;
}

/* 成功状态 */
.btn-download.success {
    background: #27ae60;
    box-shadow: 0 2px 12px rgba(39, 174, 96, 0.3);
}

.btn-download.success:hover {
    background: #219a52;
}

/* 进度条 */
.download-progress-bar {
    width: 180px;
    height: 3px;
    margin: 8px auto 0;
    background: #e0e0e0;
    border-radius: 2px;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.3s;
}

.download-progress-bar.active {
    opacity: 1;
}

.download-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #3498db, #2ecc71);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.download-hint {
    color: #999 !important;
    font-size: 13px;
    margin-top: 8px;
}

/* ===== 续做提示对话框 ===== */
.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999;
}

.dialog-overlay.hidden {
    display: none;
}

.dialog-box {
    background: #ffffff;
    border-radius: 16px;
    padding: 36px 40px;
    width: 400px;
    max-width: 85vw;
    text-align: center;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
    animation: dialogFadeIn 0.25s ease-out;
}

@keyframes dialogFadeIn {
    from { opacity: 0; transform: scale(0.92) translateY(12px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.dialog-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.dialog-box h2 {
    font-size: 20px;
    color: #2c3e50;
    margin-bottom: 10px;
}

.dialog-box p {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
    margin-bottom: 24px;
}

.dialog-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dialog-btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
}

.dialog-btn:active {
    transform: scale(0.98);
}

.dialog-btn.hidden {
    display: none;
}

.dialog-btn-primary {
    background: linear-gradient(135deg, #87CEEB, #B0E0F6);
    color: #fff;
    font-weight: bold;
    box-shadow: 0 2px 12px rgba(135, 206, 235, 0.3);
}

.dialog-btn-primary:hover {
    opacity: 0.9;
}

.dialog-btn-secondary {
    background: #f0f2f5;
    color: #555;
}

.dialog-btn-secondary:hover {
    background: #e6e8ec;
}
