/* ==========================================================================
   命相館全景沉浸式風格 - 遊戲整體視窗化與雙模式動態比例自適應版
   ========================================================================== */

:root {
    --gold-primary: #d4af37;
    --gold-hover: #f3e5ab;
    --bg-dark-overlay: rgba(15, 10, 8, 0.85);
    --card-bg: rgba(22, 15, 12, 0.85);
    --border-gold: rgba(212, 175, 55, 0.4);
    --text-light: #f5f0eb;
    --text-muted: #c8bcae;

    /* 標題兩行字的尺寸（logo 高度依此計算） */
    --title-size: clamp(1.2rem, 1.6vw, 1.8rem);
    --subtitle-size: 0.95rem;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: "Noto Serif TC", "PingFang TC", "Microsoft JhengHei", serif;
    color: var(--text-light);
    min-height: 100vh;
    background-color: #0d0806;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: clamp(10px, 2vh, 25px);
    overflow: hidden;
    transition: all 0.3s ease;
}

/* ==========================================================================
   整體遊戲視窗主框架
   ========================================================================== */

.game-window-frame {
    position: relative;
    z-index: 1;
    background: url('../64卦封面.jpg') no-repeat center center;
    background-size: cover;
    border: 2px solid var(--gold-primary);
    border-radius: 16px;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.95), 0 0 20px rgba(212, 175, 55, 0.3);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

.game-window-frame::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(90deg, rgba(10, 5, 3, 0.92) 0%, rgba(10, 5, 3, 0.75) 42%, rgba(0, 0, 0, 0.2) 100%);
    z-index: 0;
    pointer-events: none;
}

/* ==========================================================================
   雙版面型態 (視窗版 vs 全螢幕)
   ========================================================================== */

body.mode-window .game-window-frame {
    width: clamp(860px, 80vw, 1280px);
    height: clamp(560px, 86vh, 820px);
}

body.mode-full .game-window-frame {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    border: none;
}

body.mode-full {
    --title-size: 2.2rem;
    --subtitle-size: 1.1rem;
}

body.mode-full .site-footer {
    padding: 0.8rem 1.2rem 1.5rem 1.2rem;
    font-size: 1.1rem;
    border-top: none;
}

body.mode-full .section-title {
    font-size: 1.1rem;
}

body.mode-full .custom-select,
body.mode-full .custom-input {
    padding: 0.75rem 1rem;
    font-size: 1rem;
}

body.mode-full .submit-btn {
    padding: 0.85rem;
    font-size: 1rem;
}

body.mode-full .category-btn {
    padding: 0.85rem 0.4rem;
    font-size: 0.95rem;
}

body.mode-full .category-btn i {
    font-size: 1.25rem;
}

/* ==========================================================================
   頂部 Header 與切換按鈕
   ========================================================================== */

.site-header {
    position: relative;
    z-index: 2;
    padding: 0.9rem 1.2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(12, 8, 5, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border-gold);
    flex-shrink: 0;
}

.brand-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* logo 高度 = 「隨緣」一行 + 「周易神卦」一行 + 中間間距 */
.brand-logo {
    height: calc(var(--title-size) * 1.2 + var(--subtitle-size) * 1.4 + 2px);
    width: calc(var(--title-size) * 1.2 + var(--subtitle-size) * 1.4 + 2px);
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border-gold);
    flex-shrink: 0;
    display: block;
}

.brand-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.brand-title {
    font-size: var(--title-size);
    font-weight: 700;
    color: var(--gold-primary);
    text-shadow: 0 0 12px rgba(212, 175, 55, 0.5), 2px 2px 4px #000;
    letter-spacing: 2px;
    line-height: 1.2;
}

.header-subtitle {
    font-size: var(--subtitle-size);
    color: var(--text-muted);
    letter-spacing: 5px;
    line-height: 1.4;
}

.layout-switch-bar {
    display: flex;
    gap: 4px;
    background: rgba(10, 5, 3, 0.85);
    padding: 3px;
    border-radius: 8px;
    border: 1px solid var(--border-gold);
}

.layout-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 5px 12px;
    font-size: 0.8rem;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.layout-btn:hover {
    color: var(--gold-hover);
}

.layout-btn.active {
    background: rgba(212, 175, 55, 0.25);
    color: var(--gold-hover);
    font-weight: bold;
    box-shadow: 0 0 8px rgba(212, 175, 55, 0.3);
}

/* ==========================================================================
   主要操作容器
   ========================================================================== */

.main-container {
    position: relative;
    z-index: 2;
    padding: 1rem 1.2rem;
    width: clamp(340px, 32vw, 460px);
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    overflow-y: auto;
    flex: 1;
    transition: all 0.3s ease;
}

.main-container::-webkit-scrollbar {
    width: 5px;
}
.main-container::-webkit-scrollbar-track {
    background: rgba(10, 5, 3, 0.4);
}
.main-container::-webkit-scrollbar-thumb {
    background: var(--border-gold);
    border-radius: 4px;
}

.client-info-section, .category-section, .divination-input-section {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-gold);
    border-radius: 10px;
    padding: 0.9rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
}

