/* ========================================
   星际程序员 - 组件样式
   ======================================== */

/* ========================================
   按钮组件
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-family: var(--font-cn);
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-normal);
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--neon-cyan), #0099cc);
    color: var(--space-dark);
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(0, 245, 255, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(0, 245, 255, 0.5);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--space-mid);
    color: var(--text-primary);
    border: 1px solid rgba(0, 245, 255, 0.3);
}

.btn-secondary:hover {
    background: var(--space-light);
    border-color: var(--neon-cyan);
}

.btn-run {
    background: linear-gradient(135deg, var(--neon-green), #00cc66);
    color: var(--space-dark);
    font-weight: 700;
    padding: 12px 30px;
}

.btn-run:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(0, 255, 136, 0.5);
}

.btn-hint {
    background: transparent;
    color: var(--warning-yellow);
    border: 1px solid var(--warning-yellow);
    padding: 8px 16px;
    font-size: 13px;
}

.btn-hint:hover {
    background: rgba(255, 215, 0, 0.1);
}

.btn-large {
    padding: 18px 40px;
    font-size: 18px;
    border-radius: var(--radius-lg);
}

.btn-icon {
    font-size: 12px;
}

/* ========================================
   关卡卡片
   ======================================== */
.level-card {
    position: relative;
    background: var(--space-mid);
    border-radius: var(--radius-lg);
    padding: 25px;
    border: 1px solid rgba(0, 245, 255, 0.1);
    cursor: pointer;
    transition: var(--transition-normal);
    overflow: hidden;
}

.level-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--neon-cyan), var(--neon-pink));
    opacity: 0;
    transition: var(--transition-normal);
}

.level-card:hover {
    transform: translateY(-5px);
    border-color: rgba(0, 245, 255, 0.3);
    box-shadow: var(--shadow-card);
}

.level-card:hover::before {
    opacity: 1;
}

/* AI主题卡片 - 紫色风格 */
.level-card.theme-ai-card {
    border-color: rgba(138, 43, 226, 0.3);
}

.level-card.theme-ai-card .level-card-header {
    background: linear-gradient(135deg, rgba(138, 43, 226, 0.15), rgba(168, 85, 247, 0.08));
    border-bottom-color: rgba(138, 43, 226, 0.2);
}

.level-card.theme-ai-card:hover {
    transform: translateY(-5px);
    border-color: rgba(168, 85, 247, 0.4);
    box-shadow: 0 8px 30px rgba(138, 43, 226, 0.2);
}

.level-card.theme-ai-card:hover::before {
    background: linear-gradient(90deg, #a855f7, #ec4899);
}

/* 游戏主题卡片 - 金色风格 */
.level-card.theme-game-card {
    border-color: rgba(234, 179, 8, 0.3);
}

.level-card.theme-game-card .level-card-header {
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.15), rgba(250, 204, 21, 0.08));
    border-bottom-color: rgba(234, 179, 8, 0.2);
}

.level-card.theme-game-card:hover {
    transform: translateY(-5px);
    border-color: rgba(234, 179, 8, 0.4);
    box-shadow: 0 8px 30px rgba(234, 179, 8, 0.2);
}

.level-card.theme-game-card:hover::before {
    background: linear-gradient(90deg, #eab308, #facc15);
}

.level-card.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.level-card.locked:hover {
    transform: none;
}

/* 开发模式下强制解锁的卡片 - 微妙标识 */
.level-card.dev-unlocked {
    border-color: rgba(168, 85, 247, 0.3) !important;
}

.level-card.dev-unlocked .level-badge::after {
    content: 'DEV';
    font-size: 9px;
    color: #a855f7;
    margin-left: 4px;
    font-weight: 600;
    letter-spacing: 1px;
}

.level-card.completed {
    border-color: rgba(0, 255, 136, 0.3);
}

.level-card.completed::before {
    opacity: 1;
    background: linear-gradient(90deg, var(--neon-green), var(--neon-cyan));
}

.level-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.level-badge {
    font-family: var(--font-title);
    font-size: 12px;
    font-weight: 700;
    color: var(--neon-cyan);
    letter-spacing: 2px;
}

.level-card.completed .level-badge {
    color: var(--neon-green);
}

.level-icon {
    font-size: 32px;
    opacity: 0.8;
}

.level-card-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.level-card-desc {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 15px;
}

.level-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    padding: 4px 10px;
    background: rgba(0, 245, 255, 0.1);
    border-radius: var(--radius-sm);
    font-size: 11px;
    color: var(--neon-cyan);
}

.level-card-status {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.level-card-status.locked {
    background: rgba(255, 71, 87, 0.2);
    color: var(--error-red);
}

.level-card-status.completed {
    background: rgba(0, 255, 136, 0.2);
    color: var(--neon-green);
}

/* ========================================
   骨架屏加载状态
   ======================================== */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.level-card.skeleton {
    background: var(--space-mid);
    border: 1px solid rgba(0, 245, 255, 0.1);
    animation: none;
}

.level-card.skeleton::before {
    display: none;
}

.skeleton-badge,
.skeleton-status,
.skeleton-icon,
.skeleton-title,
.skeleton-desc,
.skeleton-tag {
    background: linear-gradient(90deg,
        var(--space-dark) 25%,
        rgba(0, 245, 255, 0.1) 50%,
        var(--space-dark) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
}

.skeleton-badge {
    width: 60px;
    height: 20px;
}

.skeleton-status {
    width: 20px;
    height: 20px;
    border-radius: 50%;
}

.skeleton-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin: 10px auto;
}

.skeleton-title {
    width: 70%;
    height: 18px;
    margin: 10px auto 5px;
}

.skeleton-desc {
    width: 90%;
    height: 14px;
    margin: 5px auto;
}

.skeleton-tags {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 10px;
}

.skeleton-tag {
    width: 50px;
    height: 20px;
}

/* ========================================
   挑战界面 - 全屏左右分栏布局
   ======================================== */
.screen-challenge {
    display: none;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    background: var(--space-dark);
    overflow: hidden;
    height: 100vh;
}

.screen-challenge.active {
    display: flex !important;
}

/* 顶部：进度 + 导航 */
.lesson-header {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 10px 20px;
    flex-shrink: 0;
    background: var(--space-mid);
    border-bottom: 1px solid rgba(0, 245, 255, 0.15);
}

.lesson-header .step-progress {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 0;
}

.lesson-header .progress-bar {
    flex: 1;
    height: 6px;
    margin-bottom: 0;
}

.lesson-header .step-dots {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.lesson-header #ttsContainer {
    display: flex;
    align-items: center;
    margin-left: auto;
}

/* 主区域：左右分栏（核心） */
.lesson-body {
    display: grid;
    grid-template-columns: 45% 55%;
    flex: 1;            /* 填满剩余高度 */
    min-height: 0;      /* 允许flex子元素收缩 */
    overflow: hidden;    /* 不出现页面滚动条 */
    width: 100%;        /* 确保宽度填满 */
    box-sizing: border-box;
}

/* 学习模式：左侧全宽（编辑器隐藏时） */
.lesson-body.learn-mode {
    grid-template-columns: 1fr;
}

/* 左侧：教学内容（可滚动） */
.lesson-teaching {
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    overflow-x: hidden;  /* 防止横向溢出 */
    padding: 16px 20px;
    scrollbar-width: thin;
    scrollbar-color: rgba(0,245,255,0.3) transparent;
    border-right: 1px solid rgba(0, 245, 255, 0.1);
    min-height: 0;
    width: 100%;        /* 确保宽度填满 */
    box-sizing: border-box;
    /* 确保能获得父级的高度 */
    height: 100%;
}

.lesson-teaching::-webkit-scrollbar {
    width: 6px;
}
.lesson-teaching::-webkit-scrollbar-thumb {
    background: rgba(0,245,255,0.5);
    border-radius: 3px;
}
.lesson-teaching::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.2);
}

