body {
    font-family: Arial, sans-serif;
    padding: 20px;
    background-color: #f4f4f9;
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
}

#controls {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    /* PC: グリッドレイアウトで2列を使用 */
    display: grid;
    grid-template-columns: repeat(2, 1fr); 
    gap: 20px;
    margin-bottom: 20px;
}

/* グラフ設定エリア */
#global-settings {
    grid-column: 1 / 3; /* PCでは2列すべて使用 */
    display: flex;
    flex-wrap: wrap; 
    gap: 15px;
    align-items: center;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

#global-settings .input-group {
    display: flex;
    flex-direction: column;
}

#global-settings input[type="number"] {
    width: 80px;
}

/* ステップ入力エリア */
#stepInputs {
    grid-column: 1 / 3; /* PCでは2列すべて使用 */
    display: flex;
    flex-wrap: wrap; 
    gap: 15px;
}

.input-group {
    display: flex;
    flex-direction: column;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.input-group label {
    font-size: 0.85em;
    color: #555;
    margin-bottom: 4px;
}

/* ボタンエリア */
#actions {
    grid-column: 1 / 3;
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
}

button {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.2s;
}

button:hover {
    opacity: 0.9;
}

#generate-steps {
    background-color: #007bff;
    color: white;
}

#draw-graph {
    background-color: #28a745;
    color: white;
}

#color-faces {
    background-color: #ffc107;
    color: #333;
}

/* SVG表示エリア */
#svgContainer {
    text-align: center;
    /* グラフが画面からはみ出る場合にスクロール可能にする */
    overflow-x: auto; 
    padding: 10px 0;
}

/*
--- モバイル対応 (レスポンシブデザイン) ---
*/

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    /* コントロール全体を単一の列にする */
    #controls {
        grid-template-columns: 1fr;
        padding: 15px;
        gap: 15px;
    }

    #global-settings, 
    #stepInputs,
    #actions {
        grid-column: 1 / 2;
    }

    /* グローバル設定の入力欄を横幅いっぱいに */
    #global-settings .input-group {
        width: 100%;
        box-sizing: border-box;
        flex-direction: row; /* 横並びに戻す */
        justify-content: space-between;
        align-items: center;
    }

    #global-settings input[type="number"] {
        width: 100px;
    }

    /* ステップ入力欄は縦に並ぶように */
    #stepInputs {
        flex-direction: column;
        gap: 10px;
    }

    .input-group {
        width: 100%;
        box-sizing: border-box;
    }
    
    /* ボタンを縦に並べる */
    #actions {
        flex-direction: column;
        gap: 10px;
    }

    button {
        width: 100%;
    }

    /* SVGを画面幅に合わせて縮小するための調整 */
    #svgContainer svg {
        width: 100%; 
        height: auto;
    }
}