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

body {
    font-family: 'Consolas', monospace;
    background-color: #f5f5f5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* 头部样式 */
.header {
    background: linear-gradient(90deg, #2196F3, #42a5f5);
    width: 100%;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    box-shadow: 0 2px 12px rgba(33, 150, 243, 0.2);
    height: 60px;
}

.header-content {
    max-width: 1400px;
    width: 95%;
    margin: 0 auto;
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo h1 {
    color: #ffffff;
    font-size: 1.5rem;
    font-weight: 500;
    display: flex;
    align-items: center;
}

.logo h1::before {
    content: "{ }";
    font-size: 1.2rem;
    margin-right: 8px;
    color: rgba(255, 255, 255, 0.8);
}

.nav-bar {
    display: flex;
    gap: 1rem;
}

.nav-link {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    font-size: 0.95rem;
    padding: 6px 16px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

.nav-link.active {
    background: linear-gradient(45deg, #FFC107, #FF9800);
    color: #fff;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.3);
}

/* 主容器样式 */
.container {
    flex: 1;
    width: 95%;
    max-width: 1400px;
    margin: 60px auto 100px;
    display: flex;
    flex-direction: column;
    gap: 10px; /* 减小元素间距 */
}

/* 广告横幅 */
.ad-banner {
    width: 100%;
    margin: 10px 0;
}

.ad-banner img {
    width: 100%;
    height: 100px; /* 减小高度 */
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* 控制区域 */
.controls {
    background: #ffffff;
    border-radius: 8px;
    padding: 10px 15px; /* 减小内边距 */
    margin: 5px 0; /* 减小外边距 */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.select-label {
    color: #333;
    font-size: 0.9rem;
    white-space: nowrap;
}

.inline-stats {
    display: flex;
    align-items: center;
    gap: 15px;
    white-space: nowrap;
}

/* 按钮和选择框 */
button, select {
    height: 36px;
    padding: 0 15px;
    border-radius: 4px;
    font-size: 0.9rem;
    border: none;
    background: #2196F3;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

button:hover {
    background: #1976D2;
    transform: translateY(-1px);
}

select {
    background: white;
    color: #333;
    border: 1px solid #2196F3;
    min-width: 120px;
}

#fontSizeControl {
    width: 100px;
    margin: 0 5px;
    vertical-align: middle;
}

/* 代码区域 */
.code-container {
    display: flex;
    gap: 20px;
    margin: 5px 0;
}

.code-display, .input-area {
    flex: 1;
    height: 400px; /* 减小高度 */
    display: flex;
    border-radius: 5px;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    position: relative;
}

.code-display {
    background: #1e1e1e;
    order: 1;
    border: 1px solid #333;
}

.input-area {
    background: white;
    border: 1px solid #ddd;
    order: 2;
}

/* 恢复代码显示区域样式 */
#sourceCode, .colored-code {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 20px 10px;
    margin: 0;
    font-family: 'Consolas', monospace;
    white-space: pre;
    line-height: 20px;
    font-size: 16px;
    color: #d4d4d4;
}

#sourceCode {
    display: none;  /* 隐藏原始代码 */
}

/* 修复行号区域样式 */
.line-numbers {
    width: 50px;
    min-width: 50px;
    padding: 20px 10px;
    text-align: right;
    border-right: 1px solid #333;
    color: #858585;
    user-select: none;
    white-space: pre;
    line-height: 20px;
    height: 100%;
    box-sizing: border-box;
    background: #252525;
    font-family: 'Consolas', monospace;
    overflow-y: hidden;
}

.input-area .line-numbers {
    background: #f5f5f5;
    border-right: 1px solid #ddd;
    color: #666;
}

/* 修复代码内容区域样式 */
.code-content {
    flex: 1;
    position: relative;
    overflow: auto;
    height: 100%;
    background: #1e1e1e;
}

/* 修复代码和高亮显示 */
#sourceCode, .colored-code {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 20px 10px;
    margin: 0;
    font-family: 'Consolas', monospace;
    white-space: pre;
    line-height: 20px;
    font-size: 16px;
    color: #d4d4d4;
}

#userInput {
    width: 100%;
    height: 100%;
    padding: 20px 10px;
    border: none;
    outline: none;
    resize: none;
    font-family: 'Consolas', monospace;
    font-size: 16px;
    line-height: 20px;
}

/* 代码高亮 */
.colored-code .correct { color: #4CAF50; }
.colored-code .incorrect { color: #ff3333; }
.colored-code .untyped { color: #666; }
.colored-code .space { color: #666; }

/* 页脚 */
.footer {
    position: fixed;
    bottom: 0;
    width: 100%;
    background: #333;
    color: white;
    padding: 15px 0;
    text-align: center;
    font-size: 14px;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
}

.footer p { margin: 5px 0; }
.footer a {
    color: #4CAF50;
    text-decoration: none;
}

/* 响应式布局 */
@media (max-width: 768px) {
    .header-content {
        padding: 0 15px;
    }
    
    .nav-bar {
        display: none;
    }
    
    .container {
        width: 98%;
        margin-top: 80px;
    }
    
    .controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .code-container {
        flex-direction: column;
    }
    
    .code-display, .input-area {
        height: 300px;
    }
}

/* 排行榜按钮和模态框样式 */
.leaderboard-btn {
    background: #4CAF50;
    margin-left: 10px;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1100;
}

/* 排行榜模态框样式调整 */
.modal-content {
    position: relative;
    background: white;
    margin: 30px auto;
    padding: 20px 30px;
    width: 90%;
    max-width: 900px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    max-height: calc(100vh - 60px);
    overflow-y: auto;
}

.modal-content h2 {
    text-align: center;
    font-size: 1.4rem;
    margin-bottom: 20px;
}

/* 排行榜标签页样式 */
.tab-container {
    display: flex;
    justify-content: center;
    width: 100%;
}

.tab-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.leaderboard-tabs {
    margin-bottom: 20px;
    width: 100%;
}

.tab-group {
    display: flex;
    gap: 10px;
    margin: 0 auto;  /* 使按钮组居中 */
}

.admin-login-btn {
    margin-left: 20px;
    background: #666;
    color: white;
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

.tab-btn {
    padding: 6px 12px;
    font-size: 0.9rem;
}

/* 排行榜表格样式美化 */
#leaderboardTable {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    font-size: 0.9rem;
    background: white;
}

#leaderboardTable th {
    background: #f8f9fa;
    color: #333;
    font-weight: 500;
    padding: 12px;
    text-align: center;
    border-bottom: 2px solid #dee2e6;
}

#leaderboardTable td {
    padding: 10px;
    text-align: center;
    border-bottom: 1px solid #eee;
}

/* 表格行样式 */
#leaderboardTable tr:nth-child(even) {
    background-color: #f8f9fa;
}

#leaderboardTable tr:nth-child(odd) {
    background-color: #ffffff;
}

#leaderboardTable tr:hover {
    background-color: #f1f3f5;
    transition: background-color 0.2s ease;
}

/* 排名样式 */
#leaderboardTable td:first-child {
    font-weight: 500;
}

/* 前三名特殊样式 */
#leaderboardTable tr:nth-child(1) td:first-child {
    color: #ffd700; /* 金牌 */
}

