/* 基础重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: sans-serif, 'Helvetica Neue', Helvetica, Arial; /* Changed default font */
    background-color: #FFECF5;
    color: #5D3FD3;
    line-height: 1.6;
    overflow-x: hidden;
}

.app-container {
    max-width: 820px; /* Increased max-width to allow 5 columns */
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

/* 哪吒装饰元素 */
.decor {
    position: fixed;
    width: 90px; /* 缩小到90px */
    z-index: 1000;
    opacity: 0.8;
    transition: opacity 0.5s ease;
    cursor: grab;
    background-color: transparent;
}

.decor.dragging {
    cursor: grabbing;
    opacity: 0.9; /* Slightly more opaque while dragging */
}

.left-decor {
    left: 10px;
    top: 10px; /* 移动到左上角 */
    bottom: auto; /* 取消底部定位 */
    transform: rotate(-10deg);
}

.right-decor {
    right: 10px;
    top: 10px;
    transform: rotate(10deg) scaleX(-1); /* 水平翻转 */
}

/* 图片加载动画 */
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.left-decor, .right-decor {
    animation: float 3s ease-in-out infinite;
}

.left-decor {
    animation-delay: 0.5s;
}

.decor-img {
    width: 100%;
    height: auto;
    filter: drop-shadow(0 0 10px rgba(255,107,107,0.5));
}

.decor-tooltip {
    position: absolute;
    bottom: -32px; /* 靠近图片10px (从-40px改为-35px) */
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0,0,0,0.7);
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.8rem;
    white-space: normal;
    text-align: center;
    line-height: 1.2;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    width: 80px; /* 设置固定宽度防止竖排 */
}

header {
    text-align: center;
    margin-bottom: 60px; /* 增加30px下边距 */
    position: relative;
    z-index: 2;
    padding-top: 30px; /* 标题下移30px */
}