/* 右侧：编辑器 + 输出 */
.lesson-editor {
    display: flex;
    flex-direction: column;
    flex: 1;            /* 获得grid分配的空间 */
    min-height: 0;
    overflow: hidden;
    width: 100%;        /* 确保宽度填满 */
    box-sizing: border-box;
    pointer-events: auto; /* 确保可以交互 */
}

/* 编辑器头部 */
.lesson-editor .editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(0,0,0,0.4);
    border-bottom: 1px solid rgba(0, 245, 255, 0.15);
    flex-shrink: 0;
}

.lesson-editor .editor-title {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--neon-cyan);
}

.editor-actions {
    display: flex;
    gap: 6px;
}

/* 编辑器区域 - 填满剩余空间 */
.lesson-editor .editor-container {
    display: flex;
    flex: 1;            /* 填满编辑器和输出之间的空间 */
    min-height: 120px;
    background: #0d1117;
    border-bottom: 1px solid rgba(0, 245, 255, 0.1);
    overflow: hidden;
    box-sizing: border-box;
    pointer-events: auto;
    position: relative;
    z-index: 10;
}

.editor-container .code-editor {
    flex: 1;
    width: 100%;
    height: 100%;
    min-width: 0;
    padding: 12px;
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1.5;
    color: var(--neon-green);
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    overflow-y: auto;
    white-space: pre;
    tab-size: 4;
    -moz-tab-size: 4;
    pointer-events: auto;
    cursor: text;
    z-index: 9999;
    position: relative;
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
}

/* 行号 */
.editor-container .line-numbers {
    width: 40px;
    padding: 12px 8px 12px 0;
    text-align: right;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.5;
    color: rgba(0, 245, 255, 0.3);
    background: rgba(0, 0, 0, 0.2);
    border-right: 1px solid rgba(0, 245, 255, 0.1);
    overflow: hidden;
    user-select: none;
    pointer-events: none; /* 点击穿透，行号不阻挡编辑器 */
    flex-shrink: 0;
}

.editor-container .line-numbers span {
    display: block;
}

/* 代码编辑器 textarea */
.editor-container .code-editor {
    flex: 1;
    width: 100%;
    height: 100%;
    min-width: 0;
    padding: 12px;
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1.5;
    color: var(--neon-green);
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    overflow-y: auto;
    white-space: pre;
    tab-size: 4;
    -moz-tab-size: 4;
    pointer-events: auto;
    cursor: text;
}

/* textarea placeholder 样式 */
.editor-container .code-editor::placeholder {
    color: rgba(0, 245, 255, 0.25);
}

/* contenteditable的空内容提示（保留兼容） */
.editor-container .code-editor:empty::before {
    content: attr(data-placeholder);
    color: rgba(0, 245, 255, 0.3);
    pointer-events: none;
}

.editor-container .code-editor:focus {
    outline: 2px solid var(--neon-cyan);
}

/* 读取模式（学习步骤） */
.editor-container .code-editor.readonly {
    color: var(--text-dim);
    cursor: default;
}

/* 编辑器底部 */
.lesson-editor .editor-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(0,0,0,0.3);
    border-bottom: 1px solid rgba(0, 245, 255, 0.1);
    flex-shrink: 0;
}

.editor-footer-left {
    display: flex;
    align-items: center;
}

.editor-footer-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 快捷键提示 */
.shortcut-hint {
    font-size: 11px;
    color: var(--text-muted);
    opacity: 0.6;
}

/* 输出面板 - 固定比例 */
.lesson-editor .output-panel {
    flex-shrink: 0;
    height: 30vh;
    background: var(--space-mid);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(0,245,255,0.3) transparent;
}

/* 输出面板标题 */
.output-panel .output-header {
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    background: rgba(0,0,0,0.3);
    border-bottom: 1px solid rgba(0, 245, 255, 0.1);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* 输出内容 */
.output-panel .output-content {
    padding: 10px 12px;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-primary);
}

.output-panel .output-placeholder {
    color: var(--text-dim);
    font-style: italic;
}

.output-panel .output-error {
    color: var(--error-red);
}

.output-panel .output-info {
    color: var(--text-muted);
    font-style: italic;
}

.lesson-editor .output-panel::-webkit-scrollbar {
    width: 4px;
}
.lesson-editor .output-panel::-webkit-scrollbar-thumb {
    background: rgba(0,245,255,0.3);
    border-radius: 2px;
}

/* 底部导航 */
.lesson-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    flex-shrink: 0;
    background: var(--space-mid);
    border-top: 1px solid rgba(0, 245, 255, 0.15);
}

