* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Microsoft YaHei", "SimHei", sans-serif;
}

:root {
    --primary: #2380dd;
    --secondary: #8824e6;
    --accent: #fdbb2d;
    --light: #fff9c4;
    --dark: #1a237e;
    --text: #333;
    --text-light: #666;
}

body {
    background: linear-gradient(135deg, #2380dd, #8824e6, #fdbb2d);
    background-size: 400% 400%;
    animation: gradient 15s ease infinite;
    color: #fff;
    min-height: 100vh;
    padding: 20px;
    overflow-x: hidden;
}

@keyframes gradient {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
}

/* 自定义滚动条 */
::-webkit-scrollbar {
    width: 12px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, #ff8a00, #da1b60);
    border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(to bottom, #da1b60, #ff8a00);
}

header {
    text-align: center;
    margin-bottom: 40px;
    padding: 30px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background: linear-gradient(to right, #ff8a00, #da1b60, #ff8a00);
}

h1 {
    font-size: 3.5rem;
    margin-bottom: 15px;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.7);
    color: #FFD700;
    letter-spacing: 3px;
}

.subtitle {
    font-size: 1.2rem;
    color: #FFEBCD;
    margin-bottom: 10px;
}

.search-container {
    display: flex;
    justify-content: center;
    margin-bottom: 40px;
    position: relative;
}

.search-box {
    display: flex;
    width: 80%;
    max-width: 600px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 50px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.search-box:focus-within {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.search-box input {
    flex: 1;
    padding: 15px 25px;
    border: none;
    outline: none;
    font-size: 1.2rem;
    background: transparent;
}

.search-box button {
    padding: 15px 25px;
    background: linear-gradient(to right, #ff8a00, #da1b60);
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-box button:hover {
    background: linear-gradient(to right, #da1b60, #ff8a00);
    transform: scale(1.05);
}

.search-options {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-option {
    padding: 8px 15px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.search-option:hover {
    background: rgba(255, 255, 255, 0.3);
}

.search-option.active {
    background: rgba(255, 215, 0, 0.3);
    border-color: #FFD700;
}

.feature-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.feature-btn {
    padding: 12px 25px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 30px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.feature-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-5px);
}

.feature-btn.active {
    background: rgba(255, 215, 0, 0.3);
    border-color: #FFD700;
}

.stats {
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.1rem;
    color: #FFEBCD;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.progress-bar-container {
    flex: 1;
    height: 20px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    overflow: hidden;
    margin: 0 15px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(to right, #ff8a00, #da1b60);
    border-radius: 10px;
    width: 0%;
    transition: width 0.5s ease;
}

.results-container0 {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
    margin-top: 30px;
}

.results-container {
    display: grid;
    /* 将 auto-fill 改为 auto-fit（折叠空列，优化居中效果）+ 列宽范围 */
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    /* 核心：让网格轨道（列）在容器内水平居中 */
    justify-content: center;
    /* 若需要垂直居中（容器有固定高度时），可加 align-content: center; */
    gap: 25px;
    margin-top: 30px;
    /* 可选：限制容器最大宽度，避免大屏下卡片过宽 */
    max-width: 1200px;
    /* 可选：让容器本身居中（若父容器宽度100%） */
    margin-left: auto;
    margin-right: auto;
}

.character-card {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.character-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background: linear-gradient(to right, #ff8a00, #da1b60);
}

.character-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3);
}

.character-text {
    font-size: 4rem;
    text-align: center;
    margin-bottom: 15px;
    color: #FFD700;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
    font-weight: bold;
}

.pinyin {
    font-size: 1.5rem;
    text-align: center;
    margin-bottom: 15px;
    color: #FFEBCD;
    line-height: 1.8;
}

.character-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    font-size: 1.1rem;
    color: #E6E6FA;
}

.meaning {
    font-size: 1.1rem;
    line-height: 1.6;
    color: #E6E6FA;
    margin-bottom: 15px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 15px;
}

.card-btn {
    padding: 8px 15px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 5px;
}

.card-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.card-btn.favorite {
    background: rgba(255, 105, 180, 0.3);
}

.card-btn.favorite.active {
    background: rgba(255, 105, 180, 0.7);
}

.card-btn.learned {
    background: rgba(50, 205, 50, 0.3);
}

.card-btn.learned.active {
    background: rgba(50, 205, 50, 0.7);
}

.card-btn.pronounce {
    background: rgba(30, 144, 255, 0.3);
}

.loading {
    text-align: center;
    font-size: 1.5rem;
    margin: 50px 0;
    display: none;
}

.no-results {
    text-align: center;
    font-size: 1.5rem;
    margin: 50px 0;
    display: none;
    color: #FFB6C1;
}

.data-status {
    text-align: center;
    margin: 20px 0;
    font-size: 1.1rem;
    color: #FFEBCD;
}

.load-more-container {
    text-align: center;
    margin: 40px 0;
}

.load-more-btn {
    padding: 15px 30px;
    background: linear-gradient(to right, #ff8a00, #da1b60);
    border: none;
    border-radius: 50px;
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.load-more-btn:hover {
    background: linear-gradient(to right, #da1b60, #ff8a00);
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

.load-more-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

footer {
    text-align: center;
    margin-top: 50px;
    padding: 20px;
    color: #D3D3D3;
    font-size: 0.9rem;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .search-box {
        width: 95%;
    }

    h1 {
        font-size: 2.5rem;
    }

    .character-card {
        padding: 20px;
    }

    .character-text {
        font-size: 3rem;
    }

    .feature-buttons {
        gap: 10px;
    }

    .feature-btn {
        padding: 10px 15px;
        font-size: 0.9rem;
    }

    .progress-info {
        flex-direction: column;
        gap: 10px;
    }

    .progress-bar-container {
        width: 100%;
        margin: 10px 0;
    }
}

/* 模态框样式 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background: linear-gradient(135deg, #1a2a6c, #b21f1f);
    border-radius: 20px;
    padding: 30px;
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5);
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 1.5rem;
    color: white;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.3);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.close-modal:hover {
    background: rgba(0, 0, 0, 0.5);
    transform: rotate(90deg);
}

.modal-character-text {
    font-size: 5rem;
    text-align: center;
    margin-bottom: 15px;
    color: #FFD700;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
    font-weight: bold;
}

.modal-pinyin {
    font-size: 1.8rem;
    text-align: center;
    margin-bottom: 20px;
    color: #FFEBCD;
}

.modal-character-info {
    display: flex;
    justify-content: space-around;
    margin-bottom: 20px;
    font-size: 1.3rem;
    color: #E6E6FA;
}

.modal-meaning {
    font-size: 1.2rem;
    line-height: 1.6;
    color: #E6E6FA;
    margin-bottom: 20px;
    white-space: pre-line;
}

.modal-more {
    font-size: 1rem;
    color: #D3D3D3;
    line-height: 1.6;
    white-space: pre-line;
    margin-top: 20px;
}

/* 测验容器样式 */
.quiz-container {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 25px;
    margin: 20px 0;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.quiz-title {
    font-size: 1.8rem;
    text-align: center;
    margin-bottom: 20px;
    color: #FFD700;
}

.quiz-rules {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
    font-size: 1rem;
    line-height: 1.6;
    text-align: center;
}

.quiz-game {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
}

.quiz-status {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 600px;
    margin-bottom: 10px;
}

.quiz-score, .quiz-round {
    background: rgba(0, 0, 0, 0.3);
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 1.1rem;
}

.quiz-display {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 15px;
    padding: 20px;
    width: 100%;
    max-width: 600px;
    text-align: center;
}

.quiz-question {
    font-size: 2rem;
    color: #FFD700;
    margin-bottom: 15px;
}

.quiz-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 20px;
}

.quiz-option {
    padding: 15px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.1rem;
}

.quiz-option:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-3px);
}

.quiz-option.correct {
    background: rgba(50, 205, 50, 0.5);
}

.quiz-option.incorrect {
    background: rgba(255, 0, 0, 0.5);
}

.quiz-controls {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

.quiz-btn {
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
}

.quiz-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-3px);
}

.quiz-btn.restart {
    background: linear-gradient(to right, #ff8a00, #da1b60);
}

.quiz-btn.exit {
    background: rgba(255, 0, 0, 0.3);
}

.quiz-message {
    margin-top: 15px;
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    font-weight: bold;
    display: none;
}

.quiz-message.success {
    background: rgba(0, 255, 0, 0.2);
    color: #90EE90;
    display: block;
}

.quiz-message.error {
    background: rgba(255, 0, 0, 0.2);
    color: #FFB6C1;
    display: block;
}

/* 分类容器样式 */
.category-container {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 25px;
    margin: 20px 0;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.category-title {
    font-size: 1.8rem;
    text-align: center;
    margin-bottom: 20px;
    color: #FFD700;
}

.category-options {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
    margin-bottom: 20px;
}

.category-btn {
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
}

.category-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.category-btn.active {
    background: rgba(255, 215, 0, 0.3);
    border-color: #FFD700;
}

.category-content {
    margin-top: 20px;
}

.radicals-list, .strokes-list, .pinyin-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.radical-group, .stroke-group, .pinyin-group {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.radical-group h3, .stroke-group h3, .pinyin-group h3 {
    font-size: 1.3rem;
    margin-bottom: 10px;
    color: #FFD700;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 5px;
}

.characters-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.character-item {
    padding: 5px 10px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.1rem;
}

.character-item:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.category-load-more {
    text-align: center;
    margin-top: 30px;
}

.category-load-more-btn {
    padding: 12px 25px;
    background: linear-gradient(to right, #ff8a00, #da1b60);
    border: none;
    border-radius: 25px;
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.category-load-more-btn:hover {
    background: linear-gradient(to right, #da1b60, #ff8a00);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.category-load-more-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* 返回顶部按钮样式 */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    /*background: linear-gradient(135deg, #068df6 0%, #8824e6 50%, #f35838 100%);*/
    background: linear-gradient(135deg, #068df6 0%, #f44621 50%, #25d54d 100%);
    background-size: 200% 200%;
    color: white;
    font-size: 24px;
    cursor: pointer;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.6),
    0 0 40px rgba(102, 126, 234, 0.4),
    0 0 60px rgba(102, 126, 234, 0.2),
    0 10px 25px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: gradientShift 3s ease infinite;
}

.back-to-top.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    transform: translateY(-5px) scale(1.1);
    box-shadow: 0 0 30px rgba(102, 126, 234, 0.8),
    0 0 60px rgba(102, 126, 234, 0.6),
    0 0 90px rgba(102, 126, 234, 0.4),
    0 15px 35px rgba(0, 0, 0, 0.4);
    animation: gradientShift 3s ease infinite,
    pulse 1.5s ease infinite,
    borderGlow 2s ease infinite;
}

.back-to-top:active {
    transform: translateY(-2px) scale(1.05);
    transition: transform 0.1s ease;
}

/* 背景渐变动画 */
@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* 脉冲动画 */
@keyframes pulse {
    0% {
        box-shadow: 0 0 20px rgba(102, 126, 234, 0.6),
        0 0 40px rgba(102, 126, 234, 0.4),
        0 0 60px rgba(102, 126, 234, 0.2),
        0 10px 25px rgba(0, 0, 0, 0.3);
    }
    50% {
        box-shadow: 0 0 30px rgba(102, 126, 234, 0.8),
        0 0 60px rgba(102, 126, 234, 0.6),
        0 0 90px rgba(102, 126, 234, 0.4),
        0 15px 35px rgba(0, 0, 0, 0.4);
    }
    100% {
        box-shadow: 0 0 20px rgba(102, 126, 234, 0.6),
        0 0 40px rgba(102, 126, 234, 0.4),
        0 0 60px rgba(102, 126, 234, 0.2),
        0 10px 25px rgba(0, 0, 0, 0.3);
    }
}

/* 边框发光动画 */
@keyframes borderGlow {
    0%, 100% {
        border: 2px solid rgba(102, 126, 234, 0.8);
    }
    25% {
        border: 2px solid rgba(118, 75, 162, 0.8);
    }
    50% {
        border: 2px solid rgba(243, 88, 56, 0.8);
    }
    75% {
        border: 2px solid rgba(99, 102, 241, 0.8);
    }
}

/* 图标动画 */
.back-to-top i {
    transition: transform 0.3s ease;
}

.back-to-top:hover i {
    transform: translateY(-2px);
}

/* 移动端适配 */
@media (max-width: 768px) {
    .back-to-top {
        width: 35px;
        height: 35px;
        bottom: 20px;
        right: 20px;
        font-size: 20px;
    }

    .modal-content {
        padding: 20px;
    }

    .modal-character-text {
        font-size: 4rem;
    }

    .modal-pinyin {
        font-size: 1.5rem;
    }

    .modal-character-info {
        flex-direction: column;
        gap: 10px;
        align-items: center;
    }

    .search-options {
        gap: 10px;
    }

    .search-option {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .quiz-options {
        grid-template-columns: 1fr;
    }

    .category-options {
        gap: 10px;
    }

    .category-btn {
        padding: 8px 15px;
        font-size: 0.9rem;
    }

    .card-actions {
        flex-direction: column;
        gap: 10px;
    }

    .radicals-list, .strokes-list, .pinyin-list {
        grid-template-columns: 1fr;
    }
}