/* style.css - 最终完整版 (纯滑动控制 + 超大视野) */

:root {
    --duo-green: #ffc800;       
    --duo-green-dark: #e5b300;  
    --duo-blue: #1cb0f6;
    --duo-blue-dark: #1899d6;
    --duo-yellow: #ff9600;      
    --duo-red: #ff4b4b;
    --duo-orange: #ff9600;
    --duo-gray: #e5e5e5;
    
    --text: #4b4b4b;
    --text-sub: #777;
    --bg: #ffffff;
    --bg-card: #ffffff;
    --border: #e5e5e5;
    --nav-hover: #fff5cc;
    
    --font-stack: 'Din Round', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

body {
    font-family: var(--font-stack);
    background: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100vh;
    overflow: hidden; 
    position: relative;
    display: flex;
    flex-direction: row;
    user-select: none;
    transition: background .3s, color .3s;
}

.icon-svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
    display: block;
}

/* --- 侧边栏 --- */
aside {
    width: 250px;
    background: var(--bg-card);
    border-right: 2px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px;
    z-index: 100;
    flex-shrink: 0;
    transition: background .3s, border-color .3s;
}

.brand-logo {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--duo-green); 
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    margin-bottom: 8px;
    border-radius: 12px;
    font-weight: 700;
    color: var(--text-sub);
    cursor: pointer;
    transition: .1s;
    border: 2px solid transparent;
    text-transform: uppercase;
    font-size: 1rem;
}

#nav-btn-logout {
    margin-top: auto; 
    color: var(--duo-red);
    border: 2px solid var(--border);
}

.nav-item:active {
    transform: scale(.98);
}

.nav-item.active {
    background: var(--nav-hover);
    color: var(--duo-green);      
    border-color: transparent;
    box-shadow: inset 0 0 0 2px var(--duo-green-dark);
}

.nav-item.active .nav-icon-box {
    color: var(--duo-green);
}

.nav-icon-box {
    margin-right: 15px;
    width: 24px;
    height: 24px;
}

/* 主页按钮特殊样式 - 像Home键一样突出 */
.nav-home-special {
    position: relative;
    background: linear-gradient(135deg, #fff 0%, #f0f0f0 100%);
    color: var(--duo-blue);
    border: 3px solid var(--duo-blue);
    box-shadow: 0 4px 15px rgba(28, 176, 246, 0.3);
    font-weight: 800;
    margin: 8px 0;
    padding: 16px 15px;
}

.nav-home-special:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(28, 176, 246, 0.4);
}

.nav-home-special.active {
    background: linear-gradient(135deg, var(--duo-blue) 0%, #0d8bc7 100%);
    color: white;
    border-color: white;
    box-shadow: 0 6px 25px rgba(28, 176, 246, 0.5), inset 0 0 20px rgba(255,255,255,0.2);
}

.nav-home-special .nav-icon-box {
    color: inherit;
}

/* 学习模块容器 */
.learn-modules-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    padding: 40px;
    max-width: 1200px;
    margin: 0 auto;
}

.learn-module {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 32px 24px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 3px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.learn-module:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 12px 30px rgba(0,0,0,0.15);
    border-color: var(--duo-blue);
}

.learn-module:active {
    transform: translateY(-4px) scale(1.01);
}

.learn-module-icon {
    width: 80px;
    height: 80px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    margin-bottom: 20px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}

.learn-module-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 8px;
}

.learn-module-desc {
    font-size: 1rem;
    color: var(--text-sub);
    font-weight: 600;
}

/* --- 主内容区 --- */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    max-width: 100%;
    height: 100%;
    overflow: hidden;
}

.content-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    padding-bottom: 120px;
    -webkit-overflow-scrolling: touch;
}

/* 当显示dashboard时，content-scroll背景透明 */
#view-dashboard ~ * {
    display: none;
}

.content-scroll:has(#view-dashboard:not([style*="display: none"])) {
    background: transparent !important;
    padding: 0 !important;
}

/* 主页视图不需要padding */
#view-dashboard {
    padding: 0 !important;
    margin: -20px;
    margin-bottom: -120px;
    background: transparent !important;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
}

header {
    height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: env(safe-area-inset-top) 20px 0 20px;
    background: var(--bg-card);
    border-bottom: 2px solid var(--border);
    backdrop-filter: blur(10px);
    z-index: 90;
    transition: background .3s, border-color .3s;
}

.stats-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    color: var(--duo-yellow);
    font-size: 1.1rem;
}

/* --- 吉祥物区域 --- */
/* 主页全屏 3D 容器 */
.mascot-full-container {
    width: 100%;
    height: 85%; /* 占据大部分高度，留出 header 和底部导航空间 */
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    /* 给主页一个专属的高级感背景光晕，类似游戏大厅 */
    background: radial-gradient(circle at 50% 50%, rgba(255, 200, 0, 0.15) 0%, transparent 70%);
}

#mascot {
    width: 100%;
    height: 100%;
    /* 确保模型不会被莫名其妙截断 */
    --poster-color: transparent;
}

/* 动态气泡（适应全屏模式）*/
.mascot-bubble {
    position: absolute;
    top: 15%;      /* 上移一点 */
    right: 10%;    /* 靠右 */
    background: rgba(255, 255, 255, 0.9);
    padding: 12px 18px;
    border-radius: 18px;
    border-bottom-right-radius: 4px;
    /* 增加玻璃拟态效果，看起来更原生高级 */
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.5);
    box-shadow: 0 8px 20px rgba(0,0,0,0.08);
    font-size: 0.95rem;
    color: #444;
    font-weight: 700;
    max-width: 180px;
    z-index: 10;
    opacity: 0;
    transform: scale(0.5) translateY(10px);
    transform-origin: bottom left;
    pointer-events: auto;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-align: center;
}

.mascot-bubble.show {
    opacity: 1;
    transform: scale(1) translateY(0);
}

/* 课程页面调整 */
#view-course {
    min-height: 100%;
    /* 课程页不需要那个半圆形的背景了，保持清爽 */
    background: transparent;
}

/* 书架/关卡区域层级 */
#bookshelf-area, #level-area {
    position: relative;
    z-index: 10; 
}

/* Widget 小组件容器 - 网格布局 */
.widget-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
    padding: 20px;
    animation: popIn 0.3s;
}

/* Widget 卡片 */
.widget-card {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 16px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    min-height: 180px;
}

.widget-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.widget-card:active {
    transform: scale(0.96);
}

/* Widget 头部 */
.widget-header {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

/* Widget 图标 */
.widget-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Widget 标题 */
.widget-title {
    font-size: 1rem;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.2);
    line-height: 1.3;
    word-break: break-word;
}