/* 小按钮 */
.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid rgba(0, 245, 255, 0.2);
}

.btn-ghost:hover {
    color: var(--neon-cyan);
    border-color: var(--neon-cyan);
    background: rgba(0, 245, 255, 0.05);
}

.btn-ghost:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* 学习内容区 - 紧凑 */
.learn-content {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-primary);
    flex-shrink: 0; /* 不压缩 */
}

.learn-content p {
    margin-bottom: 8px;
}

.learn-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 13px;
}

.learn-content th, .learn-content td {
    padding: 6px 10px;
    border: 1px solid rgba(0, 245, 255, 0.2);
    text-align: left;
}

.learn-content th {
    background: rgba(0, 245, 255, 0.1);
    color: var(--neon-cyan);
    font-weight: 600;
}

.learn-content code {
    background: rgba(0, 245, 255, 0.1);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--neon-green);
}

.learn-content .tip-box {
    background: rgba(0, 245, 255, 0.05);
    border-left: 3px solid var(--neon-cyan);
    padding: 8px 12px;
    margin: 8px 0;
    border-radius: 0 6px 6px 0;
    font-size: 13px;
}

.learn-content .error-box {
    background: rgba(255, 71, 87, 0.05);
    border-left: 3px solid var(--error-red);
    padding: 8px 12px;
    margin: 8px 0;
    border-radius: 0 6px 6px 0;
    font-size: 13px;
}

.learn-content .memory-box {
    background: rgba(255, 215, 0, 0.05);
    border-left: 3px solid var(--warning-yellow);
    padding: 8px 12px;
    margin: 8px 0;
    border-radius: 0 6px 6px 0;
    font-size: 13px;
}

/* 示例代码 - 紧凑 */
.example-box {
    background: var(--space-mid);
    border-radius: var(--radius-md);
    border: 1px solid rgba(0, 245, 255, 0.15);
    overflow: hidden;
    flex-shrink: 0; /* 不压缩 */
}

.example-header {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--neon-cyan);
    background: rgba(0,0,0,0.3);
    border-bottom: 1px solid rgba(0, 245, 255, 0.1);
}

.example-code {
    margin: 0;
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.5;
    overflow-x: auto;
    white-space: pre-wrap; /* 自动换行 */
    word-break: break-all;
}
    padding: 10px 12px;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.5;
    color: var(--neon-green);
    background: #0d1117;
    overflow-x: auto;
    white-space: pre;
}

.example-output {
    padding: 6px 12px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
    border-top: 1px solid rgba(0, 245, 255, 0.1);
}

/* 任务区 - 紧凑 */
.task-box {
    background: rgba(0, 255, 136, 0.05);
    border-radius: var(--radius-md);
    border: 1px solid rgba(0, 255, 136, 0.2);
    overflow: hidden;
}

.task-header {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--neon-green);
    background: rgba(0,0,0,0.3);
    border-bottom: 1px solid rgba(0, 255, 136, 0.15);
}

.task-content {
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-primary);
}

/* 练习通过动画 */
.step-success-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 200;
    display: none;
}

.step-success-animation.active {
    display: block;
}

/* 答对后的成功条 */
.output-success-bar {
    padding: 10px 16px;
    background: rgba(0, 255, 136, 0.1);
    border: 1px solid var(--neon-green);
    border-radius: var(--radius-md);
    color: var(--neon-green);
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: successSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes successSlideIn {
    from { transform: translateY(10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* 答错后的提示 */
.output-error-bar {
    padding: 10px 16px;
    background: rgba(255, 71, 87, 0.1);
    border: 1px solid var(--error-red);
    border-radius: var(--radius-md);
    color: var(--error-red);
    font-size: 13px;
    animation: errorShake 0.4s ease;
}

/* 下一步按钮 - 答对后高亮脉冲 */
.btn-next-glow {
    animation: nextGlow 1.5s ease infinite;
}

@keyframes nextGlow {
    0%, 100% { box-shadow: 0 0 10px rgba(0, 245, 255, 0.3); }
    50% { box-shadow: 0 0 25px rgba(0, 245, 255, 0.7); }
}

/* ========================================
   成功粒子画布
   ======================================== */
#successCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 199;
}

/* ========================================
   提示弹窗
   ======================================== */
.hint-popup {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    background: var(--space-mid);
    border: 1px solid var(--warning-yellow);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    font-size: 13px;
    color: var(--text-primary);
    max-width: 280px;
    z-index: 50;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    animation: hintFadeIn 0.3s ease;
}

@keyframes hintFadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========================================
   模态框
   ======================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(5px);
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: var(--space-mid);
    border-radius: var(--radius-xl);
    padding: 40px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    border: 1px solid rgba(0, 245, 255, 0.3);
    box-shadow: 0 0 50px rgba(0, 245, 255, 0.2);
}

.modal-icon {
    font-size: 80px;
    margin-bottom: 20px;
}

.modal-icon.success {
    animation: successPulse 0.5s ease;
}

.modal-icon.error {
    animation: errorShake 0.5s ease;
}

@keyframes successPulse {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-10px); }
    40%, 80% { transform: translateX(10px); }
}

.modal-title {
    font-family: var(--font-title);
    font-size: 28px;
    margin-bottom: 15px;
}

.modal-title.success {
    color: var(--neon-green);
}

.modal-title.error {
    color: var(--error-red);
}

.modal-message {
    font-size: 16px;
    color: var(--text-muted);
    margin-bottom: 25px;
    line-height: 1.6;
}

.modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

/* ========================================
   成就界面
   ======================================== */
.screen-achievements {
    display: none;
}

.screen-achievements.active {
    display: block;
}

.achievements-header {
    text-align: center;
    margin-bottom: 40px;
}

.achievements-header h2 {
    font-family: var(--font-title);
    font-size: 36px;
    color: var(--warning-yellow);
}

.achievements-summary {
    margin: 8px 0 0;
    color: rgba(226, 232, 240, .72);
    font-size: 14px;
}

