/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    background-color: #c0c0c0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    text-align: left;
    background-color: #c0c0c0;
    padding: 10px;
    border: 3px solid;
    border-color: #ffffff #808080 #808080 #ffffff;
    width: 100%;
    box-sizing: border-box;
}

/* 主内容区域 - 左右布局 */
.main-content {
    display: flex;
    gap: 20px;
    margin-top: 20px;
}

/* 游戏区域 */
.game-section {
    flex: 0 0 auto;
}

/* 编程区域 */
.coding-section {
    flex: 1;
    min-width: 500px;
}

/* 响应式设计 - 移动设备上垂直布局 */
@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }
    
    .coding-section {
        min-width: auto;
        margin-top: 20px;
    }
    
    .editor-container {
        height: 300px; /* 在移动设备上适当减小高度 */
    }
    
    .CodeMirror {
        height: 300px !important; /* 在移动设备上适当减小高度 */
    }
}

h1 {
    margin-bottom: 20px;
    font-size: 28px;
    color: #000;
}

/* 游戏信息区域 */
.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 10px;
    background-color: #000;
    border: 3px solid;
    border-color: #808080 #ffffff #ffffff #808080;
}

.counter {
    background-color: #000;
    color: #ff0000;
    font-family: 'Courier New', monospace;
    font-size: 24px;
    font-weight: bold;
    padding: 5px 10px;
    min-width: 80px;
    text-align: center;
    border: 2px inset;
}

#reset-button {
    background-color: #c0c0c0;
    font-size: 24px;
    width: 40px;
    height: 40px;
    border: 3px solid;
    border-color: #ffffff #808080 #808080 #ffffff;
    cursor: pointer;
    transition: transform 0.1s;
}

#reset-button:active {
    border-color: #808080 #ffffff #ffffff #808080;
    transform: scale(0.95);
}

/* 难度选择器 */
.difficulty-selector {
    margin-bottom: 15px;
}

.difficulty-btn {
    background-color: #c0c0c0;
    border: 2px solid;
    border-color: #ffffff #808080 #808080 #ffffff;
    padding: 8px 12px;
    margin: 0 5px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.difficulty-btn:hover {
    background-color: #d0d0d0;
}

.difficulty-btn.active {
    background-color: #a0a0a0;
    border-color: #808080 #ffffff #ffffff #808080;
    font-weight: bold;
}

/* 游戏板 */
#game-board {
    display: inline-grid;
    gap: 0;
    background-color: #c0c0c0;
    padding: 10px;
    border: 3px solid;
    border-color: #808080 #ffffff #ffffff #808080;
    margin-bottom: 15px;
}

.cell {
    width: 30px;
    height: 30px;
    border: 2px solid;
    border-color: #ffffff #808080 #808080 #ffffff;
    background-color: #c0c0c0;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.1s;
}

.cell.revealed {
    background-color: #c0c0c0;
    border: 1px solid #808080;
    cursor: default;
}

.cell.flagged {
    background-color: #c0c0c0;
}

.cell.mine {
    background-color: #ff0000;
}

.cell.exploded {
    background-color: #ff0000;
}

/* 数字颜色 */
.cell.number-1 { color: #0000ff; }
.cell.number-2 { color: #008000; }
.cell.number-3 { color: #ff0000; }
.cell.number-4 { color: #000080; }
.cell.number-5 { color: #800000; }
.cell.number-6 { color: #008080; }
.cell.number-7 { color: #000000; }
.cell.number-8 { color: #808080; }

/* 游戏消息 */
#game-message {
    font-size: 18px;
    font-weight: bold;
    margin-top: 10px;
    padding: 10px;
    background-color: #ffffff;
    border: 2px inset;
}

#game-message.visible {
    display: block;
}

#game-message.hidden {
    display: none;
}

/* 编程区域样式 */
.coding-section {
    margin-top: 20px;
    border: 3px solid;
    border-color: #808080 #ffffff #ffffff #808080;
    padding: 15px;
    background-color: #c0c0c0;
}

.coding-controls {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    gap: 10px;
    flex-wrap: wrap;
}

.coding-controls button {
    padding: 8px 15px;
    background-color: #c0c0c0;
    border: 2px solid;
    border-color: #ffffff #808080 #808080 #ffffff;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.2s;
}

.coding-controls button:hover:not(:disabled) {
    background-color: #d0d0d0;
}

.coding-controls button:active:not(:disabled) {
    border-color: #808080 #ffffff #ffffff #808080;
}

.coding-controls button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.execution-status {
    margin-left: auto;
    padding: 8px 12px;
    background-color: #000;
    color: #00ff00;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    border: 2px inset;
}

.editor-container {
    border: 3px solid;
    border-color: #808080 #ffffff #ffffff #808080;
    margin-bottom: 15px;
    background-color: #282a36;
}

.CodeMirror {
    height: 500px !important;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    border: none;
}

.api-docs {
    display: none; /* 默认隐藏API文档 */
    border: 2px inset;
    background-color: #ffffff;
    padding: 10px;
}

.api-docs h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 16px;
    color: #333;
}

.api-content {
    background-color: #f5f5f5;
    padding: 10px;
    border: 1px solid #808080;
    max-height: 300px;
    overflow-y: auto;
}

.api-content pre {
    margin: 0;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.4;
    text-align: left;
}

.api-content code {
    white-space: pre-wrap;
    color: #333;
    text-align: left;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .cell {
        width: 25px;
        height: 25px;
        font-size: 14px;
    }
    
    .counter {
        font-size: 20px;
        min-width: 60px;
    }
    
    h1 {
        font-size: 24px;
    }
    
    .CodeMirror {
        height: 200px !important;
    }
    
    .api-content {
        max-height: 200px;
    }
    
    .coding-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .execution-status {
        margin-left: 0;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .cell {
        width: 20px;
        height: 20px;
        font-size: 12px;
    }
    
    .difficulty-btn {
        font-size: 12px;
        padding: 6px 8px;
        margin: 0 3px;
    }
    
    .container {
        padding: 15px;
    }
    
    .CodeMirror {
        height: 150px !important;
        font-size: 12px;
    }
    
    .api-content {
        max-height: 150px;
    }
    
    .api-content pre {
        font-size: 11px;
    }
}