/* ==================== 游戏页自适应（PC 宽屏 + 手机端） ==================== */

/* 容器宽度过渡，切页时不突兀 */
.container { transition: max-width 0.3s ease; }

/* ---------- PC 宽屏（≥1024px）：加宽容器，组件放大 ---------- */
@media (min-width: 1024px) {
    body.game-wide .container { max-width: 1200px; }

    /* 玩家状态条 */
    body.game-wide .game-header { padding: var(--space-lg) var(--space-xl); }
    body.game-wide .game-avatar { width: 88px; height: 88px; }
    body.game-wide .game-grade { font-size: 1.5rem; }
    body.game-wide .game-lead { font-size: 1.05rem; }
    body.game-wide .currency { font-size: 1rem; padding: 8px 16px; }

    /* 学期单元格 */
    body.game-wide .unit-grid { gap: 10px; }
    body.game-wide .unit-cell { font-size: 0.95rem; border-radius: 10px; }
    body.game-wide .unit-check { font-size: 1.3rem; }

    /* BOSS 卡片 */
    body.game-wide .boss-card { padding: var(--space-lg); }
    body.game-wide .boss-sprite { font-size: 3.2rem; }
    body.game-wide .boss-name { font-size: 1.05rem; }
    body.game-wide .boss-hp-bar { height: 18px; border-radius: 9px; }
    body.game-wide .boss-hp-text { font-size: 0.9rem; }

    /* 今日任务单列展示 */
    body.game-wide .game-task-item { padding: 14px var(--space-sm); }
    body.game-wide .game-task-name { font-size: 1.02rem; }
    body.game-wide .game-task-cat,
    body.game-wide .game-task-xp { font-size: 0.9rem; }

    /* 各类卡片网格更宽松 */
    body.game-wide .inventory-grid,
    body.game-wide .shop-grid { grid-template-columns: repeat(auto-fill, 170px); }
    body.game-wide .wish-grid, body.game-wide .wish-cat-items { grid-template-columns: repeat(auto-fill, 200px); }
    body.game-wide .onboard-levels { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
    body.game-wide .onboard-level-btn { padding: 14px; font-size: 0.95rem; }
}

/* ---------- 平板及以上（≥768px）：角色页三区布局 ---------- */
@media (min-width: 768px) {
    #gameTabCharacter {
        display: grid;
        grid-template-columns: 240px 1fr;
        gap: var(--space-lg);
        align-items: start;
    }
    /* 纸娃娃卡片：占左侧，跨两行（与定制区等高） */
    #gameTabCharacter > .card.paperdoll-card {
        grid-row: 1 / 3;
        margin-bottom: 0;
    }
    #gameTabCharacter > .paperdoll-custom {
        margin-bottom: 0;
        /* 与纸娃娃平齐：让出左侧卡片"标题行"的高度（卡片上内边距 + 标题行 + 标题下边距），
           再多下移一点对齐人物头部 */
        margin-top: calc(var(--space-lg) + 1.5rem + var(--space-md) + var(--space-lg));
    }
    /* 已穿戴装备：独立成行、占满整行宽度（不再挤在右侧栏） */
    #gameTabCharacter > .card:last-child {
        grid-column: 1 / -1;
        margin-bottom: 0;
    }
    /* 纸娃娃在宽屏上等比放大（放大内部舞台，容器随卡片宽度自适应） */
    .paperdoll { max-width: 200px; }
    .paperdoll .lego-stage { transform: scale(1.15); }
}

/* ---------- 中等宽屏（≥1024px）：角色列加宽 + 纸娃娃放大 ---------- */
@media (min-width: 1024px) {
    #gameTabCharacter {
        grid-template-columns: 300px 1fr;
    }
    .paperdoll { max-width: 240px; }
    .paperdoll .lego-stage { transform: scale(1.35); }
}

/* ---------- 宽屏（≥1280px）：心愿页双栏 + 角色再加宽 ---------- */
@media (min-width: 1280px) {
    #gameTabCharacter {
        grid-template-columns: 360px 1fr;
        gap: var(--space-xl);
    }
    .paperdoll { max-width: 300px; }
    .paperdoll .lego-stage { transform: scale(1.6); }
    /* 心愿页：商店与心愿中心都占满整行 */
    #gameTabWishes {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-xl);
        align-items: start;
    }
    #gameTabWishes > .card { grid-column: 1 / -1; }
}

/* ---------- 大屏（≥1440px）：纸娃娃进一步放大 ---------- */
@media (min-width: 1440px) {
    .paperdoll { max-width: 320px; }
    .paperdoll .lego-stage { transform: scale(1.75); }
}

/* ---------- 大屏（≥1440px）：游戏页容器拉开 + 网格密度提升 ---------- */
@media (min-width: 1440px) {
    body.game-wide .container { max-width: 1280px; }
    body.game-wide .inventory-grid,
    body.game-wide .shop-grid { grid-template-columns: repeat(auto-fill, 180px); }
    body.game-wide .wish-grid,
    body.game-wide .wish-cat-items { grid-template-columns: repeat(auto-fill, 220px); }
}

/* ---------- 超大屏（≥1600px）：最大化游戏页宽度 ---------- */
@media (min-width: 1600px) {
    body.game-wide .container { max-width: 1440px; }
    body.game-wide .inventory-grid,
    body.game-wide .shop-grid { grid-template-columns: repeat(auto-fill, 200px); }
    body.game-wide .wish-grid,
    body.game-wide .wish-cat-items { grid-template-columns: repeat(auto-fill, 240px); }
}

