/* ============================================================
   Wtoy Gacha Product Page
   ============================================================ */
:root {
    --primary: #ffbf01;
    --primary-dark: #e09615;
    --accent: #ff4081;
    --accent-light: #ff80ab;
    --accent-rgb: 255, 64, 129;
}

.wgp-page-wrap {
    min-height: 60vh;
    padding-bottom: 100px; /* draw bar 高度預留 */
}

.wtoy-gacha-page {
    max-width: 1200px;
    margin: 0 auto 100px;
    padding: 0 16px;
    font-family: inherit;
}

/* ── Header ─────────────────────────────────────────────── */
.wgp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding: 16px 0 12px;
    border-bottom: 2px solid #f0f0f0;
    margin-bottom: 16px;
}

.wgp-product-name {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 700;
    color: #222;
}

.wgp-header-badges {
    display: flex;
    align-items: center;
    gap: 8px;
}

.wgp-price-badge {
    background: var(--accent);
    color: #fff;
    padding: 6px 16px;
    border-radius: 999px;
    font-size: 0.9rem;
    white-space: nowrap;
}

.wgp-price-badge strong {
    font-size: 1.1em;
}

.wgp-draw-count-badge {
    background: #f0f0f0;
    color: #555;
    padding: 6px 16px;
    border-radius: 999px;
    font-size: 0.9rem;
    white-space: nowrap;
}

.wgp-draw-count-badge strong {
    font-size: 1.1em;
    color: #333;
}

/* ── Boss Banner ─────────────────────────────────────────── */
.wgp-boss-banner {
    position: relative;
    background: linear-gradient(135deg, #e53935, #b71c1c);
    border-radius: 12px;
    padding: 14px 20px 12px;
    color: #fff;
    margin-bottom: 20px;
    overflow: hidden;
}

.wgp-boss-watermark {
    position: absolute;
    right: 140px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 4.5rem;
    font-weight: 900;
    color: #fff;
    opacity: 0.12;
    pointer-events: none;
    white-space: nowrap;
    letter-spacing: 6px;
}

/* 主內容：左右對齊 */
.wgp-boss-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

/* 左側：圓形圖標 + 文字 */
.wgp-boss-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.wgp-boss-crown-wrap {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.wgp-boss-crown {
    font-size: 1.8rem;
    line-height: 1;
}

.wgp-boss-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.wgp-boss-title {
    font-size: 1.125rem;
    opacity: 0.9;
    letter-spacing: 0.5px;
    font-weight: 600;
    color: var(--primary);
}

.wgp-boss-rate-badge {
    display: inline-block;
    background: var(--primary);
    color: #b71c1c;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    vertical-align: middle;
    letter-spacing: 0;
}

.wgp-boss-name {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.2;
}

/* 右側：累積收益 */
.wgp-boss-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    flex-shrink: 0;
}

.wgp-boss-revenue-label {
    font-size: 0.72rem;
    opacity: 0.85;
}

.wgp-boss-revenue-amount {
    font-size: 1.6rem;
    font-weight: 900;
    color: var(--primary);
    line-height: 1.1;
}

/* Hint 文字 */
.wgp-boss-hint {
    color: var(--primary);
    opacity: 0.9;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    padding: 8px;
    text-align: left;
    background-color: rgba(255, 255, 255, 0.1);
    font-size: 0.75rem;
    line-height: 1.4;
    margin: 8px 0 0 0;
    border-radius: 4px;
}

.wgp-boss-hint strong {
    color: var(--primary);
}

/* ── Main Layout ─────────────────────────────────────────── */
.wgp-main {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 20px;
    align-items: start;
}

.wgp-left {
    grid-column: 1;
    min-width: 0;
}

.wgp-right-col {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ── 手機版抽屜：桌面隱藏 ─────────────────────────────── */
.wgp-drawer-toggle,
.wgp-drawer-backdrop {
    display: none;
}

@media (max-width: 768px) {
    .wgp-main {
        grid-template-columns: 1fr;
    }

    .wgp-left,
    .wgp-right-col {
        grid-column: 1;
        grid-row: auto;
    }

    /* 右欄改為固定抽屜 */
    .wgp-right {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 85vw;
        max-width: 380px;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        z-index: 1001;
        overflow-y: auto;
        background: #f5f5f5;
        padding: 16px;
        box-sizing: border-box;
        flex: none;
    }

    .wgp-right.wgp-drawer-open {
        transform: translateX(0);
    }

    /* 觸發鈕：固定右側邊緣半圓形 */
    .wgp-drawer-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
        width: 40px;
        height: 56px;
        border: none;
        border-radius: 28px 0 0 28px;
        background: var(--accent);
        color: #fff;
        font-size: 1.2rem;
        cursor: pointer;
        z-index: 1000;
        box-shadow: -2px 2px 8px rgba(0, 0, 0, 0.15);
        transition: background 0.2s, right 0.3s ease;
        padding: 0;
    }

    .wgp-drawer-toggle.active {
        right: min(85vw, 380px);
    }

    .wgp-drawer-toggle:hover {
        background: var(--accent-light);
    }

    /* 遮罩 */
    .wgp-drawer-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 1000;
    }

    .wgp-drawer-backdrop.active {
        display: block;
    }
}

