/* CSS 變數系統 */
:root {
    /* 主色調 - 黑色系 */
    --primary-black: #000000;
    --primary-dark: #1a1a1a;
    --primary-charcoal: #2d2d2d;

    /* 輔助色 - 沙金色系 */
    --accent-sand-gold: #C9A962;
    --accent-champagne: #D4AF65;
    --accent-bronze: #B8956A;
    --accent-light-gold: #E5D5A8;

    /* 保留原狀態色 */
    --success-green: #4CAF50;
    --warning-orange: #FF9800;
    --error-red: #F44336;
    --info-blue: #2196F3;

    /* 中性色 */
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-300: #D1D5DB;
    --gray-500: #6B7280;
    --gray-700: #374151;
    --gray-900: #111827;

    /* 黑金漸變 */
    --gradient-black-gold: linear-gradient(135deg,
        #000000 0%,
        #1a1a1a 50%,
        #2d2d2d 100%);
    --gradient-gold-shine: linear-gradient(135deg,
        #C9A962 0%,
        #D4AF65 50%,
        #C9A962 100%);

    /* 黑金陰影 */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.2);
    --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.3);
    --shadow-gold: 0 4px 20px rgba(201, 169, 98, 0.3);
    --shadow-gold-lg: 0 10px 40px rgba(201, 169, 98, 0.4);

    /* 黑金發光 */
    --glow-gold: 0 0 20px rgba(201, 169, 98, 0.6);
    --glow-gold-strong: 0 0 30px rgba(212, 175, 101, 0.8);

    /* 保留用於兼容 */
    --primary-purple: #C9A962;
    --primary-blue: #C9A962;
    --primary-violet: #B8956A;
    --accent-gold: #D4AF65;
    --accent-orange: #B8956A;
    --gradient-primary: var(--gradient-black-gold);
    --gradient-accent: var(--gradient-gold-shine);
    --glow-primary: var(--glow-gold);
    --glow-accent: var(--glow-gold-strong);

    /* 過渡曲線 */
    --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --ease-smooth: cubic-bezier(0.4, 0.0, 0.2, 1);
    --ease-elastic: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 全域樣式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg,
        #000000 0%,
        #1a1a1a 50%,
        #2d2d2d 100%);
    min-height: 100vh;
    padding: 20px;
    color: #E5D5A8;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background: rgba(0, 0, 0, 0.85);
    border-radius: 20px;
    border: 1px solid var(--accent-sand-gold);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8),
                0 0 40px rgba(201, 169, 98, 0.2);
    padding: 30px;
}

/* 標題區 */
.header {
    text-align: center;
    margin-bottom: 30px;
}

.header h1 {
    font-size: 3em;
    background: linear-gradient(135deg, var(--accent-champagne) 0%, var(--accent-light-gold) 50%, var(--accent-sand-gold) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    filter: drop-shadow(0 0 20px rgba(201, 169, 98, 0.8)) drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
    margin-bottom: 15px;
    font-weight: 800;
    letter-spacing: 2px;
}

.subtitle {
    color: var(--accent-light-gold);
    font-size: 1.1em;
    margin-bottom: 10px;
}

.user-info {
    color: var(--accent-bronze);
    font-size: 0.9em;
}

.user-info span {
    font-weight: bold;
    color: var(--accent-champagne);
}

/* 訊息提示框（優化版） */
.message-box {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    background: white;
    padding: 20px 30px;
    border-radius: 15px;
    box-shadow: var(--shadow-xl);
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s var(--ease-bounce);
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 15px;
    max-width: 90%;
    font-weight: 500;
    color: var(--gray-900);
}

.message-box.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.message-box::before {
    content: '';
    font-size: 2em;
    flex-shrink: 0;
}

.message-box.info {
    border-left: 5px solid var(--info-blue);
}

.message-box.info::before {
    content: 'ℹ️';
}

.message-box.success {
    border-left: 5px solid var(--success-green);
    animation: successPop 0.5s var(--ease-bounce);
}

.message-box.success::before {
    content: '✅';
}

@keyframes successPop {
    0% {
        transform: translate(-50%, -50%) scale(0) rotate(-15deg);
    }
    70% {
        transform: translate(-50%, -50%) scale(1.1) rotate(5deg);
    }
    100% {
        transform: translate(-50%, -50%) scale(1) rotate(0deg);
    }
}

.message-box.warning {
    border-left: 5px solid var(--warning-orange);
}

.message-box.warning::before {
    content: '⚠️';
    animation: wiggle 0.5s ease;
}

@keyframes wiggle {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-10deg); }
    75% { transform: rotate(10deg); }
}

