:root {
    --klein-blue: #002FA7;
    --klein-blue-light: rgba(0, 47, 167, 0.1);
    --klein-blue-hover: #002585;
    --bg-color: #F8F9FA;
    --card-bg: #FFFFFF;
    --text-main: #212529;
    --text-muted: #6C757D;
    --border-color: #E9ECEF;
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 8px 24px rgba(0, 47, 167, 0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-tap-highlight-color: transparent; /* 去除安卓点击闪烁 */
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.container {
    width: 100%;
    max-width: 480px;
    height: 100vh;
    background-color: var(--card-bg);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

@media (min-width: 481px) {
    .container {
        height: 85vh;
        max-height: 800px;
        border-radius: 24px;
        box-shadow: var(--shadow-md);
    }
}

.screen {
    display: none;
    flex-direction: column;
    padding: 32px 24px;
    height: 100%;
    animation: fadeIn 0.4s ease forwards;
}

.screen.active {
    display: flex;
}

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

/* 欢迎页 */
#screen-welcome {
    position: relative;
    padding: 0;
}

/* 左上角 Logo */
.top-bar {
    position: absolute;
    top: 24px;
    left: 24px;
    z-index: 10;
}
.top-logo {
    height: 48px; /* 适当放大 */
    object-fit: contain;
    mix-blend-mode: multiply;
}

.welcome-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    width: 100%;
    padding: 40px 0;
}

.main-title {
    font-size: 56px;
    font-weight: 900;
    letter-spacing: 4px;
    color: #111;
    margin-bottom: 32px;
    font-family: Impact, "Arial Black", sans-serif;
    text-transform: uppercase;
}

/* 趣味跑马灯 */
.marquee-container {
    width: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 40px;
    mask-image: linear-gradient(to right, transparent, black 5%, black 95%, transparent);
    -webkit-mask-image: linear-gradient(to right, transparent, black 5%, black 95%, transparent);
}

.marquee-track {
    display: flex;
    width: max-content;
}

.track-left {
    animation: scrollLeft 25s linear infinite;
}

.track-right {
    animation: scrollRight 25s linear infinite;
}

.track-left-fast {
    animation: scrollLeft 20s linear infinite;
}

.marquee-track img {
    height: 64px;
    width: 64px;
    object-fit: cover;
    margin: 0 8px;
    mix-blend-mode: multiply;
}

@keyframes scrollLeft {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

@keyframes scrollRight {
    0% { transform: translateX(-50%); }
    100% { transform: translateX(0); }
}

/* 文字区 */
.text-section {
    text-align: center;
    margin-bottom: 32px;
}

.slogan-title {
    font-size: 24px;
    font-weight: 800;
    color: #111;
    margin-bottom: 12px;
    letter-spacing: 1px;
}

.slogan-subtitle {
    font-size: 15px;
    color: #888;
    font-style: italic;
    letter-spacing: 1px;
}

/* 黑色圆角按钮 */
.btn-black {
    background-color: #111;
    color: white;
    border-radius: 50px;
    padding: 16px 40px;
    font-size: 18px;
    font-weight: 700;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 80%;
    max-width: 320px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-black:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(0,0,0,0.25);
    background-color: #222;
}

.play-icon {
    font-size: 12px;
    border: 2px solid white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-left: 2px; /* 修正播放箭头的视觉居中 */
}

/* 底部链接 */
.footer-link {
    margin-top: 32px;
    font-size: 13px;
    color: var(--text-muted);
}
.footer-link a {
    color: var(--klein-blue);
    text-decoration: none;
    font-weight: 700;
}
.footer-link a:hover {
    text-decoration: underline;
}

/* 测试页 */
#screen-test {
    justify-content: flex-start;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background-color: var(--border-color);
    border-radius: 4px;
    margin-bottom: 24px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background-color: var(--klein-blue);
    width: 0%;
    transition: width 0.3s ease;
}

.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--klein-blue);
    font-weight: bold;
    margin-bottom: 16px;
}

.question-count-text {
    font-size: 16px;
    letter-spacing: 1px;
}

.btn-prev {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    width: 60px;
    text-align: left;
    transition: color 0.2s;
}

.btn-prev:hover {
    color: var(--klein-blue);
}

.question-container {
    margin-bottom: 40px;
    min-height: 100px;
}

.question-container h2 {
    font-size: 22px;
    font-weight: 600;
    line-height: 1.4;
}

.options-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* 结果页 */
#screen-result {
    text-align: center;
    overflow-y: auto;
}

.result-card {
    background: var(--card-bg);
    border: 2px solid var(--klein-blue-light);
    border-radius: 20px;
    padding: 32px 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.result-label {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

#result-mbti {
    font-size: 42px;
    color: var(--klein-blue);
    font-weight: 900;
    line-height: 1.1;
    margin-bottom: 8px;
    letter-spacing: 1px;
}

.result-name-sub {
    font-size: 20px;
    color: var(--text-main);
    font-weight: 700;
    margin-bottom: 16px;
}

.result-image-container {
    margin: 20px 0;
    display: flex;
    justify-content: center;
}

.result-image-container img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
}

