/* 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;
}

/* --- 主内容区 --- */
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;
}

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;
}

/* --- 吉祥物区域 --- */
.mascot-home-container {
    position: relative;
    width: 100%;
    height: 380px; 
    display: flex;
    justify-content: center;
    align-items: flex-end; 
    background: radial-gradient(circle at 50% 60%, #fff9c4 0%, transparent 60%);
    margin-bottom: -50px; 
    z-index: 1;
    overflow: visible;
}

#mascot {
    width: 100%;
    height: 100%;
    --poster-color: transparent;
}

/* 动态气泡 */
.mascot-bubble {
    position: absolute;
    top: 20%;
    right: 15%;
    background: rgba(255, 255, 255, 0.95);
    padding: 12px 18px;
    border-radius: 18px;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    font-size: 0.95rem;
    color: #444;
    font-weight: 700;
    max-width: 180px;
    z-index: 10;
    opacity: 0;
    transform: scale(0.5) translateY(10px);
    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);
}

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

.bookshelf-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 20px 15px;
    padding: 20px;
    justify-items: center;
    animation: popIn 0.3s;
    position: relative;
    z-index: 5;
}

.book-item {
    width: 100px;
    height: 130px;
    background: #fff;
    border-radius: 8px 12px 12px 8px;
    position: relative;
    cursor: pointer;
    box-shadow: inset 10px 0 20px rgba(0,0,0,0.1), 5px 5px 10px rgba(0,0,0,0.15);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 10px;
    border: 2px solid rgba(0,0,0,0.05);
    overflow: hidden; /* 关键：确保锁定遮罩不会超出圆角 */
    z-index: 1; /* 确保层级正确 */
}

.book-item:active {
    transform: scale(0.95);
    box-shadow: 2px 2px 5px rgba(0,0,0,0.1);
}

.book-item::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(255,255,255,0.3);
}

/* 新增：锁定遮罩层 (毛玻璃效果) */
.book-lock-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.4); /* 半透明白 */
    backdrop-filter: blur(4px); /* 核心：毛玻璃模糊 */
    -webkit-backdrop-filter: blur(4px); /* 兼容 iOS */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    cursor: not-allowed; /* 鼠标变为禁止符号 */
}

/* 新增：锁图标的圆形背景 */
.lock-icon-badge {
    background: rgba(0, 0, 0, 0.6); /* 深色背景凸显锁 */
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    transform: scale(1);
    transition: transform 0.2s;
}

/* 点击锁定书本时的微动效 */
.book-item:active .lock-icon-badge {
    transform: scale(1.1);
}

/* 确保 SVG 颜色正确 */
.lock-icon-badge .icon-svg {
    width: 20px;
    height: 20px;
    fill: #fff;
}

.book-title {
    color: white;
    font-weight: 800;
    font-size: 1rem;
    text-shadow: 0 2px 0 rgba(0,0,0,0.1);
    z-index: 2;
    word-break: break-word;
    line-height: 1.2;
}