.message-box.error {
    border-left: 5px solid var(--error-red);
    animation: shake 0.4s ease;
}

.message-box.error::before {
    content: '❌';
}

@keyframes shake {
    0%, 100% { transform: translate(-50%, -50%) translateX(0); }
    25% { transform: translate(-50%, -50%) translateX(-10px); }
    75% { transform: translate(-50%, -50%) translateX(10px); }
}

/* 問題輸入區 */
.question-section {
    margin-bottom: 25px;
}

.question-section label {
    display: block;
    font-size: 1.1em;
    font-weight: 600;
    color: var(--accent-light-gold);
    margin-bottom: 15px;
}

/* 快速問題按鈕 */
.quick-questions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
}

.quick-q-btn {
    padding: 10px 16px;
    border: 2px solid var(--accent-bronze);
    background: var(--primary-charcoal);
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: 500;
    color: var(--accent-light-gold);
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
    font-family: inherit;
}

.quick-q-btn:hover {
    background: var(--primary-black);
    color: var(--accent-champagne);
    border-color: var(--accent-champagne);
    box-shadow: var(--glow-gold);
    transform: translateY(-2px);
}

.quick-q-btn:active {
    transform: translateY(0);
}

.question-section textarea {
    width: 100%;
    padding: 15px;
    border: 2px solid var(--accent-bronze);
    background: var(--primary-dark);
    color: var(--accent-light-gold);
    border-radius: 10px;
    font-size: 1em;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s;
}

.question-section textarea:focus {
    outline: none;
    border-color: var(--accent-champagne);
    box-shadow: var(--glow-gold);
}

/* 卡片插槽區 */
.slots-section {
    margin-bottom: 30px;
    padding: 25px 20px;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.4) 0%, rgba(26, 26, 26, 0.4) 100%);
    border-radius: 15px;
    border: 2px dashed rgba(201, 169, 98, 0.3);
}

.slots-title {
    text-align: center;
    color: var(--accent-champagne);
    font-size: 1.3em;
    margin-bottom: 20px;
    font-weight: 700;
}

.card-slots {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 15px;
}

.card-slot {
    flex: 1;
    max-width: 150px;
    position: relative;
}

.slot-label {
    text-align: center;
    font-size: 0.9em;
    font-weight: 600;
    color: var(--accent-light-gold);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.slot-placeholder {
    width: 100%;
    height: 180px;
    border: 2px dashed var(--accent-sand-gold);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.slot-placeholder::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at center, rgba(107, 70, 193, 0.03), transparent 70%);
    pointer-events: none;
}

.slot-number {
    font-size: 3em;
    font-weight: 700;
    color: var(--accent-bronze);
    line-height: 1;
    margin-bottom: 10px;
}

.slot-hint {
    font-size: 0.75em;
    color: var(--accent-sand-gold);
    text-align: center;
    padding: 0 10px;
    line-height: 1.4;
}

.card-slot.filled .slot-placeholder {
    border-color: var(--primary-purple);
    border-style: solid;
    background: var(--gradient-primary);
    box-shadow: var(--shadow-lg), var(--glow-primary);
    animation: filledSuccess 0.5s var(--ease-bounce);
}

