@import url('https://fonts.googleapis.com/css2?family=ZCOOL+KuaiLe&display=swap');

:root {
    --bg-gradient-start: #a8e6cf;
    --bg-gradient-end: #dcedc1;
    --primary-color: #ff8a80;
    --secondary-color: #ffd180;
    --accent-color: #84ffff;
    --text-color: #5d4037;
    --white-color: #ffffff;
    --card-bg: #fafafa;
    --correct-color: #b9f6ca;
    --incorrect-color: #ffcdd2;
    --font-family: 'ZCOOL KuaiLe', 'Comic Sans MS', 'Microsoft YaHei', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
    min-height: 100vh;
    padding: 20px;
    color: var(--text-color);
    font-family: var(--font-family);
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

header {
    position: relative;
    text-align: center;
    padding: 20px;
    margin-bottom: 30px;
}

h1 {
    color: var(--primary-color);
    font-size: 3rem;
    text-shadow: 3px 3px 0 var(--secondary-color);
    margin-bottom: 10px;
}

.subtitle {
    color: var(--text-color);
    font-size: 1.5rem;
    opacity: 0.8;
}

.nav-tabs {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
}

.tab-btn {
    background-color: var(--secondary-color);
    border: none;
    border-radius: 50px;
    padding: 15px 25px;
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    border-bottom: 4px solid rgba(0, 0, 0, 0.2);
    /* 让 a 标签看起来和 button 一样 */
    text-decoration: none;
    display: inline-block;
}

.tab-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.tab-btn.active {
    background-color: var(--primary-color);
    color: var(--white-color);
    transform: translateY(-2px);
    border-bottom-color: transparent;
}

.content-section {
    background-color: var(--white-color);
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    display: none;
    animation: fadeIn 0.5s ease;
}

.content-section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

h2 {
    color: var(--primary-color);
    font-size: 2.2rem;
    margin-bottom: 15px;
    text-align: center;
}

p.section-intro {
    text-align: center;
    font-size: 1.2rem;
    margin-bottom: 30px;
    color: var(--text-color);
    opacity: 0.9;
}

h3 {
    color: #4db6ac;
    margin: 30px 0 15px;
    font-size: 1.6rem;
    border-left: 5px solid var(--secondary-color);
    padding-left: 15px;
}

h3:first-child {
    margin-top: 0;
}

.pinyin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 20px;
}

.pinyin-card {
    background: var(--card-bg);
    border-radius: 15px;
    padding: 20px 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    border: 2px solid transparent;
}

.pinyin-card:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
    border-color: var(--secondary-color);
}

.pinyin-card .pinyin {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--text-color);
}

.pinyin-card .example-words {
    font-size: 1rem;
    color: #9e9e9e;
    margin-top: 8px;
    height: 2em;
}

.pinyin-card .sound-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    font-size: 1.5rem;
    opacity: 0.5;
    transition: opacity 0.3s;
}

.pinyin-card:hover .sound-btn {
    opacity: 1;
}

/* --- 💡 详情图标样式 --- */
.view-tip-btn {
    position: absolute;
    top: 8px;
    left: 8px;
    font-size: 1.3rem;
    cursor: pointer;
    transition: transform 0.3s ease;
    opacity: 0.5;
    color: #009688;
}

.view-tip-btn:hover {
    transform: scale(1.2);
    opacity: 1;
}

/* --- 声调学习区 --- */
.tone-examples {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    text-align: center;
}

.tone-item {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 15px;
}

.tone-mark {
    font-size: 3rem;
    font-weight: bold;
    margin-bottom: 10px;
}

.tone-name {
    font-size: 1.3rem;
    color: #009688;
    font-weight: bold;
}

.tone-desc {
    font-size: 1rem;
    color: #757575;
    margin-top: 5px;
}

/* --- 游戏区 --- */
#game {
    text-align: center;
}

.game-card {
    background: var(--card-bg);
    border-radius: 15px;
    padding: 30px;
    margin: 20px auto;
    max-width: 600px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.game-question {
    font-size: 5rem;
    margin: 20px 0;
    animation: bounceIn 0.5s;
}

@keyframes bounceIn {

    0%,
    20%,
    40%,
    60%,
    80%,
    100% {
        transition-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
    }

    0% {
        opacity: 0;
        transform: scale3d(.3, .3, .3);
    }

    20% {
        transform: scale3d(1.1, 1.1, 1.1);
    }

    40% {
        transform: scale3d(.9, .9, .9);
    }

    60% {
        opacity: 1;
        transform: scale3d(1.03, 1.03, 1.03);
    }

    80% {
        transform: scale3d(.97, .97, .97);
    }

    100% {
        opacity: 1;
        transform: scale3d(1, 1, 1);
    }
}

.game-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 20px;
}

