:root {
    --taiji-stay-time: 20s;        /* 太極圖停留時間（例如 3s, 2.5s, 5s） */
    --taiji-fade-duration: 0.8s;  /* 淡出過程所需時間 */
    --primary-color: #8c2a2a;      /* 朱紅/古紅 */
    --primary-dark: #611b1b;       /* 暗紅 */
    --accent-gold: #c5a059;        /* 鎏金 */
    --accent-gold-light: #f5ece0;  /* 淺金米色 */
    --bg-color: #f2ede4;           /* 宣紙復古背景 */
    --paper-bg: #fdfaf3;          /* 籤文紙張色 */
    --ink-black: #2c2523;          /* 墨黑 */
    --border-color: #dcd1be;       /* 古風邊框 */
    --ai-purple: #4a2e80;          /* AI 靈感紫 */
}

body {
    font-family: "Noto Serif TC", "Songti SC", "STSong", "DFKai-SB", "KaiTi", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, serif;
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(rgba(197, 160, 89, 0.15) 1px, transparent 1px),
        radial-gradient(rgba(140, 42, 42, 0.08) 1px, var(--bg-color) 1px);
    background-size: 24px 24px;
    background-position: 0 0, 12px 12px;
    color: var(--ink-black);
    max-width: 720px;
    margin: 0 auto;
    padding: 20px 15px;
    line-height: 1.7;
    -webkit-user-select: none; /* Safari / Chrome */
    -moz-user-select: none;    /* Firefox */
    -ms-user-select: none;     /* IE / Edge */
    user-select: none;         /* 標準語法 */
}

.container {
    background: #faf6ee;
    padding: 20px 14px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 30px rgba(60, 40, 20, 0.12);
    position: relative;
}

.container::before {
    content: "";
    position: absolute;
    top: 6px; left: 6px; right: 6px; bottom: 6px;
    border: 1px solid rgba(197, 160, 89, 0.5);
    border-radius: 6px;
    pointer-events: none;
}

.header-box {
    text-align: center;
    position: relative;
    margin-bottom: 20px;
}

h1 {
    color: var(--primary-color);
    font-size: 28px;
    letter-spacing: 4px;
    margin: 0 0 6px 0;
    font-weight: bold;
    text-shadow: 1px 1px 0px rgba(255,255,255,0.8);
}

.subtitle {
    text-align: center;
    color: #7a6b5d;
    font-size: 14px;
    letter-spacing: 2px;
}

/* 占問事項卡片 */
.question-card {
    background: #fdfbf7;
    border: 1.5px solid var(--accent-gold);
    border-radius: 8px;
    padding: 16px 18px;
    margin-bottom: 20px;
    box-shadow: inset 0 0 10px rgba(197, 160, 89, 0.08);
}

.question-label {
    font-weight: bold;
    color: var(--primary-color);
    font-size: 15px;
    margin-bottom: 8px;
}

.question-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: #ffffff;
    font-family: inherit;
    font-size: 14.5px;
    color: var(--ink-black);
    box-sizing: border-box;
    resize: vertical;
    min-height: 60px;
    outline: none;
    transition: border-color 0.3s;
}

.question-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 5px rgba(140, 42, 42, 0.2);
}

.quick-tags {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.quick-tag-label {
    font-size: 12.5px;
    color: #888;
}

.tag-btn {
    background: #f4ebd9;
    border: 1px solid #e0d1b8;
    color: #615243;
    padding: 4px 10px;
    border-radius: 14px;
    font-size: 12.5px;
    cursor: pointer;
    transition: all 0.2s;
}

.tag-btn:hover {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

/* 語音輸入按鈕樣式 */
.voice-btn {
    background: #f4ebd9;
    border: 1px solid var(--accent-gold);
    color: var(--primary-color);
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.25s ease;
}

.voice-btn:hover {
    background: var(--accent-gold-light);
}

.voice-btn.recording {
    background: #d32f2f;
    color: #ffffff;
    border-color: #b71c1c;
    animation: pulse-red 1.2s infinite;
}

@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(211, 47, 47, 0.6); }
    70% { box-shadow: 0 0 0 8px rgba(211, 47, 47, 0); }
    100% { box-shadow: 0 0 0 0 rgba(211, 47, 47, 0); }
}