/* ── Section Title ───────────────────────────────────────── */
.wgp-section-title {
    font-size: 1rem;
    font-weight: 700;
    color: #333;
    margin: 0 0 12px;
    padding-left: 10px;
    border-left: 4px solid var(--accent);
}

/* ── Prize List ──────────────────────────────────────────── */
.wgp-prize-list {
    background: #fafafa;
    border-radius: 10px;
    padding: 16px;
}

.wgp-rarity-section {
    margin-bottom: 16px;
}

.wgp-rarity-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 0;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    user-select: none;
    margin-bottom: 10px;
}

.wgp-rarity-label {
    font-weight: 700;
    font-size: 1rem;
    font-style: italic;
    flex: 1;
}

.wgp-rarity-prob {
    font-size: 0.85rem;
    color: #888;
}

.wgp-arrow {
    font-size: 0.7rem;
    color: #aaa;
    transition: transform 0.2s;
    display: inline-block;
}

.wgp-arrow.open {
    transform: rotate(180deg);
}

.wgp-prize-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

@media (max-width: 600px) {
    .wgp-prize-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.wgp-prize-card {
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    padding: 4px;
    transition: transform 0.15s, box-shadow 0.15s;
}

.wgp-prize-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.wgp-prize-img-wrap {
    width: 100%;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.wgp-prize-img-wrap img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

.wgp-prize-no-img {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #eee, #ddd);
}

.wgp-prize-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: center;
}

.wgp-prize-name {
    font-size: 0.86rem;
    font-weight: bold;
    color: #333;
    line-height: 1.3;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.wgp-prize-prob {
    position: absolute;
    top: 5px;
    right: 5px;
    font-size: 0.65rem;
    color: #fff;
    background: rgba(0, 0, 0, 0.45);
    border-radius: 4px;
    padding: 1px 5px;
    font-weight: 600;
    line-height: 1.4;
    pointer-events: none;
}

.wgp-prize-points {
    font-size: 0.95rem;
    color: var(--primary);
    font-weight: bold;
}

.wgp-prize-boss {
    font-size: 0.8rem;
    color: var(--primary);
    text-align: center;
    font-weight: bold;
}

/* ── Doll Panel ──────────────────────────────────────────── */

/* 共用卡片樣式 */
.wgp-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

/* 外層容器：兩個卡片垂直排列，中間有間距 */
.wgp-doll-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* stage：3欄 flex 橫向佈局 */
.wgp-doll-stage {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    padding: 12px;
}

/* 左右部位欄 */
.wgp-slot-col {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 64px;
    flex-shrink: 0;
}

/* 中央角色欄 */
.wgp-doll-center {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.wgp-doll-boss-badge {
    background: var(--primary);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 4px 14px;
    border-radius: 999px;
    margin-bottom: 6px;
    white-space: nowrap;
}

/* 裝備槽格 */
.wgp-slot-cell {
    aspect-ratio: 1;
    height: 64px;
    border: 2px dashed #ddd;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    position: relative;
    background: #fafafa;
}

.wgp-slot-cell:hover {
    border-color: var(--primary);
}

.wgp-slot-cell.equipped {
    border-style: solid;
}

.wgp-slot-cell.wgp-rarity-1 { border-color: #c0c0c0; }
.wgp-slot-cell.wgp-rarity-2 { border-color: #ffd700; }
.wgp-slot-cell.wgp-rarity-3 { border-color: #b9f2ff; }
.wgp-slot-cell.wgp-rarity-4 { border-color: #1a1a2e; }

/* 裝備槽內 badge：overflow:hidden 故改為內縮定位 */
.wgp-slot-cell .wgp-inv-rate-badge {
    top: -4px;
    left: -4px;
    font-size: 0.6rem;
    padding: 1px 4px;
}

/* 裝備槽縮圖：正方形 letterbox */
.wgp-slot-cell img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: transparent;
}

.wgp-slot-label {
    font-size: 0.65rem;
    color: #aaa;
    text-align: center;
    padding: 4px;
}

/* 角色立繪 */
.wgp-doll-character {
    position: relative;
    width: 100%;
    aspect-ratio: 3/4;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 8px;
}

.wgp-char-base {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    z-index: 0;
}

.wgp-char-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #eee 0%, #ddd 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.wgp-layer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.wgp-char-name {
    text-align: center;
    font-size: 0.85rem;
    color: #666;
    margin: 0;
}

/* ── 背包 ────────────────────────────────────────────────── */
.wgp-backpack {
    /* 獨立卡片，透過 wgp-card 提供背景/陰影 */
}

.wgp-backpack-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    cursor: pointer;
    background: #fafafa;
    border-bottom: 1px solid #f0f0f0;
}

.wgp-backpack-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: #333;
}

.wgp-inv-count {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    border-radius: 999px;
    padding: 1px 7px;
    font-size: 0.75rem;
    margin-left: 4px;
}

.wgp-backpack-toggle {
    background: none;
    border: none;
    font-size: 0.75rem;
    color: #aaa;
    cursor: pointer;
    padding: 4px;
    transition: color 0.15s;
}

.wgp-backpack-toggle:hover {
    color: var(--accent);
}

.wgp-inventory-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    padding: 12px 16px 16px;
    max-height: 360px;
    overflow-y: auto;
}

/* ── 道具卡片 ─────────────────────────────────────────────── */
.wgp-inventory-item {
    border: 1.5px solid #e8e8e8;
    border-radius: 12px;
    cursor: pointer;
    background: #fff;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.wgp-inventory-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
    border-color: var(--primary);
}

/* 圖片區：強制正方形（padding-top hack 確保 grid 內生效） */
.wgp-inv-img-wrap {
    position: relative;
    width: 100%;
    padding-top: 65%; /* 略扁矩形 */
    z-index: 1;
}

/* 圖片：有 padding，不貼邊，letterbox */
.wgp-inv-img-wrap img {
    position: absolute;
    inset: 8px;
    width: calc(100% - 16px);
    height: calc(100% - 16px);
    object-fit: contain;
}

/* 無圖佔位：填滿整個區域 */
.wgp-inv-no-img {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #eee, #ddd);
}

/* 收益率徽章（左上角浮層） */
.wgp-inv-rate-badge {
    background: var(--primary);
    color: white;
    position: absolute;
    top: -6px;
    left: -6px;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 4px;
    line-height: 1.3;
    z-index: 2;
    pointer-events: none;
}

/* 穿戴中效果 */
.wgp-inventory-item.equipped {
    border-color: var(--primary);
    background: rgb(255, 251, 235);
    opacity: .8;
    box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.2);
}

.wgp-inv-equipped-label {
    font-size: 0.8rem;
    color: rgb(217, 119, 6);
    font-weight: 600;
    display: block;
}

/* 文字區 */
.wgp-inv-info {
    padding: 4px 6px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    text-align: center;
}

.wgp-inv-name {
    font-size: 0.72rem;
    font-weight: 600;
    color: #333;
    line-height: 1.3;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    width: 100%;
}

.wgp-inv-slot {
    font-size: 0.65rem;
    color: #aaa;
    display: block;
}

.wgp-outfit-status {
    font-size: 0.8rem;
    color: #aaa;
    text-align: center;
    margin: 4px 0 0;
}

.wgp-login-notice {
    padding: 20px;
    text-align: center;
    color: #888;
    font-size: 0.9rem;
}

.wgp-login-notice a {
    color: var(--accent);
    text-decoration: underline;
}

/* ── Draw Bar ────────────────────────────────────────────── */
.wgp-draw-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 999;
    background: linear-gradient(to top, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.92));
    backdrop-filter: blur(6px);
    border-top: 1px solid #f0f0f0;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.1);
    padding: 10px 16px 14px;
}