.book-icon {
    width: 32px;  
    height: 32px;
    margin-bottom: 8px;
    color: rgba(255,255,255,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
}

.book-badge {
    position: absolute;
    bottom: 10px;
    font-size: 0.7rem;
    background: rgba(0,0,0,0.2);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
}

.book-color-0 { background-color: #ffc800; border-left: 12px solid #e5b300; }
.book-color-1 { background-color: #1cb0f6; border-left: 12px solid #1899d6; }
.book-color-2 { background-color: #ff9600; border-left: 12px solid #e58600; }
.book-color-3 { background-color: #ff4b4b; border-left: 12px solid #e53935; }
.book-color-4 { background-color: #ce82ff; border-left: 12px solid #a561d1; }

.level-header {
    display: flex;
    align-items: center;
    padding: 0 15px 15px 15px;
    margin-bottom: 10px;
    border-bottom: 2px solid var(--border);
}

.btn-back-shelf {
    background: var(--bg-card);
    border: 2px solid var(--border);
    padding: 8px 15px;
    border-radius: 12px;
    font-weight: 800;
    color: var(--text-sub);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 4px 0 rgba(0,0,0,0.1);
    font-size: 0.9rem;
}

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

.current-unit-title {
    flex: 1;
    text-align: center;
    font-weight: 900;
    color: var(--text);
    font-size: 1.2rem;
}

/* --- 关卡节点 --- */
.level-node {
    width: 90%;
    max-width: 500px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 16px;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 20px;
    cursor: pointer;
    box-shadow: 0 4px 0 rgba(0,0,0,0.1);
    margin: 0 auto 20px auto;
    position: relative;
    transition: .1s;
}

.level-node:active {
    transform: translateY(4px);
    box-shadow: none;
}

.level-node.locked {
    filter: grayscale(1);
    opacity: .6;
    pointer-events: none;
    border-style: dashed;
    box-shadow: none;
}

.level-node.completed .level-icon {
    background: var(--duo-green);
    color: white;
}

.level-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--duo-green);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

/* --- 商城 --- */
#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;
    }

    /* 🔥 优化：手机端填空格子样式 */
    .slots-area {
        gap: 4px;             /* 减小格子间距 */
        margin-bottom: 25px;  /* 增加底部距离 */
        padding: 0 10px;      /* 防止太靠边 */
    }

    .slot-box {
        width: 32px;          /* 宽度缩小到 32px */
        height: 42px;         /* 高度缩小 */
        font-size: 1.4rem;    /* 字体变小 */
        border-bottom-width: 3px;
    }

    .game-tools-row {
        margin-bottom: 15px;
        gap: 20px;            /* 拉开距离 */
    }

    .btn-tool {
        width: 50px;
        height: 50px;
    }
    
    /* 移动端游戏盒子适配 - 超大视野 */
    #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) {

    /* --- 1. 词汇书架 (Home Tab) --- */
    
    .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;
    }

    /* 恢复图标和文字样式 */
    .book-icon {
        width: 48px !important;
        height: 48px !important;
        margin-bottom: 10px;
        filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
    }

    .book-title {
        font-size: 1.1rem !important;
        text-align: center;
        color: white !important; /* 确保文字是白色 */
        text-shadow: 0 1px 2px rgba(0,0,0,0.1);
    }

    .book-badge {
        margin-top: auto;
        background: rgba(0,0,0,0.2) !important;
        color: white !important;
        border-radius: 10px;
        padding: 2px 8px !important;
    }

    /* 🔥 修复颜色：移除 border-left，恢复全卡片背景色 */
    .book-color-0 { border-left: none !important; background-color: #ffc800 !important; }
    .book-color-1 { border-left: none !important; background-color: #1cb0f6 !important; }
    .book-color-2 { border-left: none !important; background-color: #ff9600 !important; }
    .book-color-3 { border-left: none !important; background-color: #ff4b4b !important; }
    .book-color-4 { border-left: none !important; background-color: #ce82ff !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;
    }
}

/* --- style.css 新增内容 --- */

/* 1. 优化书本容器：防止遮罩层溢出圆角 */
.book-item {
    overflow: hidden !important; /* 强制裁剪溢出内容 */
    position: relative;
    isolation: isolate; /* 建立新的层叠上下文 */
}

/* 2. 锁定状态遮罩层（毛玻璃效果） */
.book-locked-mask {
    position: absolute;
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    background: rgba(255, 255, 255, 0.3); /* 浅白色半透明 */
    backdrop-filter: blur(5px); /* 核心：模糊背景 */
    -webkit-backdrop-filter: blur(5px); /* 兼容 iOS */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: background 0.2s;
}

/* 3. 锁图标的圆形底座 */
.lock-badge-circle {
    width: 48px;
    height: 48px;
    background: rgba(0, 0, 0, 0.6); /* 深色半透明底 */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    transform: scale(1);
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.lock-badge-circle svg {
    width: 22px;
    height: 22px;
    fill: #ffffff;
}

/* 4. 点击锁定书本时的按压微动效 */
.book-item:active .lock-badge-circle {
    transform: scale(1.2); /* 图标放大 */
    background: rgba(0, 0, 0, 0.8);
}