/* 全局样式 */

body {
    font-family: Arial, sans-serif;
    background-color: #f0f0f0;
    margin: 0;
    padding: 20px;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background-color: #ffffff;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    padding: 20px;
}

.header {
    text-align: center;
    margin-bottom: 20px;
    padding-top: 50px;
    position: relative;
}

.header h1 {
    color: #333;
    margin: 0;
}

.menu {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    padding: 15px;
    margin-bottom: 20px;
    position: relative;
}

.menu h3 {
    margin-top: 0;
    color: #495057;
}

.menu ul {
    list-style-type: none;
    padding: 0;
    margin: 10px 0;
}

.menu li {
    margin: 5px 0;
    color: #6c757d;
}

/* 计算器样式 */

.input-area {
    margin-bottom: 20px;
}

.input-area .button-group {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.input-area label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.input-area input {
    width: 100%;
    padding: 15px 30px 50px 30px;
    font-size: 16px;
    border: 1px solid #ced4da;
    border-radius: 5px;
    box-sizing: border-box;
}

.input-area button {
    margin-top: 10px;
    padding: 10px 20px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
}

.input-area button:hover {
    background-color: #0069d9;
}

/* 计算器布局样式 */
.calculator-layout {
    margin: 20px 0;
    padding: 15px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 5px;
}

.calculator-layout h3 {
    margin-top: 0;
    color: #495057;
    margin-bottom: 15px;
}

/* 新计算器网格布局 */
.calculator-grid-new {
    display: grid;
    grid-template-columns: 3fr 2fr 2fr;
    gap: 10px;
    background-color: #f5e6c1;
    padding: 15px;
    border-radius: 5px;
}

/* 左侧科学函数区域 */
.science-section {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
}

/* 中间数字区域 */
.number-section {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
}

/* 右侧运算符区域 */
.operator-section {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
}

/* 底部功能区域 */
.bottom-section {
    display: grid;
    grid-template-columns: 3fr 2fr 2fr;
    gap: 10px;
    margin-top: 10px;
}

/* 单位转换区域 */
.convert-section {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
}

/* 方程求解区域 */
.equation-section {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
}

/* 其他功能区域 */
.other-section {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
}

/* 底部控制区域 */
.bottom-controls {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin-top: 10px;
}

/* 按钮基础样式 */
.calc-btn {
    padding: 8px 10px;
    font-size: 12px;
    font-weight: bold;
    border: 1px solid #9e8f7a;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    height: 36px;
    box-sizing: border-box;
    white-space: nowrap;
}

.calc-btn:hover {
    opacity: 0.8;
    transform: translateY(-1px);
}

/* 按钮颜色 */
/* 科学函数按钮 - 灰色 */
.science-btn {
    background-color: #C3C3C3;
    color: #333;
}

/* 数字按钮 - 浅灰色 */
.number-btn {
    background-color: #E3E3E3;
    color: #333;
}

/* 运算符按钮 - 蓝色 */
.operator-btn {
    background-color: #97CEF7;
    color: #3F48CC;
}

/* 删除按钮 - 红色 */
.del-btn {
    background-color: #FF7376;
    color: #ED1C42;
}

/* 单位转换按钮 - 浅绿色 */
.convert-btn {
    background-color: #C7CAB5;
    color: #333;
}

/* 方程求解按钮 - 灰绿色 */
.equation-btn {
    background-color: #A3AE9B;
    color: #333;
}

/* 其他功能按钮 - 深灰色 */
.other-btn {
    background-color: #9E9E9E;
    color: #333;
}

/* ANS按钮 - 紫色 */
.ans-btn {
    background-color: #C8BFE7;
    color: #333;
}

/* 等于按钮 - 蓝色 */
.equal-btn {
    background-color: #007BFF;
    color: white;
    font-size: 16px;
}

/* 装饰按钮 - 黑色 */
.decoration-btn {
    background-color: #000000;
    color: white;
}

/* 顶部控制按钮 - 灰色 */
.top-control-btn {
    background-color: #9E9E9E;
    color: #333;
}

/* 内存按钮 - 灰色 */
.memory-btn {
    background-color: #C3C3C3;
    color: #333;
}

/* 顶部控制栏 */
.top-controls {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
    margin-bottom: 10px;
}

.result {
    background-color: #e7f3ff;
    border: 1px solid #b8daff;
    border-radius: 5px;
    padding: 15px;
    margin-top: 20px;
}

.result h3 {
    margin-top: 0;
    color: #004085;
}

.result p {
    margin: 5px 0;
    color: #383d41;
}

.history {
    margin-top: 20px;
}

.history h3 {
    color: #495057;
}

.history-list {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    padding: 10px;
    max-height: 200px;
    overflow-y: auto;
}

.history-item {
    padding: 5px;
    border-bottom: 1px solid #dee2e6;
}

.history-item:last-child {
    border-bottom: none;
}

.usage-guide {
    margin-top: 20px;
}

.usage-guide h3 {
    color: #495057;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 10px;
}

.guide-content h4 {
    color: #007bff;
    margin-top: 15px;
    margin-bottom: 5px;
}

.guide-content p {
    margin: 5px 0;
    line-height: 1.4;
}

.error {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 5px;
    padding: 10px;
    margin-top: 10px;
    color: #721c24;
}

.footer {
    margin-top: 30px;
    text-align: center;
    color: #6c757d;
    font-size: 14px;
}

/* 命令按钮样式 */

.command-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.command-section {
    background-color: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    padding: 10px;
    display: block;
    min-width: 200px;
}

.command-section h4 {
    margin-top: 0;
    color: #495057;
    font-size: 14px;
    margin-bottom: 10px;
}

.command-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.command-buttons button {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 8px 10px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: bold;
    flex: 1 1 auto;
    min-width: 60px;
    max-width: none;
    text-align: center;
    height: 36px;
    box-sizing: border-box;
    white-space: nowrap;
}

.command-buttons button:hover {
    background-color: #e9ecef;
    border-color: #adb5bd;
}

.command-grid > button {
    display: none;
}

/* 命令按钮颜色 */

.command-section:nth-child(1) .command-buttons button {
    background-color: #97CEF7;
    color: #3F48CC;
}

.command-section:nth-child(2) .command-buttons button {
    background-color: #97CEF7;
    color: #3F48CC;
}

.command-section:nth-child(3) .command-buttons button {
    background-color: #C3C3C3;
}

.command-section:nth-child(4) .command-buttons button {
    background-color: #C3C3C3;
}

.command-section:nth-child(5) .command-buttons button {
    background-color: #E3E3E3;
}

.command-section:nth-child(6) .command-buttons button {
    background-color: #C7CAB5;
}

.command-section:nth-child(7) .command-buttons button {
    background-color: #A3AE9B;
}

.command-section:nth-child(8) .command-buttons button {
    background-color: #98B1A9;
}

.command-section:nth-child(9) .command-buttons button {
    background-color: #9E9E9E;
}

.command-section:nth-child(9) .command-buttons button:last-child {
    background-color: #C8BFE7;
}

/* 主菜单样式 */

.main-menu {
    text-align: center;
    padding: 30px;
}

.main-menu h2 {
    margin-bottom: 20px;
    color: #495057;
}

.main-menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-width: 300px;
    margin: 0 auto;
}

