/* ABOUTME: Main stylesheet for tarot reading app */
/* ABOUTME: Provides mystical theme with animations and card effects */

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Mystical color palette */
    --primary-dark: #0a0e27;
    --primary-purple: #1a1a3e;
    --accent-gold: #d4af37;
    --accent-purple: #9b59b6;
    --accent-blue: #3498db;
    --text-light: #e8e8e8;
    --text-muted: #a0a0a0;
    --card-back: #1e1e3f;
    --shadow-dark: rgba(0, 0, 0, 0.5);
    --glow-purple: rgba(155, 89, 182, 0.5);
    --glow-gold: rgba(212, 175, 55, 0.5);
}

body {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-purple) 100%);
    color: var(--text-light);
    font-family: "Microsoft YaHei", "微软雅黑", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

#app {
    min-height: 100vh;
    position: relative;
    max-width: 100%;
    overflow-x: hidden;
}

/* Stars background */
.stars-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    background-image: 
        radial-gradient(2px 2px at 20px 30px, #ffffff, transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255,255,255,0.8), transparent),
        radial-gradient(2px 2px at 50px 160px, rgba(255,255,255,0.6), transparent),
        radial-gradient(2px 2px at 90px 40px, #fff, transparent),
        radial-gradient(2px 2px at 130px 80px, rgba(255,255,255,0.7), transparent),
        radial-gradient(2px 2px at 160px 120px, #fff, transparent);
    background-size: 200px 200px;
    animation: twinkle 5s infinite;
}

@keyframes twinkle {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Page transitions */
.page {
    display: none;
    min-height: 100vh;
    padding: 2rem;
    position: relative;
    z-index: 1;
    animation: fadeIn 0.5s ease-in-out;
}

.page.active {
    display: block;
}

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

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 3rem;
}

.title {
    font-size: 3rem;
    font-weight: 300;
    color: var(--accent-gold);
    text-shadow: 0 0 20px var(--glow-gold);
    margin-bottom: 1rem;
    letter-spacing: 2px;
}

.subtitle {
    font-size: 1.2rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Selection sections */
.selection-section {
    margin-bottom: 3rem;
}

.section-title {
    font-size: 1.5rem;
    color: var(--accent-purple);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-title i {
    color: var(--accent-gold);
}

/* Grid layouts */
.spread-grid, .topic-grid {
    display: grid;
    gap: 1rem;
    margin-bottom: 2rem;
}

.spread-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}

.topic-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.question-section {
    margin-top: 1rem;
}

.question-input {
    width: 100%;
    min-height: 90px; /* 约 3 行文字高度 */
    padding: 0.75rem 1rem;
    border-radius: 10px;
    border: 1px solid rgba(212, 175, 55, 0.4);
    background: rgba(10, 14, 39, 0.85);
    color: var(--text-light);
    font-size: 0.95rem;
    resize: vertical;
    outline: none;
}

.question-input::placeholder {
    color: var(--text-muted);
}

.question-input:focus {
    border-color: var(--accent-gold);
    box-shadow: 0 0 10px var(--glow-gold);
}

.question-suggestions {
    margin-top: 0.75rem;
}

.question-suggestions-title {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.question-suggestions-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.question-suggestion {
    font-size: 0.85rem;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    border: 1px solid rgba(212, 175, 55, 0.5);
    background: rgba(26, 26, 62, 0.7);
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.2s ease;
}

.question-suggestion:hover {
    background: rgba(212, 175, 55, 0.2);
    box-shadow: 0 0 8px var(--glow-gold);
}

/* Selection cards */
.selection-card {
    background: linear-gradient(135deg, rgba(26, 26, 62, 0.8), rgba(10, 14, 39, 0.9));
    border: 2px solid rgba(212, 175, 55, 0.3);
    border-radius: 12px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.selection-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(212, 175, 55, 0.1), transparent);
    transition: left 0.5s;
}

.selection-card:hover::before {
    left: 100%;
}

.selection-card:hover {
    border-color: var(--accent-gold);
    box-shadow: 0 0 20px var(--glow-gold);
    transform: translateY(-5px);
}

.selection-card.selected {
    border-color: var(--accent-gold);
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.2), rgba(26, 26, 62, 0.9));
    box-shadow: 0 0 30px var(--glow-gold);
}

.selection-card.selected::after {
    content: '✓';
    position: absolute;
    top: 10px;
    right: 10px;
    color: var(--accent-gold);
    font-size: 1.5rem;
    font-weight: bold;
}

.card-title {
    font-size: 1.1rem;
    color: var(--accent-gold);
    margin-bottom: 0.5rem;
}

.card-desc {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.card-badge {
    display: inline-block;
    background: rgba(155, 89, 182, 0.3);
    color: var(--text-light);
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

/* PC 端选择牌阵页：优化卡片间距与整体高度，尽量首屏完整展示 */
@media (min-width: 1024px) {
    #page-home.page {
        padding-top: 1.5rem;
        padding-bottom: 1.5rem;
    }

    #page-home .container {
        padding-top: 1.5rem;
        padding-bottom: 1.5rem;
    }

    #page-home .selection-section {
        margin-bottom: 2rem;
    }

    #page-home .spread-grid,
    #page-home .topic-grid {
        gap: 0.75rem;
        margin-bottom: 1.5rem;
    }

    #page-home .selection-card {
        padding: 1.1rem 1.25rem;
    }

    #page-home .btn-start {
        margin-top: 1.5rem;
    }
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, var(--accent-gold), #b8941f);
    color: var(--primary-dark);
    border: none;
    padding: 1rem 2.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 4px 15px var(--glow-gold);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 6px 25px var(--glow-gold);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-start {
    display: block;
    margin: 2rem auto 0;
    font-size: 1.2rem;
    padding: 1.2rem 3rem;
}

