:root {
    --bg: #e8eef6;
    --fg: #2a2a3e;
    --muted: #7a7a92;
    --accent: #e8a0b8;
    --accent-hover: #d890a8;
    --border: rgba(255, 255, 255, 0.72);
    --pink: #f0b0c4;
    --pink-dark: #c87098;
    --blue: #88c0e0;
    --blue-dark: #5090b8;
}

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

body {
    background: var(--bg);
    color: var(--fg);
    font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
}

html,
body {
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-overflow-scrolling: touch;
    /* iOS 顺滑滚动 */
}

#container {
    position: relative;
    z-index: 1;
    max-width: 580px;
    margin: 0 auto;
    padding: 44px 18px 60px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* 结果页模式：取消居中，允许内容自然流动和滚动 */
#container.scroll-mode {
    justify-content: flex-start;
    min-height: auto;
    padding-bottom: 80px;
    /* 底部留白，确保保存按钮可见 */
}

/* 移动端高度适配：使用 100dvh 更适合 iOS Safari 的动态工具栏 */
@supports (height: 100dvh) {
    #container {
        min-height: 100dvh;
    }
}

/* 背景光斑（浅色调） */
.blob {
    position: fixed;
    border-radius: 50%;
    filter: blur(100px);
    opacity: .28;
    z-index: 0;
    pointer-events: none
}

.blob-p1 {
    width: 480px;
    height: 480px;
    background: #f0c0d0;
    top: -100px;
    left: -80px;
    animation: bf1 28s ease-in-out infinite
}

.blob-p2 {
    width: 320px;
    height: 320px;
    background: #ecd0d8;
    bottom: 10%;
    left: 8%;
    animation: bf2 32s ease-in-out infinite
}

.blob-b1 {
    width: 500px;
    height: 500px;
    background: #b0d0e8;
    bottom: -120px;
    right: -80px;
    animation: bf3 26s ease-in-out infinite
}

.blob-b2 {
    width: 280px;
    height: 280px;
    background: #c0d8f0;
    top: 22%;
    right: 12%;
    animation: bf4 30s ease-in-out infinite
}

@keyframes bf1 {

    0%,
    100% {
        transform: translate(0, 0)
    }

    33% {
        transform: translate(45px, 35px)
    }

    66% {
        transform: translate(-25px, 50px)
    }
}

@keyframes bf2 {

    0%,
    100% {
        transform: translate(0, 0)
    }

    50% {
        transform: translate(35px, -35px)
    }
}

@keyframes bf3 {

    0%,
    100% {
        transform: translate(0, 0)
    }

    40% {
        transform: translate(-50px, -25px)
    }

    80% {
        transform: translate(25px, -40px)
    }
}

@keyframes bf4 {

    0%,
    100% {
        transform: translate(0, 0)
    }

    50% {
        transform: translate(-25px, 35px)
    }
}

/* 液态玻璃 - 移除 backdrop-filter，避免 html2canvas 冲突 */
.glass {
    position: relative;
    background: rgba(255, 255, 255, 0.52);
    border: .5px solid var(--border);
    border-top: 1px solid rgba(255, 255, 255, 0.88);
    border-left: 1px solid rgba(255, 255, 255, 0.82);
    border-radius: 24px;
    box-shadow: 0 16px 48px rgba(100, 120, 160, 0.1);
    overflow: visible;
    /* 移除 overflow: hidden */
}

.glass::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 44%;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 24px 24px 0 0;
    pointer-events: none;
    z-index: 0;
}

#container {
    position: relative;
    z-index: 1;
    max-width: 580px;
    margin: 0 auto;
    padding: 44px 18px 60px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* 开始页 */
#startSection {
    text-align: center;
    padding: 48px 36px 52px;
    width: 100%
}

#startSection h1 {
    font-size: 2.4rem;
    font-weight: 800;
    letter-spacing: .04em;
    margin-bottom: 8px;
    line-height: 1.35;
    position: relative;
    z-index: 2;
    color: var(--pink-dark);
}

