/* ==================== 基础与重置 ==================== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --pink: #FF6B9D;
    --purple: #C084FC;
    --mint: #6EE7B7;
    --cream: #FFF8F0;
    --lavender: #E8D5F5;
    --peach: #FFB3BA;
    --sky: #BAE6FD;
    --yellow: #FDE68A;
    --dark: #4A3B5C;
    --card-bg: rgba(255, 255, 255, 0.85);
    --shadow: 0 8px 32px rgba(192, 132, 252, 0.2);
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", -apple-system, sans-serif;
    background: linear-gradient(135deg, var(--cream) 0%, var(--lavender) 50%, var(--sky) 100%);
    min-height: 100vh;
    color: var(--dark);
    overflow-x: hidden;
    position: relative;
}

/* ==================== 浮动装饰 ==================== */
.floating-decorations {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.deco {
    position: absolute;
    font-size: 1.5rem;
    opacity: 0.3;
    animation: floatUp 8s ease-in-out infinite;
}

.deco:nth-child(1) { top: 10%; left: 5%; animation-delay: 0s; font-size: 1.8rem; color: var(--pink); }
.deco:nth-child(2) { top: 20%; right: 8%; animation-delay: 1.5s; font-size: 1.2rem; color: var(--purple); }
.deco:nth-child(3) { top: 60%; left: 10%; animation-delay: 3s; font-size: 2rem; color: var(--mint); }
.deco:nth-child(4) { top: 40%; right: 12%; animation-delay: 0.5s; font-size: 2.2rem; color: var(--yellow); }
.deco:nth-child(5) { top: 75%; left: 20%; animation-delay: 2s; font-size: 1.6rem; color: var(--sky); }
.deco:nth-child(6) { top: 15%; left: 40%; animation-delay: 4s; font-size: 1.4rem; color: var(--pink); }
.deco:nth-child(7) { top: 85%; right: 15%; animation-delay: 1s; font-size: 1.8rem; color: var(--purple); }
.deco:nth-child(8) { top: 50%; left: 75%; animation-delay: 2.5s; font-size: 1.3rem; color: var(--mint); }

@keyframes floatUp {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-15px) rotate(5deg); }
    50% { transform: translateY(-5px) rotate(-3deg); }
    75% { transform: translateY(-20px) rotate(3deg); }
}

/* ==================== 页面切换 ==================== */
.page {
    display: none;
    min-height: 100vh;
    padding: 2rem 1rem;
    position: relative;
    z-index: 1;
}

.page.active {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.5s ease-out;
}

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

.container {
    max-width: 480px;
    width: 100%;
    margin: 0 auto;
    text-align: center;
}

/* ==================== 首页 ==================== */
.logo {
    font-size: 4rem;
    margin-bottom: 0.5rem;
    animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.title {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--pink), var(--purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
    letter-spacing: 2px;
}

.subtitle {
    color: #8B7FA3;
    font-size: 0.95rem;
    margin-bottom: 2rem;
}

/* ==================== 表单卡片 ==================== */
.form-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border-radius: 24px;
    padding: 2rem;
    box-shadow: var(--shadow);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.form-group {
    margin-bottom: 1.2rem;
    text-align: left;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 0.4rem;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #E8D5F5;
    border-radius: 14px;
    font-size: 0.95rem;
    background: rgba(255, 255, 255, 0.7);
    color: var(--dark);
    transition: all 0.3s ease;
    outline: none;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--purple);
    box-shadow: 0 0 0 3px rgba(192, 132, 252, 0.2);
}

.form-group input::placeholder {
    color: #C4B5D4;
}

/* 性别选择按钮 */
.gender-select {
    display: flex;
    gap: 0.75rem;
}

.gender-btn {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid #E8D5F5;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.7);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    color: var(--dark);
}

.gender-btn:hover {
    border-color: var(--purple);
    transform: scale(1.02);
}

.gender-btn.selected {
    border-color: var(--purple);
    background: linear-gradient(135deg, rgba(255, 107, 157, 0.15), rgba(192, 132, 252, 0.15));
    box-shadow: 0 0 0 3px rgba(192, 132, 252, 0.2);
}

/* ==================== 按钮 ==================== */
.btn-primary {
    width: 100%;
    padding: 0.9rem 2rem;
    border: none;
    border-radius: 50px;
    background: linear-gradient(135deg, var(--pink), var(--purple));
    color: white;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    letter-spacing: 1px;
    margin-top: 0.5rem;
    box-shadow: 0 4px 15px rgba(192, 132, 252, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 20px rgba(192, 132, 252, 0.5);
}

.btn-primary:active {
    transform: translateY(0) scale(0.98);
}

.btn-back {
    background: none;
    border: none;
    color: #8B7FA3;
    font-size: 0.9rem;
    cursor: pointer;
    margin-top: 1.5rem;
    padding: 0.5rem;
    transition: color 0.3s;
    font-family: inherit;
}

.btn-back:hover {
    color: var(--purple);
}

/* ==================== 选择算命方式 ==================== */
.method-cards {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
}

.method-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border-radius: 20px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    box-shadow: var(--shadow);
    text-align: center;
}