@keyframes filledSuccess {
    0% {
        transform: scale(0.8) rotate(-5deg);
        opacity: 0;
    }
    60% {
        transform: scale(1.1) rotate(5deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

.card-slot.filled .slot-number,
.card-slot.filled .slot-hint {
    display: none;
}

.card-slot.active .slot-placeholder {
    border-color: var(--accent-champagne);
    border-style: solid;
    border-width: 2px;
    background: rgba(0, 0, 0, 0.8);
    box-shadow: var(--glow-gold), inset 0 0 20px rgba(201, 169, 98, 0.2);
    background-size: 200% 200%;
    animation: slotBreath 2s ease-in-out infinite, gradientShift 4s ease infinite;
    position: relative;
}

@keyframes slotBreath {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(107, 70, 193, 0.4),
                    0 0 20px rgba(107, 70, 193, 0.2);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(107, 70, 193, 0),
                    0 0 30px rgba(107, 70, 193, 0.4);
        transform: scale(1.02);
    }
}

/* 添加指示箭頭 */
.card-slot.active .slot-placeholder::after {
    content: '👇';
    position: absolute;
    top: -45px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.8em;
    animation: bounce 1s ease infinite;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

@keyframes bounce {
    0%, 100% {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
    50% {
        transform: translateX(-50%) translateY(-12px);
        opacity: 0.7;
    }
}

.card-slot.active .slot-number {
    color: var(--primary-purple);
    animation: numberPulse 1.5s ease-in-out infinite;
}

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

.slots-progress {
    text-align: center;
    font-size: 1em;
    color: var(--accent-light-gold);
    font-weight: 500;
}

.slots-progress span {
    color: var(--accent-champagne);
    font-weight: 700;
    font-size: 1.1em;
}

/* 插槽中的卡片 */
.slot-card {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s var(--ease-elastic);
    animation: slotFillSuccess 0.6s var(--ease-bounce);
}

@keyframes slotFillSuccess {
    0% {
        transform: scale(0) rotate(0deg);
        opacity: 0;
    }
    70% {
        transform: scale(1.15) rotate(15deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

.slot-card:hover {
    transform: scale(1.08) rotate(2deg);
    filter: brightness(1.1);
}

.slot-card:active {
    transform: scale(0.95);
    transition: all 0.1s ease;
}

.slot-card-back {
    width: 90%;
    height: 90%;
    background: var(--gradient-black-gold);  /* 黑金漸變 */
    border: 2px solid var(--accent-sand-gold);  /* 金色邊框 */
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-gold-lg), var(--shadow-xl);  /* 金色發光 + 深陰影 */
}

.slot-card-emoji {
    font-size: 2.5em;
}

@keyframes cardAppear {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* 飛行中的卡片 */
.flying-card {
    animation: none !important;
}

/* 塔羅牌網格 */
.cards-section {
    margin-bottom: 30px;
    position: relative;
}

.cards-section-title {
    text-align: center;
    color: var(--accent-champagne);
    font-size: 1.1em;
    margin-bottom: 20px;
    font-weight: 600;
}

/* 水平滾動提示 */
.scroll-hint {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(201, 169, 98, 0.95);  /* 金色背景 */
    color: var(--primary-black);  /* 黑色文字 */
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 600;
    animation: slideHint 2s ease-in-out infinite;
    pointer-events: none;
    z-index: 100;
    white-space: nowrap;
    transition: opacity 0.3s ease;
    box-shadow: var(--shadow-gold-lg), var(--glow-gold-medium);  /* 金色發光 */
    border: 1px solid var(--accent-champagne);
}

@keyframes slideHint {
    0%, 100% {
        opacity: 0.8;
        transform: translateX(-50%);
    }
    50% {
        opacity: 1;
        transform: translateX(-50%) translateY(-5px);
    }
}

/* 左右漸變指示器 */
.cards-section {
    position: relative;
}

.cards-section::before,
.cards-section::after {
    content: '';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    height: 100px;
    width: 30px;
    pointer-events: none;
    z-index: 5;
    opacity: 0.8;
}

.cards-section::before {
    left: 0;
    background: linear-gradient(90deg, white, transparent);
}

.cards-section::after {
    right: 0;
    background: linear-gradient(-90deg, white, transparent);
}

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

@keyframes fadeOut {
    to {
        opacity: 0;
        visibility: hidden;
    }
}

/* 卡片容器 - 水平滾動設計 */
.cards-grid {
    position: relative;
    width: 100%;
    height: auto;
    overflow-x: auto;  /* 水平滾動 */
    overflow-y: hidden;
    padding: 20px 10px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
    border-radius: 15px;
    -webkit-overflow-scrolling: touch;  /* iOS 慣性滾動 */
    scroll-behavior: smooth;
}

/* 內部容器 - 水平排列 */
.cards-grid-inner {
    display: flex;
    flex-direction: row;
    gap: 15px;
    padding: 10px;
    min-width: min-content;
    position: relative;
}

.cards-grid::-webkit-scrollbar {
    width: 8px;
}

.cards-grid::-webkit-scrollbar-track {
    background: #E0E0E0;
    border-radius: 10px;
    margin: 5px 0;
}

.cards-grid::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--accent-sand-gold) 0%, var(--accent-bronze) 100%);
    border-radius: 10px;
    min-height: 30px;
}

.cards-grid::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, var(--accent-bronze) 0%, var(--accent-sand-gold) 100%);
}

/* 返回頂部按鈕 */
.scroll-to-top {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-sand-gold) 0%, var(--accent-bronze) 100%);
    color: white;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    z-index: 100;
    font-weight: bold;
    opacity: 0;
    transform: scale(0.8);
}

.scroll-to-top:hover {
    transform: translateY(-3px) scale(1);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.6);
}

