/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background-color: #f0f0f0;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 600px;
    margin: 20px auto;
    padding: 20px;
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

/* 标题样式 */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

h1 {
    color: #2c3e50;
    font-size: 28px;
}

h2 {
    color: #34495e;
    margin-bottom: 15px;
    font-size: 20px;
}

/* 排行榜按钮 */
.ranking-btn {
    padding: 10px 20px;
    font-size: 16px;
    border: 2px solid #3498db;
    border-radius: 5px;
    background-color: white;
    color: #3498db;
    cursor: pointer;
    transition: all 0.3s ease;
}

.ranking-btn:hover {
    background-color: #3498db;
    color: white;
}

/* 难度选择区域 */
.difficulty-section {
    margin-bottom: 30px;
    text-align: center;
}

.difficulty-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.difficulty-btn {
    padding: 10px 20px;
    font-size: 16px;
    border: 2px solid #3498db;
    border-radius: 5px;
    background-color: white;
    color: #3498db;
    cursor: pointer;
    transition: all 0.3s ease;
}

.difficulty-btn:hover {
    background-color: #3498db;
    color: white;
}

.difficulty-btn.active {
    background-color: #3498db;
    color: white;
    font-weight: bold;
}

/* 排行榜弹出层 */
.ranking-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
}

.ranking-modal.show {
    display: block;
}

.ranking-modal-content {
    background-color: white;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #888;
    border-radius: 10px;
    width: 80%;
    max-width: 600px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.ranking-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.ranking-modal-header h2 {
    margin: 0;
}

.close-btn {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    background: none;
    border: none;
    cursor: pointer;
}

.close-btn:hover,
.close-btn:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

.ranking-tabs {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 15px;
}

.ranking-tab {
    padding: 8px 16px;
    font-size: 14px;
    border: 2px solid #3498db;
    border-radius: 5px;
    background-color: white;
    color: #3498db;
    cursor: pointer;
    transition: all 0.3s ease;
}

.ranking-tab:hover {
    background-color: #3498db;
    color: white;
}

.ranking-tab.active {
    background-color: #3498db;
    color: white;
    font-weight: bold;
}

.ranking-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 10px;
    background-color: white;
}

.ranking-item {
    display: flex;
    align-items: center;
    padding: 8px;
    border-bottom: 1px solid #eee;
    flex-wrap: wrap;
}

.ranking-item:nth-child(odd) {
    background-color: #f8f9fa;
}

.ranking-item:hover {
    background-color: #e3f2fd;
}

.ranking-number {
    font-weight: bold;
    width: 40px;
    flex-shrink: 0;
}

.ranking-name {
    flex: 1;
    margin: 0 10px;
    font-weight: bold;
}

.ranking-time {
    font-weight: bold;
    color: #27ae60;
    margin: 0 10px;
    flex-shrink: 0;
    width: 80px;
}

.ranking-hint {
    color: #e67e22;
    margin: 0 10px;
    flex-shrink: 0;
    width: 80px;
}

.ranking-date {
    color: #666;
    font-size: 12px;
    flex-shrink: 0;
    width: 150px;
    text-align: right;
}

.ranking-empty {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-style: italic;
}

/* 游戏区域 */
.game-section {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* 数独棋盘 */
.sudoku-board {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr);
    gap: 1px;
    background-color: #333;
    border: 3px solid #333;
    border-radius: 5px;
    margin-bottom: 20px;
    width: 450px;
    height: 450px;
}

.sudoku-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: white;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    position: relative;
}

/* 3x3大格子的边框 */
.sudoku-cell:nth-child(3n) {
    border-right: 2px solid #333;
}

.sudoku-cell:nth-child(9n) {
    border-right: none;
}

.sudoku-cell:nth-child(n+19):nth-child(-n+27),
.sudoku-cell:nth-child(n+46):nth-child(-n+54) {
    border-bottom: 2px solid #333;
}

/* 单元格输入样式 */
.sudoku-cell input {
    width: 100%;
    height: 100%;
    border: none;
    text-align: center;
    font-size: 20px;
    font-weight: bold;
    outline: none;
    cursor: pointer;
    background-color: transparent;
}

/* 初始数字样式 */
.sudoku-cell.fixed input {
    color: #2c3e50;
    font-weight: bold;
    background-color: #f8f9fa;
}

/* 用户输入数字样式 */
.sudoku-cell input {
    color: #3498db;
}

/* 选中单元格样式 */
.sudoku-cell.selected {
    background-color: #e3f2fd;
}

/* 错误数字样式 */
.sudoku-cell.error input {
    color: #e74c3c;
    background-color: #ffebee;
}

/* 备选数字样式 */
.sudoku-cell input[value]:not([value=""]) {
    text-align: center;
}

/* 控制按钮 */
.controls {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.control-btn {
    padding: 10px 20px;
    font-size: 16px;
    border: none;
    border-radius: 5px;
    background-color: #27ae60;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.control-btn:hover {
    background-color: #219a52;
    transform: translateY(-2px);
}

.control-btn:active {
    transform: translateY(0);
}

/* 状态区域 */
.status {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 450px;
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 5px;
    font-size: 16px;
}

#message {
    font-weight: bold;
    color: #27ae60;
}

#timer {
    font-weight: bold;
    color: #3498db;
}

/* 响应式设计 */
@media (max-width: 500px) {
    .container {
        margin: 10px;
        padding: 15px;
    }
    
    h1 {
        font-size: 24px;
    }
    
    .sudoku-board {
        width: 300px;
        height: 300px;
    }
    
    .sudoku-cell input {
        font-size: 16px;
    }
    
    .controls {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .status {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
}