.method-card:hover {
    border-color: var(--purple);
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 12px 40px rgba(192, 132, 252, 0.3);
}

.method-card:active {
    transform: translateY(0) scale(0.98);
}

.method-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.method-card h2 {
    font-size: 1.2rem;
    color: var(--dark);
    margin-bottom: 0.3rem;
}

.method-card p {
    font-size: 0.85rem;
    color: #8B7FA3;
}

/* ==================== 结果页通用 ==================== */
.result-container {
    max-width: 520px;
    text-align: center;
}

.result-title {
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, var(--pink), var(--purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.result-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border-radius: 24px;
    padding: 1.8rem;
    box-shadow: var(--shadow);
    border: 1px solid rgba(255, 255, 255, 0.5);
    text-align: left;
}

.result-section {
    margin-top: 1.2rem;
}

.result-section h3 {
    font-size: 1rem;
    color: var(--dark);
    margin-bottom: 0.5rem;
}

.result-text {
    font-size: 0.9rem;
    line-height: 1.7;
    color: #5D4E6D;
}

.result-lucky {
    display: flex;
    justify-content: space-around;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px dashed #E8D5F5;
}

.lucky-item {
    text-align: center;
}

.lucky-label {
    display: block;
    font-size: 0.75rem;
    color: #8B7FA3;
    margin-bottom: 0.3rem;
}

.lucky-value {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--purple);
}

.result-actions {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.result-actions .btn-primary {
    width: auto;
    padding: 0.75rem 2.5rem;
    font-size: 1rem;
}

/* ==================== 八字命理 ==================== */
.bazi-pillars {
    display: flex;
    justify-content: center;
    gap: 0.8rem;
    margin-bottom: 1.5rem;
}

.pillar {
    background: linear-gradient(180deg, var(--lavender), rgba(255, 255, 255, 0.5));
    border-radius: 16px;
    padding: 0.8rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    min-width: 65px;
    border: 1px solid rgba(192, 132, 252, 0.3);
}

.pillar-label {
    font-size: 0.7rem;
    color: #8B7FA3;
}

.pillar-gan {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--pink);
}

.pillar-zhi {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--purple);
}

/* 五行分布 */
.wuxing-chart {
    text-align: center;
    margin-bottom: 0.5rem;
}

.wuxing-chart h3 {
    font-size: 1rem;
    margin-bottom: 0.8rem;
}

.wuxing-bars {
    display: flex;
    justify-content: center;
    gap: 0.6rem;
}

.wuxing-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

.wuxing-item .wx-label {
    font-size: 0.7rem;
    color: #8B7FA3;
}

.wuxing-item .wx-bar {
    width: 30px;
    height: 80px;
    background: rgba(192, 132, 252, 0.1);
    border-radius: 10px;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: flex-end;
}

.wuxing-item .wx-fill {
    width: 100%;
    border-radius: 10px;
    transition: height 1s ease-out;
}