#leaderboardTable tr:nth-child(2) td:first-child {
    color: #c0c0c0; /* 银牌 */
}

#leaderboardTable tr:nth-child(3) td:first-child {
    color: #cd7f32; /* 铜牌 */
}

/* WPM和准确率列样式 */
#leaderboardTable td:nth-child(3),
#leaderboardTable td:nth-child(4) {
    font-family: 'Consolas', monospace;
    font-weight: 500;
}

/* 时间列样式 */
#leaderboardTable td:nth-child(5),
#leaderboardTable td:nth-child(6) {
    font-family: 'Consolas', monospace;
    color: #666;
}

/* 分页样式 */
.pagination {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 15px 0;
}

.pagination button {
    padding: 4px 12px;
    font-size: 0.9rem;
    background: #f0f0f0;
    color: #333;
}

.pagination button.active {
    background: #2196F3;
    color: white;
}

/* 清空按钮容器样式 */
.leaderboard-actions {
    text-align: center;
    margin: 15px 0;
}

.danger-btn {
    font-size: 0.9rem;
    padding: 6px 16px;
}

.danger-btn:hover {
    background: #ff1744;
}

/* 排行榜操作按钮样式 */
.edit-btn, .delete-btn {
    padding: 4px 8px;
    margin: 0 2px;
    font-size: 0.8rem;
    border: none;
    border-radius: 3px;
    cursor: pointer;
}

.edit-btn {
    background: #4CAF50;
    color: white;
}

.delete-btn {
    background: #f44336;
    color: white;
}

.edit-btn:hover {
    background: #45a049;
}

.delete-btn:hover {
    background: #da190b;
}

/* 调整表格最后一列的宽度 */
#leaderboardTable td:last-child {
    white-space: nowrap;
    width: 160px;
}

.admin-login-btn {
    margin-left: auto;
    background: #666;
    color: white;
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

.admin-login-btn:hover {
    background: #555;
}

.close {
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #666;
    width: 30px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    border-radius: 50%;
}

.close:hover {
    background-color: #f0f0f0;
    color: #333;
}

.admin-login-btn {
    background-color: #4a5568;
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
}

.admin-login-btn:hover {
    background-color: #2d3748;
}

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

.pagination button {
    padding: 5px 10px;
    border: 1px solid #ddd;
    background: white;
    cursor: pointer;
}

.pagination button.active {
    background: #4CAF50;
    color: white;
    border-color: #4CAF50;
}

.pagination button:disabled {
    background: #f0f0f0;
    cursor: not-allowed;
}