/* ==================== CSS变量 ==================== */
:root {
    --bg: #0a0f1a;
    --bg-light: #141d2f;
    --card: #1a2744;
    --card-hover: #243656;
    --accent: #ff6b35;
    --accent-light: #ff8c5a;
    --success: #10b981;
    --error: #f43f5e;
    --text: #f1f5f9;
    --text-muted: #8896ab;
    --border: #2d3f5f;
    --sidebar-width: 240px;
}

/* ==================== 基础样式 ==================== */
* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
}

body {
    font-family: 'Nunito', 'Noto Sans SC', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ==================== 背景效果 ==================== */
.bg-atmosphere {
    position: fixed;
    inset: 0;
    background: 
        radial-gradient(ellipse at 0% 0%, rgba(255, 107, 53, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 100% 100%, rgba(16, 185, 129, 0.08) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* ==================== 侧边栏 ==================== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--bg-light) 0%, var(--bg) 100%);
    border-right: 1px solid var(--border);
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.sidebar.open { transform: translateX(0); }

.sidebar-header {
    padding: 20px 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px 8px;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-muted);
    font-size: 14px;
}

.menu-item:hover {
    background: var(--card);
    color: var(--text);
}

.menu-item.active {
    background: var(--accent);
    color: white;
}

.menu-item-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

/* ==================== 主内容区 ==================== */
.main-content {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

@media (min-width: 1024px) {
    .sidebar { transform: translateX(0); }
    .main-content { margin-left: var(--sidebar-width); }
    .menu-toggle { display: none !important; }
}

/* ==================== 顶部栏 ==================== */
.top-bar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(10, 15, 26, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.top-left { display: flex; align-items: center; gap: 12px; }
.top-right { display: flex; align-items: center; gap: 8px; }

.menu-toggle {
    width: 56px;
    height: 36px;
    border-radius: 8px;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.menu-toggle:hover { 
    background: var(--card-hover); 
    border-color: var(--accent); 
}

.page-title {
    font-size: 16px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    cursor: pointer;
}

.icon-btn {
    min-width: 66px;
    height: 36px;
    border-radius: 8px;
    padding: 8px;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-btn:hover { 
    background: var(--card-hover); 
    border-color: var(--accent); 
}

/* ==================== 遮罩层 ==================== */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 90;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.overlay.active { opacity: 1; visibility: visible; }

/* ==================== 弹窗 ==================== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    /* 新增：遮罩层背景色 */
    background: rgba(0, 0, 0, 0.75); 
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.modal.active { opacity: 1; visibility: visible; }

.modal-content {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    width: 100%;
    max-width: 360px;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative; /* 确保在遮罩层之上 */
    z-index: 201; /* 比遮罩层高 */
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5); /* 增加阴影突出层级 */
}

.modal.active .modal-content { 
    transform: scale(1) translateY(0); 
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 20px;
    text-align: center;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

/* ==================== 卡片 ==================== */
.card {
    background: linear-gradient(165deg, var(--card), var(--bg-light));
    border: 1px solid var(--border);
    border-radius: 12px;
}

/* ==================== 按钮样式 ==================== */
.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: white;
    font-weight: 700;
    padding: 12px 24px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.btn-primary:hover { 
    transform: translateY(-1px); 
    box-shadow: 0 4px 20px rgba(255, 107, 53, 0.4); 
}

.btn-secondary {
    background: var(--bg-light);
    color: var(--text);
    font-weight: 600;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-secondary:hover { 
    background: var(--card); 
    border-color: var(--accent); 
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    font-weight: 600;
    padding: 10px 18px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.btn-ghost:hover { color: var(--text); }

/* ==================== 单词卡片 ==================== */
.word-card {
    background: linear-gradient(165deg, var(--card), var(--bg-light));
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s;
    cursor: pointer;
}

.word-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
    border-color: var(--accent);
}

.word-card img {
    width: 100%;
    height: 80px;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.word-card:hover img {
    transform: scale(1.05);
}

/* 播放状态样式 */
.word-card.playing {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent), 0 8px 24px rgba(255, 107, 53, 0.3);
    transform: translateY(-2px);
}

/* ==================== 游戏选项按钮 ==================== */
.option-btn {
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    text-align: center;
}

.option-btn:hover:not(:disabled) { border-color: var(--accent); }
.option-btn.correct { background: var(--success); border-color: var(--success); }
.option-btn.wrong { background: var(--error); border-color: var(--error); }

/* ==================== 进度条 ==================== */
.progress-bar {
    height: 4px;
    background: var(--bg-light);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
    transition: width 0.3s;
}

/* ==================== 排行榜表格 ==================== */
.lb-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.lb-table th, .lb-table td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.lb-table th {
    color: var(--text-muted);
    font-weight: 600;
    background: var(--bg-light);
}

.lb-table tr:hover td { background: var(--card-hover); }

.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    font-weight: 800;
    font-size: 11px;
}

.rank-1 { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #1a1a1a; }
.rank-2 { background: linear-gradient(135deg, #9ca3af, #6b7280); color: #fff; }
.rank-3 { background: linear-gradient(135deg, #d97706, #b45309); color: #fff; }
.rank-other { background: var(--bg-light); color: var(--text-muted); }

/* ==================== 输入框 ==================== */
.input {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--text);
    font-size: 14px;
    width: 100%;
    transition: all 0.2s;
}

.input:focus { outline: none; border-color: var(--accent); }

.select {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    color: var(--text);
    font-size: 14px;
    cursor: pointer;
}

/* ==================== 音频波形 ==================== */
.audio-wave {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    height: 24px;
}

.audio-wave span {
    width: 3px;
    background: var(--accent);
    border-radius: 2px;
    animation: wave 0.8s ease-in-out infinite;
}

.audio-wave span:nth-child(1) { animation-delay: 0s; height: 10px; }
.audio-wave span:nth-child(2) { animation-delay: 0.1s; height: 18px; }
.audio-wave span:nth-child(3) { animation-delay: 0.2s; height: 24px; }
.audio-wave span:nth-child(4) { animation-delay: 0.3s; height: 18px; }
.audio-wave span:nth-child(5) { animation-delay: 0.4s; height: 10px; }

@keyframes wave {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(0.5); }
}

.audio-wave.paused span { animation-play-state: paused; }

/* ==================== 动画 ==================== */
.fade-in { animation: fadeIn 0.3s ease; }

@keyframes fadeIn { 
    from { opacity: 0; } 
    to { opacity: 1; } 
}

/* ==================== 控制按钮组 ==================== */
.control-group {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.control-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-light);
    color: var(--text);
    font-weight: 600;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    white-space: nowrap;
}

.control-btn:hover { background: var(--card); border-color: var(--accent); }

.control-btn.icon-only {
    padding: 8px;
    min-width: 36px;
    justify-content: center;
}

/* ==================== APP下载引导区域 ==================== */
.app-download-section {
    background: linear-gradient(135deg, #1a2744 0%, #0f172a 50%, #1e293b 100%);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    margin-top: 24px;
    position: relative;
    overflow: hidden;
}

.app-download-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

.app-download-section::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(255, 107, 53, 0.15) 0%, transparent 70%);
    pointer-events: none;
}

.app-promo-content {
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
    z-index: 1;
}

.app-logo-wrapper {
    flex-shrink: 0;
    position: relative;
}

.app-logo {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease;
}

.app-logo:hover {
    transform: scale(1.08) rotate(-2deg);
}

.app-logo-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 4px;
    white-space: nowrap;
}

.app-info {
    flex: 1;
    min-width: 0;
}

.app-name {
    font-size: 16px;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.app-tag {
    font-size: 10px;
    font-weight: 600;
    color: var(--accent);
    background: rgba(255, 107, 53, 0.15);
    padding: 2px 6px;
    border-radius: 4px;
}

.app-desc {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
    margin-top: 4px;
}

.app-features {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.app-feature {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 3px;
}

.app-feature svg {
    width: 12px;
    height: 12px;
    color: var(--success);
}

.app-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: white;
    font-weight: 700;
    font-size: 13px;
    padding: 10px 18px;
    border-radius: 10px;
    text-decoration: none;
    transition: all 0.25s ease;
    box-shadow: 0 4px 15px rgba(255, 107, 53, 0.3);
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.app-download-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}

.app-download-btn:hover::before {
    left: 100%;
}

.app-download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(255, 107, 53, 0.45);
}

.app-download-btn svg {
    width: 16px;
    height: 16px;
}

/* ==================== 响应式 ==================== */
@media (max-width: 480px) {
    .app-promo-content {
        flex-direction: column;
        text-align: center;
    }
    
    .app-info {
        text-align: center;
    }
    
    .app-features {
        justify-content: center;
    }
    
    .app-download-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ==================== 减少动画 ==================== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==================== 滚动条 ==================== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--card); border-radius: 3px; }

/* ==================== 计时器和分数牌样式 ==================== */
.timer-badge,
.score-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    transition: all 0.2s;
}

.timer-badge svg,
.score-badge svg {
    color: var(--text-muted);
}

.timer-badge.active {
    border-color: var(--accent);
    background: rgba(255, 107, 53, 0.1);
}

.timer-badge.active svg {
    color: var(--accent);
}

.score-badge {
    background: linear-gradient(135deg, rgba(255, 107, 53, 0.15), rgba(255, 140, 90, 0.1));
    border-color: var(--accent);
    color: var(--accent);
}

.score-badge svg {
    color: var(--accent);
}

.score-badge span {
    min-width: 32px;
    text-align: right;
}

/* 动画效果 */
.score-animate {
    animation: scoreUp 0.3s ease;
}

@keyframes scoreUp {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); color: #fbbf24; }
    100% { transform: scale(1); }
}

/* ==================== 错题流式布局样式 ==================== */
.tag-flow-container0 {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.wrong-word-tag0 {
    display: inline-flex;
    align-items: center;
    background: rgba(244, 63, 94, 0.1); /* 淡红色背景 */
    border: 1px solid rgba(244, 63, 94, 0.3);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 16px;
    color: #f1f5f9;
    line-height: 1.4;
}
.wrong-word-tag0 .word {
    color: #f43f5e; /* 红色突出单词 */
    font-weight: 700;
    margin-right: 4px;
}

.wrong-word-tag0 .meaning {
    color: #94a3b8;
}


.tag-flow-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 180px; /* 限制高度，超出滚动 */
    overflow-y: auto;
}

.wrong-word-tag {
    display: inline-flex;
    align-items: center;
    background: rgba(244, 63, 94, 0.1); /* 淡红色背景 */
    border: 1px solid rgba(244, 63, 94, 0.3);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12px;
    color: #f1f5f9;
    line-height: 1.4;
}

.wrong-word-tag .word {
    color: #f43f5e; /* 红色突出单词 */
    font-weight: 700;
    margin-right: 4px;
}

.wrong-word-tag .meaning {
    color: #94a3b8;
}

/* 弹窗内容滚动条优化 */
.modal-content::-webkit-scrollbar,
.tag-flow-container::-webkit-scrollbar {
    width: 4px;
}
.modal-content::-webkit-scrollbar-thumb,
.tag-flow-container::-webkit-scrollbar-thumb {
    background: var(--card-hover);
    border-radius: 2px;
}

.audioControlBtn {
    position: relative;
    padding: 10px 24px;
    font-size: 16px;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    overflow: hidden;
    background: #ccebff; /* 初始浅色 */
}

/* 进度背景：从左到右填充 */
#audioProgress {
    position: absolute;
    left: 0; top: 0; height: 100%;
    width: 0%; /* 进度从0开始 */
    background: #007bff; /* 主色（填满颜色） */
    transition: none; /* 50ms更流畅，禁用过渡 */
    z-index: 1;
}
.btnText {
    position: relative;
    z-index: 2;
}

.card-icon {
    width: 30px; height: 30px; border-radius: 8px;
    background: rgba(255,255,255,0.05);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
}