/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f4f4f4;
}

header {
    background-color: #333;
    color: #fff;
    padding: 1rem;
    text-align: center;
}

header h1 {
    margin-bottom: 0.5rem;
}

nav {
    margin-top: 1rem;
}

nav a {
    color: #fff;
    text-decoration: none;
    margin: 0 1rem;
    padding: 0.5rem 1rem;
    border: 1px solid #fff;
    border-radius: 5px;
    transition: background-color 0.3s;
}

nav a:hover {
    background-color: #555;
}

main {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.hero {
    text-align: center;
    padding: 2rem;
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

.hero h2 {
    margin-bottom: 1rem;
    color: #333;
}

.hero p {
    margin-bottom: 2rem;
    font-size: 1.2rem;
}

.btn {
    display: inline-block;
    background-color: #4CAF50;
    color: white;
    padding: 0.8rem 1.5rem;
    text-decoration: none;
    border-radius: 5px;
    transition: background-color 0.3s;
}

.btn:hover {
    background-color: #45a049;
}

footer {
    text-align: center;
    padding: 1rem;
    background-color: #333;
    color: #fff;
    margin-top: 2rem;
}

/* 表单样式 */
form {
    max-width: 400px;
    margin: 2rem auto;
    padding: 2rem;
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

form h2 {
    text-align: center;
    margin-bottom: 1.5rem;
}

form div {
    margin-bottom: 1rem;
}

form label {
    display: block;
    margin-bottom: 0.5rem;
}

form input[type="text"],
form input[type="password"],
form input[type="email"] {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
}

form button {
    width: 100%;
    padding: 0.8rem;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.3s;
}

form button:hover {
    background-color: #45a049;
}

/* 游戏界面 */
.game-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
    max-width: 600px;
    margin: 2rem auto;
}

.game-tile {
    aspect-ratio: 1;
    background-color: #fff;
    border: 2px solid #ddd;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s;
}

.game-tile:hover {
    border-color: #4CAF50;
}

.game-tile.selected {
    border-color: #FF5722;
    background-color: #ffebee;
}

/* 排行榜 */
.leaderboard {
    max-width: 800px;
    margin: 2rem auto;
}

.leaderboard table {
    width: 100%;
    border-collapse: collapse;
    background-color: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

.leaderboard th,
.leaderboard td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.leaderboard th {
    background-color: #333;
    color: #fff;
}

.leaderboard tr:nth-child(even) {
    background-color: #f9f9f9;
}

/* 新增样式 - 学习平台特色 */

/* 特色功能网格 */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.feature-card {
    background-color: #fff;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    text-align: center;
    transition: transform 0.3s;
}

.feature-card:hover {
    transform: translateY(-5px);
}

.feature-card h4 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: #333;
}

.feature-card p {
    color: #666;
    line-height: 1.6;
}

/* 用户统计 */
.user-stats {
    background-color: #fff;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    margin-top: 2rem;
}

.user-stats p {
    margin: 0.5rem 0;
    font-size: 1.1rem;
}

.user-stats strong {
    color: #4CAF50;
}

/* 练习页面布局 */
.practice-container {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.question-list {
    background-color: #fff;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    max-height: 80vh;
    overflow-y: auto;
}

.question-list h3 {
    margin-bottom: 1rem;
    color: #333;
}

.questions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.question-item {
    border-radius: 5px;
    overflow: hidden;
}

.question-item a {
    display: flex;
    align-items: center;
    padding: 0.8rem;
    text-decoration: none;
    color: #333;
    transition: background-color 0.3s;
}

.question-item a:hover {
    background-color: #f5f5f5;
}

.question-item.completed a {
    background-color: #e8f5e8;
}

.difficulty-badge {
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    font-size: 0.8rem;
    font-weight: bold;
    margin-right: 0.5rem;
}

.difficulty-badge.easy {
    background-color: #4CAF50;
    color: white;
}

.difficulty-badge.medium {
    background-color: #ff9800;
    color: white;
}

.difficulty-badge.hard {
    background-color: #f44336;
    color: white;
}

.question-title {
    flex: 1;
    font-weight: 500;
}

.points {
    color: #4CAF50;
    font-weight: bold;
    margin-left: 0.5rem;
}

.status {
    color: #4CAF50;
    font-weight: bold;
    margin-left: 0.5rem;
}

/* 练习区域 */
.practice-area {
    background-color: #fff;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

.question-header {
    margin-bottom: 2rem;
}

.question-header h2 {
    color: #333;
    margin-bottom: 1rem;
}

.question-meta {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.category {
    background-color: #2196F3;
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    font-size: 0.8rem;
}

.question-description {
    margin-bottom: 2rem;
}

.question-description h3 {
    color: #333;
    margin-bottom: 1rem;
}

.question-description p {
    line-height: 1.6;
    color: #666;
}

/* SQL编辑器 */
.sql-editor-container {
    margin-bottom: 1rem;
}

.sql-editor-container h3 {
    color: #333;
    margin-bottom: 1rem;
}

.CodeMirror {
    border: 1px solid #ddd;
    border-radius: 5px;
    height: 300px;
}

.editor-actions {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

.btn-primary {
    background-color: #4CAF50;
    color: white;
}

.btn-primary:hover {
    background-color: #45a049;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

/* 结果显示 */
.result-container {
    margin-bottom: 2rem;
}

.result-container h3 {
    color: #333;
    margin-bottom: 1rem;
}

.result-output {
    background-color: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 1rem;
    min-height: 100px;
    margin-bottom: 1rem;
}

.result-output pre {
    margin: 0;
    white-space: pre-wrap;
    font-family: 'Courier New', monospace;
}

.result-message {
    padding: 1rem;
    border-radius: 5px;
}

.result-message.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.result-message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.loading {
    text-align: center;
    color: #666;
}

.expected-result {
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 5px;
    padding: 1rem;
}

.expected-result h3 {
    color: #856404;
    margin-bottom: 0.5rem;
}

.expected-result p {
    color: #856404;
    margin: 0;
}

/* 成就页面 */
.achievements-header {
    text-align: center;
    margin-bottom: 2rem;
}

.user-progress {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.progress-item {
    background-color: #fff;
    padding: 1rem;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    text-align: center;
}

.progress-item .label {
    display: block;
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.progress-item .value {
    display: block;
    color: #4CAF50;
    font-size: 1.5rem;
    font-weight: bold;
}

.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.achievement-card {
    background-color: #fff;
    border-radius: 10px;
    padding: 1.5rem;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    position: relative;
    transition: transform 0.3s;
}

.achievement-card:hover {
    transform: translateY(-3px);
}

.achievement-card.earned {
    border: 2px solid #4CAF50;
}

.achievement-card.locked {
    opacity: 0.7;
    border: 2px solid #ddd;
}

.achievement-icon {
    font-size: 2rem;
    margin-bottom: 1rem;
    text-align: center;
}

.achievement-info h4 {
    color: #333;
    margin-bottom: 0.5rem;
}

.achievement-info p {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.achievement-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
}

.achievement-meta .points {
    color: #4CAF50;
    font-weight: bold;
}

.achievement-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: #4CAF50;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.achievement-lock {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 1.2rem;
    color: #999;
}

/* 进度条 */
.progress-section {
    margin-top: 2rem;
}

.progress-bars {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.progress-bar {
    background-color: #fff;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

.progress-label {
    font-weight: bold;
    color: #333;
    margin-bottom: 0.5rem;
}

.progress-track {
    background-color: #e9ecef;
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    background-color: #4CAF50;
    height: 100%;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 0.9rem;
    color: #666;
}

/* 排行榜页面 */
.leaderboard-header {
    text-align: center;
    margin-bottom: 2rem;
}

.current-user-rank {
    background-color: #e3f2fd;
    border: 1px solid #2196F3;
    border-radius: 5px;
    padding: 1rem;
    margin-top: 1rem;
    display: inline-block;
}

.current-user-rank p {
    margin: 0;
    color: #1976d2;
}

.leaderboard-tabs {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.tab-btn {
    padding: 0.8rem 1.5rem;
    border: none;
    background-color: #f8f9fa;
    color: #666;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
}

.tab-btn.active {
    background-color: #4CAF50;
    color: white;
}

.tab-btn:hover {
    background-color: #e9ecef;
}

.tab-btn.active:hover {
    background-color: #45a049;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.leaderboard-table {
    background-color: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

.leaderboard-table table {
    width: 100%;
    border-collapse: collapse;
}

.leaderboard-table th,
.leaderboard-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.leaderboard-table th {
    background-color: #333;
    color: #fff;
}

.leaderboard-table tr:nth-child(even) {
    background-color: #f9f9f9;
}

.leaderboard-table tr.current-user {
    background-color: #e3f2fd;
    font-weight: bold;
}

/* 统计卡片 */
.leaderboard-stats {
    margin-top: 2rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    background-color: #fff;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    text-align: center;
}

.stat-card h4 {
    color: #666;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.stat-number {
    font-size: 2rem;
    font-weight: bold;
    color: #4CAF50;
    margin: 0;
}

/* 欢迎消息 */
.welcome-message {
    text-align: center;
    padding: 3rem;
}

.welcome-message h2 {
    color: #333;
    margin-bottom: 1rem;
}

.welcome-message p {
    color: #666;
    margin-bottom: 2rem;
}

.tips {
    background-color: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 2rem;
    text-align: left;
    max-width: 600px;
    margin: 0 auto;
}

.tips h3 {
    color: #333;
    margin-bottom: 1rem;
}

.tips ul {
    color: #666;
    line-height: 1.8;
}

/* 自适应设计 */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.5rem;
    }

    nav a {
        margin: 0 0.5rem;
        padding: 0.3rem 0.8rem;
        font-size: 0.9rem;
    }

    .hero {
        padding: 1rem;
    }

    .hero h2 {
        font-size: 1.5rem;
    }

    .hero p {
        font-size: 1rem;
    }

    form {
        margin: 1rem auto;
        padding: 1rem;
    }

    .practice-container {
        grid-template-columns: 1fr;
    }

    .question-list {
        max-height: 300px;
    }

    .feature-grid {
        grid-template-columns: 1fr;
    }

    .user-progress {
        grid-template-columns: repeat(2, 1fr);
    }

    .achievements-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .leaderboard-tabs {
        flex-direction: column;
        align-items: center;
    }

    .tab-btn {
        width: 200px;
    }

    .question-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .editor-actions {
        flex-direction: column;
    }

    .CodeMirror {
        height: 200px;
    }
}