/* 註解與打賞按鈕 */
.annotation-btn-wrap {
    text-align: center;
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

button.annotation-btn {
    background-color: #f4ebd9;
    color: var(--primary-color);
    border: 1px solid var(--accent-gold);
    padding: 6px 18px;
    font-size: 14px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
}

button.annotation-btn:hover {
    background-color: var(--primary-color);
    color: #ffffff;
    border-color: var(--primary-color);
}

button.reward-btn-top {
    background: linear-gradient(135deg, #d32f2f 0%, #9a0007 100%);
    color: #ffffff;
    border: 1px solid #d32f2f;
}

button.reward-btn-top:hover {
    background: #b71c1c;
    border-color: #b71c1c;
}

/* 頁籤選單 */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--accent-gold);
    margin-bottom: 25px;
    gap: 10px;
}

.tab-btn {
    flex: 1;
    padding: 10px;
    text-align: center;
    background: #ede4d4;
    border: 1px solid var(--border-color);
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    font-size: 16px;
    font-weight: bold;
    color: #665b50;
    cursor: pointer;
    transition: all 0.3s;
}

.tab-btn.active {
    background: var(--primary-color);
    color: #ffffff;
    border-color: var(--primary-color);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* 金錢卦搖卦區 */
.shake-status-box {
    background: #f5ede0;
    border: 1px dashed var(--accent-gold);
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    margin-bottom: 20px;
}

.progress-text {
    font-size: 18px;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 15px;
}

.coins-stage {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 25px;
    min-height: 95px;
    margin: 15px 0;
    perspective: 800px;
}

.coin-img-wrapper {
    width: 75px; height: 75px;
    border-radius: 50%;
    box-shadow: 0 4px 10px rgba(0,0,0,0.25);
    transition: transform 0.8s ease-out;
    transform-style: preserve-3d;
    background-color: transparent;
}

.coin-img-wrapper img {
    width: 100%; height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

@keyframes coinFlipReal {
    0% { transform: translateY(0) rotateX(0deg) rotateY(0deg) scale(1); }
    30% { transform: translateY(-50px) rotateX(720deg) rotateY(360deg) scale(1.15); }
    60% { transform: translateY(10px) rotateX(1440deg) rotateY(720deg) scale(0.95); }
    80% { transform: translateY(-15px) rotateX(1800deg) rotateY(900deg) scale(1.05); }
    100% { transform: translateY(0) rotateX(2160deg) rotateY(1080deg) scale(1); }
}

.coin-img-wrapper.shaking { animation: coinFlipReal 0.8s ease-in-out; }

.coins-detail {
    font-size: 15px;
    color: #555;
    min-height: 24px;
    margin-top: 10px;
}

.input-group {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    justify-content: center;
}

input[type="number"] {
    width: 85px;
    padding: 10px;
    font-size: 16px;
    border: 1px solid var(--accent-gold);
    background-color: #fcf9f2;
    border-radius: 6px;
    text-align: center;
    color: var(--ink-black);
    font-weight: bold;
}

.btn-div {
    text-align: center;
    margin: 20px 0;
    display: flex;
    justify-content: center;
    gap: 12px;
}

button.action-btn {
    background: linear-gradient(180deg, #9e3232 0%, #7a2222 100%);
    color: #fdfaf3;
    border: 1px solid var(--accent-gold);
    padding: 12px 28px;
    font-size: 16px;
    font-weight: bold;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(122, 34, 34, 0.3);
}

button.reset-btn {
    background: linear-gradient(180deg, #388e3c 0%, #2e7d32 100%); /* 🟢 開通清爽翡翠綠漸層 */
    color: #ffffff;
    border: 1px solid #1b5e20;
    padding: 12px 20px;
    font-size: 16px;
    font-weight: bold;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(46, 125, 50, 0.3);
}

.hexagram-display {
    display: flex;
    flex-direction: column-reverse;
    margin: 20px 0;
    background: var(--accent-gold-light);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--accent-gold);
}

/* 解卦結果籤文框 */
.result-box-fortune {
    margin-top: 20px;
    background-color: var(--paper-bg);
    border: 1.5px solid var(--primary-color);
    border-radius: 8px;
    padding: 16px 12px;
    position: relative;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

.result-box-fortune::before {
    display: none;
}

.stamp-seal {
    position: absolute;
    top: 22px; right: 22px;
    width: 58px; height: 58px;
    border: 2px solid #b82626;
    color: #b82626;
    font-family: "STKaiti", "DFKai-SB", "KaiTi", serif;
    font-weight: bold;
    font-size: 16px;
    display: flex;
    align-items: center; justify-content: center;
    text-align: center;
    line-height: 1.15;
    border-radius: 8px;
    transform: rotate(-8deg);
    opacity: 0.85;
    background: rgba(253, 250, 243, 0.85);
    pointer-events: none;
}

.slip-header {
    text-align: center;
    border-bottom: 2px dashed var(--accent-gold);
    padding-bottom: 16px;
    margin-bottom: 25px;
}

.slip-title {
    color: var(--primary-color);
    font-size: 24px;
    font-weight: bold;
    letter-spacing: 3px;
    margin: 0;
}

.gua-cards-container {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    justify-content: center;
    margin-bottom: 25px;
}

.gua-card-main {
    flex: 1;
    min-width: 280px;
    background: #faf4e8;
    border: 1px solid #ebdcc5;
    border-top: 4px solid var(--primary-color);
    padding: 16px;
    border-radius: 6px;
}

.gua-card-changed {
    flex: 1;
    min-width: 280px;
    background: #f1f6f2;
    border: 1px solid #cce3d2;
    border-top: 4px solid #2e7d32;
    padding: 16px;
    border-radius: 6px;
}

.notice-banner {
    margin-bottom: 25px;
    padding: 16px 20px;
    background: #fcf4dd;
    border-left: 5px solid #d99b00;
    border-right: 1px solid #f0e2be;
    border-top: 1px solid #f0e2be;
    border-bottom: 1px solid #f0e2be;
    border-radius: 4px;
    color: #7a5200;
    font-weight: bold;
    font-size: 15px;
    line-height: 1.6;
}

/* 解卦 Tab 頁籤 */
.gua-tabs-wrapper { margin-bottom: 25px; }

.gua-tabs {
    display: flex;
    gap: 6px;
    border-bottom: 2px solid var(--accent-gold);
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.gua-tab-btn {
    padding: 9px 16px;
    background-color: #f0e6d6;
    border: 1px solid var(--border-color);
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    font-size: 14.5px;
    font-weight: bold;
    color: #5c4e43;
    cursor: pointer;
    transition: all 0.25s ease;
}

.gua-tab-btn:hover {
    background-color: #e8dbb8;
    color: var(--primary-color);
}

.gua-tab-btn.active {
    background-color: var(--primary-color);
    color: #ffffff;
    border-color: var(--primary-color);
}

.gua-tab-btn.ai-tab-btn.active {
    background: linear-gradient(135deg, #5b33a8 0%, #3a1c71 100%);
    border-color: #5b33a8;
}

.gua-tab-content {
    display: none;
    animation: fadeIn 0.2s ease-out;
}

.gua-tab-content.active { display: block; }

.gua-text-block {
    background: #ffffff;
    border: 1px solid #e8decb;
    padding: 20px 22px;
    border-radius: 6px;
}

.gua-section { margin-bottom: 18px; }
.gua-section:last-child { margin-bottom: 0; }

.gua-section-title {
    font-weight: bold;
    color: var(--primary-color);
    font-size: 16px;
    margin-bottom: 6px;
}

.gua-original-text {
    font-size: 16px;
    line-height: 1.8;
    color: #2b2421;
    background: #faf6ee;
    padding: 10px 14px;
    border-radius: 4px;
    border-left: 3px solid var(--accent-gold);
    margin-bottom: 8px;
    white-space: pre-wrap;
}

.gua-explanation-text {
    font-size: 15px;
    line-height: 1.85;
    color: #443c38;
    white-space: pre-wrap;
}

/* 變爻/動爻區塊 */
.moving-lines-box {
    background: #faf5eb;
    border: 1px solid #e5d8bf;
    border-left: 4px solid var(--primary-color);
    border-radius: 6px;
    padding: 18px 20px;
    margin-top: 20px;
}

.moving-lines-header {
    font-size: 17px;
    font-weight: bold;
    color: var(--primary-color);
    border-bottom: 1px dashed var(--accent-gold);
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.moving-lines-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.yao-card {
    background: #ffffff;
    border: 1px solid #ebdcc5;
    border-radius: 6px;
    padding: 14px 16px;
}

.yao-title {
    font-size: 15.5px;
    font-weight: bold;
    color: #8c2a2a;
    margin-bottom: 8px;
}

.yao-field {
    font-size: 14.5px;
    line-height: 1.75;
    color: #332d29;
    margin-bottom: 4px;
}

/* AI 靈卦 Tab 頁籤內容卡片 */
.ai-card {
    background: linear-gradient(135deg, #fbf7f0 0%, #f3ebff 100%);
    border: 1.5px solid #d3c2eb;
    border-radius: 10px;
    padding: 20px;
    position: relative;
    box-shadow: 0 4px 12px rgba(74, 46, 128, 0.08);
}

.ai-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    border-bottom: 1px dashed #c4b0e3;
    padding-bottom: 8px;
    flex-wrap: wrap;
    gap: 8px;
}

.ai-title {
    font-size: 18px;
    font-weight: bold;
    color: var(--ai-purple);
}

.reward-btn-inline {
    background: linear-gradient(135deg, #d32f2f 0%, #9a0007 100%);
    color: #ffffff;
    border: none;
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(211, 47, 47, 0.3);
    transition: all 0.2s ease;
}

.reward-btn-inline:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(211, 47, 47, 0.4);
}

.ai-question-recap {
    font-size: 14.5px;
    color: #4a4453;
    margin-bottom: 16px;
    background: rgba(255, 255, 255, 0.8);
    padding: 10px 14px;
    border-radius: 6px;
    border-left: 3px solid var(--ai-purple);
}

.ai-btn {
    background: linear-gradient(135deg, #5b33a8 0%, #3a1c71 100%);
    color: #ffffff;
    border: 1px solid #9d7bd8;
    padding: 11px 24px;
    font-size: 15.5px;
    font-weight: bold;
    border-radius: 25px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(58, 28, 113, 0.25);
    transition: all 0.3s;
}

.ai-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(58, 28, 113, 0.35);
}

.ai-result-content {
    margin-top: 18px;
    background: #ffffff;
    border: 1px solid #dcd1be;
    border-radius: 8px;
    padding: 20px;
    font-size: 15px;
    line-height: 1.85;
    color: #2b2421;
}

.ai-result-content h1, .ai-result-content h2, .ai-result-content h3 {
    color: var(--ai-purple);
    margin-top: 16px;
    margin-bottom: 8px;
}

.ai-result-content ul, .ai-result-content ol {
    padding-left: 22px;
}

/* Modal 彈窗 */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.65);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

.modal-content {
    background: #fdfaf3;
    border: 2px solid var(--accent-gold);
    max-width: 520px;
    width: 100%;
    max-height: 85vh;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 10px 35px rgba(0,0,0,0.4);
    position: relative;
    overflow-y: auto;
    animation: fadeIn 0.25s ease-out;
}

/* Modal 關閉按鈕通用的改進 */
.modal-close {
    position: absolute;
    top: 12px; right: 16px;
    font-size: 22px;
    font-weight: bold;
    color: var(--primary-color);
    background: #f4ebd9;
    border: 1.5px solid var(--accent-gold);
    width: 30px;
    height: 30px;
    line-height: 26px;
    text-align: center;
    border-radius: 50%;
    cursor: pointer;
    z-index: 20;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.15);
}

.modal-close:hover {
    background: var(--primary-color);
    color: #ffffff;
    border-color: var(--primary-color);
    transform: scale(1.1);
}

.modal-title {
    color: var(--primary-color);
    font-size: 20px;
    font-weight: bold;
    margin-top: 0; margin-bottom: 15px;
    border-bottom: 2px solid var(--accent-gold);
    padding-bottom: 8px;
    text-align: center;
}

/* 打賞 Modal 樣式 */
.reward-modal-box {
    max-width: 560px !important;
    background: #fdfaf5 !important;
    border: 1.5px solid #d4c3a3 !important;
    padding: 24px 20px !important;
    border-radius: 12px !important;
}

.reward-subtitle {
    text-align: center;
    font-size: 13.5px;
    color: #6b5e52;
    margin-top: -6px;
    margin-bottom: 20px;
}

.reward-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.reward-card {
    background: #ffffff;
    border: 1px solid #e8e0d0;
    border-radius: 10px;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 12px rgba(140, 42, 42, 0.04);
    transition: all 0.25s ease;
}

.reward-card:hover {
    box-shadow: 0 6px 16px rgba(140, 42, 42, 0.1);
    transform: translateY(-2px);
}

.reward-badge {
    font-size: 13px;
    font-weight: bold;
    padding: 3px 12px;
    border-radius: 12px;
    margin-bottom: 10px;
    letter-spacing: 0.5px;
}

.payme-badge { background: #ffebee; color: #eb0029; }
.alipay-badge { background: #e6f4ff; color: #1677ff; }
.wechat-badge { background: #e6f7ed; color: #07c160; }

.qr-container {
    width: 100%;
    aspect-ratio: 1 / 1;
    max-width: 150px;
    background: #ffffff;
    border: 1px solid #f0f0f0;
    border-radius: 8px;
    padding: 6px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.reward-qr {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 4px;
}

.reward-action-btn {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 6px 0;
    font-size: 12px;
    font-weight: bold;
    text-align: center;
    text-decoration: none;
    border-radius: 16px;
    transition: all 0.2s;
    box-sizing: border-box;
}

.payme-btn {
    background: #eb0029;
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(235, 0, 41, 0.25);
}
.payme-btn:hover { background: #c40022; color: #ffffff; }

.alipay-btn {
    background: #1677ff;
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(22, 119, 255, 0.25);
}
.alipay-btn:hover { background: #0958d9; color: #ffffff; }

.wechat-btn {
    background: #07c160;
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(7, 193, 96, 0.25);
}
.wechat-btn:hover { background: #059649; color: #ffffff; }

.reward-tip {
    font-size: 11.5px;
    color: #999999;
    margin-top: 8px;
    text-align: center;
}

.modal-footer-wrap {
    margin-top: 22px;
    text-align: center;
}

.btn-close-reward {
    background: linear-gradient(180deg, #9e3232 0%, #7a2222 100%);
    color: #fdfaf3;
    border: 1px solid #c5a059;
    padding: 8px 32px;
    font-size: 14px;
    font-weight: bold;
    border-radius: 20px;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(122, 34, 34, 0.25);
    transition: all 0.2s ease;
}

.btn-close-reward:hover {
    background: #611b1b;
}

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

.loading-spin {
    display: inline-block;
    animation: spin 1.5s infinite linear;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.download-jpg-btn {
    background: linear-gradient(135deg, #2e7d32 0%, #1b5e20 100%);
    color: #ffffff;
    border: 1px solid #81c784;
    padding: 11px 22px;
    font-size: 15.5px;
    font-weight: bold;
    border-radius: 25px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(46, 125, 50, 0.25);
    transition: all 0.3s ease;
}

.download-jpg-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(46, 125, 50, 0.35);
}

.download-jpg-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.voice-lang-select {
    background: #f4ebd9;
    border: 1px solid var(--accent-gold);
    color: var(--primary-color);
    padding: 3px 8px;
    border-radius: 14px;
    font-size: 12.5px;
    font-weight: bold;
    outline: none;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.25s ease;
}

.voice-lang-select:hover {
    background: var(--accent-gold-light);
}

.gua-visual-wrapper {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    box-sizing: border-box;
}

.gua-line-row {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.line-label {
    font-size: 0.73rem;
    color: #444;
    font-weight: bold;
    white-space: nowrap;
    text-align: right;
}

.line-bar-box {
    width: 80px;
    flex-shrink: 0;
    height: 9px;
}

.yang-line, .yin-line {
    width: 100%;
    height: 100%;
}

.yang-line {
    border-radius: 2px;
}

.yin-line {
    display: flex;
    justify-content: space-between;
}

.yin-line div {
    width: 44%;
    height: 100%;
    border-radius: 2px;
}

.line-normal { background-color: #8c2a2a; }
.line-changed { background-color: #2e7d32; }
.line-moving { background-color: #d32f2f; }

@media (max-width: 360px) {
    .gua-line-row {
        gap: 5px;
    }
    .line-label {
        font-size: 0.66rem;
    }
    .line-bar-box {
        width: 70px;
    }
}

.queue-box {
    background: #fffdf9;
    border: 1.5px dashed var(--accent-gold);
    border-radius: 8px;
    padding: 20px 15px;
    text-align: center;
    margin-top: 12px;
    box-shadow: inset 0 0 10px rgba(197, 160, 89, 0.05);
}

.queue-status-title {
    font-size: 16px;
    font-weight: bold;
    color: var(--ai-purple);
    margin-bottom: 6px;
}

.queue-number-display {
    font-size: 26px;
    font-weight: bold;
    color: var(--primary-color);
    margin: 12px 0;
    letter-spacing: 1px;
}

.queue-hint {
    font-size: 12.5px;
    color: #7a6b5d;
    margin-bottom: 14px;
}

.btn-cancel-queue {
    background: #888888;
    color: #ffffff;
    border: none;
    padding: 7px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: bold;
    transition: all 0.2s ease;
}

.btn-cancel-queue:hover {
    background: #666666;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* ==========================================
   ☯️ 右上角按鈕區域樣式（須知 + 打賞）
   ========================================== */
.top-right-btns-container {
    position: absolute;
    top: 14px;
    right: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 10;
}

.guide-corner-btn {
    background: #fdfaf3;
    border: 1.5px solid var(--accent-gold);
    color: var(--primary-color);
    padding: 4px 12px;
    border-radius: 20px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    box-shadow: 0 2px 6px rgba(197, 160, 89, 0.2);
    transition: all 0.25s ease;
    width: 100%;
    box-sizing: border-box;
}

.guide-corner-btn:hover {
    background: var(--primary-color);
    color: #ffffff;
    border-color: var(--primary-color);
    box-shadow: 0 4px 10px rgba(140, 42, 42, 0.3);
    transform: translateY(-1px);
}

.guide-btn-icon {
    font-size: 16px;
    line-height: 1;
}

.guide-btn-label {
    font-size: 12.5px;
    font-weight: bold;
    letter-spacing: 1px;
}

/* 古風小冊子目錄索引樣式 */
.booklet-index-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.index-nav-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f8f1e5;
    border: 1px solid var(--accent-gold);
    border-radius: 8px;
    padding: 9px 12px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
    width: 100%;
    box-sizing: border-box;
    font-family: inherit;
    color: var(--ink-black);
}

.index-nav-item:hover {
    background: var(--primary-color);
    color: #ffffff;
    border-color: var(--primary-color);
    transform: translateX(4px);
    box-shadow: 0 3px 8px rgba(140, 42, 42, 0.25);
}

.index-nav-item .index-num {
    font-weight: bold;
    font-size: 13px;
    color: var(--primary-color);
    background: rgba(197, 160, 89, 0.25);
    width: 24px;
    height: 24px;
    line-height: 24px;
    text-align: center;
    border-radius: 50%;
    margin-right: 10px;
    flex-shrink: 0;
}

.index-nav-item:hover .index-num {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.25);
}

.index-nav-item .index-title {
    font-size: 13.5px;
    font-weight: bold;
    flex: 1;
    letter-spacing: 0.5px;
}

.index-nav-item .index-arrow {
    font-size: 12px;
    opacity: 0.7;
    margin-left: 8px;
}

.page-top-bar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 8px;
}

.btn-back-index {
    background: #f4ebd9;
    border: 1px solid var(--accent-gold);
    color: var(--primary-color);
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-back-index:hover {
    background: var(--primary-color);
    color: #ffffff;
    border-color: var(--primary-color);
}

/* ==========================================
   📖 古書線裝小冊子 Modal 樣式 (已修復頁尾跑位問題)
   ========================================== */
.booklet-modal {
    background: #fdfaf3;
    border: 2px solid var(--accent-gold);
    max-width: 580px;
    width: 100%;
    height: 80vh;
    max-height: 85vh;
    border-radius: 10px;
    padding: 24px 20px 20px 42px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    position: relative;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    animation: fadeIn 0.25s ease-out;
    overflow: hidden; /* 防止內容超出彈窗 */
}

.booklet-binding {
    position: absolute;
    top: 0;
    left: 0;
    width: 28px;
    height: 100%;
    background: #eedfca;
    border-right: 2px solid #c5a059;
    border-radius: 8px 0 0 8px;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    padding: 30px 0;
    box-sizing: border-box;
}

.thread-hole {
    width: 8px;
    height: 8px;
    background: #3c2a1e;
    border-radius: 50%;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.6);
}

.booklet-content-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0; /* 關鍵修復：防止 Flex 子元素撐開容器 */
}

.booklet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1.5px solid var(--accent-gold);
    padding-bottom: 8px;
    padding-right: 36px; /* 關鍵修復：預留右側空間給關閉按鈕，避免標題文字被遮擋 */
    margin-bottom: 14px;
    flex-shrink: 0; /* 保持頁首不被壓縮 */
}

.booklet-title {
    color: var(--primary-color);
    font-size: 19px;
    font-weight: bold;
    margin: 0;
    letter-spacing: 1px;
}

.booklet-seal {
    font-size: 11px;
    color: #b82626;
    border: 1px solid #b82626;
    padding: 2px 6px;
    border-radius: 4px;
    transform: rotate(-5deg);
    font-weight: bold;
    line-height: 1.1;
    text-align: center;
}

.booklet-body {
    flex: 1;
    min-height: 0; /* 關鍵修復：讓內文可以在固定區域內獨立滾動 */
    overflow-y: auto;
    font-size: 14.5px;
    line-height: 1.85;
    color: var(--ink-black);
    padding-right: 8px;
    transition: opacity 0.2s ease-in-out;
}

.booklet-body.page-flip {
    opacity: 0;
}

.booklet-body h1, .booklet-body h2, .booklet-body h3 {
    color: var(--primary-color);
    margin-top: 10px;
    margin-bottom: 8px;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 4px;
}

.booklet-body blockquote {
    margin: 10px 0;
    padding: 8px 14px;
    background: #f5ede0;
    border-left: 3px solid var(--accent-gold);
    color: #5c4e43;
    font-style: normal;
}

.booklet-body ul, .booklet-body ol {
    padding-left: 20px;
    margin-bottom: 10px;
}

.booklet-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px dashed var(--border-color);
    padding-top: 12px;
    margin-top: 12px;
    flex-shrink: 0; /* 關鍵修復：固定頁尾按鈕不被推擠到螢幕外 */
}

.booklet-nav-btn {
    background: #f4ebd9;
    border: 1px solid var(--accent-gold);
    color: var(--primary-color);
    padding: 4px 14px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.booklet-nav-btn:hover:not(:disabled) {
    background: var(--primary-color);
    color: #ffffff;
    border-color: var(--primary-color);
}

.booklet-nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.booklet-page-num {
    font-size: 13px;
    color: #7a6b5d;
    font-weight: bold;
    letter-spacing: 1px;
}

@media (max-width: 480px) {
    .booklet-modal {
        padding: 20px 14px 16px 36px;
        height: 85vh;
    }
    .booklet-binding {
        width: 22px;
    }
    .thread-hole {
        width: 6px;
        height: 6px;
    }
}

/* ==========================================
   ☯️ 網頁開啟太極 Loading 畫面與動畫樣式 (圖片模式 & 靜謐宇宙風)
   ========================================== */

/* 全螢幕遮罩：靜謐宇宙星雲浮水印背景 */
#taiji-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    /* 替換為你的宇宙背景圖片 (並加上暗色遮罩確保文字與太極圖清晰) */
    background: linear-gradient(rgba(0,0,0,0.6), rgba(0,0,0,0.6)), 
                url('assets/images/space_bg.jpg') no-repeat center / cover;
    background-size: cover;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 99999;
    opacity: 1;
    transition: opacity var(--taiji-fade-duration, 0.8s) ease-in-out, visibility var(--taiji-fade-duration, 0.8s) ease-in-out;
    cursor: pointer;
    overflow: hidden;
}

/* 宇宙星辰浮水印 */
#taiji-loading-overlay::before {
    content: "";
    position: absolute;
    width: 200%;
    height: 200%;
    background-image: 
        radial-gradient(1.5px 1.5px at 10px 20px, rgba(255, 255, 255, 0.4), rgba(0,0,0,0)),
        radial-gradient(2px 2px at 40px 70px, rgba(255, 255, 255, 0.2), rgba(0,0,0,0)),
        radial-gradient(1.5px 1.5px at 90px 40px, rgba(195, 160, 89, 0.3), rgba(0,0,0,0)),
        radial-gradient(2px 2px at 160px 120px, rgba(255, 255, 255, 0.3), rgba(0,0,0,0));
    background-repeat: repeat;
    background-size: 250px 250px;
    opacity: 0.4;
    pointer-events: none;
}

#taiji-loading-overlay.fade-out {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* 太極圖容器：直接載入 PNG 圖片並平穩旋轉 */
.taiji-loader {
    width: 220px;
    height: 220px;
    border-radius: 50%;
    position: relative;
    /* 載入水墨太極 PNG 圖片 */
    background: url('assets/images/taiji_ink.png') no-repeat center / contain;
    /* 柔和外發光，增加氣場 */
    filter: drop-shadow(0 0 20px rgba(255, 255, 255, 0.15));
    /* 旋轉動畫：勻速、緩慢平穩 */
    animation: taiji-spin 4s linear infinite;
}
/* 確保清除舊的純 CSS 圓圈樣式影響 */
.taiji-loader::before,
.taiji-loader::after {
    display: none !important;
}

/* 文字提示：柔和鎏金 */
.taiji-loading-text {
    margin-top: 30px;
    color: #c5a059;
    font-size: 16px;
    letter-spacing: 4px;
    font-weight: 500;
    text-shadow: 0 0 10px rgba(197, 160, 89, 0.3);
    z-index: 2;
}

.taiji-loading-hint {
    margin-top: 8px;
    color: #7a8290;
    font-size: 12px;
    letter-spacing: 1px;
    z-index: 2;
}

/* 太極旋轉關鍵幀 */
@keyframes taiji-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ==========================================
   現代時代感分段切換器 (Modern Segmented Control)
   ========================================== */
   .meihua-switch-container {
    background: #e8dfcf;
    border: 1px solid var(--accent-gold);
    border-radius: 30px;
    padding: 4px;
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.08);
}

.meihua-switch-btn {
    flex: 1;
    border: none;
    background: transparent;
    color: #615243;
    padding: 10px 16px;
    border-radius: 25px;
    font-size: 14.5px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
}

.meihua-switch-btn:hover:not(.active) {
    color: var(--primary-color);
    background: rgba(255, 255, 255, 0.4);
}

/* 激活狀態：高亮朱紅 + 陰影立體感 */
.meihua-switch-btn.active {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(140, 42, 42, 0.35);
    transform: scale(1.02);
}

.meihua-switch-btn .switch-icon {
    font-size: 16px;
    transition: transform 0.3s;
}

.meihua-switch-btn.active .switch-icon {
    transform: scale(1.15);
}

/* ==========================================
   🟢 全瀏覽器 / 全手機跨平台萬用按鈕樣式
   ========================================== */

/* 1. 可按下按鈕基礎設定（適用所有裝置） */
button:not(:disabled),
.action-btn:not(:disabled),
.reset-btn:not(:disabled),
.ai-btn:not(:disabled) {
    cursor: pointer;
    transition: opacity 0.15s ease, transform 0.15s ease;
    -webkit-tap-highlight-color: transparent; /* 移除 iOS / Android 手機預設點擊灰框 */
}

/* 2. 手機觸控與電腦點擊按壓反饋 (:active) */
button:not(:disabled):active,
.action-btn:not(:disabled):active,
.reset-btn:not(:disabled):active {
    opacity: 0.8;
    transform: scale(0.97);
}

/* 3. 電腦端滑鼠懸停效果 (:hover) */
button:not(:disabled):hover,
.action-btn:not(:disabled):hover {
    opacity: 0.9;
}

/* 4. 禁用 (disabled) 按鈕：萬用變灰、半透明、無陰影與阻斷觸控 */
button:disabled,
.action-btn:disabled,
.reset-btn:disabled,
.ai-btn:disabled,
.voice-btn:disabled,
.meihua-switch-btn:disabled {
    opacity: 0.45 !important;
    cursor: not-allowed !important;
    box-shadow: none !important;
    transform: none !important;
    filter: grayscale(80%) !important;
    -webkit-filter: grayscale(80%) !important; /* 支援舊版 iOS Safari 與舊版 Android 內建瀏覽器 */
    pointer-events: none !important;            /* 徹底阻斷手機手指觸控與電腦點擊事件 */
}