.scroll-to-top:active {
    transform: translateY(0) scale(0.9);
}

/* 當按鈕顯示時的動畫 */
.scroll-to-top[style*="display: block"] {
    animation: fadeInScale 0.3s ease forwards;
}

@keyframes fadeInScale {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.tarot-card {
    position: relative;  /* 改為相對定位用於水平排列 */
    flex-shrink: 0;  /* 不縮小 */
    width: 100px;
    height: 150px;
    background: var(--gradient-black-gold);
    background-size: 200% 200%;
    border: 2px solid var(--accent-sand-gold);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s var(--ease-elastic);
    user-select: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    touch-action: manipulation;
    box-shadow: var(--shadow-gold);
    will-change: transform, filter;
    animation: gradientShift 6s ease infinite;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* ========================================
   塔羅牌正反面設計
   ======================================== */

/* 牌背和牌面共用樣式 */
.card-back,
.card-front {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 0;
    left: 0;
    border-radius: 10px;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* 牌背設計 - 精緻的黑金裝飾 */
.card-back {
    z-index: 2;
    background: var(--gradient-black-gold);
    position: relative;
}

/* 牌背中央圖示 */
.card-back-emoji {
    font-size: 2.8em;
    color: var(--accent-champagne);
    filter: drop-shadow(0 2px 8px rgba(201, 169, 98, 0.5));
    text-shadow: 0 0 15px var(--accent-sand-gold);
    animation: crystalPulse 3s ease-in-out infinite;
    position: relative;
    z-index: 2;
}

@keyframes crystalPulse {
    0%, 100% {
        transform: scale(1);
        filter: drop-shadow(0 2px 8px rgba(201, 169, 98, 0.5));
    }
    50% {
        transform: scale(1.05);
        filter: drop-shadow(0 4px 12px rgba(201, 169, 98, 0.8));
    }
}

/* 牌背裝飾層 - 四角裝飾 */
.card-back::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    bottom: 8px;
    border: 1.5px solid rgba(201, 169, 98, 0.4);
    border-radius: 6px;
    pointer-events: none;
    z-index: 1;
}

/* 牌背光暈效果 */
.card-back::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 60%;
    height: 60%;
    background: radial-gradient(circle, rgba(201, 169, 98, 0.15) 0%, transparent 70%);
    transform: translate(-50%, -50%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
}

/* 牌面設計 - 清晰明亮 */
.card-front {
    z-index: 1;
    background: linear-gradient(135deg, #FFFFFF 0%, #F8F8F8 100%);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.1);
    padding: 10px;
}

/* 牌面圖示 */
.card-front .card-emoji {
    font-size: 2.8em;
    margin-bottom: 10px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

/* 牌面名稱 */
.card-front .card-name {
    font-size: 0.75em;
    font-weight: 700;
    color: var(--accent-sand-gold);
    text-align: center;
    padding: 0 5px;
    word-break: keep-all;
    line-height: 1.3;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* 牌面邊框裝飾 */
.card-front::before {
    content: '';
    position: absolute;
    top: 6px;
    left: 6px;
    right: 6px;
    bottom: 6px;
    border: 1px solid var(--accent-bronze);
    border-radius: 6px;
    pointer-events: none;
}

.tarot-card:hover {
    transform: scale(1.15) translateY(-10px);
    border-color: var(--accent-champagne);
    box-shadow: var(--shadow-gold-lg), var(--glow-gold-strong);
    z-index: 10;
    animation: hoverGlow 1.5s ease-in-out infinite;
}

@keyframes hoverGlow {
    0%, 100% {
        box-shadow: var(--shadow-xl),
                    0 0 20px rgba(255, 215, 0, 0.4),
                    inset 0 0 40px rgba(255, 255, 255, 0.2);
    }
    50% {
        box-shadow: var(--shadow-xl),
                    0 0 40px rgba(255, 215, 0, 0.8),
                    inset 0 0 60px rgba(255, 255, 255, 0.3);
    }
}

.tarot-card:active {
    transform: scale(0.95);
    transition: all 0.1s ease;
    filter: brightness(1.1);
}

.tarot-card.selected {
    background: var(--gradient-gold-shine);
    border-color: var(--accent-champagne);
    border-width: 3px;
    opacity: 0.6;
    pointer-events: none;
    box-shadow: var(--glow-gold);
    animation: selectedPulse 2s ease-in-out infinite;
}

@keyframes selectedPulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(255, 215, 0, 0.6),
                    inset 0 0 20px rgba(255, 255, 255, 0.2);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 40px rgba(255, 215, 0, 0.9),
                    inset 0 0 40px rgba(255, 255, 255, 0.3);
        transform: scale(1.05);
    }
}

.tarot-card.selected::before {
    content: '✨';
    font-size: 2.5em;
    color: var(--accent-champagne);
    text-shadow: 0 0 10px var(--accent-sand-gold);
    animation: sparkle 1.5s ease-in-out infinite;
}

@keyframes sparkle {
    0%, 100% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(180deg) scale(1.2); }
}

/* 翻牌後的樣式 */
.tarot-card.revealed {
    background: white;
    border-color: var(--accent-sand-gold);
}

.tarot-card.revealed::before {
    content: attr(data-emoji);
    font-size: 2em;
    opacity: 1;
}

.tarot-card.revealed::after {
    display: none;
}

.card-emoji,
.card-name {
    display: none;
}

.tarot-card.revealed .card-emoji,
.tarot-card.revealed .card-name {
    display: block;
}

.card-emoji {
    font-size: 2em;
    margin-bottom: 5px;
}

.card-name {
    font-size: 0.7em;
    font-weight: 600;
    color: #333;
    padding: 0 5px;
    word-break: keep-all;
}

/* 按鈕 */
.actions {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.btn {
    flex: 1;
    padding: 15px 30px;
    border: none;
    border-radius: 10px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-black) 0%, var(--primary-charcoal) 100%);
    color: var(--accent-champagne);
    border: 3px solid var(--accent-sand-gold);
    box-shadow: var(--shadow-gold-lg), var(--glow-gold-medium), inset 0 1px 0 rgba(201, 169, 98, 0.3);
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(201, 169, 98, 0.3), transparent);
    transition: left 0.5s;
}