.wgp-draw-bar-inner {
    max-width: 700px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.wgp-draw-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-light), var(--accent));
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(var(--accent-rgb), 0.4);
    font-size: 0.75rem;
    line-height: 1.2;
    transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
    font-weight: 600;
    padding: 0;
}

.wgp-draw-btn:hover:not(:disabled) {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 6px 18px rgba(var(--accent-rgb), 0.5);
}

.wgp-draw-btn:active:not(:disabled) {
    transform: scale(0.96);
}

.wgp-draw-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.wgp-btn-icon {
    font-size: 1rem;
    display: block;
}

.wgp-btn-draws {
    font-size: 0.82rem;
    font-weight: 700;
}

.wgp-btn-cost {
    font-size: 0.65rem;
    opacity: 0.9;
}

.wgp-draw-custom {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 6px;
}

.wgp-qty-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.wgp-qty-wrap {
    display: flex;
    align-items: center;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    height: 44px;
}

.wgp-qty-btn {
    width: 32px;
    height: 100%;
    border: none;
    background: #f5f5f5;
    color: #555;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    padding: 0;
    line-height: 1;
    user-select: none;
}

.wgp-qty-btn:hover:not(:disabled) {
    background: #e8e8e8;
}

.wgp-qty-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.wgp-draw-qty {
    width: 40px;
    height: 100%;
    border: none;
    border-left: 1px solid #eee;
    border-right: 1px solid #eee;
    text-align: center;
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    padding: 0;
    appearance: textfield;
}