/* Shuffle page */
.shuffle-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
}

/* 洗牌区域：根据洗牌幅度(±210px)与牌尺寸(180×120 横向)留足空间 */
.shuffle-area {
    width: 100%;
    max-width: 900px;
    /* 移除固定最小宽度，防止小屏出现左右滑动 */
    min-width: 0;
    height: 660px;
    min-height: 620px;
    position: relative;
    margin: 2rem 0;
}

.card-deck {
    position: relative;
    width: 100%;
    height: 100%;
}

/* Tarot card styles（横向 宽×高） */
.tarot-card {
    position: absolute;
    /* 全局横向卡牌按比例缩小约 30%（原 180×120） */
    width: 126px;
    height: 84px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    transform-style: preserve-3d;
}

.tarot-card .card-face {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 10px;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid var(--accent-gold);
    box-shadow: 0 4px 20px var(--shadow-dark);
    overflow: hidden;
}

.tarot-card .card-face img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    border-radius: 7px;
    -webkit-user-drag: none;
    user-drag: none;
}

.tarot-card .card-back {
    background: linear-gradient(135deg, var(--card-back), #2a2a5a);
    background-image: 
        repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(212, 175, 55, 0.1) 10px, rgba(212, 175, 55, 0.1) 20px);
}

.tarot-card .card-back::before {
    content: '✦';
    font-size: 3rem;
    color: var(--accent-gold);
    opacity: 0.5;
}

.tarot-card .card-back:has(img)::before {
    display: none;
}

.tarot-card .card-front {
    background: linear-gradient(135deg, #f5f5f5, #e0e0e0);
    transform: rotateY(180deg);
}

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

/* hover 动画已移除 */

.tarot-card.selected {
    transform: translateY(-30px);
    box-shadow: 0 15px 50px var(--glow-gold);
    border-color: var(--accent-gold);
    z-index: 101;
}

.tarot-card.selected .card-back {
    border-color: var(--accent-gold);
}

/* Progress bar */
.progress-bar {
    width: 100%;
    max-width: 400px;
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 2rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-purple), var(--accent-gold));
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

/* Cards spread */
.cards-spread {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    padding: 1.5rem 0;
    min-height: 320px;
}

/* 56 张牌 U 型布局（PC 首屏完整展示） */
.cards-spread.u-layout {
    position: relative;
    min-height: 60vh;
    max-height: 70vh;
    display: block;
    padding: 0.5rem 0;
}

.cards-spread.u-layout .tarot-card.u-card {
    position: absolute;
    width: 126px;
    height: 84px;
    margin: 0;
    box-shadow: 0 6px 20px var(--shadow-dark), 0 2px 8px rgba(0,0,0,0.3);
}