.btn-primary:hover:not(:disabled)::before {
    left: 100%;
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--primary-charcoal) 0%, var(--primary-black) 100%);
    border-color: var(--accent-champagne);
    box-shadow: var(--shadow-gold-xl), var(--glow-gold-strong), inset 0 1px 0 rgba(212, 175, 101, 0.5);
    color: var(--accent-light-gold);
    transform: translateY(-3px) scale(1.02);
}

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

.btn-secondary {
    background: var(--primary-charcoal);
    color: var(--accent-sand-gold);
    border: 1px solid var(--accent-bronze);
}

.btn-secondary:hover {
    background: var(--primary-dark);
    border-color: var(--accent-sand-gold);
    color: var(--accent-light-gold);
}

/* 頁尾 */
.footer {
    text-align: center;
    color: var(--accent-bronze);
    font-size: 0.9em;
    padding-top: 20px;
    border-top: 1px solid var(--accent-sand-gold);
}

.footer p {
    margin: 5px 0;
}

/* 響應式設計 */
@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 20px 15px;
        border-radius: 15px;
    }

    .header h1 {
        font-size: 1.8em;
    }

    .subtitle {
        font-size: 1em;
    }

    .quick-questions {
        gap: 6px;
    }

    .quick-q-btn {
        padding: 8px 12px;
        font-size: 0.85em;
        flex: 1 1 calc(50% - 6px);
        min-width: 0;
    }

    .question-section textarea {
        font-size: 0.95em;
        padding: 12px;
    }

    /* 插槽區響應式 */
    .slots-section {
        padding: 20px 10px;
    }

    .slots-title {
        font-size: 1.1em;
        margin-bottom: 15px;
    }

    .card-slots {
        gap: 10px;
    }

    .card-slot {
        max-width: 100px;
    }

    .slot-placeholder {
        height: 140px;
    }

    .slot-number {
        font-size: 2em;
    }

    .slot-hint {
        font-size: 0.7em;
    }

    .slot-card-emoji {
        font-size: 2em;
    }

    /* 水平滾動響應式 - 移動端優化 */
    .cards-grid {
        height: auto;
        padding: 15px 10px;
        -webkit-overflow-scrolling: touch; /* iOS 慣性滾動 */
    }

    /* 移動端水平容器 */
    .cards-grid-inner {
        gap: 10px;
        padding: 8px;
    }

    .tarot-card {
        width: 80px;  /* 移動端卡片寬度 */
        height: 120px;  /* 移動端卡片高度 */
    }

    .tarot-card::before {
        font-size: 1.3em;
    }

    .card-emoji {
        font-size: 1.3em;
    }

    .card-name {
        font-size: 0.6em;
    }

    .tarot-card:hover {
        transform: scale(1.1) translateY(-8px); /* 適合水平佈局的hover效果 */
    }

    .actions {
        flex-direction: column;
        gap: 10px;
    }

    .btn {
        padding: 14px 25px;
        font-size: 1em;
    }
}