/* ---------- 手机/小平板（≤767px）：不挤压、可横滑、字号适配 ---------- */
@media (max-width: 767px) {
    /* 玩家状态条：货币区换行，头像缩小 */
    .game-header { flex-wrap: wrap; padding: var(--space-md); gap: var(--space-sm); }
    .game-avatar { width: 56px; height: 56px; }
    .game-grade { font-size: 1.1rem; }
    .game-lead { font-size: 0.85rem; }
    .game-currencies { width: 100%; gap: 6px; }
    .currency { font-size: 0.8rem; padding: 4px 8px; }

    /* 页内标签：横向滑动，避免 8 个标签挤在一起 */
    .game-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
        scrollbar-width: none;
    }
    .game-tabs::-webkit-scrollbar { display: none; }
    .game-tab {
        flex: 0 0 auto;
        padding: 8px 14px;
        font-size: 0.85rem;
        white-space: nowrap;
    }

    /* 单元格间距收紧 */
    .unit-grid { gap: 5px; }
    .unit-cell { font-size: 0.7rem; border-radius: 6px; }

    /* BOSS 卡片元素略缩 */
    .boss-sprite { font-size: 2.2rem; }

    /* 任务项允许换行，避免按钮被挤出屏幕 */
    .game-task-item { flex-wrap: wrap; row-gap: 6px; }

    /* 纸娃娃居中 */
    .paperdoll-wrap { justify-content: center; }

    /* 各类网格卡片最小宽度收窄，小屏也能放下两列 */
    .inventory-grid, .shop-grid { grid-template-columns: repeat(auto-fill, 120px); }

    .wish-grid, .wish-cat-items { grid-template-columns: repeat(auto-fill, 150px); }
    .onboard-levels { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}

/* 修复：游戏页/家长页的外层包装 div 不是 .card-full，
   在 ≥1024px 的 12 列网格布局下会被挤压到 1 列，需占满整行。
   min-width:0：网格项目默认 min-width:auto，会被图谱列的 min-content
   （列数×120px）撑破屏幕——表现为"3 列就超出屏幕宽度" */
#page-game > #gameMain,
#page-game > #gameOnboarding,
#page-parent > #parentNotifBar,
#page-finance > #ltDomains,
#page-finance > #ltAiDraftCard,
#page-knowledge > #kpGridView { grid-column: 1 / -1; min-width: 0; }

