body {
    font-family: 'Arial', sans-serif;
    background-color: #f4f7fb;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 100vh;
}

h1 {
    color: #333;
    margin-top: 20px;
    font-size: 2rem;
    font-weight: bold;
}

/* === 按钮统一样式优化开始 === */

/* 通用按钮基础样式 */
button,
#importSudokuFromString,
.controls button,
.clear-buttons button,
.variant-controls button {
    padding: 8px 12px;
    background-color: #9c27b0;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transition: background-color 0.3s ease, transform 0.2s ease;
}

button:hover,
#importSudokuFromString:hover,
.controls button:hover,
.clear-buttons button:hover,
.variant-controls button:hover {
    background-color: #7b1fa2;
    transform: translateY(-1px);
}

/* 按钮颜色分类（通过选择器识别） */
button {
    background-color: #4CAF50;
}
button:hover {
    background-color: #45a049;
}

#importSudokuFromString {
    background-color: #4CAF50;
}
#importSudokuFromString:hover {
    background-color: #45a049;
}

.controls button {
    background-color: #ff9800;
}
.controls button:hover {
    background-color: #e68900;
}

.clear-buttons button {
    background-color: #dc3545;
}
.clear-buttons button:hover {
    background-color: #c82333;
}

.variant-controls button {
    background-color: #9c27b0;
}
.variant-controls button:hover {
    background-color: #7b1fa2;
}

/* 焦点样式 */
button:focus,
#importSudokuFromString:focus,
.controls button:focus,
.clear-buttons button:focus,
.variant-controls button:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(100, 100, 255, 0.2);
}

/* === 按钮统一样式优化结束 === */

.button-container {
    display: flex;
    gap: 15px;
    margin-top: 30px;
    flex-wrap: wrap;
}

#variantCategoryButtons,
#extraButtons {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 10px;
}

#gridDisplay {
    /* margin-top: 20px; */
    position: relative;
    display: flex;
    justify-content: center;
    flex-direction: column;
    align-items: center;
    width: 100%;
}
/* #techniquePanel {
    margin-left: 20px; 
} */

.sudoku-container {
    display: inline-block;
}

.save-image-options {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin-left: 10px;
    font-size: 14px;
    color: #333;
}

.save-image-option {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    user-select: none;
}

.save-image-option input[type="checkbox"] {
    width: 14px;
    height: 14px;
}

.sudoku-grid {
    display: grid;
    gap: 0;
    /* margin-top: 20px; */
}

.sudoku-cell {
position: relative;
display: flex;
justify-content: center;
align-items: center;
width: 60px;
height: 60px;
background-color: #fff;
border-width: 0;

font-size: 24px;
font-weight: bold;
color: #333;
/* cursor: pointer; */
cursor: default;
line-height: 1; /* 添加固定行高 */
box-sizing: border-box;
}

.sudoku-cell input {
    width: 80%;
    height: 80%;
    font-size: 48px;
    text-align: center;
    border: none;
    /* pointer-events: none; */
    pointer-events: auto;
}


.sudoku-cell[style*="background-color: rgb(0, 0, 0)"] input,
.sudoku-cell.missing-cell input {
    background-color: transparent !important;
    color: transparent !important;
    pointer-events: none;
}

.extra-region-cell {
    background-color: var(--gray-cell-bg) !important;
}

:root {
    --gray-cell-bg: #c0c0c0;
    --gray-cell-contrast: #666;
}

/* 统一灰格风格（所有模式复用） */
.gray-cell,
.extra-region-cell,
.renban-cell,
.fortress-cell,
.clone-cell {
    background-color: var(--gray-cell-bg) !important;
    color: inherit;
}

/* 向后兼容：将内联 style 中使用 #e0e0e0 的元素也统一为变量色 */
/* [style*="#c0c0c0"] {
    background-color: var(--gray-cell-bg) !important;
} */

.main-input {
    position: absolute;
    width: 100%;
    height: 100%;
    font-size: 24px;
    text-align: center;
    border: none;
    background: transparent;
    z-index: 2;
    pointer-events: auto;
    transition: all 0.2s ease;
    color: inherit;
    
    line-height: 60px; /* 匹配单元格高度 */
    padding: 0; /* 移除可能的内边距 */
    margin: 0; /* 移除可能的边距 */
    vertical-align: middle; /* 垂直居中 */
}
/* 隐藏输入文字但保留值 */
.hide-input-text {
    color: transparent !important;
    text-shadow: none !important;
    caret-color: #000; /* 保持光标可见 */
    /* Candidate strings must disappear immediately. A color transition here
       briefly exposes the restored value as large blue text before the small
       candidate grid is painted. */
    transition: none !important;
}
.sudoku-cell.no-border {
    border: none !important;
    box-shadow: none !important;
}

.solution-cell {
    color: #187bcd;
    /* background-color: #fff; */
}

.import-container {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    width: 80%;
    max-width: 800px;
}

.import-export-actions {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
    justify-content: center;
}

.import-export-rows {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 0 0 auto;
    margin-left: 84px;
}

.import-export-row {
    display: flex;
    align-items: stretch;
    gap: 10px;
}

.export-text-button-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: 12px;
}

.export-text-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.export-mode-options {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: #333;
}

.export-mode-option {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    user-select: none;
}

.export-mode-option input[type="checkbox"] {
    width: 14px;
    height: 14px;
}

.hidden-date-picker {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

#sudokuString,
#exportedString,
#exportedTextString {
    width: 260px;
    flex: 0 0 260px;
    max-width: min(260px, 100%);
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    box-sizing: border-box;
}

.import-export-row button,
.export-text-button-wrap button {
    white-space: nowrap;
}

#exportStarPicker {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    background-color: #fff;
}

