:root {
    --apple-blue: #007aff; --apple-green: #34c759; --apple-red: #ff3b30; 
    --apple-orange: #ff9500; --apple-purple: #af52de; --apple-gray: #8e8e93;
    --glass-bg: rgba(255, 255, 255, 0.65); --glass-border: rgba(255, 255, 255, 0.4);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    --dark: #2c3e50; --primary: #2ecc71; --secondary: #3498db;
    --rare: #f1c40f; --epic: #9b59b6; --legend: #e74c3c;
}

* { box-sizing: border-box; } 

body { 
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; 
    margin: 0; display: flex; flex-direction: column; align-items: center; 
    padding: 20px 10px; overflow-x: hidden; transition: background 0.8s; min-height: 100vh;
    -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; -webkit-user-drag: none;
}

img { -webkit-user-drag: none; pointer-events: none; }

/* 效能優化：開啟硬體加速並優化動畫屬性 */
.fluid-bg {
    position: fixed; 
    top: -50%; left: -50%; width: 200vw; height: 200vh; z-index: -1;
    background: radial-gradient(circle at 50% 50%, #e0eafc, #cfdef3, #fdfbfb); 
    background-size: 100% 100%;
    animation: flow 20s linear infinite; 
    transition: background 1s ease; 
    will-change: transform; 
    transform: translateZ(0); /* 🚀 新增：強制開啟 GPU 硬體加速 */
}
@keyframes flow { 0% { transform: rotate(0deg) scale(1); } 50% { transform: rotate(180deg) scale(1.05); } 100% { transform: rotate(360deg) scale(1); } }

.glass-panel { background: var(--glass-bg); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid var(--glass-border); box-shadow: var(--glass-shadow); border-radius: 24px; will-change: transform, backdrop-filter; }

.app-container { width: 100%; max-width: 500px; margin: 0 auto; padding: 0 10px 100px 10px; position: relative; z-index: 1;}
.view-section { display: none; animation: slideUpFade 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }
.view-section.active { display: block; }
@keyframes slideUpFade { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.player-profile { display: flex; justify-content: space-between; align-items: center; padding: 20px; margin-bottom: 25px; position: relative; color: #1c1c1e; }
body.bg-alchemy .player-profile { color: white; }
.profile-left { text-align: left; z-index: 2; flex: 1;}
.player-title { font-size: 15px; font-weight: 800; color: var(--apple-blue); letter-spacing: 1px; text-transform: uppercase; margin-bottom: 2px;}
.player-subtitle { font-size: 12px; color: var(--apple-gray); font-weight: 600; }
.player-level { font-size: 26px; font-weight: 800; line-height: 1; }
.exp-bar-container { width: 100%; height: 8px; background: rgba(0,0,0,0.1); border-radius: 4px; margin-top: 8px; overflow: hidden; }
body.bg-alchemy .exp-bar-container { background: rgba(255,255,255,0.2); }
.exp-bar { height: 100%; width: 0%; background: var(--apple-green); transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1); }
.coin-badge { position: absolute; top: 50%; right: 15px; transform: translateY(-50%); padding: 8px 14px; border-radius: 20px; font-weight: 800; color: #d35400; font-size: 16px; z-index: 10; display: flex; align-items: center; gap: 5px; background: rgba(255,255,255,0.9); box-shadow: 0 2px 8px rgba(0,0,0,0.1);}
body.bg-alchemy .coin-badge { background: rgba(0,0,0,0.5); color: #f39c12; }

.ios-title { font-size: 32px; font-weight: 800; letter-spacing: -0.5px; color: #1c1c1e; margin-bottom: 20px; margin-top: 10px; }
body.bg-alchemy .ios-title { color: #fff; }
.ios-subtitle { font-size: 18px; font-weight: 700; color: #3a3a3c; margin-bottom: 12px;}
body.bg-alchemy .ios-subtitle { color: #eee; }
.ios-desc { font-size: 14px; color: var(--apple-gray); line-height: 1.4;}

.ios-btn { width: 100%; padding: 16px; border-radius: 18px; border: none; font-size: 17px; font-weight: 700; cursor: pointer; display: flex; justify-content: center; align-items: center; gap: 8px; transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.2s; color: white; box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.ios-btn:active { transform: scale(0.95); box-shadow: 0 2px 6px rgba(0,0,0,0.1); }
.primary-btn { background: var(--apple-blue); } .danger-btn { background: var(--apple-red); }
.warning-btn { background: var(--apple-orange); } .epic-btn { background: var(--apple-purple); }
.info-btn { background: var(--apple-green); } .secondary-btn { background: #34495e; }
.cancel-btn { background: #e5e5ea; color: #1c1c1e; box-shadow: none; }
.mt-2 { margin-top: 10px; } .mt-3 { margin-top: 15px; } .mb-2 { margin-bottom: 10px; }

.bottom-tab-bar { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); width: 92%; max-width: 400px; display: flex; justify-content: space-around; padding: 12px 5px; z-index: 100; border-radius: 35px; }
.tab-item { text-align: center; font-size: 24px; cursor: pointer; opacity: 0.4; transition: 0.3s; transform: scale(0.9); }
.tab-item span { display: block; font-size: 11px; font-weight: 700; margin-top: 5px; }
.tab-item.active { opacity: 1; transform: scale(1.1); color: var(--apple-blue); }
body.bg-alchemy .tab-item.active { color: var(--apple-orange); }

.filter-scroll { display: flex; overflow-x: auto; gap: 10px; padding: 12px; border-radius: 20px; scrollbar-width: none; margin-bottom: 15px;}
.filter-scroll::-webkit-scrollbar { display: none; }
.filter-chip { padding: 10px 18px; border-radius: 20px; border: 1px solid rgba(0,0,0,0.1); background: rgba(255,255,255,0.6); font-size: 14px; font-weight: 700; color: #1c1c1e; cursor: pointer; transition: 0.2s; white-space: nowrap; box-shadow: 0 2px 5px rgba(0,0,0,0.05);}
.filter-chip.active { background: #1c1c1e; color: white; border-color: #1c1c1e; box-shadow: 0 4px 12px rgba(0,0,0,0.2);}
body.bg-alchemy .filter-chip { background: rgba(0,0,0,0.5); color: #ccc; border-color: rgba(255,255,255,0.2);}
body.bg-alchemy .filter-chip.active { background: var(--rare); color: #000; }

.gallery-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 15px; padding-bottom: 20px; }
@media (max-width: 400px) { .gallery-grid { gap: 5px; } .stars { font-size: 10px; letter-spacing: 1px; } }
.card-item { width: 100%; padding-bottom: 140%; background: #fff; border-radius: 12px; position: relative; border: 2px solid transparent; overflow: hidden; transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.2s; box-shadow: 0 4px 10px rgba(0,0,0,0.1); cursor: pointer; }
.card-item.owned:hover { transform: scale(1.08) translateY(-5px) perspective(500px) rotateX(5deg); z-index: 10; box-shadow: 0 15px 25px rgba(0,0,0,0.2); }
.full-card-img { position: absolute; top: 0; left: 0; right: 0; bottom: 0; width: 100%; height: 100%; object-fit: cover; z-index: 2; transition: filter 0.3s; }
.locked-blur { filter: grayscale(100%) brightness(0.7); opacity: 0.85; }
.stars-overlay { position: absolute; bottom: 0; left: 0; right: 0; padding: 15px 0 5px 0; background: linear-gradient(transparent, rgba(0,0,0,0.8)); text-align: center; z-index: 5; pointer-events: none; }
.stars { font-size: 14px; color: #f1c40f; letter-spacing: 2px; text-shadow: 0 2px 4px rgba(0,0,0,0.8); }
.locked-overlay { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 35px; z-index: 10; opacity: 0.9; text-shadow: 0 2px 5px rgba(0,0,0,0.5); pointer-events: none; }

.card-item.n { border-color: #bdc3c7; } .card-item.r { border-color: var(--secondary); } .card-item.sr { border-color: var(--epic); }
.card-item.ssr { border-color: var(--rare); animation: glow 1.5s infinite alternate; }
.card-item.max-star { border-color: #f39c12; box-shadow: 0 0 15px rgba(243, 156, 18, 0.6); }
.card-item.locked { border-color: #ccc; }
.card-item.maxed-out { opacity: 0.4; cursor: not-allowed; filter: grayscale(100%); border-color: transparent;} .card-item.maxed-out:hover { transform: none; }

@keyframes glow { from { box-shadow: 0 0 5px var(--rare); } to { box-shadow: 0 0 20px var(--rare); } }

.quest-board { padding: 20px; margin-top: 20px; text-align: left; }
.quest-item { display: flex; justify-content: space-between; align-items: center; padding: 15px 0; border-bottom: 1px solid rgba(0,0,0,0.05); }
.quest-item:last-child { border-bottom: none; padding-bottom: 0; }

.status-bar { display: flex; justify-content: space-between; align-items: center; padding: 15px 20px; margin-bottom: 20px; font-weight: bold; }
.ion-display { font-size: 36px; font-weight: bold; margin: 20px 0; min-height: 120px; display: flex; justify-content: center; align-items: center; flex-direction: column; font-family: 'Times New Roman', serif; line-height: 1.3; text-align: center;}
.options-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 20px; }
.option-btn { background: rgba(255,255,255,0.8); border: 2px solid rgba(0,0,0,0.1); padding: 15px 5px; font-size: 22px; font-family: 'Times New Roman', serif; border-radius: 16px; cursor: pointer; transition: 0.2s; min-height: 80px; color: var(--dark); font-weight: bold; box-shadow: 0 4px 10px rgba(0,0,0,0.05);}
body.bg-alchemy .option-btn { background: rgba(0,0,0,0.6); border-color: rgba(255,255,255,0.1); color: white; }
.option-btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 15px rgba(0,0,0,0.1); }
.option-btn.correct { background: var(--apple-green) !important; color: white !important; border-color: transparent !important; }
.option-btn.wrong { background: var(--apple-red) !important; color: white !important; border-color: transparent !important; }

.battery { width: 60px; height: 25px; border: 2px solid var(--dark); border-radius: 6px; position: relative; padding: 2px; }
.battery::after { content: ''; position: absolute; right: -6px; top: 4px; width: 4px; height: 12px; background: var(--dark); border-radius: 0 2px 2px 0;}
.battery-level { height: 100%; width: 0%; background: var(--apple-green); transition: width 0.3s; border-radius: 3px;}
body.bg-alchemy .battery { border-color: white; }
body.bg-alchemy .battery::after { background: white; }

.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 200; justify-content: center; align-items: flex-end; padding: 10px;}
.modal-content { width: 100%; max-width: 500px; margin-bottom: 25px; animation: slideUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); padding: 30px 25px; text-align: center;}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.transparent-panel { background: transparent !important; box-shadow: none !important; border: none !important; backdrop-filter: none !important; -webkit-backdrop-filter: none !important;}
.anim-lock { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; z-index: 9999; display: none; }
.fab-btn { position: fixed; top: 15px; left: 15px; width: 48px; height: 48px; border-radius: 50%; display: flex; justify-content: center; align-items: center; font-size: 22px; cursor: pointer; z-index: 10;}

.reveal-card { width: 220px; height: 308px; background: #fff; border-radius: 12px; position: relative; margin: 0 auto 20px auto; transform: scale(0); transition: 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275); box-shadow: 0 20px 50px rgba(0,0,0,0.5); overflow: hidden; }
.reveal-card.show { transform: scale(1); }
.ten-draw-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; width: 100%; margin-bottom: 20px; }
@media (max-width: 600px) { .ten-draw-grid { grid-template-columns: repeat(3, 1fr); } }

.gacha-anim-container { font-size: 100px; text-shadow: 0 0 30px var(--primary); animation: gachaShake 2s cubic-bezier(.36,.07,.19,.97) both; transform-origin: bottom center;}
@keyframes gachaShake { 0% { transform: scale(1) rotate(0deg); } 20% { transform: scale(1.1) rotate(-10deg); filter: hue-rotate(45deg); } 40% { transform: scale(1.2) rotate(10deg); filter: hue-rotate(90deg); } 60% { transform: scale(1.4) rotate(-15deg); filter: hue-rotate(180deg); } 80% { transform: scale(1.6) rotate(15deg); filter: hue-rotate(270deg); } 100% { transform: scale(2) rotate(0deg); filter: brightness(200%); } }
.explosion-anim { font-size: 120px; animation: explode 0.5s ease-out both; }
@keyframes explode { 0% { transform: scale(0.5); opacity: 0; } 50% { transform: scale(1.5); opacity: 1; filter: brightness(200%);} 100% { transform: scale(1); opacity: 1; } }
.screen-shake { animation: sShake 0.4s ease-in-out; }
@keyframes sShake { 0% { transform: translate(0, 0); } 25% { transform: translate(10px, -10px); } 50% { transform: translate(-10px, 10px); } 75% { transform: translate(10px, 10px); } 100% { transform: translate(0, 0); } }

.white-flash { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: white; z-index: 200; opacity: 0; pointer-events: none; transition: opacity 0.4s ease-in-out; }
.white-flash.active { opacity: 1; }

.save-textarea { width: 100%; height: 120px; margin: 15px 0; padding: 12px; border-radius: 12px; border: 1px solid rgba(0,0,0,0.1); resize: none; font-family: monospace; font-size: 13px; box-sizing: border-box; background: rgba(255,255,255,0.5); color: #1c1c1e;}
.save-textarea:focus { outline: none; border-color: var(--apple-blue); background: white; box-shadow: 0 0 0 3px rgba(0,122,255,0.2);}
.pvp-banner { background: var(--apple-red); color: white; padding: 15px; font-weight: 800; margin-bottom: 20px; text-align: center; border: none; box-shadow: 0 8px 20px rgba(255,59,48,0.3);}
.reward-badge { background: var(--apple-orange); color: white; padding: 8px 16px; border-radius: 20px; font-weight: 800; font-size: 16px; margin: 10px auto; animation: bounce 1s infinite alternate; width: fit-content; box-shadow: 0 4px 10px rgba(255, 149, 0, 0.4); }
@keyframes bounce { from { transform: translateY(0); } to { transform: translateY(-5px); } }

.highlight-text { color: var(--apple-blue); }
.timer-text { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 20px; color: var(--apple-red); }
sub, sup { font-size: 0.6em; }
.ios-input { width: 100%; height: 50px; margin: 15px 0; padding: 10px; border-radius: 12px; border: 1px solid rgba(0,0,0,0.1); font-family: monospace; font-size: 18px; font-weight: bold; text-align: center; text-transform: uppercase; box-sizing: border-box; background: rgba(255,255,255,0.8); color: #1c1c1e; outline: none; transition: 0.2s;}
.ios-input:focus { border-color: var(--apple-blue); box-shadow: 0 0 0 3px rgba(0,122,255,0.2); background: white; }
body.bg-fever .fluid-bg { background: radial-gradient(circle at 50% 50%, #f6d365, #fda085, #ffecd2); animation: flow 3s linear infinite; }
body.bg-fever .glass-panel { border-color: rgba(243, 156, 18, 0.5); box-shadow: 0 8px 32px rgba(243, 156, 18, 0.2); }

.profile-right { display: flex; flex-direction: column; align-items: flex-end; width: 50%; margin-right: 60px; z-index: 2; }
.exp-text { font-size: 10px; color: var(--apple-gray); font-weight: 700; margin-bottom: 3px; letter-spacing: 0.5px; }
body.bg-alchemy .exp-text { color: #ddd; }

.lb-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 10px; border-bottom: 1px solid rgba(0,0,0,0.05); font-weight: bold; }
.lb-rank { width: 30px; font-size: 18px; text-align: center; }
.lb-name { flex: 1; margin-left: 10px; font-size: 16px; color: var(--dark); }
.lb-lvl { color: var(--apple-blue); font-size: 14px; }
.lb-row.top-1 .lb-rank { font-size: 24px; }
.lb-row.top-2 .lb-rank { font-size: 22px; }
.lb-row.top-3 .lb-rank { font-size: 20px; }

.fallback-content { display: flex; flex-direction: column; justify-content: center; align-items: center; width: 100%; height: 100%; position: absolute; top: 0; left: 0; text-align: center; padding: 5px; box-sizing: border-box; }
.fallback-content div:first-child { font-family: 'Times New Roman', serif; font-weight: bold; }

/* =========================================
   🖥️ 電腦與平板版專用佈局 (Responsive Web Design)
   ========================================= */
@media (min-width: 768px) {
    /* 1. 放寬主要內容區塊，並靠右對齊留出左側導覽列空間 */
    .app-container {
        max-width: 900px;
        padding: 20px 20px 20px 120px; 
    }

    /* 2. 將底部導覽列改為「左側固定側邊欄」 */
    .bottom-tab-bar {
        top: 50%;
        left: 20px;
        bottom: auto;
        transform: translateY(-50%);
        width: 80px;
        flex-direction: column;
        padding: 20px 5px;
        box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    }

    .tab-item {
        margin: 15px 0;
    }

    /* 3. 測驗模式按鈕改為並排顯示 */
    .game-modes {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 15px;
    }
    .game-modes .mt-3 {
        margin-top: 0; /* 移除手機版的垂直間距 */
    }

    /* 4. 放寬圖鑑與實驗室的網格顯示數量 (一排 6 個) */
    .gallery-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: 15px;
    }

    /* 5. 調整抽卡動畫顯示的卡片大小 */
    .reveal-card {
        width: 260px;
        height: 364px;
    }
}

/* 針對更大螢幕（如桌上型螢幕）的進階微調 */
@media (min-width: 1024px) {
    .app-container {
        max-width: 1100px;
        padding-left: 150px;
    }
    
    .bottom-tab-bar {
        width: 100px;
    }

    .gallery-grid {
        grid-template-columns: repeat(8, 1fr); /* 一排 8 個 */
    }
}
