/* ===== 基础样式 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #4ade80;
    --primary-dark: #16a34a;
    --secondary: #60a5fa;
    --danger: #f87171;
    --warning: #fbbf24;
    --bg-dark: #0f0c29;
    --bg-card: rgba(255,255,255,0.05);
    --text-light: #f0f0f0;
    --text-muted: #94a3b8;
    --border: rgba(255,255,255,0.1);
    --glow-green: 0 0 20px rgba(74, 222, 128, 0.4);
    --glow-blue: 0 0 20px rgba(96, 165, 250, 0.4);
}

body {
    font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
    background: #0f0c29;
    min-height: 100vh;
    color: var(--text-light);
    overflow: hidden;
}

#game-container {
    max-width: 960px;
    margin: 0 auto;
    min-height: 100vh;
    position: relative;
}

/* ===== 屏幕切换 ===== */
.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* ===== 开始界面 ===== */
#start-screen {
    justify-content: center;
    align-items: center;
    text-align: center;
    position: relative;
    overflow: hidden;
    background: radial-gradient(ellipse at center, #1a1040 0%, #0f0c29 70%);
}

/* 粒子背景 */
#start-screen::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(1px 1px at 10% 20%, rgba(255,255,255,0.6) 0%, transparent 100%),
        radial-gradient(1px 1px at 30% 60%, rgba(255,255,255,0.4) 0%, transparent 100%),
        radial-gradient(1px 1px at 50% 10%, rgba(255,255,255,0.5) 0%, transparent 100%),
        radial-gradient(1px 1px at 70% 80%, rgba(255,255,255,0.3) 0%, transparent 100%),
        radial-gradient(1px 1px at 90% 40%, rgba(255,255,255,0.6) 0%, transparent 100%),
        radial-gradient(1px 1px at 20% 90%, rgba(255,255,255,0.4) 0%, transparent 100%),
        radial-gradient(1px 1px at 80% 15%, rgba(255,255,255,0.5) 0%, transparent 100%),
        radial-gradient(1px 1px at 45% 50%, rgba(255,255,255,0.3) 0%, transparent 100%),
        radial-gradient(2px 2px at 60% 30%, rgba(96,165,250,0.5) 0%, transparent 100%),
        radial-gradient(2px 2px at 15% 70%, rgba(74,222,128,0.4) 0%, transparent 100%);
    pointer-events: none;
    animation: twinkle 4s ease-in-out infinite alternate;
}

@keyframes twinkle {
    0% { opacity: 0.6; }
    100% { opacity: 1; }
}

/* 光晕装饰 */
#start-screen::after {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(74,222,128,0.06) 0%, transparent 70%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.5; }
    50% { transform: translate(-50%, -50%) scale(1.1); opacity: 1; }
}

.start-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.logo {
    font-size: 5rem;
    margin-bottom: 10px;
    filter: drop-shadow(0 0 20px rgba(74,222,128,0.8));
    animation: logo-float 3s ease-in-out infinite;
}

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

#start-screen h1 {
    font-size: 2.8rem;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #4ade80, #60a5fa, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    letter-spacing: 2px;
}

.start-subtitle {
    color: var(--text-muted);
    margin-bottom: 40px;
    font-size: 1rem;
    letter-spacing: 1px;
}

.input-group {
    margin-bottom: 20px;
    position: relative;
}

.input-group input {
    padding: 14px 24px;
    font-size: 1.1rem;
    border: 2px solid rgba(74,222,128,0.3);
    border-radius: 50px;
    background: rgba(255,255,255,0.05);
    color: var(--text-light);
    text-align: center;
    width: 280px;
    backdrop-filter: blur(10px);
    transition: all 0.3s;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--glow-green);
    background: rgba(74,222,128,0.05);
}

.input-group input::placeholder {
    color: var(--text-muted);
}

/* ===== 按钮样式 ===== */
.btn {
    padding: 12px 24px;
    font-size: 1rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(255,255,255,0.05);
    color: var(--text-light);
    border: 1px solid var(--border);
    backdrop-filter: blur(10px);
}