.wgp-draw-qty::-webkit-inner-spin-button,
.wgp-draw-qty::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.wgp-custom-cost-badge {
    display: flex;
    align-items: baseline;
    gap: 2px;
    background: linear-gradient(135deg, #fff0f3, #ffe0e6);
    border: 1px solid rgba(var(--accent-rgb), 0.25);
    border-radius: 8px;
    padding: 6px 10px;
    min-width: 48px;
    justify-content: center;
    white-space: nowrap;
}

.wgp-custom-cost-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent);
    line-height: 1;
}

.wgp-custom-cost-unit {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
    opacity: 0.8;
    line-height: 1;
}

.wgp-draw-custom-btn {
    height: 44px;
    padding: 0 16px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--accent-light), var(--accent));
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 700;
    box-shadow: 0 3px 8px rgba(var(--accent-rgb), 0.35);
    transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
    white-space: nowrap;
}

.wgp-draw-custom-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 14px rgba(var(--accent-rgb), 0.45);
}

.wgp-draw-custom-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

@media (max-width: 768px) {
    .wgp-draw-btn {
        width: 56px;
        height: 56px;
        font-size: 0.68rem;
    }

    .wgp-btn-icon { font-size: 0.85rem; }

    .wgp-draw-custom {
        margin-left: 2px;
        gap: 4px;
    }

    .wgp-qty-group {
        flex-direction: column-reverse;
        gap: 3px;
    }

    .wgp-qty-wrap {
        height: 36px;
    }

    .wgp-qty-btn {
        width: 28px;
        font-size: 0.95rem;
    }

    .wgp-draw-qty {
        width: 34px;
        font-size: 0.85rem;
    }

    .wgp-custom-cost-badge {
        padding: 3px 8px;
        font-size: 0.8rem;
    }

    .wgp-custom-cost-value {
        font-size: 0.9rem;
    }

    .wgp-draw-custom-btn {
        height: 56px;
        padding: 0 12px;
        font-size: 0.85rem;
    }

    .wgp-draw-bar {
        padding: 6px 8px 10px;
    }

    .wgp-draw-bar-inner {
        gap: 6px;
    }
}

/* ── Loading 遮罩 ──────────────────────────────────────────── */
.wgp-loading-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 10001;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 16px;
}

.wgp-loading-spinner {
    width: 48px; height: 48px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: wgp-spin 0.7s linear infinite;
}

@keyframes wgp-spin {
    to { transform: rotate(360deg); }
}

.wgp-loading-text {
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    letter-spacing: 1px;
}

/* ── 抽獎結果 Modal ────────────────────────────────────────── */
.wgp-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 10000;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}

.wgp-modal--result {
    background: #fff;
    border-radius: 20px;
    width: 100%; max-width: 400px;
    max-height: 88vh;
    display: flex; flex-direction: column;
    overflow: hidden;
    box-shadow: 0 12px 48px rgba(0,0,0,0.35);
}