.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.achievement-card {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 340px;
    padding: 18px 20px 20px;
    text-align: center;
    border: 1px solid rgba(179, 195, 214, .16);
    border-radius: 16px 16px 16px 5px;
    background: linear-gradient(150deg, rgba(27, 39, 57, .98), rgba(14, 22, 35, .98));
    box-shadow: inset 0 1px rgba(255,255,255,.035), 0 10px 24px rgba(0,0,0,.16);
    transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.achievement-card:hover {
    transform: translateY(-3px);
    border-color: rgba(229, 193, 111, .46);
    box-shadow: 0 15px 30px rgba(0,0,0,.26), 0 0 20px rgba(229,193,111,.08);
}

.achievement-card.unlocked {
    border-color: rgba(229, 193, 111, .42);
    background: radial-gradient(circle at 50% 25%, rgba(181, 138, 61, .11), transparent 44%), linear-gradient(150deg, rgba(34, 42, 55, .98), rgba(15, 23, 36, .98));
}

.achievement-card.locked {
    border-color: rgba(179, 195, 214, .12);
}

.achievement-card-top {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.achievement-category,
.achievement-state {
    padding: 4px 8px;
    border: 1px solid rgba(198, 210, 224, .13);
    border-radius: 999px;
    color: rgba(214, 222, 233, .72);
    background: rgba(211, 222, 237, .055);
    font-size: 10px;
    line-height: 1.2;
}

.achievement-card.unlocked .achievement-state {
    color: #ead19a;
    border-color: rgba(229, 193, 111, .28);
    background: rgba(229, 193, 111, .09);
}

.achievement-medal-img {
    display: block;
    width: 112px;
    height: 112px;
    margin: 9px auto 3px;
    object-fit: contain;
    filter: drop-shadow(0 7px 11px rgba(0,0,0,.3));
    transition: transform .25s ease, filter .25s ease;
}

.achievement-medal-sprite {
    background-repeat: no-repeat;
    background-size: 300% 300%;
}

.achievement-card:hover .achievement-medal-img {
    transform: translateY(-2px) scale(1.045);
}

.achievement-card.locked .achievement-medal-img {
    filter: grayscale(.85) saturate(.4) brightness(.65) drop-shadow(0 5px 8px rgba(0,0,0,.24));
}

.achievement-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.achievement-desc {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
    min-height: 40px;
}

.achievement-progress-label {
    display: flex;
    width: 100%;
    justify-content: space-between;
    gap: 10px;
    margin-top: auto;
    color: rgba(214, 222, 233, .63);
    font-size: 11px;
}

.achievement-progress-label strong {
    color: #e8d29d;
    font-variant-numeric: tabular-nums;
}

.achievement-progress-track {
    width: 100%;
    height: 5px;
    margin-top: 7px;
    overflow: hidden;
    border-radius: 99px;
    background: rgba(224, 231, 241, .1);
}

.achievement-progress-track > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #8ecbd0, #e8c576);
    transition: width .3s ease;
}

/* ========================================
   交互式选择题（学习步骤中的互动问答）
   ======================================== */
.interactive-quiz {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 16px 0;
}

.quiz-option {
    display: block;
    width: 100%;
    text-align: left;
    padding: 14px 18px;
    font-size: 15px;
    color: var(--text-primary);
    background: rgba(0, 245, 255, 0.06);
    border: 1px solid rgba(0, 245, 255, 0.2);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    line-height: 1.5;
}

.quiz-option:hover:not(.answered) {
    background: rgba(0, 245, 255, 0.12);
    border-color: var(--neon-cyan);
    transform: translateX(4px);
}

.quiz-option.answered {
    pointer-events: none;
    cursor: default;
}

.quiz-option.correct {
    border-color: var(--neon-green);
    background: rgba(0, 255, 136, 0.12);
    animation: correctPulse 0.5s ease;
}

.quiz-option.wrong {
    border-color: var(--error-red);
    background: rgba(255, 71, 87, 0.12);
    animation: wrongShake 0.4s ease;
}

@keyframes correctPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); box-shadow: 0 0 20px rgba(0,255,136,0.3); }
    100% { transform: scale(1); box-shadow: none; }
}

@keyframes wrongShake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
}

.quiz-feedback {
    display: none;
    padding: 14px 18px;
    margin-top: 4px;
    border-radius: var(--radius-md);
    font-size: 14px;
    line-height: 1.6;
    animation: feedbackSlideIn 0.3s ease;
}

.quiz-feedback.visible {
    display: block;
}

.quiz-feedback.correct {
    background: rgba(0, 255, 136, 0.08);
    border-left: 3px solid var(--neon-green);
    color: var(--neon-green);
}

.quiz-feedback.wrong {
    background: rgba(255, 71, 87, 0.08);
    border-left: 3px solid var(--error-red);
    color: #ff9999;
}

@keyframes feedbackSlideIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========================================
   闯关前小测验（Mini Quiz）- 全屏选择题
   ======================================== */
#miniQuizContainer {
    width: 100%;
    margin-top: 16px;
}

.mini-quiz-card {
    background: rgba(0, 245, 255, 0.04);
    border: 1px solid rgba(0, 245, 255, 0.15);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.mini-quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(0, 245, 255, 0.1);
}

.mini-quiz-counter {
    font-size: 13px;
    color: var(--neon-cyan);
    font-weight: 600;
}

.mini-quiz-score {
    font-size: 13px;
    color: var(--warning-yellow);
    font-weight: 600;
}

.mini-quiz-question {
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.quiz-code-example {
    background: #0d1117;
    color: var(--neon-green);
    padding: 8px 12px;
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 13px;
    text-align: left;
    margin-top: 8px;
    white-space: pre-wrap;
}

.mini-quiz-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.mq-option {
    display: block;
    width: 100%;
    text-align: left;
    padding: 12px 18px;
    font-size: 14px;
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(0, 245, 255, 0.15);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    line-height: 1.5;
}

.mq-option:hover:not(.disabled) {
    background: rgba(0, 245, 255, 0.08);
    border-color: var(--neon-cyan);
    transform: translateX(4px);
}

.mq-option.disabled {
    pointer-events: none;
    cursor: default;
    opacity: 0.9;
}

.mq-option.correct {
    border-color: var(--neon-green);
    background: rgba(0, 255, 136, 0.1);
    animation: correctPulse 0.5s ease;
}

.mq-option.wrong {
    border-color: var(--error-red);
    background: rgba(255, 71, 87, 0.08);
    animation: wrongShake 0.4s ease;
}

.mini-quiz-explanation {
    min-height: 30px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 13px;
    line-height: 1.6;
    margin-bottom: 12px;
    animation: feedbackSlideIn 0.3s ease;
}

.mq-feedback.correct {
    color: var(--neon-green);
    background: rgba(0, 255, 136, 0.06);
    border-left: 3px solid var(--neon-green);
}

.mq-feedback.wrong {
    color: #ff9999;
    background: rgba(255, 71, 87, 0.06);
    border-left: 3px solid var(--error-red);
}

.mq-next-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 24px;
    background: linear-gradient(135deg, var(--neon-cyan), var(--neon-blue));
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: 0 4px 15px rgba(0, 245, 255, 0.2);
    width: 100%;
}