.btn:hover {
    transform: translateY(-2px);
    background: rgba(255,255,255,0.1);
    box-shadow: 0 8px 20px rgba(0,0,0,0.3);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, #16a34a, #15803d);
    border-color: var(--primary);
    font-weight: bold;
    font-size: 1.1rem;
    padding: 14px 40px;
    border-radius: 50px;
    box-shadow: var(--glow-green);
    letter-spacing: 1px;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #4ade80, #22c55e);
    box-shadow: 0 0 30px rgba(74,222,128,0.6);
}

/* ===== 玩家信息 ===== */
.player-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: bold;
    font-size: 0.95rem;
}

/* ===== 游戏界面 ===== */
#game-screen {
    padding: 8px;
    gap: 8px;
    background: #0f0c29;
    height: 100vh;
    overflow: hidden;
}

#top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255,255,255,0.04);
    padding: 10px 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    backdrop-filter: blur(20px);
    flex-shrink: 0;
}

.hp-xp-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
}

/* 金币栏样式 */
#gold-bar {
    display: flex !important;
    min-width: 60px;
}

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

.bar-fill {
    height: 100%;
    transition: width 0.4s ease;
    border-radius: 4px;
}

.hp-fill {
    background: linear-gradient(90deg, #f87171, #fbbf24, #4ade80);
}

.xp-fill {
    background: linear-gradient(90deg, #60a5fa, #c084fc);
    box-shadow: 0 0 6px rgba(96,165,250,0.5);
}

#game-view {
    flex: 1;
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: inset 0 0 60px rgba(0,0,0,0.5);
}

#game-canvas {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    cursor: crosshair;
}

#map-info {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(0,0,0,0.8);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    z-index: 20;
    border: 2px solid var(--border);
    backdrop-filter: blur(10px);
    letter-spacing: 1px;
    transition: all 0.3s;
}

#map-info.locked {
    border-color: #f87171;
    color: #f87171;
}

#map-info.unlocked {
    border-color: #4ade80;
    color: #4ade80;
}

#message-box {
    position: absolute;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.85);
    color: #fff;
    padding: 12px 24px;
    border-radius: 20px;
    font-size: 14px;
    z-index: 50;
    text-align: center;
    max-width: 80%;
    display: none;
    border: 1px solid rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

#bottom-bar {
    display: flex;
    gap: 8px;
    background: rgba(255,255,255,0.04);
    padding: 8px;
    border-radius: 12px;
    border: 1px solid var(--border);
    flex-shrink: 0;
}

#bottom-bar .btn {
    flex: 1;
    padding: 10px;
    font-size: 0.85rem;
    border-radius: 8px;
}

/* ===== 角色 ===== */
.player {
    position: absolute;
    width: 64px;
    height: 64px;
    font-size: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    filter: drop-shadow(0 0 8px rgba(74,222,128,0.8));
    transition: left 0.05s linear, top 0.05s linear;
}

.player::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 28px;
    height: 8px;
    background: radial-gradient(ellipse, rgba(74,222,128,0.4) 0%, transparent 70%);
    border-radius: 50%;
}

/* ===== NPC ===== */
.npc {
    position: absolute;
    width: 64px;
    height: 64px;
    font-size: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    cursor: pointer;
}

.npc.enemy {
    animation: enemy-float 2.5s ease-in-out infinite;
    filter: drop-shadow(0 0 8px rgba(248,113,113,0.7));
}

.npc.friendly {
    animation: npc-float 3s ease-in-out infinite;
    filter: drop-shadow(0 0 8px rgba(96,165,250,0.7));
}

.npc.portal {
    animation: portal-spin 4s linear infinite;
    filter: drop-shadow(0 0 12px rgba(192,132,252,0.9));
    font-size: 48px;
}

.npc.back-portal {
    animation: back-portal-pulse 2s ease-in-out infinite;
    filter: drop-shadow(0 0 10px rgba(96,165,250,0.8));
    font-size: 48px;
}

@keyframes back-portal-pulse {
    0%, 100% { transform: scale(1); opacity: 0.9; }
    50% { transform: scale(1.15) translateY(-3px); opacity: 1; }
}

@keyframes enemy-float {
    0%, 100% { transform: translateY(0) rotate(-3deg); }
    50% { transform: translateY(-6px) rotate(3deg); }
}

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

@keyframes portal-spin {
    0% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(180deg) scale(1.1); }
    100% { transform: rotate(360deg) scale(1); }
}

