/* --- 基礎變數設定 --- */
:root {
    --g-dark: #0f0505;
    --g-red: #5e0a0a;
    --g-red-light: #dc2626;
    --g-gold: #fbbf24;
    --g-gold-light: #fef3c7;
    --g-gold-dark: #b45309;
    --neon-gold: 0 0 15px rgba(251, 191, 36, 0.5), 0 0 30px rgba(180, 83, 9, 0.3);
    --neon-red: 0 0 20px rgba(220, 38, 38, 0.6);
    --font-main: 'Noto Sans TC', sans-serif;
    --font-gaming: 'Russo One', sans-serif;
}


.bg-overlay {
    position: fixed;
    inset: 0;
    z-index: 0;
    opacity: 0.3;
    /* background-image: url('https://img.freepik.com/free-vector/dark-hexagonal-background-with-gradient-color_79603-1409.jpg'); */
    background-size: cover;
}

/* --- 動畫定義 --- */
@keyframes shine {
    0% {
        background-position: 200% center;
    }

    100% {
        background-position: -200% center;
    }
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

@keyframes sheen {
    0% {
        left: -100%;
    }

    100% {
        left: 200%;
    }
}

@keyframes rotate {
    from {
        transform: translate(-50%, -50%) rotate(0deg);
    }

    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

@keyframes pulse-fast {

    0%,
    100% {
        opacity: 0.3;
    }

    50% {
        opacity: 0.6;
    }
}

/* --- 通用組件 --- */
.tech-border {
    clip-path: polygon(0 10px, 10px 0, calc(100% - 10px) 0, 100% 10px, 100% calc(100% - 10px), calc(100% - 10px) 100%, 10px 100%, 0 calc(100% - 10px));
}

.btn-trigger {
    padding: 0.75rem 2rem;
    background: linear-gradient(to right, #dc2626, #991b1b);
    color: white;
    font-weight: bold;
    border: 2px solid #f87171;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: var(--neon-red);
    letter-spacing: 0.1em;
}

.btn-trigger:hover {
    transform: scale(1.05);
}

/* --- Modal 結構 --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 51;
    display: none;
    /* JS 控制顯示 */
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s;
}

.backdrop.show {
    opacity: 1;
}

#gameModal .modal-content {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 400px;
    height: 580px;
    perspective: 1200px;
    transform: scale(0.9);
    /* opacity: 0; */
    transition: all 0.3s ease-out;
}

.modal-content.show {
    transform: scale(1);
    opacity: 1;
}

.close-btn {
    position: absolute;
    top: -48px;
    right: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid #6b7280;
    background: rgba(0, 0, 0, 0.5);
    color: #d1d5db;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 60;
    transition: all 0.2s;
}

.close-btn:hover {
    color: white;
    border-color: white;
    background: rgba(127, 29, 29, 0.5);
}

/* --- 列表視圖 --- */
#listView {
    position: absolute;
    inset: 0;
    background: var(--g-dark);
    border-radius: 20px;
    border: 1px solid rgba(180, 83, 9, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.5s;
}

/* .bg-grid-pattern {
    position: absolute;
    inset: 0;
    background-image: linear-gradient(45deg, rgba(0, 0, 0, 0.1) 25%, transparent 25%, transparent 75%, rgba(0, 0, 0, 0.1) 75%, rgba(0, 0, 0, 0.1)), linear-gradient(45deg, rgba(0, 0, 0, 0.1) 25%, transparent 25%, transparent 75%, rgba(0, 0, 0, 0.1) 75%, rgba(0, 0, 0, 0.1));
    background-position: 0 0, 10px 10px;
    background-size: 20px 20px;
    opacity: 0.1;
    pointer-events: none;
} */

.list-header {
    padding: 1.5rem;
    text-align: center;
    z-index: 10;
}

.list-header h2 {
    font-family: var(--font-gaming);
    font-size: 1.5rem;
    letter-spacing: 0.1em;
    color: white;
}

.list-header p {
    color: rgba(251, 191, 36, 0.8);
    font-size: 0.85rem;
    letter-spacing: 0.2em;
    margin-top: 0.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 1rem;
}

.list-container {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 1rem;
    z-index: 10;
}

/* 隱藏捲軸 */
.list-container::-webkit-scrollbar {
    display: none;
}

.reward-item {
    position: relative;
    height: 96px;
    margin-bottom: 1rem;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: all 0.3s ease;
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%);
}