/* Header */
.wgp-modal-header {
    background: linear-gradient(160deg, var(--accent-light), var(--accent));
    padding: 20px 16px 18px;
    text-align: center;
    position: relative;
    flex-shrink: 0;
}
.wgp-modal-x {
    position: absolute; top: 12px; right: 14px;
    background: rgba(255,255,255,0.25);
    border: none; border-radius: 50%;
    width: 28px; height: 28px;
    color: #fff; font-size: 0.9rem;
    cursor: pointer; line-height: 1;
}
.wgp-modal-hero { font-size: 2rem; margin-bottom: 4px; }
.wgp-modal-title {
    margin: 0;
    font-size: 1.1rem; font-weight: 700; color: #fff;
}

/* Item list */
.wgp-result-list {
    flex: 1; overflow-y: auto;
    padding: 8px 12px;
    max-height: 320px;
}
.wgp-result-row {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid #f0f0f0;
    margin: 6px 0;
    border-radius: 4px;
}
.wgp-result-row:last-child { border-bottom: none; }
.wgp-result-row-icon {
    width: 44px; height: 44px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem; flex-shrink: 0;
    overflow: hidden;
}
.wgp-result-row-info {
    flex: 1; min-width: 0;
    display: flex; flex-direction: column; gap: 2px;
}
.wgp-result-row-name {
    font-size: 0.9rem; font-weight: 600; color: #1a1a1a;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wgp-result-row-rarity { font-size: 0.75rem; color: #888; }
.wgp-result-row-pts {
    font-size: 0.9rem; font-weight: 700;
    color: var(--primary); white-space: nowrap; flex-shrink: 0;
}

/* Footer */
.wgp-modal-footer {
    padding: 12px 16px 16px;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
}
.wgp-modal-total {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 12px;
    font-size: 0.9rem; color: #555;
}
.wgp-modal-total-pts {
    font-size: 1.1rem; font-weight: 700; color: var(--primary);
}
.wgp-modal-close {
    display: block; width: 100%;
    padding: 13px;
    text-align: center;
    background: var(--primary);
    color: #fff; border: none; border-radius: 12px;
    font-size: 1rem; font-weight: 700;
    cursor: pointer; transition: background 0.15s;
}
.wgp-modal-close:hover { background: var(--primary-dark); }

/* ── 角色選擇 ── */
.wgp-char-select {
    width: 100%;
    max-width: 800px;
    margin: 60px auto;
    text-align: center;
    padding: 0 16px;
    box-sizing: border-box;
}

.wgp-char-select__title {
    font-size: 1.6rem;
    margin-bottom: 8px;
}

.wgp-char-select__desc {
    color: #666;
    margin-bottom: 32px;
}

.wgp-char-select__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 20px;
}

.wgp-char-card {
    border: 3px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: border-color .2s, transform .2s;
    overflow: hidden;
    background: #f5f5f5;
}

.wgp-char-card:hover {
    border-color: #aaa;
    transform: translateY(-4px);
}

.wgp-char-card--selected {
    border-color: #7c4dff;
}

.wgp-char-card__img-wrap {
    aspect-ratio: 3/4;
    overflow: hidden;
}

.wgp-char-card__img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.wgp-char-card__no-img {
    width: 100%;
    height: 100%;
    background: #ddd;
}

.wgp-char-card__name {
    display: block;
    padding: 8px 4px;
    font-weight: 600;
}

/* ── 中獎名單 ───────────────────────────────────── */


.wgp-winners-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
}
.wgp-winners-title { font-size: 14px; font-weight: 600; color: #333; }

.wgp-winners-body {
    max-height: 300px;
    overflow-y: auto;
    padding: 4px 0;
}

.wgp-winner-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border-radius: 8px;
    margin: 2px 6px;
    background: #f9f9f9;
}
.wgp-winner-row:first-child { margin-top: 6px; }
.wgp-winner-row:last-child  { margin-bottom: 6px; }

.wgp-winner-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: #555;
    overflow: hidden;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 11px; font-weight: 700;
}
.wgp-winner-avatar img { width: 100%; height: 100%; object-fit: cover; }