/* NPC 名字标签 */
.npc-label {
    position: absolute;
    bottom: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    white-space: nowrap;
    color: var(--text-muted);
    background: rgba(0,0,0,0.6);
    padding: 2px 6px;
    border-radius: 4px;
    pointer-events: none;
}

/* 点击目标 */
.click-target {
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid var(--primary);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: target-pulse 0.6s ease-out forwards;
    pointer-events: none;
    z-index: 30;
}

@keyframes target-pulse {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(2); opacity: 0; }
}

/* ===== 战斗界面 ===== */
#battle-screen {
    padding: 16px;
    gap: 12px;
    background: radial-gradient(ellipse at center top, #1a0a2e 0%, #0f0c29 60%);
    overflow-y: auto;
}

#battle-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255,255,255,0.04);
    border-radius: 16px;
    padding: 20px;
    border: 1px solid var(--border);
    backdrop-filter: blur(20px);
    position: relative;
    overflow: hidden;
    min-height: 160px;
}

#battle-header::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(74,222,128,0.03) 0%, rgba(248,113,113,0.03) 100%);
    pointer-events: none;
}

.combatant {
    text-align: center;
    flex: 1;
    position: relative;
    z-index: 1;
    transition: all 0.3s;
}

.combatant .avatar {
    font-size: 3.5rem;
    margin-bottom: 10px;
    display: block;
    filter: drop-shadow(0 0 10px rgba(255,255,255,0.3));
    transition: all 0.3s;
}

#player-combatant .avatar {
    filter: drop-shadow(0 0 12px rgba(74,222,128,0.6));
    animation: hero-idle 2s ease-in-out infinite;
}

#enemy-combatant .avatar {
    filter: drop-shadow(0 0 12px rgba(248,113,113,0.6));
    animation: enemy-idle 1.5s ease-in-out infinite;
}

/* 攻击动画 */
.combatant.attacking .avatar {
    animation: attack 0.4s ease-out;
}

@keyframes attack {
    0% { transform: translateX(0) scale(1); }
    30% { transform: translateX(30px) scale(1.2); }
    60% { transform: translateX(60px) scale(1); }
    100% { transform: translateX(0) scale(1); }
}

#player-combatant.attacking .avatar {
    animation: player-attack 0.5s ease-out;
}

@keyframes player-attack {
    0% { transform: translateX(0); }
    40% { transform: translateX(80px) rotate(10deg); }
    100% { transform: translateX(0); }
}

#enemy-combatant.attacking .avatar {
    animation: enemy-attack 0.5s ease-out;
}

@keyframes enemy-attack {
    0% { transform: translateX(0); }
    40% { transform: translateX(-80px) rotate(-10deg); }
    100% { transform: translateX(0); }
}

/* 受伤动画 */
.combatant.hurt .avatar {
    animation: hurt 0.3s ease-out;
}

@keyframes hurt {
    0%, 100% { transform: translateX(0); filter: drop-shadow(0 0 10px rgba(255,255,255,0.3)); }
    25% { transform: translateX(-10px); filter: drop-shadow(0 0 20px rgba(248,113,113,0.8)); }
    75% { transform: translateX(10px); filter: drop-shadow(0 0 20px rgba(248,113,113,0.8)); }
}

/* 死亡动画 - 敌人死亡 */
#enemy-combatant.dead .avatar {
    animation: enemy-dead 1s ease-out forwards;
    filter: grayscale(100%) !important;
}

@keyframes enemy-dead {
    0% { transform: translateY(0) scale(1); opacity: 1; }
    30% { transform: translateY(-20px) scale(1.1); }
    100% { transform: translateY(80px) scale(0.5) rotate(120deg); opacity: 0; }
}

/* 死亡动画 - 玩家死亡 */
#player-combatant.dead .avatar {
    animation: player-dead 1s ease-out forwards;
    filter: grayscale(100%) !important;
}

@keyframes player-dead {
    0% { transform: translateY(0) scale(1); opacity: 1; }
    30% { transform: translateY(-20px) scale(1.1); }
    100% { transform: translateY(80px) scale(0.5) rotate(-120deg); opacity: 0; }
}