.reward-item:hover h3 {
    color: var(--theme-color) !important;
    transition: color 0.3s;
}

/* 日期標籤變色與邊框 */
.date-tag {
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.05);
    position: absolute;
    bottom: 6px;
    right: 12px;
    font-size: 0.8rem;
    font-family: monospace;
    background: rgba(0, 0, 0, 0.4);
    padding: 2px 6px;
    border-radius: 4px;
}

.reward-item:hover .date-tag {
    /* 增加飽和度：將文字設為純白或更亮的顏色，並強化背景與邊框 */
    border-color: var(--theme-color) !important;
    background: rgba(0, 0, 0, 0.6) !important;
    box-shadow: 0 0 3px var(--theme-color);
    /* 增加一個微弱的光暈提升飽和感 */
}

.reward-item:hover {
    transform: translateX(4px);
    border-color: var(--theme-color, rgba(251, 191, 36, 0.8)) !important;
}

.reward-item .bg-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.7s;
}

.reward-item:hover .bg-img {
    transform: scale(1.1);
}

.reward-item .overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to right, rgba(0, 0, 0, 0.95), rgba(0, 0, 0, 0.6), transparent);
}

.reward-item .content {
    position: relative;
    z-index: 10;
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 1rem;
    gap: 1rem;
}

.reward-item .content h3 {
    font-size: 1.1rem;
    font-weight: bold;
}

.reward-item .content p {
    font-size: 0.95rem;
    color: #9ca3af;
    margin-bottom: 0;
}

.reward-item.claimed {
    cursor: not-allowed;
    border-color: rgba(255, 255, 255, 0.05);
}

.reward-item.claimed .overlay {
    background: rgba(17, 24, 39, 0.8);
}

.reward-item.claimed .content {
    opacity: 0.4;
    filter: grayscale(1);
}

.claimed-stamp {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
}

.claimed-stamp span {
    border: 2px solid #6b7280;
    color: #9ca3af;
    font-weight: 900;
    padding: 0.25rem 1.5rem;
    transform: rotate(-12deg);
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    letter-spacing: 0.2em;
}

/* --- 卡片視圖 --- */
#cardView {
    position: absolute;
    inset: 0;
    transition: all 0.5s;
    transform: translateX(100%);
    opacity: 0;
    pointer-events: none;
}

#cardView.active {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
}