.result-image-placeholder {
    font-size: 80px;
}

.result-desc {
    font-size: 15px;
    color: var(--text-main);
    text-align: justify;
    background-color: var(--bg-color);
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 0;
}

/* 图表与分数条区域 */
.stats-card {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 24px 20px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.dimension-bars {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.dim-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
}

.dim-label {
    width: 60px;
}
.dim-label.right {
    text-align: right;
}

.dim-bar-container {
    flex-grow: 1;
    margin: 0 12px;
    height: 12px;
    border-radius: 6px;
    background-color: var(--border-color);
    position: relative;
    display: flex;
}

.dim-bar-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 1s ease-in-out;
}

.dim-score-badge {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    background: white;
    color: var(--klein-blue);
    font-size: 12px;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 2;
    transition: left 1s ease-in-out;
}

.chart-container {
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* 按钮样式 */
button {
    border: none;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.3s ease;
    /* 防止连续快速点击导致屏幕放大 */
    touch-action: manipulation;
    /* 防止点击时选中文字 */
    user-select: none;
    -webkit-user-select: none;
}

.btn-primary {
    background-color: var(--klein-blue);
    color: white;
    width: 100%;
    padding: 16px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
}

.btn-primary:hover {
    background-color: var(--klein-blue-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 47, 167, 0.2);
}

.btn-secondary {
    background-color: transparent;
    color: var(--klein-blue);
    width: 100%;
    padding: 16px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    border: 1px solid var(--klein-blue);
}

.btn-secondary:hover {
    background-color: var(--klein-blue-light);
}

.btn-option {
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 18px 20px;
    border-radius: 16px;
    font-size: 15px;
    text-align: left;
    font-weight: 500;
    line-height: 1.4;
    transition: all 0.2s ease;
}

@media (hover: hover) {
    .btn-option:hover {
        border-color: var(--klein-blue);
        background-color: var(--klein-blue-light);
        color: var(--klein-blue);
    }
}

.btn-option.selected {
    border-color: var(--klein-blue) !important;
    background-color: var(--klein-blue-light) !important;
    color: var(--klein-blue) !important;
}

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

/* 离屏海报生成容器（聚集、紧凑、高级渐变） */
.export-poster {
    position: fixed;
    left: -9999px;
    top: -9999px;
    width: 375px; /* 锁死物理比例 */
    background: linear-gradient(180deg, #F0F4FF 0%, #FFFFFF 100%);
    padding: 24px;
    box-sizing: border-box;
    z-index: -1000;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ep-header { text-align: center; }
.ep-title { font-size: 42px; font-weight: 900; color: var(--klein-blue); margin: 0; font-family: Impact, sans-serif; letter-spacing: 2px; }
.ep-subtitle { font-size: 13px; color: #555; margin: 4px 0 0 0; font-weight: 600; }

.ep-content { background: #fff; border-radius: 16px; padding: 20px; box-shadow: 0 4px 20px rgba(0,0,0,0.06); display: flex; flex-direction: column; gap: 16px; }

.ep-result-card { text-align: center; }
.ep-label { font-size: 12px; font-weight: 700; color: var(--klein-blue); margin: 0; }
.ep-name { font-size: 26px; font-weight: 900; margin: 4px 0; color: #111; }
#ep-image { width: 140px; height: 140px; margin: 8px auto; display: block; border-radius: 16px; object-fit: cover; border: 3px solid #f0f4ff; }
#ep-desc { font-size: 13px; color: #444; line-height: 1.6; margin: 0; text-align: justify; }

.ep-stats { display: flex; flex-direction: column; gap: 12px; align-items: center; width: 100%; border-top: 1px dashed #eee; padding-top: 16px; }
.ep-bars { width: 100%; }
.ep-chart { width: 220px; height: 220px; margin-top: -10px; }

.ep-footer { display: flex; align-items: center; justify-content: center; gap: 14px; background: rgba(255,255,255,0.9); padding: 14px; border-radius: 14px; box-shadow: 0 2px 10px rgba(0,0,0,0.03); border: 1px solid #eee; }
.ep-qrcode { width: 60px; height: 60px; background: white; padding: 4px; border-radius: 8px; border: 1px solid #ddd; }
.ep-qrcode img { width: 100%; height: 100%; }
.ep-scan-text { text-align: left; }
.ep-scan-title { font-size: 16px; font-weight: 800; color: var(--klein-blue); margin: 0 0 4px 0; }
.ep-scan-url { font-size: 12px; color: #666; margin: 0; font-family: monospace; font-weight: 600; }

/* 弹窗样式 */
.modal {
    display: none;
    position: fixed;
    z-index: 999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background-color: var(--bg-color);
    padding: 24px;
    border-radius: 20px;
    width: 90%;
    max-width: 400px;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-height: 90vh;
}

.close-btn {
    position: absolute;
    top: 12px;
    right: 16px;
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-btn:hover {
    color: #333;
}

.modal-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--klein-blue);
    margin-bottom: 16px;
    margin-top: 8px;
}

.generated-image-container {
    width: 100%;
    overflow-y: auto;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
}

#generated-poster {
    width: 100%;
    height: auto;
    display: block;
}