.start-emoji {
    font-size: 2.4rem;
    margin-bottom: 16px;
    position: relative;
    z-index: 2
}

.start-sub {
    color: var(--muted);
    font-size: .95rem;
    line-height: 2;
    margin-bottom: 36px;
    position: relative;
    z-index: 2
}

/* 4. 给其他按钮也加上消除触摸高亮 */
.btn-primary {
    position: relative;
    z-index: 5;
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 13px 44px;
    font-size: 1.02rem;
    font-weight: 700;
    border-radius: 999px;
    cursor: pointer;
    transition: all .2s;
    letter-spacing: .06em;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 6px 20px rgba(200, 112, 152, 0.25)
}

.btn-primary:active {
    transform: scale(0.97)
}

.btn-primary:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px
}

/* 测试页 */
#quizSection {
    width: 100%;
    padding: 28px 28px 32px
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 7px;
    position: relative;
    z-index: 2
}

.progress-label {
    font-size: .8rem;
    color: var(--muted);
    font-weight: 500
}

.progress-count {
    font-size: .8rem;
    color: var(--pink-dark);
    font-weight: 700;
    font-variant-numeric: tabular-nums
}

.progress-track {
    width: 100%;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 3px;
    margin-bottom: 28px;
    overflow: hidden;
    position: relative;
    z-index: 2
}

.progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width .35s ease;
    width: 0%
}

.q-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    position: relative;
    z-index: 2
}

.q-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 700;
    flex-shrink: 0;
    background: rgba(232, 160, 184, 0.18);
    color: var(--pink-dark);
}

.q-cat {
    font-size: .72rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 999px;
    letter-spacing: .03em
}

.q-cat.cat-code {
    background: rgba(240, 176, 196, 0.2);
    color: var(--pink-dark)
}

.q-cat.cat-habit {
    background: rgba(136, 192, 224, 0.2);
    color: var(--blue-dark)
}

.q-cat.cat-life {
    background: rgba(160, 140, 200, 0.18);
    color: #7a68a8
}

.q-text {
    font-size: 1.12rem;
    font-weight: 650;
    line-height: 1.7;
    margin-bottom: 24px;
    position: relative;
    z-index: 2;
    color: var(--fg)
}

.opts-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
    z-index: 2
}

/* 3. 修改选项按钮样式，消除手机端高亮残留 */
.opt-btn {
    position: relative;
    background: rgba(255, 255, 255, 0.4);
    border: .5px solid var(--border);
    border-radius: 999px;
    padding: 13px 20px;
    color: var(--muted);
    font-size: .9rem;
    text-align: left;
    cursor: pointer;
    transition: all .2s;
    line-height: 1.55;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
    /* 消除移动端默认触摸高亮 */
    outline: none;
    /* 防止焦点蓝框残留 */
}

/* 仅在支持真hover的设备（如鼠标）上应用hover效果，防止手机端粘滞 */
@media (hover: hover) {
    .opt-btn:hover:not(:disabled) {
        background: rgba(255, 255, 255, 0.7);
        border-color: rgba(255, 255, 255, 0.9);
        color: var(--fg)
    }
}

.opt-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px
}

.opt-btn:disabled {
    cursor: default
}

.opt-btn.selected {
    background: rgba(232, 160, 184, 0.18);
    border-color: rgba(232, 160, 184, 0.4);
    color: var(--pink-dark);
    font-weight: 600
}

/* 结果区 */
#resultSection {
    display: none;
    width: 100%;
    background: #ffffff;
    border-radius: 24px;
    /* 恢复圆角，与 .glass 保持一致 */
    padding: 40px 32px 36px;
    color: #2a2a3e;
    box-shadow: 0 16px 48px rgba(100, 120, 160, 0.1);
    /* 恢复液态玻璃的柔和阴影 */
    overflow: hidden;
    /* 配合圆角裁剪内容 */
}