.wgp-winner-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.wgp-winner-name  { font-size: 13px; font-weight: 600; color: #333; }
.wgp-winner-prize {
    font-size: 12px; color: #888;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.wgp-winner-rarity {
    font-size: 12px; font-weight: 600;
    white-space: nowrap; flex-shrink: 0;
}

.wgp-winner-row.wgp-winner-rarity-1 { background: rgba(192, 192, 192, 0.15); }
.wgp-winner-row.wgp-winner-rarity-2 { background: rgba(255, 215, 0, 0.15); }
.wgp-winner-row.wgp-winner-rarity-3 { background: rgba(185, 242, 255, 0.25); }
.wgp-winner-row.wgp-winner-rarity-4 { background: rgba(26, 26, 46, 0.12); }

/* ============================================================
   衣櫃頁（My Account / doll-wardrobe）
   ============================================================ */
.wtoy-wardrobe-wrap {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 16px;
}

.wtoy-wardrobe-wrap .wtoy-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0 0 20px;
}

/* ── 區塊 A：紙娃娃展示（限制尺寸） ──── */
.wtoy-wardrobe-doll-section {
    max-width: 420px;
    margin: 0 auto 28px;
}

.wtoy-wardrobe-doll-section .wgp-doll-stage {
    padding: 10px 8px;
}

.wtoy-wardrobe-doll-section .wgp-doll-character {
    max-height: 320px;
    aspect-ratio: 3/4;
}

.wtoy-wardrobe-doll-section .wgp-boss-hint {
    font-size: 0.72rem;
}

/* ── 篩選列 ──── */
.wtoy-filter-name {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 9px 12px;
    border: 1.5px solid #e8e8e8;
    border-radius: 10px;
    font-size: 0.88rem;
    color: #333;
    background: #fff;
    margin-bottom: 8px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.wtoy-filter-name::placeholder { color: #bbb; }
.wtoy-filter-name:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.12);
}

.wtoy-wardrobe-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.wtoy-wardrobe-filters select {
    flex: 1 1 0;
    min-width: 100px;
    padding: 8px 28px 8px 12px;
    border: 1.5px solid #e8e8e8;
    border-radius: 10px;
    font-size: 0.85rem;
    color: #444;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='%23999'%3E%3Cpath d='M0 0l5 6 5-6z'/%3E%3C/svg%3E") right 10px center / 10px no-repeat;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.wtoy-wardrobe-filters select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.12);
}