.back-btn {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 40;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #d1d5db;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.back-btn:hover {
    color: white;
    transform: scale(1.1);
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

.card-inner.flipped {
    transform: rotateY(180deg);
}

/* add 當卡片翻轉後，手動將正面透明度降為 0，避免殘影 */
.card-inner.flipped .card-front {
    opacity: 0;
    pointer-events: none; /* 翻轉後禁止點擊正面元素 */
    transition: opacity 0.3s;
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 20px;
    overflow: hidden;
    background: #0f0505;
    /* add */
    -webkit-backface-visibility: hidden; /* 針對 Safari/Chrome 行動版 */
    transform: translateZ(0); /* 強制開啟硬體加速 */
}

.card-front {
    background: linear-gradient(to bottom, #111827, #1a0505, #2b0808);
    border: 1px solid rgba(180, 83, 9, 0.3);
    display: flex;
    flex-direction: column;
}

.viptag-font {
    font-size: 0.8rem;
    font-weight: 900;
    color: #450a0a;
}

.viptag-font-num {
    font-family: var(--font-gaming);
    font-size: 1.25rem;
}

#packetTitle {
    font-size: 1.8rem;
    color: #fbbf24;
    text-shadow: 0 2px 4px black;
}

.packet-title-underline {
    height: 2px;
    width: 100px;
    background: linear-gradient(to right, transparent, #b45309, transparent);
    margin: 8px auto 16px;
}

.event-info-box {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 12px;
    text-align: left;
    margin-bottom: 20px;
}

.event-info-box-top {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 4px;
}

.event-info-box-top>span{
    font-size: 0.8rem;
    color: #fbbf24;
    font-weight: bold;
}

.event-info-box-top>i{
    font-size: 0.8rem;
    color: #4b5563;
}

#packetDesc{
    font-size: 1rem;
    color: #d1d5db;
    line-height: 1.6;
}

.card-back {
    /* transform: rotateY(180deg); */
    border: 2px solid var(--g-gold-dark);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* add */
    transform: rotateY(180deg) translateZ(1px); /* 增加微小的 Z 軸位移，確保它在最前面 */
}

/* --- 領取成功特效 --- */
.god-rays {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(from 0deg, transparent 0deg, rgba(251, 191, 36, 0.1) 10deg, transparent 20deg, rgba(251, 191, 36, 0.1) 30deg, transparent 40deg);
    animation: rotate 20s linear infinite;
    pointer-events: none;
}

.card-back-content{
    position: relative;
    z-index: 10;
    text-align: center;
    width: 100%;
    padding: 0 32px;
}

.happy-title{
    font-size: 1rem;
    color: #fbbf24;
    letter-spacing: 0.15em;
    margin-bottom: 16px;
    border-bottom: 1px solid rgba(251, 191, 36, 0.3);
    padding-bottom: 8px;
}

.card-back-content>i{
    font-size: 4rem;
    color: #fbbf24;
    filter: drop-shadow(0 0 10px #fbbf24);
    margin-bottom: 1rem;
}

.card-back-content>h3{
    font-size: 1.5rem;
    font-weight: bold;
}

.card-back-content>p{
    font-size: 0.9rem;
    letter-spacing: 0.1rem;
    color: #9ca3af;
    margin-top: 8px;
}

/* 3D 籌碼與按鈕 */
/* 外層容器：負責定位與動畫，不裁切 */
.chip-container {
    width: 144px;
    height: 144px;
    position: relative;
    margin: 1rem auto;
    animation: float 3s ease-in-out infinite;
    cursor: pointer;
    /* 移除 overflow: hidden */
    /* 移除 border-radius */
}

.chip-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 10px 15px rgba(0, 0, 0, 0.6));
    transition: transform 0.5s;
}

.chip-container:hover .chip-img {
    transform: scale(1.05) rotate(12deg);
}

.btn-claim {
    width: 100%;
    padding: 0.875rem 0;
    background: linear-gradient(90deg, #b45309 0%, #fbbf24 50%, #b45309 100%);
    background-size: 200% auto;
    color: #450a0a;
    font-weight: 900;
    font-size: 1.125rem;
    letter-spacing: 0.2em;
    border: 1px solid #fef3c7;
    cursor: pointer;
    box-shadow: var(--neon-gold);
    animation: shine 3s infinite linear;
    position: relative;
    overflow: hidden;
}

.btn-claim::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.3), transparent);
    transform: skewX(-25deg);
    transition: 0.5s;
}

.btn-claim:hover::after {
    left: 150%;
}

.reward-amount {
    background: linear-gradient(to right, transparent, rgba(127, 29, 29, 0.4), transparent);
    width: 100%;
    padding: 1rem 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin: 1.5rem 0;
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 4px;
}

.amount-text {
    font-family: var(--font-gaming);
    color: var(--g-gold);
    font-size: 3rem;
    font-weight: 900;
}