/* 胜利动画 */
#player-combatant.victory .avatar {
    animation: victory 0.8s ease-out;
    filter: drop-shadow(0 0 20px gold) !important;
}

@keyframes victory {
    0% { transform: scale(1); }
    50% { transform: scale(1.3) translateY(-10px); }
    100% { transform: scale(1) translateY(0); }
}

@keyframes hero-idle {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

@keyframes enemy-idle {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-4px) scale(1.05); }
}

.combatant .name {
    font-weight: bold;
    margin-bottom: 10px;
    font-size: 0.95rem;
    letter-spacing: 1px;
}

.hp-bar {
    width: 100%;
    max-width: 160px;
    height: 10px;
    background: rgba(255,255,255,0.1);
    border-radius: 5px;
    margin: 0 auto 6px;
    overflow: hidden;
}

.hp-fill {
    height: 100%;
    background: linear-gradient(90deg, #f87171, #fbbf24, #4ade80);
    border-radius: 5px;
    transition: width 0.5s ease;
    box-shadow: 0 0 6px rgba(74,222,128,0.4);
}

.hp-text {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.vs {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--warning);
    padding: 0 20px;
    text-shadow: 0 0 20px rgba(251,191,36,0.6);
    animation: vs-pulse 1s ease-in-out infinite;
}

@keyframes vs-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

#battle-log {
    background: rgba(255,255,255,0.04);
    border-radius: 12px;
    padding: 14px 20px;
    border: 1px solid var(--border);
    text-align: center;
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--text-light);
    min-height: 60px;
    backdrop-filter: blur(10px);
}

/* ===== 题目区域 ===== */
#question-area {
    background: rgba(255,255,255,0.04);
    border-radius: 16px;
    padding: 24px;
    border: 1px solid var(--border);
    backdrop-filter: blur(10px);
}

.question-title {
    font-size: 1.1rem;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
    line-height: 1.7;
    color: var(--text-light);
    flex: 1;
    white-space: pre-wrap;
    font-family: inherit;
}

.question-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border);
}

.knowledge-btn {
    flex-shrink: 0;
    padding: 6px 12px;
    font-size: 0.85rem;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border: none;
    border-radius: 20px;
    color: white;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}

.knowledge-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.5);
}

.code-block {
    background: rgba(0,0,0,0.5);
    border-radius: 8px;
    padding: 14px 18px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    margin: 12px 0;
    overflow-x: auto;
    border-left: 3px solid var(--primary);
    font-size: 0.9rem;
    color: #a8ff78;
    line-height: 1.6;
}

.options-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
}

.option-btn {
    text-align: left;
    padding: 14px 20px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.option-btn:hover:not(:disabled) {
    border-color: var(--primary);
    background: rgba(74,222,128,0.08);
    transform: translateX(4px);
    box-shadow: var(--glow-green);
}

.option-btn.correct {
    border-color: var(--primary) !important;
    background: rgba(74,222,128,0.15) !important;
    box-shadow: var(--glow-green);
}

.option-btn.wrong {
    border-color: var(--danger) !important;
    background: rgba(248,113,113,0.15) !important;
}

/* ===== 弹窗 ===== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: linear-gradient(135deg, rgba(26,16,64,0.95), rgba(15,12,41,0.95));
    border-radius: 20px;
    padding: 32px;
    max-width: 420px;
    width: 90%;
    text-align: center;
    border: 1px solid rgba(255,255,255,0.15);
    box-shadow: 0 20px 60px rgba(0,0,0,0.6), var(--glow-green);
}

/* 技能树模式下的弹窗更宽 */
.modal-content .skill-tree + .skill-tree {
    /* skill tree sets its own width */
}
/* 兼容性：:has() 选择器在旧浏览器中不支持，使用 .modal-content.skill-tree-modal 替代 */
.modal-content.skill-tree-modal {
    max-width: 680px;
    padding: 20px;
    text-align: left;
}
/* 现代浏览器仍然支持 :has() */
@supports selector(:has(*)) {
.modal-content:has(.skill-tree) {
    max-width: 680px;
    padding: 20px;
    text-align: left;
}
}

#modal-title {
    font-size: 1.5rem;
    margin-bottom: 16px;
    color: var(--primary);
    text-shadow: var(--glow-green);
}

#modal-body {
    margin-bottom: 24px;
    line-height: 1.8;
    color: var(--text-muted);
}