.wuxing-item .wx-fill.metal { background: linear-gradient(180deg, #FFD700, #DAA520); }
.wuxing-item .wx-fill.wood { background: linear-gradient(180deg, #6EE7B7, #34D399); }
.wuxing-item .wx-fill.water { background: linear-gradient(180deg, #93C5FD, #60A5FA); }
.wuxing-item .wx-fill.fire { background: linear-gradient(180deg, #FCA5A5, #F87171); }
.wuxing-item .wx-fill.earth { background: linear-gradient(180deg, #FDE68A, #FBBF24); }

.wuxing-item .wx-count {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--dark);
}

/* ==================== 星座运势 ==================== */
.zodiac-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.zodiac-symbol {
    font-size: 3.5rem;
    margin-bottom: 0.5rem;
    animation: twinkle 2s ease-in-out infinite;
}

@keyframes twinkle {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

.zodiac-header h2 {
    font-size: 1.4rem;
    color: var(--dark);
}

.zodiac-date {
    font-size: 0.8rem;
    color: #8B7FA3;
}

.fortune-scores {
    margin-bottom: 1rem;
}

.score-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 0.6rem;
}

.score-label {
    font-size: 0.85rem;
    white-space: nowrap;
    min-width: 80px;
}

.score-bar {
    flex: 1;
    height: 12px;
    background: rgba(192, 132, 252, 0.1);
    border-radius: 6px;
    overflow: hidden;
}

.score-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 1.5s ease-out;
    width: 0;
}

.score-fill.level-5 { background: linear-gradient(90deg, var(--pink), var(--purple)); width: 100%; }
.score-fill.level-4 { background: linear-gradient(90deg, var(--pink), var(--purple)); width: 80%; }
.score-fill.level-3 { background: linear-gradient(90deg, var(--mint), var(--sky)); width: 60%; }
.score-fill.level-2 { background: linear-gradient(90deg, var(--yellow), #FBBF24); width: 40%; }
.score-fill.level-1 { background: linear-gradient(90deg, #FCA5A5, #F87171); width: 20%; }

/* ==================== 塔罗牌 ==================== */
.tarot-draw-phase {
    text-align: center;
}

.tarot-instruction {
    font-size: 1rem;
    color: #8B7FA3;
    margin-bottom: 1.5rem;
    animation: fadeIn 0.5s ease-out;
}

.tarot-cards {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.tarot-card {
    width: 100px;
    height: 150px;
    perspective: 800px;
    cursor: pointer;
}

.tarot-card-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.tarot-card.flipped .tarot-card-inner {
    transform: rotateY(180deg);
}

.tarot-card-front, .tarot-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
}

.tarot-card-front {
    background: linear-gradient(135deg, var(--purple), var(--pink));
    color: white;
    font-size: 2rem;
    box-shadow: 0 4px 15px rgba(192, 132, 252, 0.4);
}

.tarot-card-front .card-position {
    font-size: 0.75rem;
    opacity: 0.8;
}

.tarot-card:not(.flipped):hover .tarot-card-inner {
    transform: translateY(-5px) rotate(2deg);
}

.tarot-card-back {
    background: var(--card-bg);
    transform: rotateY(180deg);
    border: 2px solid var(--lavender);
    box-shadow: var(--shadow);
}

.card-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--dark);
    padding: 0 0.3rem;
    text-align: center;
}

.card-orient {
    font-size: 0.7rem;
    color: var(--purple);
}

.tarot-hint {
    font-size: 0.85rem;
    color: #8B7FA3;
}

/* 塔罗解读 */
.tarot-result-phase {
    text-align: center;
}

.tarot-reading {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border-radius: 24px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    text-align: left;
    margin-bottom: 1rem;
}

.reading-item {
    margin-bottom: 1.2rem;
}

.reading-item:last-child {
    margin-bottom: 0;
}

.reading-position {
    font-size: 0.8rem;
    color: var(--purple);
    font-weight: 700;
    margin-bottom: 0.2rem;
}

.reading-card-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 0.3rem;
}

.reading-text {
    font-size: 0.85rem;
    line-height: 1.6;
    color: #5D4E6D;
}

/* ==================== 打字机效果 ==================== */
.typewriter {
    border-right: 2px solid var(--purple);
    animation: blink 0.8s step-end infinite;
}

@keyframes blink {
    50% { border-color: transparent; }
}

/* ==================== 响应式 ==================== */
@media (max-width: 480px) {
    html { font-size: 15px; }

    .page { padding: 1.5rem 0.8rem; }

    .container { padding: 0 0.5rem; }

    .logo { font-size: 3rem; }

    .title { font-size: 1.5rem; }

    .form-card { padding: 1.3rem; }

    .form-group input,
    .form-group select {
        padding: 0.7rem 0.8rem;
        font-size: 16px; /* 防止 iOS 自动缩放 */
    }

    .gender-btn { padding: 0.7rem; font-size: 16px; }

    .btn-primary { padding: 0.85rem 1.5rem; font-size: 1rem; }

    .method-card { padding: 1.2rem; }
    .method-icon { font-size: 2rem; }
    .method-card h2 { font-size: 1.05rem; }

    .bazi-pillars { gap: 0.4rem; }
    .pillar { padding: 0.6rem 0.6rem; min-width: 52px; }
    .pillar-gan, .pillar-zhi { font-size: 1.1rem; }

    .wuxing-item .wx-bar { width: 26px; height: 65px; }

    .result-card { padding: 1.3rem; }

    .tarot-card { width: 85px; height: 130px; }
    .tarot-card-front { font-size: 1.6rem; }
    .tarot-cards { gap: 0.7rem; }

    .result-lucky { flex-wrap: wrap; gap: 0.8rem; }

    .score-label { min-width: 70px; font-size: 0.8rem; }
}

/* 超小屏（如 iPhone SE） */
@media (max-width: 360px) {
    html { font-size: 14px; }

    .tarot-card { width: 75px; height: 115px; }
    .tarot-card-front { font-size: 1.4rem; }

    .pillar { min-width: 48px; padding: 0.5rem; }
    .pillar-gan, .pillar-zhi { font-size: 1rem; }
}

/* ==================== 触控优化 ==================== */
@media (hover: none) and (pointer: coarse) {
    .method-card:hover {
        transform: none;
        border-color: transparent;
    }
    .method-card:active {
        transform: scale(0.97);
        border-color: var(--purple);
    }

    .tarot-card:not(.flipped):hover .tarot-card-inner {
        transform: none;
    }
    .tarot-card:not(.flipped):active .tarot-card-inner {
        transform: translateY(-3px);
    }

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

    .gender-btn:hover {
        transform: none;
    }
    .gender-btn:active {
        transform: scale(0.97);
    }
}

/* 安全区域（刘海屏等） */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .page {
        padding-bottom: calc(2rem + env(safe-area-inset-bottom));
    }
}

/* ==================== 星星闪烁动画（星座页用） ==================== */
@keyframes starTwinkle {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

/* ==================== 选中高亮动画 ==================== */
@keyframes popIn {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); opacity: 1; }
}

.pop-in {
    animation: popIn 0.4s ease-out;
}