.result-heading {
    text-align: center;
    font-size: 1.4rem;
    font-weight: 800;
    color: #2a2a3e;
    margin-bottom: 8px;
    letter-spacing: .1em
}

.result-heading-line {
    width: 36px;
    height: 3px;
    background: var(--accent);
    border-radius: 2px;
    margin: 0 auto 22px
}

.proportions {
    text-align: center;
    font-size: 1rem;
    color: #555;
    margin-bottom: 22px;
    line-height: 1.9
}

.proportions .t-val {
    color: #c87098;
    font-weight: 700
}

.proportions .v-val {
    color: #5090b8;
    font-weight: 700
}

.chart-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 16px
}

#resultChart {
    display: block
}

.legend {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin-bottom: 26px
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: .84rem;
    color: #666
}

.legend-swatch {
    width: 13px;
    height: 13px;
    border-radius: 4px;
    flex-shrink: 0
}

.legend-swatch.sw-t {
    background: #f0b0c4
}

.legend-swatch.sw-v {
    background: #88c0e0
}

.type-name {
    text-align: center;
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 12px
}

.type-name.is-t {
    color: #c87098
}

.type-name.is-v {
    color: #5090b8
}

.type-desc {
    font-size: .88rem;
    line-height: 2;
    color: #444;
    text-align: justify
}

#resultSection {
    display: none;
    width: 100%;
    background: #ffffff;
    border-radius: 24px;
    /* 恢复圆角，与 .glass 保持一致 */
    padding: 40px 32px 36px;
    color: #2a2a3e;
    box-shadow: 0 16px 48px rgba(100, 120, 160, 0.1);
    /* 恢复液态玻璃的柔和阴影 */
    overflow: hidden;
    /* 恢复 overflow: hidden，配合圆角裁剪内容 */
}

/* 保存按钮胶囊形 */
#saveBtn {
    display: none;
    margin-top: 20px;
    position: relative;
    z-index: 2;
    background: rgba(255, 255, 255, 0.45);
    border: .5px solid var(--border);
    color: var(--muted);
    padding: 12px 32px;
    font-size: .9rem;
    font-weight: 600;
    border-radius: 999px;
    cursor: pointer;
    transition: all .2s;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}

#saveBtn:hover {
    background: rgba(255, 255, 255, 0.7);
    color: var(--fg);
    border-color: rgba(255, 255, 255, 0.9)
}

#saveBtn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px
}

.fade-in {
    animation: fadeIn .36s ease both
}

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

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

.hidden {
    display: none !important
}

.toast {
    position: fixed;
    bottom: 36px;
    left: 50%;
    transform: translateX(-50%) translateY(16px);
    background: rgba(42, 42, 62, 0.88);
    backdrop-filter: blur(16px);
    color: #fff;
    padding: 11px 26px;
    border-radius: 999px;
    font-size: .86rem;
    opacity: 0;
    transition: all .3s;
    z-index: 999;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0)
}

.start-sub-warning {
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 20px;
}

.start-sub-warning a {
    color: var(--pink-dark);
    text-decoration: none;
}

.start-sub-warning a:hover {
    text-decoration: underline;
}

@media(max-width:480px) {
    #container {
        padding: 24px 12px 40px
    }

    #startSection {
        padding: 36px 22px 40px
    }

    #startSection h1 {
        font-size: 1.8rem
    }

    #quizSection {
        padding: 22px 18px 26px
    }

    .q-text {
        font-size: 1rem
    }

    #resultSection {
        padding: 30px 20px 28px
    }

    .result-heading {
        font-size: 1.2rem
    }

    .legend {
        gap: 18px
    }

    .blob {
        filter: blur(70px);
        opacity: .18
    }
}

@media(prefers-reduced-motion:reduce) {

    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important
    }
}