:root {
    --bg-color: #000000;
    --glass-surface: rgba(30, 30, 40, 0.75); /* 稍微加深背景提高可读性 */
    --glass-border: rgba(255, 255, 255, 0.12);
    --accent-color: #0a84ff;
    --accent-gradient: linear-gradient(135deg, #0a84ff, #5e5ce6);
    --text-primary: #f5f5f7;
    --text-secondary: #86868b;
    --cost-1: #a0a0a0; --cost-2: #30d158; --cost-3: #0a84ff;
    --font-stack: -apple-system, BlinkMacSystemFont, "SF Pro Text", Helvetica, sans-serif;
}

body {
    margin: 0;
    background-color: var(--bg-color);
    font-family: var(--font-stack);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

#bg-layer {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: -1;
    background-image: url('assets/background.png');
    background-size: cover;
    background-position: center;
    filter: brightness(0.4) saturate(1.2);
    transform: scale(1.05); 
}

#ui-layer {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; 
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px;
    box-sizing: border-box;
    z-index: 10;
}

.pointer-events-auto { pointer-events: auto; }

.glass-panel {
    background: var(--glass-surface);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

#top-bar {
    height: 64px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    margin-bottom: 20px;
}

.stat-group { display: flex; gap: 24px; font-weight: 600; font-size: 15px; letter-spacing: -0.3px; }
.stat-item { display: flex; align-items: center; gap: 8px; }
.stat-icon { font-size: 18px; filter: drop-shadow(0 0 5px rgba(255,255,255,0.3)); }

.control-group { display: flex; gap: 12px; }

.icon-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 40px; height: 40px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 18px;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.25); transform: scale(1.05); }

#canvas-wrapper {
    flex-grow: 1;
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1); /* Smooth Zoom */
}
/* 当商店打开时，棋盘缩小并上移 */
#canvas-wrapper.board-shrunk {
    transform: scale(0.85) translateY(-60px);
}

canvas {
    max-width: 100%;
    max-height: 100%;
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5); 
    image-rendering: -webkit-optimize-contrast;
}