/* 超小屏幕優化 */
@media (max-width: 375px) {
    .cards-grid {
        padding: 10px 5px;
    }

    .cards-grid-inner {
        gap: 8px;
        padding: 5px;
    }

    .tarot-card {
        width: 70px;  /* 超小屏幕卡片寬度 */
        height: 105px;  /* 超小屏幕卡片高度 */
    }

    .quick-q-btn {
        flex: 1 1 100%;
    }

    .scroll-to-top {
        bottom: 70px;
        right: 10px;
        width: 40px;
        height: 40px;
        font-size: 1.2em;
    }
}

/* ========================================
   移動端UX優化 - 視覺引導
   ======================================== */

/* 移動端專屬提示 */
@media (max-width: 600px) {
    .cards-section-title {
        font-size: 1em;
        margin-bottom: 10px;
    }

    /* 水平滾動提示優化 */
    .scroll-hint {
        font-size: 0.8em;
        padding: 6px 12px;
    }

    @keyframes gentlePulse {
        0%, 100% { opacity: 1; }
        50% { opacity: 0.7; }
    }

    /* 活躍插槽的強化視覺提示 */
    .card-slot.active .slot-placeholder::after {
        font-size: 1.5em; /* 更大的箭頭 */
        top: -40px;
    }

    /* 選擇進度條優化 */
    .slots-progress {
        font-size: 0.95em;
        background: linear-gradient(135deg,
            rgba(107, 70, 193, 0.08) 0%,
            rgba(118, 75, 162, 0.12) 100%);
        padding: 8px 15px;
        border-radius: 20px;
        display: inline-block;
        margin-top: 10px;
    }
}

/* ========================================
   移動端觸控優化
   ======================================== */