/* hover 动画已移除（U 型布局） */

.cards-spread.u-layout .tarot-card.u-card.selected {
    /* 选中后沿卡牌“外侧”方向移出：在旋转后做平移 */
    transform: translate(-50%, -50%) rotate(var(--card-rotate, 0deg)) translate(var(--select-tx, 0px), var(--select-ty, 0px)) !important;
    z-index: 201;
}

.selected-cards-info {
    text-align: center;
    margin-top: 4rem;
}

.selected-count {
    font-size: 1.2rem;
    color: var(--accent-gold);
    margin-bottom: 1rem;
}

.btn-confirm {
    font-size: 1.1rem;
    padding: 1rem 2rem;
}

/* Result page */
.result-container {
    padding-bottom: 4rem;
}

.spread-layout {
    display: grid;
    gap: 2rem;
    margin: 2rem auto;
    justify-items: center;
    justify-content: center;
    /* 结果页统一使用 4 列布局 */
    grid-template-columns: repeat(4, 200px);
}

/* 按牌阵坐标绝对定位布局 */
.spread-layout.absolute {
    position: relative;
    display: block;
    margin: 2rem 0;
    /* 给牌阵留更大空间，避免互相遮挡 */
    min-height: 820px;
}

.spread-layout.absolute .result-card {
    position: absolute;
    transform: translate(-50%, -50%);
    /* 绝对定位牌阵：缩小卡片容器，降低重叠概率 */
    width: 140px;
    padding: 0.5rem;
}

/* 生命之树牌阵：专用更紧凑样式 + 更高容器，避免重叠 */
.spread-layout.absolute.spread-16 {
    min-height: 860px;
}

.spread-layout.absolute.spread-16 .result-card {
    width: 145px;
    padding: 0.5rem;
}

