/* 成就與紀錄面板樣式
   架構：overlay 以 position:fixed 浮在 #stage 外，覆蓋全視窗
   20px = 20px
*/

/*底*/
.ach-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: hsla(0, 0%, 0%, 0.85);
    z-index: 2100;
    /* 高於遊戲 overlay (2000) 與 GameMessage (2050)；
       4 個覆蓋層（成就/群英榜/江南小院/名人列傳）統一 2100 */
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
    /* 2px → 2px */
}

.ach-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

/*卡片*/
.ach-container {
    background-color: hsl(0, 60%, 24%);
    border-radius: 20px;
    /* 20px → 20px */
    box-shadow: 0 12px 38px rgba(0, 0, 0, 0.8);
    /* 0.625/37.5px → 12/38px */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: hsl(34, 64%, 98%);
    font-family: 'Noto Serif TC', serif;
    position: absolute;
}

/*標題底*/
.ach-header {
    background: hsl(0, 60%, 36%);
    color: hsl(34, 64%, 98%);
    padding: 5px 25px;
    /* 0.5/25px → 10/25px */
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    /* 2px → 2px */
}

/* 標題右側 X 關閉按鈕（4 dialog 唯一關閉方式） */
.ach-close-btn {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: bold;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.2);
    color: hsl(34, 64%, 98%);
    cursor: pointer;
}

.ach-close-btn:hover {
    opacity: 0.85;
}

/*標題文字*/
.ach-title {
    font-size: 30px;
    /* 30px → 30px */
    font-weight: bold;
    letter-spacing: 5px;
    /* 5px → 5px */
    text-align: center;
}

/*分頁*/
.ach-tabs {
    display: flex;
    background: hsl(0, 60%, 28%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    /* 1px → 1px */
}

.ach-tab {
    flex: 1;
    text-align: center;
    padding: 5px 0;
    cursor: pointer;
    font-size: 20px;
    font-weight: bold;
    color: hsl(0, 0%, 73%);
    transition: background 0.2s, color 0.2s;
    border-right: 1px solid hsla(0, 0%, 100%, 0.2);
    /* 1px → 1px */
    border-bottom: 2px solid hsla(0, 0%, 100%, 0.2);
    /* 2px → 2px */
}

.ach-tab:last-child {
    border-right: none;
}

/*分頁active*/
.ach-tab.active {
    background: hsl(0, 60%, 48%);
    color: #fdfaf6;
    border-bottom: 2px solid hsl(48, 89%, 50%);
    /* 2px → 2px */
}

/* 成就殿堂頁籤：有未領獎狀時，右上角顯示黃底紅色驚嘆號 */
.ach-tab {
    position: relative;
}

.ach-tab.has-unclaimed::after {
    content: "!";
    position: absolute;
    top: 2px;
    right: 6px;
    width: 20px;
    height: 20px;
    line-height: 18px;
    text-align: center;
    background: hsl(50, 100%, 55%);
    color: hsl(0, 85%, 45%);
    font-size: 16px;
    font-weight: 900;
    border-radius: 50%;
    border: 1.5px solid hsl(0, 85%, 45%);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
    animation: ach-pulse-badge 1.4s ease-in-out infinite;
    pointer-events: none;
}

@keyframes ach-pulse-badge {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.18);
    }
}

/*內容*/
.ach-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    /* 20px → 20px */
    position: relative;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.8) transparent;
    cursor: grab;
    user-select: none;
}

.ach-body.grabbing {
    cursor: grabbing;
}

.ach-body::-webkit-scrollbar {
    width: 4px;
    /* 4px → 4px */
}

.ach-body::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 2px;
    /* 2px → 2px */
}

