/* 基础样式 */
body {
    font-family: 'Arial', sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f0f8ff;
    color: #333;
}

.game-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.game-header {
    text-align: center;
    margin-bottom: 20px;
}

.game-header h1 {
    color: #0066cc;
    margin-bottom: 10px;
}

.game-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
}

.game-controls button, 
.game-controls select, 
.game-controls a.help-button,
#start-game,
#toggle-direction {
    padding: 8px 15px;
    border: none;
    border-radius: 4px;
    background-color: #0066cc;
    color: white;
    cursor: pointer;
    font-size: 16px;
    text-decoration: none;
    display: inline-block;
    margin: 0 5px;
    transition: background-color 0.2s ease;
}

#toggle-direction.vertical {
    background-color: #4CAF50;
}

#toggle-direction.vertical::after {
    content: "(垂直)";
}

#toggle-direction.horizontal::after {
    content: "(水平)";
}

#start-game:hover {
    background-color: #0055aa;
}

.game-controls button:hover {
    background-color: #0055aa;
}

/* API Key设置样式 */
.api-key-control {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
    width: 100%;
    max-width: 400px;
}

.api-form {
    display: flex;
    gap: 8px;
    width: 100%;
}

.api-input {
    flex-grow: 1;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    background-color: white;
    color: #333;
}

.api-button {
    padding: 8px 16px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s ease;
}

.api-button:hover {
    background-color: #3e8e41;
}

.api-status {
    font-size: 12px;
    color: #666;
    text-align: center;
    margin-top: 5px;
}

.game-boards {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 30px;
    margin-bottom: 20px;
}

.board-container {
    text-align: center;
}

.board-container h2 {
    margin-bottom: 10px;
    color: #0066cc;
}

.board {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    grid-template-rows: repeat(10, 1fr);
    gap: 1px;
    width: 400px;
    height: 400px;
    background-color: #0066cc;
    border: 2px solid #0066cc;
}

.cell {
    background-color: #e6f2ff;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cell:hover {
    background-color: #cce0ff;
}

.cell.hit {
    background-color: #ff6b6b;
    position: relative;
}

.cell.hit::after {
    content: '✖';
    color: white;
    font-size: 20px;
}

.cell.miss {
    background-color: #d1d1d1;
    position: relative;
}

.cell.miss::after {
    content: '•';
    color: #666;
    font-size: 24px;
    position: absolute;
}

.cell.ship {
    background-color: #a3c2ff;
}

.cell.ship.hit {
    background-color: #ff8c8c;
}

/* 船只放置时的预览样式 */
.cell.ship-preview {
    background-color: rgba(163, 194, 255, 0.5);
}

.cell.ship-preview.invalid {
    background-color: rgba(255, 107, 107, 0.5);
}

.game-status {
    text-align: center;
    margin-top: 20px;
}

#status-message {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 10px;
    min-height: 27px;
}

.score-board {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.score-board span {
    font-size: 16px;
}

/* 战舰选择区域样式 */
.ship-selection {
    text-align: center;
    margin-bottom: 20px;
    padding: 15px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.ship-selection h2 {
    color: #0066cc;
    margin-bottom: 15px;
}

.ship-options {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.ship-option {
    padding: 8px 15px;
    background-color: #e6f2ff;
    border: 2px solid #0066cc;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: bold;
}

.ship-option:hover {
    background-color: #cce0ff;
}

.ship-option.selected {
    background-color: #0066cc;
    color: white;
}

.ship-instruction {
    color: #666;
    font-style: italic;
    margin-top: 10px;
}

/* 战舰样式 */
.cell.ship {
    background-color: #b3d9ff;
    border-color: #0066cc;
}

.cell.ship-horizontal {
    border-right: 3px solid #0066cc;
    border-left: 3px solid #0066cc;
}

.cell.ship-vertical {
    border-top: 3px solid #0066cc;
    border-bottom: 3px solid #0066cc;
}

.cell.ship:first-child {
    border-top-left-radius: 4px;
}

.cell.ship:last-child {
    border-bottom-right-radius: 4px;
}

/* 高亮可放置区域 */
.cell.highlight {
    background-color: rgba(0, 200, 0, 0.3);
    border: 2px dashed #00aa00;
}

/* 拖动相关样式 */
.ship-option {
    cursor: grab;
    user-select: none;
    touch-action: none;
}

.ship-option:active {
    cursor: grabbing;
}

.ship-option.dragging {
    opacity: 0.7;
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.ship-preview {
    background-color: rgba(0, 102, 204, 0.3) !important;
    border: 2px dashed #0066cc !important;
}

.ship-preview.invalid {
    background-color: rgba(255, 0, 0, 0.3) !important;
    border: 2px dashed red !important;
}

/* 响应式设计 */
@media (max-width: 900px) {
    .game-board {
        width: 350px;
        height: 350px;
    }
}

@media (max-width: 768px) {
    .game-boards {
        flex-direction: column;
        align-items: center;
    }
    
    .game-board {
        width: 300px;
        height: 300px;
    }
}

@media (max-width: 480px) {
    .game-board {
        width: 280px;
        height: 280px;
    }
    
    .game-controls {
        flex-direction: column;
        align-items: center;
    }
}

/* 对话区域样式 */
.dialogue-section {
    margin: 20px auto;
    padding: 15px;
    max-width: 800px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.dialogue-section h3 {
    color: #0066cc;
    margin-bottom: 15px;
    text-align: center;
}

.dialogue-history {
    height: 150px;
    overflow-y: auto;
    margin-bottom: 15px;
    padding: 10px;
    background-color: #f9f9f9;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
}

.player-dialogue {
    margin-bottom: 8px;
    padding: 8px 12px;
    background-color: #e6f7ff;
    border-radius: 4px;
    border-left: 3px solid #0066cc;
}

.ai-dialogue {
    margin-bottom: 8px;
    padding: 8px 12px;
    background-color: #f0f0f0;
    border-radius: 4px;
    border-left: 3px solid #666;
}

.dialogue-input {
    display: flex;
    gap: 10px;
}

.dialogue-input input {
    flex-grow: 1;
    padding: 10px 15px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
}

.dialogue-input button {
    padding: 10px 20px;
    background-color: #0066cc;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s ease;
}

.dialogue-input button:hover {
    background-color: #0055aa;
}

/* 响应式调整 */
@media (max-width: 600px) {
    .dialogue-section {
        margin: 15px;
    }
    
    .dialogue-history {
        height: 120px;
    }
    
    .dialogue-input {
        flex-direction: column;
    }
    
    .dialogue-input button {
        width: 100%;
    }
}