/* 自定义样式 */

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* 导航链接 */
.nav-link {
    position: relative;
}

.nav-link::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -4px;
    left: 0;
    background-color: currentColor;
    transition: width 0.3s;
}

.nav-link:hover::after {
    width: 100%;
}

/* 游戏画布 */
#game-canvas {
    background-color: #1a1a2e;
    border-radius: 8px;
}

/* 关卡卡片 */
.level-card {
    transition: transform 0.2s, box-shadow 0.2s;
}

.level-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

.level-card.completed {
    border-left: 4px solid #10b981;
}

.level-card.current {
    border-left: 4px solid #f59e0b;
}

.level-card.locked {
    opacity: 0.6;
}

/* 排行榜条目 */
.leaderboard-item {
    transition: background-color 0.2s;
}

.leaderboard-item:hover {
    background-color: #f3f4f6;
}

.leaderboard-item.rank-1 {
    background: linear-gradient(90deg, #fef3c7, transparent);
    border-left: 3px solid #fbbf24;
}

.leaderboard-item.rank-2 {
    background: linear-gradient(90deg, #e5e7eb, transparent);
    border-left: 3px solid #9ca3af;
}

.leaderboard-item.rank-3 {
    background: linear-gradient(90deg, #fed7aa, transparent);
    border-left: 3px solid #f97316;
}

/* 算法列表项 */
.algorithm-item {
    transition: background-color 0.2s;
}

.algorithm-item:hover {
    background-color: #f9fafb;
}

/* 加载动画 */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-spinner {
    border: 3px solid #f3f4f6;
    border-top: 3px solid #3b82f6;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
}

/* 成功/错误提示 */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.alert-success {
    background-color: #d1fae5;
    color: #065f46;
    border-left: 4px solid #10b981;
}

.alert-error {
    background-color: #fee2e2;
    color: #991b1b;
    border-left: 4px solid #ef4444;
}

.alert-info {
    background-color: #dbeafe;
    color: #1e40af;
    border-left: 4px solid #3b82f6;
}

/* 按钮动画 */
.btn {
    transition: all 0.2s;
}

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

.btn:active {
    transform: translateY(0);
}

/* 代码编辑器 */
#algo-code {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
    line-height: 1.5;
    tab-size: 4;
}

/* 滚动条美化 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* 响应式调整 */
@media (max-width: 768px) {
    #game-canvas {
        width: 100%;
        height: auto;
    }

    .level-card {
        margin-bottom: 1rem;
    }
}