.ach-panel {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.ach-panel.active {
    display: block;
}

/* 總覽 */
.ach-overview {
    text-align: center;
    color: hsl(34, 64%, 98%);
}

/*當前文位*/
.ach-rank-title {
    color: hsl(34, 0%, 80%);
    font-size: 24px;
    /* 24px → 24px */
    margin-top: 6px;
    /* 6px → 6px */
}

/*稱號*/
.ach-rank-display {
    font-size: 120px;
    /* 120px → 120px */
    letter-spacing: 20px;
    /* 20px → 20px */
    font-weight: bold;
    color: hsl(36, 90%, 60%);
    margin: 20px 0;
    /* 20px → 20px */
    text-shadow: 2px 2px 2px rgba(0, 0, 0, 0.5);
    /* 2px → 2px */
    text-align: center;
}

.ach-overview-stats {
    display: flex;
    justify-content: center;
    gap: 38px;
    /* 37.5px → 38px */
    margin-top: 25px;
    /* 25px → 25px */
}

/*累積總分底*/
.ach-stat-box {
    background: hsla(0, 50%, 30%, 1);
    padding: 10px 20px;
    /* 0.9375/31.25px → 19/31px */
    border-radius: 10px;
    /* 10px → 10px */
    border: 1px solid rgba(255, 255, 255, 0.1);
    /* 1px → 1px */
}

/*累積總分數字*/
.ach-stat-val {
    font-size: 40px;
    /* 40px → 40px */
    font-weight: bold;
    color: hsl(36, 100%, 96%);
}

/*累積總分文字*/
.ach-stat-lbl {
    font-size: 24px;
    /* 24px → 24px */
    color: hsl(0, 0%, 90%);
    margin-top: 2px;
    /* 2px → 2px */
}

/*下一個稱號的框底*/
.ach-next-stat {
    margin-top: 10px;
    /* 10px → 10px */
    padding: 6px;
    /* 6px → 6px */
    background: rgba(0, 0, 0, 0.0);
    border-radius: 6px;
    /* 6px → 6px */
}

/* 進階橫欄：文位進度 */
.ach-rank-progress-row {
    margin-top: 20px;
    width: 100%;
    padding: 10px 14px;
    background: hsla(0, 50%, 25%, 0.8);
    border: 1px solid hsla(48, 100%, 65%, 0.3);
    border-radius: 10px;
}

.ach-rank-progress-labels {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 20px;
    color: hsl(36, 100%, 92%);
    margin-bottom: 6px;
}

.ach-rank-progress-labels span:nth-child(2) {
    font-size: 18px;
    color: hsl(45, 60%, 78%);
    font-family: monospace;
}

.ach-rank-progress-track {
    height: 12px;
    background: rgba(0, 0, 0, 0.35);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.ach-rank-progress-fill {
    height: 100%;
    background: linear-gradient(90deg,
            hsl(30, 90%, 55%), hsl(45, 80%, 55%));
    border-radius: 6px;
    transition: width 0.5s ease;
}

/*下一個稱號的數字*/
.ach-next-val {
    font-size: 24px;
    /* 24px → 24px */
    color: hsl(0, 0%, 85%);
    font-family: 'monospace';
    letter-spacing: 1px;
    /* 1px → 1px */
}

/*下一個稱號的文字*/
.ach-next-lbl {
    font-size: 20px;
    /* 20px → 20px */
    color: hsl(0, 0%, 80%);
}

.clickable-rank {
    cursor: pointer;
    font-size: 44px !important;
    /* 44px → 44px */
    color: hsl(48, 100%, 60%);
    text-decoration: underline;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

/* 遊戲紀錄 */
.ach-games-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
    /* 6px → 6px */
}

.ach-game-card {
    background: hsla(0, 50%, 30%, 1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    /* 1px → 1px */
    border-radius: 10px;
    /* 10px → 10px */
    padding: 19px;
    /* 18.75px → 19px */
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    /* 0.125/6.25px → 2/6px */
}

.ach-game-name {
    font-size: 24px;
    /* 24px → 24px */
    font-weight: bold;
    color: hsl(34, 64%, 98%);
}

.ach-game-details {
    text-align: right;
    font-size: 19px;
    /* 19px → 19px */
    color: hsl(0, 0%, 87%);
    line-height: 1.5;
}

/* 徽章 (成就殿堂列表) */
.ach-badges {
    display: flex;
    flex-direction: column;
    gap: 6px;
    /* 6px → 6px */
}

.ach-badge-item {
    background: hsla(0, 50%, 30%, 1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    /* 1px → 1px */
    border-radius: 10px;
    /* 10px → 10px */
    padding: 15px 19px;
    /* 0.75/18.75px → 15/19px */
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* 標題 (成就殿堂列表) */
.ach-badge-title {
    font-size: 22px;
    /* 22px → 22px */
    color: hsl(34, 64%, 98%);
    font-weight: bold;
}

/*領獎狀態*/
.ach-badge-status {
    font-size: 20px;
    /* 20px → 20px */
    color: hsl(0, 0%, 80%);
}

/*領獎按鍵*/
.ach-btn-claim {
    background: linear-gradient(135deg, hsl(48, 85%, 60%), hsl(36, 85%, 40%));
    color: #fff;
    border: none;
    font-size: 20px;
    /* 20px → 20px */
    padding: 10px 6px;
    /* 0.5/6px → 10/6px */
    border-radius: 6px;
    /* 6px → 6px */
    cursor: pointer;
    font-weight: bold;
    font-family: inherit;
    box-shadow: 0 2px 2px rgba(0, 0, 0, 0.3);
    /* 2px → 2px */
    transition: transform 0.1s;
}

.ach-btn-claim {
    position: relative;
    /* 為右上角紅圈定位錨點 */
}

.ach-btn-claim:active {
    transform: scale(0.95);
}

/* 領取獎狀按鈕：右上角紅底圓圈提示 */
.ach-btn-claim.claim-pending::after {
    content: "";
    position: absolute;
    top: -6px;
    right: -6px;
    width: 14px;
    height: 14px;
    background: hsl(0, 85%, 50%);
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 5px rgba(255, 0, 0, 0.6);
    animation: ach-pulse-badge 1.4s ease-in-out infinite;
    pointer-events: none;
}

/* 獎狀彈窗 */
.cert-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 3000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.cert-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/*獎狀 — 寬高與位置由 registerOverlayResize 依 stageRect 動態設定*/
.cert-card {
    position: absolute;
    background-size: 90% auto;
    background-repeat: no-repeat;
    background-position: center;
    border-radius: 20px;
    /* 20px → 20px */
    box-shadow: 0 12px 50px rgba(0, 0, 0, 0.8);
    /* 0.625/50px → 12/50px */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 24px;
    /* 24px → 24px */
    box-sizing: border-box;
    text-align: center;
    color: #333;
    font-family: 'Noto Serif TC', serif;
    transform-origin: top left;
}

/*獎狀背景*/
.cert-card.fallback-bg {
    background-color: hsla(0, 50%, 30%, 1);
}

/*獎狀文字框*/
.cert-content {
    background: hsla(36, 75%, 85%, 0.75);
    padding: 10px;
    /* 10px → 10px */
    margin: 20px;
    /* 20px → 20px */
    border-radius: 6px;
    /* 6px → 6px */
    border: 1px solid rgba(0, 0, 0, 0.2);
    /* 1.25px → 1px */
    opacity: 0;
}

.cert-content.animate {
    animation: fadeInContent 1.2s ease-in-out 0.6s forwards;
}

@keyframes fadeInContent {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/*獎狀文字*/
.cert-text {
    font-size: 26px;
    /* 26px → 26px */
    font-weight: bold;
    line-height: 1.6;
    margin: 20px;
    /* 20px → 20px */
    text-align: center;
    white-space: pre-wrap;
}

/*獎狀關閉提示*/
.cert-close-hint {
    position: absolute;
    bottom: -24px;
    /* -24px → -24px */
    color: #fff;
    font-size: 18px;
    /* 18px → 18px */
    width: 100%;
    text-align: center;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
        /* 6.25px → 6px */
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 領取積分獎勵與特效樣式 */
.cert-reward-msg {
    position: absolute;
    bottom: 5%;
    width: 70%;
    background: rgba(0, 0, 0, 0.3);
    color: hsl(48, 100%, 65%);
    border: 1px solid hsla(48, 100%, 65%, 0.5);
    padding: 10px 20px;
    /* 0.5/20px → 10/20px */
    border-radius: 30px;
    /* 30px → 30px */
    font-size: 30px;
    /* 30px → 30px */
    font-weight: bold;
    z-index: 3100;
    pointer-events: none;
    transition: opacity 0.5s;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    /* 10px → 10px */
}

/*獎勵星星容器 — 座標/尺寸由 registerOverlayResize 依 stageRect 動態設定*/
.cert-star-container {
    position: absolute;
    pointer-events: none;
    overflow: hidden;
    z-index: 3050;
}

/*獎勵星星*/
.cert-star {
    position: absolute;
    bottom: 0;
    color: #ffcc00;
    text-shadow: 0 0 5px #fff;
    /* 5px → 5px */
    animation: certStarFly linear forwards;
}

@keyframes certStarFly {
    0% {
        transform: translateY(0) rotate(0deg) scale(0.5);
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        transform: translateY(-100vh) rotate(360deg) scale(1.2);
        opacity: 0;
    }
}

/* 即時成就領獎彈窗 (Premium古風) */
.ach-instant-pop-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.2);
    z-index: 4000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
    /* 4px → 4px */
}

.ach-instant-pop {
    background: hsl(40, 60%, 88%);
    width: 85%;
    max-width: 400px;
    /* 400px → 400px */
    padding: 40px;
    /* 40px → 40px */
    border-radius: 30px;
    /* 30px → 30px */
    border: 6px double hsl(0, 50%, 30%);
    /* 6px → 6px */
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    /* 1/60px → 20/60px */
    animation: popScaleIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.ach-instant-pop h2 {
    color: hsl(0, 50%, 30%);
    font-size: 36px;
    /* 36px → 36px */
    margin-bottom: 30px;
    /* 30px → 30px */
    letter-spacing: 4px;
    /* 4px → 4px */
    font-weight: bold;
    border-bottom: 2px solid hsla(0, 50%, 30%, 0.2);
    /* 2px → 2px */
    padding-bottom: 10px;
    /* 10px → 10px */
}

.ach-instant-pop p {
    color: hsl(0, 40%, 20%);
    font-size: 23px;
    /* 23px → 23px */
    line-height: 1.8;
    margin-bottom: 40px;
    /* 40px → 40px */
    text-align: justify;
    text-indent: 40px;
    /* 40px → 40px */
}

.ach-instant-btn {
    background: linear-gradient(180deg, hsl(45, 100%, 70%), hsl(35, 100%, 50%));
    color: hsl(0, 50%, 20%);
    border: 3px solid hsl(35, 100%, 30%);
    /* 3px → 3px */
    border-radius: 24px;
    /* 24px → 24px */
    padding: 10px 60px;
    /* 0.5/60px → 10/60px */
    font-size: 28px;
    /* 28px → 28px */
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 8px 8px hsl(35, 100%, 20%);
    /* 8px → 8px */
    transition: all 0.2s;
}

.ach-instant-btn:active {
    transform: translateY(4px);
    /* 4px → 4px */
    box-shadow: 0 4px 0 hsl(35, 100%, 20%);
    /* 4px → 4px */
}

@keyframes popScaleIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {}
}

/* 雲端存檔引繼碼區塊 */
.ach-cloud-id-section {
    position: absolute;
    bottom: 2%;
    width: 90%;
    left: 3%;
    background: hsla(0, 50%, 25%, 0.8);
    border: 1px solid hsla(48, 100%, 65%, 0.3);
    /* 1px → 1px */
    border-radius: 10px;
    /* 10px → 10px */
    padding: 10px;
    /* 10px → 10px */
    margin: 10px;
    /* 10px → 10px */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    /* 4px → 4px */
}

.ach-cloud-id-label {
    font-size: 16px;
    /* 16px → 16px */
    color: hsl(0, 0%, 75%);
}

.ach-cloud-id-value {
    font-size: 30px;
    /* 40px → 40px */
    font-weight: bold;
    color: hsl(48, 100%, 70%);
    letter-spacing: 2px;
    /* 2px → 2px */
    user-select: text;
}

.ach-cloud-id-actions {
    display: flex;
    gap: 20px;
    /* 20px → 20px */
    margin-top: 4px;
    /* 4px → 4px */
}

.ach-btn-medium {
    background: linear-gradient(135deg, hsl(0, 65%, 50%), hsl(0, 65%, 35%));
    color: #fff;
    border: 1px solid hsl(40, 100%, 66%);
    padding: 10px 20px;
    /* 0.1/10px → 2/10px */
    border-radius: 16px;
    /* 6px → 6px */
    cursor: pointer;
    font-size: 24px;
    transition: all 0.2s;
}

.ach-btn-medium:hover {
    background: linear-gradient(135deg, hsl(40, 70%, 50%), hsl(30, 70%, 40%));
    transform: translateY(-2px);
}

.ach-btn-medium:active {
    transform: translateY(6px);
}

.ach-btn-small {
    background: linear-gradient(135deg, hsl(40, 60%, 40%), hsl(30, 60%, 30%));
    color: #fff;
    border: 1px solid hsla(40, 60%, 50%, 0.5);
    padding: 2px 10px;
    /* 0.1/10px → 2/10px */
    border-radius: 6px;
    /* 6px → 6px */
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
}

.ach-btn-small:hover {
    background: linear-gradient(135deg, hsl(40, 70%, 50%), hsl(30, 70%, 40%));
    transform: translateY(-2px);
}

.ach-btn-small:active {
    transform: translateY(1px);
}

/* ── 詩詞寶盒面板 ── */
.ach-poem-records {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ach-poem-item {
    background: hsla(0, 50%, 30%, 1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    padding: 12px 19px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.ach-poem-left {
    flex: 1;
    min-width: 0;
}

.ach-poem-title {
    font-size: 22px;
    color: hsl(48, 100%, 72%);
    font-weight: bold;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ach-poem-title:active {
    opacity: 0.7;
}

.ach-poem-counts {
    font-size: 18px;
    margin-top: 5px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    color: hsl(0, 0%, 75%);
}

.ach-poem-count-tag {
    font-weight: bold;
}

/* ── 詩詞寶盒圖片彈窗 ── */
.treasurebox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    z-index: 4500;
}

.treasurebox-stage {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

.treasurebox-container {
    position: relative;
    width: 450px;
    height: 800px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.8);
}

.treasurebox-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: grayscale(100%) brightness(1.9);
}

.treasurebox-grid {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(8, 1fr);
    padding: 4px;
    gap: 3px;
}

.tb-cell {
    border-radius: 5px;
    border: 1.5px solid hsla(45, 90%, 60%, 0.85);
    background-size: 500% 800%;
    background-repeat: no-repeat;
}

.tb-cell.tb-cell-hidden {
    border-color: transparent;
    background: transparent;
}

.treasurebox-hint {
    margin-top: 16px;
    color: rgba(255, 255, 255, 0.65);
    font-size: 18px;
    font-family: 'Noto Serif TC', serif;
    text-align: center;
}