/* ===== 响应式 ===== */
@media (max-width: 600px) {
    #top-bar {
        flex-wrap: wrap;
        gap: 8px;
    }

    .bar-container {
        width: 60px;
    }

    #battle-header {
        flex-direction: column;
        gap: 16px;
    }

    .vs {
        padding: 8px 0;
    }
}

/* ===== 技能效果飘字 ===== */
.skill-effect {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: bold;
    margin-top: 6px;
    animation: skill-float-up 2s ease-out forwards;
}

@keyframes skill-float-up {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    30% { opacity: 1; transform: translateY(-10px) scale(1.1); }
    100% { opacity: 0; transform: translateY(-30px) scale(0.9); }
}

.skill-effect-crit {
    background: linear-gradient(135deg, #fbbf24, #f97316);
    color: #fff;
    box-shadow: 0 0 15px rgba(251, 191, 36, 0.6);
}

.skill-effect-combo {
    background: linear-gradient(135deg, #f97316, #ef4444);
    color: #fff;
    box-shadow: 0 0 15px rgba(249, 115, 22, 0.6);
}

.skill-effect-speed {
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    color: #fff;
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.6);
}

.skill-effect-armor {
    background: linear-gradient(135deg, #60a5fa, #3b82f6);
    color: #fff;
    box-shadow: 0 0 15px rgba(96, 165, 250, 0.6);
}

.skill-effect-lucky {
    background: linear-gradient(135deg, #4ade80, #22c55e);
    color: #fff;
    box-shadow: 0 0 15px rgba(74, 222, 128, 0.6);
}

.skill-effect-shield {
    background: linear-gradient(135deg, #38bdf8, #0ea5e9);
    color: #fff;
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.6);
}

/* 暴击动画 */
.critting .avatar {
    animation: crit-shake 0.4s ease-out !important;
}

@keyframes crit-shake {
    0% { transform: translateX(0) scale(1); filter: drop-shadow(0 0 10px rgba(255,255,255,0.3)); }
    25% { transform: translateX(60px) scale(1.3) rotate(10deg); filter: drop-shadow(0 0 30px rgba(251,191,36,1)); }
    50% { transform: translateX(80px) scale(1.2) rotate(5deg); filter: drop-shadow(0 0 20px rgba(251,191,36,0.8)); }
    75% { transform: translateX(60px) scale(1.1); }
    100% { transform: translateX(0) scale(1); }
}

/* ===== 战斗中的Buff显示 ===== */
.buff-display {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 4px;
    min-height: 16px;
}

#player-shield {
    animation: shield-glow 2s ease-in-out infinite;
}

@keyframes shield-glow {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

#player-combo {
    transition: opacity 0.3s;
    font-weight: bold;
}

/* ===== 技能树弹窗 ===== */
.modal-content.skill-tree-modal {
    max-width: 680px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 20px;
}

.skill-tree {
    text-align: left;
}

.skill-tree-header {
    background: rgba(74, 222, 128, 0.08);
    border: 1px solid rgba(74, 222, 128, 0.2);
    border-radius: 12px;
    padding: 14px 18px;
    margin-bottom: 16px;
}

.skill-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.skill-pts-info {
    font-size: 0.95rem;
}

.skill-group {
    margin-bottom: 16px;
}

.skill-group-title {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 10px;
    padding-left: 4px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    padding-bottom: 6px;
}

.skill-group-items {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.skill-card {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 12px;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.skill-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: rgba(255,255,255,0.05);
    transition: background 0.3s;
}

.skill-card.unlocked::before {
    background: linear-gradient(90deg, var(--primary), var(--secondary));
}

.skill-card.locked {
    opacity: 0.5;
}

.skill-card.can-upgrade {
    border-color: rgba(74, 222, 128, 0.3);
    background: rgba(74, 222, 128, 0.05);
}

.skill-card.can-upgrade:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(74, 222, 128, 0.2);
}

.skill-card.flash {
    animation: skill-flash 0.6s ease-out;
}

@keyframes skill-flash {
    0% { background: rgba(74, 222, 128, 0.4); }
    100% { background: rgba(74, 222, 128, 0.05); }
}

.skill-card-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.skill-icon {
    font-size: 1.2rem;
}

.skill-name {
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--text-light);
    flex: 1;
}

.skill-lock-badge {
    font-size: 0.7rem;
    background: rgba(255,255,255,0.08);
    padding: 2px 6px;
    border-radius: 8px;
    color: var(--text-muted);
}

.skill-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    line-height: 1.4;
    min-height: 32px;
}