.mq-next-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(0, 245, 255, 0.35);
}

/* 小测验结果页 */
.mini-quiz-result {
    text-align: center;
    padding: 40px 24px;
    border-radius: var(--radius-xl);
}

.mini-quiz-result.passed {
    background: linear-gradient(135deg, rgba(0, 255, 136, 0.06), rgba(0, 200, 100, 0.03));
    border: 2px solid rgba(0, 255, 136, 0.3);
}

.mini-quiz-result.failed {
    background: linear-gradient(135deg, rgba(255, 71, 87, 0.06), rgba(200, 50, 70, 0.03));
    border: 2px solid rgba(255, 71, 87, 0.3);
}

.result-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.result-score {
    font-size: 22px;
    color: var(--text-primary);
    margin: 8px 0 12px;
}

.result-msg {
    font-size: 15px;
    color: var(--text-muted);
}

/* ========================================
   调试面板（开发者工具）
   ======================================== */
.debug-panel {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: var(--font-primary);
}

.debug-toggle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.15);
    background: rgba(20, 25, 40, 0.9);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.debug-toggle:hover {
    background: rgba(30, 40, 60, 0.95);
    border-color: rgba(0, 245, 255, 0.5);
    transform: rotate(45deg);
    box-shadow: 0 4px 20px rgba(0, 245, 255, 0.3);
}

.debug-body {
    position: absolute;
    bottom: 54px;
    right: 0;
    width: 260px;
    background: rgba(16, 20, 32, 0.97);
    border: 1px solid rgba(0, 245, 255, 0.25);
    border-radius: 14px;
    padding: 18px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 20px rgba(0, 245, 255, 0.08);
    backdrop-filter: blur(12px);
    display: none;
    animation: debugSlideUp 0.25s ease;
}

.debug-body.open {
    display: block;
}

@keyframes debugSlideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.debug-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--neon-cyan);
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.debug-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 13px;
    color: var(--text-muted);
}

.debug-item label:first-child {
    flex: 1;
}

/* 开关组件 */
.switch {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 22px;
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255, 255, 255, 0.1);
    transition: 0.3s;
    border-radius: 11px;
}

.slider:before {
    content: "";
    position: absolute;
    height: 17px;
    width: 17px;
    left: 3px;
    bottom: 2.5px;
    background: #fff;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .slider { background: var(--neon-cyan); }
input:checked + .slider:before { transform: translateX(20px); }

.dbg-btn {
    padding: 4px 14px;
    font-size: 12px;
    color: #fff;
    background: rgba(255, 71, 87, 0.2);
    border: 1px solid rgba(255, 71, 87, 0.4);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.dbg-btn:hover {
    background: rgba(255, 71, 87, 0.35);
    border-color: rgba(255, 71, 87, 0.7);
}

.debug-info {
    margin-top: 10px;
    padding: 8px 10px;
    background: rgba(0, 245, 255, 0.05);
    border-radius: 8px;
    font-size: 11px;
    color: var(--text-dim);
    line-height: 1.5;
    font-family: var(--font-mono);
}

/* 开发模式总开关 - 高亮样式 */
.dbg-primary {
    background: linear-gradient(135deg, rgba(0, 245, 255, 0.08), rgba(138, 43, 226, 0.08));
    border-radius: 10px;
    padding: 12px 14px !important;
    margin-bottom: 4px !important;
}

.dbg-primary label:first-child {
    font-weight: 600 !important;
    color: var(--neon-cyan) !important;
    letter-spacing: 1px;
}

.switch-primary input:checked + .slider {
    background: linear-gradient(90deg, #00f5ff, #a855f7);
    box-shadow: 0 0 12px rgba(0, 245, 255, 0.5);
}

/* 分隔线 */
.debug-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    margin: 8px 0;
}

/* 子选项区（开发模式关闭时置灰） */
#debugSubOptions {
    transition: opacity 0.3s ease;
}

#debugSubOptions.disabled {
    opacity: 0.35;
    pointer-events: none;
}

/* 按钮组 */
.debug-btn-group {
    display: flex;
    gap: 6px;
    width: 100%;
}

.debug-btn-group .dbg-btn {
    flex: 1;
    text-align: center;
    padding: 5px 8px;
}

.dbg-btn.dbg-export {
    background: rgba(0, 200, 100, 0.15) !important;
    border-color: rgba(0, 200, 100, 0.35) !important;
}

.dbg-btn.dbg-export:hover {
    background: rgba(0, 200, 100, 0.3) !important;
    border-color: rgba(0, 200, 100, 0.6) !important;
}

/* ========================================
   响应式设计
   ======================================== */
@media (max-width: 1024px) {
    /* 保持左右分栏，但调整比例 */
    .lesson-body {
        grid-template-columns: 40% 60%;
    }

    .lesson-teaching {
        padding: 12px 16px;
    }

    .lesson-editor .editor-container {
        min-height: 150px;
    }

    .main-title {
        font-size: 48px;
    }

    .theme-card {
        width: calc(33.333% - 14px);
        min-width: 240px;
    }
}

@media (max-width: 768px) {
    .main-title {
        font-size: 36px;
        letter-spacing: 4px;
    }
    
    .subtitle {
        font-size: 14px;
        letter-spacing: 3px;
    }
    
    .levels-grid {
        grid-template-columns: 1fr;
    }
    
    .top-nav {
        flex-direction: column;
        gap: 15px;
        padding: 10px 0;
    }
    
    .screen-start {
        padding: 100px 16px 40px;
    }
    
    .bottom-nav {
        flex-wrap: wrap;
    }

    .lesson-body {
        grid-template-columns: 1fr;
    }

    .theme-card {
        width: calc(50% - 10px);
        min-width: 220px;
    }
}

