:root {
    --primary-color: #6a5acd;
    --secondary-color: #9370db;
    --accent-color: #ffa500;
    --background-color: #f5f5ff;
    --text-color: #333;
}

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

body {
    font-family: 'Arial', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
}

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    width: 100%;
}

#pet-container {
    flex: 1;
    min-width: 300px;
    background-color: white;
    border-radius: 15px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    padding: 20px;
    margin-bottom: 20px;
}

#challenge-container {
    flex: 2;
    min-width: 300px;
    background-color: white;
    border-radius: 15px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    padding: 20px;
    margin-bottom: 20px;
}

#shop-container {
    width: 100%;
    background-color: white;
    border-radius: 15px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    padding: 20px;
}

/* 头部导航栏 */
.navbar {
    width: 100%;
    background-color: var(--primary-color);
    color: white;
    padding: 15px 20px;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: nowrap;
}

.branding {
    font-size: 1.5rem;
    font-weight: bold;
    flex: 0 0 auto;
    margin-right: 10px;
}

.player-stats {
    display: flex;
    gap: 20px;
    font-size: 1.1rem;
    font-weight: bold;
    justify-content: center;
    flex: 1;
}

.navbar-menu {
    display: flex;
    gap: 20px;
    align-items: center;
    flex: 0 0 auto;
    margin-left: auto;
}

.username {
    margin-left: 10px;
    font-weight: bold;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.navbar-menu button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1rem;
    padding: 5px 10px;
    border-radius: 5px;
}

.navbar-menu button:hover {
    background-color: var(--secondary-color);
}

/* 宠物显示区域 */
.pet-container {
    flex: 1;
    min-width: 300px;
    background-color: white;
    border-radius: 15px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.pet-image {
    width: 200px;
    height: 200px;
    margin-bottom: 20px;
}

.pet-stats {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.stat-bar {
    width: 100%;
    height: 20px;
    background-color: #eee;
    border-radius: 10px;
    position: relative;
    overflow: hidden;
}

.stat-value {
    height: 100%;
    border-radius: 10px;
    transition: width 0.3s ease-in-out;
}

.health-bar .stat-value {
    background-color: #4caf50;
}

.happiness-bar .stat-value {
    background-color: #ff9800;
}

.hunger-bar .stat-value {
    background-color: #f44336;
}

.exp-bar .stat-value {
    background-color: #2196f3;
}

/* 数学题目区 */
.math-challenge {
    flex: 2;
    min-width: 300px;
    background-color: white;
    border-radius: 15px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    padding: 20px;
}

.question {
    font-size: 1.5rem;
    margin-bottom: 20px;
    text-align: center;
}

.options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.option-button {
    padding: 15px;
    border: 2px solid var(--primary-color);
    border-radius: 10px;
    background-color: white;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.option-button:hover {
    background-color: var(--primary-color);
    color: white;
}

/* 商城区域 */
.shop {
    width: 100%;
    background-color: white;
    border-radius: 15px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    padding: 20px;
    margin-top: 20px;
}

.shop-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.shop-tab {
    padding: 10px 15px;
    background-color: #eee;
    border-radius: 5px 5px 0 0;
    cursor: pointer;
}

.shop-tab.active {
    background-color: var(--primary-color);
    color: white;
}

.shop-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
}

.shop-item {
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.shop-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.item-image {
    width: 80px;
    height: 80px;
    margin-bottom: 10px;
}

.item-name {
    font-weight: bold;
    margin-bottom: 5px;
}

.item-price {
    color: var(--accent-color);
    font-weight: bold;
}

/* 按钮样式 */
.button {
    padding: 10px 20px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.2s;
}

.button:hover {
    background-color: var(--secondary-color);
}

/* 升级特效 */
.level-up-effect {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(255, 165, 0, 0.8);
    color: white;
    font-size: 24px;
    font-weight: bold;
    padding: 20px 40px;
    border-radius: 20px;
    animation: levelUpAnimation 2s ease-in-out;
    z-index: 100;
}

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

/* 游戏通知 */
.game-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 15px 20px;
    border-radius: 5px;
    z-index: 1000;
    animation: notificationAnimation 3s ease-in-out;
}

@keyframes notificationAnimation {
    0% {
        opacity: 0;
        transform: translateY(-20px);
    }
    10% {
        opacity: 1;
        transform: translateY(0);
    }
    90% {
        opacity: 1;
        transform: translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateY(-20px);
    }
}

/* 改进答题结果显示样式 */
.result {
    padding: 15px;
    border-radius: 10px;
    margin-top: 20px;
    text-align: center;
    font-weight: bold;
    animation: fadeInResult 0.3s ease-in-out;
}

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

.result.correct {
    background-color: rgba(76, 175, 80, 0.2);
    color: #2e7d32;
}

.result.wrong {
    background-color: rgba(244, 67, 54, 0.2);
    color: #c62828;
}

.result-icon {
    font-size: 24px;
    margin-bottom: 10px;
    display: inline-block;
}

.result-icon.correct {
    color: #4CAF50;
}

.result-icon.wrong {
    color: #F44336;
}

/* 改进选项按钮状态样式 */
.option-button.correct {
    background-color: rgba(76, 175, 80, 0.8) !important;
    color: white !important;
    border-color: #2e7d32 !important;
}

.option-button.wrong {
    background-color: rgba(244, 67, 54, 0.8) !important;
    color: white !important;
    border-color: #c62828 !important;
}

.option-button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* 填空题样式 */
.fill-blank-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
}

.fill-blank-input {
    padding: 10px 15px;
    font-size: 18px;
    border: 2px solid var(--primary-color);
    border-radius: 5px;
    width: 100%;
    text-align: center;
}

.fill-blank-input:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
}

