* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* 移除iOS点击高亮 */
}

body {
    font-family: 'Arial', sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    touch-action: manipulation; /* 优化触摸事件 */
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* 确保移动设备上的视口设置正确 */
@viewport {
    width: device-width;
    initial-scale: 1.0;
    maximum-scale: 1.0;
    user-scalable: no;
}

h1 {
    color: #8B4513;
    margin-bottom: 15px;
    font-size: 1.8em;
    text-align: center;
}

h2 {
    color: #8B4513;
    margin-bottom: 15px;
    font-size: 1.5em;
}

.game-info {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 15px;
    padding: 15px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.game-mode {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 5px 0;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
}

.game-mode select {
    padding: 10px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    background-color: white;
    font-size: 16px;
    min-width: 150px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url('data:image/svg+xml;charset=UTF-8,%3csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22 fill=%22none%22 stroke=%22currentColor%22 stroke-width=%222%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22%3e%3cpolyline points=%226 9 12 15 18 9%3e%3c/polyline%3e%3c/svg%3e');
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 20px;
    cursor: pointer;
}

.game-mode select:focus {
    outline: none;
    border-color: #8B4513;
}

.player-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.2em;
    font-weight: bold;
    justify-content: center;
    width: 100%;
}

.stone {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: inline-block;
    transition: transform 0.1s;
}

.stone:active {
    transform: scale(0.95);
}

.stone.black {
    background-color: #000;
    border: 1px solid #333;
}

.stone.white {
    background-color: #fff;
    border: 1px solid #333;
}

.controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    width: 100%;
}

button {
    padding: 12px 20px;
    background-color: #8B4513;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.2s;
    min-width: 100px;
    touch-action: manipulation;
}

button:hover {
    background-color: #A0522D;
}

button:active {
    transform: scale(0.98);
    background-color: #6B340B;
}

button:hover {
    background-color: #A0522D;
}

button:active {
    transform: translateY(1px);
}

.board-container {
    margin-bottom: 15px;
    background-color: #DEB887;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    position: relative;
    overflow: hidden;
    touch-action: none; /* 防止触摸滚动 */
}

.board {
    width: 100%;
    max-width: 560px;
    aspect-ratio: 1 / 1;
    position: relative;
    background-color: #DEB887;
    border: 1px solid #8B4513;
    margin: 0 auto;
}

.board::before,
.board::after {
    content: '';
    position: absolute;
    background-color: #000;
}

/* 绘制棋盘线条 */
.grid-line {
    position: absolute;
    background-color: #000;
}

.grid-line.horizontal {
    height: 1px;
    width: 100%;
    left: 0;
}

.grid-line.vertical {
    width: 1px;
    height: 100%;
    top: 0;
}

/* 棋盘上的交叉点 */
.intersection {
    position: absolute;
    width: 12px;
    height: 12px;
    cursor: pointer;
    border-radius: 50%;
    z-index: 1;
    transform: translate(-50%, -50%);
}

.intersection:hover,
.intersection:active {
    background-color: rgba(255, 255, 255, 0.4);
    transform: translate(-50%, -50%) scale(1.2);
}

/* 标记星位点 */
.star-point {
    position: absolute;
    width: 8px;
    height: 8px;
    background-color: #000;
    border-radius: 50%;
    z-index: 0;
    transform: translate(-50%, -50%);
}

/* 棋盘上的棋子样式 */
.board .stone {
    position: absolute;
    width: 85%; /* 相对于单元格大小的百分比 */
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    z-index: 2;
    transform: translate(-50%, -50%);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s, box-shadow 0.1s;
    touch-action: manipulation;
}

.board .stone:hover,
.board .stone:active {
    transform: translate(-50%, -50%) scale(1.1);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
}

.captured-stones {
    width: 100%;
    max-width: 600px;
    display: flex;
    justify-content: space-around;
    margin-bottom: 15px;
    padding: 15px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.captured-black,
.captured-white {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1em;
}

.rules {
    width: 100%;
    max-width: 600px;
    padding: 20px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.rules ul {
    list-style-position: inside;
    padding-left: 10px;
}

.rules li {
    margin-bottom: 8px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 5px;
    }
    
    h1 {
        font-size: 1.5em;
        margin-bottom: 10px;
    }
    
    .board-container {
        padding: 8px;
    }
    
    .game-mode select {
        min-width: 120px;
        font-size: 14px;
    }
    
    button {
        padding: 10px 16px;
        font-size: 14px;
        min-width: 80px;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.3em;
    }
    
    .board-container {
        padding: 5px;
    }
    
    .game-info {
        padding: 10px;
        gap: 10px;
    }
    
    .player-indicator {
        font-size: 1em;
    }
    
    .game-mode {
        flex-direction: column;
        align-items: stretch;
    }
    
    .game-mode select {
        width: 100%;
        margin-bottom: 5px;
    }
    
    .controls {
        flex-direction: column;
        gap: 8px;
    }
    
    button {
        width: 100%;
        padding: 12px;
        font-size: 16px;
    }
    
    .rules {
        padding: 15px;
        font-size: 0.9em;
    }
    
    .rules h2 {
        font-size: 1.2em;
    }
    
    /* 优化触摸目标大小 */
    .intersection {
        width: 32px;
        height: 32px;
    }
}

/* 横屏模式优化 */
@media screen and (orientation: landscape) and (max-width: 900px) {
    .container {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        align-items: flex-start;
    }
    
    .game-info {
        width: 45%;
        max-width: none;
        margin-right: 10px;
    }
    
    .board-container {
        width: 50%;
        margin-bottom: 10px;
    }
    
    .captured-stones {
        width: 100%;
        max-width: none;
    }
}