.main-menu-button {
    padding: 15px;
    font-size: 18px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s;
    font-weight: bold;
}

.main-menu-button:hover {
    background-color: #0069d9;
}

/* 游戏相关样式 */

.game-menu {
    padding: 20px;
}

.game-menu h2 {
    margin-bottom: 20px;
    color: #495057;
    text-align: center;
}

.game-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 300px;
    margin: 0 auto;
}

.game-button {
    padding: 12px;
    font-size: 16px;
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s;
    font-weight: bold;
}

.game-button:hover {
    background-color: #218838;
}

.game-container {
    padding: 20px;
    text-align: center;
}

.game-container h2 {
    margin-bottom: 20px;
    color: #495057;
}

.game-stats {
    margin: 20px 0;
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 5px;
}

.game-input {
    margin: 20px 0;
}

.game-input input {
    padding: 10px;
    font-size: 16px;
    width: 200px;
    margin-right: 10px;
}

.game-message {
    margin: 20px 0;
    padding: 15px;
    border-radius: 5px;
}

.game-message.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.game-message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.game-message.info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.header button[onclick="showMainMenu()"],
.header button[onclick="showGameMenu()"] {
    position: absolute;
    right: 10px;
    top: 10px;
    background-color: #6c757d;
    padding: 5px 10px;
    font-size: 12px;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
}

/* 数独游戏 */
.sudoku-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 20px 0;
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 5px;
    flex-wrap: wrap;
    gap: 10px;
}

.sudoku-timer, .sudoku-hints-left {
    font-weight: bold;
}

/* 数独提示信息样式 */
.sudoku-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 15px 25px;
    border-radius: 5px;
    font-size: 16px;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sudoku-grid {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

#sudoku-table {
    border-collapse: collapse;
    border: 3px solid #333;
}

#sudoku-table td {
    width: 40px;
    height: 40px;
    text-align: center;
    vertical-align: middle;
    border: 1px solid #ccc;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

#sudoku-table td:hover {
    background-color: #f0f0f0;
}