/* ==================== 知识图谱（跨年级补漏/跳级） ==================== */
.kp-legend { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.kp-legend-tip { margin-left: auto; font-size: 13px; color: var(--text-secondary, #666); }
/* 图例四个状态徽标可点击筛选；active = 当前筛选条件 */
.kp-legend-chip { cursor: pointer; user-select: none; }
.kp-legend-chip.active {
    border-color: var(--primary-600); box-shadow: 0 0 0 1px var(--primary-600);
    font-weight: 600;
}
.kp-cards-filter { font-size: 12px; color: var(--primary-600); margin-left: 8px; }
.kp-col-empty { padding: 8px; font-size: 12px; color: #9ca3af; }
.kp-subject-tabs { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.kp-weak-badge {
    font-size: 11px; background: #fee2e2; color: #b91c1c;
    border-radius: 8px; padding: 1px 6px; margin-left: 4px;
}

.kp-main { display: flex; gap: 12px; align-items: flex-start; }
.kp-grade-board {
    display: flex; gap: 10px; overflow-x: auto; flex: 1;
    padding-bottom: 8px; min-height: 300px; min-width: 0;
}
.kp-grade-col {
    /* 弹性列宽：列少时撑满容器（不溢出），列多才横向滚动 */
    flex: 1 1 0; min-width: 120px;
    border: 1px solid #e5e7eb; border-radius: 10px; background: #fafafa;
    display: flex; flex-direction: column;
}
.kp-grade-col.kp-col-current { border-color: var(--primary-500); box-shadow: 0 0 0 1px var(--primary-500); }
.kp-grade-head {
    padding: 8px 10px; font-weight: 600; font-size: 14px;
    border-bottom: 1px solid #e5e7eb; background: #fff;
    display: flex; justify-content: space-between; align-items: center;
    border-radius: 10px 10px 0 0; position: sticky; top: 0;
}
.kp-grade-counts { font-size: 11px; font-weight: 400; color: #666; }
.kp-chip-list { padding: 8px; overflow-y: auto; max-height: 60vh; }

.kp-chip {
    font-size: 12px; padding: 4px 8px; border-radius: 6px; margin-bottom: 4px;
    cursor: pointer; border: 1px solid transparent;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.kp-chip:hover { border-color: var(--primary-400); }
.kp-chip.selected { border-color: var(--primary-600); box-shadow: 0 0 0 1px var(--primary-600); }
.kp-mastered { background: #dcfce7; color: #166534; }
.kp-learning { background: #fef9c3; color: #854d0e; }
.kp-weak { background: #fee2e2; color: #b91c1c; }
.kp-unknown { background: #f3f4f6; color: #6b7280; }

.kp-side {
    width: 340px; flex-shrink: 0; border: 1px solid #e5e7eb; border-radius: 10px;
    background: #fff; padding: 12px; position: sticky; top: 12px;
    max-height: 75vh; overflow-y: auto;
}
.kp-side-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.kp-side-meta { font-size: 12px; color: #666; margin: 6px 0; }
.kp-mark-row { font-size: 13px; margin: 8px 0; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.kp-path-block { margin-top: 12px; }
.kp-path-title { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.kp-path-item {
    display: flex; gap: 6px; align-items: center; font-size: 12px;
    padding: 5px 8px; border-radius: 6px; margin-bottom: 4px;
}
.kp-path-grade { flex-shrink: 0; font-weight: 600; }
.kp-path-name { flex: 1; }
.kp-path-status { flex-shrink: 0; font-size: 11px; }
.kp-via { flex-shrink: 0; font-size: 10px; background: #ede9fe; color: #5b21b6; border-radius: 6px; padding: 1px 5px; }
.kp-cross {
    font-size: 11px; color: var(--primary-700); font-weight: 600;
    margin: 6px 0 2px; padding-left: 4px;
}
.kp-empty { font-size: 13px; color: #9ca3af; padding: 12px; text-align: center; }

@media (max-width: 768px) {
    /* 竖排后交叉轴变为水平：必须改回 stretch，否则 align-items:flex-start
       会让年级画板按内容宽度（列数×列宽）撑出容器，表现为下图谱比上卡片宽 */
    .kp-main { flex-direction: column; align-items: stretch; }
    .kp-side { width: 100%; position: static; max-height: none; }
    .kp-chip-list { max-height: 40vh; }
    /* 单年级卡片模式全宽（minmax(0,…)：1fr 轨道的最小值是内容 min-content，
       长标题不换行会把轨道撑出容器，整页横向溢出） */
    .kp-grade-cards { grid-template-columns: minmax(0, 1fr); }
}

/* ==================== 单年级卡片列表（手机端默认模式） ==================== */
.kp-grade-cards {
    display: flex; flex-direction: column; gap: 6px;
    flex: 1; min-width: 0;
}
.kp-cards-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 12px; background: linear-gradient(135deg, #eef2ff, #f3e8ff);
    border-radius: 10px; margin-bottom: 2px;
}
.kp-cards-grade { font-weight: 700; font-size: 15px; color: #4338ca; }
.kp-cards-counts { font-size: 12px; color: #6b7280; }
.kp-grade-card {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 10px;
    cursor: pointer; border: 1px solid transparent;
    transition: transform .12s, box-shadow .12s;
}
.kp-grade-card:hover {
    transform: translateX(3px);
    box-shadow: 0 2px 8px rgba(0,0,0,.1);
}
.kp-grade-card.selected {
    border-color: var(--primary-600);
    box-shadow: 0 0 0 1px var(--primary-600);
}
.kp-card-status { font-size: 18px; flex-shrink: 0; }
.kp-card-name {
    flex: 1; font-size: 14px; font-weight: 500;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.kp-card-diff {
    flex-shrink: 0; font-size: 11px; letter-spacing: 1px;
}

/* 卡片模式分页器（grid/flex 容器里都独占一行） */
.kp-pager {
    grid-column: 1 / -1;
    display: flex; align-items: center; justify-content: center; gap: 12px;
    padding: 10px 0 4px;
}
.kp-pager-info { font-size: 12px; color: #6b7280; white-space: nowrap; }
.kp-pager .btn-compact:disabled { opacity: .4; cursor: default; }

/* 平板及以上：单年级卡片双列 */
@media (min-width: 768px) {
    .kp-grade-cards {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .kp-cards-head { grid-column: 1 / -1; }
}

/* 宽屏：单年级卡片三列 */
@media (min-width: 1280px) {
    .kp-grade-cards {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* ==================== 知识闯关地图 + 答题弹窗 ==================== */
.kp-title-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

/* 标题栏下拉框：胶囊样式 + 自定义箭头（隐藏浏览器默认外观） */
.kp-title-actions select {
    appearance: none;
    -webkit-appearance: none;
    max-width: 150px;
    min-width: 0;
    padding: 6px 30px 6px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--surface) url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
    font-size: var(--text-sm);
    color: var(--text);
    cursor: pointer;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.kp-title-actions select:hover { border-color: var(--primary-300); }
.kp-title-actions select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-100);
}
.kp-review-badge {
    border: none; border-radius: 14px; padding: 5px 12px; cursor: pointer;
    background: #fef3c7; color: #92400e; font-size: 13px;
}
.kp-review-badge b { color: #b45309; }

.kp-due-text { color: #b45309; }

/* ---- 世界选择页签（科目） ---- */
.kp-world-tabs { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.kp-world-tab {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    min-width: 88px; padding: 8px 12px; border-radius: 14px; cursor: pointer;
    border: 2px solid #e5e7eb; background: #f9fafb; font-size: 13px;
    transition: transform .15s, box-shadow .15s;
}
.kp-world-tab:hover { transform: translateY(-2px); }
.kp-world-tab.active {
    border-color: var(--primary-500);
    background: linear-gradient(135deg, #eef2ff, #f3e8ff);
    box-shadow: 0 0 12px rgba(102,126,234,.45);
}
.kp-world-icon { font-size: 22px; }
.kp-world-name { font-weight: 600; }
.kp-world-bar { width: 100%; height: 5px; border-radius: 3px; background: #e5e7eb; overflow: hidden; }
.kp-world-bar i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--primary-500), var(--secondary)); }
.kp-world-pct { font-size: 11px; color: #6b7280; }

/* ---- 学科开关（家长端：勾选做在科目页签上） ---- */
.kp-config-bar {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    padding: 6px 0 8px; margin-bottom: 4px;
    border-bottom: 1px dashed #e5e7eb; font-size: 12px;
}
.kp-config-hint { color: #6b7280; }
.kp-world-tab { position: relative; }
.kp-toggle {
    position: absolute; top: 2px; right: 6px; font-size: 13px; line-height: 1;
    color: var(--primary-500); cursor: pointer; padding: 2px;
}
.kp-world-tab.kp-tab-disabled { opacity: .45; border-style: dashed; cursor: default; }
.kp-world-tab.kp-tab-disabled:hover { transform: none; }
.kp-world-tab.kp-tab-disabled .kp-world-bar i { background: #d1d5db; }

/* 心愿卡抵扣提示（心愿商店价格旁） */
.wish-card-hint { color: #7c3aed; font-size: 11px; }

/* ---- 横板放置战斗场景（知识闯关主视图：左角色 / 中宝剑 / 右小妖） ---- */
.kp-battle { margin: 4px 0 6px; }
.kp-battle-stage {
    position: relative; overflow: hidden;
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 8px; padding: 14px 26px 12px; min-height: 196px;
    border-radius: 16px;
    background:
        radial-gradient(circle at 84% 8%, rgba(255,244,190,.95) 0, rgba(255,244,190,0) 17%),
        linear-gradient(180deg, #5fb2e5 0%, #9fd6f0 50%, #a5cf76 51%, #7fb45e 100%);
    box-shadow: inset 0 0 40px rgba(35,90,45,.18);
}
/* 复习宝库模式：暖色黄昏调 */
.kp-battle-review {
    background:
        radial-gradient(circle at 84% 8%, rgba(255,244,190,.95) 0, rgba(255,244,190,0) 17%),
        linear-gradient(180deg, #f0b25e 0%, #f5d9a8 50%, #b8a05e 51%, #8f7f45 100%);
}
.kp-battle-win { align-items: center; justify-content: center; }
.kp-battle-win-text {
    font-size: 16px; font-weight: 700; color: #41321d;
    background: rgba(255,255,255,.75); border-radius: 12px; padding: 12px 20px;
}
.kp-battle-stage .kp-empty { color: #4c6040; margin: auto; }

.kp-battle-side { display: flex; flex-direction: column; align-items: center; gap: 4px; z-index: 2; }
.kp-battle-name {
    font-size: 13px; font-weight: 700; color: #2f2413;
    background: rgba(255,255,255,.72); border-radius: 10px; padding: 2px 10px;
    white-space: nowrap;
}
.kp-battle-bar {
    width: 110px; height: 7px; border-radius: 4px; overflow: hidden;
    background: rgba(255,255,255,.55); box-shadow: inset 0 1px 2px rgba(0,0,0,.15);
}
.kp-battle-bar i {
    display: block; height: 100%; border-radius: 4px;
    background: linear-gradient(90deg, #60a5fa, #818cf8);
    transition: width .3s;
}
/* 角色：乐高纸娃娃缩小站上台地 */
.kp-battle-figure { height: 128px; display: flex; align-items: flex-end; }
.kp-battle-figure .lego-stage { transform: scale(.72); transform-origin: 50% 100%; }
.kp-battle-emoji { font-size: 64px; line-height: 128px; }

/* 小妖：待机浮动 */
.kp-battle-monster {
    font-size: 72px; line-height: 1; height: 128px;
    display: flex; align-items: flex-end;
    filter: drop-shadow(0 6px 6px rgba(30,60,30,.35));
    animation: kpMonsterBob 2.4s ease-in-out infinite;
}
.kp-battle-hearts { font-size: 13px; letter-spacing: 2px; min-height: 18px; }

/* 中间：VS + 宝剑攻击按钮 */
.kp-battle-mid {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    align-self: center; z-index: 2;
}
.kp-battle-vs {
    font-size: 15px; font-weight: 900; color: #b45309; font-style: italic;
    text-shadow: 0 1px 2px rgba(255,255,255,.8);
}
.kp-sword-btn {
    position: relative; width: 92px; height: 92px; border-radius: 50%;
    border: 3px solid #fef3c7; cursor: pointer;
    background: radial-gradient(circle at 35% 30%, #fde68a, #d97706);
    box-shadow: 0 4px 12px rgba(120,70,10,.45), inset 0 2px 4px rgba(255,255,255,.5);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; transition: transform .15s, box-shadow .15s;
    animation: kpSwordPulse 2s ease-in-out infinite;
}
.kp-sword-btn:hover { transform: scale(1.08); box-shadow: 0 6px 16px rgba(120,70,10,.55), 0 0 14px rgba(246,196,83,.8); }
.kp-sword-btn:active { transform: scale(.94); }
.kp-sword-label { font-size: 13px; font-weight: 800; color: #451a03; }
/* CSS 宝剑：刃/格/柄/首四件拼成，旋转 45° 指向小妖 */
.kp-sword-shape {
    display: flex; flex-direction: column; align-items: center;
    transform: rotate(45deg); transform-origin: 50% 50%;
}
.kp-sword-blade {
    width: 9px; height: 34px;
    background: linear-gradient(90deg, #e5e7eb 0%, #ffffff 50%, #9ca3af 100%);
    clip-path: polygon(50% 0, 100% 12%, 100% 100%, 0 100%, 0 12%);
    box-shadow: 0 0 4px rgba(255,255,255,.8);
}
.kp-sword-guard {
    width: 26px; height: 6px; border-radius: 3px;
    background: linear-gradient(180deg, #fbbf24, #b45309);
}
.kp-sword-grip { width: 7px; height: 12px; background: linear-gradient(90deg, #7c4a21, #5b3416); }
.kp-sword-pommel {
    width: 10px; height: 10px; border-radius: 50%; margin-top: -1px;
    background: radial-gradient(circle at 35% 30%, #fde68a, #b45309);
}

/* 攻击动画：角色前冲 → 小妖受击抖动 + ⚡ 闪光 */
.kp-battle-slash {
    position: absolute; right: 12%; bottom: 46%; z-index: 3;
    font-size: 40px; opacity: 0; pointer-events: none;
}
.kp-battle-attacking .kp-battle-hero .kp-battle-figure { animation: kpHeroLunge .5s ease-in-out; }
.kp-battle-attacking .kp-battle-foe .kp-battle-monster { animation: kpFoeHit .5s ease-in-out; }
.kp-battle-attacking .kp-battle-slash { animation: kpSlashFlash .5s ease-out; }
.kp-battle-attacking .kp-sword-shape { animation: kpSwordSwing .5s ease-in-out; }

@keyframes kpMonsterBob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}
@keyframes kpHeroLunge {
    0%, 100% { transform: translateX(0); }
    35% { transform: translateX(38px); }
}
@keyframes kpFoeHit {
    0%, 100% { transform: translateX(0); }
    30% { transform: translateX(10px) rotate(4deg); }
    55% { transform: translateX(-6px) rotate(-4deg); }
    80% { transform: translateX(4px); }
}
@keyframes kpSlashFlash {
    0% { opacity: 0; transform: scale(.5) rotate(-20deg); }
    30% { opacity: 1; transform: scale(1.3) rotate(10deg); }
    100% { opacity: 0; transform: scale(1.6) rotate(20deg); }
}
@keyframes kpSwordSwing {
    0%, 100% { transform: rotate(45deg); }
    40% { transform: rotate(110deg); }
}
@keyframes kpSwordPulse {
    0%, 100% { box-shadow: 0 4px 12px rgba(120,70,10,.45), inset 0 2px 4px rgba(255,255,255,.5); }
    50% { box-shadow: 0 4px 12px rgba(120,70,10,.45), 0 0 16px rgba(246,196,83,.9); }
}

@media (max-width: 768px) {
    .kp-battle-stage { padding: 10px 12px 10px; min-height: 158px; gap: 4px; }
    .kp-battle-figure { height: 100px; }
    .kp-battle-figure .lego-stage { transform: scale(.56); }
    .kp-battle-emoji { font-size: 48px; line-height: 100px; }
    .kp-battle-monster { font-size: 54px; height: 100px; }
    .kp-sword-btn { width: 76px; height: 76px; }
    .kp-sword-blade { height: 28px; }
    .kp-battle-bar { width: 84px; }
    .kp-battle-name { font-size: 12px; padding: 1px 8px; }
    .kp-battle-slash { right: 8%; }
}


/* ---- 当前月完整场景地图：真实节点 + 独立归一化路径 ---- */
.kp-quest-map-host { min-width: 0; max-width: 100%; margin: 4px 0 6px; }
.kp-map-scroll {
    width: 100%; max-width: 100%; margin: 0 auto; overflow: hidden;
    border-radius: 16px; background: #62c6ed;
    box-shadow: inset 0 0 35px rgba(35,90,90,.16);
}
.kp-map-track {
    position: relative; min-width: 100%; overflow: hidden; isolation: isolate;
    transform-origin: left top;
    background-position: center; background-size: 100% 100%; background-repeat: no-repeat;
}

.kp-map-node {
    position: absolute; z-index: 4; width: 56px; height: 56px;
    transform: translate(-50%,-50%); padding: 0; border: 4px solid #fff;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(145deg, #55b9f3, #2479d0); color: #fff;
    box-shadow: 0 5px 0 #1c5d9c, 0 8px 14px rgba(29,73,110,.3);
    cursor: pointer; font: inherit; font-weight: 800; transition: filter .15s, box-shadow .15s;
}
.kp-map-node:hover { filter: brightness(1.08); }
.kp-map-node:focus-visible, .kp-map-treasure:focus-visible { outline: 4px solid #fff29a; outline-offset: 5px; }
.kp-map-node-number { font-size: 21px; line-height: 1; text-shadow: 0 1px 2px rgba(0,0,0,.22); }
.kp-map-node-number svg { width: 25px; height: 25px; fill: currentColor; }
.kp-map-node-caption {
    position: absolute; top: calc(100% + 12px); left: 50%; transform: translateX(-50%);
    width: 140px; padding: 5px 7px; border-radius: 9px;
    background: rgba(255,255,255,.9); color: #30465b;
    box-shadow: 0 2px 6px rgba(33,65,88,.14); text-align: center;
    line-height: 1.3; pointer-events: none; opacity: 0; transition: opacity .15s;
}
.kp-map-node:hover .kp-map-node-caption, .kp-map-node:focus-visible .kp-map-node-caption,
.kp-map-node.is-current .kp-map-node-caption { opacity: 1; }
.kp-map-node.caption-above .kp-map-node-caption { top: auto; bottom: calc(100% + 12px); }
.kp-map-boss-node.caption-above .kp-map-boss-art { bottom: auto; top: 50%; right: calc(100% + 5px); left: auto; transform: translateY(-50%); width: 96px; }
.kp-map-boss-node.caption-above .kp-map-boss-art .aa-boss-svg { width: 96px; }
.kp-map-node-caption b, .kp-map-node-caption small { display: block; overflow-wrap: anywhere; }
.kp-map-node-caption b { font-size: 12px; }
.kp-map-node-caption small { margin-top: 2px; font-size: 10px; font-weight: 500; color: #617487; }
.kp-map-node.is-current {
    width: 64px; height: 64px; border-color: #fff5ad;
    background: linear-gradient(145deg, #66c8ff, #3768db);
    box-shadow: 0 5px 0 #2750a4, 0 0 0 7px rgba(255,240,128,.35), 0 8px 18px rgba(29,73,110,.35);
    animation: kpMapCurrentPulse 2s ease-in-out infinite;
}
.kp-map-node.is-passed { background: linear-gradient(145deg, #57d4b0, #25967e); box-shadow: 0 5px 0 #1d735f, 0 8px 14px rgba(29,90,75,.25); }
.kp-map-node.is-due { border-color: #ffe17c; box-shadow: 0 5px 0 #9c761c, 0 0 0 6px rgba(255,215,85,.3); }
.kp-map-node.is-due .kp-map-node-caption { color: #76510a; }
.kp-map-node.is-locked {
    background: linear-gradient(145deg, #b5c4ce, #748b9b); color: #e9f0f4;
    box-shadow: 0 5px 0 #586c79, 0 6px 12px rgba(40,60,75,.2);
    cursor: not-allowed; filter: saturate(.65);
}

.kp-map-boss-node {
    width: 102px; height: 102px; border-color: #f6d8ff;
    background: linear-gradient(145deg, #bc6ed7, #7b3e9d);
    box-shadow: 0 5px 0 #5b2c76, 0 8px 16px rgba(75,35,100,.35);
}
.kp-map-boss-node .kp-map-node-number { font-size: 17px; letter-spacing: .4px; }
.kp-map-boss-node .kp-map-node-caption { width: 158px; }
.kp-map-boss-node.is-killed { background: linear-gradient(145deg, #72b9a1, #477f70); box-shadow: 0 5px 0 #386457; }
.kp-map-boss-node.is-fled { filter: grayscale(.6); opacity: .75; }
.kp-map-boss-node.is-claimable { border-color: #ffe08a; animation: kpMapClaimPulse 1.6s ease-in-out infinite; }
.kp-map-boss-art {
    position: absolute; left: 50%; bottom: calc(100% + 2px); transform: translateX(-50%);
    width: 124px; height: 116px; pointer-events: none;
    filter: drop-shadow(0 4px 3px rgba(41,31,74,.25));
}
.kp-map-boss-art .aa-boss-svg { width: 124px; height: 116px; }
.kp-map-boss-node.is-weekly {
    width: 88px; height: 88px; border-width: 4px;
    box-shadow: 0 4px 0 #275f9c, 0 6px 12px rgba(35,85,130,.3);
}
.kp-map-boss-node.is-weekly.is-active { background: linear-gradient(145deg, #55b9f3, #2479d0); }
.kp-map-boss-node.is-weekly .kp-map-node-number { font-size: 17px; letter-spacing: 0; }
.kp-map-boss-node.is-weekly .kp-map-node-caption { width: 138px; }
.kp-map-boss-node.is-weekly .kp-map-boss-art,
.kp-map-boss-node.is-weekly.caption-above .kp-map-boss-art {
    left: 50%; right: auto; top: auto; bottom: calc(100% + 2px);
    transform: translateX(-50%); width: 110px; height: 104px;
}
.kp-map-boss-node.is-weekly .kp-map-boss-art .aa-boss-svg,
.kp-map-boss-node.is-weekly.caption-above .kp-map-boss-art .aa-boss-svg { width: 110px; height: 104px; }
.kp-map-boss-node.is-weekly .kp-map-boss-hp,
.kp-map-boss-node.is-monthly .kp-map-boss-hp { display: none; }
.kp-map-boss-node.is-semester {
    width: 110px; height: 110px; border-color: #ffe29a;
    background: linear-gradient(145deg, #e9654f, #8d263d);
    box-shadow: 0 6px 0 #6f1e32, 0 10px 22px rgba(110,30,40,.4);
}
.kp-map-boss-node.is-semester .kp-map-boss-art,
.kp-map-boss-node.is-semester.caption-above .kp-map-boss-art {
    left: 50%; right: auto; top: auto; bottom: calc(100% + 4px);
    transform: translateX(-50%); width: 160px; height: 150px;
}
.kp-map-boss-node.is-semester .kp-map-boss-art .aa-boss-svg,
.kp-map-boss-node.is-semester.caption-above .kp-map-boss-art .aa-boss-svg { width: 160px; height: 150px; }
.kp-map-boss-node.is-holiday {
    width: 82px; height: 82px; border-color: #fff0a8;
    background: linear-gradient(145deg, #f39fc3, #9a68c7);
    box-shadow: 0 5px 0 #70468e, 0 8px 18px rgba(76,44,110,.32);
}
.kp-map-boss-node.is-holiday .kp-map-boss-art,
.kp-map-boss-node.is-holiday.caption-above .kp-map-boss-art {
    left: 50%; right: auto; top: auto; bottom: calc(100% + 4px);
    transform: translateX(-50%); width: 112px; height: 104px;
    border-radius: 24px; overflow: hidden; background: #f8f5ff;
}
.kp-map-boss-node.is-holiday .kp-map-boss-art .aa-boss-svg,
.kp-map-boss-node.is-holiday.caption-above .kp-map-boss-art .aa-boss-svg {
    width: 112px; height: 104px; object-fit: cover; border-radius: 24px;
}
.kp-map-boss-period {
    position: absolute; top: calc(100% + 7px); left: 50%; transform: translateX(-50%);
    padding: 2px 7px; border-radius: 7px; background: rgba(255,255,255,.9);
    color: #6b3c80; font-size: 15px; font-weight: 800; white-space: nowrap;
    pointer-events: none;
}
.kp-map-boss-node .kp-map-node-caption { top: calc(100% + 34px); }
.kp-map-boss-node.caption-above .kp-map-node-caption { top: auto; }
.kp-map-boss-node.is-pending { filter: grayscale(.55); opacity: .72; }
.kp-map-boss-hp { position: absolute; left: 8px; right: 8px; bottom: 7px; height: 5px; border-radius: 3px; overflow: hidden; background: rgba(255,255,255,.35); }
.kp-map-boss-hp i { display: block; height: 100%; background: #ffe4eb; }

.kp-map-treasure {
    position: absolute; z-index: 6; width: 54px; height: 54px;
    transform: translate(-50%,-50%); padding: 0; border: 0; background: transparent;
    cursor: pointer; filter: drop-shadow(0 4px 3px rgba(80,45,50,.25));
}
.kp-map-treasure svg { width: 100%; height: 100%; }
.kp-map-treasure:hover { filter: drop-shadow(0 4px 5px rgba(80,45,50,.35)) brightness(1.08); }
.kp-map-treasure.is-locked { filter: grayscale(.65); opacity: .68; cursor: not-allowed; }
.kp-map-treasure:disabled { cursor: wait; opacity: .6; }
.kp-map-treasure-caption {
    position: absolute; top: calc(100% + 3px); left: 50%; transform: translateX(-50%);
    padding: 2px 6px; border-radius: 6px; background: rgba(255,255,255,.88);
    color: #744254; font-size: 10px; white-space: nowrap;
}

.kp-map-start, .kp-map-finish {
    position: absolute; z-index: 3; width: 82px; transform: translate(-50%,-50%) scale(1.4);
    text-align: center; pointer-events: none;
}
.kp-map-start i, .kp-map-finish i {
    position: relative; display: block; width: 58px; height: 22px; margin: 0 auto 5px;
    border: 4px solid rgba(255,255,255,.85); border-radius: 50%;
    background: #58b66b; box-shadow: 0 4px 0 rgba(41,105,59,.4);
}
.kp-map-start i::before { content: ""; position: absolute; left: 25px; bottom: 12px; width: 4px; height: 68px; background: #f4f0d5; border-radius: 2px; }
.kp-map-start i::after { content: ""; position: absolute; left: 29px; bottom: 52px; border-top: 12px solid transparent; border-bottom: 12px solid transparent; border-left: 30px solid #55c878; }
.kp-map-finish i { background: #9a70d0; box-shadow: 0 4px 0 rgba(83,54,121,.4); }
.kp-map-finish.is-complete i { background: #f1bd45; box-shadow: 0 4px 0 #b67b22; }
.kp-map-start b, .kp-map-finish b {
    display: inline-block; padding: 2px 8px; border-radius: 8px;
    background: rgba(255,255,255,.86); color: #3a5e49; font-size: 11px;
}
.kp-map-finish b { color: #624585; }

.kp-map-hero, .kp-map-monster {
    position: absolute; z-index: 5; transform: translate(-50%,-100%);
    pointer-events: none;
}
.kp-map-hero { width: 118px; height: 142px; }
.kp-map-hero .aa-stage { position: absolute; left: 50%; bottom: 17px; margin-left: -70px; transform: scale(.67); transform-origin: 50% 100%; }
.kp-map-hero > span {
    position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
    padding: 2px 7px; border-radius: 8px; background: rgba(255,255,255,.88);
    color: #3e5064; font-size: 15px; font-weight: 700; white-space: nowrap;
}
.kp-map-monster { width: 106px; height: 110px; animation: kpMapMonsterBob 2.4s ease-in-out infinite; }
.kp-map-monster .aa-monster-svg { width: 106px; height: 106px; }
.kp-map-complete {
    position: absolute; z-index: 5; transform: translateX(-50%); padding: 5px 12px;
    border-radius: 12px; background: #fff3b0; color: #875d0a;
    font-size: 13px; font-weight: 800; white-space: nowrap;
}
.kp-map-chapter-empty {
    position: absolute; left: 50%; top: 45%; z-index: 5; transform: translate(-50%,-50%);
    padding: 10px 18px; border-radius: 12px; background: rgba(255,255,255,.88);
    color: #496073; font-weight: 700; white-space: nowrap;
}
.kp-map-state {
    min-height: 280px; display: flex; align-items: center; justify-content: center;
    border-radius: 16px; background: linear-gradient(#65c8ed, #a6d984);
    color: #294a5d; font-weight: 700;
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@keyframes kpMapCurrentPulse { 50% { box-shadow: 0 5px 0 #2750a4, 0 0 0 12px rgba(255,240,128,0), 0 8px 18px rgba(29,73,110,.35); } }
@keyframes kpMapClaimPulse { 50% { box-shadow: 0 5px 0 #5b2c76, 0 0 0 10px rgba(255,220,100,.12), 0 8px 16px rgba(75,35,100,.35); } }
@keyframes kpMapMonsterBob { 50% { margin-top: -7px; } }

@media (max-width: 768px) {
    .kp-map-node-caption { width: 120px; }
    .kp-map-boss-node .kp-map-node-caption { width: 138px; }
}
@media (prefers-reduced-motion: reduce) {
    .kp-map-node.is-current, .kp-map-boss-node.is-claimable, .kp-map-monster,
    .kp-battle-stage *, .kp-sword-btn { animation: none; }
}

@keyframes kpVerdictPop { 0% { transform: scale(.8); opacity: 0; } }

.kp-quiz-mask {
    position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 900;
    display: flex; align-items: center; justify-content: center; padding: 16px;
}
.kp-quiz-modal {
    background: #fff; border-radius: 14px; padding: 16px 18px;
    width: 100%; max-width: 560px; max-height: 86vh; overflow-y: auto;
}
.kp-quiz-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.kp-quiz-meta { font-size: 12px; color: #666; margin: 4px 0 10px; }
.kp-quiz-q { margin-bottom: 14px; padding: 10px; border-radius: 10px; background: #f9fafb; }
.kp-quiz-qtext { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.kp-quiz-opt { display: block; font-size: 14px; padding: 4px 6px; border-radius: 6px; cursor: pointer; }
.kp-quiz-opt:hover { background: #eef2ff; }
.kp-quiz-opt input { margin-right: 6px; }
.kp-quiz-fill { width: 60%; min-width: 200px; padding: 6px 10px; font-size: 14px;
    border: 1px solid #d1d5db; border-radius: 6px; }
.kp-quiz-fill:focus { outline: none; border-color: #6366f1; }
.kp-quiz-kptag { display: inline-block; margin-left: 6px; padding: 0 6px; font-size: 11px;
    color: #6366f1; background: #eef2ff; border-radius: 8px; font-weight: 400; }
.kp-side-stats { font-size: 12px; color: #4b5563; line-height: 1.7; background: #f9fafb;
    border-radius: 8px; padding: 6px 10px; margin: 6px 0; }
.kp-side-stats b { color: #111827; }
.kp-q-correct { outline: 2px solid #22c55e; }
.kp-q-wrong { outline: 2px solid #ef4444; }
.kp-quiz-expl { font-size: 12px; color: #166534; margin-top: 6px; }
.kp-quiz-foot { text-align: center; margin-top: 8px; }
.kp-quiz-verdict { border-radius: 10px; padding: 12px; margin: 10px 0; font-size: 15px; }
.kp-verdict-pass { background: #dcfce7; color: #166534; }
.kp-verdict-fail { background: #fef3c7; color: #92400e; }
.kp-quiz-next { font-size: 12px; margin-top: 4px; }
.kp-progress-item { padding: 2px 0; line-height: 1.6; }
.kp-remedial { margin-top: 8px; font-size: 13px; }
.kp-remedial-item { padding: 2px 0; }
.kp-review-item {
    display: flex; gap: 8px; align-items: center; cursor: pointer;
    padding: 8px 10px; border-radius: 8px; margin-bottom: 6px; background: #fffbeb;
    border: 1px solid #fde68a; font-size: 14px;
}
.kp-review-item:hover { background: #fef3c7; }
.kp-review-name { flex: 1; }
.kp-node-stage {
    flex-shrink: 0; font-size: 11px; background: #ede9fe; color: #5b21b6;
    border-radius: 8px; padding: 1px 6px;
}

/* ---- 答题弹窗战斗化（闯关/复习时加 kp-quiz-battle） ---- */
.kp-quiz-battle .kp-quiz-modal {
    border: 2px solid #7c3aed; border-radius: 18px;
    box-shadow: 0 0 30px rgba(124,58,237,.45);
}
.kp-quiz-battle .kp-quiz-head {
    background: linear-gradient(90deg, #4c1d95, #7c3aed); color: #fff;
    margin: -16px -18px 10px; padding: 12px 18px; border-radius: 14px 14px 0 0;
}
.kp-quiz-battle .kp-quiz-head .btn-small { background: rgba(255,255,255,.15); color: #fff; border: none; }
.kp-quiz-battle .kp-quiz-opt:hover { background: #ede9fe; transform: translateX(2px); }
.kp-quiz-battle .kp-verdict-pass { animation: kpVerdictPop .4s ease-out; }

@media (max-width: 768px) {
    .kp-quiz-modal { max-height: 92vh; }

    /* 复习徽章更紧凑 */
    .kp-review-badge { padding: 4px 8px; font-size: 12px; }
}

/* 手机端（≤480px）：更激进的适配 */
@media (max-width: 480px) {
    /* 世界标签：水平滑动（不换行），隐藏滚动条 */
    .kp-world-tabs {
        flex-wrap: nowrap; overflow-x: auto; gap: 6px; padding-bottom: 4px;
        -webkit-overflow-scrolling: touch; scrollbar-width: none;
    }
    .kp-world-tabs::-webkit-scrollbar { display: none; }
    .kp-world-tab {
        flex: 0 0 auto; min-width: 68px; padding: 6px 10px; font-size: 11px;
        border-radius: 10px; border-width: 1.5px;
    }
    .kp-world-icon { font-size: 18px; }
    .kp-world-name { font-size: 11px; }
    .kp-world-bar { height: 4px; }
    .kp-world-pct { font-size: 10px; }

    /* 年级列更窄（全部年级模式），配合弹性列宽尽量一屏放下 */
    .kp-grade-col { min-width: 100px; }
    .kp-grade-head { font-size: 12px; padding: 6px 8px; }
    /* 知识点芯片：加大点击区域 */
    .kp-chip {
        font-size: 12px; padding: 6px 8px; min-height: 36px;
        margin-bottom: 5px; line-height: 1.3;
    }
    .kp-chip-list { max-height: 35vh; }

    /* 卡片模式手机端优化 */
    .kp-cards-head { padding: 6px 10px; border-radius: 8px; }
    .kp-cards-grade { font-size: 14px; }
    .kp-grade-card { padding: 10px 10px; gap: 8px; border-radius: 8px; }
    .kp-card-name { font-size: 13px; }
    .kp-card-status { font-size: 16px; }
    .kp-card-diff { font-size: 10px; }

    /* 详情面板 */
    .kp-side { font-size: 13px; padding: 10px; }
    .kp-side-head { font-size: 14px; }
    /* 标记按钮行加大 */
    .kp-mark-row { gap: 4px; }
    .kp-mark-row .btn-small { min-height: 36px; padding: 6px 10px; font-size: 12px; }

    /* 答题弹窗全屏 */
    .kp-quiz-mask { padding: 0; align-items: stretch; }
    .kp-quiz-modal {
        max-width: 100vw; max-height: 100vh; border-radius: 0;
        padding: 12px 14px; margin: 0;
    }
    .kp-quiz-qtext { font-size: 14px; }
    /* 答题选项：加大点击区域，防止误触 */
    .kp-quiz-opt {
        font-size: 14px; padding: 10px 10px; margin-bottom: 2px;
        min-height: 42px; display: flex; align-items: center;
    }
    .kp-quiz-opt input[type="radio"] { width: 18px; height: 18px; margin-right: 8px; }
    .kp-quiz-head { font-size: 15px; }
    .kp-quiz-foot .btn-primary { min-height: 42px; padding: 10px 28px; font-size: 15px; }

    /* 战斗弹窗标题修正 */
    .kp-quiz-battle .kp-quiz-head {
        margin: -12px -14px 8px; padding: 10px 14px;
        border-radius: 0;
    }

    /* 标题栏下拉框：覆盖内联 max-width，16px 防 iOS 缩放 */
    .kp-title-actions select {
        max-width: 120px !important; font-size: 14px;
    }
}

/* ==================== 知识图谱响应式补充 ==================== */

/* 平板（768-1023px）：知识图谱仍可并排但缩小侧栏 */
@media (min-width: 768px) and (max-width: 1023px) {
    .kp-main {
        flex-direction: row;
    }
    .kp-side {
        width: 280px;
    }
    .kp-grade-col {
        min-width: 110px;
    }
}

/* ---------- 宽屏（≥1280px）：知识图谱侧栏加大（年级列保持弹性，不再强制加宽） ---------- */
@media (min-width: 1280px) {
    .kp-side {
        width: 380px;
    }
    .kp-main {
        gap: 16px;
    }
}

/* ---------- 大屏（≥1600px）：进一步放宽侧栏 ---------- */
@media (min-width: 1600px) {
    .kp-side {
        width: 420px;
    }
}