/* 觸控裝置專用優化 */
@media (max-width: 600px) and (hover: none) {
    /* 卡片觸控優化 */
    .tarot-card {
        /* 增加觸控熱區 */
        min-width: 44px;
        min-height: 44px;
        padding: 5px;
        /* 避免觸控延遲 */
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    /* 移除 hover 效果，使用 active 替代 */
    .tarot-card:hover {
        transform: none;
        animation: none;
    }

    /* 觸控點擊反饋 - 更明顯 */
    .tarot-card:active {
        transform: scale(1.08) !important;
        filter: brightness(1.2);
        z-index: 9999 !important;
        box-shadow: var(--shadow-gold-xl), var(--glow-gold-strong);
        transition: all 0.1s ease-out;
    }

    /* 已選中的卡片觸控反饋 */
    .tarot-card.selected:active {
        transform: scale(0.95) !important;
    }

    /* 快速問題按鈕觸控優化 */
    .quick-q-btn {
        min-height: 44px; /* iOS 建議的最小觸控尺寸 */
        min-width: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 12px 16px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    .quick-q-btn:active {
        transform: scale(0.95);
        background: var(--primary-black);
        border-color: var(--accent-champagne);
    }

    /* 主要按鈕觸控優化 */
    .btn {
        min-height: 48px;
        min-width: 120px;
        padding: 16px 32px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    .btn:active:not(:disabled) {
        transform: scale(0.97);
    }

    /* 文字輸入框觸控優化 */
    .question-section textarea {
        min-height: 44px;
        font-size: 16px; /* 防止 iOS 自動縮放 */
        -webkit-appearance: none;
        touch-action: manipulation;
    }

    /* 插槽觸控優化 */
    .card-slot {
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    /* 水平滾動容器觸控優化 */
    .cards-grid {
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x proximity;
        touch-action: pan-x;
    }

    /* 卡片滾動吸附效果 */
    .tarot-card {
        scroll-snap-align: center;
    }
}

/* 載入動畫 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.container {
    animation: fadeIn 0.5s ease;
}

/* 3D 卡片翻轉動畫 */
@keyframes cardFlip {
    0% {
        transform: perspective(1000px) rotateY(0deg) scale(1);
        opacity: 1;
    }
    45% {
        transform: perspective(1000px) rotateY(90deg) scale(1.15);
        opacity: 0.8;
    }
    55% {
        transform: perspective(1000px) rotateY(270deg) scale(1.15);
        opacity: 0.8;
    }
    100% {
        transform: perspective(1000px) rotateY(360deg) scale(1);
        opacity: 1;
    }
}

.tarot-card.flipping {
    animation: cardFlip 1s cubic-bezier(0.4, 0.0, 0.2, 1);
    transform-style: preserve-3d;
}

/* 翻牌後的閃光效果 */
@keyframes reveal-glow {
    0%, 100% {
        box-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
    }
    50% {
        box-shadow: 0 0 40px rgba(255, 215, 0, 0.8), 0 0 60px rgba(255, 215, 0, 0.6);
    }
}

.tarot-card.revealed {
    animation: reveal-glow 1.5s ease-in-out;
}

/* 脈衝動畫 (用於按鈕) */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.btn-primary:active {
    animation: pulse 0.3s ease;
}

/* 晃動動畫 (用於錯誤提示) */
@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

/* 選中卡片的脈衝動畫 */
@keyframes selectedPulse {
    0%, 100% {
        box-shadow: 0 15px 35px rgba(255, 215, 0, 0.5);
    }
    50% {
        box-shadow: 0 20px 45px rgba(255, 215, 0, 0.8), 0 0 30px rgba(255, 215, 0, 0.4);
    }
}

/* 旋轉動畫 */
@keyframes rotate360 {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* 閃爍光暈效果 (用於選中的牌) */
.tarot-card.selected {
    position: relative;
    overflow: visible;
}

.tarot-card.selected::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 120%;
    height: 120%;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, rgba(255, 215, 0, 0.3) 0%, transparent 70%);
    border-radius: 50%;
    animation: glowPulse 2s ease-in-out infinite;
    z-index: -1;
}

@keyframes glowPulse {
    0%, 100% {
        opacity: 0.5;
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        opacity: 0.8;
        transform: translate(-50%, -50%) scale(1.1);
    }
}

/* 載入動畫 */
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-left: 10px;
}

/* 滑動進入動畫 */
@keyframes slideInFromBottom {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 微妙的呼吸動畫 */
@keyframes subtleFloat {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-3px);
    }
}

.tarot-card {
    animation: slideInFromBottom 0.5s ease backwards;
}

.tarot-card:not(.selected):not(.revealed):not(.flipping):hover {
    animation: subtleFloat 2s ease-in-out infinite;
}

/* 錯落的進入動畫延遲 */
.tarot-card:nth-child(1) { animation-delay: 0.02s; }
.tarot-card:nth-child(2) { animation-delay: 0.04s; }
.tarot-card:nth-child(3) { animation-delay: 0.06s; }
.tarot-card:nth-child(4) { animation-delay: 0.08s; }
.tarot-card:nth-child(5) { animation-delay: 0.1s; }
.tarot-card:nth-child(6) { animation-delay: 0.12s; }
.tarot-card:nth-child(7) { animation-delay: 0.14s; }
.tarot-card:nth-child(8) { animation-delay: 0.16s; }
.tarot-card:nth-child(9) { animation-delay: 0.18s; }
.tarot-card:nth-child(10) { animation-delay: 0.2s; }
.tarot-card:nth-child(11) { animation-delay: 0.22s; }
.tarot-card:nth-child(12) { animation-delay: 0.24s; }

/* 改善 focus 狀態 (無障礙支援) */
.tarot-card:focus,
.btn:focus {
    outline: 3px solid var(--accent-sand-gold);
    outline-offset: 2px;
}

/* 暗黑模式支援 */
@media (prefers-color-scheme: dark) {
    body {
        background: linear-gradient(135deg, #2D1B4E 0%, #1A0B2E 100%);
    }

    .container {
        background: #1F1F1F;
        color: #E0E0E0;
    }

    .question-section textarea {
        background: #2A2A2A;
        color: #E0E0E0;
        border-color: #404040;
    }

    .tarot-card {
        background: #2A2A2A;
        border-color: #404040;
        color: #E0E0E0;
    }

    .btn-secondary {
        background: #3A3A3A;
        color: #E0E0E0;
    }

    .footer {
        color: #999;
        border-top-color: #404040;
    }
}

/* 平滑滾動 */
html {
    scroll-behavior: smooth;
}

/* 選取文字顏色 */
::selection {
    background: var(--accent-sand-gold);
    color: white;
}

::-moz-selection {
    background: var(--accent-sand-gold);
    color: white;
}

/* ========================================
   抽卡流程優化 - 加載遮罩動畫
   ======================================== */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(20px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.loading-overlay.show {
    opacity: 1;
}

.loading-content {
    text-align: center;
    color: var(--accent-light-gold);
    max-width: 90%;
}

.crystal-ball {
    font-size: 6em;
    animation: float 2s ease-in-out infinite, crystalGlow 3s ease-in-out infinite;
    margin-bottom: 30px;
    filter: drop-shadow(0 0 30px var(--accent-sand-gold));
}

@keyframes crystalGlow {
    0%, 100% {
        filter: drop-shadow(0 0 20px rgba(201, 169, 98, 0.4));
    }
    50% {
        filter: drop-shadow(0 0 50px rgba(212, 175, 101, 0.9));
    }
}

.loading-text {
    font-size: 1.8em;
    font-weight: 700;
    margin-bottom: 30px;
    color: var(--accent-champagne);
    animation: textPulse 1.5s ease-in-out infinite;
    text-shadow: 0 0 10px var(--accent-sand-gold);
}

@keyframes textPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(0.98);
    }
}

.loading-progress {
    width: 320px;
    margin: 0 auto;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(26, 26, 26, 0.6);
    border: 1px solid var(--accent-bronze);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

.progress-fill {
    height: 100%;
    background: var(--gradient-gold-shine);
    background-size: 200% 100%;
    width: 0%;
    transition: width 0.5s cubic-bezier(0.4, 0.0, 0.2, 1);
    box-shadow: 0 0 15px var(--accent-sand-gold);
    animation: progressShimmer 2s linear infinite;
}

@keyframes progressShimmer {
    0% {
        background-position: 0% 50%;
    }
    100% {
        background-position: 200% 50%;
    }
}

/* ========================================
   慶祝動畫
   ======================================== */

.celebration-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.celebration-overlay.show {
    opacity: 1;
}

.celebration-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--accent-champagne);
    text-shadow: 0 3px 15px rgba(0, 0, 0, 0.9), 0 0 20px var(--accent-sand-gold);
    z-index: 2;
}