.skill-level-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
}

.skill-level-pip {
    flex: 1;
    height: 4px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
    transition: background 0.3s;
}

.skill-level-pip.filled {
    background: linear-gradient(90deg, var(--primary), var(--secondary));
}

.skill-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    font-size: 0.7rem;
}

.skill-next {
    color: var(--text-muted);
}

.skill-maxed {
    color: #fbbf24;
    font-weight: bold;
}

.skill-upgrade-btn {
    padding: 3px 10px;
    font-size: 0.75rem;
    background: linear-gradient(135deg, #16a34a, #15803d);
    border: none;
    border-radius: 12px;
    color: white;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
    flex-shrink: 0;
}

.skill-upgrade-btn:hover {
    background: linear-gradient(135deg, #4ade80, #22c55e);
    transform: scale(1.05);
}

.skill-tree-tip {
    margin-top: 16px;
    padding: 12px;
    background: rgba(255,255,255,0.03);
    border-radius: 10px;
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.8;
    text-align: center;
}

/* 响应式：技能树 */
@media (max-width: 600px) {
    .skill-group-items {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 400px) {
    .skill-group-items {
        grid-template-columns: 1fr;
    }
}

/* ===== Boss 战动画 ===== */
#boss-player-el.attacking {
    animation: boss-player-slide 0.5s ease-out forwards;
}

@keyframes boss-player-slide {
    0% { transform: translateX(0); }
    40% { transform: translateX(60px); }
    100% { transform: translateX(0); }
}

#boss-enemy-el.hurt {
    animation: boss-enemy-shake 0.4s ease-out;
}

@keyframes boss-enemy-shake {
    0% { transform: translateX(0); filter: brightness(1); }
    20% { transform: translateX(-15px); filter: brightness(2) drop-shadow(0 0 10px rgba(255,255,255,0.8)); }
    40% { transform: translateX(10px); filter: brightness(1.5); }
    60% { transform: translateX(-5px); }
    100% { transform: translateX(0); filter: brightness(1); }
}

#boss-player-el.hurt {
    animation: player-shake 0.4s ease-out;
}

@keyframes player-shake {
    0% { transform: translateX(0); }
    20% { transform: translateX(-20px); filter: brightness(1.5) drop-shadow(0 0 10px rgba(255,50,50,0.8)); }
    100% { transform: translateX(0); filter: brightness(1); }
}

#boss-enemy-el.dead {
    animation: boss-death 1s ease-out forwards;
}

@keyframes boss-death {
    0% { transform: scale(1) rotate(0); opacity: 1; }
    50% { transform: scale(1.3) rotate(5deg); opacity: 0.8; filter: brightness(2) drop-shadow(0 0 20px rgba(255,100,0,0.9)); }
    100% { transform: scale(0) rotate(15deg); opacity: 0; }
}

#boss-player-el.dead {
    animation: player-death 0.8s ease-out forwards;
}

@keyframes player-death {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(0.9); filter: brightness(0.3); }
    100% { transform: scale(0.7); opacity: 0; }
}

#boss-player-el.critting {
    animation: crit-glow 0.5s ease-out;
}

@keyframes crit-glow {
    0% { filter: drop-shadow(0 0 5px rgba(251,191,36,0.5)); }
    50% { filter: drop-shadow(0 0 30px rgba(251,191,36,1)) brightness(1.5); }
    100% { filter: drop-shadow(0 0 5px rgba(251,191,36,0.5)); }
}