#synergy-float {
    position: absolute;
    left: 20px;
    top: 100px;
    width: 200px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none; 
    z-index: 20;
}
.syn-tag {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    padding: 10px 14px;
    border-radius: 12px;
    border-left: 4px solid #555;
    color: #fff;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transition: all 0.3s;
}
.syn-tag.active {
    border-left-color: var(--cost-2);
    background: rgba(20, 40, 30, 0.85);
    transform: translateX(5px);
}
.syn-head { display: flex; justify-content: space-between; font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.syn-body { font-size: 11px; color: #ccc; line-height: 1.3; }

#shop-dock {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(150%); /* Hidden */
    width: auto;
    min-width: 600px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: transform 0.5s cubic-bezier(0.19, 1, 0.22, 1);
    z-index: 100;
}
#shop-dock.visible { transform: translateX(-50%) translateY(0); }

/* Minimized State: Slide down but keep header visible */
#shop-dock.minimized { transform: translateX(-50%) translateY(calc(100% - 15px)); opacity: 0.8; }
#shop-dock.minimized:hover { opacity: 1; transform: translateX(-50%) translateY(calc(100% - 25px)); } /* Peek hint */

/* Toggle Button for Shop */
.dock-header {
    position: absolute;
    top: -20px;
    left: 0;
    width: 100%; 
    display: flex;
    justify-content: center;
    pointer-events: none;
}
.dock-toggle-btn {
    pointer-events: auto;
    cursor: pointer;
    background: var(--glass-surface);
    border: 1px solid var(--glass-border);
    border-bottom: none;
    border-radius: 12px 12px 0 0;
    padding: 4px 20px;
    color: #aaa;
    font-size: 12px;
    box-shadow: 0 -4px 10px rgba(0,0,0,0.2);
    transition: 0.2s;
}
.dock-toggle-btn:hover { color: white; background: var(--accent-color); }

.shop-cards {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.card {
    width: 110px;
    height: 150px;
    position: relative;
    border-radius: 14px;
    background: linear-gradient(160deg, #2a2a2e, #1c1c1e);
    border: 1px solid rgba(255,255,255,0.08);
    cursor: pointer;
    transition: all 0.3s;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}
.card:hover { transform: translateY(-10px) scale(1.05); z-index: 10; border-color: rgba(255,255,255,0.4); }
.card:active { transform: scale(0.95); }

.card[data-cost="1"] { border-bottom: 3px solid var(--cost-1); }
.card[data-cost="2"] { border-bottom: 3px solid var(--cost-2); }
.card[data-cost="3"] { border-bottom: 3px solid var(--cost-3); }

.card-img-box {
    width: 80px; height: 80px;
    margin-top: 12px;
    border-radius: 12px;
    background: rgba(0,0,0,0.3);
    overflow: hidden;
    display: flex; justify-content: center; align-items: center;
}
.card-img-box img { width: 100%; height: 100%; object-fit: contain; }

.card-info { padding: 8px 4px; text-align: center; width: 100%; }
.c-name { font-size: 13px; font-weight: 700; color: #fff; margin-bottom: 4px; }
.c-meta { font-size: 10px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-cost { 
    position: absolute; top: 6px; right: 6px; 
    font-size: 11px; font-weight: 800; color: #ffd700; 
    background: rgba(0,0,0,0.6); padding: 2px 6px; border-radius: 6px;
}

.shop-actions { display: flex; justify-content: space-between; align-items: center; padding: 0 10px; }

.action-btn {
    padding: 12px 32px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 15px;
    border: none;
    cursor: pointer;
    transition: 0.2s;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    display: flex; align-items: center; gap: 8px;
}

.btn-reroll { background: rgba(255, 255, 255, 0.08); color: var(--accent-color); }
.btn-reroll:hover { background: rgba(255, 255, 255, 0.15); }

.btn-battle { background: var(--accent-gradient); color: white; box-shadow: 0 4px 20px rgba(10, 132, 255, 0.4); }
.btn-battle:hover { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(10, 132, 255, 0.5); }

.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(10px);
    z-index: 1000;
    display: none;
    justify-content: center; align-items: center;
    opacity: 0; animation: fadeIn 0.3s forwards;
}
@keyframes fadeIn { to { opacity: 1; } }

.modal-card {
    background: #1c1c1e;
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 40px;
    width: 90%; max-width: 380px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    transform: scale(0.9); animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
@keyframes popIn { to { transform: scale(1); } }

.modal-card h2 { margin: 0 0 10px; font-size: 24px; background: var(--accent-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.modal-card p { color: var(--text-secondary); margin-bottom: 24px; font-size: 14px; }

.apple-input {
    background: #2c2c2e; border: none;
    color: white; padding: 14px; border-radius: 12px;
    width: 100%; box-sizing: border-box; margin-bottom: 20px;
    font-size: 16px; text-align: center; outline: none;
    transition: box-shadow 0.2s;
}
.apple-input:focus { box-shadow: 0 0 0 2px var(--accent-color); }

.float-text {
    position: absolute;
    font-weight: 800;
    pointer-events: none;
    animation: floatUp 0.6s cubic-bezier(0.23, 1, 0.32, 1) forwards;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    z-index: 500;
}
@keyframes floatUp {
    0% { opacity: 0; transform: translate(-50%, 0) scale(0.5); }
    20% { opacity: 1; transform: translate(-50%, -20px) scale(1.2); }
    100% { opacity: 0; transform: translate(-50%, -60px) scale(1); }
}

#loading {
    position: fixed; z-index: 9999; background: #000;
    top: 0; left: 0; width: 100%; height: 100%;
    display: flex; justify-content: center; align-items: center; flex-direction: column;
    color: #666; font-size: 12px; letter-spacing: 2px; text-transform: uppercase;
}
.spinner {
    width: 40px; height: 40px; border: 3px solid rgba(255,255,255,0.1);
    border-top-color: var(--accent-color); border-radius: 50%;
    animation: spin 0.8s linear infinite; margin-bottom: 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 850px) {
    #shop-dock { min-width: 100%; width: 100%; bottom: 0; border-radius: 24px 24px 0 0; padding-bottom: 30px; }
    .shop-cards { overflow-x: auto; justify-content: flex-start; padding: 4px 10px; }
    .card { flex-shrink: 0; }
    #top-bar { padding: 0 12px; height: 50px; }
    .stat-group { gap: 12px; font-size: 13px; }
    
    /* Mobile Synergies: Hidden by default, shown via Modal */
    #synergy-float {
        display: none; /* Override inline styles via JS class */
    }
    /* Special class when toggled on mobile */
    #synergy-float.mobile-active {
        display: flex;
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 80%;
        max-height: 70vh;
        overflow-y: auto;
        background: rgba(20,20,25,0.95);
        padding: 20px;
        border-radius: 20px;
        border: 1px solid rgba(255,255,255,0.1);
        z-index: 2000;
        box-shadow: 0 0 50px black;
    }
    #btn-syn-mobile { display: flex; }
    
    /* Disable Board Shrink on Mobile (Screen too small) */
    #canvas-wrapper.board-shrunk { transform: none !important; }
}