.success-icon {
    font-size: 7em;
    animation: successBounce 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    filter: drop-shadow(0 0 40px var(--accent-sand-gold));
}

@keyframes successBounce {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    70% {
        transform: scale(1.3) rotate(30deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

.celebration-title {
    font-size: 2.5em;
    font-weight: 800;
    margin: 25px 0 15px;
    color: var(--accent-light-gold);
    animation: fadeInUp 0.5s ease 0.2s both;
    letter-spacing: 1px;
}

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

.celebration-text {
    font-size: 1.3em;
    font-weight: 500;
    color: var(--accent-bronze);
    animation: fadeInUp 0.5s ease 0.4s both;
}

.confetti-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
    z-index: 1;
}

.confetti {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 2px;
    animation: confettiFall 3s ease-out forwards;
}

@keyframes confettiFall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* ========================================
   插槽卡片3D翻轉優化
   ======================================== */

.slot-card {
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.slot-card.flipping {
    animation: slot3DFlip 0.6s ease-in-out;
}

@keyframes slot3DFlip {
    0% {
        transform: rotateY(0deg) scale(1);
    }
    50% {
        transform: rotateY(90deg) scale(1.15);
        box-shadow: 0 25px 50px rgba(107, 70, 193, 0.6);
    }
    100% {
        transform: rotateY(180deg) scale(1);
    }
}

.slot-card.revealed {
    background: white;
    border: 3px solid var(--accent-sand-gold);
    animation: revealGlow 1.2s ease-in-out;
}

@keyframes revealGlow {
    0%, 100% {
        box-shadow: 0 0 25px rgba(107, 70, 193, 0.5);
    }
    50% {
        box-shadow: 0 0 50px rgba(107, 70, 193, 0.9),
                    0 0 80px rgba(255, 215, 0, 0.6);
    }
}

.revealed-card {
    padding: 20px 15px;
    text-align: center;
    animation: cardContentAppear 0.4s ease 0.3s both;
}

@keyframes cardContentAppear {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.revealed-card .card-emoji {
    font-size: 3.5em;
    margin-bottom: 12px;
    animation: emojiPop 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) 0.5s both;
}

@keyframes emojiPop {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    70% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.revealed-card .card-name {
    font-size: 1.1em;
    font-weight: 700;
    color: var(--accent-sand-gold);
    animation: textSlideIn 0.4s ease 0.7s both;
}

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

/* 按鈕加載狀態 */
.btn-primary.loading {
    position: relative;
    pointer-events: none;
}

.btn-primary.loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 22px;
    height: 22px;
    margin: -11px 0 0 -11px;
    border: 3px solid white;
    border-top-color: transparent;
    border-radius: 50%;
    animation: buttonSpin 0.8s linear infinite;
}

@keyframes buttonSpin {
    to {
        transform: rotate(360deg);
    }
}

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