/* =========================================================================
   心理人格测试 —— 全局样式（手机端优先）
   设计语言：蓝紫渐变背景 + 卡片式布局，营造沉浸式心理测试氛围
   ========================================================================= */

/* ---------- 基础重置 ---------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* 移除移动端点击高亮 */
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
    color: #fff;
    background: #4f46e5;
    overflow-x: hidden;
    line-height: 1.6;
}

/* 蓝紫渐变背景，固定铺满 */
body {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 45%, #a855f7 100%);
    background-attachment: fixed;
    min-height: 100vh;
}

button {
    font-family: inherit;
    border: none;
    cursor: pointer;
    color: #fff;
}

input {
    font-family: inherit;
}

/* ---------- 右上角"我的主页"按钮（固定） ---------- */
.home-btn {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 100;
    padding: 7px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    background: rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, 0.28);
    transition: background 0.2s ease, transform 0.15s ease;
}
.home-btn:active {
    transform: scale(0.94);
    background: rgba(255, 255, 255, 0.3);
}

/* ---------- 应用容器与屏幕切换 ---------- */
.app-container {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    padding: 0 20px 32px;
}

.screen {
    display: none;
    flex-direction: column;
    min-height: 100vh;
    padding-top: 56px;
    animation: fadeIn 0.4s ease;
}
.screen.active {
    display: flex;
}

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

/* ---------- 通用按钮 ---------- */
.btn {
    height: 54px;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 600;
    transition: transform 0.12s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}
.btn:active {
    transform: scale(0.97);
}
.btn-primary {
    background: #fff;
    color: #6d28d9;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}
.btn-primary:disabled {
    opacity: 0.5;
}
.btn-ghost {
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* ---------- 1. 授权页 ---------- */
.screen-inner {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;
}
.hero {
    text-align: center;
    margin-bottom: 36px;
}
.hero-icon {
    font-size: 64px;
    margin-bottom: 12px;
    filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.25));
}
.hero-title {
    font-size: 30px;
    font-weight: 700;
    letter-spacing: 1px;
}
.hero-subtitle {
    margin-top: 10px;
    font-size: 15px;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.7;
}
.auth-card {
    background: rgba(255, 255, 255, 0.14);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 26px 22px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.2);
}
.auth-label {
    display: block;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 10px;
}
.auth-input {
    width: 100%;
    height: 52px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.95);
    color: #2d2d2d;
    font-size: 16px;
    padding: 0 16px;
    outline: none;
    text-align: center;
    letter-spacing: 1px;
}
.auth-input:focus {
    border-color: #fff;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.25);
}
.auth-card .btn-primary {
    width: 100%;
    margin-top: 16px;
}
.auth-tip {
    margin-top: 14px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
}

/* ---------- 2. 测试页 ---------- */
.progress-wrap {
    position: relative;
    margin-bottom: 20px;
}
.progress-bar {
    height: 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.2);
    overflow: hidden;
}
.progress-bar::after {
    content: "";
    display: block;
    height: 100%;
    width: var(--progress, 2%);
    border-radius: 999px;
    background: linear-gradient(90deg, #fde68a, #fff);
    transition: width 0.35s ease;
}
.progress-text {
    position: absolute;
    right: 0;
    top: -22px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.85);
    font-variant-numeric: tabular-nums;
}

.question-card {
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 22px;
    padding: 28px 22px;
    flex: 1;
    display: flex;
    flex-direction: column;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
    /* 触摸滑动相关 */
    touch-action: pan-y;
    user-select: none;
}
.question-num {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 14px;
    font-weight: 600;
    letter-spacing: 1px;
}
.question-text {
    font-size: 21px;
    font-weight: 600;
    line-height: 1.5;
    margin-bottom: 28px;
}

.options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.option {
    /* 选项按钮：高度 >= 56px，方便手指点击 */
    min-height: 56px;
    display: flex;
    align-items: center;
    padding: 14px 18px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.14);
    border: 2px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    font-size: 16px;
    text-align: left;
    transition: all 0.18s ease;
}
.option .opt-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    font-size: 14px;
    font-weight: 700;
    margin-right: 12px;
    flex-shrink: 0;
}
.option.selected {
    background: #fff;
    color: #6d28d9;
    border-color: #fff;
    transform: scale(1.02);
}
.option.selected .opt-letter {
    background: #6d28d9;
    color: #fff;
}
.option:active {
    transform: scale(0.98);
}

.test-nav {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}
.test-nav .btn {
    flex: 1;
}
.test-nav #backBtn:disabled {
    opacity: 0.35;
}

/* ---------- 3. 加载页 ---------- */
.loading-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    text-align: center;
}
.spinner {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 5px solid rgba(255, 255, 255, 0.25);
    border-top-color: #fff;
    animation: spin 0.9s linear infinite;
    margin-bottom: 26px;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
.loading-text {
    font-size: 20px;
    font-weight: 600;
}
.loading-subtext {
    margin-top: 8px;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
}

/* ---------- 4. 结果页 ---------- */
.result-wrap {
    padding-bottom: 8px;
}
.result-title {
    text-align: center;
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 12px;
}
.chart-wrap {
    width: 100%;
    max-width: 360px;
    aspect-ratio: 1 / 1;
    margin: 0 auto 24px;
}
.chart-wrap canvas {
    width: 100%;
    height: 100%;
}

.score-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}
.score-item {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 14px;
    padding: 12px 16px;
}
.score-item-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 8px;
    font-size: 14px;
}
.score-item-name {
    font-weight: 600;
}
.score-item-val {
    font-size: 18px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.score-item-bar {
    height: 7px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.22);
    overflow: hidden;
}
.score-item-bar span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #fde68a, #fff);
}

.analysis-box {
    background: rgba(255, 255, 255, 0.97);
    color: #2d2d2d;
    border-radius: 18px;
    padding: 22px 20px;
    margin-bottom: 22px;
    line-height: 1.75;
    font-size: 15px;
}
.analysis-box h2,
.analysis-box h3,
.analysis-box h4 {
    margin: 16px 0 8px;
    color: #6d28d9;
}
.analysis-box h2 { font-size: 19px; }
.analysis-box h3 { font-size: 17px; }
.analysis-box h4 { font-size: 16px; }
.analysis-box h2:first-child,
.analysis-box h3:first-child,
.analysis-box h4:first-child {
    margin-top: 0;
}
.analysis-box p {
    margin: 8px 0;
}
.analysis-box ul,
.analysis-box ol {
    margin: 8px 0 8px 22px;
}
.analysis-box li {
    margin: 4px 0;
}
.analysis-box strong {
    color: #4c1d95;
}
.analysis-box code {
    background: #f3f0ff;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 13px;
}

.result-wrap #restartBtn {
    width: 100%;
}

/* ---------- Toast 提示 ---------- */
.toast {
    position: fixed;
    left: 50%;
    bottom: 40px;
    transform: translateX(-50%) translateY(20px);
    max-width: 90%;
    padding: 12px 20px;
    border-radius: 12px;
    background: rgba(30, 30, 46, 0.92);
    color: #fff;
    font-size: 14px;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 200;
}
.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ---------- 极小屏适配（< 360px） ---------- */
@media (max-width: 359px) {
    .hero-title { font-size: 26px; }
    .question-text { font-size: 19px; }
    .option { font-size: 15px; }
}

/* ---------- 大屏（平板/桌面）居中约束 ---------- */
@media (min-width: 481px) {
    body {
        display: flex;
        justify-content: center;
    }
    .app-container {
        box-shadow: 0 0 60px rgba(0, 0, 0, 0.25);
    }
}