.wgp-filter-toggle-btn {
    background: none;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    padding: 4px 8px;
    line-height: 1;
    transition: background 0.15s, border-color 0.15s;
}
.wgp-filter-toggle-btn:hover {
    background: #f5f5f5;
}
.wgp-filter-toggle-btn.active {
    background: var(--accent, #ff4081);
    border-color: var(--accent, #ff4081);
    color: #fff;
}

.wgp-backpack-filters {
    padding: 10px 16px 0;
}

/* ── 稀有度邊框 ──── */
.wgp-rarity-1 { border-color: #c0c0c0; }  /* 白銀 */
.wgp-rarity-2 { border-color: #ffd700; }  /* 黃金 */
.wgp-rarity-3 { border-color: #b9f2ff; }  /* 鑽石 */
.wgp-rarity-4 { border-color: #1a1a2e; }  /* 黑鑽 */

/* ── 區塊 B：所有裝備 ──── */
.wtoy-wardrobe-inventory-section {
    margin-bottom: 32px;
}

.wtoy-wardrobe-inventory-section h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #333;
    margin: 0 0 12px;
    padding-left: 10px;
    border-left: 4px solid var(--accent, #ff4081);
}

/* 衣櫃頁用更多欄 + 固定高度捲動 */
.wtoy-wardrobe-inventory-section .wgp-inventory-grid {
    grid-template-columns: repeat(6, 1fr);
    max-height: 480px;
    overflow-y: auto;
    gap: 10px;
    padding: 0;
}

@media (max-width: 768px) {
    .wtoy-wardrobe-inventory-section .wgp-inventory-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* 衣櫃裝備卡：退點 badge */
.wgp-inv-return-badge {
    display: block;
    font-size: 0.7rem;
    color: var(--primary-dark, #e09615);
    font-weight: 600;
    margin-top: 2px;
}

.wgp-inv-return-link {
    color: var(--accent, #ff4081);
    text-decoration: underline;
    font-size: 0.68rem;
    margin-left: 4px;
    cursor: pointer;
}

.wgp-inv-return-link:hover {
    color: #c51162;
}

/* ── 區塊 C：虛擬獎品退點 ──── */
.wtoy-virtual-return-section {
    margin-bottom: 32px;
}

.wtoy-virtual-return-section h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #333;
    margin: 0 0 8px;
    padding-left: 10px;
    border-left: 4px solid var(--accent, #ff4081);
}

.wtoy-virtual-return-section .wtoy-hint {
    font-size: 0.85rem;
    color: #888;
    margin: 0 0 16px;
}

.wtoy-virtual-return-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
}

.wtoy-virtual-return-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 12px;
    padding: 12px 16px;
    transition: box-shadow 0.15s, border-color 0.15s;
}

.wtoy-virtual-return-item:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.wtoy-virtual-return-item img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 8px;
    background: #f5f5f5;
    flex-shrink: 0;
}

.wtoy-virtual-return-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.wtoy-virtual-return-info strong {
    font-size: 0.9rem;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wtoy-virtual-return-source {
    font-size: 0.75rem;
    color: #aaa;
}

.wtoy-virtual-return-points {
    font-size: 0.82rem;
    color: var(--primary-dark, #e09615);
    font-weight: 600;
}

.wtoy-virtual-return-item .wtoy-btn {
    flex-shrink: 0;
    font-size: 0.8rem;
    padding: 8px 14px;
}

/* ── 獎項卡片可點擊 ──────────────────────────────────────── */
.wgp-prize-clickable {
    cursor: pointer;
}

/* ── 獎項詳情彈窗 ────────────────────────────────────────── */
.wgp-prize-detail-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 10000;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}

.wgp-prize-detail-modal {
    background: #fff;
    border-radius: 20px;
    width: 100%; max-width: 400px;
    max-height: 88vh;
    overflow-y: auto;
    box-shadow: 0 12px 48px rgba(0,0,0,0.3);
    position: relative;
    display: flex;
    flex-direction: column;
}

/* 關閉按鈕 */
.wgp-detail-close {
    position: absolute; top: 12px; right: 14px;
    background: none;
    border: none;
    width: 32px; height: 32px;
    color: #999; font-size: 1.4rem;
    cursor: pointer; line-height: 1;
    transition: color 0.15s;
    z-index: 1;
}
.wgp-detail-close:hover { color: #555; }

/* Hero 區：淺灰背景 + 置中內容 */
.wgp-detail-hero {
    background: #f7f7f7;
    border-radius: 20px 20px 0 0;
    padding: 32px 20px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.wgp-detail-img-wrap {
    width: 140px; height: 140px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,0.8);
    border-radius: 16px;
    margin-bottom: 14px;
    padding: 10px;
}
.wgp-detail-img-wrap img {
    max-width: 100%; max-height: 100%;
    object-fit: contain;
}
.wgp-detail-no-img {
    width: 100%; height: 100%;
    background: linear-gradient(135deg, #eee, #ddd);
    border-radius: 12px;
}

.wgp-detail-badge {
    display: inline-block;
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 4px 16px;
    border-radius: 999px;
    margin-bottom: 8px;
}

.wgp-detail-name {
    font-size: 1.2rem;
    font-weight: 700;
    color: #222;
    line-height: 1.3;
    margin-bottom: 6px;
}

.wgp-detail-hero-pts {
    font-size: 1.05rem;
    font-weight: bold;
    color: var(--primary);
    margin-bottom: 2px;
}

.wgp-detail-hero-boss {
    font-size: 0.82rem;
    font-weight: bold;
    color: var(--primary);
}

/* Body 區 */
.wgp-detail-body {
    padding: 16px 20px 0;
}

/* 商品介紹 */
.wgp-detail-desc {
    padding: 0;
    background: none;
    border-radius: 0;
    margin-bottom: 12px;
}
.wgp-detail-desc-title {
    font-size: 0.88rem;
    font-weight: bold;
    color: #000;
    margin-bottom: 8px;
}
.wgp-detail-desc-body {
    font-size: 0.88rem;
    color: #000;
    line-height: 1.6;
    white-space: pre-wrap;
}

/* 中獎機率 */
.wgp-detail-prob {
    padding: 12px 0 0;
    background: none;
    border-radius: 0;
    border-top: 1px solid #f0f0f0;
    margin-bottom: 4px;
}
.wgp-detail-prob-title {
    font-size: 0.88rem;
    font-weight: bold;
    color: #000;
    margin-bottom: 10px;
}
.wgp-detail-prob-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 3px 0;
    font-size: 0.85rem;
    color: #000;
}
.wgp-detail-prob-text {
    font-size: 0.85rem;
    color: #000;
    padding: 3px 0;
    line-height: 1.5;
}
.wgp-detail-prob-val {
    font-weight: bold;
    color: var(--primary);
}
.wgp-detail-prob-highlight {
    font-weight: bold;
    color: var(--primary);
    font-size: 0.92rem;
    margin-top: 6px;
    padding-top: 8px;
}

/* 出貨時間 */
.wgp-detail-shipping {
    padding: 12px 0 0;
    background: none;
    border-radius: 0;
    border-top: 1px solid #f0f0f0;
    margin-bottom: 12px;
}
.wgp-detail-shipping-title {
    font-size: 0.88rem;
    font-weight: bold;
    color: #000;
    margin-bottom: 8px;
}
.wgp-detail-shipping-text {
    font-size: 0.85rem;
    color: #000;
    line-height: 1.5;
}

/* 返回按鈕 */
.wgp-detail-back {
    display: block;
    width: calc(100% - 40px);
    margin: 16px 20px 20px;
    padding: 13px;
    text-align: center;
    background: #f0f0f0;
    color: #333;
    border: none;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
}
.wgp-detail-back:hover { background: #e4e4e4; }

/* ── 退回模式 ───────────────────────────────────────────── */

/* 背包 header actions */
.wgp-backpack-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.wgp-wardrobe-inv-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.wgp-wardrobe-inv-header h3 {
    margin-bottom: 0;
}

.wgp-return-mode-btn {
    background: #f0f0f0;
    border: 1.5px solid #ddd;
    border-radius: 8px;
    padding: 5px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.wgp-return-mode-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.wgp-return-mode-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.wgp-return-all-btn {
    background: linear-gradient(135deg, #fff3e0, #ffe0b2);
    border: 1.5px solid #ffb74d;
    border-radius: 8px;
    padding: 5px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #e65100;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.wgp-return-all-btn:hover {
    background: linear-gradient(135deg, #ffe0b2, #ffcc80);
    border-color: #ff9800;
}

/* 退回模式下的 checkbox overlay */
.wgp-return-mode .wgp-inventory-item::before {
    content: '';
    position: absolute;
    top: 6px;
    left: 6px;
    width: 20px;
    height: 20px;
    border: 2px solid #ccc;
    border-radius: 4px;
    background: #fff;
    z-index: 10;
    transition: all 0.15s;
}

.wgp-return-mode .wgp-inventory-item {
    position: relative;
}

.wgp-return-mode .wgp-inventory-item.wgp-return-checked::before {
    background: var(--accent);
    border-color: var(--accent);
}

.wgp-return-mode .wgp-inventory-item.wgp-return-checked::after {
    content: '✓';
    position: absolute;
    top: 7px;
    left: 10px;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    z-index: 11;
    pointer-events: none;
}

/* 已穿戴卡片在退回模式中顯示 disabled 效果 */
.wgp-return-mode .wgp-inventory-item.equipped {
    opacity: 0.45;
    pointer-events: auto;
    cursor: not-allowed;
}

.wgp-return-mode .wgp-inventory-item.equipped::before {
    border-color: #e0e0e0;
    background: #e0e0e0;
}

/* 批次操作列（固定底部浮動） */
.wgp-batch-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: linear-gradient(to top, rgba(255,255,255,0.98), rgba(255,255,255,0.92));
    backdrop-filter: blur(6px);
    border-top: 1px solid #f0f0f0;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.1);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.wgp-batch-info {
    font-size: 0.9rem;
    font-weight: 600;
    color: #333;
}

.wgp-batch-return-btn {
    background: linear-gradient(135deg, var(--accent-light), var(--accent));
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 24px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(var(--accent-rgb), 0.35);
    transition: transform 0.15s, box-shadow 0.15s;
}

.wgp-batch-return-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 14px rgba(var(--accent-rgb), 0.45);
}

/* 單個退回按鈕（退回模式下每張卡片） */
.wgp-single-return-btn {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 4px 8px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--accent);
    background: rgba(var(--accent-rgb), 0.08);
    border: 1px solid rgba(var(--accent-rgb), 0.3);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.wgp-single-return-btn:hover:not(:disabled) {
    background: rgba(var(--accent-rgb), 0.18);
    border-color: var(--accent);
}

.wgp-single-return-btn:disabled {
    color: #bbb;
    background: #f5f5f5;
    border-color: #e0e0e0;
    cursor: not-allowed;
    opacity: 0.6;
}
