/* ============================================
   游戏化系统 - Galgame风格UI
   ============================================ */

/* ===== 游戏容器 ===== */
.game-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    pointer-events: none;
    cursor: grab;
    user-select: none;
    transition: opacity .2s ease, transform .2s ease;
}
.game-container.game-hidden {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
}

/* 隐藏按钮（在容器内） */
.game-toggle-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 0;
    background: rgba(0,0,0,0.45);
    color: #fff;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: background .15s ease;
}
.game-toggle-btn:hover {
    background: rgba(220,80,80,0.8);
}

/* 恢复按钮（容器隐藏后显示） */
.game-restore-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 0;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(139,92,246,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .15s ease, box-shadow .15s ease;
}
.game-restore-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(139,92,246,0.5);
}

.game-container:active {
    cursor: grabbing;
}

.game-container.dragging {
    cursor: grabbing;
    transition: none;
}

.game-container > * {
    pointer-events: auto;
}

/* ===== AI助手角色 ===== */
.assistant-character {
    position: relative;
    width: 120px;
    height: 160px;
    cursor: grab;
    transition: transform 0.3s ease;
    animation: float 3s ease-in-out infinite;
}

.game-container.dragging .assistant-character {
    animation: none;
    transition: none;
}

.assistant-character:hover {
    transform: scale(1.05);
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.character-sprite {
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
    border-radius: 60px 60px 30px 30px;
    position: relative;
    box-shadow: 0 8px 30px rgba(139, 92, 246, 0.5);
    overflow: hidden;
}

.character-sprite::before {
    content: '';
    position: absolute;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 30%;
    background: rgba(255,255,255,0.9);
    border-radius: 50%;
}

.character-face {
    position: absolute;
    top: 25%;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 50px;
}

.character-eyes {
    display: flex;
    justify-content: space-around;
    padding-top: 8px;
}

.eye {
    width: 12px;
    height: 14px;
    background: #1e293b;
    border-radius: 50%;
    animation: blink 4s infinite;
}

@keyframes blink {
    0%, 90%, 100% { transform: scaleY(1); }
    95% { transform: scaleY(0.1); }
}

.character-mouth {
    width: 20px;
    height: 8px;
    background: #1e293b;
    border-radius: 0 0 10px 10px;
    margin: 8px auto 0;
    transition: all 0.3s ease;
}

.character-mouth.happy {
    border-radius: 10px 10px 0 0;
    height: 6px;
}

.character-mouth.excited {
    width: 24px;
    height: 12px;
    border-radius: 50%;
}

/* ===== 对话框 ===== */
.assistant-dialog {
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    border: 1px solid rgba(99, 102, 241, 0.4);
    padding: 16px 20px;
    max-width: 280px;
    min-width: 200px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    animation: dialogPop 0.3s ease;
    position: relative;
}

.assistant-dialog::before {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 40px;
    width: 16px;
    height: 16px;
    background: rgba(15, 23, 42, 0.95);
    border-right: 1px solid rgba(99, 102, 241, 0.4);
    border-bottom: 1px solid rgba(99, 102, 241, 0.4);
    transform: rotate(45deg);
}

@keyframes dialogPop {
    from { opacity: 0; transform: scale(0.8) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.dialog-text {
    color: #e2e8f0;
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 8px;
}

.dialog-text .highlight {
    color: #a5b4fc;
    font-weight: 600;
}

.dialog-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 20px;
    height: 20px;
    border: none;
    background: rgba(255,255,255,0.1);
    color: #94a3b8;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dialog-close:hover {
    background: rgba(255,255,255,0.2);
}

/* ===== 经验值条 ===== */
.exp-bar-container {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.1);
    padding: 12px 16px;
    min-width: 200px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.exp-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.level-badge {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
}

.exp-text {
    color: #94a3b8;
    font-size: 0.75rem;
}

.exp-bar {
    width: 100%;
    height: 8px;
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
    overflow: hidden;
}

.exp-fill {
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #a855f7, #ec4899);
    border-radius: 4px;
    transition: width 0.5s ease;
    position: relative;
}

.exp-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ===== 成就通知 ===== */
.achievement-popup {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(245, 158, 11, 0.4);
    z-index: 2000;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.achievement-popup.show {
    transform: translateX(-50%) translateY(0);
}

.achievement-icon {
    font-size: 2rem;
}

.achievement-info h4 {
    font-size: 0.8rem;
    opacity: 0.9;
    margin-bottom: 2px;
}

.achievement-info p {
    font-size: 1rem;
    font-weight: 700;
}

/* ===== 任务完成特效 ===== */
.completion-effect {
    position: fixed;
    pointer-events: none;
    z-index: 1500;
}

.particle {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: particleBurst 0.8s ease-out forwards;
}

@keyframes particleBurst {
    0% { opacity: 1; transform: translate(0, 0) scale(1); }
    100% { opacity: 0; transform: translate(var(--tx), var(--ty)) scale(0); }
}

/* ===== 连击显示 ===== */
.combo-display {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    font-weight: 900;
    color: #fbbf24;
    text-shadow: 0 0 20px rgba(251, 191, 36, 0.5);
    pointer-events: none;
    opacity: 0;
    z-index: 1500;
}

.combo-display.show {
    animation: comboPopup 1s ease-out forwards;
}

@keyframes comboPopup {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    20% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
    100% { opacity: 0; transform: translate(-50%, -70%) scale(1); }
}

/* ===== 游戏面板 ===== */
.game-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 380px;
    height: 100vh;
    background: rgba(15, 23, 42, 0.98);
    backdrop-filter: blur(20px);
    border-left: 1px solid rgba(255,255,255,0.1);
    z-index: 2001;
    overflow-y: auto;
    transition: right 0.3s ease;
    padding: 20px;
}

.game-panel.open {
    right: 0;
}

.game-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.game-panel-header h2 {
    font-size: 1.2rem;
    color: #f1f5f9;
}

.close-panel-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    color: #94a3b8;
    cursor: pointer;
    font-size: 1rem;
}

.close-panel-btn:hover {
    background: rgba(255,255,255,0.12);
}

/* ===== 统计卡片 ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card {
    background: rgba(255,255,255,0.04);
    border-radius: 12px;
    padding: 16px;
    border: 1px solid rgba(255,255,255,0.06);
}

.stat-card-icon {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.stat-card-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #f1f5f9;
}

.stat-card-label {
    font-size: 0.75rem;
    color: #94a3b8;
}

/* ===== 成就列表 ===== */
.achievements-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.achievement-card {
    background: rgba(255,255,255,0.04);
    border-radius: 12px;
    padding: 16px 12px;
    text-align: center;
    border: 1px solid rgba(255,255,255,0.06);
    transition: all 0.2s ease;
}

.achievement-card.unlocked {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.3);
}