/* 3x3宫格边框 */
#sudoku-table tr:nth-child(3n) td {
    border-bottom: 2px solid #333;
}

#sudoku-table tr td:nth-child(3n) {
    border-right: 2px solid #333;
}

/* 初始数字（固定） */
.sudoku-fixed {
    color: #0000ff;
    font-weight: bold;
}

/* 用户输入数字 */
.sudoku-user {
    color: #000000;
}

/* 错误数字 */
.sudoku-error {
    color: #ff0000;
    background-color: #ffe6e6;
}

/* 选中单元格 */
.sudoku-selected {
    background-color: #e6f7ff;
}

/* 飞机大作战游戏样式 */
#plane-game {
    max-width: 750px;
}

#plane-game .game-container {
    text-align: center;
}

#plane-canvas {
    display: block;
    margin: 20px auto;
    border-radius: 5px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
    max-width: 100%;
    height: auto;
}

#plane-stats {
    display: flex;
    justify-content: space-around;
    gap: 20px;
    margin-bottom: 10px;
    font-weight: bold;
    font-size: 18px;
    background-color: rgba(0, 0, 0, 0.85);
    color: #00ff88;
    padding: 12px 30px;
    border-radius: 8px;
    position: relative;
    z-index: 10;
    border: 2px solid #00ff88;
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.5);
}

#plane-message {
    margin: 10px 0;
    padding: 15px;
    border-radius: 5px;
}

/* 下拉菜单移动端兼容性修复 */
select {
    -webkit-appearance: menulist;
    -moz-appearance: menulist;
    appearance: menulist;
    cursor: pointer;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    background-color: white;
    font-size: 14px;
    color: #333;
}

select::-ms-expand {
    display: block;
}

select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

select:active, select:hover {
    background-color: #f8f9fa;
}

/* 移动端响应式样式 */
@media (max-width: 768px) {
    body {
        padding: 5px;
        margin: 0;
    }
    
    .container {
        max-width: 100%;
        padding: 10px;
        border-radius: 5px;
    }
    
    .header {
        padding-top: 20px;
        margin-bottom: 10px;
    }
    
    .header h1 {
        font-size: 18px;
    }
    
    /* 计算器输入框 */
    .calculator-input {
        font-size: 18px;
        padding: 10px;
    }
    
    /* 计算器按钮 */
    .calc-btn {
        padding: 6px 5px;
        font-size: 10px;
        height: 30px;
        min-width: 30px;
    }
    
    /* 顶部控制按钮 */
    .top-controls {
        grid-template-columns: repeat(4, 1fr);
        gap: 3px;
    }
    
    /* 计算器主网格 */
    .calculator-grid-new {
        grid-template-columns: 2fr 1.5fr 1.5fr;
        gap: 5px;
        padding: 8px;
    }
    
    /* 科学函数区域 */
    .science-section {
        grid-template-columns: repeat(2, 1fr);
        gap: 3px;
    }
    
    /* 数字区域 */
    .number-section {
        grid-template-columns: repeat(3, 1fr);
        gap: 3px;
    }
    
    /* 运算符区域 */
    .operator-section {
        grid-template-columns: 1fr;
        gap: 3px;
    }
    
    /* 底部功能区域 */
    .bottom-section {
        grid-template-columns: 1fr;
        gap: 5px;
    }
    
    /* 单位转换区域 */
    .convert-section {
        grid-template-columns: repeat(2, 1fr);
        gap: 3px;
    }
    
    /* 方程求解区域 */
    .equation-section {
        grid-template-columns: repeat(2, 1fr);
        gap: 3px;
    }
    
    /* 其他功能区域 */
    .other-section {
        grid-template-columns: repeat(2, 1fr);
        gap: 3px;
    }
    
    /* 底部控制区域 */
    .bottom-controls {
        grid-template-columns: repeat(3, 1fr);
        gap: 5px;
    }
    
    /* 等于按钮 */
    .equal-btn {
        font-size: 14px;
    }
    
    /* 飞机大作战游戏移动端样式 */
    #plane-game {
        max-width: 100%;
    }
    
    #plane-canvas {
        width: 100%;
        max-width: 400px;
        height: auto;
    }
    
    #plane-stats {
        gap: 15px;
        font-size: 14px;
    }
    
    /* 移动端下拉菜单优化 */
    select {
        -webkit-appearance: menulist-button;
        -moz-appearance: menulist-button;
        appearance: menulist-button;
        min-width: 120px;
        padding: 12px 16px;
        font-size: 16px;
        line-height: 1.5;
        min-height: 44px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        cursor: pointer;
    }
    
    /* 移动端按钮点击区域放大 */
    select, button {
        min-height: 44px;
        min-width: 44px;
    }
}