/* ===== 基础重置 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    /* 颜色系统 */
    --glass-bg: rgba(255, 255, 255, 0.25);
    --glass-bg-strong: rgba(255, 255, 255, 0.4);
    --glass-border: rgba(255, 255, 255, 0.5);
    --glass-border-strong: rgba(255, 255, 255, 0.7);
    --glass-shadow: 0 8px 32px rgba(31, 38, 135, 0.15);
    
    --text-primary: rgba(0, 0, 0, 0.85);
    --text-secondary: rgba(0, 0, 0, 0.6);
    --text-tertiary: rgba(0, 0, 0, 0.4);
    
    --accent-blue: #007AFF;
    --accent-green: #34C759;
    --accent-red: #FF3B30;
    --accent-orange: #FF9500;
    --accent-purple: #AF52DE;
    --accent-pink: #FF2D55;
    
    --success-bg: rgba(52, 199, 89, 0.15);
    --error-bg: rgba(255, 59, 48, 0.15);
    
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 12px;
    --radius-xs: 8px;
}

/* ===== 全局样式 ===== */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: #f5f5f7;
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== 动态背景 ===== */
.bg-gradient {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 25%, #f093fb 50%, #f5576c 75%, #4facfe 100%);
    background-size: 400% 400%;
    animation: gradientShift 20s ease infinite;
    z-index: -1;
    overflow: hidden;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.6;
    animation: blobFloat 15s ease-in-out infinite;
}

.blob-1 {
    width: 400px;
    height: 400px;
    background: #ff6b6b;
    top: -100px;
    left: -100px;
    animation-delay: 0s;
}

.blob-2 {
    width: 350px;
    height: 350px;
    background: #4ecdc4;
    top: 30%;
    right: -80px;
    animation-delay: -5s;
}

.blob-3 {
    width: 450px;
    height: 450px;
    background: #a855f7;
    bottom: -150px;
    left: 20%;
    animation-delay: -10s;
}

@keyframes blobFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -30px) scale(1.1); }
    66% { transform: translate(-20px, 20px) scale(0.95); }
}

/* ===== 玻璃效果 ===== */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
}

.glass-sm {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* ===== 应用容器 ===== */
.app-container {
    max-width: 430px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    padding-bottom: env(safe-area-inset-bottom);
}

/* ===== 顶部导航 ===== */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    margin: 12px;
    border-radius: var(--radius-lg);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-icon {
    font-size: 28px;
}

.app-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.header-right {
    display: flex;
    align-items: center;
}

.streak-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 14px;
}

.streak-icon {
    font-size: 16px;
}

.streak-num {
    color: var(--text-primary);
    min-width: 16px;
    text-align: center;
}

/* ===== 主内容区 ===== */
.main-content {
    flex: 1;
    padding: 8px 16px 24px;
}

.page {
    display: none;
    animation: pageSlideIn 0.4s cubic-bezier(0.32, 0.72, 0, 1);
}

.page.active {
    display: block;
}

@keyframes pageSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== 欢迎区域 ===== */
.welcome-section {
    padding: 20px 4px 24px;
}

.welcome-title {
    font-size: 32px;
    font-weight: 800;
    color: white;
    margin-bottom: 8px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.welcome-subtitle {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
}

/* ===== 词书卡片 ===== */
.book-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 20px;
}

.book-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    position: relative;
    overflow: hidden;
}

.book-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0) 100%);
    pointer-events: none;
}

.book-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(31, 38, 135, 0.2);
    border-color: var(--glass-border-strong);
}

.book-card:active {
    transform: translateY(0) scale(0.98);
}

.book-icon-wrap {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.book-icon {
    font-size: 32px;
}

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

.book-name {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.book-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.book-level {
    display: flex;
    gap: 8px;
}

.level-tag {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.level-basic {
    background: rgba(52, 199, 89, 0.2);
    color: #248a3d;
}

.level-medium {
    background: rgba(255, 149, 0, 0.2);
    color: #b36900;
}

.level-advanced {
    background: rgba(175, 82, 222, 0.2);
    color: #7a3aa0;
}

.book-arrow {
    color: var(--text-tertiary);
    flex-shrink: 0;
    opacity: 0.6;
}

/* ===== 统计卡片 ===== */
.stats-card {
    padding: 20px;
    border-radius: var(--radius-lg);
}

.stats-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.stats-grid {
    display: flex;
    align-items: center;
    justify-content: space-around;
}

.stat-item {
    text-align: center;
    flex: 1;
}

.stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-divider {
    width: 1px;
    height: 40px;
    background: var(--glass-border);
}

/* ===== 听写页面 ===== */
.dictation-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 4px 16px;
}

.back-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.2s ease;
    border: none;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

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

.progress-info {
    flex: 1;
    text-align: center;
}

.progress-text {
    font-size: 15px;
    font-weight: 600;
    color: white;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.book-name-sm {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    text-align: right;
    min-width: 60px;
    font-weight: 500;
}

.progress-bar {
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 20px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple));
    border-radius: 4px;
    transition: width 0.4s cubic-bezier(0.32, 0.72, 0, 1);
    width: 0%;
}

/* ===== 单词卡片 ===== */
.word-card {
    text-align: center;
    padding: 40px 20px;
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
}

.play-btn {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-blue), #5856d6);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    position: relative;
    transition: all 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: 0 8px 24px rgba(0, 122, 255, 0.4);
}

.play-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 32px rgba(0, 122, 255, 0.5);
}

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

.play-btn-inner {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 4px;
}

.play-ripple {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    opacity: 0;
    animation: none;
}