/* ===== 移动端适配 ===== */
@media screen and (max-width: 768px), screen and (max-height: 500px) {
    /* 允许滚动 */
    body {
        overflow: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* 容器 */
    #game-container {
        max-width: 100%;
        min-height: 100vh;
    }
    
    /* 顶部状态栏 */
    #top-bar {
        padding: 8px 10px;
        flex-wrap: wrap;
        gap: 8px;
    }
    .player-info {
        font-size: 0.75rem;
    }
    .hp-xp-bar {
        font-size: 0.7rem;
    }
    .bar-container {
        width: 60px;
    }
    
    /* 底部按钮栏 */
    #bottom-bar {
        flex-wrap: wrap;
        padding: 8px;
        gap: 6px;
        justify-content: center;
    }
    #bottom-bar .btn {
        font-size: 0.75rem;
        padding: 8px 12px;
        flex: 1 1 auto;
        min-width: 60px;
    }
    
    /* 游戏视图 */
    #game-view {
        flex: 1;
        min-height: 300px;
        overflow: auto;
    }
    
    /* 游戏界面整体可滚动 */
    #game-screen {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* 战斗界面 */
    #battle-screen {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 20px;
    }
    #battle-screen {
        padding: 10px;
    }
    #battle-header {
        flex-direction: column;
        gap: 10px;
        align-items: center;
    }
    .combatant {
        padding: 10px 15px;
        min-width: 120px;
    }
    .avatar {
        font-size: 36px;
    }
    .hp-bar-container {
        width: 80px;
    }
    
    /* 战斗区域 */
    #battle-area {
        flex-direction: column;
        padding: 10px 0;
    }
    #battle-question-area {
        margin: 10px 0;
        padding: 10px;
    }
    #battle-log {
        font-size: 0.85rem;
        padding: 8px;
    }
    .question-title {
        font-size: 0.9rem;
    }
    .option-btn {
        font-size: 0.85rem;
        padding: 10px 12px;
        width: 100%;
        margin: 4px 0;
    }
    .options-list {
        gap: 8px;
    }
    
    /* Boss战界面 */
    #boss-screen {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 20px;
    }
        padding: 10px;
    }
    #boss-battle-area {
        flex-direction: column;
        gap: 15px;
    }
    .boss-combatant {
        padding: 12px 15px;
        min-width: 100px;
    }
    .boss-avatar {
        font-size: 36px;
    }
    .boss-avatar-enemy {
        font-size: 42px;
    }
    .boss-vs {
        font-size: 1.2rem;
    }
    #boss-actions {
        flex-wrap: wrap;
        gap: 8px;
    }
    #boss-actions .btn {
        flex: 1 1 45%;
        font-size: 0.8rem;
        padding: 10px;
    }
    
    /* 模态框 */
    #modal-body {
        max-height: 70vh;
        padding: 15px;
        font-size: 0.9rem;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .modal-content {
        width: 95%;
        max-width: 95%;
    }
    
    /* 商店 */
    .shop-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    .shop-item-btn {
        width: 100%;
        text-align: center;
    }
    
    /* 技能树 */
    .skill-card {
        padding: 12px;
    }
    .skill-desc {
        font-size: 0.8rem;
    }
    .skill-group-items {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }
    .skill-card {
        width: 100%;
    }
}
    .skill-desc {
        font-size: 0.8rem;
    }
    
    /* 开始界面 */
    #start-screen {
        padding: 20px;
    }
    .logo {
        font-size: 64px;
    }
    #start-screen h1 {
        font-size: 1.8rem;
    }
    #player-name {
        font-size: 1rem;
        padding: 12px;
    }
    .btn {
        font-size: 0.9rem;
        padding: 12px 24px;
    }
    
    /* 地图NPC */
    .player, .npc {
        width: 48px;
        height: 48px;
        font-size: 32px;
    }
    
    /* 滚动条 */
    ::-webkit-scrollbar {
        width: 4px;
    }
}

/* 小屏手机 */
@media screen and (max-width: 480px) {
    /* 进一步缩小 */
    .btn {
        font-size: 0.8rem;
        padding: 10px 16px;
    }
    .avatar {
        font-size: 32px;
    }
    .boss-avatar {
        font-size: 32px;
    }
    .boss-avatar-enemy {
        font-size: 36px;
    }
    .player, .npc {
        width: 40px;
        height: 40px;
        font-size: 28px;
    }
    #bottom-bar .btn {
        font-size: 0.7rem;
        padding: 8px 10px;
        min-width: 50px;
    }
    
    /* 模态框更小 */
    .modal-content {
        width: 98%;
        max-width: 98%;
    }
    #modal-body {
        padding: 10px;
    }
}

