body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    margin: 0;
    padding: 0;
}



#grid {
    display: grid;
    width: 100%;
    height: 100%;
    justify-content: center;
    align-content: center;
}

#grid-container {
    flex: 1;
    /* ✅ 自动填满剩余空间 */
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}


#grid-container {
    flex-grow: 1;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding-bottom: 0;
    height: auto;
    /* ✅ 让它根据内容自动伸展 */
}


.cell {

    position: relative;
    overflow: hidden;
    background-color: rgb(255, 255, 255);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.base-color-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    /* ✅ 图像层应该 z-index 更高 */
    background-color: #fdf6e3;
    /* 可动态设置 */
}

.cell span {
    font-size: 8vh;
    /* 更大字体 */
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cell img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.text-container {
    height: 6%;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #e7e7e7;
    font-size: 2vh;
}

@media screen and (max-width: 600px) {
    .containControls {
        flex-direction: column;
        padding: 2vh 4vw;
        align-items: center;
    }

    #textInput {
        font-size: 1.2rem;
        /* 更适合触控输入 */
        width: 90vw;
        /* 避免贴边 */
        max-width: 100%;
        white-space: normal;
        /* 允许换行 */
        text-align: left;
        /* 更自然的输入体验 */
        padding: 0.5rem 1rem;
        /* 增加触控区域 */
        background-color: rgba(255, 255, 255, 0.05);
        /* 微弱背景提升可见性 */
        border-radius: 8px;
    }
}


.containControls {
    position: relative;
    /* ✅ 改为相对定位 */
    width: 100%;
    display: flex;
    justify-content: center;
    z-index: 9;
    padding: 1vh 0;
}

#controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    font-family: "Noto Sans", "Helvetica Neue", sans-serif;
}

#controls button,
#controls select {
    height: 2.5rem;
    /* 原来是 36px */
    min-width: 3rem;
    /* 原来是 80px */
    padding: 0 0.75rem;
    /* 原来是 12px */
    margin: 0.25rem;
    /* 原来是 4px */
    font-size: 0.875rem;
    /* 原来是 14px */
    border-radius: 0.375rem;
    /* 原来是 6px */
    border: 1px solid #ccc;
    background-color: #f8f8f8;
    cursor: pointer;
    transition: background-color 0.2s ease;
}



#controls button:hover {
    background-color: #e0e0e0;
}

#txtFileInput {
    display: none;
    /* 隐藏原始文件输入框 */
}

input[type="text"],
input[type="number"] {
    font-size: 2vh;
    padding: 1vh;
}

input[type="number"] {
    width: 1.5vw;
    /* 或者用固定像素如 40px */
    font-size: 2vh;
    padding: 0.5vh;
    text-align: center;
}

#popup {
    display: none;
    position: absolute;
    background: #fffff0;
    border: 1px solid #333;
    padding: 1vh;
    z-index: 9;
}

#popup img:hover {
    border: 2px solid #f0f8ff;
}

.scroll-menu {
    position: absolute;
    bottom: 100%;
    /* 从按钮底部向上展开 */
    right: 0;
    background: #f9f9f9;
    border: 1px solid #ccc;
    width: 160px;
    display: none;
    animation: slideUp 0.3s ease-out forwards;
    z-index: 10;
}

.scroll-menu ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.scroll-menu li {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
}

.scroll-menu li:hover {
    background-color: #e6f7ff;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.colorized-result {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}