/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Microsoft YaHei', sans-serif;
}

body {
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 15px;
    text-align: center;
    width: 100%;
}

h1 {
    margin-bottom: 20px;
    color: #2c3e50;
    font-size: 1.8rem;
}

h2 {
    margin-bottom: 15px;
    color: #3498db;
    font-size: 1.5rem;
}

button {
    padding: 10px 15px;
    margin: 5px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
    touch-action: manipulation;
}

button:hover {
    background-color: #2980b9;
}

/* 屏幕控制 */
.screen {
    display: none;
    flex-direction: column;
    align-items: center;
    margin-top: 15px;
    width: 100%;
}

.screen.active {
    display: flex;
}

/* 欢迎屏幕 */
.difficulty-selection {
    margin: 15px 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
}

.difficulty-btn {
    min-width: 90px;
    height: 44px;
    margin: 5px;
    flex: 0 0 auto;
}

/* 游戏屏幕 */
.game-info {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 15px;
    font-size: 16px;
    flex-wrap: wrap;
}

.game-info > div {
    margin: 5px;
}

.sudoku-container {
    margin-bottom: 15px;
    width: 100%;
    max-width: 450px;
}

.sudoku-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr);
    width: 100%;
    aspect-ratio: 1 / 1;
    border: 2px solid #2c3e50;
    margin: 0 auto 15px;
}

.cell {
    width: 100%;
    height: 100%;
    border: 1px solid #bdc3c7;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    background-color: white;
    cursor: pointer;
    transition: background-color 0.3s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.cell:hover:not(.given) {
    background-color: #ecf0f1;
}

.cell.selected {
    background-color: #d6eaf8;
}

.cell.given {
    font-weight: bold;
    color: #2c3e50;
    background-color: #eee;
}

.cell.error {
    color: #e74c3c;
}

.cell.hint {
    background-color: #d4efdf;
}

/* 为3x3方格添加边框 */
.cell:nth-child(3n) {
    border-right: 2px solid #2c3e50;
}

.cell:nth-child(9n) {
    border-right: none;
}

.cell:nth-child(n+19):nth-child(-n+27),
.cell:nth-child(n+46):nth-child(-n+54) {
    border-bottom: 2px solid #2c3e50;
}

/* 数字键盘 */
.number-pad {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin: 15px auto 0;
    width: 100%;
    max-width: 450px;
}

.number-btn {
    padding: 0;
    font-size: 18px;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    height: auto;
}

/* 游戏控制 */
.game-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 10px;
    width: 100%;
}

.game-controls button {
    flex: 1 1 calc(50% - 10px);
    max-width: 150px;
    margin: 5px;
}

/* 排行榜屏幕 */
.leaderboard-tabs {
    display: flex;
    margin-bottom: 15px;
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
}

.leaderboard-tab {
    background-color: #ecf0f1;
    color: #333;
    flex: 1 1 auto;
    max-width: 120px;
}

.leaderboard-tab.active {
    background-color: #3498db;
    color: white;
}

.leaderboard-container {
    margin: 15px 0;
    width: 100%;
    max-height: 350px;
    overflow-y: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

thead {
    background-color: #2c3e50;
    color: white;
}

th, td {
    padding: 8px 5px;
    text-align: center;
    border: 1px solid #ddd;
    font-size: 0.9rem;
}

tbody tr:nth-child(even) {
    background-color: #f2f2f2;
}

/* 游戏结束屏幕 */
.game-stats {
    margin: 15px 0;
    font-size: 16px;
}

.name-input {
    margin: 15px 0;
    width: 100%;
    max-width: 300px;
}

.name-input label {
    display: block;
    margin-bottom: 5px;
}

.name-input input {
    padding: 8px;
    font-size: 16px;
    border: 1px solid #ddd;
    border-radius: 4px;
    width: 100%;
    max-width: 250px;
}

#save-score-btn, #play-again-btn, #end-to-menu-btn {
    margin-top: 5px;
    width: 100%;
    max-width: 200px;
}

/* 响应式设计 */
@media screen and (max-width: 480px) {
    .container {
        padding: 10px;
    }
    
    h1 {
        font-size: 1.6rem;
        margin-bottom: 15px;
    }
    
    h2 {
        font-size: 1.3rem;
    }
    
    .cell {
        font-size: 0.9rem;
    }
    
    .number-btn {
        font-size: 16px;
    }
    
    .game-controls button {
        padding: 8px;
        font-size: 14px;
    }
    
    th, td {
        padding: 6px 3px;
        font-size: 0.8rem;
    }
}

@media screen and (max-width: 320px) {
    .number-pad {
        gap: 5px;
    }
    
    .number-btn {
        font-size: 14px;
    }
} 