@media (max-width: 480px) {
    .theme-card {
        width: 100%;
        min-width: auto;
    }
}

/* ========================================
   TTS 语音播报控制栏
   ======================================== */
.tts-control-bar {
    background: linear-gradient(135deg, rgba(0, 245, 255, 0.12), rgba(138, 43, 226, 0.08));
    border: 1px solid rgba(0, 245, 255, 0.35);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    overflow: hidden;
    animation: ttsSlideIn 0.3s ease;
    position: relative;
    z-index: 1000;
    min-height: 50px;
}

@keyframes ttsSlideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.tts-main {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    background: rgba(0, 0, 0, 0.35);
}

.tts-icon-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 245, 255, 0.15);
    border: 1px solid rgba(0, 245, 255, 0.4);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 18px;
    line-height: 1;
    padding: 0;
    color: var(--neon-cyan);
    min-width: 36px;
}

.tts-icon-btn:hover:not(:disabled) {
    background: rgba(0, 245, 255, 0.35);
    border-color: var(--neon-cyan);
    transform: scale(1.08);
    box-shadow: 0 0 15px rgba(0, 245, 255, 0.3);
}

.tts-icon-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.tts-icon-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.tts-icon-btn.tts-play-btn {
    background: linear-gradient(135deg, var(--neon-cyan), #00a8cc);
    color: var(--space-dark);
    font-weight: bold;
    border-color: var(--neon-cyan);
    box-shadow: 0 0 12px rgba(0, 245, 255, 0.4);
}

.tts-icon-btn.tts-play-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #00ffff, #00b8dd);
    box-shadow: 0 0 20px rgba(0, 245, 255, 0.6);
}

.tts-status-mini {
    font-size: 12px;
    color: var(--text-muted);
    padding: 2px 8px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.tts-status-mini.tts-status-playing {
    color: var(--neon-green);
    background: rgba(0, 255, 136, 0.12);
}

.tts-status-mini.tts-status-paused {
    color: var(--warning-yellow);
    background: rgba(255, 215, 0, 0.12);
}

.tts-status-mini.tts-status-ended {
    color: var(--neon-cyan);
}

.tts-status-mini.tts-status-error {
    color: var(--error-red);
    background: rgba(255, 71, 87, 0.12);
}

.tts-spacer {
    flex: 1;
}

.tts-settings {
    padding: 12px;
    border-top: 1px solid rgba(0, 245, 255, 0.15);
}

.tts-setting-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.tts-setting-item:last-child {
    margin-bottom: 0;
}

.tts-setting-label {
    font-size: 12px;
    color: var(--text-muted);
    min-width: 60px;
}

.tts-select-mini {
    flex: 1;
    padding: 6px 10px;
    font-size: 12px;
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(0, 245, 255, 0.2);
    border-radius: 6px;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
}

.tts-select-mini:hover {
    border-color: var(--neon-cyan);
}

.tts-select-mini:focus {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 8px rgba(0, 245, 255, 0.2);
}

.tts-range-mini {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(0, 245, 255, 0.2);
    border-radius: 2px;
    outline: none;
}

.tts-range-mini::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: var(--neon-cyan);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tts-range-mini::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 8px rgba(0, 245, 255, 0.5);
}

.tts-range-mini::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: var(--neon-cyan);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.tts-rate-mini {
    font-size: 12px;
    color: var(--neon-cyan);
    font-weight: 600;
    min-width: 40px;
    text-align: right;
}

/* ========================================
   ���껭��Ԥ������
   ======================================== */
.turtle-canvas-container {
    margin-top: 12px;
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #0d1117;
}

.turtle-canvas-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.15), rgba(34, 197, 94, 0.05));
    border-bottom: 1px solid rgba(34, 197, 94, 0.2);
    font-size: 13px;
    color: #86efac;
}

.turtle-canvas-container canvas {
    display: block;
    width: 100%;
    height: auto;
    background: #0d1117;
}

/* Course catalog mission cards */
.ai-mission-banner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 190px;
    align-items: center;
    gap: 20px;
    position: relative;
    min-height: 190px;
    margin: 0 0 24px;
    padding: 24px 34px;
    overflow: hidden;
    border: 1px solid rgba(199, 174, 238, .3);
    border-radius: 18px 18px 18px 5px;
    background:
        radial-gradient(circle at 88% 45%, rgba(139, 111, 201, .2), transparent 28%),
        linear-gradient(115deg, rgba(27, 39, 58, .97), rgba(17, 22, 40, .96));
    box-shadow: 0 12px 30px rgba(0,0,0,.22), inset 0 1px rgba(255,255,255,.04);
}

.ai-mission-banner[hidden] { display: none !important; }

.ai-mission-banner::before {
    content: '';
    position: absolute;
    inset: 10px;
    border: 1px dashed rgba(220, 202, 247, .15);
    border-radius: 11px 11px 11px 3px;
    pointer-events: none;
}

.ai-mission-copy { position: relative; z-index: 1; }

.mission-overline {
    color: #c2a4f0;
    font: 700 10px/1.5 var(--font-mono);
    letter-spacing: 2.3px;
}

.mission-overline span { color: #e6bf73; }

.ai-mission-copy h2 {
    margin: 7px 0 5px;
    color: #f0e6ce;
    font-size: clamp(22px, 3vw, 30px);
}

.ai-mission-copy > p:not(.mission-overline) {
    max-width: 680px;
    color: #b7c2d1;
    font-size: 14px;
    line-height: 1.8;
}

.mission-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
    margin-top: 14px;
    color: #c3cddd;
    font-size: 12px;
}