.section-title {
    font-size: 0.9rem;
    color: var(--gold-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-top: 0.6rem;
}

.category-btn {
    background: rgba(45, 32, 26, 0.6);
    border: 1px solid rgba(212, 175, 55, 0.2);
    color: var(--text-muted);
    padding: 0.6rem 0.2rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.82rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    transition: all 0.25s ease;
}

.category-btn i {
    font-size: 1rem;
}

.category-btn:hover, .category-btn.active {
    background: rgba(212, 175, 55, 0.2);
    border-color: var(--gold-primary);
    color: var(--gold-hover);
}

.custom-select, .custom-input {
    background: rgba(10, 5, 3, 0.85);
    border: 1px solid var(--border-gold);
    color: var(--gold-hover);
    padding: 0.55rem 0.75rem;
    border-radius: 5px;
    font-size: 0.85rem;
    outline: none;
    width: 100%;
}

.submit-btn {
    background: linear-gradient(135deg, #b8860b 0%, #d4af37 50%, #996515 100%);
    border: none;
    color: #1a0f00;
    font-weight: bold;
    padding: 0.7rem;
    font-size: 0.88rem;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
}

.submit-btn:hover {
    filter: brightness(1.2);
    box-shadow: 0 0 12px rgba(212, 175, 55, 0.5);
}

/* ==========================================================================
   右側解卦結果顯示區
   ========================================================================== */

.result-section {
    display: none;
    position: absolute;
    top: 65px;
    bottom: 50px;
    left: 480px;
    right: 20px;
    z-index: 999;
    overflow: hidden;
    border-radius: 12px;
}

.result-body::-webkit-scrollbar {
    width: 6px;
}
.result-body::-webkit-scrollbar-track {
    background: rgba(10, 5, 3, 0.5);
    border-radius: 4px;
}
.result-body::-webkit-scrollbar-thumb {
    background: var(--border-gold);
    border-radius: 4px;
}

.result-card {
    background: rgba(18, 12, 9, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-gold);
    border-radius: 12px;
    padding: 1.2rem;
    height: 100%;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
    gap: 4px;
}

.result-tag {
    background: rgba(212, 175, 55, 0.2);
    color: var(--gold-hover);
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 0.75rem;
    border: 1px solid var(--border-gold);
}

.close-panel-btn:hover {
    color: var(--gold-hover) !important;
}

.result-client-preview {
    background: rgba(212, 175, 55, 0.08);
    border: 1px dashed var(--border-gold);
    padding: 0.5rem;
    border-radius: 5px;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.result-divider {
    border: none;
    height: 1px;
    background: var(--border-gold);
    margin-bottom: 0.7rem;
}

.result-body {
    line-height: 1.6;
    color: #e6dfd5;
    font-size: 1.1rem;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

/* ==========================================================================
   頁腳 Footer
   ========================================================================== */

.site-footer {
    position: relative;
    z-index: 5;
    padding: 0.8rem 1.2rem;
    color: #e2d7c5;
    font-size: clamp(0.85rem, 1vw, 1.15rem);
    font-weight: 500;
    letter-spacing: 1.5px;
    text-align: center;
    border-top: 1px solid var(--border-gold);
    background: rgba(10, 5, 3, 0.88);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    flex-shrink: 0;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.9), 0 0 8px rgba(212, 175, 55, 0.25);
}

.toast-message {
    position: fixed;
    top: 25px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: rgba(26, 18, 14, 0.96);
    border: 1px solid var(--gold-primary);
    color: var(--gold-hover);
    padding: 9px 20px;
    border-radius: 8px;
    font-size: 0.85rem;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.9), 0 0 15px rgba(212, 175, 55, 0.35);
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 90%;
}

.toast-message.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ==========================================================================
   手機版
   ========================================================================== */

@media (max-width: 768px) {
    body {
        padding: 0;
        overflow-y: auto !important;
    }

    .game-window-frame {
        width: 100vw !important;
        height: auto !important;
        min-height: auto !important;
        border: none;
        border-radius: 0;
        overflow: visible !important;
        justify-content: flex-start !important;
    }

    .site-header {
        padding: 0.5rem 1rem !important;
    }

    .main-container {
        width: 100% !important;
        padding: 0.5rem 1rem !important;
        gap: 0.4rem !important;
        flex: none !important;
        height: auto !important;
    }

    .client-info-section, .category-section, .divination-input-section {
        padding: 0.5rem !important;
    }

    .result-section {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        bottom: auto !important;
        width: 100% !important;
        margin-top: 1rem;
    }

    .layout-switch-bar {
        display: none;
    }

    .site-footer {
        padding: 0.5rem 0.4rem !important;
        font-size: 0.75rem !important;
        white-space: nowrap !important;
        overflow: hidden;
        text-overflow: ellipsis;
        letter-spacing: 0.5px !important;
        position: relative !important;
        z-index: 99 !important;
    }

    .result-card h2, .result-card .result-title, .result-section h3 {
        font-size: 1.1rem !important;
        white-space: nowrap !important;
    }

    .result-card h3,
    .result-card h4,
    .result-card div[class*="summary"] {
        font-size: 1.05rem !important;
        letter-spacing: 0px !important;
    }

    .result-card span,
    .result-card div[style*="background"] {
        font-size: 0.82rem !important;
        padding: 2px 5px !important;
        letter-spacing: 0px !important;
    }

    .result-body {
        line-height: 1.85 !important;
        letter-spacing: 0.8px !important;
        font-size: 1.1rem !important;
    }
}

/* 三大領域按鈕鎖定（進階版功能） */
.category-btn {
    opacity: 0.4 !important;
    pointer-events: none !important;
    cursor: not-allowed !important;
    filter: grayscale(80%) !important;
}