* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.container {
    width: 100vw;
    height: 100vh;
    display: grid;
    grid-template-rows: 40% 60%;
    grid-template-columns: 40% 60%;
}

/* 状态显示区域 */
.status-area {
    grid-row: 1;
    grid-column: 1;
    padding: 20px;
    display: grid;
    grid-template-rows: 60% 20% 10%;
    flex-direction: column;
    overflow: auto;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    gap: 10px;
}

.state-display {
    display: grid;
    gap: 10px;
    grid-template-columns: 50% 50%;
}

.current-state, .target-state {
    display: grid;
    flex-direction: column;
    grid-template-rows: 10% 90%;
    justify-items: center;
    align-items: center;
}

.puzzle-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 2px;
    background-color: #ccc;
    padding: 2px;
    margin: 10px 0;
    width: 100%;
    max-width: 50%; /* 使用相对单位 */
    aspect-ratio: 1;
    box-sizing: border-box;
}

.puzzle-grid > div {
    background-color: white;  
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    width: 100%;
    height: 100%;
}

@media (max-width: 600px) {
    .puzzle-grid {
        max-width: 100%;
    }
}

.controls {
    display: grid;
    grid-template-columns: 50% 30% 20%;
}

.controls button {
    cursor: pointer;
    padding: 6px 10px;
    background-color: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.controls button:hover {
    background-color: #e0e0e0;
}

.controls button:active {
    background-color: #d0d0d0;
}

.info {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    justify-self: center;
}

/* 表区域 - 性能优化 */
.tables-area {
    display: flex;
    flex-direction: column;
    grid-row: 1;
    grid-column: 2;
    padding: 20px;
    border-bottom: 1px solid #ccc;
    gap: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    overflow: auto;
}

.table-container {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.table-scroll {
    overflow-x: auto;
    white-space: nowrap;
    border: 2px solid #ccc;
    height: 100%;
    display: flex;
    flex-direction: row; 
    flex-wrap: nowrap; 
    justify-content: flex-start; 
    align-items: center;
    padding: 2px;
    gap: 4px;
    /* 性能优化：添加滚动平滑和GPU加速 */
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    will-change: scroll-position;
    transform: translateZ(0);
}

.table-entry {
    border: 1px solid #ccc;
    display: flex;
    flex-direction: column;
    grid-template-rows: 10% 90%;
    /* 性能优化：限制最小宽度，提高渲染效率 */
    min-width: 70px;
    max-width: 70px;
}

.state-id {
    font-size: 0.5em;
    align-self: center;
    text-align: center;
    padding: 2px;
}

.matrix33 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 3px;
    background-color: #ccc;
    padding: 2px;
    height: 85%;
    aspect-ratio: 1;
}

.matrix33 > div {
    background-color: white;  
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    font-size: 0.8em;
}

/* 搜索树区域 */
.tree-area {
    grid-row: 2;
    grid-column: 1 / span 2;
    padding: 20px;
    position: relative;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
}

.mode-selector {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    background-color: rgba(255, 255, 255, 0.9);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    z-index: 10;
}

.mode-selector label {
    margin-bottom: 5px;
}

.tree-container {
    margin: 0;
    overflow: hidden;
    position: relative; 
}

/* 树节点样式 */
svg {
    width: 97.9vw;
    height: 57vh;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
}

.node rect {
    fill: #fff;
    stroke-width: 1.5px;
    cursor: pointer;
}

.rect-type0 {
    stroke: rgb(192, 192, 192);
}

.rect-type1 {
    stroke: rgb(100, 192, 100);
}

.rect-type2 {
    stroke: rgb(64, 64, 64);
}

.rect-type3 {
    stroke: rgb(64, 140, 64);
}

.rect-type4 {
    stroke: rgb(224, 80, 80);
}

.grid line {
    stroke-width: 1px;
    cursor: pointer;
}

.line-type0 {
    stroke: rgb(192, 192, 192);
}

.line-type1 {
    stroke: rgb(100, 224, 100);
}

.line-type2 {
    stroke: rgb(32, 32, 32);
}

.line-type3 {
    stroke: rgb(80, 160, 80);
}

.line-type4 {
    stroke: rgb(224, 80, 80);
}

.grid text {
    font: 8px sans-serif;
    cursor: pointer;
}

.link {
    fill: none;
    stroke: #ccc;
    stroke-width: 1.5px;
}

/* 提示信息 */
.table-entry.info-message {
    justify-content: center;
    align-items: center;
    background-color: #f8f8f8;
    padding: 5px;
}

/* 加载提示的样式 */
.loading-indicator {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #f0f0f0;
    padding: 5px 10px;
    font-size: 0.8em;
    color: #666;
    border-left: 1px solid #ccc;
    min-width: 100px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}