/* 模态框样式 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    max-width: 600px;
    width: 90%;
}

.modal .form-group {
    margin-bottom: 15px;
}

.modal .form-group label {
    display: block;
    margin-bottom: 5px;
}

.modal .form-group input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.modal .form-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.modal .message {
    margin-top: 10px;
    color: #ff4444;
}

.exp-bonus-info {
    color: #ff9900;
    font-weight: bold;
    margin: 5px 0;
}

/* 宠物选择样式 */
.pet-selection {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.pet-option {
    border: 2px solid #ddd;
    border-radius: 10px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 200px;
}

.pet-option:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.pet-option.selected {
    border-color: #4CAF50;
    background-color: rgba(76, 175, 80, 0.1);
}

.pet-option .image-container {
    width: 100%;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
}

.pet-option img {
    max-width: 100%;
    max-height: 80px;
    width: auto;
    height: auto;
    object-fit: contain;
}

.pet-option h3 {
    margin: 5px 0;
    font-size: 16px;
}

.pet-option p {
    font-size: 14px;
    color: #666;
    /* 限制描述文字行数 */
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

/* 玩家信息和经验条 */
.player-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.level-info {
    display: flex;
    flex-direction: column;
    min-width: 150px;
}

.player-exp-bar-container {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 3px;
}

.player-exp-bar {
    flex: 1;
    height: 8px;
    background-color: #eee;
    border-radius: 4px;
    overflow: hidden;
}

.player-exp-bar-fill {
    height: 100%;
    background-color: #2196f3;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.exp-text {
    font-size: 0.8rem;
    color: #666;
}

/* 等级提升通知 */
.notification.level-up {
    background-color: #673ab7;
    color: white;
}

.notification.unlock {
    background-color: #ff9800;
    color: white;
}

/* 添加加载中和错误消息的样式 */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    margin: 10px 0;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error-message {
    background-color: #ffebee;
    color: #d32f2f;
    padding: 15px;
    border-radius: 8px;
    margin: 10px 0;
    text-align: center;
    border-left: 4px solid #d32f2f;
}

/* 添加朗读按钮样式 */
.speak-button {
    background-color: #4a7dff;
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.speak-button:hover {
    background-color: #3a6ae0;
    transform: scale(1.1);
    box-shadow: 0 3px 8px rgba(0,0,0,0.3);
}

.speak-button:active {
    background-color: #2a59cf;
    transform: scale(0.95);
}

/* 选项发音图标样式 */
.option-speak-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
    opacity: 0.6;
    cursor: pointer;
    vertical-align: middle;
    background-color: #4a7dff;
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 0.9rem;
    padding: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.option-speak-icon:hover {
    opacity: 1;
    transform: scale(1.1);
    background-color: #3a6ae0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

/* 单词发音区域样式 */
.word-speak-container {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 10px 0;
    padding: 10px;
    background-color: #f0f8ff;
    border-radius: 8px;
    border: 1px solid #c0d8ff;
}

.word-to-speak {
    font-size: 1.5rem;
    font-weight: bold;
    margin-right: 15px;
    color: #2d5ca3;
}