.mission-facts strong { color: #d0b0ff; font-family: var(--font-mono); }

.ai-mission-banner > img {
    position: relative;
    z-index: 1;
    width: min(100%, 168px);
    justify-self: center;
    filter: drop-shadow(0 8px 18px rgba(168, 130, 255, .24));
}

.mission-orbit {
    position: absolute;
    right: 14px;
    top: 50%;
    width: 220px;
    aspect-ratio: 1;
    border: 1px dashed rgba(203, 178, 246, .2);
    border-radius: 50%;
    transform: translate(12%, -50%) rotate(-22deg) scaleY(.45);
    pointer-events: none;
}

.mission-orbit--two {
    transform: translate(12%, -50%) rotate(35deg) scaleY(.55);
    border-color: rgba(111, 201, 221, .17);
}

#screenLevels[data-theme="ai"] .levels-header .section-title,
#screenLevels[data-theme="ai"] .level-stats .stat-value { color: #c8adff; }

.level-card.theme-ai-card {
    position: relative;
    padding-top: 18px;
    border-color: rgba(182, 157, 224, .24);
    border-radius: 14px 14px 14px 4px;
    background:
        radial-gradient(circle at 88% 22%, rgba(151, 117, 203, .1), transparent 30%),
        linear-gradient(145deg, #1b2434, #141b29);
}

.level-card.theme-ai-card::after {
    content: '';
    position: absolute;
    inset: 7px;
    border: 1px dashed rgba(213, 194, 239, .1);
    border-radius: 9px 9px 9px 3px;
    pointer-events: none;
}

.level-card.theme-ai-card .level-card-header {
    position: relative;
    z-index: 1;
    align-items: center;
    padding: 0 0 12px;
    background: none;
    border-bottom: 1px solid rgba(213, 194, 239, .13);
}

.level-card.theme-ai-card .level-badge {
    color: #d5bbff;
    font: 600 11px/1.4 var(--font-mono);
    letter-spacing: 1px;
}

.lesson-icon-frame {
    display: grid;
    place-items: center;
    position: relative;
    z-index: 1;
    width: 66px;
    height: 70px;
    margin: 12px 0 10px;
    border: 1px solid color-mix(in srgb, var(--lesson-accent, #83c9dc) 34%, transparent);
    border-radius: 10px 10px 10px 3px;
    background: linear-gradient(145deg, color-mix(in srgb, var(--lesson-accent, #83c9dc) 13%, #1b2433), rgba(14, 22, 35, .9));
    color: var(--lesson-accent, #83c9dc);
    box-shadow: inset 0 1px rgba(255,255,255,.04);
}

.lesson-icon-frame.has-art {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    margin: 12px 0 14px;
    overflow: hidden;
    border-radius: 12px;
    background: #101a2b;
    box-shadow: 0 8px 22px rgba(0, 0, 0, .2), inset 0 1px rgba(255,255,255,.06);
}

.lesson-icon-frame.has-art img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.lesson-card-icon {
    display: block;
    width: 44px;
    height: 44px;
    overflow: visible;
}

.lesson-icon-index {
    position: absolute;
    right: -7px;
    bottom: -6px;
    padding: 3px 5px;
    border: 1px solid rgba(220, 200, 157, .25);
    border-radius: 4px 4px 4px 1px;
    background: #172131;
    color: #d9c797;
    font: 600 8px/1 var(--font-mono);
    letter-spacing: .2px;
}

#screenLevels[data-theme="space"] { --lesson-accent: #70d3e5; }
#screenLevels[data-theme="ai"] { --lesson-accent: #c0a1f4; }
#screenLevels[data-theme="turtle"] { --lesson-accent: #a3ce93; }
#screenLevels[data-theme="game"] { --lesson-accent: #e6c174; }
#screenLevels[data-theme="data"] { --lesson-accent: #87bde4; }
#screenLevels[data-theme="algorithm-beginner"] { --lesson-accent: #b3a3ef; }
#screenLevels[data-theme="algorithm-advanced"] { --lesson-accent: #e694b3; }

.level-card.theme-ai-card .level-card-title {
    position: relative;
    z-index: 1;
    margin-bottom: 8px;
    color: #f0e9dc;
    font-size: 17px;
}

.level-card.theme-ai-card .level-card-desc {
    position: relative;
    z-index: 1;
    color: #aeb8c7;
    line-height: 1.7;
}

.level-card.theme-ai-card .level-card-tags { position: relative; z-index: 1; gap: 6px; }
.level-card.theme-ai-card .tag { color: #d0b8f4; background: rgba(168, 130, 219, .1); }
.level-card.theme-ai-card.locked { opacity: .65; }
.level-card.theme-ai-card.completed::before { background: linear-gradient(90deg, #7bc7bf, #d1c08e); }

/* Mission log lesson styling */
#screenChallenge[data-theme="ai"] .lesson-header {
    background: linear-gradient(100deg, #1a2434, #211e35 75%, #1a2434);
    border-bottom-color: rgba(193, 167, 231, .22);
}

#screenChallenge[data-theme="ai"] .lesson-header .progress-bar {
    background: rgba(221, 206, 179, .12);
}

#screenChallenge[data-theme="ai"] .lesson-header .progress-fill {
    background: linear-gradient(90deg, #8e78c4, #d5b968);
    box-shadow: 0 0 12px rgba(172, 144, 225, .35);
}

#screenChallenge[data-theme="ai"] .lesson-teaching {
    gap: 16px;
    padding: clamp(18px, 3vw, 34px);
    border-right-color: rgba(195, 176, 219, .16);
    background:
        radial-gradient(circle at 94% 4%, rgba(172, 141, 218, .08), transparent 25%),
        radial-gradient(rgba(224, 205, 165, .12) .7px, transparent .8px) 0 0 / 34px 34px,
        #111a28;
}

#screenChallenge[data-theme="ai"] .lesson-kicker {
    width: max-content;
    padding: 5px 9px;
    border: 1px solid rgba(210, 185, 232, .22);
    border-radius: 5px 5px 5px 2px;
    color: #d2b7f4;
    background: rgba(190, 165, 223, .08);
    font: 700 10px/1.4 var(--font-mono);
    letter-spacing: 1.3px;
}

#screenChallenge[data-theme="ai"] .lesson-kicker span { color: #e5c875; }

#screenChallenge[data-theme="ai"] .step-title {
    color: #f0e6ce;
    font-size: clamp(22px, 2.4vw, 30px);
    line-height: 1.4;
}

#screenChallenge[data-theme="ai"] .learn-content {
    color: #d5dce2;
    font-size: 15px;
    line-height: 1.9;
}

#screenChallenge[data-theme="ai"] .learn-content h3,
#screenChallenge[data-theme="ai"] .learn-content h4 { color: #d6c0ef; }

#screenChallenge[data-theme="ai"] .learn-content code {
    color: #bde0dc;
    background: rgba(115, 182, 174, .13);
}

#screenChallenge[data-theme="ai"] .learn-content th {
    color: #e4cc91;
    background: rgba(208, 176, 105, .1);
}

#screenChallenge[data-theme="ai"] .learn-content th,
#screenChallenge[data-theme="ai"] .learn-content td { border-color: rgba(214, 196, 161, .2); }

#screenChallenge[data-theme="ai"] .learn-content .tip-box,
#screenChallenge[data-theme="ai"] .learn-content .memory-box {
    color: #e0d8c4;
    background: rgba(202, 174, 116, .08);
    border-left-color: #ceb873;
}

#screenChallenge[data-theme="ai"] .example-box {
    border-color: rgba(210, 185, 232, .22);
    background: rgba(236, 226, 203, .035);
}

#screenChallenge[data-theme="ai"] .example-header,
#screenChallenge[data-theme="ai"] .task-header {
    color: #e3ce9c;
    background: rgba(208, 184, 124, .08);
    border-bottom-color: rgba(208, 184, 124, .16);
}

#screenChallenge[data-theme="ai"] .task-box {
    border-color: rgba(177, 151, 222, .28);
    background: rgba(126, 97, 174, .08);
}

