/**
 * 国象进阶练习模块样式
 * 覆盖: 目录页 / 解题页（棋盘、关卡轨道、弹窗、序章）+ 移动端适配
 * 主题: 跟随站点紫色渐变主题（#667eea → #764ba2），棋盘色使用全局 CSS 变量 --sq-light/--sq-dark
 */

/* ============ 通用 ============ */
.prac-page { max-width: 1400px; margin: 0 auto; padding: 0 16px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; color: #333; }
@media (min-width: 1024px) {
    .prac-theme-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1280px) {
    .prac-theme-grid { grid-template-columns: repeat(4, 1fr); }
}
.prac-page button { font-family: inherit; }
.prac-muted { color: #999; font-size: 12px; font-weight: normal; }

.prac-btn {
    padding: 9px 18px; border: 1px solid #e0e0e0; border-radius: 8px; background: #fff;
    color: #333; font-size: 14px; cursor: pointer; transition: all .15s; white-space: nowrap;
}
.prac-btn:hover { border-color: #667eea; color: #667eea; transform: translateY(-1px); }
.prac-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.prac-btn-primary { background: linear-gradient(135deg, #667eea, #764ba2); border: none; color: #fff; }
.prac-btn-primary:hover { color: #fff; opacity: .92; }
.prac-btn-ghost { background: rgba(255,255,255,.6); }
.prac-btn-danger { background: #ffebee; border-color: #ef9a9a; color: #c62828; }
.prac-btn-sm { padding: 5px 12px; font-size: 12px; }

/* ============ 目录页 ============ */
.prac-banner {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #fff;
    border-radius: 12px; padding: 12px 18px; font-size: 14px; margin-bottom: 14px;
    box-shadow: 0 4px 14px rgba(102,126,234,.35); transition: opacity .4s;
}
.prac-banner.hide { opacity: 0; pointer-events: none; height: 0; margin: 0; padding: 0; overflow: hidden; }

.prac-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.prac-header-left h2 { margin: 0 0 4px; font-size: 22px; color: #333; }
.prac-sub { margin: 0; color: #888; font-size: 13px; }

.prac-loading { text-align: center; padding: 60px 0; color: #888; font-size: 14px; }
.prac-spinner {
    width: 28px; height: 28px; margin: 0 auto 12px; border-radius: 50%;
    border: 3px solid #e5e7f2; border-top-color: #667eea; animation: pracSpin .8s linear infinite;
}
@keyframes pracSpin { to { transform: rotate(360deg); } }
.prac-error { text-align: center; padding: 60px 0; color: #888; }

.prac-category { background: linear-gradient(135deg, #fff8f3 0%, #ffffff 60%); border-radius: 14px; padding: 14px 18px 12px; margin-bottom: 14px; box-shadow: 0 2px 10px rgba(0,0,0,.05); border-left: 4px solid #ff7043; }
.prac-cat-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px dashed #ffe0d0; }
.prac-cat-icon { font-size: 22px; width: 32px; height: 32px; border-radius: 8px; background: linear-gradient(135deg, #ff7043, #ff5722); color: #fff; display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 2px 6px rgba(255,112,67,.35); }
.prac-cat-name { font-size: 17px; font-weight: 700; color: #c54417; flex: 1; }
.prac-cat-desc { font-size: 12px; color: #ff7043; background: rgba(255,112,67,.08); padding: 2px 8px; border-radius: 8px; }

.prac-theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.prac-theme-card {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px;
    border: 1px solid #eef0f7; background: linear-gradient(135deg, #fff 0%, #f8f9ff 100%); cursor: pointer; transition: all .18s; text-decoration: none; color: inherit;
    position: relative; overflow: hidden;
}
.prac-theme-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: linear-gradient(90deg, #667eea, #764ba2); }
.prac-theme-card:hover { border-color: #667eea; box-shadow: 0 6px 18px rgba(102,126,234,.18); transform: translateY(-2px); }
.prac-theme-card.done { background: linear-gradient(135deg, #e8f5e9, #c8e6c9); border-color: #a5d6a7; }
.prac-theme-card.done::before { background: linear-gradient(90deg, #4CAF50, #81C784); }
.prac-theme-card.doing { background: linear-gradient(135deg, #e3f2fd, #bbdefb); border-color: #90caf9; }
.prac-theme-card.doing::before { background: linear-gradient(90deg, #2196F3, #64B5F6); }

.prac-theme-icon { width: 44px; height: 44px; flex-shrink: 0; border-radius: 10px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 10px rgba(102,126,234,.35); padding: 7px; }
.prac-theme-icon img { width: 100%; height: 100%; filter: brightness(0) invert(1); }
.prac-theme-card.done .prac-theme-icon { background: linear-gradient(135deg, #4CAF50 0%, #81C784 100%); box-shadow: 0 4px 10px rgba(76,175,80,.4); }
.prac-theme-card.doing .prac-theme-icon { background: linear-gradient(135deg, #2196F3 0%, #64B5F6 100%); box-shadow: 0 4px 10px rgba(33,150,243,.4); }

.prac-theme-info { flex: 1; min-width: 0; }
.prac-theme-name { font-size: 14px; font-weight: 600; color: #333; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prac-theme-progress-bar { height: 5px; border-radius: 3px; background: rgba(102,126,234,.15); overflow: hidden; margin-bottom: 4px; }
.prac-theme-progress-fill { height: 100%; border-radius: 3px; background: linear-gradient(90deg, #667eea, #9f7aea); transition: width .3s; box-shadow: 0 1px 3px rgba(102,126,234,.4); }
.prac-theme-card.done .prac-theme-progress-fill { background: linear-gradient(90deg, #4CAF50, #81C784); box-shadow: 0 1px 3px rgba(76,175,80,.4); }
.prac-theme-card.doing .prac-theme-progress-fill { background: linear-gradient(90deg, #2196F3, #64B5F6); box-shadow: 0 1px 3px rgba(33,150,243,.4); }
.prac-theme-meta { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: #888; }
.prac-theme-status { font-weight: 600; }
.prac-theme-status.nodo { color: #aaa; }
.prac-theme-status.doing { color: #667eea; }
.prac-theme-status.done { color: #2e7d32; letter-spacing: 1px; }

/* ============ 解题页顶部 ============ */
.prac-study-top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.prac-back { padding: 6px 12px; border-radius: 8px; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.08); color: #555; text-decoration: none; font-size: 14px; }
.prac-back:hover { color: #667eea; }
.prac-study-title { flex: 1; font-size: 18px; font-weight: 700; color: #333; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prac-top-actions { display: flex; gap: 8px; }
.prac-top-btn {
    position: relative; width: 38px; height: 38px; border-radius: 10px; border: none; background: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,.08); font-size: 17px; cursor: pointer; transition: all .15s;
}
.prac-top-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(0,0,0,.1); }
.prac-badge {
    position: absolute; top: -5px; right: -5px; min-width: 17px; height: 17px; padding: 0 4px;
    border-radius: 9px; background: #f44336; color: #fff; font-size: 11px; line-height: 17px; text-align: center;
}

/* ============ 关卡轨道 ============ */
.prac-stage-rail-wrap { background: #fff; border-radius: 12px; padding: 10px 12px; margin-bottom: 14px; box-shadow: 0 2px 8px rgba(0,0,0,.05); }
.prac-stage-rail { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.prac-stage-btn {
    min-width: 40px; height: 40px; padding: 0 8px; border-radius: 9px; border: 1.5px solid #e4e7f1; background: #fff;
    font-size: 13px; font-weight: 600; color: #666; cursor: pointer; flex-shrink: 0; transition: all .15s;
}
.prac-stage-btn:hover { border-color: #667eea; color: #667eea; }
.prac-stage-btn.current { border-color: #667eea; background: linear-gradient(135deg, #667eea, #764ba2); color: #fff; box-shadow: 0 3px 10px rgba(102,126,234,.35); }
.prac-stage-btn.prologue { border-style: dashed; color: #667eea; background: #f5f3ff; }
.prac-stage-btn.star1 { border-color: #f5c887; background: #fff8ec; color: #c9862b; }
.prac-stage-btn.star2 { border-color: #f0b13d; background: #fff4dc; color: #b07a12; }
.prac-stage-btn.star3 { border-color: #f2b32c; background: linear-gradient(135deg, #ffe9b3, #ffd76e); color: #8a6100; }

/* ============ 主区域布局 ============ */
.prac-main { display: grid; grid-template-columns: minmax(320px, 1fr) 320px; gap: 16px; align-items: start; }

/* ============ 棋盘 ============ */
.prac-board-col { min-width: 0; }
.prac-board-box { display: flex; justify-content: center; }
.prac-board { position: relative; width: 100%; max-width: 560px; aspect-ratio: 1 / 1; border-radius: 8px; overflow: hidden; box-shadow: 0 4px 16px rgba(0,0,0,.12); }
.prac-board-mini { max-width: 300px; box-shadow: 0 2px 10px rgba(0,0,0,.1); }
.prac-board-grid { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); }
.prac-sq { position: relative; }
.prac-sq.light { background: var(--sq-light, #f0d9b5); }
.prac-sq.dark { background: var(--sq-dark, #b58863); }
.prac-sq.selected::after { content: ''; position: absolute; inset: 0; background: rgba(102,126,234,.45); }
.prac-sq.last-move::after { content: ''; position: absolute; inset: 0; background: rgba(255,213,79,.42); }
.prac-sq.valid-dot::before {
    content: ''; position: absolute; left: 50%; top: 50%; width: 22%; height: 22%;
    transform: translate(-50%, -50%); border-radius: 50%; background: rgba(20,20,20,.22);
}
.prac-sq.valid-cap::before {
    content: ''; position: absolute; inset: 5%; border-radius: 50%;
    border: 4px solid rgba(20,20,20,.22);
}
.prac-sq .chess-piece { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.prac-sq .coord { position: absolute; font-size: 10px; font-weight: 700; opacity: .55; pointer-events: none; }
.prac-sq .coord.file { right: 3px; bottom: 1px; }
.prac-sq .coord.rank { left: 3px; top: 1px; }
.prac-sq.light .coord { color: var(--sq-dark, #b58863); }
.prac-sq.dark .coord { color: var(--sq-light, #f0d9b5); }

/* 批注层（箭头/高亮/关键格），viewBox 0 0 8 8 */
.prac-board-anno { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.prac-anno-hl { fill-opacity: .45; }
.prac-anno-arrow { stroke-width: .13; stroke-linecap: round; fill: none; }
.prac-anno-arrow-head { stroke: none; }
.prac-anno-key { fill: rgba(255,255,255,.85); }
.prac-anno-key-text { font-size: .42px; font-weight: 700; text-anchor: middle; dominant-baseline: central; fill: #c62828; }
/* 答案演示/提示箭头 */
.prac-arrow-hint { stroke: #4CAF50; stroke-width: .16; }
.prac-arrow-hint-head { fill: #4CAF50; }
/* 最后一着标记 */
.prac-anno-lastmove { stroke: rgba(255,171,64,.9); stroke-width: .07; fill: none; }

.prac-turn-row { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 12px; font-size: 14px; color: #555; }
.prac-turn-dot { width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid #999; }
.prac-turn-dot.w { background: #fff; border-color: #bbb; }
.prac-turn-dot.b { background: #333; border-color: #333; }

/* 走错横幅 */
.prac-error-banner {
    display: flex; align-items: center; gap: 10px; background: #ffebee; color: #c62828;
    border: 1px solid #ef9a9a; border-radius: 10px; padding: 10px 14px; margin-bottom: 10px; font-size: 13px;
    animation: pracSlideIn .2s ease-out;
}
@keyframes pracSlideIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.prac-banner-hint { margin-left: auto; border: none; background: #c62828; color: #fff; border-radius: 6px; padding: 5px 12px; font-size: 12px; cursor: pointer; flex-shrink: 0; }

/* ============ 右栏 ============ */
.prac-side-col { display: flex; flex-direction: column; gap: 12px; }
.prac-card { background: #fff; border-radius: 12px; padding: 14px 16px; box-shadow: 0 2px 8px rgba(0,0,0,.05); }
.prac-card-title { font-size: 13px; color: #888; font-weight: 600; margin-bottom: 8px; }
.prac-puzzle-name { font-size: 16px; font-weight: 700; color: #333; margin-bottom: 6px; }
.prac-puzzle-goal { font-size: 13px; color: #667eea; line-height: 1.6; }
.prac-concept-tip {
    margin-top: 10px; padding: 10px 12px; background: #f5f3ff; border-left: 3px solid #667eea;
    border-radius: 6px; font-size: 12px; color: #555; line-height: 1.7;
}
.prac-moves { max-height: 150px; overflow-y: auto; font-size: 13px; line-height: 1.9; color: #444; }
.prac-move-item { display: inline-block; margin: 0 6px 4px 0; padding: 2px 8px; background: #f4f5fa; border-radius: 6px; font-family: Consolas, monospace; }
.prac-move-item.mine { background: #ede7f6; color: #4527a0; font-weight: 600; }

.prac-controls { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.prac-controls .prac-btn { width: 100%; padding: 10px 6px; font-size: 13px; }

.prac-answer-area { background: #fff; border-radius: 12px; padding: 14px 16px; box-shadow: 0 2px 8px rgba(0,0,0,.05); }
.prac-answer-text { font-family: Consolas, monospace; font-size: 14px; color: #856404; background: #fff8e1; border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; line-height: 1.9; }

/* ============ 升变浮层 ============ */
.prac-promo-mask, .prac-mask { position: fixed; inset: 0; z-index: 9000; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; }
.prac-promo-card, .prac-modal { background: #fff; border-radius: 16px; padding: 22px 26px; max-width: 480px; width: calc(100% - 48px); box-shadow: 0 20px 60px rgba(0,0,0,.3); animation: pracModalIn .18s ease-out; max-height: 86vh; overflow-y: auto; }
@keyframes pracModalIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.prac-promo-title { text-align: center; font-size: 15px; color: #555; margin-bottom: 14px; }
.prac-promo-choices { display: flex; gap: 10px; justify-content: center; }
.prac-promo-choice { width: 64px; height: 64px; border-radius: 10px; border: 2px solid #e4e7f1; background: #fafbff; cursor: pointer; transition: all .15s; padding: 4px; }
.prac-promo-choice:hover { border-color: #667eea; transform: translateY(-2px); }
.prac-promo-choice img { width: 100%; height: 100%; object-fit: contain; }
.prac-promo-cancel { display: block; margin: 14px auto 0; border: none; background: none; color: #999; font-size: 13px; cursor: pointer; }

/* ============ 弹窗通用 ============ */
.prac-modal-title { font-size: 17px; font-weight: 700; color: #333; margin-bottom: 12px; text-align: center; }
.prac-modal-text { font-size: 14px; color: #666; line-height: 1.8; text-align: center; margin-bottom: 14px; }
.prac-modal-actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.prac-result-icon { font-size: 52px; text-align: center; }
.prac-result-msg { font-size: 17px; font-weight: 600; text-align: center; margin-top: 8px; color: #333; }
.prac-result-stars { text-align: center; font-size: 26px; color: #f2b32c; letter-spacing: 4px; margin-top: 6px; min-height: 32px; }

/* 选题 */
.prac-modal-picker { max-width: 560px; }
.prac-picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 6px; }
.prac-picker-item {
    padding: 8px 6px; border-radius: 8px; border: 1px solid #e8eaf2; background: #fff; cursor: pointer;
    font-size: 12px; text-align: center; color: #555; transition: all .12s; line-height: 1.4;
}
.prac-picker-item:hover { border-color: #667eea; color: #667eea; }
.prac-picker-item.current { border-color: #667eea; background: #ede7f6; }
.prac-picker-item.done { background: #e8f5e9; border-color: #bfe6c5; }
.prac-picker-item .p-stars { color: #f2b32c; }

/* 课程列表 */
.prac-modal-course { max-width: 560px; }
.prac-course-list { max-height: 55vh; overflow-y: auto; }
.prac-course-cat { font-size: 13px; font-weight: 700; color: #667eea; margin: 12px 0 6px; }
.prac-course-item {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; cursor: pointer;
    border: 1px solid #eef0f7; margin-bottom: 6px; font-size: 14px; transition: all .12s;
}
.prac-course-item:hover { border-color: #667eea; background: #f5f3ff; }
.prac-course-item.current { background: #ede7f6; border-color: #667eea; font-weight: 600; }
.prac-course-item .cat-tag { font-size: 11px; color: #999; background: #f4f5fa; padding: 2px 8px; border-radius: 8px; }

/* 错题本 */
.prac-mistake-list { max-height: 50vh; overflow-y: auto; }
.prac-mistake-item { padding: 10px 12px; border-radius: 10px; border: 1px solid #f0d9d9; background: #fffafa; margin-bottom: 6px; }
.prac-mistake-item .m-name { font-size: 14px; font-weight: 600; color: #333; }
.prac-mistake-item .m-meta { font-size: 12px; color: #999; margin-top: 3px; }
.prac-mistake-item .m-ops { margin-top: 6px; display: flex; gap: 8px; }
.prac-mistake-item .m-ops button { border: 1px solid #e0e0e0; background: #fff; border-radius: 6px; padding: 3px 10px; font-size: 12px; cursor: pointer; color: #555; }

/* 说明弹窗 */
.prac-desc-body { font-size: 14px; color: #555; line-height: 1.9; }
.prac-desc-body h4 { margin: 12px 0 4px; color: #333; }
.prac-desc-body .goal, .prac-desc-body .hint { padding: 8px 12px; border-radius: 8px; margin-bottom: 8px; }
.prac-desc-body .goal { background: #ede7f6; color: #4527a0; }
.prac-desc-body .hint { background: #fff8e1; color: #856404; }

/* ============ 序章弹窗 ============ */
.prac-modal-prologue { max-width: 720px; padding: 18px 22px; }
.prac-prologue-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.prac-prologue-title { flex: 1; font-size: 16px; font-weight: 700; color: #333; min-width: 120px; }
.prac-prologue-nav { display: flex; align-items: center; gap: 8px; }
.prac-prologue-close { border: none; background: none; font-size: 24px; color: #999; cursor: pointer; line-height: 1; }
.prac-prologue-body { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }
.prac-prologue-board-wrap { display: flex; justify-content: center; }
.prac-prologue-points { font-size: 14px; color: #444; line-height: 1.9; max-height: 400px; overflow-y: auto; padding-right: 6px; }
.prac-tp { margin: 0 0 8px; }
.prac-tp.heading { font-size: 16px; font-weight: 700; color: #333; margin-top: 6px; }
.prac-tp.heading.lv2 { font-size: 14px; }
.prac-tp.important { background: #fff8e1; border-left: 3px solid #f0b13d; padding: 8px 12px; border-radius: 6px; color: #7a5a00; }
.prac-tp.step { background: #f4f6fb; border-radius: 6px; padding: 6px 12px; color: #4338ca; font-family: Consolas, monospace; font-size: 13px; }
.prac-tp.list { padding-left: 4px; }
.prac-prologue-foot { margin-top: 14px; text-align: center; }

/* ============ 移动端 ============ */
@media (max-width: 860px) {
    .prac-main { grid-template-columns: 1fr; }
    .prac-theme-grid { grid-template-columns: 1fr; }
    .prac-board { max-width: 100%; }
    .prac-controls { grid-template-columns: repeat(3, 1fr); }
    .prac-prologue-body { grid-template-columns: 1fr; }
    .prac-prologue-points { max-height: 300px; }
    .prac-stage-rail-wrap { position: sticky; top: 0; z-index: 50; }
    .prac-study-title { font-size: 16px; }
}
@media (max-width: 480px) {
    .prac-header-left h2 { font-size: 19px; }
    .prac-controls { grid-template-columns: repeat(2, 1fr); }
    .prac-banner { font-size: 12px; }
}