.achievement-card.locked {
    opacity: 0.4;
    filter: grayscale(1);
}

.achievement-card-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

.achievement-card-name {
    font-size: 0.75rem;
    color: #e2e8f0;
    font-weight: 600;
}

.achievement-card-desc {
    font-size: 0.65rem;
    color: #94a3b8;
    margin-top: 4px;
}

/* ===== 等级称号 ===== */
.level-titles {
    margin-top: 24px;
}

.level-title-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255,255,255,0.04);
    border-radius: 10px;
    margin-bottom: 8px;
}

.level-title-item.current {
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.level-title-icon {
    font-size: 1.5rem;
}

.level-title-info h4 {
    font-size: 0.85rem;
    color: #e2e8f0;
}

.level-title-info p {
    font-size: 0.7rem;
    color: #94a3b8;
}

/* ===== 移动端适配 ===== */
@media (max-width: 768px) {
    .game-container {
        bottom: 10px;
        right: 10px;
    }

    .assistant-character {
        width: 80px;
        height: 100px;
    }

    .assistant-dialog {
        max-width: 220px;
        padding: 12px 16px;
    }

    .exp-bar-container {
        min-width: 160px;
        padding: 10px 12px;
    }

    .game-panel {
        width: 100%;
        right: -100%;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .achievements-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