#screenChallenge[data-theme="ai"] .lesson-editor {
    border-left: 1px solid rgba(210, 185, 232, .15);
    background: #101826;
}

#screenChallenge[data-theme="ai"] .lesson-editor .editor-header,
#screenChallenge[data-theme="ai"] .lesson-editor .editor-footer {
    border-color: rgba(210, 185, 232, .16);
}

#screenChallenge[data-theme="ai"] .lesson-editor .editor-title { color: #d0b3f1; }
#screenChallenge[data-theme="ai"] .lesson-footer {
    background: #1b2433;
    border-top-color: rgba(210, 185, 232, .18);
}

#screenChallenge[data-theme="ai"] #btnNextStep {
    color: #1b1b26;
    background: linear-gradient(135deg, #d9c68b, #bda5dd);
    box-shadow: 0 4px 15px rgba(187, 160, 218, .16);
}

@media (max-width: 760px) {
    .ai-mission-banner { grid-template-columns: minmax(0, 1fr) 106px; gap: 6px; padding: 20px 18px; }
    .ai-mission-banner > img { width: 104px; }
    .mission-facts { gap: 6px 12px; }
    #screenChallenge[data-theme="ai"] .lesson-header { flex-wrap: wrap; gap: 8px 12px; padding: 9px 12px; }
    #screenChallenge[data-theme="ai"] .lesson-header .step-progress { min-width: 50%; }
    #screenChallenge[data-theme="ai"] .lesson-header .step-dots { display: none; }
}

@media (max-width: 480px) {
    .ai-mission-banner { grid-template-columns: minmax(0, 1fr); }
    .ai-mission-banner > img { position: absolute; width: 88px; right: 14px; top: 12px; opacity: .32; }
    .ai-mission-copy { padding-right: 16px; }
    .mission-facts { position: relative; z-index: 2; }
}

@media (max-width: 600px) {
    .screen-start { padding-top: 196px; }

    .screen-levels .levels-header {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 10px;
        margin-bottom: 18px;
    }

    .screen-levels .levels-header .section-title {
        grid-column: 1 / -1;
        grid-row: 2;
        text-align: left;
        font-size: clamp(20px, 6vw, 26px);
        line-height: 1.35;
    }

    .screen-levels .levels-header .level-stats { grid-column: 2; grid-row: 1; }
    .screen-levels .levels-header .stat { padding: 7px 10px; font-size: 12px; }
    #screenChallenge[data-theme="ai"] .lesson-header .step-progress { flex: 1; min-width: 58%; }
    #screenChallenge[data-theme="ai"] .lesson-header .step-progress .progress-text { white-space: nowrap; font-size: 11px; }
}

#screenLevels[data-theme="ai"] .ship-blueprint { display: none; }

.intro-learning-plan {
    display: grid;
    gap: 9px;
    margin: 18px 0 22px;
    padding: 14px 16px;
    border: 1px solid rgba(228, 201, 129, .24);
    border-radius: 14px;
    background: rgba(14, 25, 39, .58);
    text-align: left;
}

.intro-learning-plan > div { display: grid; grid-template-columns: 82px minmax(0, 1fr); gap: 12px; }
.intro-learning-plan span { color: #c2b697; font-size: 13px; }
.intro-learning-plan strong { color: #f3e7ca; font-size: 14px; line-height: 1.55; font-weight: 600; }
.level-card-lock-note { margin: 8px 0 0; color: #e6c174; font-size: 12px; line-height: 1.45; }
.level-card-mastery { margin: 8px 0 0; color: #9fd9c3; font-size: 12px; }

.theme-learning-progress { margin: 14px 0 16px; text-align: left; }
.theme-course-info { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; margin-bottom: 11px; color: rgba(239, 232, 215, .64); font-size: 11px; }
.theme-learning-progress-label { display: flex; justify-content: space-between; gap: 12px; color: rgba(239, 232, 215, .74); font-size: 12px; }
.theme-learning-progress-label strong { color: #f3e7ca; font-variant-numeric: tabular-nums; }
.theme-learning-progress-track { height: 5px; margin: 7px 0 6px; overflow: hidden; border-radius: 99px; background: rgba(239, 232, 215, .14); }
.theme-learning-progress-track > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #88bdc6, #e6c174); transition: width .3s ease; }
.theme-learning-progress small { color: rgba(239, 232, 215, .58); font-size: 11px; line-height: 1.4; }
.legacy-progress-notice { max-width: 760px; margin: 8px auto 0; color: #e6c174; font-size: 12px; line-height: 1.55; }

@media (max-width: 600px) {
    .intro-learning-plan { padding: 12px; }
    .intro-learning-plan > div { grid-template-columns: 70px minmax(0, 1fr); gap: 8px; }
    .intro-learning-plan strong { font-size: 13px; }
    .theme-learning-progress { margin: 10px 0 12px; }
}