header h1 {
    font-size: 3rem; /* 增大字体 */
    color: #FF6B6B;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

/* 其他原有样式保持不变... */
.mode-selection {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: nowrap;
    min-width: 300px;
    transform: translateY(-40px); /* 上移50px (原下移10px改为上移40px) */
}

.mode-btn {
    padding: 15px 30px;
    font-size: 1.4rem; /* 增大字体 */
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    position: relative;
    z-index: 2;
}

.mode-btn:hover {
    transform: scale(1.05);
    background-color: #3e8e41;
}

.card-container {
    display: flex;
    flex-direction: column;
    gap: 30px;
    padding: 20px;
    background-color: transparent;
    position: relative;
    z-index: 2;
}

.card-section h2 {
    color: #FF6B6B;
    margin: 0 auto 15px;
    font-size: 1.5rem;
    text-align: center;
    width: 100%;
}

.card-grid {
    display: grid;
    /* Allow auto-fitting columns based on card size */
    grid-template-columns: repeat(auto-fit, 130px); 
    gap: 20px; 
    justify-content: center; /* Center the grid/cards */
    /* Removed max-width and margin: 0 auto to allow natural expansion */
}

.pinyin-card {
    /* Explicit size for all cards */
    width: 130px; 
    aspect-ratio: 1 / 1; /* Make cards square */
    display: flex; /* Use flexbox for centering content */
    flex-direction: column; /* Stack content vertically */
    justify-content: center; /* Center content vertically */
    align-items: center; /* Center content horizontally */
    /* New default background for learning cards */
    background-color: #E0F7FA; 
    border-radius: 15px;
    padding: 10px; /* Adjusted padding */
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.pinyin-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.pinyin-char {
    font-family: 'SimHei', 'Microsoft YaHei', sans-serif; /* Use Heiti/bold sans-serif */
    font-size: 3rem; /* Further increased size */
    font-weight: bold;
    color: #5D3FD3;
    margin-bottom: 10px; /* Adjusted margin */
}

.pinyin-word {
    font-family: 'KaiTi', 'STKaiti', serif; /* Keep KaiTi for Chinese characters */
    font-size: 1.4rem; /* Further increased size */
    color: #666;
    margin-bottom: 8px; /* Adjusted margin */
}

.pinyin-emoji {
    font-size: 1.5rem;
}

/* 练习模式样式 */
.practice-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0; /* 移除容器内间距 */
}

.practice-grid {
    display: grid;
    grid-template-columns: repeat(3, 130px); 
    gap: 20px; 
    justify-content: center;
    width: auto; 
    max-width: none; 
    aspect-ratio: unset; 
    margin-top: 0; /* 确保网格顶部无额外间距 */
}

/* 练习模式下的卡片样式调整 */
.practice-grid .pinyin-card {
    /* Override background for practice cards */
    background-color: #FFF9C4; 
    cursor: pointer; /* 允许点击，为未来交互做准备 */
}

.refresh-btn {
    padding: 12px 25px;
    font-size: 1.1rem;
    background-color: #FF6B6B;
    color: white;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    transition: background-color 0.3s;
    margin-bottom: 20px; /* 增加按钮下方间距 */
}

.refresh-btn:hover {
    background-color: #e05252;
}

.coming-soon, .error {
    text-align: center;
    font-size: 1.2rem;
    color: #FF6B6B;
    padding: 50px 0;
}

.error {
    color: #FF0000;
    background-color: #FFEEEE;
    border-radius: 10px;
}

footer {
    margin-top: auto;
    text-align: center;
    padding: 20px;
    font-size: 0.9rem;
    color: #666;
    position: relative;
    z-index: 2;
}

/* 响应式设计 */
/* 手机设备 (小于600px) */
@media (max-width: 600px) {
    header h1 {
        font-size: 2.2rem; /* 手机端也增大字体 */
    }
    
    .mode-selection {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        gap: 5px;
    }
    
    .mode-btn {
        width: auto;
        padding: 10px 15px;
        font-size: 1.1rem; /* 手机端也增大字体 */
    }
    /* Ensure learning grid has at least 3 columns on mobile */
     .card-grid {
         grid-template-columns: repeat(3, 1fr);
         gap: 10px;
         padding: 10px; /* 增加内边距 */
         background-color: transparent; /* 移除白色背景 */
     }
     /* Keep practice grid adjustments */
     .practice-grid {
          grid-template-columns: repeat(3, 1fr);
          gap: 10px;
          padding: 10px; /* 增加内边距 */
          background-color: transparent; /* 移除白色背景 */
     }
     .pinyin-card {
         width: 100px; /* 减小卡片宽度 */
         padding: 8px; /* 减小内边距 */
         margin: 3px; /* 减小外边距 */
         background-color: #E0F7FA;
     }
     
     .practice-grid .pinyin-card {
         background-color: #FFF9C4;
     }
     
     .card-grid, .practice-grid {
         gap: 5px; /* 减小网格间距 */
         padding: 5px; /* 减小容器内边距 */
     }

    .pinyin-char {
        font-size: 2.5rem; /* Further increased size for mobile */
    }
    .pinyin-word {
        font-size: 1.2rem; /* Further increased size for mobile */
    }
    
    .decor {
        width: 90px; /* 手机端也缩小到90px */
        opacity: 0.6;
    }
}

/* 平板设备 (601px-1024px) */
@media (min-width: 601px) and (max-width: 1024px) {
    .app-container {
        max-width: 90%;
    }
    /* Let auto-fit handle learning grid columns on tablet */
     .card-grid {
         /* No specific rule needed, auto-fit applies */
         gap: 20px; /* Restore default gap */
         padding: 0; /* Restore default padding */
     }
     /* Keep practice grid adjustments */
     .practice-grid {
         grid-template-columns: repeat(3, 130px);
     }
    .pinyin-card {
        padding: 12px;
    }
    
    .pinyin-char {
        font-size: 2.8rem; /* Further increased size for tablet */
    }
     .pinyin-word {
        font-size: 1.3rem; /* Further increased size for tablet */
    }
    
    .decor {
        width: 90px; /* 平板端也缩小到90px */
    }
}

/* 大屏幕设备 (大于1024px) */
@media (min-width: 1025px) {
     /* Let auto-fit handle learning grid columns on large screens */
     .card-grid {
         /* No specific rule needed, auto-fit applies */
     }
     /* Keep practice grid adjustments */
     .practice-grid {
         grid-template-columns: repeat(3, 130px);
     }
    .decor:hover {
        transform: scale(1.1) rotate(0deg);
        opacity: 1;
    }
}

/* 支持按钮样式 */
.support-container {
    position: relative;
    margin-top: 20px;
    text-align: center;
    width: 100%;
}

#supportBtn {
    padding: 10px 20px;
    background-color: #FF6B6B;
    color: white;
    border: none;
    border-radius: 30px;
    font-size: 0.9rem;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    transition: all 0.3s;
    margin-bottom: 20px;
}

#supportBtn:hover {
    background-color: #e05252;
    transform: translateY(-2px);
}

/* 弹窗样式 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: transparent;
    padding: 0;
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.close {
    position: absolute;
    top: 20px;
    right: 20px;
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #FF6B6B;
}
