/* 基础样式 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Microsoft YaHei', sans-serif;
    margin: 0;
    background-color: #f0f0f0;
    padding: 20px;
    line-height: 1.6;
}

/* 输入高亮动画 */
.highlight {
    animation: highlightAnimation 1s ease-in-out;
}

@keyframes highlightAnimation {
    0% { background-color: yellow; }
    100% { background-color: white; }
}

/* 主容器 */
.container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

h1 {
    text-align: center;
    margin-bottom: 15px;
}

/* 标签页 */
.tabs {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.tab-btn {
    padding: 10px 20px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: #666;
    transition: all 0.3s;
}

.tab-btn:hover {
    color: #007bff;
}

.tab-btn.active {
    color: #007bff;
    border-bottom-color: #007bff;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

h4 {
    text-align: center;
    margin-bottom: 20px;
}

/* 输入组 */
.input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.input-group input {
    flex: 1;
    min-width: 120px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.input-group button {
    padding: 10px 16px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    white-space: nowrap;
}

.input-group label {
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.input-group button:hover {
    background-color: #0056b3;
}

/* 历史记录和可能性区域 */
.history, .possibilities {
    margin-top: 20px;
    padding: 15px;
    border: 1px solid #eee;
    border-radius: 4px;
}

.history h3, .possibilities h3 {
    margin-bottom: 15px;
}

#historyList {
    list-style-type: none;
}

#historyList li {
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

#historyList li:last-child {
    border-bottom: none;
}

/* 可能答案网格 */
#possibleAnswers {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin-top: 15px;
}

.num-box {
    cursor: pointer;
    border: 1px solid #ccc;
    padding: 10px;
    text-align: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.num-box:hover, .num-box.active {
    background-color: #f0f0f0;
    transform: translateY(-2px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.total-count {
    text-align: center;
    margin: 10px 0 15px;
    color: #666;
    font-size: 0.9rem;
}

.no-results {
    text-align: center;
    padding: 20px;
    color: #666;
    font-style: italic;
    background-color: #f9f9f9;
    border-radius: 4px;
    margin-top: 10px;
}

.more {
    text-align: center;
    padding: 10px;
    color: #666;
    font-size: 0.9rem;
    margin-top: 10px;
}

/* 游戏模式样式 */
.game-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    align-items: center;
}

@media (max-width: 480px) {
    .game-controls {
        flex-direction: column;
    }
    
    .game-controls input,
    .game-controls button {
        width: 100%;
        padding: 12px;
        font-size: 1rem;
    }
    
    .game-history {
        padding: 12px;
    }
    
    .game-history h3 {
        font-size: 1.1rem;
    }
    
    #game-history-list li {
        font-size: 0.9rem;
        padding: 10px 0;
    }
    
    #possibleAnswers {
        gap: 8px;
    }
}

.game-controls input {
    flex: 1;
    min-width: 120px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.game-controls button {
    padding: 10px 16px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    white-space: nowrap;
}

.game-controls button:hover {
    background-color: #0056b3;
}

.game-host-controls {
    width: 100%;
    margin-top: 15px;
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 4px;
    border: 1px dashed #ccc;
}

.host-option {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #666;
    font-size: 0.9rem;
}

.answer-display {
    margin-top: 10px;
    padding: 8px;
    background-color: #e9f5ff;
    border-radius: 4px;
    font-weight: bold;
    text-align: center;
    color: #007bff;
    font-size: 1.2rem;
}

.hidden {
    display: none;
}

/* 模态框样式 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 20px;
    border-radius: 8px;
    width: 300px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.modal-buttons {
    margin-top: 15px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal input[type="text"] {
    width: 100%;
    padding: 8px;
    margin-top: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.game-info {
    width: 100%;
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    color: #666;
}

.game-history {
    margin-top: 20px;
    padding: 15px;
    border: 1px solid #eee;
    border-radius: 4px;
}

.game-history h3 {
    margin-bottom: 15px;
}

#game-history-list {
    list-style-type: none;
}

#game-history-list li {
    padding: 8px 0;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#game-history-list li:last-child {
    border-bottom: none;
}

.use-in-helper {
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 5px 10px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.use-in-helper:hover {
    background-color: #218838;
}

.correct-answer {
    color: #28a745;
    font-weight: bold;
}

/* 错误提示 */
.error {
    color: #dc3545;
    margin: 10px 0;
    padding: 10px;
    background: #f8d7da;
    border-radius: 4px;
}

/* 规则说明样式 */
.rules-section {
    margin-top: 30px;
    display: flex;
    justify-content: space-between;
    background: linear-gradient(135deg, #f6f8f9 0%, #e5ebee 100%);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    border: 1px solid #d1d9e6;
}

.game-rules, .helper-instructions {
    width: 48%;
    background-color: white;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    transition: transform 0.3s ease;
}

.game-rules:hover, .helper-instructions:hover {
    transform: translateY(-5px);
}

.game-rules h3, .helper-instructions h3 {
    color: #007bff;
    border-bottom: 2px solid #007bff;
    padding-bottom: 10px;
    margin-bottom: 15px;
    font-weight: 600;
}

.game-rules ol, .helper-instructions ol {
    padding-left: 25px;
    counter-reset: item;
}

.game-rules li, .helper-instructions li {
    margin-bottom: 12px;
    line-height: 1.6;
    position: relative;
    counter-increment: item;
}

/* .game-rules li::before, .helper-instructions li::before {
    content: counter(item) ".";
    position: absolute;
    left: -25px;
    color: #007bff;
    font-weight: bold;
} */

.game-rules ul, .helper-instructions ul {
    margin-top: 8px;
    padding-left: 25px;
    list-style-type: disc;
}

.game-rules ul li, .helper-instructions ul li {
    margin-bottom: 6px;
}

@media (max-width: 768px) {
    .rules-section {
        flex-direction: column;
        padding: 20px;
    }

    .game-rules, .helper-instructions {
        width: 100%;
        margin-bottom: 20px;
    }
}

/* 移动端适配 */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .container {
        max-width: 100%;
        border-radius: 8px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        padding: 15px;
    }

    h1 {
        font-size: 1.5rem;
        margin: 10px 0 20px;
    }
    
    .tabs {
        flex-wrap: wrap;
    }
    
    .tab-btn {
        flex: 1;
        text-align: center;
        padding: 8px 10px;
    }
    
    .game-controls {
        flex-direction: column;
        gap: 15px;
    }
    
    .game-controls input,
    .game-controls button {
        width: 100%;
        padding: 12px;
        font-size: 1.1rem;
    }
    
    .game-info {
        flex-direction: column;
        gap: 5px;
        align-items: center;
    }
    
    #game-history-list li {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .use-in-helper {
        align-self: flex-end;
    }
    
    /* 移动端输入组垂直排列 */
    .input-group {
        flex-direction: column;
        gap: 15px;
        width: 100%;
        align-items: flex-start;
    }
    
    .input-group input, 
    .input-group button {
        width: 100%;
        padding: 12px;
        font-size: 1.1rem;
        height: auto;
    }
    
    .input-group label {
        margin-top: 5px;
        font-size: 1.1rem;
    }
    
    .input-group label input[type="checkbox"] {
        width: auto;
        height: 18px;
        width: 18px;
        margin-right: 8px;
    }
    
    /* 移动端可能答案改为单列显示 */
    #possibleAnswers {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .num-box {
        padding: 15px;
        font-size: 1.3rem;
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 60px;
        background-color: #f9f9f9;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    }
    
    .history, .possibilities {
        padding: 12px;
        margin-top: 15px;
    }
    
    .history h3, .possibilities h3 {
        font-size: 1.2rem;
        text-align: center;
    }
    
    .history li {
        padding: 8px 0;
        border-bottom: 1px solid #eee;
    }
    
    .history li:last-child {
        border-bottom: none;
    }
    
    .error {
        font-size: 1rem;
        padding: 12px;
    }
}

/* 平板适配 */
@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        max-width: 95%;
        padding: 20px;
    }
    
    .input-group {
        flex-wrap: wrap;
        justify-content: space-between;
    }
    
    .input-group input {
        min-width: 45%;
        flex: 0 0 auto;
    }
    
    .input-group button {
        min-width: 120px;
        flex: 0 0 auto;
    }
    
    #possibleAnswers {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .num-box {
        font-size: 1.1rem;
    }
}

/* 中小屏幕适配 - 处理输入组的过渡布局 */
@media (min-width: 481px) and (max-width: 768px) {
    .input-group {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
    }
    
    .input-group input {
        min-width: 45%;
        flex: 0 0 auto;
    }
    
    .input-group button {
        min-width: 45%;
        flex: 0 0 auto;
        margin-top: 10px;
    }
    
    .input-group label {
        width: 100%;
        margin-top: 10px;
        justify-content: flex-start;
    }
    
    #possibleAnswers {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* 小屏幕手机适配 */
@media (max-width: 480px) {
    .input-group {
        flex-direction: column;
        gap: 8px;
    }
    
    .input-wrap,
    .btn-wrap {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 8px;
    }
    
    .input-group input {
        padding: 12px;
        font-size: 1rem;
    }
    
    .input-group button {
        padding: 14px;
        font-size: 1.1rem;
    }
    
    .num-box {
        width: 100%;
        margin: 2px 0;
        padding: 14px;
        font-size: 1.2rem;
    }
    
    .container {
        padding: 12px;
        margin: 8px;
    }
    
    #possibleAnswers {
        grid-template-columns: 1fr;
    }
    
    .btn-wrap {
        margin-top: 10px;
    }
}
