/* 遮罩层 */
.tarot-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--fade-duration, 400ms) ease;
}
.tarot-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* 模态框 */
.tarot-modal {
    position: relative;
    background: transparent;
    color: #fff;
    padding: 20px 30px;
    max-width: 850px;
    width: 92%;
    text-align: center;
    text-shadow: 2px 2px 8px rgba(0,0,0,0.8);
    pointer-events: auto;
    opacity: 0;
    transition: opacity var(--fade-duration, 400ms) ease;
}
.tarot-modal.active {
    opacity: 1;
}

/* 牌名、正逆位 */
.tarot-name {
    font-size: 2em; font-weight: bold; margin-bottom: 4px; letter-spacing: 2px;
}
.tarot-position {
    font-size: 1.3em; opacity: 0.85; margin-bottom: 16px;
}

/* 3D翻转场景 */
.tarot-card {
    perspective: 1000px;
    width: 100%;
    max-width: 360px;
    margin: 0 auto;
}

/* 翻转容器 */
.tarot-flipper {
    position: relative;
    width: 100%;
    height: 40vh;
    min-height: 250px;
    transform-style: preserve-3d;
    /* transition 由子元素控制，此处不需要 */
}

/* 通用两面 */
.tarot-side {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    backface-visibility: hidden;
    /* 改用变量控制旋转速度 */
    transition: transform var(--rotate-duration, 600ms) ease-in-out;
    border-radius: 12px;
    overflow: hidden;
}

/* 图片自适应，绝不超过容器 */
.tarot-side img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 0 12px rgba(255,255,255,0.25));
    /* 禁用图片自身过渡 */
    transition: none !important;
}

/* 初始状态：正面可见（0度），背面旋转180度隐藏 */
.tarot-front {
    transform: rotateY(0deg);
}
.tarot-back {
    transform: rotateY(-180deg);
}

/* 翻转：正面转走，背面转来 */
.tarot-flipper.flipped .tarot-front {
    transform: rotateY(180deg);
}
.tarot-flipper.flipped .tarot-back {
    transform: rotateY(0deg);
}

/* 描述文字 */
.tarot-description {
    font-size: 1.05em; line-height: 1.7; margin: 18px auto 24px;
    text-align: center;
    max-width: none; width: 100%; padding: 0 10px; box-sizing: border-box;
}

/* 再翻一次按钮 */
.tarot-retry {
    display: inline-block;
    border: 2px solid #fff; background: transparent; color: #fff;
    padding: 10px 28px;
    font-size: 1em; font-weight: 600; cursor: pointer;
    border-radius: 0; transition: all 0.3s ease;
    pointer-events: auto; letter-spacing: 1px;
}
.tarot-retry:hover { background: rgba(255,255,255,0.15); }
.tarot-retry:active { background: rgba(255,255,255,0.3); }

/* 响应式 */
@media (max-width: 600px) {
    .tarot-modal { padding: 15px 12px; width: 80%; max-width: 360px; }
    .tarot-name { font-size: 1.5em; }
    .tarot-position { font-size: 1.1em; }
    .tarot-description { font-size: 0.95em; }
    .tarot-flipper { height: 35vh; min-height: 200px; }
}