.redenvelope-closebtn{
    width: 100%;
    padding: 12px 0;
    background: #1f2937;
    border: 1px solid #4b5563;
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.125rem;
    letter-spacing: 0.1em;
}

/* 響應式微調 */
@media (max-height: 600px) {
    .modal-content {
        transform: scale(0.8);
    }
}

/* --- 右下角漂浮按鈕樣式 --- */
.floating-btn-wrap {
    position: fixed;
    right: 30px;
    bottom: 30px;
    z-index: 49;
    /* 確保在最上層 */
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    animation: float 3s ease-in-out infinite;
    /* 使用您原本定義的 float 動畫 */
}

.floating-btn-wrap:hover {
    transform: scale(1.1) rotate(5deg);
}

.floating-btn {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #dc2626 0%, #7f1d1d 100%);
    border: 2px solid #f87171;
    box-shadow: var(--neon-red), 0 10px 20px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    gap: 4px;
}

.floating-btn i {
    font-size: 24px;
    color: var(--color-w100);
    filter: drop-shadow(0 0 5px rgba(251, 191, 36, 0.6));
}

.floating-btn span {
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 1px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* 通知小紅點 */
.notification-dot {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 28px;
    height: 28px;
    background: #ff0000;
    border: 2px solid white;
    border-radius: 50%;
    z-index: 50;
    animation: pulse-fast 1s infinite;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
}

/* 讓手機版稍微縮小一點點 */
@media (max-width: 480px) {
    .floating-btn-wrap {
        right: 20px;
        bottom: 20px;
    }

    .floating-btn {
        width: 70px;
        height: 70px;
    }
}

/* 定義光影移動動畫 */
@keyframes sheen {
    0% {
        left: -100%;
    }

    100% {
        left: 200%;
    }
}

/* 光影效果層樣式 */
.animate-sheen-layer {
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    /* 光束寬度 */
    height: 100%;
    background: linear-gradient(to right,
            transparent,
            rgba(255, 255, 255, 0.25) 50%,
            transparent);
    transform: skewX(-25deg);
    /* 傾斜角度 */
    animation: sheen 3s infinite ease-in-out;
    /* 3秒循環一次 */
    pointer-events: none;
    /* 確保不影響點擊 */
    z-index: 5;
    /* 確保在背景之上，文字之下 */
}

/* 外光暈層 */
/* 核心：外光暈（放在背後） */
.chip-outer-glow {
    position: absolute;
    /* 讓光暈比容器大一點，從中心向外擴散 */
    inset: -20px;
    background: radial-gradient(circle, rgba(251, 191, 36, 0.6) 0%, transparent 70%);
    border-radius: 50%;
    filter: blur(20px);
    z-index: 1;
    /* 確保在最底層 */
    opacity: 0.5;
    transition: all 0.4s ease;
}

/* 滑過時增強背後光暈 */
.chip-container:hover .chip-outer-glow {
    opacity: 1;
    transform: scale(1.2);
    background: radial-gradient(circle, rgba(251, 191, 36, 0.8) 0%, transparent 75%);
}

/* 內層包裝：負責裁切內部的閃光(Sheen) */
.chip-inner-wrap {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    /* 在這裡裁切閃光 */
    z-index: 2;
    /* 蓋在光暈上面 */
}

/* 僅用於卡片背面的紋理層 */
.card-back-texture {
    position: absolute;
    inset: 0;
    background-image: url('https://www.transparenttextures.com/patterns/cubes.png');
    opacity: 0.1;
    /* 透明度設定為 0.1 */
    pointer-events: none;
    /* 確保不影響點擊 */
    z-index: 1;
    /* 放在背景色之上，內容物之下 */
}

/* 確保卡片背面有正確的層級設定 */
.card-face.card-back {
    position: relative;
    overflow: hidden;
}

/* 確保文字內容層級高於紋理 */
.card-back>div[style*="z-index: 10"] {
    position: relative;
    z-index: 10 !important;
}