.game-option {
    background: #e0f7fa;
    border: 2px solid #b2ebf2;
    border-radius: 12px;
    padding: 20px;
    font-size: 1.8rem;
    cursor: pointer;
    transition: all 0.3s;
}

.game-option:hover:not(.disabled) {
    transform: translateY(-5px);
    background: #b2ebf2;
}

.game-option.correct {
    background: var(--correct-color);
    border-color: #69f0ae;
    transform: scale(1.05);
}

.game-option.incorrect {
    background: var(--incorrect-color);
    border-color: #ff8a80;
    opacity: 0.6;
}

.game-option.disabled {
    pointer-events: none;
}

#game-feedback {
    margin-top: 20px;
    height: 3rem;
    font-size: 1.8rem;
    font-weight: bold;
}

#next-question-btn {
    margin-top: 10px;
    padding: 15px 30px;
    font-size: 1.2rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s;
    visibility: hidden;
}

#next-question-btn:hover {
    transform: scale(1.1);
}

footer {
    text-align: center;
    padding: 20px;
    color: var(--white-color);
    font-size: 1rem;
    margin-top: 40px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

/* --- 智能学习提示框样式 --- */
.learning-hint {
    text-align: center;
    margin: -15px auto 25px;
    padding: 12px 25px;
    background-color: rgba(255, 255, 255, 0.75);
    border-radius: 50px;
    max-width: 85%;
    width: fit-content;
    font-size: 1.1rem;
    color: #3b8d99;
    font-weight: bold;
    transition: all 0.5s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

/* --- 🌟 激励系统样式 --- */
.star-counter {
    position: absolute;
    top: 25px;
    right: 30px;
    background-color: #ffd180;
    color: #5d4037;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 1.5rem;
    font-weight: bold;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

.star-counter:hover {
    transform: scale(1.1);
}

.star-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.star-modal-content {
    background: linear-gradient(135deg, #ff8a80, #ffd180);
    padding: 40px;
    border-radius: 30px;
    text-align: center;
    color: white;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    transform: scale(0.5);
    animation: zoomIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.star-modal-content .star {
    font-size: 6rem;
    animation: starShine 1.5s infinite;
}

.star-modal-content p {
    font-size: 2rem;
    font-weight: bold;
    margin-top: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

@keyframes starShine {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.8;
    }

    50% {
        transform: scale(1.2);
        opacity: 1;
    }
}

@keyframes zoomIn {
    from {
        transform: scale(0.5);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* --- 💡 详情弹窗样式 --- */
.modal-backdrop {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-backdrop.visible {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--white-color);
    padding: 25px;
    border-radius: 20px;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 500px;
    position: relative;
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.modal-backdrop.visible .modal-content {
    transform: scale(1);
}

.modal-close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2rem;
    color: #aaa;
    cursor: pointer;
    transition: transform 0.2s, color 0.2s;
}

.modal-close-btn:hover {
    transform: scale(1.2);
    color: var(--primary-color);
}

.modal-header {
    text-align: center;
    margin-bottom: 20px;
}

.modal-pinyin {
    font-size: 4rem;
    font-weight: bold;
    color: var(--primary-color);
}

.modal-words {
    font-size: 1.5rem;
    color: #757575;
}

.modal-body {
    margin-top: 20px;
}

.modal-tip {
    font-size: 1.2rem;
    line-height: 1.6;
    background-color: #f5f5f5;
    padding: 15px;
    border-radius: 10px;
    text-align: left;
}

.modal-tip::before {
    content: '💡 ';
}

/* --- 🎮 游戏反馈弹窗样式 --- */
.feedback-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1001;
    animation: fadeIn 0.3s ease;
}

.feedback-modal-content {
    width: 90%;
    max-width: 400px;
    padding: 30px;
    border-radius: 30px;
    text-align: center;
    color: white;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    transform: scale(0.5);
    animation: zoomIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* 答对的样式 */
.feedback-modal-content.correct {
    background: linear-gradient(135deg, #81c784, #a5d6a7);
}

/* 答错的样式 */
.feedback-modal-content.incorrect {
    background: linear-gradient(135deg, #e57373, #ef9a9a);
}

.feedback-modal-icon {
    font-size: 5rem;
}

.feedback-modal-title {
    font-size: 2rem;
    font-weight: bold;
    margin-top: 15px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.feedback-modal-explanation {
    font-size: 1.2rem;
    margin-top: 10px;
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

/* --- 🎮 拼写游戏新样式 --- */
.spell-answer-area {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin: 20px 0;
    padding-bottom: 20px;
    border-bottom: 2px dashed var(--secondary-color);
}

.spell-syllable-group {
    display: flex;
    gap: 5px;
}

.spell-slot {
    width: 50px;
    height: 60px;
    background-color: #e9ecef;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    font-weight: bold;
    color: var(--text-color);
    border-bottom: 4px solid #ced4da;
}

.spell-slot.filled {
    background-color: var(--secondary-color);
    border-bottom-color: #f7b731;
}

.tile-bank {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin: 20px 0;
}

.spell-tile {
    padding: 10px 18px;
    background-color: var(--card-bg);
    border: 2px solid #dee2e6;
    border-radius: 10px;
    font-size: 1.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px #ced4da;
}

.spell-tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px #ced4da;
}

.spell-tile:active {
    transform: translateY(2px);
    box-shadow: 0 2px #ced4da;
}

.spell-tile.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.spell-actions {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    gap: 20px;
}

.spell-actions button {
    padding: 15px 30px;
    font-size: 1.2rem;
    color: white;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-family);
}

.spell-delete-btn {
    background-color: #ffc107;
}

.spell-check-btn {
    background-color: #28a745;
}

.spell-actions button:hover {
    transform: scale(1.05);
}

/* --- 移动端响应式布局 --- */
@media (max-width: 768px) {
    body {
        /* 增加底部内边距，为固定按钮留出空间 */
        padding: 10px 10px 60px 10px; 
    }

    header {
        padding: 10px;
        margin-bottom: 20px;
    }

    h1 {
        font-size: 2.5rem;
    }

    .subtitle {
        font-size: 1.2rem;
    }

    .nav-tabs {
        justify-content: flex-start;
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 10px; /* 防止滚动条遮挡 */
        -ms-overflow-style: none;
        scrollbar-width: none;
    }

    .nav-tabs::-webkit-scrollbar {
        display: none;
    }

    .tab-btn {
        flex-shrink: 0;
        padding: 12px 20px;
        font-size: 1rem;
    }

    .pinyin-grid {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
        gap: 15px;
    }

    .pinyin-card .pinyin {
        font-size: 2rem;
    }

    .game-option {
        padding: 15px;
        font-size: 1.5rem;
    }

    /* --- 核心优化 --- */
    .learning-hint {
        /* 在移动端彻底隐藏提示语 */
        display: none;
    }
    
    .install-btn {
        /* 固定在左下角 */
        position: fixed;
        top: auto;
        left: 10px;
        bottom: 10px;
        font-size: 0.9rem;
        z-index: 100; /* 确保在最上层 */
    }

    .star-counter {
        /* 固定在右下角 */
        position: fixed;
        top: auto;
        right: 10px;
        bottom: 10px;
        font-size: 0.9rem;
        z-index: 100; /* 确保在最上层 */
    }
}

/* --- 锁定状态的导航按钮样式 --- */
.tab-btn.locked {
    opacity: 0.6;
    cursor: not-allowed;
    filter: grayscale(80%);
    pointer-events: none;
    position: relative;
}

.tab-btn.locked::after {
    content: '🔒';
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    font-size: 1rem;
}

/* --- PWA 安装按钮样式 --- */
.install-btn {
    position: absolute;
    top: 25px;
    left: 30px;
    background-color: #84ffff;
    color: var(--text-color);
    border: none;
    border-radius: 20px;
    padding: 8px 15px;
    font-size: 1.1rem;
    font-family: var(--font-family);
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.install-btn:hover {
    transform: scale(1.1);
}

@media (max-width: 768px) {
    .install-btn {
        top: auto;
        left: 10px;
        bottom: 10px;
        font-size: 0.8rem;
    }
}

/* --- 新增：朗读题目按钮样式 --- */
.read-aloud-btn {
    background: none;
    border: none;
    font-size: 1.5rem; /* 放大图标 */
    cursor: pointer;
    margin-left: 10px;
    vertical-align: middle; /* 垂直居中对齐 */
    transition: transform 0.2s ease;
    color: #009688; /* 赋予一个柔和的颜色 */
}

.read-aloud-btn:hover {
    transform: scale(1.2);
}