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

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #f5f5f7;
    color: #1d1d1f;
    padding: 0;
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

/* ========== 主容器 ========== */
.container {
    width: 100%;
    max-width: 700px;
    padding: 16px 16px 30px;
    background: #f5f5f7;
    min-height: 100vh;
}

/* ========== 顶部导航（蓝色底色） ========== */
.nav-bar {
    background: #007aff;
    padding: 12px 16px;
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    border-radius: 14px;
    margin-bottom: 16px;
    box-shadow: 0 4px 16px rgba(0, 122, 255, 0.3);
}

.nav-bar a {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    letter-spacing: 0.3px;
}

.nav-bar a:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.nav-bar a.active {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ========== 工具切换（武将按钮） ========== */
.tool-switcher {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin: 8px 0 12px;
    justify-content: center;
}

.tool-btn {
    padding: 8px 20px;
    border: 1.5px solid #e5e5ea;
    background: #fff;
    cursor: pointer;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    color: #1d1d1f;
    transition: all 0.2s ease;
    font-family: inherit;
    letter-spacing: 0.3px;
}

.tool-btn:hover {
    background: #f5f5f7;
    border-color: #c6c6c8;
}

.tool-btn.active {
    background: #007aff;
    color: #fff;
    border-color: #007aff;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.25);
}

/* ========== 统计卡片 ========== */
.stats-card {
    background: #fff;
    border-radius: 14px;
    padding: 16px 18px;
    margin: 10px 0 14px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.stats-card-title {
    font-weight: 600;
    font-size: 15px;
    color: #1d1d1f;
    margin-bottom: 12px;
    letter-spacing: 0.2px;
    text-align: center;
}

.stats-card-title span {
    color: #007aff;
    font-weight: 600;
}

/* ========== 跨组统计表格 ========== */
.stats-table-wrap {
    overflow-x: auto;
    margin: 4px 0;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    text-align: center;
    font-size: 14px;
}

.stats-table th,
.stats-table td {
    padding: 8px 4px;
    border: 1px solid #e5e5ea;
    min-width: 30px;
}

.stats-table th {
    background: #f8f8fa;
    font-weight: 600;
    color: #6e6e73;
    font-size: 13px;
}

.stats-table td {
    font-weight: 700;
    color: #1d1d1f;
}

/* ========== 最新一期频率统计表格 ========== */
.inline-digit-table {
    width: 100%;
    border-collapse: collapse;
    text-align: center;
    margin: 4px 0 8px;
    font-size: 14px;
}

.inline-digit-table th,
.inline-digit-table td {
    padding: 6px 4px;
    border: 1px solid #e5e5ea;
    min-width: 30px;
}

.inline-digit-table th {
    background: #f8f8fa;
    font-weight: 600;
    color: #6e6e73;
    font-size: 13px;
}

.inline-digit-table td {
    font-weight: 700;
    color: #1d1d1f;
}

/* ========== 分组切换按钮（两行居中） ========== */
.group-switcher {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin: 10px 0 12px;
}

.group-switcher .btn-group {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: center;
}

.tab-btn {
    padding: 6px 16px;
    border: 1.5px solid #e5e5ea;
    background: #fff;
    cursor: pointer;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #1d1d1f;
    transition: all 0.2s ease;
    font-family: inherit;
}

.tab-btn:hover {
    background: #f5f5f7;
}

.tab-btn.active {
    background: #007aff;
    color: #fff;
    border-color: #007aff;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.2);
}

/* ========== 视图容器 ========== */
.view-container {
    display: none;
    background: #fff;
    border-radius: 14px;
    padding: 16px 14px 10px;
    margin-top: 12px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.view-container.active {
    display: block;
}

.view-container h3 {
    font-size: 15px;
    font-weight: 600;
    color: #1d1d1f;
    margin: 8px 0 10px;
    letter-spacing: 0.2px;
    text-align: center;
}

/* ========== 历史表格 ========== */
.scrollable-table {
    overflow-x: auto;
    width: 100%;
    margin: 6px 0 4px;
    -webkit-overflow-scrolling: touch;
}

.scrollable-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 500px;
}

.scrollable-table th,
.scrollable-table td {
    text-align: center;
    white-space: nowrap;
    border: 1px solid #e5e5ea;
    padding: 5px 8px;
}

.scrollable-table th {
    background: #f8f8fa;
    font-weight: 600;
    color: #6e6e73;
    font-size: 12px;
    letter-spacing: 0.2px;
    position: sticky;
    top: 0;
    z-index: 5;
}

.scrollable-table td {
    font-size: 13px;
    font-weight: 400;
    color: #1d1d1f;
}

.scrollable-table tr:hover td {
    background: #f8f9fc;
}

/* ========== 正确/错误颜色（只标记错误） ========== */
/* 正确的：普通样式，无特殊标记 */
.correct {
    color: #1d1d1f !important;
    font-weight: 400 !important;
    background: transparent !important;
}

/* 错误的：红色加粗，浅红背景 */
.incorrect {
    color: #ff3b30 !important;
    font-weight: 700 !important;
    background: #ffebea !important;
}

/* ========== 错数高亮 ========== */
.err-highlight {
    color: #ff3b30;
    font-weight: 700;
}

/* ========== 滚动条美化 ========== */
.scrollable-table::-webkit-scrollbar,
.stats-table-wrap::-webkit-scrollbar {
    height: 10px;
}

.scrollable-table::-webkit-scrollbar-track,
.stats-table-wrap::-webkit-scrollbar-track {
    background: #e8e8ed;
    border-radius: 8px;
}

.scrollable-table::-webkit-scrollbar-thumb,
.stats-table-wrap::-webkit-scrollbar-thumb {
    background: #b8b8be;
    border-radius: 8px;
    border: 2px solid #f0f0f2;
    min-height: 30px;
}

.scrollable-table::-webkit-scrollbar-thumb:hover,
.stats-table-wrap::-webkit-scrollbar-thumb:hover {
    background: #8e8e93;
}

/* ========== 移动端适配 ========== */
@media screen and (max-width: 500px) {
    .container {
        padding: 10px 10px 20px;
    }

    .nav-bar {
        padding: 10px 12px;
        border-radius: 12px;
    }

    .nav-bar a {
        font-size: 12px;
        padding: 5px 10px;
    }

    .tool-btn {
        font-size: 12px;
        padding: 6px 14px;
        border-radius: 8px;
    }

    .tab-btn {
        font-size: 11px;
        padding: 4px 12px;
    }

    .stats-table {
        font-size: 12px;
    }

    .stats-table th,
    .stats-table td {
        padding: 5px 2px;
        min-width: 20px;
    }

    .inline-digit-table {
        font-size: 12px;
    }

    .inline-digit-table th,
    .inline-digit-table td {
        padding: 4px 2px;
        min-width: 20px;
    }

    .scrollable-table {
        font-size: 11px;
    }

    .scrollable-table th,
    .scrollable-table td {
        padding: 4px 5px;
        font-size: 11px;
    }

    .stats-card {
        padding: 12px 12px;
    }

    .view-container {
        padding: 12px 10px 6px;
    }

    .group-switcher {
        gap: 4px;
    }

    .scrollable-table::-webkit-scrollbar,
    .stats-table-wrap::-webkit-scrollbar {
        height: 8px;
    }

    .scrollable-table::-webkit-scrollbar-thumb,
    .stats-table-wrap::-webkit-scrollbar-thumb {
        border-width: 1.5px;
        min-height: 24px;
    }
}

@media screen and (max-width: 380px) {
    .nav-bar a {
        font-size: 11px;
        padding: 4px 8px;
    }

    .tool-btn {
        font-size: 11px;
        padding: 5px 10px;
    }

    .stats-table {
        font-size: 10px;
    }

    .stats-table th,
    .stats-table td {
        padding: 3px 1px;
        min-width: 16px;
        font-size: 10px;
    }

    .inline-digit-table {
        font-size: 10px;
    }

    .inline-digit-table th,
    .inline-digit-table td {
        padding: 3px 1px;
        min-width: 16px;
        font-size: 10px;
    }

    .scrollable-table::-webkit-scrollbar,
    .stats-table-wrap::-webkit-scrollbar {
        height: 6px;
    }
}

/* ========== 工具类 ========== */
.text-muted {
    color: #8e8e93;
}

.text-primary {
    color: #007aff;
}

.text-center {
    text-align: center;
}

.mt-8 {
    margin-top: 8px;
}

.mb-8 {
    margin-bottom: 8px;
}

/* ========== 工具通用组件样式 ========== */
.input-container {
    background: #fff;
    padding: 16px;
    border-radius: 14px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    margin-bottom: 16px;
}

.input-group {
    margin-bottom: 15px;
}

.input-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #1d1d1f;
}

.input-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.input-row input,
.input-row textarea {
    flex: 1 1 120px;
    /* Grow, shrink, and base width of 120px */
    padding: 10px;
    border: 1.5px solid #e5e5ea;
    border-radius: 10px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    min-width: 0;
    /* Allow shrinking below content width */
}

.input-row input:focus,
.input-row textarea:focus {
    border-color: #007aff;
}

.collapsible-header {
    background-color: #f8f8fa;
    color: #1d1d1f;
    cursor: pointer;
    border: none;
    text-align: left;
    outline: none;
    font-size: 15px;
    transition: 0.3s;
    margin-top: 10px;
    border-radius: 10px;
    font-weight: 600;
    border-left: 5px solid #007aff;
    margin-bottom: 8px;
    padding: 12px 14px;
}

.collapsible-content {
    display: block;
    padding: 0 10px;
}

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 10px 0;
}

.checkbox-group label {
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-weight: 400;
}

.button-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 8px;
    margin-top: 16px;
}

.filter-btn,
.filter-btn2,
.copy-btn {
    padding: 12px;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.filter-btn {
    background: #007aff;
    color: #fff;
}

.filter-btn2 {
    background: #f2f2f7;
    color: #1d1d1f;
}

.copy-btn {
    background: #34c759;
    color: #fff;
    width: 100%;
}

.filter-btn:active,
.copy-btn:active {
    transform: scale(0.98);
}

#result {
    margin-top: 20px;
    word-break: break-all;
}

.result-header {
    background: #f8f8fa;
    padding: 10px;
    border-radius: 10px 10px 0 0;
    font-weight: 600;
    border-bottom: 1px solid #e5e5ea;
}

.result-content {
    background: #fff;
    padding: 15px;
    border-radius: 0 0 10px 10px;
    border: 1px solid #e5e5ea;
    border-top: none;
    line-height: 1.8;
}

.result-content span {
    display: inline-block;
    background: #f2f2f7;
    padding: 2px 8px;
    margin: 2px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 14px;
}