body {
    font-family: 'Arial', 'Microsoft JhengHei', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #f0e6e6; /* 淺粉色背景 */
    margin: 0;
}

.container {
    text-align: center;
    background: white;
    padding: 30px 50px;
    border-radius: 20px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 700px;
}

h1 {
    color: #ef5350; /* 粉紅色標題 */
    margin-bottom: 30px;
}

.hidden {
    display: none;
}

input[type="text"] {
    padding: 12px;
    margin: 8px;
    border-radius: 8px;
    border: 1px solid #ffcdd2; /* 淡粉色邊框 */
    font-size: 1.1em;
}

button {
    padding: 12px 25px;
    margin: 10px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    background-color: #ef5350; /* 粉紅色按鈕 */
    color: white;
    font-size: 1.1em;
    font-weight: bold;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

    button:hover {
        background-color: #e53935;
        transform: translateY(-2px);
    }

.mode-selection {
    margin-top: 20px;
}

.mode-button {
    background-color: #f06292;
    padding: 15px 30px;
    font-size: 1.2em;
}

    .mode-button:hover {
        background-color: #d81b60;
    }

.game-info p {
    font-size: 1.3em;
    font-weight: bold;
    color: #333;
    margin: 5px 0;
}

.question-visuals {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
    margin: 30px 0;
}

/* 移除原有的圖片容器樣式 */
#image-container {
    display: none;
}

/* 新增圖片容器的樣式 */
.visuals-container {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
    min-height: 80px; /* 確保有足夠的高度，避免內容跳動 */
}

.image-box {
    display: flex;
    flex-wrap: wrap;
    gap: 5px; /* 圖片之間的間距 */
    justify-content: center;
    align-items: center;
    border: 2px solid #a5d6a7;
    border-radius: 10px;
    padding: 10px;
    background-color: #e8f5e9;
    width: 150px; /* 適當調整寬度 */
}

    .image-box img {
        width: 32px;
        height: 32px;
        object-fit: contain;
    }

/* 樹狀圖佈局與樣式 (使用 CSS Grid) */
.tree-diagram-container {
    display: grid;
    grid-template-columns: 1fr 1fr; /* 兩欄 */
    grid-template-rows: auto auto; /* 兩列 */
    gap: 20px;
    width: 200px;
    height: 200px;
    position: relative;
    align-items: center; /* 讓所有子元素在網格內居中 */
    margin: 30px auto; /* 新增此行 */
}

    /* 針對不同模式的佈局調整 */
    .tree-diagram-container.split-mode .total-box {
        grid-column: 1 / span 2; /* 總數框橫跨兩欄 */
        grid-row: 1; /* 位於第一列 */
        justify-self: center;
    }

    .tree-diagram-container.split-mode .part-box {
        grid-row: 2; /* 位於第二列 */
    }

    .tree-diagram-container.split-mode .part-box-1 {
        grid-column: 1 / 2; /* 第一部分在第一欄 */
        justify-self: start;
    }

    .tree-diagram-container.split-mode .part-box-2 {
        grid-column: 2 / 3; /* 第二部分在第二欄 */
        justify-self: end;
    }

    .tree-diagram-container.combine-mode .total-box {
        grid-column: 1 / span 2; /* 總數框橫跨兩欄 */
        grid-row: 2; /* 位於第二列 */
        justify-self: center;
    }

    .tree-diagram-container.combine-mode .part-box {
        grid-row: 1; /* 位於第一列 */
    }

    .tree-diagram-container.combine-mode .part-box-1 {
        grid-column: 1 / 2; /* 第一部分在第一欄 */
        justify-self: start;
    }

    .tree-diagram-container.combine-mode .part-box-2 {
        grid-column: 2 / 3; /* 第二部分在第二欄 */
        justify-self: end;
    }


.answer-box {
    width: 70px;
    height: 70px;
    text-align: center;
    font-size: 2.2em;
    font-weight: bold;
    border: 2px solid #ef9a9a; /* 粉紅色邊框 */
    border-radius: 10px;
    background-color: #ffcdd2; /* 淺粉色背景 */
    transition: background-color 0.3s;
    -moz-appearance: textfield;
}

/* 移除 Chrome, Safari, Edge 的數字輸入框箭頭 */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.answer-box.active-input {
    border-color: #d81b60; /* 點擊時邊框顏色 */
    box-shadow: 0 0 8px #d81b60;
}

.answer-box.disabled-input {
    background-color: #ffebee;
    color: #e53935;
}

/* SVG 連線樣式 */
.connector-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

    .connector-lines line {
        stroke: #d81b60; /* 鮮豔的粉紅色 */
        stroke-width: 4; /* 增加線條粗細 */
    }

#leaderboard-container {
    margin-top: 40px;
    padding-top: 25px;
    border-top: 2px solid #ffcdd2;
}

#leaderboard-list {
    list-style: none;
    padding: 0;
}

    #leaderboard-list li {
        background: #f8e5e5;
        padding: 12px;
        margin-bottom: 10px;
        border-radius: 10px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size: 1.1em;
        color: #444;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    }
