/* 靈棋經占卜 - 樣式（導航/基礎由 style.css 提供） */

:root {
    --color-red: #dc2626;
}

/* 主容器 */
.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 24px 20px;
}

h1 {
    text-align: center;
    font-size: 1.8rem;
    color: var(--color-primary);
    margin-bottom: 8px;
}

.subtitle {
    text-align: center;
    color: var(--color-muted);
    font-size: 0.9rem;
    margin-bottom: 28px;
}

/* 占卜按鈕 */
.action-area {
    text-align: center;
    margin-bottom: 28px;
}

.btn-divinate {
    padding: 14px 48px;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.15rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s;
    letter-spacing: 2px;
}

.btn-divinate:hover {
    background: #16213e;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(26, 26, 46, 0.3);
}

.btn-divinate:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* 棋盤 */
.board {
    display: none;
    margin-bottom: 28px;
}

.board.show {
    display: block;
}

.piece-group {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.group-label {
    width: 48px;
    text-align: center;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-primary);
    flex-shrink: 0;
}

.group-sub {
    display: block;
    font-size: 0.7rem;
    color: var(--color-muted);
    font-weight: 400;
}

.piece-row {
    display: flex;
    gap: 10px;
    flex: 1;
}

/* 棋子 */
.piece {
    width: 64px;
    height: 64px;
    perspective: 400px;
}

.piece-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s ease;
    transform-style: preserve-3d;
}

/* 翻轉中：快速旋轉 */
.piece.flipping .piece-inner {
    animation: flip-spin 0.6s ease infinite;
}

@keyframes flip-spin {
    0% { transform: rotateY(0deg); }
    100% { transform: rotateY(360deg); }
}

/* 翻轉中的旋轉速度：慢一些，更有儀式感 */
.piece.flipping .piece-inner {
    animation-duration: 1s;
}

/* 正面朝上 */
.piece.face-up .piece-inner {
    transform: rotateY(0deg);
}

/* 蓋牌（背面朝上） */
.piece.face-down .piece-inner {
    transform: rotateY(180deg);
}

.piece-front,
.piece-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

/* 正面：象棋子外觀 */
.piece-front {
    background: #fef7e0;
    border: 3px solid #b8860b;
    color: var(--color-red);
    font-size: 1.3rem;
    box-shadow: inset 0 0 8px rgba(184, 134, 11, 0.2), 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* 背面：蓋牌 */
.piece-back {
    background: #4a5568;
    border: 3px solid #2d3748;
    transform: rotateY(180deg);
    box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.3), 0 2px 4px rgba(0, 0, 0, 0.1);
}

.piece-back::after {
    content: "";
    width: 36px;
    height: 36px;
    border: 2px solid #718096;
    border-radius: 50%;
}

/* 結果區 */
.result-section {
    display: none;
}

.result-section.show {
    display: block;
    animation: fadeIn 0.5s ease;
}

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

.result-header {
    text-align: center;
    padding: 24px;
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    margin-bottom: 16px;
}

.result-code {
    font-size: 0.9rem;
    color: var(--color-muted);
    margin-bottom: 8px;
    letter-spacing: 2px;
}

.result-name {
    font-size: 2rem;
    font-weight: 800;
    color: var(--color-primary);
    margin-bottom: 4px;
}

.result-symbol {
    font-size: 1rem;
    color: #92400e;
    font-weight: 500;
}

/* 元信息標籤 */
.result-meta {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.meta-tag {
    display: inline-block;
    padding: 4px 12px;
    background: #f3f4f6;
    border: 1px solid var(--color-border);
    border-radius: 20px;
    font-size: 0.82rem;
    color: var(--color-muted);
}

/* 結果卡片 */
.result-card {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 16px 20px;
    margin-bottom: 12px;
}

.result-card-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-muted);
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid #f3f4f6;
}

.result-card-text {
    font-size: 1rem;
    line-height: 1.8;
    color: var(--color-text);
}

.result-card-text.poem {
    font-style: italic;
    color: #4a5568;
}

/* RWD */
@media (max-width: 640px) {
    h1 {
        font-size: 1.4rem;
    }

    .piece {
        width: 52px;
        height: 52px;
    }

    .piece-front {
        font-size: 1.1rem;
    }

    .piece-back::after {
        width: 28px;
        height: 28px;
    }

    .piece-row {
        gap: 6px;
    }

    .group-label {
        width: 40px;
        font-size: 0.95rem;
    }

    .result-name {
        font-size: 1.6rem;
    }

    .btn-divinate {
        padding: 12px 36px;
        font-size: 1rem;
    }
}