.candidates-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none; /* 默认隐藏 */
    grid-template-columns: repeat(var(--sub-size), 1fr);
    grid-template-rows: repeat(var(--sub-size), 1fr);
    gap: 1px;
    /* Candidate digits must remain readable above variant marks. Marker
       layers currently use z-index values up to 6. Pointer events stay
       disabled so editable marks underneath remain interactive. */
    z-index: 10;
    pointer-events: none;
    /* background-color: #f0f0f0; */
    background-color: transparent;
    padding: 2px;
    box-sizing: border-box;
}
.candidates-cell {
    position: relative;
    display: none;
    justify-content: center;
    align-items: center;
    font-size: 12px;
    color: #000000;
    /* background-color: white; */
    background-color: transparent !important;
    border-radius: 2px;
}

.controls {
    margin-top: 30px;
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.candidate-input:focus {
    outline: none;
    background-color: #e0f7fa;
}

.hidden {
    display: none;
}


/* 当显示候选数时隐藏主输入 */
.sudoku-cell.showing-candidates .main-input {
    display: none;
}

/* 当显示候选数时显示候选网格 */
.sudoku-cell.showing-candidates .candidates-grid {
    display: grid;
}

/* 高亮当前选中的候选数 */
.candidates-cell.highlighted {
    background-color: #e0f7fa;
    font-weight: bold;
}
/* 添加过渡效果 */
.main-input, .candidates-grid {
    transition: all 0.2s ease;
}
/* 结果展示区域样式 */
#resultDisplay {
    margin-top: 20px;
    padding: 15px;
    border-radius: 8px;
    background-color: #f8f9fa;
    width: 80%;
    max-width: 800px;
    text-align: center;
    font-size: 1.1rem;
    min-height: 24px;
    transition: all 0.3s ease;
}

.success {
    color: #28a745;
    background-color: #d4edda;
}

.error {
    color: #dc3545;
    background-color: #f8d7da;
}

.info {
    color: #17a2b8;
    background-color: #d1ecf1;
}

/* 过程日志容器 */
/* #processLogContainer {
    margin-top: 10px;
    width: 80%;
    max-width: 800px;
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 10px;
    max-height: 200px;
    overflow-y: auto;
} */
#processLogContainer {
    position: absolute;
    left: calc(50% + 400px);
    top: 100px;
    width: 300px;
    max-height: 600px;
    overflow-y: auto;
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    z-index: 1000;
}

#processLogContainer div {
    padding: 5px 0;
    border-bottom: 1px solid #eee;
    color: #333;
    font-size: 14px;
    line-height: 1.4;
}

#processLogContainer div:last-child {
    border-bottom: none;
}

.clear-buttons {
    display: flex;
    gap: 10px;
}

.vx-mark {
    position: absolute;
    font-size: 20px;
    font-weight: bold;
    color: black;
    pointer-events: auto;
    z-index: 5;
    background-color: white;
    border-radius: 100%;
    width: 30px;
    height: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}
.vx-mark input {
    background: transparent;
    border: none;
    outline: none;
    text-align: center;
    font-size: 22px;
    width: 28px;
    height: 28px;
    color: #333;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

.variant-controls {
    margin-top: 10px;
    display: flex;
    justify-content: center;  /* 水平居中 */
    align-items: center;      /* 垂直对齐 */
    flex-wrap: wrap;
    gap: 10px;
}

/* 杀手数独虚线边框层 */
.killer-svg {
    z-index: 0;
}

/* 杀手数独和值输入框 */
.killer-sum-input {
    position: absolute;
    width: 20px;
    height: 14px;
    font-size: 14px;
    font-weight: bold;
    text-align: center;
    border: none;
    border-radius: 0;
    background: #fff;
    color: #333;
    z-index: 1;
    pointer-events: auto;
    padding: 0;
    line-height: 14px;
}
.killer-sum-input:focus {
    outline: none;
}
.killer-sum-input::-webkit-inner-spin-button,
.killer-sum-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.killer-sum-input[type="number"] {
    -moz-appearance: textfield;
}

/* 技巧面板 Tab 样式 */
#techniquePanel .tab-btn {
    flex: 1; padding: 8px; border: 1px solid #ccc;
    background: #f0f0f0; cursor: pointer; font-size: 14px; text-align: center;
    transition: background 0.15s;
}
#techniquePanel .tab-btn:hover {
    background: #e0e0e0;
}
#techniquePanel .tab-btn.active {
    background: #4a90d9; color: white; border-bottom-color: #4a90d9;
}

/* 拖拽排序指示器 */
#techniquePanel .drag-over-before {
    border-top: 2px solid #4a90d9 !important;
}
#techniquePanel .drag-over-after {
    border-bottom: 2px solid #4a90d9 !important;
}

/* === 登录/注册覆盖层 === */
#auth-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
#auth-overlay.hidden {
    display: none;
}

.auth-card {
    background: #fff;
    padding: 30px 32px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    width: 320px;
    text-align: center;
}
.auth-card h2 {
    margin: 0 0 18px;
    font-size: 1.3rem;
    color: #333;
}

.auth-tabs {
    display: flex;
    margin-bottom: 16px;
}
.auth-tab {
    flex: 1;
    padding: 8px;
    border: 1px solid #ccc;
    background: #f0f0f0;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    transition: background 0.15s;
}
.auth-tab.active {
    background: #9c27b0;
    color: #fff;
}

#authForm {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
#authForm input {
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
}
#authSubmit {
    padding: 10px;
    font-size: 1rem;
}

.auth-error {
    color: #dc3545;
    font-size: 14px;
    min-height: 18px;
    margin-top: 8px;
}

#logoutBtn {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 10000;
    background-color: #dc3545;
}