.play-btn.playing .play-ripple {
    animation: ripple 1.5s ease-out infinite;
}

@keyframes ripple {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.5;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.8);
        opacity: 0;
    }
}

.play-hint {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.word-meaning-box {
    margin-top: 20px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-md);
    animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.word-phonetic {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-family: 'SF Mono', Menlo, monospace;
}

.word-meaning {
    font-size: 18px;
    color: var(--text-primary);
    font-weight: 600;
}

/* ===== 输入卡片 ===== */
.input-card {
    padding: 16px;
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
}

.answer-input {
    width: 100%;
    padding: 16px 18px;
    font-size: 18px;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.3);
    border: 1.5px solid transparent;
    border-radius: var(--radius-md);
    outline: none;
    transition: all 0.3s ease;
    color: var(--text-primary);
    font-family: inherit;
}

.answer-input::placeholder {
    color: var(--text-tertiary);
}

.answer-input:focus {
    background: rgba(255, 255, 255, 0.5);
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.15);
}

.answer-input.correct {
    background: var(--success-bg);
    border-color: var(--accent-green);
    color: #248a3d;
}

.answer-input.wrong {
    background: var(--error-bg);
    border-color: var(--accent-red);
    color: #c9251c;
    animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
}

.feedback-box {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 14px;
    padding: 14px;
    border-radius: var(--radius-sm);
    animation: slideDown 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.feedback-box.correct {
    background: var(--success-bg);
}

.feedback-box.wrong {
    background: var(--error-bg);
}

.feedback-icon {
    font-size: 28px;
    flex-shrink: 0;
}

.feedback-content {
    flex: 1;
    min-width: 0;
}

.feedback-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.feedback-word {
    font-size: 14px;
    color: var(--text-secondary);
    font-family: 'SF Mono', Menlo, monospace;
}

/* ===== 操作按钮 ===== */
.action-buttons {
    margin-bottom: 16px;
}

.primary-btn {
    width: 100%;
    padding: 18px 24px;
    font-size: 16px;
    font-weight: 700;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: white;
    background: linear-gradient(135deg, var(--accent-blue), #5856d6);
    border: none;
    box-shadow: 0 8px 24px rgba(0, 122, 255, 0.3);
    font-family: inherit;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(0, 122, 255, 0.4);
}

.primary-btn:active {
    transform: translateY(0) scale(0.98);
}

.primary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.primary-btn.success {
    background: linear-gradient(135deg, var(--accent-green), #30d158);
    box-shadow: 0 8px 24px rgba(52, 199, 89, 0.3);
}

.primary-btn.success:hover {
    box-shadow: 0 12px 32px rgba(52, 199, 89, 0.4);
}

.secondary-btn {
    width: 100%;
    padding: 14px 24px;
    font-size: 15px;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-primary);
    border: none;
    margin-top: 12px;
    font-family: inherit;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.35);
}

.secondary-btn:active {
    transform: scale(0.98);
}

/* ===== 提示栏 ===== */
.hint-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.hint-icon {
    font-size: 16px;
}

/* ===== 结果页面 ===== */
.result-card {
    text-align: center;
    padding: 40px 24px;
    border-radius: var(--radius-lg);
    margin-top: 20px;
}

.result-emoji {
    font-size: 72px;
    margin-bottom: 16px;
    animation: bounceIn 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes bounceIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    60% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.result-title {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.result-subtitle {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-weight: 500;
}

.result-stats {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-bottom: 32px;
}

.result-stat {
    text-align: center;
    flex: 1;
    padding: 16px 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-md);
}

.result-stat-num {
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 4px;
}

.result-stat.correct .result-stat-num {
    color: var(--accent-green);
}

.result-stat.wrong .result-stat-num {
    color: var(--accent-red);
}

.result-stat.accuracy .result-stat-num {
    color: var(--accent-blue);
}

.result-stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.result-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ===== 撒花动画 ===== */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    overflow: hidden;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    animation: confettiFall 3s ease-out forwards;
}

@keyframes confettiFall {
    0% {
        transform: translateY(-100px) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* ===== 响应式 ===== */
@media (max-width: 375px) {
    .welcome-title {
        font-size: 28px;
    }
    
    .book-card {
        padding: 16px;
    }
    
    .book-icon-wrap {
        width: 48px;
        height: 48px;
    }
    
    .book-icon {
        font-size: 28px;
    }
    
    .word-card {
        padding: 32px 16px;
    }
    
    .play-btn {
        width: 76px;
        height: 76px;
    }
}

/* ===== 深色模式支持 ===== */
@media (prefers-color-scheme: dark) {
    :root {
        --glass-bg: rgba(30, 30, 30, 0.4);
        --glass-bg-strong: rgba(40, 40, 40, 0.5);
        --glass-border: rgba(255, 255, 255, 0.1);
        --glass-border-strong: rgba(255, 255, 255, 0.2);
        
        --text-primary: rgba(255, 255, 255, 0.9);
        --text-secondary: rgba(255, 255, 255, 0.6);
        --text-tertiary: rgba(255, 255, 255, 0.4);
    }
    
    .answer-input {
        background: rgba(255, 255, 255, 0.1);
    }
    
    .answer-input:focus {
        background: rgba(255, 255, 255, 0.15);
    }
    
    .word-meaning-box {
        background: rgba(255, 255, 255, 0.1);
    }
    
    .result-stat {
        background: rgba(255, 255, 255, 0.08);
    }
    
    .book-icon-wrap {
        background: rgba(255, 255, 255, 0.1);
    }
}