.spread-layout.absolute.spread-16 .result-card-name {
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.spread-layout.absolute.spread-16 .result-card-position {
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
}

.spread-layout.absolute.spread-16 .result-card-orientation {
    font-size: 0.75rem;
}

/* 凯尔特十字牌阵：专用更宽布局，避免中心与右列重叠 */
.spread-layout.absolute.spread-15 {
    min-height: 920px;
}

.spread-layout.absolute.spread-15 .result-card {
    width: 135px;
    padding: 0.45rem;
}

/* 七行星牌阵：增加竖向空间，保证 7 张不重叠 */
.spread-layout.absolute.spread-12 {
    min-height: 1300px;
}

/* 年运周期牌阵：为 4×3 布局留出更大高度，保证图片完整显示 */
.spread-layout.absolute.spread-17 {
    /* 纯文字/标签卡片时高度适当收紧，居中更好看 */
    min-height: 760px;
}


/* 不再按 layout-X 区分列数，统一 4 列布局 */

/* Result card */
.result-card {
    background: linear-gradient(135deg, rgba(26, 26, 62, 0.9), rgba(10, 14, 39, 0.95));
    border: 2px solid rgba(212, 175, 55, 0.3);
    border-radius: 12px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    width: 200px;
}

.result-card-position-name {
    font-size: 0.95rem;
    color: var(--accent-gold);
    margin-bottom: 0.25rem;
}

.result-card-position-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.question-display {
    margin-top: 0.5rem;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.result-card.is-hidden {
    opacity: 0;
    transform: translateY(0);
    pointer-events: none;
}

.fly-card {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 5000;
    will-change: transform;
    transition: transform 700ms cubic-bezier(0.22, 1, 0.36, 1);
    pointer-events: none;
}

.result-card:hover {
    border-color: var(--accent-gold);
    box-shadow: 0 0 25px var(--glow-gold);
    transform: translateY(-5px);
}

.result-card-image {
    /* 结果页卡牌使用竖版原图，完整显示 */
    width: 100%;
    height: auto;
    max-height: 260px;
    margin: 0 auto 1rem;
    border-radius: 8px;
    border: 2px solid var(--accent-gold);
    object-fit: contain;
    background: rgba(0, 0, 0, 0.2);
}

.result-card-image.is-reversed,
.card-image.is-reversed {
    transform: rotate(180deg);
}

.result-card-name {
    font-size: 1rem;
    color: var(--accent-gold);
    margin-bottom: 0.5rem;
}

.result-card-position {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.result-card-orientation {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
}

.result-card-orientation.upright {
    background: rgba(155, 89, 182, 0.3);
    color: #c39bd3;
}

.result-card-orientation.reversed {
    background: rgba(231, 76, 60, 0.3);
    color: #ec7063;
}

/* Interpretation section */
.interpretation-section {
    background: linear-gradient(135deg, rgba(26, 26, 62, 0.7), rgba(10, 14, 39, 0.8));
    border: 2px solid rgba(155, 89, 182, 0.3);
    border-radius: 12px;
    padding: 2rem;
    margin: 2rem 0;
}

.interpretation-title {
    font-size: 1.5rem;
    color: var(--accent-purple);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.interpretation-title i {
    color: var(--accent-gold);
}

.interpretation-content {
    line-height: 1.8;
    color: var(--text-light);
    font-size: 1rem;
}

.overall-env {
    margin-top: 0.75rem;
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.6;
}

.overall-env .env-num {
    font-family: "Microsoft YaHei", "微软雅黑", sans-serif;
}

.deep-analysis-block {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px dashed rgba(155, 89, 182, 0.5);
}

.deep-analysis-block h4 {
    color: var(--accent-purple);
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.deep-analysis-content {
    font-size: 0.95rem;
    line-height: 1.8;
    color: var(--text-light);
    overflow: hidden;
}

.deep-analysis-content ul,
.deep-analysis-content ol {
    padding-left: 1.25rem;
}

.deep-analysis-content li {
    margin: 15px 0;
}

/* Deep analysis image: responsive on PC/mobile */
.deep-conclusion-image,
.deep-analysis-content img,
.interpretation-content img {
    width: 100%;
    max-width: 960px;
    height: auto;
    display: block;
    margin: 20px auto;
    border-radius: 12px;
}

/* Image preview modal (deep analysis) */
.image-modal-content {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border-radius: 0;
    padding: 0;
    overflow: hidden;
}

.image-modal-body {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#imageModalImg {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    border-radius: 12px;
    border: 2px solid rgba(212, 175, 55, 0.35);
    background: rgba(0, 0, 0, 0.2);
    touch-action: none; /* enable custom pan/pinch */
    transform: translate3d(0, 0, 0) scale(1);
    transform-origin: center center;
    will-change: transform;
}

.deep-status {
    text-align: center;
    margin: 1.25rem auto 0;
    color: var(--text-muted);
    font-size: 0.95rem;
    max-width: 520px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.deep-spinner {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(212, 175, 55, 0.25);
    border-top-color: var(--accent-gold);
    animation: deep-spin 0.8s linear infinite;
}

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

/* Oracle message */
.oracle-message {
    text-align: center;
    font-style: italic;
    font-size: 1.3rem;
    color: var(--accent-gold);
    padding: 2rem;
    margin: 2rem 0;
    position: relative;
}

.oracle-message i {
    color: var(--accent-purple);
    opacity: 0.5;
    font-size: 1.5rem;
    margin: 0 1rem;
}

.oracle-message i:first-child {
    position: absolute;
    top: 0;
    left: 0;
}

.oracle-message i:last-child {
    position: absolute;
    bottom: 0;
    right: 0;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    overflow-y: auto;
    padding: 2rem;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: linear-gradient(135deg, var(--primary-purple), var(--primary-dark));
    border: 2px solid var(--accent-gold);
    border-radius: 16px;
    padding: 2rem;
    max-width: 900px;
    width: 100%;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.3s;
    z-index: 10;
}

.modal-close:hover {
    color: var(--accent-gold);
}

.card-detail {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 2rem;
    align-items: start;
}

.card-image-wrapper {
    position: relative;
}

.card-image {
    width: 100%;
    border-radius: 12px;
    border: 3px solid var(--accent-gold);
    box-shadow: 0 8px 30px var(--shadow-dark);
}

.orientation-badge {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: var(--accent-gold);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
}

.card-info {
    color: var(--text-light);
}

.card-name {
    font-size: 1.8rem;
    color: var(--accent-gold);
    margin-bottom: 0.5rem;
}

.card-meta {
    margin-bottom: 1rem;
    color: var(--text-muted);
}

.card-keywords {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.card-keywords span {
    background: rgba(155, 89, 182, 0.2);
    color: var(--accent-purple);
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    border: 1px solid rgba(155, 89, 182, 0.3);
}

.card-description-section,
.card-interpretation-section,
.card-advice-section {
    margin-bottom: 1.5rem;
}

.card-description-section h4,
.card-interpretation-section h4,
.card-topic-section h4,
.card-advice-section h4 {
    color: var(--accent-purple);
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.card-description-section p,
.card-interpretation-section p,
.card-topic-section p,
.card-advice-section p {
    line-height: 1.8;
    color: var(--text-light);
}

.btn-restart {
    display: block;
    margin: 2rem auto 0;
}

/* Responsive design */
@media (max-width: 768px) {
    .page {
        /* 移动端：仅上下 1rem，左右无内边距 */
        padding: 1rem 0;
    }
    
    .container {
        padding: 1rem;
    }
    
    .title {
        font-size: 2rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .spread-grid {
        grid-template-columns: 1fr;
    }
    
    .topic-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* 移动端结果页：2 列自适应布局，禁止横向滚动 */
    .spread-layout {
        width: 100%;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1.5rem;
        padding: 0 1rem;
    }
    
    .shuffle-area {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        min-height: 520px;
        height: 560px;
    }
    
    .tarot-card {
        /* 移动端同样按比例缩小（原 120×80） */
        width: 84px;
        height: 56px;
    }

    /* 移动端选牌页 U 形布局优化 */
    #page-select {
        padding-bottom: 120px; /* 为底部固定按钮预留空间 */
    }

    /* 修复：U 型绝对定位卡牌可能覆盖顶部标题 */
    #page-select .header {
        position: relative;
        z-index: 200;
        margin-bottom: 1.25rem;
    }
    
    #page-select .cards-spread.u-layout {
        position: relative;
        z-index: 1;
        padding-top: 1rem;
        min-height: auto;
        max-height: calc(100vh - 280px); /* 减去头部 + 底部按钮区域 */
        height: auto;
    }
    
    #page-select .cards-spread.u-layout .tarot-card.u-card {
        width: 84px;
        height: 56px;
    }

    /* 移动端确认选择按钮固定在底部 */
    #page-select .selected-cards-info {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        margin-top: 0;
        padding: 1rem;
        background: linear-gradient(to top, rgba(10, 14, 39, 0.98), rgba(10, 14, 39, 0.95));
        border-top: 1px solid rgba(212, 175, 55, 0.3);
        z-index: 100;
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }

    #page-select .selected-count {
        font-size: 1rem;
        margin-bottom: 0.75rem;
    }

    #page-select .btn-confirm {
        width: 100%;
        max-width: 300px;
        font-size: 1rem;
        padding: 0.875rem 2rem;
    }
    
    .card-detail {
        grid-template-columns: 1fr;
        text-align: center;
    }
    
    .card-image-wrapper {
        max-width: 250px;
        margin: 0 auto;
    }
    
    .result-card {
        width: 100%;
        max-width: 220px;
    }
    
    .result-card-image {
        width: 100%;
        height: auto;
        max-height: 220px;
    }
}

/* Shuffle animation keyframes */
@keyframes shuffle {
    0%, 100% {
        transform: translateX(0) translateY(0) rotate(0deg);
    }
    25% {
        transform: translateX(-50px) translateY(-30px) rotate(-10deg);
    }
    50% {
        transform: translateX(50px) translateY(30px) rotate(10deg);
    }
    75% {
        transform: translateX(-30px) translateY(-50px) rotate(-5deg);
    }
}

.shuffle-animation {
    animation: shuffle 1s ease-in-out infinite;
}

/* Card reveal animation */
@keyframes revealCard {
    from {
        opacity: 0;
        transform: scale(0.8) rotateY(180deg);
    }
    to {
        opacity: 1;
        transform: scale(1) rotateY(0deg);
    }
}

.reveal-animation {
    animation: revealCard 0.8s ease-out forwards;
}