/* Widget 主体 */
.widget-body {
    display: flex;
    gap: 16px;
    margin-top: auto;
    margin-bottom: 12px;
}

/* 统计项 */
.widget-stat {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    backdrop-filter: blur(10px);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: #fff;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* 进度条 */
.widget-progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 3px;
    transition: width 0.4s ease;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
}

/* 锁定遮罩 */
.widget-lock-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    cursor: not-allowed;
    border-radius: 20px;
}

.lock-icon-circle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* Widget 配色方案 - 丰富的渐变背景 */
.widget-color-0 { background: linear-gradient(135deg, #1cb0f6 0%, #0d8bc7 100%); } /* 天蓝 */
.widget-color-1 { background: linear-gradient(135deg, #ffc800 0%, #ff9500 100%); } /* 橙黄 */
.widget-color-2 { background: linear-gradient(135deg, #ff4b4b 0%, #d32f2f 100%); } /* 红色 */
.widget-color-3 { background: linear-gradient(135deg, #58cc02 0%, #38a003 100%); } /* 绿色 */
.widget-color-4 { background: linear-gradient(135deg, #ce82ff 0%, #9c4dcc 100%); } /* 紫色 */
.widget-color-5 { background: linear-gradient(135deg, #ff6b9d 0%, #c44569 100%); } /* 粉红 */
.widget-color-6 { background: linear-gradient(135deg, #00d2ff 0%, #0097b2 100%); } /* 青色 */
.widget-color-7 { background: linear-gradient(135deg, #ff9f43 0%, #e67e22 100%); } /* 橙色 */
.widget-color-8 { background: linear-gradient(135deg, #5f27cd 0%, #341f97 100%); } /* 深紫 */
.widget-color-9 { background: linear-gradient(135deg, #00b894 0%, #00837a 100%); } /* 青绿 */

/* 确保 SVG 颜色正确 */
.lock-icon-badge .icon-svg {
    width: 20px;
    height: 20px;
    fill: #fff;
}
/* 关卡详情页面头部 */
.level-detail-header {
    display: flex;
    align-items: center;
    padding: 20px;
    margin-bottom: 10px;
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 100;
    border-bottom: 1px solid var(--border);
}

.btn-back-modern {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    padding: 10px 16px;
    border-radius: 14px;
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.btn-back-modern:hover {
    background: var(--nav-hover);
    transform: translateX(-2px);
}

.btn-back-modern:active {
    transform: scale(0.95);
}

.level-course-title {
    flex: 1;
    text-align: center;
    font-weight: 900;
    color: var(--text);
    font-size: 1.3rem;
    letter-spacing: -0.5px;
}

/* 关卡网格 */
.level-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0 20px 100px 20px;
}

/* 关卡卡片 */
.level-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 20px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.level-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    border-color: var(--duo-green);
}

.level-card:active {
    transform: scale(0.98);
}

.level-card.locked {
    opacity: 0.5;
    filter: grayscale(1);
    cursor: not-allowed;
    pointer-events: none;
}

.level-card.completed {
    background: linear-gradient(135deg, #f0f9ff 0%, #e8f5e9 100%);
}

.level-card.completed .level-card-icon {
    background: linear-gradient(135deg, var(--duo-green) 0%, #38a003 100%);
}

/* 关卡图标 */
.level-card-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--duo-blue) 0%, #0d8bc7 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 4px 8px rgba(28, 176, 246, 0.3);
}

/* 关卡图标配色方案 */
.level-card.level-color-0 .level-card-icon { background: linear-gradient(135deg, #1cb0f6 0%, #0d8bc7 100%); box-shadow: 0 4px 8px rgba(28, 176, 246, 0.3); }
.level-card.level-color-1 .level-card-icon { background: linear-gradient(135deg, #ffc800 0%, #ff9500 100%); box-shadow: 0 4px 8px rgba(255, 200, 0, 0.3); }
.level-card.level-color-2 .level-card-icon { background: linear-gradient(135deg, #ff4b4b 0%, #d32f2f 100%); box-shadow: 0 4px 8px rgba(255, 75, 75, 0.3); }
.level-card.level-color-3 .level-card-icon { background: linear-gradient(135deg, #58cc02 0%, #38a003 100%); box-shadow: 0 4px 8px rgba(88, 204, 2, 0.3); }
.level-card.level-color-4 .level-card-icon { background: linear-gradient(135deg, #ce82ff 0%, #9c4dcc 100%); box-shadow: 0 4px 8px rgba(206, 130, 255, 0.3); }
.level-card.level-color-5 .level-card-icon { background: linear-gradient(135deg, #ff6b9d 0%, #c44569 100%); box-shadow: 0 4px 8px rgba(255, 107, 157, 0.3); }
.level-card.level-color-6 .level-card-icon { background: linear-gradient(135deg, #00d2ff 0%, #0097b2 100%); box-shadow: 0 4px 8px rgba(0, 210, 255, 0.3); }
.level-card.level-color-7 .level-card-icon { background: linear-gradient(135deg, #ff9f43 0%, #e67e22 100%); box-shadow: 0 4px 8px rgba(255, 159, 67, 0.3); }
.level-card.level-color-8 .level-card-icon { background: linear-gradient(135deg, #5f27cd 0%, #341f97 100%); box-shadow: 0 4px 8px rgba(95, 39, 205, 0.3); }
.level-card.level-color-9 .level-card-icon { background: linear-gradient(135deg, #00b894 0%, #00837a 100%); box-shadow: 0 4px 8px rgba(0, 184, 148, 0.3); }

/* 已完成关卡保持绿色 */
.level-card.completed .level-card-icon {
    background: linear-gradient(135deg, var(--duo-green) 0%, #38a003 100%) !important;
    box-shadow: 0 4px 8px rgba(88, 204, 2, 0.3) !important;
}

/* 关卡内容 */
.level-card-content {
    flex: 1;
    min-width: 0;
}

.level-card-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 4px;
}

.level-card-status {
    font-size: 0.85rem;
    color: var(--text-sub);
    font-weight: 600;
}

/* 关卡箭头 */
.level-card-arrow {
    font-size: 1.8rem;
    color: var(--text-sub);
    opacity: 0.4;
    transition: all 0.2s;
}

.level-card:hover .level-card-arrow {
    opacity: 1;
    transform: translateX(4px);
}

/* --- 商城 --- */
#shop-list {
    display: block;
    padding-bottom: 60px;
    width: 100%;
}

.shop-section-title {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    font-size: 1.2rem;
    font-weight: 900;
    color: var(--text);
    margin: 25px 0 15px 0;
    width: 100%;
    line-height: 1;
}

.shop-grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); 
    gap: 15px;
    width: 100%;
    margin-bottom: 10px;
}

.shop-grid-container > div {
    margin: 0;
}

/* --- 游戏界面 --- */
.game-wrapper {
    max-width: 600px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    gap: 15px;
}

.progress-track {
    flex: 1;
    height: 16px;
    background: #e5e5e5;
    border-radius: 8px;
    overflow: hidden;
}

#game-progress-bar {
    width: 0;
    height: 100%;
    background: var(--duo-green);
    transition: width .3s ease;
}

.game-score-badge {
    font-weight: 800;
    color: var(--duo-yellow);
    font-size: 1.2rem;
    min-width: 60px;
    text-align: right;
}

.combo-popup {
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 1.2rem;
    color: var(--duo-orange);
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    margin-bottom: 10px;
    text-shadow: none;
}

.combo-popup.show {
    opacity: 1;
    transform: scale(1.1);
}

.combo-popup.high {
    color: var(--duo-red);
    font-size: 1.6rem;
}

.card-container {
    width: 200px;
    height: 200px;
    margin: 0 auto 20px;
}

.chinese-card {
    width: 100%;
    height: 100%;
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 900;
    text-shadow: 0 2px 4px rgba(0, 0, 0, .2);
    box-shadow: 0 8px 0 rgba(0, 0, 0, .1);
    border: 4px solid rgba(255, 255, 255, .3);
    padding: 20px;
    text-align: center;
    background-image: linear-gradient(135deg, #ffc800, #ff9600);
    font-size: 2rem;
}

.btn-audio-replay {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--duo-blue);
    font-weight: 700;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.2s;
    margin: 0 auto 20px auto;
    width: fit-content;
    border: 2px solid transparent;
}

.btn-audio-replay:hover, .btn-audio-replay:active {
    background: #e1f5fe;
}

.slots-area {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin: 20px 0;
    flex-wrap: wrap;
    min-height: 60px;
    align-items: center;
}

.game-tools-row {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 20px;
}

.btn-tool {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 2px solid rgba(0,0,0,0.1); 
    border-radius: 16px;
    cursor: pointer;
    box-shadow: 0 4px 0 rgba(0,0,0,0.1);
    color: var(--text-sub);
    transition: 0.1s;
    font-size: 1.2rem;
}

.btn-tool:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 rgba(0,0,0,0.1);
    background: var(--nav-hover);
}

.slot-box {
    width: 50px;
    height: 60px;
    border-bottom: 4px solid var(--border);
    font-size: 2rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: .2s;
}

.slot-box.correct {
    color: var(--duo-green);
    border-color: var(--duo-green);
}

.slot-box.wrong {
    color: var(--duo-red);
    border-color: var(--duo-red);
    animation: shake .4s;
}

.keyboard-area {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.key-btn {
    background: var(--bg-card);
    border: 2px solid var(--border);
    padding: 15px;
    font-weight: 800;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 4px 0 rgba(0,0,0,0.1);
    min-width: 45px;
    text-align: center;
    touch-action: manipulation;
    color: var(--text);
}

.key-btn:active {
    transform: translateY(4px);
    box-shadow: none;
    background: #eee;
}

.key-btn.used {
    background: #f0f0f0;
    color: #ccc;
    border-color: #eee;
    box-shadow: none;
    transform: translateY(4px);
    pointer-events: none;
}

.bottom-actions {
    padding: 20px;
    background: transparent;
    display: flex;
    gap: 10px;
    transition: background .3s, border-color .3s;
    border-top: none;
}

.action-btn {
    flex: 1;
    border: 2px solid transparent; 
    padding: 15px;
    border-radius: 16px;
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
    color: white;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2); 
    text-align: center;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1); 
}

.btn-green {
    background: var(--duo-green);
    border-color: var(--duo-green); 
    color: white; 
}

.btn-green:active {
    transform: translateY(2px);
    box-shadow: none;
}

.btn-gray {
    background: var(--duo-gray);
    border-color: var(--duo-gray);
    color: #999;
}

.btn-gray:active {
    transform: translateY(2px);
    box-shadow: none;
}

/* --- 🔥 口语与录音 --- */
.speak-card {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 0 rgba(0,0,0,0.05);
}

.speak-target {
    font-size: 1.3rem;
    color: var(--text);
    font-weight: 500;
    margin: 15px 0 20px 0;
    line-height: 2.2; 
}

.interactive-word {
    cursor: pointer;
    border: 2px solid var(--border);
    border-radius: 10px;
    padding: 4px 10px;
    margin: 4px 2px;
    transition: all .1s;
    display: inline-block;
    color: var(--text);
    font-weight: 700;
    background: var(--bg);
    box-shadow: 0 2px 0 rgba(0,0,0,0.05);
}

.interactive-word:hover,
.interactive-word:active {
    background: var(--nav-hover);
    border-color: var(--duo-blue);
    color: var(--duo-blue);
    transform: translateY(-1px);
    box-shadow: 0 3px 0 rgba(0,0,0,0.1);
}

.control-bar {
    display: flex;
    align-items: center;
    justify-content: space-between; 
    gap: 15px;
    background: #f8f9fa;
    padding: 12px;
    border-radius: 16px;
    margin-bottom: 20px;
    border: 2px solid #eee;
}

.btn-play {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--duo-blue);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 0 rgba(0,0,0,0.1);
    transition: .1s;
    flex-shrink: 0;
}

.btn-play:active {
    transform: translateY(2px);
    box-shadow: none;
}

.speed-box {
    display: flex;
    gap: 5px;
}

.speed-btn {
    padding: 6px 12px;
    border: 2px solid transparent;
    background: #fff;
    color: var(--text-sub);
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 800;
    cursor: pointer;
    transition: .2s;
    border: 2px solid #eee;
}

.speed-btn.active {
    background: var(--duo-blue);
    color: white;
    border-color: var(--duo-blue-dark);
    box-shadow: 0 2px 0 rgba(0,0,0,0.1);
}

.record-area {
    text-align: center;
}

.btn-record-large {
    width: 100%;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-bottom: 4px solid var(--border);
    border-radius: 16px;
    padding: 18px;
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--duo-green);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: .1s;
}

.btn-record-large:active {
    transform: translateY(2px);
    border-bottom-width: 2px;
}

.btn-record-large.recording {
    background: #ffebeb;
    color: var(--duo-red);
    border-color: #ffcccc;
    border-bottom-color: #ffcccc;
    animation: pulse-red 1.5s infinite;
}

/* --- 复习与消消乐 --- */
.review-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 30px 20px;
    height: 100%;
    overflow-y: auto;
    perspective: 1000px;
}

.flashcard {
    width: 300px;
    height: 350px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform .6s cubic-bezier(.175, .885, .32, 1.275);
    cursor: pointer;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.flashcard.flipped {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 24px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, .1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    border: 2px solid var(--border);
    background: var(--bg-card); 
    text-align: center;
}

.card-front {
    background: linear-gradient(145deg, #ffffff, #f0f8ff);
}

.card-back {
    background: linear-gradient(145deg, #fff9c4, #fff);
    transform: rotateY(180deg);
    color: var(--text);
}

.flash-word {
    font-size: 2.2rem;
    font-weight: 900;
    color: var(--duo-blue);
    margin-bottom: 20px;
}

.flash-cn {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1.4;
}

.flash-nav {
    display: flex;
    gap: 20px;
    width: 300px;
    margin-top: 10px;
    flex-shrink: 0;
}

.flash-btn {
    flex: 1;
    padding: 15px;
    border-radius: 50px;
    border: 2px solid var(--border);
    font-weight: 800;
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: 0 4px 0 rgba(0, 0, 0, .1);
    transition: .1s;
    background: var(--bg-card);
    color: var(--text-sub);
}

.flash-btn:active {
    transform: translateY(2px);
    box-shadow: none;
}

.flash-btn-main {
    background: var(--duo-green);
    color: white;
    border-color: var(--duo-green);
    box-shadow: 0 4px 0 var(--duo-green-dark);
}

/* 消消乐容器 */
.match-container {
    padding: 20px;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.review-header {
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 800;
    color: #999;
}

.match-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding-bottom: 40px;
}

.match-card {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 16px;
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 8px;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text);
    cursor: pointer;
    box-shadow: 0 4px 0 rgba(0,0,0,0.1);
    transition: all .1s;
    user-select: none;
    word-break: break-word;
}

.match-card:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 rgba(0,0,0,0.1);
    background: var(--nav-hover);
}

.match-card.selected {
    background: var(--nav-hover);
    border-color: var(--duo-green);
    color: var(--duo-green);
    box-shadow: 0 4px 0 var(--duo-green-dark);
}

.match-card.matched {
    opacity: 0;
    pointer-events: none;
    transform: scale(0);
    transition: .3s;
}

.match-card.wrong {
    background: #ffebeb;
    border-color: var(--duo-red);
    color: var(--duo-red);
    animation: shake .4s;
}

.stage-transition {
    text-align: center;
    padding: 40px 20px;
    animation: popIn .3s;
}

/* --- 原生级 Toast 弹窗 --- */
.toast-container {
    position: fixed;
    top: 60px; 
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    color: #4b4b4b;
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 800;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
    z-index: 9999; 
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(0,0,0,0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
    width: auto;
    min-width: 200px;
}

.toast-container.show {
    opacity: 1;
    transform: translateX(-50%) translateY(20px);
}

.toast-success {
    border-left: 5px solid var(--duo-green);
}

.toast-error {
    border-left: 5px solid var(--duo-red);
}

/* --- 登录弹窗 --- */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, .7);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}

.modal-box {
    background: var(--bg-card);
    padding: 30px;
    border-radius: 20px;
    width: 320px;
    text-align: center;
    border: 2px solid var(--border);
    position: relative;
    animation: popIn .3s;
}

.inp-name {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 1.1rem;
    text-align: center;
    margin: 10px 0;
    outline: none;
}

/* --- 排行榜 --- */
.rank-list-container {
    padding: 15px;
    background: transparent;
    min-height: 100%;
}

.rank-row {
    display: flex;
    align-items: center;
    padding: 15px;
    margin-bottom: 12px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 4px 0 rgba(0,0,0,0.1);
    transition: transform .1s;
    cursor: default;
}

.rank-row:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 var(--border);
}

.rank-badge {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 1.2rem;
    margin-right: 15px;
    border-radius: 50%;
    flex-shrink: 0;
    position: relative;
}

.rank-1 {
    background: linear-gradient(135deg, #ffd700, #ffaa00);
    color: #fff;
    border: 2px solid #e69b00;
    box-shadow: 0 4px 0 #e69b00;
    font-size: 1.5rem;
    text-shadow: 0 2px 0 rgba(0, 0, 0, .1);
}

.rank-1::after {
    content: '👑';
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.2rem;
}

.rank-2 {
    background: linear-gradient(135deg, #e0e0e0, #bdbdbd);
    color: #fff;
    border: 2px solid #9e9e9e;
    box-shadow: 0 4px 0 #9e9e9e;
    font-size: 1.3rem;
}

.rank-3 {
    background: linear-gradient(135deg, #f4a460, #d2691e);
    color: #fff;
    border: 2px solid #a0522d;
    box-shadow: 0 4px 0 #a0522d;
    font-size: 1.3rem;
}

.rank-common {
    color: #bbb;
    font-size: 1.1rem;
    font-weight: 800;
    width: 44px;
    text-align: center;
    margin-right: 15px;
}

.rank-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #eee;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.2rem;
    margin-right: 15px;
    border: 3px solid rgba(255, 255, 255, .5);
    box-shadow: 0 2px 5px rgba(0, 0, 0, .1);
    text-transform: uppercase;
}

.rank-info {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.rank-name {
    font-weight: 800;
    color: var(--text);
    font-size: 1rem;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rank-detail {
    font-size: .75rem;
    color: #999;
    font-weight: 700;
    background: #f0f0f0;
    padding: 2px 8px;
    border-radius: 10px;
    align-self: flex-start;
}

.rank-score {
    font-weight: 900;
    color: var(--duo-blue);
    font-size: 1.1rem;
    min-width: 80px;
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.rank-score span {
    font-size: .7rem;
    color: #ccc;
    font-weight: 700;
}

@keyframes popIn {
    from { transform: scale(.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(255, 75, 75, .4); }
    70% { box-shadow: 0 0 0 10px rgba(255, 75, 75, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 75, 75, 0); }
}

/* ========================================= */
/* AI Chat UI (Doubao Style)           */
/* ========================================= */

.chat-modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: #f7f9fc; /* 类似豆包的淡灰背景 */
    z-index: 5000;
    display: flex;
    flex-direction: column;
}

/* 进场动画 */
.slide-in {
    animation: slideUpEnter 0.3s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

/* 离场动画 */
.slide-out {
    animation: slideDownExit 0.3s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes slideUpEnter {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes slideDownExit {
    from { transform: translateY(0); opacity: 1; }
    to { transform: translateY(100%); opacity: 0; }
}

/* 顶部导航 */
.chat-header {
    height: 56px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    background: #fff;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    box-shadow: 0 2px 10px rgba(0,0,0,0.02);
    justify-content: space-between;
    flex-shrink: 0;
}

/* 吉祥物头像圈 */
.chat-mascot-avatar {
    width: 36px; height: 36px;
    background: var(--duo-green); 
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--duo-green-dark);
    margin-right: 10px;
}

.chat-title {
    flex: 1; 
    font-weight: 800; 
    font-size: 1.1rem; 
    color: var(--text);
}

.icon-btn-plain {
    background: none; border: none; cursor: pointer; padding: 5px;
    border-radius: 50%;
    transition: background 0.2s;
}
.icon-btn-plain:active { background: rgba(0,0,0,0.05); }

/* 聊天内容区 */
.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 15px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    /* 隐藏滚动条但保留功能 */
    -ms-overflow-style: none; scrollbar-width: none;
}
.chat-body::-webkit-scrollbar { display: none; }

/* 底部输入区 */
.chat-footer {
    padding: 10px 16px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
    background: #fff;
    border-top: 1px solid #f0f0f0;
}

.chat-input-box {
    display: flex;
    align-items: center;
    background: #f2f4f7;
    border-radius: 24px;
    padding: 8px 16px;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.chat-input-box:focus-within {
    border-color: var(--duo-blue);
    background: white;
    box-shadow: 0 0 0 4px rgba(28, 176, 246, 0.1);
}

#chat-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 1rem;
    padding: 4px 0;
    color: var(--text);
    margin-right: 10px;
}

.chat-send-btn {
    width: 36px; height: 36px;
    background: var(--duo-blue);
    border-radius: 50%;
    border: none;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: transform 0.1s, background 0.2s;
    box-shadow: 0 2px 6px rgba(28, 176, 246, 0.4);
}
.chat-send-btn:hover { background: var(--duo-blue-dark); }
.chat-send-btn:active { transform: scale(0.9); }

/* 消息行 */
.msg-row {
    display: flex;
    gap: 12px;
    align-items: flex-end; /* 底部对齐 */
}

.msg-ai { align-self: flex-start; }
.msg-user { align-self: flex-end; flex-direction: row-reverse; }

.msg-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
/* AI 头像背景色 */
.msg-ai .msg-avatar { background: var(--duo-green); }
/* 用户头像背景色 */
.msg-user .msg-avatar { background: var(--duo-blue); }

.msg-bubble {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 1rem;
    line-height: 1.6;
    word-wrap: break-word;
    position: relative;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* AI 气泡: 白色 + 左下角尖角 */
.msg-ai .msg-bubble {
    background: white;
    color: #1f1f1f;
    border-bottom-left-radius: 2px;
}

/* 用户气泡: 蓝色 + 右下角尖角 */
.msg-user .msg-bubble {
    background: #0066ff;
    color: white;
    border-bottom-right-radius: 2px;
}

/* Markdown 内容修正 */
.msg-bubble p { margin: 0; }
.msg-bubble strong { color: inherit; font-weight: 800; }

/* 加载动画 (3个点) */
.typing-dot {
    display: inline-block; width: 6px; height: 6px;
    background: #ccc; border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
    margin: 0 2px;
}
.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes typing { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }

/* --- 3D 翻转卡片样式 --- */
.flip-container {
    perspective: 1000px;
    width: 300px;
    height: 400px;
    margin: 20px auto;
    cursor: pointer;
}

.flip-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    border-radius: 20px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

/* 翻转激活状态 */
.flip-container.flipped .flip-inner {
    transform: rotateY(180deg);
}

.flip-front, .flip-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: white;
    border: 2px solid var(--border);
}

/* 正面样式 */
.flip-front {
    background: #ffffff;
}

/* 背面样式 (翻转180度) */
.flip-back {
    transform: rotateY(180deg);
    background: #fffdf5; /* 稍微带点暖色背景 */
}

/* 内容排版 */
.card-word {
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--duo-blue);
    margin-bottom: 10px;
}

.card-pron {
    font-size: 1.2rem;
    color: #999;
    font-family: monospace;
    margin-bottom: 20px;
}

.card-cn {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--text);
    margin-bottom: 15px;
}

.card-hint {
    font-size: 0.9rem;
    color: #bbb;
    position: absolute;
    bottom: 20px;
}

/* 底部控制栏 */
.review-controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 30px;
    padding-bottom: 40px;
}

/* ========================================= */
/* 🔥 重点修复：移动端导航适配 & 填空格优化     */
/* ========================================= */
@media (max-width: 1024px) {
    body {
        flex-direction: column;
        height: 100vh; /* 强制高度 */
        overscroll-behavior: none; /* 禁止橡皮筋效果 */
    }

    /* 底部导航栏容器 */
    aside {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: auto;
        min-height: 70px; /* 保证最小高度 */
        flex-direction: row;
        justify-content: space-around; /* 关键：均匀分布 */
        align-items: center; /* 垂直居中 */
        padding: 5px 0 calc(5px + env(safe-area-inset-bottom)) 0; /* 适配 iPhone 底部黑条 */
        border-top: 2px solid var(--border);
        border-right: none;
        background: var(--bg-card);
        z-index: 200;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    }

    .brand-logo { display: none; }
    
    /* 隐藏占位符 */
    .spacer { display: none; }

    /* 强制重置导航项样式 */
    .nav-item {
        flex: 1; /* 平分宽度 */
        flex-direction: column; /* 图标在上文字在下 */
        font-size: .7rem; /* 字体调小 */
        border: none !important; 
        margin: 0 !important;
        padding: 5px 0;
        background: transparent !important;
        border-radius: 8px;
        justify-content: center;
        text-align: center;
        height: auto;
    }

    /* 修复退出按钮在手机端的颜色和样式 */
    #nav-btn-logout {
        color: var(--text-sub); 
        border: none !important;
        margin-top: 0 !important; /* 必须重置 margin-top */
    }

    /* 激活状态 */
    .nav-item.active {
        box-shadow: none;
        color: var(--duo-green); 
    }

    .nav-icon-box {
        margin: 0 0 3px 0;
        width: 24px;
        height: 24px;
    }

    main {
        width: 100%;
        height: 100%;
        padding-bottom: 80px; /* 给底部导航留出空间 */
    }
    
    .content-scroll {
        padding: 10px; /* 减小内边距 */
        padding-bottom: 100px;
    }

    /* 移动端dashboard视图时content-scroll透明 */
    .content-scroll:has(#view-dashboard:not([style*="display: none"])) {
        background: transparent !important;
        padding: 0 !important;
    }

    /* 移动端主页视图不需要padding */
    #view-dashboard {
        padding: 0 !important;
        margin: -10px;
        margin-bottom: -100px;
        background: transparent !important;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
    }

    /* 移动端主页全屏模型适配 */
    .mascot-full-container {
        height: 75vh; /* 手机上给底部导航留足空间 */
        margin-top: -20px;
    }

    /* 🔥 移动端游戏界面完整适配 - 不需滚动 */
    #view-game {
        height: 100% !important;
        overflow: hidden !important;
    }

    .game-container {
        height: 100% !important;
        display: flex;
        flex-direction: column;
    }

    .game-wrapper {
        height: 100%;
        display: flex;
        flex-direction: column;
        padding: 10px;
        overflow: hidden;
    }

    .review-container {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        overflow: hidden;
        padding-bottom: 10px;
    }

    /* 卡片容器 - 自适应大小 */
    .card-container {
        width: 140px !important;
        height: 140px !important;
        margin: 5px auto 10px !important;
        flex-shrink: 0;
    }

    .chinese-card {
        font-size: 1.3rem !important;
        padding: 15px !important;
        border-radius: 20px !important;
    }

    /* Combo 提示 */
    .combo-popup {
        height: 25px !important;
        margin-bottom: 5px !important;
        font-size: 1rem !important;
    }

    /* 音频按钮 */
    .btn-audio-replay {
        padding: 6px 12px !important;
        margin: 0 auto 10px auto !important;
        font-size: 0.85rem !important;
    }

    /* 工具按钮行 */
    .game-tools-row {
        margin-bottom: 10px !important;
        gap: 12px !important;
    }

    .btn-tool {
        width: 45px !important;
        height: 45px !important;
        border-radius: 12px !important;
    }

    /* 🔥 优化：手机端填空格子样式 */
    .slots-area {
        gap: 3px !important;             /* 减小格子间距 */
        margin: 10px 0 !important;  /* 减小底部距离 */
        padding: 0 5px !important;      /* 防止太靠边 */
        min-height: auto !important;
        flex-shrink: 0;
    }

    .slot-box {
        width: 28px !important;          /* 宽度缩小 */
        height: 38px !important;         /* 高度缩小 */
        font-size: 1.3rem !important;    /* 字体变小 */
        border-bottom-width: 3px !important;
    }

    /* 键盘区域 - 灵活适应 */
    .keyboard-area {
        gap: 6px !important;
        padding: 0 5px !important;
        flex-shrink: 0;
        overflow-y: auto;
        max-height: 30vh;
    }

    .key-btn {
        padding: 10px 8px !important;
        min-width: 38px !important;
        font-size: 0.95rem !important;
        border-radius: 10px !important;
    }

    /* 底部按钮 */
    .bottom-actions {
        padding: 10px !important;
        gap: 8px !important;
        flex-shrink: 0;
        margin-bottom: calc(env(safe-area-inset-bottom) + 5px);
    }

    .action-btn {
        padding: 12px !important;
        font-size: 1rem !important;
        border-radius: 12px !important;
    }
    
    /* 移动端游戏盒子适配 - 超大视野 */
    #snake-container.mode-game {
        width: 95%; 
        margin: 10px auto;
        /* 动态计算高度：占屏幕 70% */
        height: 70vh; 
        max-height: none;
        display: flex;
        flex-direction: column;
        /* 🔥 关键：确保圆角内有背景色 */
        background: #fff;
    }
    
    #snake-canvas-wrapper { 
        flex: 1;
        /* 🔥 核心修复：增加 12px 内边距，避开圆角遮挡 */
        padding: 12px; 
        display: flex;
        justify-content: center;
        align-items: center;
        background: #f7f9fb;
        border-radius: 0 0 24px 24px; 
    }

    /* 彻底隐藏虚拟按键 */
    .snake-controls { display: none !important; }
}

/* ========================================= */
/* 🔥 新增：预览板块 (双模式 + 虚拟按键 + 动画) */
/* ========================================= */

/* 布局外壳：确保占满 100% 高度 */
.preview-layout-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    overflow: hidden;
    position: relative;
}

/* 1. 容器状态 - 闪卡模式 */
#snake-container {
    flex: 1; 
    width: 100%;
    display: flex;
    flex-direction: column;
    padding: 0;
    background: transparent;
    margin: 0;
    border: none;
    box-shadow: none;
    overflow: hidden;
    position: relative;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* 2. 容器状态 - 游戏模式 (白盒子) */
#snake-container.mode-game {
    flex: 0 1 auto; /* 允许收缩 */
    height: auto;
    width: 95%;
    max-width: 480px;
    background: #fff;
    margin: 10px auto 0 auto; 
    border: 2px solid #e5e5e5;
    border-radius: 24px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
}

/* 快闪动画 */
@keyframes flashText {
    0% { transform: scale(1); color: #fff; background: #e1f5fe; }
    50% { transform: scale(1.1); color: #fff; background: #ff4b4b; border-color: #ff4b4b; }
    100% { transform: scale(1); color: var(--duo-blue); background: #e1f5fe; }
}

.flash-anim {
    animation: flashText 0.3s ease-in-out;
}

/* 角落弹出动画 */
@keyframes popFromCorner {
    0% { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

.pop-corner {
    animation: popFromCorner 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* 定义四个角落的变换原点 */
.pop-corner-tl { transform-origin: top left; }
.pop-corner-tr { transform-origin: top right; }
.pop-corner-bl { transform-origin: bottom left; }
.pop-corner-br { transform-origin: bottom right; }

/* 震动动画 */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.shake-anim {
    animation: shake 0.3s;
}

/* Header */
#snake-header {
    display: none;
    flex-shrink: 0;
    padding: 10px 20px 5px 20px;
    background: #fff;
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
    z-index: 10;
}

#snake-container.mode-game #snake-header {
    display: block;
}

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

.snake-top-bar {
    display: flex;
    align-items: center;
    gap: 10px; /* 稍微减小间距 */
    width: 100%;
}

.snake-progress-track {
    flex: 1;
    height: 12px;
    background: #f1f2f6;
    border-radius: 6px;
    overflow: hidden;
}

#snake-progress-fill {
    height: 100%;
    background: var(--duo-green);
    transition: width 0.3s ease;
}

.snake-score-pill {
    font-weight: 900;
    color: var(--duo-yellow);
    font-size: 1rem; /* 稍微调小 */
    display: flex;
    align-items: center;
    background: #fff9c4;
    padding: 4px 10px;
    border-radius: 20px;
}

#snake-target-word {
    text-align: center;
    font-size: 2.2rem;
    font-weight: 800;
    font-family: monospace;
    letter-spacing: 3px;
    color: var(--text);
    margin: 0;
    padding-bottom: 5px;
    min-height: 45px;
    line-height: 1.2;
}

.l-done { display: inline-block; min-width: 24px; text-align: center; margin: 0 3px; border-bottom: 4px solid var(--duo-green); color: var(--duo-green); }
.l-target { display: inline-block; min-width: 24px; text-align: center; margin: 0 3px; border-bottom: 4px solid var(--duo-yellow); color: var(--duo-yellow); }
.l-todo { display: inline-block; min-width: 24px; text-align: center; margin: 0 3px; border-bottom: 4px solid #e5e5e5; color: #e5e5e5; }

/* 画布容器 */
#snake-canvas-wrapper {
    flex: 1; 
    position: relative;
    width: 100%;
    height: 100%;
    display: none;
    justify-content: center;
    align-items: center;
    background: #f7f9fb;
    border-radius: 0 0 24px 24px; 
    overflow: hidden;
    margin: 0;
}

#snake-container.mode-game #snake-canvas-wrapper {
    display: flex;
}

#snake-canvas {
    display: block;
    background: #f7f9fb;
}

/* 🟢 3D 闪卡 */
#snake-intro-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: transparent; 
    z-index: 50;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.4s;
}

#snake-container.mode-game #snake-intro-overlay {
    display: none;
}

.snake-flashcard-container {
    perspective: 1000px;
    width: 300px; 
    height: 400px;
    max-height: 70vh;
}

.snake-flashcard-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-style: preserve-3d;
    box-shadow: 0 25px 60px rgba(0,0,0,0.2); 
    border-radius: 24px;
}

.snake-flashcard-front, .snake-flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(0,0,0,0.05);
    background: white;
}

.snake-flashcard-front { background: linear-gradient(135deg, #ffffff 0%, #f0f9ff 100%); }
.snake-flashcard-back { background: linear-gradient(135deg, #fff9c4 0%, #ffffff 100%); transform: rotateY(180deg); }

#flash-word-front { font-size: 3.5rem; font-weight: 900; color: var(--duo-blue); word-break: break-all; line-height: 1.1; }
#flash-word-back { font-size: 2.4rem; font-weight: 900; color: var(--duo-green); margin-bottom: 10px; }
#flash-cn-back { font-size: 2rem; color: #4b4b4b; font-weight: 800; margin-bottom: 30px; }
.flash-hint { color: #999; margin-top: 25px; font-size: 1rem; font-weight: bold; }
.flash-spelling { 
    font-size: 1.3rem; 
    font-weight: bold; 
    color: var(--duo-blue); 
    background: #e1f5fe; 
    padding: 12px 30px; 
    border-radius: 40px; 
    border: 2px solid #b3e5fc;
    display: flex; align-items: center; gap: 6px;
    transition: all 0.3s;
}
.flash-spelling svg { width: 20px; height: 20px; fill: currentColor; }

/* 暂停层 */
#snake-pause-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.4);
    display: flex; flex-direction: column;
    justify-content: center; align-items: center;
    z-index: 30;
    cursor: pointer;
    backdrop-filter: blur(4px);
    border-radius: 24px;
}

/* 🔥 新增：胶囊暂停按钮样式 */
.btn-capsule-pause {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: #f1f2f6;
    color: var(--text-sub);
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 800;
    font-size: 0.85rem;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    /* 防止文字换行 */
    white-space: nowrap;
    user-select: none;
}

.btn-capsule-pause:active {
    background: #e5e7eb;
    transform: scale(0.95);
}

.btn-capsule-pause svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
    display: block;
}

/* ========================================= */
/* 🔥 虚拟按键区域 (彻底隐藏，改用全屏滑动) */
/* ========================================= */

.snake-controls { display: none !important; }
.d-pad, .d-key { display: none !important; }
#snake-controls-hint { display: none !important; }

/* 电脑端适配 */
@media (min-width: 1024px) {
    #snake-container.mode-game {
        height: 80vh;
        max-height: 800px;
    }
}

/* 进度条样式 */
.preview-progress-bar {
    width: 100%;
    height: 6px;
    background: #f0f2f5;
    border-radius: 3px;
    margin-top: 5px;
    overflow: hidden;
}

.preview-progress-fill {
    height: 100%;
    background: var(--duo-green);
    transition: width 0.3s ease;
    border-radius: 3px;
}

/* ========================================= */
/* 🔥 闪卡升级 - 炫酷风格 (修复文字可见性) */
/* ========================================= */

/* 1. 背景光晕 */
.card-glow {
    position: absolute;
    width: 300px;
    height: 400px;
    background: radial-gradient(circle, rgba(255,236,179,0.6) 0%, rgba(255,255,255,0) 70%);
    border-radius: 50%;
    z-index: 40;
    animation: rotateGlow 10s linear infinite;
    pointer-events: none;
}

@keyframes rotateGlow {
    0% { transform: scale(1) rotate(0deg); opacity: 0.6; }
    50% { transform: scale(1.2) rotate(180deg); opacity: 0.8; }
    100% { transform: scale(1) rotate(360deg); opacity: 0.6; }
}

/* 2. 玻璃拟态 + 流光 */
.snake-flashcard-front, .snake-flashcard-back {
    /* 强力覆盖背景 */
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 
        0 15px 35px rgba(0,0,0,0.1),
        0 5px 15px rgba(0,0,0,0.05),
        inset 0 0 20px rgba(255,255,255,0.8);
    overflow: hidden;
    color: #333; /* 默认深色文字 */
}

/* 确保背面内容层级最高 */
#flash-content-layer {
    position: relative;
    z-index: 10; /* 比 shine 高 */
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.card-shine {
    position: absolute;
    top: 0; left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(
        to right,
        rgba(255,255,255,0) 0%,
        rgba(255,255,255,0.6) 50%,
        rgba(255,255,255,0) 100%
    );
    transform: skewX(-25deg);
    animation: shineMove 3s infinite;
    pointer-events: none;
    z-index: 1; /* 比内容低 */
}

@keyframes shineMove {
    0% { left: -100%; }
    20% { left: 200%; }
    100% { left: 200%; }
}

/* 3. 文字特效 */
#flash-word-front {
    font-size: 3.8rem;
    background: linear-gradient(45deg, #2b70c9, #1cb0f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 4px rgba(43,112,201,0.2));
    position: relative; z-index: 10;
}

#flash-word-back {
    font-size: 2.4rem;
    font-weight: 900;
    color: var(--duo-green);
    margin-bottom: 10px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

#flash-cn-back {
    font-size: 2.2rem;
    color: #4b4b4b; /* 深灰色 */
    font-weight: 800;
    margin-bottom: 30px;
}

#flash-spell-hint {
    font-size: 1.2rem;
    font-weight: bold;
    color: #fff;
    background: linear-gradient(90deg, #2ba6ff, #1cb0f6);
    padding: 10px 30px;
    border-radius: 50px;
    box-shadow: 0 4px 15px rgba(28,176,246,0.3);
    border: none;
    transition: all 0.3s;
}

/* 4. 进度条优化 */
.preview-progress-bar {
    height: 8px;
    border-radius: 4px;
    background: #f0f2f5;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.05);
}
.preview-progress-fill {
    border-radius: 4px;
    background: linear-gradient(90deg, #58cc02, #89e219);
    box-shadow: 0 1px 2px rgba(88,204,2,0.3);
}

/* ========================================= */
/* 🔥 闪卡升级 - 3D 抛掷动画 */
/* ========================================= */

/* 抛掷动画基础类 */
.throw-card {
    animation-duration: 0.8s;
    animation-fill-mode: forwards;
    animation-timing-function: cubic-bezier(0.175, 0.885, 0.32, 1.275); /* 弹性效果 */
}

/* 四个角落的动画定义 */
.throw-from-tl { animation-name: throwFromTL; }
.throw-from-tr { animation-name: throwFromTR; }
.throw-from-bl { animation-name: throwFromBL; }
.throw-from-br { animation-name: throwFromBR; }

/* 1. 左上角飞入 (Top-Left) */
@keyframes throwFromTL {
    0% {
        opacity: 0;
        transform: translate3d(-100vw, -100vh, 0) rotate3d(1, 1, 0, -720deg) scale(0.1);
    }
    100% {
        opacity: 1;
        transform: translate3d(0, 0, 0) rotate3d(0, 0, 0, 0deg) scale(1);
    }
}

/* 2. 右上角飞入 (Top-Right) */
@keyframes throwFromTR {
    0% {
        opacity: 0;
        transform: translate3d(100vw, -100vh, 0) rotate3d(-1, 1, 0, 720deg) scale(0.1);
    }
    100% {
        opacity: 1;
        transform: translate3d(0, 0, 0) rotate3d(0, 0, 0, 0deg) scale(1);
    }
}

/* 3. 左下角飞入 (Bottom-Left) */
@keyframes throwFromBL {
    0% {
        opacity: 0;
        transform: translate3d(-100vw, 100vh, 0) rotate3d(1, -1, 0, -720deg) scale(0.1);
    }
    100% {
        opacity: 1;
        transform: translate3d(0, 0, 0) rotate3d(0, 0, 0, 0deg) scale(1);
    }
}

/* 4. 右下角飞入 (Bottom-Right) */
@keyframes throwFromBR {
    0% {
        opacity: 0;
        transform: translate3d(100vw, 100vh, 0) rotate3d(-1, -1, 0, 720deg) scale(0.1);
    }
    100% {
        opacity: 1;
        transform: translate3d(0, 0, 0) rotate3d(0, 0, 0, 0deg) scale(1);
    }
}

/* ========================================= */
/* 🔥 闪卡升级 - 字母弹跳动画 (修复遮挡) */
/* ========================================= */

.char-span {
    display: inline-block;
    transition: transform 0.1s cubic-bezier(0.175, 0.885, 0.32, 1.275), color 0.1s ease;
    margin: 0 2px; /* 增加间距防止字母粘连 */
    position: relative; /* 确保层级 */
    z-index: 1;
}

.char-span.active {
    transform: scale(1.8) translateY(-10px); /* 放大倍数增加 */
    color: #ffc800;
    text-shadow: 0 4px 8px rgba(255, 200, 0, 0.4);
    z-index: 100; /* 🔥 关键修复：弹跳时层级最高，防止被覆盖 */
}

/* ========================================= */
/* 📱 移动端布局优化 (Bookshelf & Preview)    */
/* ========================================= */

@media (max-width: 600px) {

    /* --- 学习模块移动端适配 --- */
    .learn-modules-container {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 20px 16px 100px 16px;
    }

    .learn-module {
        padding: 24px 20px;
        border-radius: 16px;
    }

    .learn-module-icon {
        width: 60px;
        height: 60px;
        border-radius: 16px;
        padding: 14px;
        margin-bottom: 16px;
    }

    .learn-module-title {
        font-size: 1.2rem;
    }

    .learn-module-desc {
        font-size: 0.9rem;
    }

    /* 主页按钮移动端适配 */
    .nav-home-special {
        padding: 14px 12px;
        margin: 6px 0;
    }

    /* --- 1. Widget 小组件移动端适配 --- */
    
    .widget-container {
        grid-template-columns: repeat(2, 1fr) !important; 
        gap: 12px !important; 
        padding: 16px 16px 100px 16px !important;
    }

    .widget-card {
        min-height: 160px;
        padding: 14px;
        border-radius: 18px;
    }

    .widget-icon {
        width: 40px;
        height: 40px;
        border-radius: 12px;
    }

    .widget-title {
        font-size: 0.9rem;
    }

    .widget-body {
        gap: 12px;
        margin-bottom: 10px;
    }

    .stat-value {
        font-size: 1.3rem;
    }

    .stat-label {
        font-size: 0.65rem;
    }

    /* 关卡列表移动端适配 */
    .level-detail-header {
        padding: 16px;
    }

    .level-course-title {
        font-size: 1.1rem;
    }

    .level-grid {
        padding: 0 16px 100px 16px;
        gap: 10px;
    }

    .level-card {
        padding: 14px 16px;
        gap: 12px;
    }

    .level-card-icon {
        width: 44px;
        height: 44px;
        border-radius: 12px;
    }

    .level-card-title {
        font-size: 1rem;
    }

    .level-card-status {
        font-size: 0.8rem;
    }

    /* --- 2. 保留旧的书架样式避免报错 --- */
    .bookshelf-container {
        /* 强制双列布局 */
        display: grid; /* 🔥 删除 !important，让 JS 可以控制显示/隐藏 */
        grid-template-columns: repeat(2, 1fr) !important; 
        gap: 15px !important; 
        padding: 20px 20px 100px 20px !important;
        justify-items: center;
    }

    .book-item {
        width: 100% !important; 
        aspect-ratio: 3 / 4; /* 保持比例 */
        height: auto !important; 
        
        /* 🔥 修复核心：恢复彩色卡片，去除白色背景 */
        /* background: linear-gradient(...)  <-- 删除这行，让原有的颜色类生效 */
        
        border-radius: 12px !important;
        box-shadow: 
            inset 0 0 0 2px rgba(0,0,0,0.05), /* 内描边增加质感 */
            0 4px 10px rgba(0,0,0,0.1) !important;
        
        display: flex;
        flex-direction: column;
        justify-content: center; /* 内容居中 */
        align-items: center;
        padding: 10px !important;
    }

    /* --- 2. 预习/口语 分组 (Preview & Speaking Folders) --- */
    /* ... 下面的代码保持不变 ... */
    .speak-folder-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important; 
        gap: 12px !important;
        padding: 15px 15px 100px 15px !important;
    }
    
    .folder-card {
        height: auto !important;
        min-height: 120px;
        padding: 15px !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important; /* 居中对齐 */
        text-align: center !important;
    }
    
    .folder-play-icon {
        margin-bottom: 10px !important;
        align-self: center !important;
    }
    
    .folder-sub {
        margin-top: auto !important;
    }
}